diff --git a/packages/google-cloud-memcache/.eslintignore b/packages/google-cloud-memcache/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-memcache/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-memcache/.eslintrc.json b/packages/google-cloud-memcache/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-memcache/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-memcache/README.md b/packages/google-cloud-memcache/README.md index f6c2955765c3..7ca048f0777d 100644 --- a/packages/google-cloud-memcache/README.md +++ b/packages/google-cloud-memcache/README.md @@ -110,7 +110,7 @@ More Information: [Google Cloud Platform Launch Stages][launch_stages] ## Contributing -Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-memcache/CONTRIBUTING.md). +Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/CONTRIBUTING.md). Please note that this `README.md` and a variety of configuration files in this repository (including `.nycrc` and `tsconfig.json`) @@ -120,7 +120,7 @@ are generated from a central template. Apache Version 2.0 -See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-memcache/LICENSE) +See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/LICENSE) [shell_img]: https://gstatic.com/cloudssh/images/open-btn.png [projects]: https://console.cloud.google.com/project diff --git a/packages/google-cloud-memcache/protos/protos.d.ts b/packages/google-cloud-memcache/protos/protos.d.ts index 80b207be62df..93e8ed397e22 100644 --- a/packages/google-cloud-memcache/protos/protos.d.ts +++ b/packages/google-cloud-memcache/protos/protos.d.ts @@ -5536,6 +5536,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -5553,6 +5556,9 @@ export namespace google { /** CommonLanguageSettings destinations. */ public destinations: google.api.ClientLibraryDestination[]; + /** CommonLanguageSettings selectiveGapicGeneration. */ + public selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); + /** * Creates a new CommonLanguageSettings instance using the specified properties. * @param [properties] Properties to set @@ -6253,6 +6259,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -6267,6 +6276,9 @@ export namespace google { /** PythonSettings common. */ public common?: (google.api.ICommonLanguageSettings|null); + /** PythonSettings experimentalFeatures. */ + public experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); + /** * Creates a new PythonSettings instance using the specified properties. * @param [properties] Properties to set @@ -6345,6 +6357,118 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + namespace PythonSettings { + + /** Properties of an ExperimentalFeatures. */ + interface IExperimentalFeatures { + + /** ExperimentalFeatures restAsyncIoEnabled */ + restAsyncIoEnabled?: (boolean|null); + + /** ExperimentalFeatures protobufPythonicTypesEnabled */ + protobufPythonicTypesEnabled?: (boolean|null); + + /** ExperimentalFeatures unversionedPackageDisabled */ + unversionedPackageDisabled?: (boolean|null); + } + + /** Represents an ExperimentalFeatures. */ + class ExperimentalFeatures implements IExperimentalFeatures { + + /** + * Constructs a new ExperimentalFeatures. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.PythonSettings.IExperimentalFeatures); + + /** ExperimentalFeatures restAsyncIoEnabled. */ + public restAsyncIoEnabled: boolean; + + /** ExperimentalFeatures protobufPythonicTypesEnabled. */ + public protobufPythonicTypesEnabled: boolean; + + /** ExperimentalFeatures unversionedPackageDisabled. */ + public unversionedPackageDisabled: boolean; + + /** + * Creates a new ExperimentalFeatures instance using the specified properties. + * @param [properties] Properties to set + * @returns ExperimentalFeatures instance + */ + public static create(properties?: google.api.PythonSettings.IExperimentalFeatures): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Encodes the specified ExperimentalFeatures message. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @param message ExperimentalFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.PythonSettings.IExperimentalFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExperimentalFeatures message, length delimited. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @param message ExperimentalFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.PythonSettings.IExperimentalFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExperimentalFeatures + * @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.api.PythonSettings.ExperimentalFeatures; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExperimentalFeatures + * @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.api.PythonSettings.ExperimentalFeatures; + + /** + * Verifies an ExperimentalFeatures 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 an ExperimentalFeatures message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExperimentalFeatures + */ + public static fromObject(object: { [k: string]: any }): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Creates a plain object from an ExperimentalFeatures message. Also converts values to other types if specified. + * @param message ExperimentalFeatures + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.PythonSettings.ExperimentalFeatures, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExperimentalFeatures to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExperimentalFeatures + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + /** Properties of a NodeSettings. */ interface INodeSettings { @@ -6671,6 +6795,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -6685,6 +6812,9 @@ export namespace google { /** GoSettings common. */ public common?: (google.api.ICommonLanguageSettings|null); + /** GoSettings renamedServices. */ + public renamedServices: { [k: string]: string }; + /** * Creates a new GoSettings instance using the specified properties. * @param [properties] Properties to set @@ -7009,6 +7139,109 @@ export namespace google { PACKAGE_MANAGER = 20 } + /** Properties of a SelectiveGapicGeneration. */ + interface ISelectiveGapicGeneration { + + /** SelectiveGapicGeneration methods */ + methods?: (string[]|null); + + /** SelectiveGapicGeneration generateOmittedAsInternal */ + generateOmittedAsInternal?: (boolean|null); + } + + /** Represents a SelectiveGapicGeneration. */ + class SelectiveGapicGeneration implements ISelectiveGapicGeneration { + + /** + * Constructs a new SelectiveGapicGeneration. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.ISelectiveGapicGeneration); + + /** SelectiveGapicGeneration methods. */ + public methods: string[]; + + /** SelectiveGapicGeneration generateOmittedAsInternal. */ + public generateOmittedAsInternal: boolean; + + /** + * Creates a new SelectiveGapicGeneration instance using the specified properties. + * @param [properties] Properties to set + * @returns SelectiveGapicGeneration instance + */ + public static create(properties?: google.api.ISelectiveGapicGeneration): google.api.SelectiveGapicGeneration; + + /** + * Encodes the specified SelectiveGapicGeneration message. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @param message SelectiveGapicGeneration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.ISelectiveGapicGeneration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SelectiveGapicGeneration message, length delimited. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @param message SelectiveGapicGeneration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.ISelectiveGapicGeneration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SelectiveGapicGeneration + * @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.api.SelectiveGapicGeneration; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SelectiveGapicGeneration + * @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.api.SelectiveGapicGeneration; + + /** + * Verifies a SelectiveGapicGeneration 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 SelectiveGapicGeneration message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SelectiveGapicGeneration + */ + public static fromObject(object: { [k: string]: any }): google.api.SelectiveGapicGeneration; + + /** + * Creates a plain object from a SelectiveGapicGeneration message. Also converts values to other types if specified. + * @param message SelectiveGapicGeneration + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.SelectiveGapicGeneration, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SelectiveGapicGeneration to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SelectiveGapicGeneration + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** LaunchStage enum. */ enum LaunchStage { LAUNCH_STAGE_UNSPECIFIED = 0, @@ -7390,6 +7623,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -7420,6 +7654,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -7469,6 +7706,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -7603,6 +7843,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -7644,6 +7887,9 @@ export namespace google { /** DescriptorProto reservedName. */ public reservedName: string[]; + /** DescriptorProto visibility. */ + public visibility: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility); + /** * Creates a new DescriptorProto instance using the specified properties. * @param [properties] Properties to set @@ -8491,6 +8737,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -8517,6 +8766,9 @@ export namespace google { /** EnumDescriptorProto reservedName. */ public reservedName: string[]; + /** EnumDescriptorProto visibility. */ + public visibility: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility); + /** * Creates a new EnumDescriptorProto instance using the specified properties. * @param [properties] Properties to set @@ -9451,6 +9703,9 @@ export namespace google { /** FieldOptions features */ features?: (google.protobuf.IFeatureSet|null); + /** FieldOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** FieldOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); @@ -9506,6 +9761,9 @@ export namespace google { /** FieldOptions features. */ public features?: (google.protobuf.IFeatureSet|null); + /** FieldOptions featureSupport. */ + public featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** FieldOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; @@ -9726,6 +9984,121 @@ export namespace google { */ public static getTypeUrl(typeUrlPrefix?: string): string; } + + /** Properties of a FeatureSupport. */ + interface IFeatureSupport { + + /** FeatureSupport editionIntroduced */ + editionIntroduced?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSupport editionDeprecated */ + editionDeprecated?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSupport deprecationWarning */ + deprecationWarning?: (string|null); + + /** FeatureSupport editionRemoved */ + editionRemoved?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + } + + /** Represents a FeatureSupport. */ + class FeatureSupport implements IFeatureSupport { + + /** + * Constructs a new FeatureSupport. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.FieldOptions.IFeatureSupport); + + /** FeatureSupport editionIntroduced. */ + public editionIntroduced: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSupport editionDeprecated. */ + public editionDeprecated: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSupport deprecationWarning. */ + public deprecationWarning: string; + + /** FeatureSupport editionRemoved. */ + public editionRemoved: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** + * Creates a new FeatureSupport instance using the specified properties. + * @param [properties] Properties to set + * @returns FeatureSupport instance + */ + public static create(properties?: google.protobuf.FieldOptions.IFeatureSupport): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Encodes the specified FeatureSupport message. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @param message FeatureSupport message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.FieldOptions.IFeatureSupport, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FeatureSupport message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @param message FeatureSupport message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.FieldOptions.IFeatureSupport, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FeatureSupport + * @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.protobuf.FieldOptions.FeatureSupport; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FeatureSupport + * @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.protobuf.FieldOptions.FeatureSupport; + + /** + * Verifies a FeatureSupport 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 FeatureSupport message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FeatureSupport + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Creates a plain object from a FeatureSupport message. Also converts values to other types if specified. + * @param message FeatureSupport + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldOptions.FeatureSupport, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FeatureSupport to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FeatureSupport + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } } /** Properties of an OneofOptions. */ @@ -9964,6 +10337,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -9986,6 +10362,9 @@ export namespace google { /** EnumValueOptions debugRedact. */ public debugRedact: boolean; + /** EnumValueOptions featureSupport. */ + public featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; @@ -10578,6 +10957,12 @@ export namespace google { /** FeatureSet jsonFormat */ jsonFormat?: (google.protobuf.FeatureSet.JsonFormat|keyof typeof google.protobuf.FeatureSet.JsonFormat|null); + + /** FeatureSet enforceNamingStyle */ + enforceNamingStyle?: (google.protobuf.FeatureSet.EnforceNamingStyle|keyof typeof google.protobuf.FeatureSet.EnforceNamingStyle|null); + + /** FeatureSet defaultSymbolVisibility */ + defaultSymbolVisibility?: (google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|keyof typeof google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|null); } /** Represents a FeatureSet. */ @@ -10607,6 +10992,12 @@ export namespace google { /** FeatureSet jsonFormat. */ public jsonFormat: (google.protobuf.FeatureSet.JsonFormat|keyof typeof google.protobuf.FeatureSet.JsonFormat); + /** FeatureSet enforceNamingStyle. */ + public enforceNamingStyle: (google.protobuf.FeatureSet.EnforceNamingStyle|keyof typeof google.protobuf.FeatureSet.EnforceNamingStyle); + + /** FeatureSet defaultSymbolVisibility. */ + public defaultSymbolVisibility: (google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|keyof typeof google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility); + /** * Creates a new FeatureSet instance using the specified properties. * @param [properties] Properties to set @@ -10729,6 +11120,116 @@ export namespace google { ALLOW = 1, LEGACY_BEST_EFFORT = 2 } + + /** EnforceNamingStyle enum. */ + enum EnforceNamingStyle { + ENFORCE_NAMING_STYLE_UNKNOWN = 0, + STYLE2024 = 1, + STYLE_LEGACY = 2 + } + + /** Properties of a VisibilityFeature. */ + interface IVisibilityFeature { + } + + /** Represents a VisibilityFeature. */ + class VisibilityFeature implements IVisibilityFeature { + + /** + * Constructs a new VisibilityFeature. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.FeatureSet.IVisibilityFeature); + + /** + * Creates a new VisibilityFeature instance using the specified properties. + * @param [properties] Properties to set + * @returns VisibilityFeature instance + */ + public static create(properties?: google.protobuf.FeatureSet.IVisibilityFeature): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Encodes the specified VisibilityFeature message. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @param message VisibilityFeature message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.FeatureSet.IVisibilityFeature, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified VisibilityFeature message, length delimited. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @param message VisibilityFeature message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.FeatureSet.IVisibilityFeature, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns VisibilityFeature + * @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.protobuf.FeatureSet.VisibilityFeature; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns VisibilityFeature + * @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.protobuf.FeatureSet.VisibilityFeature; + + /** + * Verifies a VisibilityFeature 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 VisibilityFeature message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns VisibilityFeature + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Creates a plain object from a VisibilityFeature message. Also converts values to other types if specified. + * @param message VisibilityFeature + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FeatureSet.VisibilityFeature, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this VisibilityFeature to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for VisibilityFeature + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace VisibilityFeature { + + /** DefaultSymbolVisibility enum. */ + enum DefaultSymbolVisibility { + DEFAULT_SYMBOL_VISIBILITY_UNKNOWN = 0, + EXPORT_ALL = 1, + EXPORT_TOP_LEVEL = 2, + LOCAL_ALL = 3, + STRICT = 4 + } + } } /** Properties of a FeatureSetDefaults. */ @@ -10848,8 +11349,11 @@ export namespace google { /** FeatureSetEditionDefault edition */ edition?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); - /** FeatureSetEditionDefault features */ - features?: (google.protobuf.IFeatureSet|null); + /** FeatureSetEditionDefault overridableFeatures */ + overridableFeatures?: (google.protobuf.IFeatureSet|null); + + /** FeatureSetEditionDefault fixedFeatures */ + fixedFeatures?: (google.protobuf.IFeatureSet|null); } /** Represents a FeatureSetEditionDefault. */ @@ -10864,8 +11368,11 @@ export namespace google { /** FeatureSetEditionDefault edition. */ public edition: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); - /** FeatureSetEditionDefault features. */ - public features?: (google.protobuf.IFeatureSet|null); + /** FeatureSetEditionDefault overridableFeatures. */ + public overridableFeatures?: (google.protobuf.IFeatureSet|null); + + /** FeatureSetEditionDefault fixedFeatures. */ + public fixedFeatures?: (google.protobuf.IFeatureSet|null); /** * Creates a new FeatureSetEditionDefault instance using the specified properties. @@ -11398,6 +11905,13 @@ export namespace google { } } + /** SymbolVisibility enum. */ + enum SymbolVisibility { + VISIBILITY_UNSET = 0, + VISIBILITY_LOCAL = 1, + VISIBILITY_EXPORT = 2 + } + /** Properties of a Duration. */ interface IDuration { diff --git a/packages/google-cloud-memcache/protos/protos.js b/packages/google-cloud-memcache/protos/protos.js index 00961849c01a..b26ed2182679 100644 --- a/packages/google-cloud-memcache/protos/protos.js +++ b/packages/google-cloud-memcache/protos/protos.js @@ -13907,6 +13907,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -13941,6 +13942,14 @@ */ CommonLanguageSettings.prototype.destinations = $util.emptyArray; + /** + * CommonLanguageSettings selectiveGapicGeneration. + * @member {google.api.ISelectiveGapicGeneration|null|undefined} selectiveGapicGeneration + * @memberof google.api.CommonLanguageSettings + * @instance + */ + CommonLanguageSettings.prototype.selectiveGapicGeneration = null; + /** * Creates a new CommonLanguageSettings instance using the specified properties. * @function create @@ -13973,6 +13982,8 @@ writer.int32(message.destinations[i]); writer.ldelim(); } + if (message.selectiveGapicGeneration != null && Object.hasOwnProperty.call(message, "selectiveGapicGeneration")) + $root.google.api.SelectiveGapicGeneration.encode(message.selectiveGapicGeneration, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); return writer; }; @@ -14024,6 +14035,10 @@ message.destinations.push(reader.int32()); break; } + case 3: { + message.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -14075,6 +14090,11 @@ break; } } + if (message.selectiveGapicGeneration != null && message.hasOwnProperty("selectiveGapicGeneration")) { + var error = $root.google.api.SelectiveGapicGeneration.verify(message.selectiveGapicGeneration); + if (error) + return "selectiveGapicGeneration." + error; + } return null; }; @@ -14117,6 +14137,11 @@ break; } } + if (object.selectiveGapicGeneration != null) { + if (typeof object.selectiveGapicGeneration !== "object") + throw TypeError(".google.api.CommonLanguageSettings.selectiveGapicGeneration: object expected"); + message.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.fromObject(object.selectiveGapicGeneration); + } return message; }; @@ -14135,8 +14160,10 @@ var object = {}; if (options.arrays || options.defaults) object.destinations = []; - if (options.defaults) + if (options.defaults) { object.referenceDocsUri = ""; + object.selectiveGapicGeneration = null; + } if (message.referenceDocsUri != null && message.hasOwnProperty("referenceDocsUri")) object.referenceDocsUri = message.referenceDocsUri; if (message.destinations && message.destinations.length) { @@ -14144,6 +14171,8 @@ for (var j = 0; j < message.destinations.length; ++j) object.destinations[j] = options.enums === String ? $root.google.api.ClientLibraryDestination[message.destinations[j]] === undefined ? message.destinations[j] : $root.google.api.ClientLibraryDestination[message.destinations[j]] : message.destinations[j]; } + if (message.selectiveGapicGeneration != null && message.hasOwnProperty("selectiveGapicGeneration")) + object.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.toObject(message.selectiveGapicGeneration, options); return object; }; @@ -15966,6 +15995,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -15991,6 +16021,14 @@ */ PythonSettings.prototype.common = null; + /** + * PythonSettings experimentalFeatures. + * @member {google.api.PythonSettings.IExperimentalFeatures|null|undefined} experimentalFeatures + * @memberof google.api.PythonSettings + * @instance + */ + PythonSettings.prototype.experimentalFeatures = null; + /** * Creates a new PythonSettings instance using the specified properties. * @function create @@ -16017,6 +16055,8 @@ writer = $Writer.create(); if (message.common != null && Object.hasOwnProperty.call(message, "common")) $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.experimentalFeatures != null && Object.hasOwnProperty.call(message, "experimentalFeatures")) + $root.google.api.PythonSettings.ExperimentalFeatures.encode(message.experimentalFeatures, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; @@ -16057,6 +16097,10 @@ message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); break; } + case 2: { + message.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -16097,6 +16141,11 @@ if (error) return "common." + error; } + if (message.experimentalFeatures != null && message.hasOwnProperty("experimentalFeatures")) { + var error = $root.google.api.PythonSettings.ExperimentalFeatures.verify(message.experimentalFeatures); + if (error) + return "experimentalFeatures." + error; + } return null; }; @@ -16117,6 +16166,11 @@ throw TypeError(".google.api.PythonSettings.common: object expected"); message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); } + if (object.experimentalFeatures != null) { + if (typeof object.experimentalFeatures !== "object") + throw TypeError(".google.api.PythonSettings.experimentalFeatures: object expected"); + message.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.fromObject(object.experimentalFeatures); + } return message; }; @@ -16133,10 +16187,14 @@ if (!options) options = {}; var object = {}; - if (options.defaults) + if (options.defaults) { object.common = null; + object.experimentalFeatures = null; + } if (message.common != null && message.hasOwnProperty("common")) object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + if (message.experimentalFeatures != null && message.hasOwnProperty("experimentalFeatures")) + object.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.toObject(message.experimentalFeatures, options); return object; }; @@ -16166,6 +16224,258 @@ return typeUrlPrefix + "/google.api.PythonSettings"; }; + PythonSettings.ExperimentalFeatures = (function() { + + /** + * Properties of an ExperimentalFeatures. + * @memberof google.api.PythonSettings + * @interface IExperimentalFeatures + * @property {boolean|null} [restAsyncIoEnabled] ExperimentalFeatures restAsyncIoEnabled + * @property {boolean|null} [protobufPythonicTypesEnabled] ExperimentalFeatures protobufPythonicTypesEnabled + * @property {boolean|null} [unversionedPackageDisabled] ExperimentalFeatures unversionedPackageDisabled + */ + + /** + * Constructs a new ExperimentalFeatures. + * @memberof google.api.PythonSettings + * @classdesc Represents an ExperimentalFeatures. + * @implements IExperimentalFeatures + * @constructor + * @param {google.api.PythonSettings.IExperimentalFeatures=} [properties] Properties to set + */ + function ExperimentalFeatures(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]]; + } + + /** + * ExperimentalFeatures restAsyncIoEnabled. + * @member {boolean} restAsyncIoEnabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.restAsyncIoEnabled = false; + + /** + * ExperimentalFeatures protobufPythonicTypesEnabled. + * @member {boolean} protobufPythonicTypesEnabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.protobufPythonicTypesEnabled = false; + + /** + * ExperimentalFeatures unversionedPackageDisabled. + * @member {boolean} unversionedPackageDisabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.unversionedPackageDisabled = false; + + /** + * Creates a new ExperimentalFeatures instance using the specified properties. + * @function create + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures=} [properties] Properties to set + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures instance + */ + ExperimentalFeatures.create = function create(properties) { + return new ExperimentalFeatures(properties); + }; + + /** + * Encodes the specified ExperimentalFeatures message. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @function encode + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures} message ExperimentalFeatures message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExperimentalFeatures.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.restAsyncIoEnabled != null && Object.hasOwnProperty.call(message, "restAsyncIoEnabled")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.restAsyncIoEnabled); + if (message.protobufPythonicTypesEnabled != null && Object.hasOwnProperty.call(message, "protobufPythonicTypesEnabled")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.protobufPythonicTypesEnabled); + if (message.unversionedPackageDisabled != null && Object.hasOwnProperty.call(message, "unversionedPackageDisabled")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.unversionedPackageDisabled); + return writer; + }; + + /** + * Encodes the specified ExperimentalFeatures message, length delimited. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures} message ExperimentalFeatures message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExperimentalFeatures.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer. + * @function decode + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExperimentalFeatures.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.PythonSettings.ExperimentalFeatures(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.restAsyncIoEnabled = reader.bool(); + break; + } + case 2: { + message.protobufPythonicTypesEnabled = reader.bool(); + break; + } + case 3: { + message.unversionedPackageDisabled = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExperimentalFeatures.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExperimentalFeatures message. + * @function verify + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExperimentalFeatures.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.restAsyncIoEnabled != null && message.hasOwnProperty("restAsyncIoEnabled")) + if (typeof message.restAsyncIoEnabled !== "boolean") + return "restAsyncIoEnabled: boolean expected"; + if (message.protobufPythonicTypesEnabled != null && message.hasOwnProperty("protobufPythonicTypesEnabled")) + if (typeof message.protobufPythonicTypesEnabled !== "boolean") + return "protobufPythonicTypesEnabled: boolean expected"; + if (message.unversionedPackageDisabled != null && message.hasOwnProperty("unversionedPackageDisabled")) + if (typeof message.unversionedPackageDisabled !== "boolean") + return "unversionedPackageDisabled: boolean expected"; + return null; + }; + + /** + * Creates an ExperimentalFeatures message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {Object.} object Plain object + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + */ + ExperimentalFeatures.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.PythonSettings.ExperimentalFeatures) + return object; + var message = new $root.google.api.PythonSettings.ExperimentalFeatures(); + if (object.restAsyncIoEnabled != null) + message.restAsyncIoEnabled = Boolean(object.restAsyncIoEnabled); + if (object.protobufPythonicTypesEnabled != null) + message.protobufPythonicTypesEnabled = Boolean(object.protobufPythonicTypesEnabled); + if (object.unversionedPackageDisabled != null) + message.unversionedPackageDisabled = Boolean(object.unversionedPackageDisabled); + return message; + }; + + /** + * Creates a plain object from an ExperimentalFeatures message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.ExperimentalFeatures} message ExperimentalFeatures + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExperimentalFeatures.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.restAsyncIoEnabled = false; + object.protobufPythonicTypesEnabled = false; + object.unversionedPackageDisabled = false; + } + if (message.restAsyncIoEnabled != null && message.hasOwnProperty("restAsyncIoEnabled")) + object.restAsyncIoEnabled = message.restAsyncIoEnabled; + if (message.protobufPythonicTypesEnabled != null && message.hasOwnProperty("protobufPythonicTypesEnabled")) + object.protobufPythonicTypesEnabled = message.protobufPythonicTypesEnabled; + if (message.unversionedPackageDisabled != null && message.hasOwnProperty("unversionedPackageDisabled")) + object.unversionedPackageDisabled = message.unversionedPackageDisabled; + return object; + }; + + /** + * Converts this ExperimentalFeatures to JSON. + * @function toJSON + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + * @returns {Object.} JSON object + */ + ExperimentalFeatures.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExperimentalFeatures + * @function getTypeUrl + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExperimentalFeatures.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.PythonSettings.ExperimentalFeatures"; + }; + + return ExperimentalFeatures; + })(); + return PythonSettings; })(); @@ -17042,6 +17352,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -17053,6 +17364,7 @@ * @param {google.api.IGoSettings=} [properties] Properties to set */ function GoSettings(properties) { + this.renamedServices = {}; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -17067,6 +17379,14 @@ */ GoSettings.prototype.common = null; + /** + * GoSettings renamedServices. + * @member {Object.} renamedServices + * @memberof google.api.GoSettings + * @instance + */ + GoSettings.prototype.renamedServices = $util.emptyObject; + /** * Creates a new GoSettings instance using the specified properties. * @function create @@ -17093,6 +17413,9 @@ writer = $Writer.create(); if (message.common != null && Object.hasOwnProperty.call(message, "common")) $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.renamedServices != null && Object.hasOwnProperty.call(message, "renamedServices")) + for (var keys = Object.keys(message.renamedServices), i = 0; i < keys.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.renamedServices[keys[i]]).ldelim(); return writer; }; @@ -17123,7 +17446,7 @@ GoSettings.decode = function decode(reader, length, error) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.GoSettings(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.GoSettings(), key, value; while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) @@ -17133,6 +17456,29 @@ message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); break; } + case 2: { + if (message.renamedServices === $util.emptyObject) + message.renamedServices = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = ""; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = reader.string(); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.renamedServices[key] = value; + break; + } default: reader.skipType(tag & 7); break; @@ -17173,6 +17519,14 @@ if (error) return "common." + error; } + if (message.renamedServices != null && message.hasOwnProperty("renamedServices")) { + if (!$util.isObject(message.renamedServices)) + return "renamedServices: object expected"; + var key = Object.keys(message.renamedServices); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.renamedServices[key[i]])) + return "renamedServices: string{k:string} expected"; + } return null; }; @@ -17193,6 +17547,13 @@ throw TypeError(".google.api.GoSettings.common: object expected"); message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); } + if (object.renamedServices) { + if (typeof object.renamedServices !== "object") + throw TypeError(".google.api.GoSettings.renamedServices: object expected"); + message.renamedServices = {}; + for (var keys = Object.keys(object.renamedServices), i = 0; i < keys.length; ++i) + message.renamedServices[keys[i]] = String(object.renamedServices[keys[i]]); + } return message; }; @@ -17209,10 +17570,18 @@ if (!options) options = {}; var object = {}; + if (options.objects || options.defaults) + object.renamedServices = {}; if (options.defaults) object.common = null; if (message.common != null && message.hasOwnProperty("common")) object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + var keys2; + if (message.renamedServices && (keys2 = Object.keys(message.renamedServices)).length) { + object.renamedServices = {}; + for (var j = 0; j < keys2.length; ++j) + object.renamedServices[keys2[j]] = message.renamedServices[keys2[j]]; + } return object; }; @@ -17851,30 +18220,275 @@ return values; })(); - /** - * LaunchStage enum. - * @name google.api.LaunchStage - * @enum {number} - * @property {number} LAUNCH_STAGE_UNSPECIFIED=0 LAUNCH_STAGE_UNSPECIFIED value - * @property {number} UNIMPLEMENTED=6 UNIMPLEMENTED value - * @property {number} PRELAUNCH=7 PRELAUNCH value - * @property {number} EARLY_ACCESS=1 EARLY_ACCESS value - * @property {number} ALPHA=2 ALPHA value - * @property {number} BETA=3 BETA value - * @property {number} GA=4 GA value - * @property {number} DEPRECATED=5 DEPRECATED value - */ - api.LaunchStage = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "LAUNCH_STAGE_UNSPECIFIED"] = 0; - values[valuesById[6] = "UNIMPLEMENTED"] = 6; - values[valuesById[7] = "PRELAUNCH"] = 7; - values[valuesById[1] = "EARLY_ACCESS"] = 1; - values[valuesById[2] = "ALPHA"] = 2; - values[valuesById[3] = "BETA"] = 3; - values[valuesById[4] = "GA"] = 4; - values[valuesById[5] = "DEPRECATED"] = 5; - return values; + api.SelectiveGapicGeneration = (function() { + + /** + * Properties of a SelectiveGapicGeneration. + * @memberof google.api + * @interface ISelectiveGapicGeneration + * @property {Array.|null} [methods] SelectiveGapicGeneration methods + * @property {boolean|null} [generateOmittedAsInternal] SelectiveGapicGeneration generateOmittedAsInternal + */ + + /** + * Constructs a new SelectiveGapicGeneration. + * @memberof google.api + * @classdesc Represents a SelectiveGapicGeneration. + * @implements ISelectiveGapicGeneration + * @constructor + * @param {google.api.ISelectiveGapicGeneration=} [properties] Properties to set + */ + function SelectiveGapicGeneration(properties) { + this.methods = []; + 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]]; + } + + /** + * SelectiveGapicGeneration methods. + * @member {Array.} methods + * @memberof google.api.SelectiveGapicGeneration + * @instance + */ + SelectiveGapicGeneration.prototype.methods = $util.emptyArray; + + /** + * SelectiveGapicGeneration generateOmittedAsInternal. + * @member {boolean} generateOmittedAsInternal + * @memberof google.api.SelectiveGapicGeneration + * @instance + */ + SelectiveGapicGeneration.prototype.generateOmittedAsInternal = false; + + /** + * Creates a new SelectiveGapicGeneration instance using the specified properties. + * @function create + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration=} [properties] Properties to set + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration instance + */ + SelectiveGapicGeneration.create = function create(properties) { + return new SelectiveGapicGeneration(properties); + }; + + /** + * Encodes the specified SelectiveGapicGeneration message. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @function encode + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration} message SelectiveGapicGeneration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SelectiveGapicGeneration.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.methods != null && message.methods.length) + for (var i = 0; i < message.methods.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.methods[i]); + if (message.generateOmittedAsInternal != null && Object.hasOwnProperty.call(message, "generateOmittedAsInternal")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.generateOmittedAsInternal); + return writer; + }; + + /** + * Encodes the specified SelectiveGapicGeneration message, length delimited. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration} message SelectiveGapicGeneration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SelectiveGapicGeneration.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer. + * @function decode + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SelectiveGapicGeneration.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.SelectiveGapicGeneration(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + if (!(message.methods && message.methods.length)) + message.methods = []; + message.methods.push(reader.string()); + break; + } + case 2: { + message.generateOmittedAsInternal = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SelectiveGapicGeneration.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SelectiveGapicGeneration message. + * @function verify + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SelectiveGapicGeneration.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.methods != null && message.hasOwnProperty("methods")) { + if (!Array.isArray(message.methods)) + return "methods: array expected"; + for (var i = 0; i < message.methods.length; ++i) + if (!$util.isString(message.methods[i])) + return "methods: string[] expected"; + } + if (message.generateOmittedAsInternal != null && message.hasOwnProperty("generateOmittedAsInternal")) + if (typeof message.generateOmittedAsInternal !== "boolean") + return "generateOmittedAsInternal: boolean expected"; + return null; + }; + + /** + * Creates a SelectiveGapicGeneration message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {Object.} object Plain object + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + */ + SelectiveGapicGeneration.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.SelectiveGapicGeneration) + return object; + var message = new $root.google.api.SelectiveGapicGeneration(); + if (object.methods) { + if (!Array.isArray(object.methods)) + throw TypeError(".google.api.SelectiveGapicGeneration.methods: array expected"); + message.methods = []; + for (var i = 0; i < object.methods.length; ++i) + message.methods[i] = String(object.methods[i]); + } + if (object.generateOmittedAsInternal != null) + message.generateOmittedAsInternal = Boolean(object.generateOmittedAsInternal); + return message; + }; + + /** + * Creates a plain object from a SelectiveGapicGeneration message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.SelectiveGapicGeneration} message SelectiveGapicGeneration + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SelectiveGapicGeneration.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.methods = []; + if (options.defaults) + object.generateOmittedAsInternal = false; + if (message.methods && message.methods.length) { + object.methods = []; + for (var j = 0; j < message.methods.length; ++j) + object.methods[j] = message.methods[j]; + } + if (message.generateOmittedAsInternal != null && message.hasOwnProperty("generateOmittedAsInternal")) + object.generateOmittedAsInternal = message.generateOmittedAsInternal; + return object; + }; + + /** + * Converts this SelectiveGapicGeneration to JSON. + * @function toJSON + * @memberof google.api.SelectiveGapicGeneration + * @instance + * @returns {Object.} JSON object + */ + SelectiveGapicGeneration.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SelectiveGapicGeneration + * @function getTypeUrl + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SelectiveGapicGeneration.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.SelectiveGapicGeneration"; + }; + + return SelectiveGapicGeneration; + })(); + + /** + * LaunchStage enum. + * @name google.api.LaunchStage + * @enum {number} + * @property {number} LAUNCH_STAGE_UNSPECIFIED=0 LAUNCH_STAGE_UNSPECIFIED value + * @property {number} UNIMPLEMENTED=6 UNIMPLEMENTED value + * @property {number} PRELAUNCH=7 PRELAUNCH value + * @property {number} EARLY_ACCESS=1 EARLY_ACCESS value + * @property {number} ALPHA=2 ALPHA value + * @property {number} BETA=3 BETA value + * @property {number} GA=4 GA value + * @property {number} DEPRECATED=5 DEPRECATED value + */ + api.LaunchStage = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "LAUNCH_STAGE_UNSPECIFIED"] = 0; + values[valuesById[6] = "UNIMPLEMENTED"] = 6; + values[valuesById[7] = "PRELAUNCH"] = 7; + values[valuesById[1] = "EARLY_ACCESS"] = 1; + values[valuesById[2] = "ALPHA"] = 2; + values[valuesById[3] = "BETA"] = 3; + values[valuesById[4] = "GA"] = 4; + values[valuesById[5] = "DEPRECATED"] = 5; + return values; })(); /** @@ -18836,6 +19450,7 @@ * @name google.protobuf.Edition * @enum {number} * @property {number} EDITION_UNKNOWN=0 EDITION_UNKNOWN value + * @property {number} EDITION_LEGACY=900 EDITION_LEGACY value * @property {number} EDITION_PROTO2=998 EDITION_PROTO2 value * @property {number} EDITION_PROTO3=999 EDITION_PROTO3 value * @property {number} EDITION_2023=1000 EDITION_2023 value @@ -18850,6 +19465,7 @@ protobuf.Edition = (function() { var valuesById = {}, values = Object.create(valuesById); values[valuesById[0] = "EDITION_UNKNOWN"] = 0; + values[valuesById[900] = "EDITION_LEGACY"] = 900; values[valuesById[998] = "EDITION_PROTO2"] = 998; values[valuesById[999] = "EDITION_PROTO3"] = 999; values[valuesById[1000] = "EDITION_2023"] = 1000; @@ -18874,6 +19490,7 @@ * @property {Array.|null} [dependency] FileDescriptorProto dependency * @property {Array.|null} [publicDependency] FileDescriptorProto publicDependency * @property {Array.|null} [weakDependency] FileDescriptorProto weakDependency + * @property {Array.|null} [optionDependency] FileDescriptorProto optionDependency * @property {Array.|null} [messageType] FileDescriptorProto messageType * @property {Array.|null} [enumType] FileDescriptorProto enumType * @property {Array.|null} [service] FileDescriptorProto service @@ -18896,6 +19513,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -18946,6 +19564,14 @@ */ FileDescriptorProto.prototype.weakDependency = $util.emptyArray; + /** + * FileDescriptorProto optionDependency. + * @member {Array.} optionDependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.optionDependency = $util.emptyArray; + /** * FileDescriptorProto messageType. * @member {Array.} messageType @@ -19067,6 +19693,9 @@ writer.uint32(/* id 12, wireType 2 =*/98).string(message.syntax); if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) writer.uint32(/* id 14, wireType 0 =*/112).int32(message.edition); + if (message.optionDependency != null && message.optionDependency.length) + for (var i = 0; i < message.optionDependency.length; ++i) + writer.uint32(/* id 15, wireType 2 =*/122).string(message.optionDependency[i]); return writer; }; @@ -19139,6 +19768,12 @@ message.weakDependency.push(reader.int32()); break; } + case 15: { + if (!(message.optionDependency && message.optionDependency.length)) + message.optionDependency = []; + message.optionDependency.push(reader.string()); + break; + } case 4: { if (!(message.messageType && message.messageType.length)) message.messageType = []; @@ -19241,6 +19876,13 @@ if (!$util.isInteger(message.weakDependency[i])) return "weakDependency: integer[] expected"; } + if (message.optionDependency != null && message.hasOwnProperty("optionDependency")) { + if (!Array.isArray(message.optionDependency)) + return "optionDependency: array expected"; + for (var i = 0; i < message.optionDependency.length; ++i) + if (!$util.isString(message.optionDependency[i])) + return "optionDependency: string[] expected"; + } if (message.messageType != null && message.hasOwnProperty("messageType")) { if (!Array.isArray(message.messageType)) return "messageType: array expected"; @@ -19295,6 +19937,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -19347,6 +19990,13 @@ for (var i = 0; i < object.weakDependency.length; ++i) message.weakDependency[i] = object.weakDependency[i] | 0; } + if (object.optionDependency) { + if (!Array.isArray(object.optionDependency)) + throw TypeError(".google.protobuf.FileDescriptorProto.optionDependency: array expected"); + message.optionDependency = []; + for (var i = 0; i < object.optionDependency.length; ++i) + message.optionDependency[i] = String(object.optionDependency[i]); + } if (object.messageType) { if (!Array.isArray(object.messageType)) throw TypeError(".google.protobuf.FileDescriptorProto.messageType: array expected"); @@ -19410,6 +20060,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -19475,6 +20129,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -19531,6 +20186,11 @@ object.syntax = message.syntax; if (message.edition != null && message.hasOwnProperty("edition")) object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.optionDependency && message.optionDependency.length) { + object.optionDependency = []; + for (var j = 0; j < message.optionDependency.length; ++j) + object.optionDependency[j] = message.optionDependency[j]; + } return object; }; @@ -19579,6 +20239,7 @@ * @property {google.protobuf.IMessageOptions|null} [options] DescriptorProto options * @property {Array.|null} [reservedRange] DescriptorProto reservedRange * @property {Array.|null} [reservedName] DescriptorProto reservedName + * @property {google.protobuf.SymbolVisibility|null} [visibility] DescriptorProto visibility */ /** @@ -19684,6 +20345,14 @@ */ DescriptorProto.prototype.reservedName = $util.emptyArray; + /** + * DescriptorProto visibility. + * @member {google.protobuf.SymbolVisibility} visibility + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.visibility = 0; + /** * Creates a new DescriptorProto instance using the specified properties. * @function create @@ -19736,6 +20405,8 @@ if (message.reservedName != null && message.reservedName.length) for (var i = 0; i < message.reservedName.length; ++i) writer.uint32(/* id 10, wireType 2 =*/82).string(message.reservedName[i]); + if (message.visibility != null && Object.hasOwnProperty.call(message, "visibility")) + writer.uint32(/* id 11, wireType 0 =*/88).int32(message.visibility); return writer; }; @@ -19828,6 +20499,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -19941,6 +20616,15 @@ if (!$util.isString(message.reservedName[i])) return "reservedName: string[] expected"; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + switch (message.visibility) { + default: + return "visibility: enum value expected"; + case 0: + case 1: + case 2: + break; + } return null; }; @@ -20040,6 +20724,26 @@ for (var i = 0; i < object.reservedName.length; ++i) message.reservedName[i] = String(object.reservedName[i]); } + switch (object.visibility) { + default: + if (typeof object.visibility === "number") { + message.visibility = object.visibility; + break; + } + break; + case "VISIBILITY_UNSET": + case 0: + message.visibility = 0; + break; + case "VISIBILITY_LOCAL": + case 1: + message.visibility = 1; + break; + case "VISIBILITY_EXPORT": + case 2: + message.visibility = 2; + break; + } return message; }; @@ -20069,6 +20773,7 @@ if (options.defaults) { object.name = ""; object.options = null; + object.visibility = options.enums === String ? "VISIBILITY_UNSET" : 0; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -20114,6 +20819,8 @@ for (var j = 0; j < message.reservedName.length; ++j) object.reservedName[j] = message.reservedName[j]; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + object.visibility = options.enums === String ? $root.google.protobuf.SymbolVisibility[message.visibility] === undefined ? message.visibility : $root.google.protobuf.SymbolVisibility[message.visibility] : message.visibility; return object; }; @@ -22158,6 +22865,7 @@ * @property {google.protobuf.IEnumOptions|null} [options] EnumDescriptorProto options * @property {Array.|null} [reservedRange] EnumDescriptorProto reservedRange * @property {Array.|null} [reservedName] EnumDescriptorProto reservedName + * @property {google.protobuf.SymbolVisibility|null} [visibility] EnumDescriptorProto visibility */ /** @@ -22218,6 +22926,14 @@ */ EnumDescriptorProto.prototype.reservedName = $util.emptyArray; + /** + * EnumDescriptorProto visibility. + * @member {google.protobuf.SymbolVisibility} visibility + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.visibility = 0; + /** * Creates a new EnumDescriptorProto instance using the specified properties. * @function create @@ -22255,6 +22971,8 @@ if (message.reservedName != null && message.reservedName.length) for (var i = 0; i < message.reservedName.length; ++i) writer.uint32(/* id 5, wireType 2 =*/42).string(message.reservedName[i]); + if (message.visibility != null && Object.hasOwnProperty.call(message, "visibility")) + writer.uint32(/* id 6, wireType 0 =*/48).int32(message.visibility); return writer; }; @@ -22317,6 +23035,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -22385,6 +23107,15 @@ if (!$util.isString(message.reservedName[i])) return "reservedName: string[] expected"; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + switch (message.visibility) { + default: + return "visibility: enum value expected"; + case 0: + case 1: + case 2: + break; + } return null; }; @@ -22434,6 +23165,26 @@ for (var i = 0; i < object.reservedName.length; ++i) message.reservedName[i] = String(object.reservedName[i]); } + switch (object.visibility) { + default: + if (typeof object.visibility === "number") { + message.visibility = object.visibility; + break; + } + break; + case "VISIBILITY_UNSET": + case 0: + message.visibility = 0; + break; + case "VISIBILITY_LOCAL": + case 1: + message.visibility = 1; + break; + case "VISIBILITY_EXPORT": + case 2: + message.visibility = 2; + break; + } return message; }; @@ -22458,6 +23209,7 @@ if (options.defaults) { object.name = ""; object.options = null; + object.visibility = options.enums === String ? "VISIBILITY_UNSET" : 0; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -22478,6 +23230,8 @@ for (var j = 0; j < message.reservedName.length; ++j) object.reservedName[j] = message.reservedName[j]; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + object.visibility = options.enums === String ? $root.google.protobuf.SymbolVisibility[message.visibility] === undefined ? message.visibility : $root.google.protobuf.SymbolVisibility[message.visibility] : message.visibility; return object; }; @@ -24796,6 +25550,7 @@ * @property {Array.|null} [targets] FieldOptions targets * @property {Array.|null} [editionDefaults] FieldOptions editionDefaults * @property {google.protobuf.IFeatureSet|null} [features] FieldOptions features + * @property {google.protobuf.FieldOptions.IFeatureSupport|null} [featureSupport] FieldOptions featureSupport * @property {Array.|null} [uninterpretedOption] FieldOptions uninterpretedOption * @property {Array.|null} [".google.api.fieldBehavior"] FieldOptions .google.api.fieldBehavior * @property {google.api.IResourceReference|null} [".google.api.resourceReference"] FieldOptions .google.api.resourceReference @@ -24916,6 +25671,14 @@ */ FieldOptions.prototype.features = null; + /** + * FieldOptions featureSupport. + * @member {google.protobuf.FieldOptions.IFeatureSupport|null|undefined} featureSupport + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.featureSupport = null; + /** * FieldOptions uninterpretedOption. * @member {Array.} uninterpretedOption @@ -24990,6 +25753,8 @@ $root.google.protobuf.FieldOptions.EditionDefault.encode(message.editionDefaults[i], writer.uint32(/* id 20, wireType 2 =*/162).fork()).ldelim(); if (message.features != null && Object.hasOwnProperty.call(message, "features")) $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 21, wireType 2 =*/170).fork()).ldelim(); + if (message.featureSupport != null && Object.hasOwnProperty.call(message, "featureSupport")) + $root.google.protobuf.FieldOptions.FeatureSupport.encode(message.featureSupport, writer.uint32(/* id 22, wireType 2 =*/178).fork()).ldelim(); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); @@ -25091,6 +25856,10 @@ message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); break; } + case 22: { + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.decode(reader, reader.uint32()); + break; + } case 999: { if (!(message.uninterpretedOption && message.uninterpretedOption.length)) message.uninterpretedOption = []; @@ -25226,6 +25995,11 @@ if (error) return "features." + error; } + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) { + var error = $root.google.protobuf.FieldOptions.FeatureSupport.verify(message.featureSupport); + if (error) + return "featureSupport." + error; + } if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { if (!Array.isArray(message.uninterpretedOption)) return "uninterpretedOption: array expected"; @@ -25414,6 +26188,11 @@ throw TypeError(".google.protobuf.FieldOptions.features: object expected"); message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); } + if (object.featureSupport != null) { + if (typeof object.featureSupport !== "object") + throw TypeError(".google.protobuf.FieldOptions.featureSupport: object expected"); + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.fromObject(object.featureSupport); + } if (object.uninterpretedOption) { if (!Array.isArray(object.uninterpretedOption)) throw TypeError(".google.protobuf.FieldOptions.uninterpretedOption: array expected"); @@ -25511,6 +26290,7 @@ object.debugRedact = false; object.retention = options.enums === String ? "RETENTION_UNKNOWN" : 0; object.features = null; + object.featureSupport = null; object[".google.api.resourceReference"] = null; } if (message.ctype != null && message.hasOwnProperty("ctype")) @@ -25543,6 +26323,8 @@ } if (message.features != null && message.hasOwnProperty("features")) object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) + object.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.toObject(message.featureSupport, options); if (message.uninterpretedOption && message.uninterpretedOption.length) { object.uninterpretedOption = []; for (var j = 0; j < message.uninterpretedOption.length; ++j) @@ -25815,6 +26597,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -25856,103 +26639,589 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; break; case "EDITION_PROTO3": case 999: - message.edition = 999; + message.edition = 999; + break; + case "EDITION_2023": + case 1000: + message.edition = 1000; + break; + case "EDITION_2024": + case 1001: + message.edition = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.edition = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.edition = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.edition = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.edition = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.edition = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.edition = 2147483647; + break; + } + if (object.value != null) + message.value = String(object.value); + return message; + }; + + /** + * Creates a plain object from an EditionDefault message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {google.protobuf.FieldOptions.EditionDefault} message EditionDefault + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EditionDefault.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.value = ""; + object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + } + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + if (message.edition != null && message.hasOwnProperty("edition")) + object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + return object; + }; + + /** + * Converts this EditionDefault to JSON. + * @function toJSON + * @memberof google.protobuf.FieldOptions.EditionDefault + * @instance + * @returns {Object.} JSON object + */ + EditionDefault.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for EditionDefault + * @function getTypeUrl + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + EditionDefault.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FieldOptions.EditionDefault"; + }; + + return EditionDefault; + })(); + + FieldOptions.FeatureSupport = (function() { + + /** + * Properties of a FeatureSupport. + * @memberof google.protobuf.FieldOptions + * @interface IFeatureSupport + * @property {google.protobuf.Edition|null} [editionIntroduced] FeatureSupport editionIntroduced + * @property {google.protobuf.Edition|null} [editionDeprecated] FeatureSupport editionDeprecated + * @property {string|null} [deprecationWarning] FeatureSupport deprecationWarning + * @property {google.protobuf.Edition|null} [editionRemoved] FeatureSupport editionRemoved + */ + + /** + * Constructs a new FeatureSupport. + * @memberof google.protobuf.FieldOptions + * @classdesc Represents a FeatureSupport. + * @implements IFeatureSupport + * @constructor + * @param {google.protobuf.FieldOptions.IFeatureSupport=} [properties] Properties to set + */ + function FeatureSupport(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]]; + } + + /** + * FeatureSupport editionIntroduced. + * @member {google.protobuf.Edition} editionIntroduced + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionIntroduced = 0; + + /** + * FeatureSupport editionDeprecated. + * @member {google.protobuf.Edition} editionDeprecated + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionDeprecated = 0; + + /** + * FeatureSupport deprecationWarning. + * @member {string} deprecationWarning + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.deprecationWarning = ""; + + /** + * FeatureSupport editionRemoved. + * @member {google.protobuf.Edition} editionRemoved + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionRemoved = 0; + + /** + * Creates a new FeatureSupport instance using the specified properties. + * @function create + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport=} [properties] Properties to set + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport instance + */ + FeatureSupport.create = function create(properties) { + return new FeatureSupport(properties); + }; + + /** + * Encodes the specified FeatureSupport message. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport} message FeatureSupport message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSupport.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.editionIntroduced != null && Object.hasOwnProperty.call(message, "editionIntroduced")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.editionIntroduced); + if (message.editionDeprecated != null && Object.hasOwnProperty.call(message, "editionDeprecated")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.editionDeprecated); + if (message.deprecationWarning != null && Object.hasOwnProperty.call(message, "deprecationWarning")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.deprecationWarning); + if (message.editionRemoved != null && Object.hasOwnProperty.call(message, "editionRemoved")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.editionRemoved); + return writer; + }; + + /** + * Encodes the specified FeatureSupport message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport} message FeatureSupport message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSupport.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSupport.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FieldOptions.FeatureSupport(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.editionIntroduced = reader.int32(); + break; + } + case 2: { + message.editionDeprecated = reader.int32(); + break; + } + case 3: { + message.deprecationWarning = reader.string(); + break; + } + case 4: { + message.editionRemoved = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSupport.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FeatureSupport message. + * @function verify + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FeatureSupport.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.editionIntroduced != null && message.hasOwnProperty("editionIntroduced")) + switch (message.editionIntroduced) { + default: + return "editionIntroduced: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + if (message.editionDeprecated != null && message.hasOwnProperty("editionDeprecated")) + switch (message.editionDeprecated) { + default: + return "editionDeprecated: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + if (message.deprecationWarning != null && message.hasOwnProperty("deprecationWarning")) + if (!$util.isString(message.deprecationWarning)) + return "deprecationWarning: string expected"; + if (message.editionRemoved != null && message.hasOwnProperty("editionRemoved")) + switch (message.editionRemoved) { + default: + return "editionRemoved: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + return null; + }; + + /** + * Creates a FeatureSupport message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + */ + FeatureSupport.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FieldOptions.FeatureSupport) + return object; + var message = new $root.google.protobuf.FieldOptions.FeatureSupport(); + switch (object.editionIntroduced) { + default: + if (typeof object.editionIntroduced === "number") { + message.editionIntroduced = object.editionIntroduced; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionIntroduced = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionIntroduced = 900; + break; + case "EDITION_PROTO2": + case 998: + message.editionIntroduced = 998; + break; + case "EDITION_PROTO3": + case 999: + message.editionIntroduced = 999; + break; + case "EDITION_2023": + case 1000: + message.editionIntroduced = 1000; + break; + case "EDITION_2024": + case 1001: + message.editionIntroduced = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.editionIntroduced = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.editionIntroduced = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.editionIntroduced = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.editionIntroduced = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.editionIntroduced = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.editionIntroduced = 2147483647; + break; + } + switch (object.editionDeprecated) { + default: + if (typeof object.editionDeprecated === "number") { + message.editionDeprecated = object.editionDeprecated; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionDeprecated = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionDeprecated = 900; + break; + case "EDITION_PROTO2": + case 998: + message.editionDeprecated = 998; + break; + case "EDITION_PROTO3": + case 999: + message.editionDeprecated = 999; + break; + case "EDITION_2023": + case 1000: + message.editionDeprecated = 1000; + break; + case "EDITION_2024": + case 1001: + message.editionDeprecated = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.editionDeprecated = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.editionDeprecated = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.editionDeprecated = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.editionDeprecated = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.editionDeprecated = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.editionDeprecated = 2147483647; + break; + } + if (object.deprecationWarning != null) + message.deprecationWarning = String(object.deprecationWarning); + switch (object.editionRemoved) { + default: + if (typeof object.editionRemoved === "number") { + message.editionRemoved = object.editionRemoved; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionRemoved = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionRemoved = 900; + break; + case "EDITION_PROTO2": + case 998: + message.editionRemoved = 998; + break; + case "EDITION_PROTO3": + case 999: + message.editionRemoved = 999; break; case "EDITION_2023": case 1000: - message.edition = 1000; + message.editionRemoved = 1000; break; case "EDITION_2024": case 1001: - message.edition = 1001; + message.editionRemoved = 1001; break; case "EDITION_1_TEST_ONLY": case 1: - message.edition = 1; + message.editionRemoved = 1; break; case "EDITION_2_TEST_ONLY": case 2: - message.edition = 2; + message.editionRemoved = 2; break; case "EDITION_99997_TEST_ONLY": case 99997: - message.edition = 99997; + message.editionRemoved = 99997; break; case "EDITION_99998_TEST_ONLY": case 99998: - message.edition = 99998; + message.editionRemoved = 99998; break; case "EDITION_99999_TEST_ONLY": case 99999: - message.edition = 99999; + message.editionRemoved = 99999; break; case "EDITION_MAX": case 2147483647: - message.edition = 2147483647; + message.editionRemoved = 2147483647; break; } - if (object.value != null) - message.value = String(object.value); return message; }; /** - * Creates a plain object from an EditionDefault message. Also converts values to other types if specified. + * Creates a plain object from a FeatureSupport message. Also converts values to other types if specified. * @function toObject - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @static - * @param {google.protobuf.FieldOptions.EditionDefault} message EditionDefault + * @param {google.protobuf.FieldOptions.FeatureSupport} message FeatureSupport * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - EditionDefault.toObject = function toObject(message, options) { + FeatureSupport.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { - object.value = ""; - object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; - } - if (message.value != null && message.hasOwnProperty("value")) - object.value = message.value; - if (message.edition != null && message.hasOwnProperty("edition")) - object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + object.editionIntroduced = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.editionDeprecated = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.deprecationWarning = ""; + object.editionRemoved = options.enums === String ? "EDITION_UNKNOWN" : 0; + } + if (message.editionIntroduced != null && message.hasOwnProperty("editionIntroduced")) + object.editionIntroduced = options.enums === String ? $root.google.protobuf.Edition[message.editionIntroduced] === undefined ? message.editionIntroduced : $root.google.protobuf.Edition[message.editionIntroduced] : message.editionIntroduced; + if (message.editionDeprecated != null && message.hasOwnProperty("editionDeprecated")) + object.editionDeprecated = options.enums === String ? $root.google.protobuf.Edition[message.editionDeprecated] === undefined ? message.editionDeprecated : $root.google.protobuf.Edition[message.editionDeprecated] : message.editionDeprecated; + if (message.deprecationWarning != null && message.hasOwnProperty("deprecationWarning")) + object.deprecationWarning = message.deprecationWarning; + if (message.editionRemoved != null && message.hasOwnProperty("editionRemoved")) + object.editionRemoved = options.enums === String ? $root.google.protobuf.Edition[message.editionRemoved] === undefined ? message.editionRemoved : $root.google.protobuf.Edition[message.editionRemoved] : message.editionRemoved; return object; }; /** - * Converts this EditionDefault to JSON. + * Converts this FeatureSupport to JSON. * @function toJSON - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @instance * @returns {Object.} JSON object */ - EditionDefault.prototype.toJSON = function toJSON() { + FeatureSupport.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for EditionDefault + * Gets the default type url for FeatureSupport * @function getTypeUrl - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - EditionDefault.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + FeatureSupport.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.protobuf.FieldOptions.EditionDefault"; + return typeUrlPrefix + "/google.protobuf.FieldOptions.FeatureSupport"; }; - return EditionDefault; + return FeatureSupport; })(); return FieldOptions; @@ -26547,6 +27816,7 @@ * @property {boolean|null} [deprecated] EnumValueOptions deprecated * @property {google.protobuf.IFeatureSet|null} [features] EnumValueOptions features * @property {boolean|null} [debugRedact] EnumValueOptions debugRedact + * @property {google.protobuf.FieldOptions.IFeatureSupport|null} [featureSupport] EnumValueOptions featureSupport * @property {Array.|null} [uninterpretedOption] EnumValueOptions uninterpretedOption */ @@ -26590,6 +27860,14 @@ */ EnumValueOptions.prototype.debugRedact = false; + /** + * EnumValueOptions featureSupport. + * @member {google.protobuf.FieldOptions.IFeatureSupport|null|undefined} featureSupport + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.featureSupport = null; + /** * EnumValueOptions uninterpretedOption. * @member {Array.} uninterpretedOption @@ -26628,6 +27906,8 @@ $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.debugRedact != null && Object.hasOwnProperty.call(message, "debugRedact")) writer.uint32(/* id 3, wireType 0 =*/24).bool(message.debugRedact); + if (message.featureSupport != null && Object.hasOwnProperty.call(message, "featureSupport")) + $root.google.protobuf.FieldOptions.FeatureSupport.encode(message.featureSupport, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); @@ -26679,6 +27959,10 @@ message.debugRedact = reader.bool(); break; } + case 4: { + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.decode(reader, reader.uint32()); + break; + } case 999: { if (!(message.uninterpretedOption && message.uninterpretedOption.length)) message.uninterpretedOption = []; @@ -26731,6 +28015,11 @@ if (message.debugRedact != null && message.hasOwnProperty("debugRedact")) if (typeof message.debugRedact !== "boolean") return "debugRedact: boolean expected"; + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) { + var error = $root.google.protobuf.FieldOptions.FeatureSupport.verify(message.featureSupport); + if (error) + return "featureSupport." + error; + } if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { if (!Array.isArray(message.uninterpretedOption)) return "uninterpretedOption: array expected"; @@ -26764,6 +28053,11 @@ } if (object.debugRedact != null) message.debugRedact = Boolean(object.debugRedact); + if (object.featureSupport != null) { + if (typeof object.featureSupport !== "object") + throw TypeError(".google.protobuf.EnumValueOptions.featureSupport: object expected"); + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.fromObject(object.featureSupport); + } if (object.uninterpretedOption) { if (!Array.isArray(object.uninterpretedOption)) throw TypeError(".google.protobuf.EnumValueOptions.uninterpretedOption: array expected"); @@ -26796,6 +28090,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -26803,6 +28098,8 @@ object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); if (message.debugRedact != null && message.hasOwnProperty("debugRedact")) object.debugRedact = message.debugRedact; + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) + object.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.toObject(message.featureSupport, options); if (message.uninterpretedOption && message.uninterpretedOption.length) { object.uninterpretedOption = []; for (var j = 0; j < message.uninterpretedOption.length; ++j) @@ -28270,6 +29567,8 @@ * @property {google.protobuf.FeatureSet.Utf8Validation|null} [utf8Validation] FeatureSet utf8Validation * @property {google.protobuf.FeatureSet.MessageEncoding|null} [messageEncoding] FeatureSet messageEncoding * @property {google.protobuf.FeatureSet.JsonFormat|null} [jsonFormat] FeatureSet jsonFormat + * @property {google.protobuf.FeatureSet.EnforceNamingStyle|null} [enforceNamingStyle] FeatureSet enforceNamingStyle + * @property {google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|null} [defaultSymbolVisibility] FeatureSet defaultSymbolVisibility */ /** @@ -28335,6 +29634,22 @@ */ FeatureSet.prototype.jsonFormat = 0; + /** + * FeatureSet enforceNamingStyle. + * @member {google.protobuf.FeatureSet.EnforceNamingStyle} enforceNamingStyle + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.enforceNamingStyle = 0; + + /** + * FeatureSet defaultSymbolVisibility. + * @member {google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility} defaultSymbolVisibility + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.defaultSymbolVisibility = 0; + /** * Creates a new FeatureSet instance using the specified properties. * @function create @@ -28371,6 +29686,10 @@ writer.uint32(/* id 5, wireType 0 =*/40).int32(message.messageEncoding); if (message.jsonFormat != null && Object.hasOwnProperty.call(message, "jsonFormat")) writer.uint32(/* id 6, wireType 0 =*/48).int32(message.jsonFormat); + if (message.enforceNamingStyle != null && Object.hasOwnProperty.call(message, "enforceNamingStyle")) + writer.uint32(/* id 7, wireType 0 =*/56).int32(message.enforceNamingStyle); + if (message.defaultSymbolVisibility != null && Object.hasOwnProperty.call(message, "defaultSymbolVisibility")) + writer.uint32(/* id 8, wireType 0 =*/64).int32(message.defaultSymbolVisibility); return writer; }; @@ -28431,6 +29750,14 @@ message.jsonFormat = reader.int32(); break; } + case 7: { + message.enforceNamingStyle = reader.int32(); + break; + } + case 8: { + message.defaultSymbolVisibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -28521,6 +29848,26 @@ case 2: break; } + if (message.enforceNamingStyle != null && message.hasOwnProperty("enforceNamingStyle")) + switch (message.enforceNamingStyle) { + default: + return "enforceNamingStyle: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.defaultSymbolVisibility != null && message.hasOwnProperty("defaultSymbolVisibility")) + switch (message.defaultSymbolVisibility) { + default: + return "defaultSymbolVisibility: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } return null; }; @@ -28660,6 +30007,54 @@ message.jsonFormat = 2; break; } + switch (object.enforceNamingStyle) { + default: + if (typeof object.enforceNamingStyle === "number") { + message.enforceNamingStyle = object.enforceNamingStyle; + break; + } + break; + case "ENFORCE_NAMING_STYLE_UNKNOWN": + case 0: + message.enforceNamingStyle = 0; + break; + case "STYLE2024": + case 1: + message.enforceNamingStyle = 1; + break; + case "STYLE_LEGACY": + case 2: + message.enforceNamingStyle = 2; + break; + } + switch (object.defaultSymbolVisibility) { + default: + if (typeof object.defaultSymbolVisibility === "number") { + message.defaultSymbolVisibility = object.defaultSymbolVisibility; + break; + } + break; + case "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN": + case 0: + message.defaultSymbolVisibility = 0; + break; + case "EXPORT_ALL": + case 1: + message.defaultSymbolVisibility = 1; + break; + case "EXPORT_TOP_LEVEL": + case 2: + message.defaultSymbolVisibility = 2; + break; + case "LOCAL_ALL": + case 3: + message.defaultSymbolVisibility = 3; + break; + case "STRICT": + case 4: + message.defaultSymbolVisibility = 4; + break; + } return message; }; @@ -28683,6 +30078,8 @@ object.utf8Validation = options.enums === String ? "UTF8_VALIDATION_UNKNOWN" : 0; object.messageEncoding = options.enums === String ? "MESSAGE_ENCODING_UNKNOWN" : 0; object.jsonFormat = options.enums === String ? "JSON_FORMAT_UNKNOWN" : 0; + object.enforceNamingStyle = options.enums === String ? "ENFORCE_NAMING_STYLE_UNKNOWN" : 0; + object.defaultSymbolVisibility = options.enums === String ? "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN" : 0; } if (message.fieldPresence != null && message.hasOwnProperty("fieldPresence")) object.fieldPresence = options.enums === String ? $root.google.protobuf.FeatureSet.FieldPresence[message.fieldPresence] === undefined ? message.fieldPresence : $root.google.protobuf.FeatureSet.FieldPresence[message.fieldPresence] : message.fieldPresence; @@ -28696,6 +30093,10 @@ object.messageEncoding = options.enums === String ? $root.google.protobuf.FeatureSet.MessageEncoding[message.messageEncoding] === undefined ? message.messageEncoding : $root.google.protobuf.FeatureSet.MessageEncoding[message.messageEncoding] : message.messageEncoding; if (message.jsonFormat != null && message.hasOwnProperty("jsonFormat")) object.jsonFormat = options.enums === String ? $root.google.protobuf.FeatureSet.JsonFormat[message.jsonFormat] === undefined ? message.jsonFormat : $root.google.protobuf.FeatureSet.JsonFormat[message.jsonFormat] : message.jsonFormat; + if (message.enforceNamingStyle != null && message.hasOwnProperty("enforceNamingStyle")) + object.enforceNamingStyle = options.enums === String ? $root.google.protobuf.FeatureSet.EnforceNamingStyle[message.enforceNamingStyle] === undefined ? message.enforceNamingStyle : $root.google.protobuf.FeatureSet.EnforceNamingStyle[message.enforceNamingStyle] : message.enforceNamingStyle; + if (message.defaultSymbolVisibility != null && message.hasOwnProperty("defaultSymbolVisibility")) + object.defaultSymbolVisibility = options.enums === String ? $root.google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility[message.defaultSymbolVisibility] === undefined ? message.defaultSymbolVisibility : $root.google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility[message.defaultSymbolVisibility] : message.defaultSymbolVisibility; return object; }; @@ -28823,6 +30224,219 @@ return values; })(); + /** + * EnforceNamingStyle enum. + * @name google.protobuf.FeatureSet.EnforceNamingStyle + * @enum {number} + * @property {number} ENFORCE_NAMING_STYLE_UNKNOWN=0 ENFORCE_NAMING_STYLE_UNKNOWN value + * @property {number} STYLE2024=1 STYLE2024 value + * @property {number} STYLE_LEGACY=2 STYLE_LEGACY value + */ + FeatureSet.EnforceNamingStyle = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "ENFORCE_NAMING_STYLE_UNKNOWN"] = 0; + values[valuesById[1] = "STYLE2024"] = 1; + values[valuesById[2] = "STYLE_LEGACY"] = 2; + return values; + })(); + + FeatureSet.VisibilityFeature = (function() { + + /** + * Properties of a VisibilityFeature. + * @memberof google.protobuf.FeatureSet + * @interface IVisibilityFeature + */ + + /** + * Constructs a new VisibilityFeature. + * @memberof google.protobuf.FeatureSet + * @classdesc Represents a VisibilityFeature. + * @implements IVisibilityFeature + * @constructor + * @param {google.protobuf.FeatureSet.IVisibilityFeature=} [properties] Properties to set + */ + function VisibilityFeature(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]]; + } + + /** + * Creates a new VisibilityFeature instance using the specified properties. + * @function create + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature=} [properties] Properties to set + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature instance + */ + VisibilityFeature.create = function create(properties) { + return new VisibilityFeature(properties); + }; + + /** + * Encodes the specified VisibilityFeature message. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature} message VisibilityFeature message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VisibilityFeature.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified VisibilityFeature message, length delimited. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature} message VisibilityFeature message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VisibilityFeature.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VisibilityFeature.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FeatureSet.VisibilityFeature(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VisibilityFeature.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a VisibilityFeature message. + * @function verify + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + VisibilityFeature.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a VisibilityFeature message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + */ + VisibilityFeature.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FeatureSet.VisibilityFeature) + return object; + return new $root.google.protobuf.FeatureSet.VisibilityFeature(); + }; + + /** + * Creates a plain object from a VisibilityFeature message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.VisibilityFeature} message VisibilityFeature + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + VisibilityFeature.toObject = function toObject() { + return {}; + }; + + /** + * Converts this VisibilityFeature to JSON. + * @function toJSON + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @instance + * @returns {Object.} JSON object + */ + VisibilityFeature.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for VisibilityFeature + * @function getTypeUrl + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + VisibilityFeature.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FeatureSet.VisibilityFeature"; + }; + + /** + * DefaultSymbolVisibility enum. + * @name google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility + * @enum {number} + * @property {number} DEFAULT_SYMBOL_VISIBILITY_UNKNOWN=0 DEFAULT_SYMBOL_VISIBILITY_UNKNOWN value + * @property {number} EXPORT_ALL=1 EXPORT_ALL value + * @property {number} EXPORT_TOP_LEVEL=2 EXPORT_TOP_LEVEL value + * @property {number} LOCAL_ALL=3 LOCAL_ALL value + * @property {number} STRICT=4 STRICT value + */ + VisibilityFeature.DefaultSymbolVisibility = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN"] = 0; + values[valuesById[1] = "EXPORT_ALL"] = 1; + values[valuesById[2] = "EXPORT_TOP_LEVEL"] = 2; + values[valuesById[3] = "LOCAL_ALL"] = 3; + values[valuesById[4] = "STRICT"] = 4; + return values; + })(); + + return VisibilityFeature; + })(); + return FeatureSet; })(); @@ -29007,6 +30621,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -29024,6 +30639,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -29072,6 +30688,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -29124,6 +30744,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -29232,7 +30856,8 @@ * @memberof google.protobuf.FeatureSetDefaults * @interface IFeatureSetEditionDefault * @property {google.protobuf.Edition|null} [edition] FeatureSetEditionDefault edition - * @property {google.protobuf.IFeatureSet|null} [features] FeatureSetEditionDefault features + * @property {google.protobuf.IFeatureSet|null} [overridableFeatures] FeatureSetEditionDefault overridableFeatures + * @property {google.protobuf.IFeatureSet|null} [fixedFeatures] FeatureSetEditionDefault fixedFeatures */ /** @@ -29259,12 +30884,20 @@ FeatureSetEditionDefault.prototype.edition = 0; /** - * FeatureSetEditionDefault features. - * @member {google.protobuf.IFeatureSet|null|undefined} features + * FeatureSetEditionDefault overridableFeatures. + * @member {google.protobuf.IFeatureSet|null|undefined} overridableFeatures + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @instance + */ + FeatureSetEditionDefault.prototype.overridableFeatures = null; + + /** + * FeatureSetEditionDefault fixedFeatures. + * @member {google.protobuf.IFeatureSet|null|undefined} fixedFeatures * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault * @instance */ - FeatureSetEditionDefault.prototype.features = null; + FeatureSetEditionDefault.prototype.fixedFeatures = null; /** * Creates a new FeatureSetEditionDefault instance using the specified properties. @@ -29290,10 +30923,12 @@ FeatureSetEditionDefault.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.features != null && Object.hasOwnProperty.call(message, "features")) - $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) writer.uint32(/* id 3, wireType 0 =*/24).int32(message.edition); + if (message.overridableFeatures != null && Object.hasOwnProperty.call(message, "overridableFeatures")) + $root.google.protobuf.FeatureSet.encode(message.overridableFeatures, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.fixedFeatures != null && Object.hasOwnProperty.call(message, "fixedFeatures")) + $root.google.protobuf.FeatureSet.encode(message.fixedFeatures, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); return writer; }; @@ -29334,8 +30969,12 @@ message.edition = reader.int32(); break; } - case 2: { - message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + case 4: { + message.overridableFeatures = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + break; + } + case 5: { + message.fixedFeatures = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); break; } default: @@ -29378,6 +31017,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -29390,10 +31030,15 @@ case 2147483647: break; } - if (message.features != null && message.hasOwnProperty("features")) { - var error = $root.google.protobuf.FeatureSet.verify(message.features); + if (message.overridableFeatures != null && message.hasOwnProperty("overridableFeatures")) { + var error = $root.google.protobuf.FeatureSet.verify(message.overridableFeatures); + if (error) + return "overridableFeatures." + error; + } + if (message.fixedFeatures != null && message.hasOwnProperty("fixedFeatures")) { + var error = $root.google.protobuf.FeatureSet.verify(message.fixedFeatures); if (error) - return "features." + error; + return "fixedFeatures." + error; } return null; }; @@ -29421,6 +31066,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -29462,10 +31111,15 @@ message.edition = 2147483647; break; } - if (object.features != null) { - if (typeof object.features !== "object") - throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.features: object expected"); - message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); + if (object.overridableFeatures != null) { + if (typeof object.overridableFeatures !== "object") + throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.overridableFeatures: object expected"); + message.overridableFeatures = $root.google.protobuf.FeatureSet.fromObject(object.overridableFeatures); + } + if (object.fixedFeatures != null) { + if (typeof object.fixedFeatures !== "object") + throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.fixedFeatures: object expected"); + message.fixedFeatures = $root.google.protobuf.FeatureSet.fromObject(object.fixedFeatures); } return message; }; @@ -29484,13 +31138,16 @@ options = {}; var object = {}; if (options.defaults) { - object.features = null; object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.overridableFeatures = null; + object.fixedFeatures = null; } - if (message.features != null && message.hasOwnProperty("features")) - object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); if (message.edition != null && message.hasOwnProperty("edition")) object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.overridableFeatures != null && message.hasOwnProperty("overridableFeatures")) + object.overridableFeatures = $root.google.protobuf.FeatureSet.toObject(message.overridableFeatures, options); + if (message.fixedFeatures != null && message.hasOwnProperty("fixedFeatures")) + object.fixedFeatures = $root.google.protobuf.FeatureSet.toObject(message.fixedFeatures, options); return object; }; @@ -30705,6 +32362,22 @@ return GeneratedCodeInfo; })(); + /** + * SymbolVisibility enum. + * @name google.protobuf.SymbolVisibility + * @enum {number} + * @property {number} VISIBILITY_UNSET=0 VISIBILITY_UNSET value + * @property {number} VISIBILITY_LOCAL=1 VISIBILITY_LOCAL value + * @property {number} VISIBILITY_EXPORT=2 VISIBILITY_EXPORT value + */ + protobuf.SymbolVisibility = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "VISIBILITY_UNSET"] = 0; + values[valuesById[1] = "VISIBILITY_LOCAL"] = 1; + values[valuesById[2] = "VISIBILITY_EXPORT"] = 2; + return values; + })(); + protobuf.Duration = (function() { /** diff --git a/packages/google-cloud-memcache/protos/protos.json b/packages/google-cloud-memcache/protos/protos.json index c5a5381bd83d..96637c336f4b 100644 --- a/packages/google-cloud-memcache/protos/protos.json +++ b/packages/google-cloud-memcache/protos/protos.json @@ -1677,8 +1677,7 @@ "java_multiple_files": true, "java_outer_classname": "ResourceProto", "java_package": "com.google.api", - "objc_class_prefix": "GAPI", - "cc_enable_arenas": true + "objc_class_prefix": "GAPI" }, "nested": { "http": { @@ -1802,6 +1801,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -1942,6 +1945,28 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "experimentalFeatures": { + "type": "ExperimentalFeatures", + "id": 2 + } + }, + "nested": { + "ExperimentalFeatures": { + "fields": { + "restAsyncIoEnabled": { + "type": "bool", + "id": 1 + }, + "protobufPythonicTypesEnabled": { + "type": "bool", + "id": 2 + }, + "unversionedPackageDisabled": { + "type": "bool", + "id": 3 + } + } } } }, @@ -1999,6 +2024,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -2060,6 +2090,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -2192,12 +2235,19 @@ "type": "FileDescriptorProto", "id": 1 } - } + }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ] }, "Edition": { "edition": "proto2", "values": { "EDITION_UNKNOWN": 0, + "EDITION_LEGACY": 900, "EDITION_PROTO2": 998, "EDITION_PROTO3": 999, "EDITION_2023": 1000, @@ -2236,6 +2286,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -2324,6 +2379,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -2549,6 +2608,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -2599,7 +2662,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -2763,6 +2833,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -2898,7 +2969,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -2926,6 +2998,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -2995,6 +3071,26 @@ "id": 2 } } + }, + "FeatureSupport": { + "fields": { + "editionIntroduced": { + "type": "Edition", + "id": 1 + }, + "editionDeprecated": { + "type": "Edition", + "id": 2 + }, + "deprecationWarning": { + "type": "string", + "id": 3 + }, + "editionRemoved": { + "type": "Edition", + "id": 4 + } + } } } }, @@ -3083,6 +3179,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -3225,6 +3325,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -3235,6 +3336,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -3245,6 +3347,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -3255,6 +3358,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -3265,7 +3369,8 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", - "edition_defaults.edition": "EDITION_PROTO2", + "feature_support.edition_introduced": "EDITION_2023", + "edition_defaults.edition": "EDITION_LEGACY", "edition_defaults.value": "LENGTH_PREFIXED" } }, @@ -3275,27 +3380,38 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "ALLOW" } + }, + "enforceNamingStyle": { + "type": "EnforceNamingStyle", + "id": 7, + "options": { + "retention": "RETENTION_SOURCE", + "targets": "TARGET_TYPE_METHOD", + "feature_support.edition_introduced": "EDITION_2024", + "edition_defaults.edition": "EDITION_2024", + "edition_defaults.value": "STYLE2024" + } + }, + "defaultSymbolVisibility": { + "type": "VisibilityFeature.DefaultSymbolVisibility", + "id": 8, + "options": { + "retention": "RETENTION_SOURCE", + "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2024", + "edition_defaults.edition": "EDITION_2024", + "edition_defaults.value": "EXPORT_TOP_LEVEL" + } } }, "extensions": [ [ 1000, - 1000 - ], - [ - 1001, - 1001 - ], - [ - 1002, - 1002 - ], - [ - 9990, - 9990 + 9994 ], [ 9995, @@ -3340,7 +3456,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -3355,6 +3477,33 @@ "ALLOW": 1, "LEGACY_BEST_EFFORT": 2 } + }, + "EnforceNamingStyle": { + "values": { + "ENFORCE_NAMING_STYLE_UNKNOWN": 0, + "STYLE2024": 1, + "STYLE_LEGACY": 2 + } + }, + "VisibilityFeature": { + "fields": {}, + "reserved": [ + [ + 1, + 536870911 + ] + ], + "nested": { + "DefaultSymbolVisibility": { + "values": { + "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN": 0, + "EXPORT_ALL": 1, + "EXPORT_TOP_LEVEL": 2, + "LOCAL_ALL": 3, + "STRICT": 4 + } + } + } } } }, @@ -3382,11 +3531,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -3399,6 +3563,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -3484,6 +3654,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Duration": { "fields": { "seconds": { @@ -3542,6 +3720,7 @@ "java_multiple_files": true, "java_outer_classname": "OperationsProto", "java_package": "com.google.longrunning", + "objc_class_prefix": "GLRUN", "php_namespace": "Google\\LongRunning" }, "nested": { diff --git a/packages/google-cloud-memcache/samples/generated/v1/snippet_metadata_google.cloud.memcache.v1.json b/packages/google-cloud-memcache/samples/generated/v1/snippet_metadata_google.cloud.memcache.v1.json index 77a2ffaa1d9d..8d1ed37fe55c 100644 --- a/packages/google-cloud-memcache/samples/generated/v1/snippet_metadata_google.cloud.memcache.v1.json +++ b/packages/google-cloud-memcache/samples/generated/v1/snippet_metadata_google.cloud.memcache.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-memcache", - "version": "4.2.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-memcache/samples/generated/v1beta2/snippet_metadata_google.cloud.memcache.v1beta2.json b/packages/google-cloud-memcache/samples/generated/v1beta2/snippet_metadata_google.cloud.memcache.v1beta2.json index bc5fc7f2cdbe..29c62d4469c2 100644 --- a/packages/google-cloud-memcache/samples/generated/v1beta2/snippet_metadata_google.cloud.memcache.v1beta2.json +++ b/packages/google-cloud-memcache/samples/generated/v1beta2/snippet_metadata_google.cloud.memcache.v1beta2.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-memcache", - "version": "4.2.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-memcache/src/v1/cloud_memcache_client.ts b/packages/google-cloud-memcache/src/v1/cloud_memcache_client.ts index 85b870be20ab..ead7bd324e87 100644 --- a/packages/google-cloud-memcache/src/v1/cloud_memcache_client.ts +++ b/packages/google-cloud-memcache/src/v1/cloud_memcache_client.ts @@ -18,11 +18,22 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -58,7 +69,7 @@ export class CloudMemcacheClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('memcache'); @@ -71,11 +82,11 @@ export class CloudMemcacheClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - cloudMemcacheStub?: Promise<{[name: string]: Function}>; + cloudMemcacheStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of CloudMemcacheClient. @@ -116,21 +127,42 @@ export class CloudMemcacheClient { * const client = new CloudMemcacheClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof CloudMemcacheClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'memcache.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -155,7 +187,7 @@ export class CloudMemcacheClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -169,15 +201,11 @@ export class CloudMemcacheClient { } this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -199,10 +227,10 @@ export class CloudMemcacheClient { // Create useful helper objects for these. this.pathTemplates = { instancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/instances/{instance}' + 'projects/{project}/locations/{location}/instances/{instance}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), }; @@ -210,8 +238,11 @@ export class CloudMemcacheClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listInstances: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'instances') + listInstances: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'instances', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -220,69 +251,122 @@ export class CloudMemcacheClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1/{name=projects/*}/locations', + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.memcache.v1.Instance') as gax.protobuf.Type; + '.google.cloud.memcache.v1.Instance', + ) as gax.protobuf.Type; const createInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.memcache.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.memcache.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.memcache.v1.Instance') as gax.protobuf.Type; + '.google.cloud.memcache.v1.Instance', + ) as gax.protobuf.Type; const updateInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.memcache.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.memcache.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateParametersResponse = protoFilesRoot.lookup( - '.google.cloud.memcache.v1.Instance') as gax.protobuf.Type; + '.google.cloud.memcache.v1.Instance', + ) as gax.protobuf.Type; const updateParametersMetadata = protoFilesRoot.lookup( - '.google.cloud.memcache.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.memcache.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteInstanceResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.memcache.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.memcache.v1.OperationMetadata', + ) as gax.protobuf.Type; const applyParametersResponse = protoFilesRoot.lookup( - '.google.cloud.memcache.v1.Instance') as gax.protobuf.Type; + '.google.cloud.memcache.v1.Instance', + ) as gax.protobuf.Type; const applyParametersMetadata = protoFilesRoot.lookup( - '.google.cloud.memcache.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.memcache.v1.OperationMetadata', + ) as gax.protobuf.Type; const rescheduleMaintenanceResponse = protoFilesRoot.lookup( - '.google.cloud.memcache.v1.Instance') as gax.protobuf.Type; + '.google.cloud.memcache.v1.Instance', + ) as gax.protobuf.Type; const rescheduleMaintenanceMetadata = protoFilesRoot.lookup( - '.google.cloud.memcache.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.memcache.v1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createInstanceResponse.decode.bind(createInstanceResponse), - createInstanceMetadata.decode.bind(createInstanceMetadata)), + createInstanceMetadata.decode.bind(createInstanceMetadata), + ), updateInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateInstanceResponse.decode.bind(updateInstanceResponse), - updateInstanceMetadata.decode.bind(updateInstanceMetadata)), + updateInstanceMetadata.decode.bind(updateInstanceMetadata), + ), updateParameters: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateParametersResponse.decode.bind(updateParametersResponse), - updateParametersMetadata.decode.bind(updateParametersMetadata)), + updateParametersMetadata.decode.bind(updateParametersMetadata), + ), deleteInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteInstanceResponse.decode.bind(deleteInstanceResponse), - deleteInstanceMetadata.decode.bind(deleteInstanceMetadata)), + deleteInstanceMetadata.decode.bind(deleteInstanceMetadata), + ), applyParameters: new this._gaxModule.LongrunningDescriptor( this.operationsClient, applyParametersResponse.decode.bind(applyParametersResponse), - applyParametersMetadata.decode.bind(applyParametersMetadata)), + applyParametersMetadata.decode.bind(applyParametersMetadata), + ), rescheduleMaintenance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - rescheduleMaintenanceResponse.decode.bind(rescheduleMaintenanceResponse), - rescheduleMaintenanceMetadata.decode.bind(rescheduleMaintenanceMetadata)) + rescheduleMaintenanceResponse.decode.bind( + rescheduleMaintenanceResponse, + ), + rescheduleMaintenanceMetadata.decode.bind( + rescheduleMaintenanceMetadata, + ), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.memcache.v1.CloudMemcache', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.memcache.v1.CloudMemcache', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -313,28 +397,42 @@ export class CloudMemcacheClient { // Put together the "service stub" for // google.cloud.memcache.v1.CloudMemcache. this.cloudMemcacheStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.memcache.v1.CloudMemcache') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.memcache.v1.CloudMemcache', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.memcache.v1.CloudMemcache, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const cloudMemcacheStubMethods = - ['listInstances', 'getInstance', 'createInstance', 'updateInstance', 'updateParameters', 'deleteInstance', 'applyParameters', 'rescheduleMaintenance']; + const cloudMemcacheStubMethods = [ + 'listInstances', + 'getInstance', + 'createInstance', + 'updateInstance', + 'updateParameters', + 'deleteInstance', + 'applyParameters', + 'rescheduleMaintenance', + ]; for (const methodName of cloudMemcacheStubMethods) { const callPromise = this.cloudMemcacheStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -344,7 +442,7 @@ export class CloudMemcacheClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -359,8 +457,14 @@ export class CloudMemcacheClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'memcache.googleapis.com'; } @@ -371,8 +475,14 @@ export class CloudMemcacheClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'memcache.googleapis.com'; } @@ -403,9 +513,7 @@ export class CloudMemcacheClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -414,8 +522,9 @@ export class CloudMemcacheClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -426,885 +535,1310 @@ export class CloudMemcacheClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets details of a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Memcached instance resource name in the format: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region - * @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 {@link protos.google.cloud.memcache.v1.Instance|Instance}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cloud_memcache.get_instance.js - * region_tag:memcache_v1_generated_CloudMemcache_GetInstance_async - */ + /** + * Gets details of a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Memcached instance resource name in the format: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region + * @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 {@link protos.google.cloud.memcache.v1.Instance|Instance}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cloud_memcache.get_instance.js + * region_tag:memcache_v1_generated_CloudMemcache_GetInstance_async + */ getInstance( - request?: protos.google.cloud.memcache.v1.IGetInstanceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.memcache.v1.IInstance, - protos.google.cloud.memcache.v1.IGetInstanceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memcache.v1.IGetInstanceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IGetInstanceRequest | undefined, + {} | undefined, + ] + >; getInstance( - request: protos.google.cloud.memcache.v1.IGetInstanceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.memcache.v1.IInstance, - protos.google.cloud.memcache.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memcache.v1.IGetInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IGetInstanceRequest | null | undefined, + {} | null | undefined + >, + ): void; getInstance( - request: protos.google.cloud.memcache.v1.IGetInstanceRequest, - callback: Callback< - protos.google.cloud.memcache.v1.IInstance, - protos.google.cloud.memcache.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memcache.v1.IGetInstanceRequest, + callback: Callback< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IGetInstanceRequest | null | undefined, + {} | null | undefined + >, + ): void; getInstance( - request?: protos.google.cloud.memcache.v1.IGetInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.memcache.v1.IInstance, - protos.google.cloud.memcache.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.memcache.v1.IGetInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.memcache.v1.IInstance, - protos.google.cloud.memcache.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.memcache.v1.IInstance, - protos.google.cloud.memcache.v1.IGetInstanceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.memcache.v1.IGetInstanceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IGetInstanceRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IGetInstanceRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getInstance request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.memcache.v1.IInstance, - protos.google.cloud.memcache.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.memcache.v1.IInstance, + | protos.google.cloud.memcache.v1.IGetInstanceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getInstance response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getInstance(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.memcache.v1.IInstance, - protos.google.cloud.memcache.v1.IGetInstanceRequest|undefined, - {}|undefined - ]) => { - this._log.info('getInstance response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getInstance(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IGetInstanceRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getInstance response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a new Instance in a given location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the instance location using the form: - * `projects/{project_id}/locations/{location_id}` - * where `location_id` refers to a GCP region - * @param {string} request.instanceId - * Required. The logical name of the Memcached instance in the user - * project with the following restrictions: - * - * * Must contain only lowercase letters, numbers, and hyphens. - * * Must start with a letter. - * * Must be between 1-40 characters. - * * Must end with a number or a letter. - * * Must be unique within the user project / location. - * - * If any of the above are not met, the API raises an invalid argument error. - * @param {google.cloud.memcache.v1.Instance} request.instance - * Required. A Memcached Instance - * @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/cloud_memcache.create_instance.js - * region_tag:memcache_v1_generated_CloudMemcache_CreateInstance_async - */ + /** + * Creates a new Instance in a given location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the instance location using the form: + * `projects/{project_id}/locations/{location_id}` + * where `location_id` refers to a GCP region + * @param {string} request.instanceId + * Required. The logical name of the Memcached instance in the user + * project with the following restrictions: + * + * * Must contain only lowercase letters, numbers, and hyphens. + * * Must start with a letter. + * * Must be between 1-40 characters. + * * Must end with a number or a letter. + * * Must be unique within the user project / location. + * + * If any of the above are not met, the API raises an invalid argument error. + * @param {google.cloud.memcache.v1.Instance} request.instance + * Required. A Memcached Instance + * @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/cloud_memcache.create_instance.js + * region_tag:memcache_v1_generated_CloudMemcache_CreateInstance_async + */ createInstance( - request?: protos.google.cloud.memcache.v1.ICreateInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memcache.v1.ICreateInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createInstance( - request: protos.google.cloud.memcache.v1.ICreateInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memcache.v1.ICreateInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createInstance( - request: protos.google.cloud.memcache.v1.ICreateInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memcache.v1.ICreateInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createInstance( - request?: protos.google.cloud.memcache.v1.ICreateInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.memcache.v1.ICreateInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createInstance request %j', request); - return this.innerApiCalls.createInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createInstance()`. - * @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/cloud_memcache.create_instance.js - * region_tag:memcache_v1_generated_CloudMemcache_CreateInstance_async - */ - async checkCreateInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createInstance()`. + * @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/cloud_memcache.create_instance.js + * region_tag:memcache_v1_generated_CloudMemcache_CreateInstance_async + */ + async checkCreateInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.memcache.v1.Instance, + protos.google.cloud.memcache.v1.OperationMetadata + > + > { this._log.info('createInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.memcache.v1.Instance, + protos.google.cloud.memcache.v1.OperationMetadata + >; } -/** - * Updates an existing Instance in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Mask of fields to update. - * - * * `displayName` - * @param {google.cloud.memcache.v1.Instance} request.instance - * Required. A Memcached Instance. - * Only fields specified in update_mask are updated. - * @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/cloud_memcache.update_instance.js - * region_tag:memcache_v1_generated_CloudMemcache_UpdateInstance_async - */ + /** + * Updates an existing Instance in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Mask of fields to update. + * + * * `displayName` + * @param {google.cloud.memcache.v1.Instance} request.instance + * Required. A Memcached Instance. + * Only fields specified in update_mask are updated. + * @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/cloud_memcache.update_instance.js + * region_tag:memcache_v1_generated_CloudMemcache_UpdateInstance_async + */ updateInstance( - request?: protos.google.cloud.memcache.v1.IUpdateInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memcache.v1.IUpdateInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateInstance( - request: protos.google.cloud.memcache.v1.IUpdateInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memcache.v1.IUpdateInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateInstance( - request: protos.google.cloud.memcache.v1.IUpdateInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memcache.v1.IUpdateInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateInstance( - request?: protos.google.cloud.memcache.v1.IUpdateInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.memcache.v1.IUpdateInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'instance.name': request.instance!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'instance.name': request.instance!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateInstance request %j', request); - return this.innerApiCalls.updateInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateInstance()`. - * @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/cloud_memcache.update_instance.js - * region_tag:memcache_v1_generated_CloudMemcache_UpdateInstance_async - */ - async checkUpdateInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateInstance()`. + * @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/cloud_memcache.update_instance.js + * region_tag:memcache_v1_generated_CloudMemcache_UpdateInstance_async + */ + async checkUpdateInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.memcache.v1.Instance, + protos.google.cloud.memcache.v1.OperationMetadata + > + > { this._log.info('updateInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.memcache.v1.Instance, + protos.google.cloud.memcache.v1.OperationMetadata + >; } -/** - * Updates the defined Memcached parameters for an existing instance. - * This method only stages the parameters, it must be followed by - * `ApplyParameters` to apply the parameters to nodes of the Memcached - * instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the Memcached instance for which the parameters should be - * updated. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Mask of fields to update. - * @param {google.cloud.memcache.v1.MemcacheParameters} request.parameters - * The parameters to apply to the instance. - * @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/cloud_memcache.update_parameters.js - * region_tag:memcache_v1_generated_CloudMemcache_UpdateParameters_async - */ + /** + * Updates the defined Memcached parameters for an existing instance. + * This method only stages the parameters, it must be followed by + * `ApplyParameters` to apply the parameters to nodes of the Memcached + * instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the Memcached instance for which the parameters should be + * updated. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Mask of fields to update. + * @param {google.cloud.memcache.v1.MemcacheParameters} request.parameters + * The parameters to apply to the instance. + * @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/cloud_memcache.update_parameters.js + * region_tag:memcache_v1_generated_CloudMemcache_UpdateParameters_async + */ updateParameters( - request?: protos.google.cloud.memcache.v1.IUpdateParametersRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memcache.v1.IUpdateParametersRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateParameters( - request: protos.google.cloud.memcache.v1.IUpdateParametersRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memcache.v1.IUpdateParametersRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateParameters( - request: protos.google.cloud.memcache.v1.IUpdateParametersRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memcache.v1.IUpdateParametersRequest, + callback: Callback< + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateParameters( - request?: protos.google.cloud.memcache.v1.IUpdateParametersRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.memcache.v1.IUpdateParametersRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateParameters response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateParameters request %j', request); - return this.innerApiCalls.updateParameters(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateParameters response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateParameters(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateParameters response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateParameters()`. - * @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/cloud_memcache.update_parameters.js - * region_tag:memcache_v1_generated_CloudMemcache_UpdateParameters_async - */ - async checkUpdateParametersProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateParameters()`. + * @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/cloud_memcache.update_parameters.js + * region_tag:memcache_v1_generated_CloudMemcache_UpdateParameters_async + */ + async checkUpdateParametersProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.memcache.v1.Instance, + protos.google.cloud.memcache.v1.OperationMetadata + > + > { this._log.info('updateParameters long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateParameters, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateParameters, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.memcache.v1.Instance, + protos.google.cloud.memcache.v1.OperationMetadata + >; } -/** - * Deletes a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Memcached instance resource name in the format: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region - * @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/cloud_memcache.delete_instance.js - * region_tag:memcache_v1_generated_CloudMemcache_DeleteInstance_async - */ + /** + * Deletes a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Memcached instance resource name in the format: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region + * @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/cloud_memcache.delete_instance.js + * region_tag:memcache_v1_generated_CloudMemcache_DeleteInstance_async + */ deleteInstance( - request?: protos.google.cloud.memcache.v1.IDeleteInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memcache.v1.IDeleteInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteInstance( - request: protos.google.cloud.memcache.v1.IDeleteInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memcache.v1.IDeleteInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteInstance( - request: protos.google.cloud.memcache.v1.IDeleteInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memcache.v1.IDeleteInstanceRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteInstance( - request?: protos.google.cloud.memcache.v1.IDeleteInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.memcache.v1.IDeleteInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteInstance request %j', request); - return this.innerApiCalls.deleteInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteInstance()`. - * @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/cloud_memcache.delete_instance.js - * region_tag:memcache_v1_generated_CloudMemcache_DeleteInstance_async - */ - async checkDeleteInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteInstance()`. + * @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/cloud_memcache.delete_instance.js + * region_tag:memcache_v1_generated_CloudMemcache_DeleteInstance_async + */ + async checkDeleteInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.memcache.v1.OperationMetadata + > + > { this._log.info('deleteInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.memcache.v1.OperationMetadata + >; } -/** - * `ApplyParameters` restarts the set of specified nodes in order to update - * them to the current set of parameters for the Memcached Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the Memcached instance for which parameter group updates - * should be applied. - * @param {string[]} request.nodeIds - * Nodes to which the instance-level parameter group is applied. - * @param {boolean} request.applyAll - * Whether to apply instance-level parameter group to all nodes. If set to - * true, users are restricted from specifying individual nodes, and - * `ApplyParameters` updates all nodes within the instance. - * @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/cloud_memcache.apply_parameters.js - * region_tag:memcache_v1_generated_CloudMemcache_ApplyParameters_async - */ + /** + * `ApplyParameters` restarts the set of specified nodes in order to update + * them to the current set of parameters for the Memcached Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the Memcached instance for which parameter group updates + * should be applied. + * @param {string[]} request.nodeIds + * Nodes to which the instance-level parameter group is applied. + * @param {boolean} request.applyAll + * Whether to apply instance-level parameter group to all nodes. If set to + * true, users are restricted from specifying individual nodes, and + * `ApplyParameters` updates all nodes within the instance. + * @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/cloud_memcache.apply_parameters.js + * region_tag:memcache_v1_generated_CloudMemcache_ApplyParameters_async + */ applyParameters( - request?: protos.google.cloud.memcache.v1.IApplyParametersRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memcache.v1.IApplyParametersRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; applyParameters( - request: protos.google.cloud.memcache.v1.IApplyParametersRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memcache.v1.IApplyParametersRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; applyParameters( - request: protos.google.cloud.memcache.v1.IApplyParametersRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memcache.v1.IApplyParametersRequest, + callback: Callback< + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; applyParameters( - request?: protos.google.cloud.memcache.v1.IApplyParametersRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.memcache.v1.IApplyParametersRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('applyParameters response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('applyParameters request %j', request); - return this.innerApiCalls.applyParameters(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('applyParameters response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .applyParameters(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('applyParameters response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `applyParameters()`. - * @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/cloud_memcache.apply_parameters.js - * region_tag:memcache_v1_generated_CloudMemcache_ApplyParameters_async - */ - async checkApplyParametersProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `applyParameters()`. + * @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/cloud_memcache.apply_parameters.js + * region_tag:memcache_v1_generated_CloudMemcache_ApplyParameters_async + */ + async checkApplyParametersProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.memcache.v1.Instance, + protos.google.cloud.memcache.v1.OperationMetadata + > + > { this._log.info('applyParameters long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.applyParameters, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.applyParameters, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.memcache.v1.Instance, + protos.google.cloud.memcache.v1.OperationMetadata + >; } -/** - * Reschedules upcoming maintenance event. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Required. Memcache instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - * @param {google.cloud.memcache.v1.RescheduleMaintenanceRequest.RescheduleType} request.rescheduleType - * Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as well. - * @param {google.protobuf.Timestamp} request.scheduleTime - * Timestamp when the maintenance shall be rescheduled to if - * reschedule_type=SPECIFIC_TIME, in RFC 3339 format, for - * example `2012-11-15T16:19:00.094Z`. - * @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/cloud_memcache.reschedule_maintenance.js - * region_tag:memcache_v1_generated_CloudMemcache_RescheduleMaintenance_async - */ + /** + * Reschedules upcoming maintenance event. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Required. Memcache instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + * @param {google.cloud.memcache.v1.RescheduleMaintenanceRequest.RescheduleType} request.rescheduleType + * Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as well. + * @param {google.protobuf.Timestamp} request.scheduleTime + * Timestamp when the maintenance shall be rescheduled to if + * reschedule_type=SPECIFIC_TIME, in RFC 3339 format, for + * example `2012-11-15T16:19:00.094Z`. + * @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/cloud_memcache.reschedule_maintenance.js + * region_tag:memcache_v1_generated_CloudMemcache_RescheduleMaintenance_async + */ rescheduleMaintenance( - request?: protos.google.cloud.memcache.v1.IRescheduleMaintenanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memcache.v1.IRescheduleMaintenanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; rescheduleMaintenance( - request: protos.google.cloud.memcache.v1.IRescheduleMaintenanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memcache.v1.IRescheduleMaintenanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; rescheduleMaintenance( - request: protos.google.cloud.memcache.v1.IRescheduleMaintenanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memcache.v1.IRescheduleMaintenanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; rescheduleMaintenance( - request?: protos.google.cloud.memcache.v1.IRescheduleMaintenanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.memcache.v1.IRescheduleMaintenanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('rescheduleMaintenance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('rescheduleMaintenance request %j', request); - return this.innerApiCalls.rescheduleMaintenance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('rescheduleMaintenance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .rescheduleMaintenance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('rescheduleMaintenance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `rescheduleMaintenance()`. - * @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/cloud_memcache.reschedule_maintenance.js - * region_tag:memcache_v1_generated_CloudMemcache_RescheduleMaintenance_async - */ - async checkRescheduleMaintenanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `rescheduleMaintenance()`. + * @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/cloud_memcache.reschedule_maintenance.js + * region_tag:memcache_v1_generated_CloudMemcache_RescheduleMaintenance_async + */ + async checkRescheduleMaintenanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.memcache.v1.Instance, + protos.google.cloud.memcache.v1.OperationMetadata + > + > { this._log.info('rescheduleMaintenance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.rescheduleMaintenance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.rescheduleMaintenance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.memcache.v1.Instance, + protos.google.cloud.memcache.v1.OperationMetadata + >; } - /** - * Lists Instances in a given location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the instance location using the form: - * `projects/{project_id}/locations/{location_id}` - * where `location_id` refers to a GCP region - * @param {number} request.pageSize - * The maximum number of items to return. - * - * If not specified, a default value of 1000 will be used by the service. - * Regardless of the `page_size` value, the response may include a partial - * list and a caller should only rely on response's - * {@link protos.google.cloud.memcache.v1.ListInstancesResponse.next_page_token|`next_page_token`} - * to determine if there are more instances left to be queried. - * @param {string} request.pageToken - * The `next_page_token` value returned from a previous List request, if any. - * @param {string} request.filter - * List filter. For example, exclude all Memcached instances with name as - * my-instance by specifying `"name != my-instance"`. - * @param {string} request.orderBy - * Sort results. Supported values are "name", "name desc" or "" (unsorted). - * @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 Array of {@link protos.google.cloud.memcache.v1.Instance|Instance}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listInstancesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists Instances in a given location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the instance location using the form: + * `projects/{project_id}/locations/{location_id}` + * where `location_id` refers to a GCP region + * @param {number} request.pageSize + * The maximum number of items to return. + * + * If not specified, a default value of 1000 will be used by the service. + * Regardless of the `page_size` value, the response may include a partial + * list and a caller should only rely on response's + * {@link protos.google.cloud.memcache.v1.ListInstancesResponse.next_page_token|`next_page_token`} + * to determine if there are more instances left to be queried. + * @param {string} request.pageToken + * The `next_page_token` value returned from a previous List request, if any. + * @param {string} request.filter + * List filter. For example, exclude all Memcached instances with name as + * my-instance by specifying `"name != my-instance"`. + * @param {string} request.orderBy + * Sort results. Supported values are "name", "name desc" or "" (unsorted). + * @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 Array of {@link protos.google.cloud.memcache.v1.Instance|Instance}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listInstances( - request?: protos.google.cloud.memcache.v1.IListInstancesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.memcache.v1.IInstance[], - protos.google.cloud.memcache.v1.IListInstancesRequest|null, - protos.google.cloud.memcache.v1.IListInstancesResponse - ]>; + request?: protos.google.cloud.memcache.v1.IListInstancesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.memcache.v1.IInstance[], + protos.google.cloud.memcache.v1.IListInstancesRequest | null, + protos.google.cloud.memcache.v1.IListInstancesResponse, + ] + >; listInstances( - request: protos.google.cloud.memcache.v1.IListInstancesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.memcache.v1.IListInstancesRequest, - protos.google.cloud.memcache.v1.IListInstancesResponse|null|undefined, - protos.google.cloud.memcache.v1.IInstance>): void; + request: protos.google.cloud.memcache.v1.IListInstancesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.memcache.v1.IListInstancesRequest, + protos.google.cloud.memcache.v1.IListInstancesResponse | null | undefined, + protos.google.cloud.memcache.v1.IInstance + >, + ): void; listInstances( - request: protos.google.cloud.memcache.v1.IListInstancesRequest, - callback: PaginationCallback< - protos.google.cloud.memcache.v1.IListInstancesRequest, - protos.google.cloud.memcache.v1.IListInstancesResponse|null|undefined, - protos.google.cloud.memcache.v1.IInstance>): void; + request: protos.google.cloud.memcache.v1.IListInstancesRequest, + callback: PaginationCallback< + protos.google.cloud.memcache.v1.IListInstancesRequest, + protos.google.cloud.memcache.v1.IListInstancesResponse | null | undefined, + protos.google.cloud.memcache.v1.IInstance + >, + ): void; listInstances( - request?: protos.google.cloud.memcache.v1.IListInstancesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.memcache.v1.IListInstancesRequest, - protos.google.cloud.memcache.v1.IListInstancesResponse|null|undefined, - protos.google.cloud.memcache.v1.IInstance>, - callback?: PaginationCallback< + request?: protos.google.cloud.memcache.v1.IListInstancesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.memcache.v1.IListInstancesRequest, - protos.google.cloud.memcache.v1.IListInstancesResponse|null|undefined, - protos.google.cloud.memcache.v1.IInstance>): - Promise<[ - protos.google.cloud.memcache.v1.IInstance[], - protos.google.cloud.memcache.v1.IListInstancesRequest|null, - protos.google.cloud.memcache.v1.IListInstancesResponse - ]>|void { + | protos.google.cloud.memcache.v1.IListInstancesResponse + | null + | undefined, + protos.google.cloud.memcache.v1.IInstance + >, + callback?: PaginationCallback< + protos.google.cloud.memcache.v1.IListInstancesRequest, + protos.google.cloud.memcache.v1.IListInstancesResponse | null | undefined, + protos.google.cloud.memcache.v1.IInstance + >, + ): Promise< + [ + protos.google.cloud.memcache.v1.IInstance[], + protos.google.cloud.memcache.v1.IListInstancesRequest | null, + protos.google.cloud.memcache.v1.IListInstancesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.memcache.v1.IListInstancesRequest, - protos.google.cloud.memcache.v1.IListInstancesResponse|null|undefined, - protos.google.cloud.memcache.v1.IInstance>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.memcache.v1.IListInstancesRequest, + | protos.google.cloud.memcache.v1.IListInstancesResponse + | null + | undefined, + protos.google.cloud.memcache.v1.IInstance + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listInstances values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1313,135 +1847,140 @@ export class CloudMemcacheClient { this._log.info('listInstances request %j', request); return this.innerApiCalls .listInstances(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.memcache.v1.IInstance[], - protos.google.cloud.memcache.v1.IListInstancesRequest|null, - protos.google.cloud.memcache.v1.IListInstancesResponse - ]) => { - this._log.info('listInstances values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.memcache.v1.IInstance[], + protos.google.cloud.memcache.v1.IListInstancesRequest | null, + protos.google.cloud.memcache.v1.IListInstancesResponse, + ]) => { + this._log.info('listInstances values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listInstances`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the instance location using the form: - * `projects/{project_id}/locations/{location_id}` - * where `location_id` refers to a GCP region - * @param {number} request.pageSize - * The maximum number of items to return. - * - * If not specified, a default value of 1000 will be used by the service. - * Regardless of the `page_size` value, the response may include a partial - * list and a caller should only rely on response's - * {@link protos.google.cloud.memcache.v1.ListInstancesResponse.next_page_token|`next_page_token`} - * to determine if there are more instances left to be queried. - * @param {string} request.pageToken - * The `next_page_token` value returned from a previous List request, if any. - * @param {string} request.filter - * List filter. For example, exclude all Memcached instances with name as - * my-instance by specifying `"name != my-instance"`. - * @param {string} request.orderBy - * Sort results. Supported values are "name", "name desc" or "" (unsorted). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.memcache.v1.Instance|Instance} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listInstancesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listInstances`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the instance location using the form: + * `projects/{project_id}/locations/{location_id}` + * where `location_id` refers to a GCP region + * @param {number} request.pageSize + * The maximum number of items to return. + * + * If not specified, a default value of 1000 will be used by the service. + * Regardless of the `page_size` value, the response may include a partial + * list and a caller should only rely on response's + * {@link protos.google.cloud.memcache.v1.ListInstancesResponse.next_page_token|`next_page_token`} + * to determine if there are more instances left to be queried. + * @param {string} request.pageToken + * The `next_page_token` value returned from a previous List request, if any. + * @param {string} request.filter + * List filter. For example, exclude all Memcached instances with name as + * my-instance by specifying `"name != my-instance"`. + * @param {string} request.orderBy + * Sort results. Supported values are "name", "name desc" or "" (unsorted). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.memcache.v1.Instance|Instance} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listInstancesStream( - request?: protos.google.cloud.memcache.v1.IListInstancesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.memcache.v1.IListInstancesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listInstances']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listInstances stream %j', request); return this.descriptors.page.listInstances.createStream( this.innerApiCalls.listInstances as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listInstances`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the instance location using the form: - * `projects/{project_id}/locations/{location_id}` - * where `location_id` refers to a GCP region - * @param {number} request.pageSize - * The maximum number of items to return. - * - * If not specified, a default value of 1000 will be used by the service. - * Regardless of the `page_size` value, the response may include a partial - * list and a caller should only rely on response's - * {@link protos.google.cloud.memcache.v1.ListInstancesResponse.next_page_token|`next_page_token`} - * to determine if there are more instances left to be queried. - * @param {string} request.pageToken - * The `next_page_token` value returned from a previous List request, if any. - * @param {string} request.filter - * List filter. For example, exclude all Memcached instances with name as - * my-instance by specifying `"name != my-instance"`. - * @param {string} request.orderBy - * Sort results. Supported values are "name", "name desc" or "" (unsorted). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.memcache.v1.Instance|Instance}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cloud_memcache.list_instances.js - * region_tag:memcache_v1_generated_CloudMemcache_ListInstances_async - */ + /** + * Equivalent to `listInstances`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the instance location using the form: + * `projects/{project_id}/locations/{location_id}` + * where `location_id` refers to a GCP region + * @param {number} request.pageSize + * The maximum number of items to return. + * + * If not specified, a default value of 1000 will be used by the service. + * Regardless of the `page_size` value, the response may include a partial + * list and a caller should only rely on response's + * {@link protos.google.cloud.memcache.v1.ListInstancesResponse.next_page_token|`next_page_token`} + * to determine if there are more instances left to be queried. + * @param {string} request.pageToken + * The `next_page_token` value returned from a previous List request, if any. + * @param {string} request.filter + * List filter. For example, exclude all Memcached instances with name as + * my-instance by specifying `"name != my-instance"`. + * @param {string} request.orderBy + * Sort results. Supported values are "name", "name desc" or "" (unsorted). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.memcache.v1.Instance|Instance}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cloud_memcache.list_instances.js + * region_tag:memcache_v1_generated_CloudMemcache_ListInstances_async + */ listInstancesAsync( - request?: protos.google.cloud.memcache.v1.IListInstancesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.memcache.v1.IListInstancesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listInstances']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listInstances iterate %j', request); return this.descriptors.page.listInstances.asyncIterate( this.innerApiCalls['listInstances'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** + + /** * Gets information about a location. * * @param {Object} request @@ -1476,12 +2015,11 @@ export class CloudMemcacheClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -1514,12 +2052,12 @@ export class CloudMemcacheClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -1562,22 +2100,22 @@ export class CloudMemcacheClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -1612,15 +2150,15 @@ export class CloudMemcacheClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - 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 ?? '', - }); + 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 ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -1654,7 +2192,7 @@ export class CloudMemcacheClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -1667,25 +2205,24 @@ export class CloudMemcacheClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -1724,22 +2261,22 @@ export class CloudMemcacheClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -1755,7 +2292,7 @@ export class CloudMemcacheClient { * @param {string} instance * @returns {string} Resource name string. */ - instancePath(project:string,location:string,instance:string) { + instancePath(project: string, location: string, instance: string) { return this.pathTemplates.instancePathTemplate.render({ project: project, location: location, @@ -1803,7 +2340,7 @@ export class CloudMemcacheClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -1840,14 +2377,16 @@ export class CloudMemcacheClient { */ close(): Promise { if (this.cloudMemcacheStub && !this._terminated) { - return this.cloudMemcacheStub.then(stub => { + return this.cloudMemcacheStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.locationsClient.close().catch(err => {throw err}); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-memcache/src/v1/index.ts b/packages/google-cloud-memcache/src/v1/index.ts index 0cc6f5474e9c..577c0eb2ec94 100644 --- a/packages/google-cloud-memcache/src/v1/index.ts +++ b/packages/google-cloud-memcache/src/v1/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {CloudMemcacheClient} from './cloud_memcache_client'; +export { CloudMemcacheClient } from './cloud_memcache_client'; diff --git a/packages/google-cloud-memcache/src/v1beta2/cloud_memcache_client.ts b/packages/google-cloud-memcache/src/v1beta2/cloud_memcache_client.ts index 16e3b7071e2c..1a33f314da9b 100644 --- a/packages/google-cloud-memcache/src/v1beta2/cloud_memcache_client.ts +++ b/packages/google-cloud-memcache/src/v1beta2/cloud_memcache_client.ts @@ -18,11 +18,22 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -58,7 +69,7 @@ export class CloudMemcacheClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('memcache'); @@ -71,11 +82,11 @@ export class CloudMemcacheClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - cloudMemcacheStub?: Promise<{[name: string]: Function}>; + cloudMemcacheStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of CloudMemcacheClient. @@ -116,21 +127,42 @@ export class CloudMemcacheClient { * const client = new CloudMemcacheClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof CloudMemcacheClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'memcache.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -155,7 +187,7 @@ export class CloudMemcacheClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -169,15 +201,11 @@ export class CloudMemcacheClient { } this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -199,10 +227,10 @@ export class CloudMemcacheClient { // Create useful helper objects for these. this.pathTemplates = { instancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/instances/{instance}' + 'projects/{project}/locations/{location}/instances/{instance}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), }; @@ -210,8 +238,11 @@ export class CloudMemcacheClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listInstances: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'resources') + listInstances: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'resources', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -220,77 +251,133 @@ export class CloudMemcacheClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1beta2/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1beta2/{name=projects/*}/locations',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1beta2/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1beta2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta2/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1beta2/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1beta2/{name=projects/*}/locations', + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1beta2/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1beta2/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1beta2/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1beta2/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.memcache.v1beta2.Instance') as gax.protobuf.Type; + '.google.cloud.memcache.v1beta2.Instance', + ) as gax.protobuf.Type; const createInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.memcache.v1beta2.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.memcache.v1beta2.OperationMetadata', + ) as gax.protobuf.Type; const updateInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.memcache.v1beta2.Instance') as gax.protobuf.Type; + '.google.cloud.memcache.v1beta2.Instance', + ) as gax.protobuf.Type; const updateInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.memcache.v1beta2.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.memcache.v1beta2.OperationMetadata', + ) as gax.protobuf.Type; const updateParametersResponse = protoFilesRoot.lookup( - '.google.cloud.memcache.v1beta2.Instance') as gax.protobuf.Type; + '.google.cloud.memcache.v1beta2.Instance', + ) as gax.protobuf.Type; const updateParametersMetadata = protoFilesRoot.lookup( - '.google.cloud.memcache.v1beta2.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.memcache.v1beta2.OperationMetadata', + ) as gax.protobuf.Type; const deleteInstanceResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.memcache.v1beta2.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.memcache.v1beta2.OperationMetadata', + ) as gax.protobuf.Type; const applyParametersResponse = protoFilesRoot.lookup( - '.google.cloud.memcache.v1beta2.Instance') as gax.protobuf.Type; + '.google.cloud.memcache.v1beta2.Instance', + ) as gax.protobuf.Type; const applyParametersMetadata = protoFilesRoot.lookup( - '.google.cloud.memcache.v1beta2.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.memcache.v1beta2.OperationMetadata', + ) as gax.protobuf.Type; const applySoftwareUpdateResponse = protoFilesRoot.lookup( - '.google.cloud.memcache.v1beta2.Instance') as gax.protobuf.Type; + '.google.cloud.memcache.v1beta2.Instance', + ) as gax.protobuf.Type; const applySoftwareUpdateMetadata = protoFilesRoot.lookup( - '.google.cloud.memcache.v1beta2.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.memcache.v1beta2.OperationMetadata', + ) as gax.protobuf.Type; const rescheduleMaintenanceResponse = protoFilesRoot.lookup( - '.google.cloud.memcache.v1beta2.Instance') as gax.protobuf.Type; + '.google.cloud.memcache.v1beta2.Instance', + ) as gax.protobuf.Type; const rescheduleMaintenanceMetadata = protoFilesRoot.lookup( - '.google.cloud.memcache.v1beta2.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.memcache.v1beta2.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createInstanceResponse.decode.bind(createInstanceResponse), - createInstanceMetadata.decode.bind(createInstanceMetadata)), + createInstanceMetadata.decode.bind(createInstanceMetadata), + ), updateInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateInstanceResponse.decode.bind(updateInstanceResponse), - updateInstanceMetadata.decode.bind(updateInstanceMetadata)), + updateInstanceMetadata.decode.bind(updateInstanceMetadata), + ), updateParameters: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateParametersResponse.decode.bind(updateParametersResponse), - updateParametersMetadata.decode.bind(updateParametersMetadata)), + updateParametersMetadata.decode.bind(updateParametersMetadata), + ), deleteInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteInstanceResponse.decode.bind(deleteInstanceResponse), - deleteInstanceMetadata.decode.bind(deleteInstanceMetadata)), + deleteInstanceMetadata.decode.bind(deleteInstanceMetadata), + ), applyParameters: new this._gaxModule.LongrunningDescriptor( this.operationsClient, applyParametersResponse.decode.bind(applyParametersResponse), - applyParametersMetadata.decode.bind(applyParametersMetadata)), + applyParametersMetadata.decode.bind(applyParametersMetadata), + ), applySoftwareUpdate: new this._gaxModule.LongrunningDescriptor( this.operationsClient, applySoftwareUpdateResponse.decode.bind(applySoftwareUpdateResponse), - applySoftwareUpdateMetadata.decode.bind(applySoftwareUpdateMetadata)), + applySoftwareUpdateMetadata.decode.bind(applySoftwareUpdateMetadata), + ), rescheduleMaintenance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - rescheduleMaintenanceResponse.decode.bind(rescheduleMaintenanceResponse), - rescheduleMaintenanceMetadata.decode.bind(rescheduleMaintenanceMetadata)) + rescheduleMaintenanceResponse.decode.bind( + rescheduleMaintenanceResponse, + ), + rescheduleMaintenanceMetadata.decode.bind( + rescheduleMaintenanceMetadata, + ), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.memcache.v1beta2.CloudMemcache', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.memcache.v1beta2.CloudMemcache', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -321,28 +408,43 @@ export class CloudMemcacheClient { // Put together the "service stub" for // google.cloud.memcache.v1beta2.CloudMemcache. this.cloudMemcacheStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.memcache.v1beta2.CloudMemcache') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.memcache.v1beta2.CloudMemcache', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.memcache.v1beta2.CloudMemcache, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const cloudMemcacheStubMethods = - ['listInstances', 'getInstance', 'createInstance', 'updateInstance', 'updateParameters', 'deleteInstance', 'applyParameters', 'applySoftwareUpdate', 'rescheduleMaintenance']; + const cloudMemcacheStubMethods = [ + 'listInstances', + 'getInstance', + 'createInstance', + 'updateInstance', + 'updateParameters', + 'deleteInstance', + 'applyParameters', + 'applySoftwareUpdate', + 'rescheduleMaintenance', + ]; for (const methodName of cloudMemcacheStubMethods) { const callPromise = this.cloudMemcacheStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -352,7 +454,7 @@ export class CloudMemcacheClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -367,8 +469,14 @@ export class CloudMemcacheClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'memcache.googleapis.com'; } @@ -379,8 +487,14 @@ export class CloudMemcacheClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'memcache.googleapis.com'; } @@ -411,9 +525,7 @@ export class CloudMemcacheClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -422,8 +534,9 @@ export class CloudMemcacheClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -434,1000 +547,1499 @@ export class CloudMemcacheClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets details of a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Memcached instance resource name in the format: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region - * @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 {@link protos.google.cloud.memcache.v1beta2.Instance|Instance}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta2/cloud_memcache.get_instance.js - * region_tag:memcache_v1beta2_generated_CloudMemcache_GetInstance_async - */ + /** + * Gets details of a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Memcached instance resource name in the format: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region + * @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 {@link protos.google.cloud.memcache.v1beta2.Instance|Instance}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta2/cloud_memcache.get_instance.js + * region_tag:memcache_v1beta2_generated_CloudMemcache_GetInstance_async + */ getInstance( - request?: protos.google.cloud.memcache.v1beta2.IGetInstanceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.memcache.v1beta2.IInstance, - protos.google.cloud.memcache.v1beta2.IGetInstanceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memcache.v1beta2.IGetInstanceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IGetInstanceRequest | undefined, + {} | undefined, + ] + >; getInstance( - request: protos.google.cloud.memcache.v1beta2.IGetInstanceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.memcache.v1beta2.IInstance, - protos.google.cloud.memcache.v1beta2.IGetInstanceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memcache.v1beta2.IGetInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.memcache.v1beta2.IInstance, + | protos.google.cloud.memcache.v1beta2.IGetInstanceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getInstance( - request: protos.google.cloud.memcache.v1beta2.IGetInstanceRequest, - callback: Callback< - protos.google.cloud.memcache.v1beta2.IInstance, - protos.google.cloud.memcache.v1beta2.IGetInstanceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memcache.v1beta2.IGetInstanceRequest, + callback: Callback< + protos.google.cloud.memcache.v1beta2.IInstance, + | protos.google.cloud.memcache.v1beta2.IGetInstanceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getInstance( - request?: protos.google.cloud.memcache.v1beta2.IGetInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.memcache.v1beta2.IInstance, - protos.google.cloud.memcache.v1beta2.IGetInstanceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.memcache.v1beta2.IGetInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.memcache.v1beta2.IInstance, - protos.google.cloud.memcache.v1beta2.IGetInstanceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.memcache.v1beta2.IInstance, - protos.google.cloud.memcache.v1beta2.IGetInstanceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.memcache.v1beta2.IGetInstanceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.memcache.v1beta2.IInstance, + | protos.google.cloud.memcache.v1beta2.IGetInstanceRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IGetInstanceRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getInstance request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.memcache.v1beta2.IInstance, - protos.google.cloud.memcache.v1beta2.IGetInstanceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.memcache.v1beta2.IInstance, + | protos.google.cloud.memcache.v1beta2.IGetInstanceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getInstance response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getInstance(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.memcache.v1beta2.IInstance, - protos.google.cloud.memcache.v1beta2.IGetInstanceRequest|undefined, - {}|undefined - ]) => { - this._log.info('getInstance response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getInstance(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IGetInstanceRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getInstance response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a new Instance in a given location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the instance location using the form: - * `projects/{project_id}/locations/{location_id}` - * where `location_id` refers to a GCP region - * @param {string} request.instanceId - * Required. The logical name of the Memcached instance in the user - * project with the following restrictions: - * - * * Must contain only lowercase letters, numbers, and hyphens. - * * Must start with a letter. - * * Must be between 1-40 characters. - * * Must end with a number or a letter. - * * Must be unique within the user project / location. - * - * If any of the above are not met, the API raises an invalid argument error. - * @param {google.cloud.memcache.v1beta2.Instance} request.resource - * Required. A Memcached [Instance] resource - * @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/v1beta2/cloud_memcache.create_instance.js - * region_tag:memcache_v1beta2_generated_CloudMemcache_CreateInstance_async - */ + /** + * Creates a new Instance in a given location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the instance location using the form: + * `projects/{project_id}/locations/{location_id}` + * where `location_id` refers to a GCP region + * @param {string} request.instanceId + * Required. The logical name of the Memcached instance in the user + * project with the following restrictions: + * + * * Must contain only lowercase letters, numbers, and hyphens. + * * Must start with a letter. + * * Must be between 1-40 characters. + * * Must end with a number or a letter. + * * Must be unique within the user project / location. + * + * If any of the above are not met, the API raises an invalid argument error. + * @param {google.cloud.memcache.v1beta2.Instance} request.resource + * Required. A Memcached [Instance] resource + * @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/v1beta2/cloud_memcache.create_instance.js + * region_tag:memcache_v1beta2_generated_CloudMemcache_CreateInstance_async + */ createInstance( - request?: protos.google.cloud.memcache.v1beta2.ICreateInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memcache.v1beta2.ICreateInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createInstance( - request: protos.google.cloud.memcache.v1beta2.ICreateInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memcache.v1beta2.ICreateInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createInstance( - request: protos.google.cloud.memcache.v1beta2.ICreateInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memcache.v1beta2.ICreateInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createInstance( - request?: protos.google.cloud.memcache.v1beta2.ICreateInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.memcache.v1beta2.ICreateInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createInstance request %j', request); - return this.innerApiCalls.createInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createInstance()`. - * @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/v1beta2/cloud_memcache.create_instance.js - * region_tag:memcache_v1beta2_generated_CloudMemcache_CreateInstance_async - */ - async checkCreateInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createInstance()`. + * @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/v1beta2/cloud_memcache.create_instance.js + * region_tag:memcache_v1beta2_generated_CloudMemcache_CreateInstance_async + */ + async checkCreateInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.memcache.v1beta2.Instance, + protos.google.cloud.memcache.v1beta2.OperationMetadata + > + > { this._log.info('createInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.memcache.v1beta2.Instance, + protos.google.cloud.memcache.v1beta2.OperationMetadata + >; } -/** - * Updates an existing Instance in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Mask of fields to update. - * - * * `displayName` - * @param {google.cloud.memcache.v1beta2.Instance} request.resource - * Required. A Memcached [Instance] resource. - * Only fields specified in update_mask are updated. - * @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/v1beta2/cloud_memcache.update_instance.js - * region_tag:memcache_v1beta2_generated_CloudMemcache_UpdateInstance_async - */ + /** + * Updates an existing Instance in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Mask of fields to update. + * + * * `displayName` + * @param {google.cloud.memcache.v1beta2.Instance} request.resource + * Required. A Memcached [Instance] resource. + * Only fields specified in update_mask are updated. + * @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/v1beta2/cloud_memcache.update_instance.js + * region_tag:memcache_v1beta2_generated_CloudMemcache_UpdateInstance_async + */ updateInstance( - request?: protos.google.cloud.memcache.v1beta2.IUpdateInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memcache.v1beta2.IUpdateInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateInstance( - request: protos.google.cloud.memcache.v1beta2.IUpdateInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memcache.v1beta2.IUpdateInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateInstance( - request: protos.google.cloud.memcache.v1beta2.IUpdateInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memcache.v1beta2.IUpdateInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateInstance( - request?: protos.google.cloud.memcache.v1beta2.IUpdateInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.memcache.v1beta2.IUpdateInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'resource.name': request.resource!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'resource.name': request.resource!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateInstance request %j', request); - return this.innerApiCalls.updateInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateInstance()`. - * @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/v1beta2/cloud_memcache.update_instance.js - * region_tag:memcache_v1beta2_generated_CloudMemcache_UpdateInstance_async - */ - async checkUpdateInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateInstance()`. + * @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/v1beta2/cloud_memcache.update_instance.js + * region_tag:memcache_v1beta2_generated_CloudMemcache_UpdateInstance_async + */ + async checkUpdateInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.memcache.v1beta2.Instance, + protos.google.cloud.memcache.v1beta2.OperationMetadata + > + > { this._log.info('updateInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.memcache.v1beta2.Instance, + protos.google.cloud.memcache.v1beta2.OperationMetadata + >; } -/** - * Updates the defined Memcached parameters for an existing instance. - * This method only stages the parameters, it must be followed by - * `ApplyParameters` to apply the parameters to nodes of the Memcached - * instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the Memcached instance for which the parameters should be - * updated. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Mask of fields to update. - * @param {google.cloud.memcache.v1beta2.MemcacheParameters} request.parameters - * The parameters to apply to the instance. - * @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/v1beta2/cloud_memcache.update_parameters.js - * region_tag:memcache_v1beta2_generated_CloudMemcache_UpdateParameters_async - */ + /** + * Updates the defined Memcached parameters for an existing instance. + * This method only stages the parameters, it must be followed by + * `ApplyParameters` to apply the parameters to nodes of the Memcached + * instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the Memcached instance for which the parameters should be + * updated. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Mask of fields to update. + * @param {google.cloud.memcache.v1beta2.MemcacheParameters} request.parameters + * The parameters to apply to the instance. + * @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/v1beta2/cloud_memcache.update_parameters.js + * region_tag:memcache_v1beta2_generated_CloudMemcache_UpdateParameters_async + */ updateParameters( - request?: protos.google.cloud.memcache.v1beta2.IUpdateParametersRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memcache.v1beta2.IUpdateParametersRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateParameters( - request: protos.google.cloud.memcache.v1beta2.IUpdateParametersRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memcache.v1beta2.IUpdateParametersRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateParameters( - request: protos.google.cloud.memcache.v1beta2.IUpdateParametersRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memcache.v1beta2.IUpdateParametersRequest, + callback: Callback< + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateParameters( - request?: protos.google.cloud.memcache.v1beta2.IUpdateParametersRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.memcache.v1beta2.IUpdateParametersRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateParameters response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateParameters request %j', request); - return this.innerApiCalls.updateParameters(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateParameters response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateParameters(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateParameters response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateParameters()`. - * @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/v1beta2/cloud_memcache.update_parameters.js - * region_tag:memcache_v1beta2_generated_CloudMemcache_UpdateParameters_async - */ - async checkUpdateParametersProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateParameters()`. + * @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/v1beta2/cloud_memcache.update_parameters.js + * region_tag:memcache_v1beta2_generated_CloudMemcache_UpdateParameters_async + */ + async checkUpdateParametersProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.memcache.v1beta2.Instance, + protos.google.cloud.memcache.v1beta2.OperationMetadata + > + > { this._log.info('updateParameters long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateParameters, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateParameters, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.memcache.v1beta2.Instance, + protos.google.cloud.memcache.v1beta2.OperationMetadata + >; } -/** - * Deletes a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Memcached instance resource name in the format: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region - * @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/v1beta2/cloud_memcache.delete_instance.js - * region_tag:memcache_v1beta2_generated_CloudMemcache_DeleteInstance_async - */ + /** + * Deletes a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Memcached instance resource name in the format: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region + * @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/v1beta2/cloud_memcache.delete_instance.js + * region_tag:memcache_v1beta2_generated_CloudMemcache_DeleteInstance_async + */ deleteInstance( - request?: protos.google.cloud.memcache.v1beta2.IDeleteInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memcache.v1beta2.IDeleteInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteInstance( - request: protos.google.cloud.memcache.v1beta2.IDeleteInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memcache.v1beta2.IDeleteInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteInstance( - request: protos.google.cloud.memcache.v1beta2.IDeleteInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memcache.v1beta2.IDeleteInstanceRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteInstance( - request?: protos.google.cloud.memcache.v1beta2.IDeleteInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.memcache.v1beta2.IDeleteInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteInstance request %j', request); - return this.innerApiCalls.deleteInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteInstance()`. - * @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/v1beta2/cloud_memcache.delete_instance.js - * region_tag:memcache_v1beta2_generated_CloudMemcache_DeleteInstance_async - */ - async checkDeleteInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteInstance()`. + * @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/v1beta2/cloud_memcache.delete_instance.js + * region_tag:memcache_v1beta2_generated_CloudMemcache_DeleteInstance_async + */ + async checkDeleteInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.memcache.v1beta2.OperationMetadata + > + > { this._log.info('deleteInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.memcache.v1beta2.OperationMetadata + >; } -/** - * `ApplyParameters` restarts the set of specified nodes in order to update - * them to the current set of parameters for the Memcached Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the Memcached instance for which parameter group updates - * should be applied. - * @param {string[]} request.nodeIds - * Nodes to which the instance-level parameter group is applied. - * @param {boolean} request.applyAll - * Whether to apply instance-level parameter group to all nodes. If set to - * true, users are restricted from specifying individual nodes, and - * `ApplyParameters` updates all nodes within the instance. - * @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/v1beta2/cloud_memcache.apply_parameters.js - * region_tag:memcache_v1beta2_generated_CloudMemcache_ApplyParameters_async - */ + /** + * `ApplyParameters` restarts the set of specified nodes in order to update + * them to the current set of parameters for the Memcached Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the Memcached instance for which parameter group updates + * should be applied. + * @param {string[]} request.nodeIds + * Nodes to which the instance-level parameter group is applied. + * @param {boolean} request.applyAll + * Whether to apply instance-level parameter group to all nodes. If set to + * true, users are restricted from specifying individual nodes, and + * `ApplyParameters` updates all nodes within the instance. + * @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/v1beta2/cloud_memcache.apply_parameters.js + * region_tag:memcache_v1beta2_generated_CloudMemcache_ApplyParameters_async + */ applyParameters( - request?: protos.google.cloud.memcache.v1beta2.IApplyParametersRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memcache.v1beta2.IApplyParametersRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; applyParameters( - request: protos.google.cloud.memcache.v1beta2.IApplyParametersRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memcache.v1beta2.IApplyParametersRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; applyParameters( - request: protos.google.cloud.memcache.v1beta2.IApplyParametersRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memcache.v1beta2.IApplyParametersRequest, + callback: Callback< + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; applyParameters( - request?: protos.google.cloud.memcache.v1beta2.IApplyParametersRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.memcache.v1beta2.IApplyParametersRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('applyParameters response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('applyParameters request %j', request); - return this.innerApiCalls.applyParameters(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('applyParameters response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .applyParameters(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('applyParameters response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `applyParameters()`. - * @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/v1beta2/cloud_memcache.apply_parameters.js - * region_tag:memcache_v1beta2_generated_CloudMemcache_ApplyParameters_async - */ - async checkApplyParametersProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `applyParameters()`. + * @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/v1beta2/cloud_memcache.apply_parameters.js + * region_tag:memcache_v1beta2_generated_CloudMemcache_ApplyParameters_async + */ + async checkApplyParametersProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.memcache.v1beta2.Instance, + protos.google.cloud.memcache.v1beta2.OperationMetadata + > + > { this._log.info('applyParameters long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.applyParameters, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.applyParameters, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.memcache.v1beta2.Instance, + protos.google.cloud.memcache.v1beta2.OperationMetadata + >; } -/** - * Updates software on the selected nodes of the Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Required. Resource name of the Memcached instance for which software update should be - * applied. - * @param {string[]} request.nodeIds - * Nodes to which we should apply the update to. Note all the selected nodes - * are updated in parallel. - * @param {boolean} request.applyAll - * Whether to apply the update to all nodes. If set to - * true, will explicitly restrict users from specifying any nodes, and apply - * software update to all nodes (where applicable) within the instance. - * @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/v1beta2/cloud_memcache.apply_software_update.js - * region_tag:memcache_v1beta2_generated_CloudMemcache_ApplySoftwareUpdate_async - */ + /** + * Updates software on the selected nodes of the Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Required. Resource name of the Memcached instance for which software update should be + * applied. + * @param {string[]} request.nodeIds + * Nodes to which we should apply the update to. Note all the selected nodes + * are updated in parallel. + * @param {boolean} request.applyAll + * Whether to apply the update to all nodes. If set to + * true, will explicitly restrict users from specifying any nodes, and apply + * software update to all nodes (where applicable) within the instance. + * @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/v1beta2/cloud_memcache.apply_software_update.js + * region_tag:memcache_v1beta2_generated_CloudMemcache_ApplySoftwareUpdate_async + */ applySoftwareUpdate( - request?: protos.google.cloud.memcache.v1beta2.IApplySoftwareUpdateRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memcache.v1beta2.IApplySoftwareUpdateRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; applySoftwareUpdate( - request: protos.google.cloud.memcache.v1beta2.IApplySoftwareUpdateRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memcache.v1beta2.IApplySoftwareUpdateRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; applySoftwareUpdate( - request: protos.google.cloud.memcache.v1beta2.IApplySoftwareUpdateRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memcache.v1beta2.IApplySoftwareUpdateRequest, + callback: Callback< + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; applySoftwareUpdate( - request?: protos.google.cloud.memcache.v1beta2.IApplySoftwareUpdateRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.memcache.v1beta2.IApplySoftwareUpdateRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('applySoftwareUpdate response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('applySoftwareUpdate request %j', request); - return this.innerApiCalls.applySoftwareUpdate(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('applySoftwareUpdate response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .applySoftwareUpdate(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('applySoftwareUpdate response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `applySoftwareUpdate()`. - * @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/v1beta2/cloud_memcache.apply_software_update.js - * region_tag:memcache_v1beta2_generated_CloudMemcache_ApplySoftwareUpdate_async - */ - async checkApplySoftwareUpdateProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `applySoftwareUpdate()`. + * @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/v1beta2/cloud_memcache.apply_software_update.js + * region_tag:memcache_v1beta2_generated_CloudMemcache_ApplySoftwareUpdate_async + */ + async checkApplySoftwareUpdateProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.memcache.v1beta2.Instance, + protos.google.cloud.memcache.v1beta2.OperationMetadata + > + > { this._log.info('applySoftwareUpdate long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.applySoftwareUpdate, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.applySoftwareUpdate, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.memcache.v1beta2.Instance, + protos.google.cloud.memcache.v1beta2.OperationMetadata + >; } -/** - * Performs the apply phase of the RescheduleMaintenance verb. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Required. Memcache instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a GCP region. - * @param {google.cloud.memcache.v1beta2.RescheduleMaintenanceRequest.RescheduleType} request.rescheduleType - * Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as well. - * @param {google.protobuf.Timestamp} request.scheduleTime - * Timestamp when the maintenance shall be rescheduled to if - * reschedule_type=SPECIFIC_TIME, in RFC 3339 format, for - * example `2012-11-15T16:19:00.094Z`. - * @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/v1beta2/cloud_memcache.reschedule_maintenance.js - * region_tag:memcache_v1beta2_generated_CloudMemcache_RescheduleMaintenance_async - */ + /** + * Performs the apply phase of the RescheduleMaintenance verb. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Required. Memcache instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a GCP region. + * @param {google.cloud.memcache.v1beta2.RescheduleMaintenanceRequest.RescheduleType} request.rescheduleType + * Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as well. + * @param {google.protobuf.Timestamp} request.scheduleTime + * Timestamp when the maintenance shall be rescheduled to if + * reschedule_type=SPECIFIC_TIME, in RFC 3339 format, for + * example `2012-11-15T16:19:00.094Z`. + * @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/v1beta2/cloud_memcache.reschedule_maintenance.js + * region_tag:memcache_v1beta2_generated_CloudMemcache_RescheduleMaintenance_async + */ rescheduleMaintenance( - request?: protos.google.cloud.memcache.v1beta2.IRescheduleMaintenanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memcache.v1beta2.IRescheduleMaintenanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; rescheduleMaintenance( - request: protos.google.cloud.memcache.v1beta2.IRescheduleMaintenanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memcache.v1beta2.IRescheduleMaintenanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; rescheduleMaintenance( - request: protos.google.cloud.memcache.v1beta2.IRescheduleMaintenanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memcache.v1beta2.IRescheduleMaintenanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; rescheduleMaintenance( - request?: protos.google.cloud.memcache.v1beta2.IRescheduleMaintenanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.memcache.v1beta2.IRescheduleMaintenanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('rescheduleMaintenance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('rescheduleMaintenance request %j', request); - return this.innerApiCalls.rescheduleMaintenance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('rescheduleMaintenance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .rescheduleMaintenance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('rescheduleMaintenance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `rescheduleMaintenance()`. - * @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/v1beta2/cloud_memcache.reschedule_maintenance.js - * region_tag:memcache_v1beta2_generated_CloudMemcache_RescheduleMaintenance_async - */ - async checkRescheduleMaintenanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `rescheduleMaintenance()`. + * @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/v1beta2/cloud_memcache.reschedule_maintenance.js + * region_tag:memcache_v1beta2_generated_CloudMemcache_RescheduleMaintenance_async + */ + async checkRescheduleMaintenanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.memcache.v1beta2.Instance, + protos.google.cloud.memcache.v1beta2.OperationMetadata + > + > { this._log.info('rescheduleMaintenance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.rescheduleMaintenance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.rescheduleMaintenance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.memcache.v1beta2.Instance, + protos.google.cloud.memcache.v1beta2.OperationMetadata + >; } - /** - * Lists Instances in a given location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the instance location using the form: - * `projects/{project_id}/locations/{location_id}` - * where `location_id` refers to a GCP region - * @param {number} request.pageSize - * The maximum number of items to return. - * - * If not specified, a default value of 1000 will be used by the service. - * Regardless of the `page_size` value, the response may include a partial - * list and a caller should only rely on response's - * {@link protos.google.cloud.memcache.v1beta2.ListInstancesResponse.next_page_token|`next_page_token`} - * to determine if there are more instances left to be queried. - * @param {string} request.pageToken - * The `next_page_token` value returned from a previous List request, if any. - * @param {string} request.filter - * List filter. For example, exclude all Memcached instances with name as - * my-instance by specifying `"name != my-instance"`. - * @param {string} request.orderBy - * Sort results. Supported values are "name", "name desc" or "" (unsorted). - * @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 Array of {@link protos.google.cloud.memcache.v1beta2.Instance|Instance}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listInstancesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists Instances in a given location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the instance location using the form: + * `projects/{project_id}/locations/{location_id}` + * where `location_id` refers to a GCP region + * @param {number} request.pageSize + * The maximum number of items to return. + * + * If not specified, a default value of 1000 will be used by the service. + * Regardless of the `page_size` value, the response may include a partial + * list and a caller should only rely on response's + * {@link protos.google.cloud.memcache.v1beta2.ListInstancesResponse.next_page_token|`next_page_token`} + * to determine if there are more instances left to be queried. + * @param {string} request.pageToken + * The `next_page_token` value returned from a previous List request, if any. + * @param {string} request.filter + * List filter. For example, exclude all Memcached instances with name as + * my-instance by specifying `"name != my-instance"`. + * @param {string} request.orderBy + * Sort results. Supported values are "name", "name desc" or "" (unsorted). + * @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 Array of {@link protos.google.cloud.memcache.v1beta2.Instance|Instance}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listInstances( - request?: protos.google.cloud.memcache.v1beta2.IListInstancesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.memcache.v1beta2.IInstance[], - protos.google.cloud.memcache.v1beta2.IListInstancesRequest|null, - protos.google.cloud.memcache.v1beta2.IListInstancesResponse - ]>; + request?: protos.google.cloud.memcache.v1beta2.IListInstancesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.memcache.v1beta2.IInstance[], + protos.google.cloud.memcache.v1beta2.IListInstancesRequest | null, + protos.google.cloud.memcache.v1beta2.IListInstancesResponse, + ] + >; listInstances( - request: protos.google.cloud.memcache.v1beta2.IListInstancesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.memcache.v1beta2.IListInstancesRequest, - protos.google.cloud.memcache.v1beta2.IListInstancesResponse|null|undefined, - protos.google.cloud.memcache.v1beta2.IInstance>): void; + request: protos.google.cloud.memcache.v1beta2.IListInstancesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.memcache.v1beta2.IListInstancesRequest, + | protos.google.cloud.memcache.v1beta2.IListInstancesResponse + | null + | undefined, + protos.google.cloud.memcache.v1beta2.IInstance + >, + ): void; listInstances( - request: protos.google.cloud.memcache.v1beta2.IListInstancesRequest, - callback: PaginationCallback< - protos.google.cloud.memcache.v1beta2.IListInstancesRequest, - protos.google.cloud.memcache.v1beta2.IListInstancesResponse|null|undefined, - protos.google.cloud.memcache.v1beta2.IInstance>): void; + request: protos.google.cloud.memcache.v1beta2.IListInstancesRequest, + callback: PaginationCallback< + protos.google.cloud.memcache.v1beta2.IListInstancesRequest, + | protos.google.cloud.memcache.v1beta2.IListInstancesResponse + | null + | undefined, + protos.google.cloud.memcache.v1beta2.IInstance + >, + ): void; listInstances( - request?: protos.google.cloud.memcache.v1beta2.IListInstancesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.memcache.v1beta2.IListInstancesRequest, - protos.google.cloud.memcache.v1beta2.IListInstancesResponse|null|undefined, - protos.google.cloud.memcache.v1beta2.IInstance>, - callback?: PaginationCallback< + request?: protos.google.cloud.memcache.v1beta2.IListInstancesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.memcache.v1beta2.IListInstancesRequest, - protos.google.cloud.memcache.v1beta2.IListInstancesResponse|null|undefined, - protos.google.cloud.memcache.v1beta2.IInstance>): - Promise<[ - protos.google.cloud.memcache.v1beta2.IInstance[], - protos.google.cloud.memcache.v1beta2.IListInstancesRequest|null, - protos.google.cloud.memcache.v1beta2.IListInstancesResponse - ]>|void { + | protos.google.cloud.memcache.v1beta2.IListInstancesResponse + | null + | undefined, + protos.google.cloud.memcache.v1beta2.IInstance + >, + callback?: PaginationCallback< + protos.google.cloud.memcache.v1beta2.IListInstancesRequest, + | protos.google.cloud.memcache.v1beta2.IListInstancesResponse + | null + | undefined, + protos.google.cloud.memcache.v1beta2.IInstance + >, + ): Promise< + [ + protos.google.cloud.memcache.v1beta2.IInstance[], + protos.google.cloud.memcache.v1beta2.IListInstancesRequest | null, + protos.google.cloud.memcache.v1beta2.IListInstancesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.memcache.v1beta2.IListInstancesRequest, - protos.google.cloud.memcache.v1beta2.IListInstancesResponse|null|undefined, - protos.google.cloud.memcache.v1beta2.IInstance>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.memcache.v1beta2.IListInstancesRequest, + | protos.google.cloud.memcache.v1beta2.IListInstancesResponse + | null + | undefined, + protos.google.cloud.memcache.v1beta2.IInstance + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listInstances values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1436,135 +2048,140 @@ export class CloudMemcacheClient { this._log.info('listInstances request %j', request); return this.innerApiCalls .listInstances(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.memcache.v1beta2.IInstance[], - protos.google.cloud.memcache.v1beta2.IListInstancesRequest|null, - protos.google.cloud.memcache.v1beta2.IListInstancesResponse - ]) => { - this._log.info('listInstances values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.memcache.v1beta2.IInstance[], + protos.google.cloud.memcache.v1beta2.IListInstancesRequest | null, + protos.google.cloud.memcache.v1beta2.IListInstancesResponse, + ]) => { + this._log.info('listInstances values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listInstances`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the instance location using the form: - * `projects/{project_id}/locations/{location_id}` - * where `location_id` refers to a GCP region - * @param {number} request.pageSize - * The maximum number of items to return. - * - * If not specified, a default value of 1000 will be used by the service. - * Regardless of the `page_size` value, the response may include a partial - * list and a caller should only rely on response's - * {@link protos.google.cloud.memcache.v1beta2.ListInstancesResponse.next_page_token|`next_page_token`} - * to determine if there are more instances left to be queried. - * @param {string} request.pageToken - * The `next_page_token` value returned from a previous List request, if any. - * @param {string} request.filter - * List filter. For example, exclude all Memcached instances with name as - * my-instance by specifying `"name != my-instance"`. - * @param {string} request.orderBy - * Sort results. Supported values are "name", "name desc" or "" (unsorted). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.memcache.v1beta2.Instance|Instance} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listInstancesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listInstances`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the instance location using the form: + * `projects/{project_id}/locations/{location_id}` + * where `location_id` refers to a GCP region + * @param {number} request.pageSize + * The maximum number of items to return. + * + * If not specified, a default value of 1000 will be used by the service. + * Regardless of the `page_size` value, the response may include a partial + * list and a caller should only rely on response's + * {@link protos.google.cloud.memcache.v1beta2.ListInstancesResponse.next_page_token|`next_page_token`} + * to determine if there are more instances left to be queried. + * @param {string} request.pageToken + * The `next_page_token` value returned from a previous List request, if any. + * @param {string} request.filter + * List filter. For example, exclude all Memcached instances with name as + * my-instance by specifying `"name != my-instance"`. + * @param {string} request.orderBy + * Sort results. Supported values are "name", "name desc" or "" (unsorted). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.memcache.v1beta2.Instance|Instance} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listInstancesStream( - request?: protos.google.cloud.memcache.v1beta2.IListInstancesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.memcache.v1beta2.IListInstancesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listInstances']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listInstances stream %j', request); return this.descriptors.page.listInstances.createStream( this.innerApiCalls.listInstances as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listInstances`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the instance location using the form: - * `projects/{project_id}/locations/{location_id}` - * where `location_id` refers to a GCP region - * @param {number} request.pageSize - * The maximum number of items to return. - * - * If not specified, a default value of 1000 will be used by the service. - * Regardless of the `page_size` value, the response may include a partial - * list and a caller should only rely on response's - * {@link protos.google.cloud.memcache.v1beta2.ListInstancesResponse.next_page_token|`next_page_token`} - * to determine if there are more instances left to be queried. - * @param {string} request.pageToken - * The `next_page_token` value returned from a previous List request, if any. - * @param {string} request.filter - * List filter. For example, exclude all Memcached instances with name as - * my-instance by specifying `"name != my-instance"`. - * @param {string} request.orderBy - * Sort results. Supported values are "name", "name desc" or "" (unsorted). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.memcache.v1beta2.Instance|Instance}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta2/cloud_memcache.list_instances.js - * region_tag:memcache_v1beta2_generated_CloudMemcache_ListInstances_async - */ + /** + * Equivalent to `listInstances`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the instance location using the form: + * `projects/{project_id}/locations/{location_id}` + * where `location_id` refers to a GCP region + * @param {number} request.pageSize + * The maximum number of items to return. + * + * If not specified, a default value of 1000 will be used by the service. + * Regardless of the `page_size` value, the response may include a partial + * list and a caller should only rely on response's + * {@link protos.google.cloud.memcache.v1beta2.ListInstancesResponse.next_page_token|`next_page_token`} + * to determine if there are more instances left to be queried. + * @param {string} request.pageToken + * The `next_page_token` value returned from a previous List request, if any. + * @param {string} request.filter + * List filter. For example, exclude all Memcached instances with name as + * my-instance by specifying `"name != my-instance"`. + * @param {string} request.orderBy + * Sort results. Supported values are "name", "name desc" or "" (unsorted). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.memcache.v1beta2.Instance|Instance}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta2/cloud_memcache.list_instances.js + * region_tag:memcache_v1beta2_generated_CloudMemcache_ListInstances_async + */ listInstancesAsync( - request?: protos.google.cloud.memcache.v1beta2.IListInstancesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.memcache.v1beta2.IListInstancesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listInstances']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listInstances iterate %j', request); return this.descriptors.page.listInstances.asyncIterate( this.innerApiCalls['listInstances'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** + + /** * Gets information about a location. * * @param {Object} request @@ -1599,12 +2216,11 @@ export class CloudMemcacheClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -1637,12 +2253,12 @@ export class CloudMemcacheClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -1685,22 +2301,22 @@ export class CloudMemcacheClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -1735,15 +2351,15 @@ export class CloudMemcacheClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - 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 ?? '', - }); + 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 ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -1777,7 +2393,7 @@ export class CloudMemcacheClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -1790,25 +2406,24 @@ export class CloudMemcacheClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -1847,22 +2462,22 @@ export class CloudMemcacheClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -1878,7 +2493,7 @@ export class CloudMemcacheClient { * @param {string} instance * @returns {string} Resource name string. */ - instancePath(project:string,location:string,instance:string) { + instancePath(project: string, location: string, instance: string) { return this.pathTemplates.instancePathTemplate.render({ project: project, location: location, @@ -1926,7 +2541,7 @@ export class CloudMemcacheClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -1963,14 +2578,16 @@ export class CloudMemcacheClient { */ close(): Promise { if (this.cloudMemcacheStub && !this._terminated) { - return this.cloudMemcacheStub.then(stub => { + return this.cloudMemcacheStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.locationsClient.close().catch(err => {throw err}); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-memcache/src/v1beta2/index.ts b/packages/google-cloud-memcache/src/v1beta2/index.ts index 0cc6f5474e9c..577c0eb2ec94 100644 --- a/packages/google-cloud-memcache/src/v1beta2/index.ts +++ b/packages/google-cloud-memcache/src/v1beta2/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {CloudMemcacheClient} from './cloud_memcache_client'; +export { CloudMemcacheClient } from './cloud_memcache_client'; diff --git a/packages/google-cloud-memcache/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-memcache/system-test/fixtures/sample/src/index.ts index bf5979a21323..d844bfce309e 100644 --- a/packages/google-cloud-memcache/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-memcache/system-test/fixtures/sample/src/index.ts @@ -16,7 +16,7 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {CloudMemcacheClient} from '@google-cloud/memcache'; +import { CloudMemcacheClient } from '@google-cloud/memcache'; // check that the client class type name can be used function doStuffWithCloudMemcacheClient(client: CloudMemcacheClient) { diff --git a/packages/google-cloud-memcache/system-test/install.ts b/packages/google-cloud-memcache/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-memcache/system-test/install.ts +++ b/packages/google-cloud-memcache/system-test/install.ts @@ -16,34 +16,36 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {packNTest} from 'pack-n-play'; -import {readFileSync} from 'fs'; -import {describe, it} from 'mocha'; +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; +import { describe, it } from 'mocha'; describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { + it('TypeScript code', async function () { this.timeout(300000); const options = { packageDir: process.cwd(), sample: { description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } + ts: readFileSync( + './system-test/fixtures/sample/src/index.ts', + ).toString(), + }, }; await packNTest(options); }); - it('JavaScript code', async function() { + it('JavaScript code', async function () { this.timeout(300000); const options = { packageDir: process.cwd(), sample: { description: 'JavaScript user can use the library', - cjs: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } + cjs: readFileSync( + './system-test/fixtures/sample/src/index.js', + ).toString(), + }, }; await packNTest(options); }); - }); diff --git a/packages/google-cloud-memcache/test/gapic_cloud_memcache_v1.ts b/packages/google-cloud-memcache/test/gapic_cloud_memcache_v1.ts index a0bb53d4f51c..441100e1679e 100644 --- a/packages/google-cloud-memcache/test/gapic_cloud_memcache_v1.ts +++ b/packages/google-cloud-memcache/test/gapic_cloud_memcache_v1.ts @@ -19,2048 +19,2570 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as cloudmemcacheModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1.CloudMemcacheClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'memcache.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = cloudmemcacheModule.v1.CloudMemcacheClient.servicePath; - assert.strictEqual(servicePath, 'memcache.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = cloudmemcacheModule.v1.CloudMemcacheClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'memcache.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'memcache.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'memcache.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new cloudmemcacheModule.v1.CloudMemcacheClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'memcache.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'memcache.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new cloudmemcacheModule.v1.CloudMemcacheClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = cloudmemcacheModule.v1.CloudMemcacheClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudMemcacheStub, undefined); - await client.initialize(); - assert(client.cloudMemcacheStub); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'memcache.googleapis.com'); + }); - it('has close method for the initialized client', done => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.cloudMemcacheStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has universeDomain', () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has close method for the non-initialized client', done => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudMemcacheStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + cloudmemcacheModule.v1.CloudMemcacheClient.servicePath; + assert.strictEqual(servicePath, 'memcache.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + cloudmemcacheModule.v1.CloudMemcacheClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'memcache.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'memcache.example.com'); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'memcache.example.com'); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new cloudmemcacheModule.v1.CloudMemcacheClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'memcache.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'memcache.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new cloudmemcacheModule.v1.CloudMemcacheClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); }); - describe('getInstance', () => { - it('invokes getInstance without error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.memcache.v1.Instance() - ); - client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); - const [response] = await client.getInstance(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has port', () => { + const port = cloudmemcacheModule.v1.CloudMemcacheClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('invokes getInstance without error using callback', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.memcache.v1.Instance() - ); - client.innerApiCalls.getInstance = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getInstance( - request, - (err?: Error|null, result?: protos.google.cloud.memcache.v1.IInstance|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('should create a client with no option', () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient(); + assert(client); + }); - it('invokes getInstance with error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getInstance = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('should create a client with gRPC fallback', () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + fallback: true, + }); + assert(client); + }); - it('invokes getInstance with closed client', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getInstance(request), expectedError); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudMemcacheStub, undefined); + await client.initialize(); + assert(client.cloudMemcacheStub); }); - describe('createInstance', () => { - it('invokes createInstance without error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.createInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the initialized client', (done) => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.cloudMemcacheStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes createInstance without error using callback', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the non-initialized client', (done) => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudMemcacheStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes createInstance with call error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('invokes createInstance with LRO error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getInstance', () => { + it('invokes getInstance without error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.memcache.v1.Instance(), + ); + client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); + const [response] = await client.getInstance(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateInstanceProgress without error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes getInstance without error using callback', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.memcache.v1.Instance(), + ); + client.innerApiCalls.getInstance = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getInstance( + request, + ( + err?: Error | null, + result?: protos.google.cloud.memcache.v1.IInstance | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateInstanceProgress with error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes getInstance with error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getInstance = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateInstance', () => { - it('invokes updateInstance without error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getInstance with closed client', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getInstance(request), expectedError); + }); + }); + + describe('createInstance', () => { + it('invokes createInstance without error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.CreateInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.CreateInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateInstance without error using callback', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createInstance without error using callback', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.CreateInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.CreateInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateInstance with call error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createInstance with call error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.CreateInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.CreateInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateInstance with LRO error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createInstance with LRO error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.CreateInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.CreateInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateInstanceProgress without error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkCreateInstanceProgress without error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkUpdateInstanceProgress with error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateInstanceProgress with error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateInstance', () => { + it('invokes updateInstance without error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.UpdateInstanceRequest(), + ); + request.instance ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.UpdateInstanceRequest', + ['instance', 'name'], + ); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateParameters', () => { - it('invokes updateParameters without error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.UpdateParametersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.UpdateParametersRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateParameters = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateParameters(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateParameters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateParameters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateInstance without error using callback', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.UpdateInstanceRequest(), + ); + request.instance ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.UpdateInstanceRequest', + ['instance', 'name'], + ); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateParameters without error using callback', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.UpdateParametersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.UpdateParametersRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateParameters = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateParameters( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateParameters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateParameters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateInstance with call error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.UpdateInstanceRequest(), + ); + request.instance ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.UpdateInstanceRequest', + ['instance', 'name'], + ); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateParameters with call error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.UpdateParametersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.UpdateParametersRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateParameters = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateParameters(request), expectedError); - const actualRequest = (client.innerApiCalls.updateParameters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateParameters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateInstance with LRO error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.UpdateInstanceRequest(), + ); + request.instance ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.UpdateInstanceRequest', + ['instance', 'name'], + ); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateParameters with LRO error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.UpdateParametersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.UpdateParametersRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateParameters = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateParameters(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateParameters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateParameters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateInstanceProgress without error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkUpdateParametersProgress without error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateParametersProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateInstanceProgress with error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateParameters', () => { + it('invokes updateParameters without error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.UpdateParametersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.UpdateParametersRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateParameters = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateParameters(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateParameters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateParameters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateParametersProgress with error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateParametersProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateParameters without error using callback', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.UpdateParametersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.UpdateParametersRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateParameters = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateParameters( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateParameters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateParameters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteInstance', () => { - it('invokes deleteInstance without error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateParameters with call error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.UpdateParametersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.UpdateParametersRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateParameters = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateParameters(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateParameters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateParameters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteInstance without error using callback', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateParameters with LRO error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.UpdateParametersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.UpdateParametersRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateParameters = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateParameters(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateParameters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateParameters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteInstance with call error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateParametersProgress without error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateParametersProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteInstance with LRO error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateParametersProgress with error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateParametersProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteInstance', () => { + it('invokes deleteInstance without error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.DeleteInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.DeleteInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteInstanceProgress without error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteInstance without error using callback', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.DeleteInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.DeleteInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memcache.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memcache.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteInstanceProgress with error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteInstance with call error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.DeleteInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.DeleteInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('applyParameters', () => { - it('invokes applyParameters without error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.ApplyParametersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.ApplyParametersRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.applyParameters = stubLongRunningCall(expectedResponse); - const [operation] = await client.applyParameters(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.applyParameters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.applyParameters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteInstance with LRO error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.DeleteInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.DeleteInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes applyParameters without error using callback', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.ApplyParametersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.ApplyParametersRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.applyParameters = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.applyParameters( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.applyParameters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.applyParameters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteInstanceProgress without error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes applyParameters with call error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.ApplyParametersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.ApplyParametersRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.applyParameters = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.applyParameters(request), expectedError); - const actualRequest = (client.innerApiCalls.applyParameters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.applyParameters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteInstanceProgress with error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('applyParameters', () => { + it('invokes applyParameters without error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.ApplyParametersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.ApplyParametersRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.applyParameters = + stubLongRunningCall(expectedResponse); + const [operation] = await client.applyParameters(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.applyParameters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.applyParameters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes applyParameters with LRO error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.ApplyParametersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.ApplyParametersRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.applyParameters = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.applyParameters(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.applyParameters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.applyParameters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes applyParameters without error using callback', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.ApplyParametersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.ApplyParametersRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.applyParameters = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.applyParameters( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.applyParameters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.applyParameters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkApplyParametersProgress without error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkApplyParametersProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes applyParameters with call error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.ApplyParametersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.ApplyParametersRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.applyParameters = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.applyParameters(request), expectedError); + const actualRequest = ( + client.innerApiCalls.applyParameters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.applyParameters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkApplyParametersProgress with error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkApplyParametersProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes applyParameters with LRO error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.ApplyParametersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.ApplyParametersRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.applyParameters = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.applyParameters(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.applyParameters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.applyParameters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('rescheduleMaintenance', () => { - it('invokes rescheduleMaintenance without error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.RescheduleMaintenanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.RescheduleMaintenanceRequest', ['instance']); - request.instance = defaultValue1; - const expectedHeaderRequestParams = `instance=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.rescheduleMaintenance = stubLongRunningCall(expectedResponse); - const [operation] = await client.rescheduleMaintenance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkApplyParametersProgress without error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkApplyParametersProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes rescheduleMaintenance without error using callback', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.RescheduleMaintenanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.RescheduleMaintenanceRequest', ['instance']); - request.instance = defaultValue1; - const expectedHeaderRequestParams = `instance=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.rescheduleMaintenance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rescheduleMaintenance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkApplyParametersProgress with error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkApplyParametersProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('rescheduleMaintenance', () => { + it('invokes rescheduleMaintenance without error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.RescheduleMaintenanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.RescheduleMaintenanceRequest', + ['instance'], + ); + request.instance = defaultValue1; + const expectedHeaderRequestParams = `instance=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.rescheduleMaintenance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.rescheduleMaintenance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rescheduleMaintenance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rescheduleMaintenance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes rescheduleMaintenance with call error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.RescheduleMaintenanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.RescheduleMaintenanceRequest', ['instance']); - request.instance = defaultValue1; - const expectedHeaderRequestParams = `instance=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rescheduleMaintenance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.rescheduleMaintenance(request), expectedError); - const actualRequest = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes rescheduleMaintenance without error using callback', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.RescheduleMaintenanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.RescheduleMaintenanceRequest', + ['instance'], + ); + request.instance = defaultValue1; + const expectedHeaderRequestParams = `instance=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.rescheduleMaintenance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rescheduleMaintenance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.memcache.v1.IInstance, + protos.google.cloud.memcache.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rescheduleMaintenance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rescheduleMaintenance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes rescheduleMaintenance with LRO error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.RescheduleMaintenanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.RescheduleMaintenanceRequest', ['instance']); - request.instance = defaultValue1; - const expectedHeaderRequestParams = `instance=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rescheduleMaintenance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.rescheduleMaintenance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes rescheduleMaintenance with call error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.RescheduleMaintenanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.RescheduleMaintenanceRequest', + ['instance'], + ); + request.instance = defaultValue1; + const expectedHeaderRequestParams = `instance=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rescheduleMaintenance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.rescheduleMaintenance(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.rescheduleMaintenance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rescheduleMaintenance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRescheduleMaintenanceProgress without error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkRescheduleMaintenanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes rescheduleMaintenance with LRO error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.RescheduleMaintenanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.RescheduleMaintenanceRequest', + ['instance'], + ); + request.instance = defaultValue1; + const expectedHeaderRequestParams = `instance=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rescheduleMaintenance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.rescheduleMaintenance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.rescheduleMaintenance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rescheduleMaintenance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRescheduleMaintenanceProgress with error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRescheduleMaintenanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkRescheduleMaintenanceProgress without error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkRescheduleMaintenanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('listInstances', () => { - it('invokes listInstances without error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.memcache.v1.Instance()), - generateSampleMessage(new protos.google.cloud.memcache.v1.Instance()), - generateSampleMessage(new protos.google.cloud.memcache.v1.Instance()), - ]; - client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); - const [response] = await client.listInstances(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRescheduleMaintenanceProgress with error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkRescheduleMaintenanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listInstances', () => { + it('invokes listInstances without error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.memcache.v1.Instance()), + generateSampleMessage(new protos.google.cloud.memcache.v1.Instance()), + generateSampleMessage(new protos.google.cloud.memcache.v1.Instance()), + ]; + client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); + const [response] = await client.listInstances(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listInstances without error using callback', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.memcache.v1.Instance()), - generateSampleMessage(new protos.google.cloud.memcache.v1.Instance()), - generateSampleMessage(new protos.google.cloud.memcache.v1.Instance()), - ]; - client.innerApiCalls.listInstances = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listInstances( - request, - (err?: Error|null, result?: protos.google.cloud.memcache.v1.IInstance[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listInstances without error using callback', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.memcache.v1.Instance()), + generateSampleMessage(new protos.google.cloud.memcache.v1.Instance()), + generateSampleMessage(new protos.google.cloud.memcache.v1.Instance()), + ]; + client.innerApiCalls.listInstances = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listInstances( + request, + ( + err?: Error | null, + result?: protos.google.cloud.memcache.v1.IInstance[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listInstances with error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listInstances = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listInstances(request), expectedError); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listInstances with error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listInstances = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listInstances(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listInstancesStream without error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.memcache.v1.Instance()), - generateSampleMessage(new protos.google.cloud.memcache.v1.Instance()), - generateSampleMessage(new protos.google.cloud.memcache.v1.Instance()), - ]; - client.descriptors.page.listInstances.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listInstancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.memcache.v1.Instance[] = []; - stream.on('data', (response: protos.google.cloud.memcache.v1.Instance) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); - assert( - (client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listInstancesStream without error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.memcache.v1.Instance()), + generateSampleMessage(new protos.google.cloud.memcache.v1.Instance()), + generateSampleMessage(new protos.google.cloud.memcache.v1.Instance()), + ]; + client.descriptors.page.listInstances.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.memcache.v1.Instance[] = []; + stream.on( + 'data', + (response: protos.google.cloud.memcache.v1.Instance) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listInstances, request), + ); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listInstancesStream with error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstances.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listInstancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.memcache.v1.Instance[] = []; - stream.on('data', (response: protos.google.cloud.memcache.v1.Instance) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); - assert( - (client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listInstancesStream with error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstances.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.memcache.v1.Instance[] = []; + stream.on( + 'data', + (response: protos.google.cloud.memcache.v1.Instance) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listInstances, request), + ); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listInstances without error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.memcache.v1.Instance()), - generateSampleMessage(new protos.google.cloud.memcache.v1.Instance()), - generateSampleMessage(new protos.google.cloud.memcache.v1.Instance()), - ]; - client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.memcache.v1.IInstance[] = []; - const iterable = client.listInstancesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listInstances without error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.memcache.v1.Instance()), + generateSampleMessage(new protos.google.cloud.memcache.v1.Instance()), + generateSampleMessage(new protos.google.cloud.memcache.v1.Instance()), + ]; + client.descriptors.page.listInstances.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.memcache.v1.IInstance[] = []; + const iterable = client.listInstancesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listInstances.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listInstances with error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listInstancesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.memcache.v1.IInstance[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listInstances with error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstances.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listInstancesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.memcache.v1.IInstance[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listInstances.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes getLocation without error using callback', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes getLocation with error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('uses async iteration with listLocations with error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('instance', async () => { + const fakePath = '/rendered/path/instance'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + instance: 'instanceValue', + }; + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.instancePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.instancePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('instancePath', () => { + const result = client.instancePath( + 'projectValue', + 'locationValue', + 'instanceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.instancePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromInstanceName', () => { + const result = client.matchProjectFromInstanceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromInstanceName', () => { + const result = client.matchLocationFromInstanceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchInstanceFromInstanceName', () => { + const result = client.matchInstanceFromInstanceName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('instance', async () => { - const fakePath = "/rendered/path/instance"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - instance: "instanceValue", - }; - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.instancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.instancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('instancePath', () => { - const result = client.instancePath("projectValue", "locationValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.instancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInstanceName', () => { - const result = client.matchProjectFromInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromInstanceName', () => { - const result = client.matchLocationFromInstanceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromInstanceName', () => { - const result = client.matchInstanceFromInstanceName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new cloudmemcacheModule.v1.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-memcache/test/gapic_cloud_memcache_v1beta2.ts b/packages/google-cloud-memcache/test/gapic_cloud_memcache_v1beta2.ts index 3ada8ff9f757..d9eecee92265 100644 --- a/packages/google-cloud-memcache/test/gapic_cloud_memcache_v1beta2.ts +++ b/packages/google-cloud-memcache/test/gapic_cloud_memcache_v1beta2.ts @@ -19,2202 +19,2788 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as cloudmemcacheModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1beta2.CloudMemcacheClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'memcache.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = cloudmemcacheModule.v1beta2.CloudMemcacheClient.servicePath; - assert.strictEqual(servicePath, 'memcache.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = cloudmemcacheModule.v1beta2.CloudMemcacheClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'memcache.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'memcache.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'memcache.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'memcache.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'memcache.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new cloudmemcacheModule.v1beta2.CloudMemcacheClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = cloudmemcacheModule.v1beta2.CloudMemcacheClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudMemcacheStub, undefined); - await client.initialize(); - assert(client.cloudMemcacheStub); - }); - - it('has close method for the initialized client', done => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.cloudMemcacheStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'memcache.googleapis.com'); + }); - it('has close method for the non-initialized client', done => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudMemcacheStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has universeDomain', () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + cloudmemcacheModule.v1beta2.CloudMemcacheClient.servicePath; + assert.strictEqual(servicePath, 'memcache.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + cloudmemcacheModule.v1beta2.CloudMemcacheClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'memcache.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'memcache.example.com'); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'memcache.example.com'); }); - describe('getInstance', () => { - it('invokes getInstance without error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.Instance() - ); - client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); - const [response] = await client.getInstance(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'memcache.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'memcache.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('invokes getInstance without error using callback', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.Instance() - ); - client.innerApiCalls.getInstance = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getInstance( - request, - (err?: Error|null, result?: protos.google.cloud.memcache.v1beta2.IInstance|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has port', () => { + const port = cloudmemcacheModule.v1beta2.CloudMemcacheClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('invokes getInstance with error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getInstance = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('should create a client with no option', () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient(); + assert(client); + }); - it('invokes getInstance with closed client', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getInstance(request), expectedError); - }); + it('should create a client with gRPC fallback', () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + fallback: true, + }); + assert(client); }); - describe('createInstance', () => { - it('invokes createInstance without error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.createInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudMemcacheStub, undefined); + await client.initialize(); + assert(client.cloudMemcacheStub); + }); - it('invokes createInstance without error using callback', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the initialized client', (done) => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.cloudMemcacheStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes createInstance with call error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the non-initialized client', (done) => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudMemcacheStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes createInstance with LRO error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('invokes checkCreateInstanceProgress without error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getInstance', () => { + it('invokes getInstance without error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.Instance(), + ); + client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); + const [response] = await client.getInstance(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateInstanceProgress with error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes getInstance without error using callback', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.Instance(), + ); + client.innerApiCalls.getInstance = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getInstance( + request, + ( + err?: Error | null, + result?: protos.google.cloud.memcache.v1beta2.IInstance | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateInstance', () => { - it('invokes updateInstance without error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.UpdateInstanceRequest() - ); - request.resource ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.UpdateInstanceRequest', ['resource', 'name']); - request.resource.name = defaultValue1; - const expectedHeaderRequestParams = `resource.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getInstance with error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getInstance = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateInstance without error using callback', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.UpdateInstanceRequest() - ); - request.resource ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.UpdateInstanceRequest', ['resource', 'name']); - request.resource.name = defaultValue1; - const expectedHeaderRequestParams = `resource.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getInstance with closed client', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getInstance(request), expectedError); + }); + }); + + describe('createInstance', () => { + it('invokes createInstance without error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.CreateInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.CreateInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateInstance with call error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.UpdateInstanceRequest() - ); - request.resource ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.UpdateInstanceRequest', ['resource', 'name']); - request.resource.name = defaultValue1; - const expectedHeaderRequestParams = `resource.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createInstance without error using callback', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.CreateInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.CreateInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateInstance with LRO error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.UpdateInstanceRequest() - ); - request.resource ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.UpdateInstanceRequest', ['resource', 'name']); - request.resource.name = defaultValue1; - const expectedHeaderRequestParams = `resource.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createInstance with call error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.CreateInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.CreateInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateInstanceProgress without error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createInstance with LRO error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.CreateInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.CreateInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateInstanceProgress with error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateInstanceProgress without error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('updateParameters', () => { - it('invokes updateParameters without error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.UpdateParametersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.UpdateParametersRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateParameters = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateParameters(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateParameters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateParameters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateInstanceProgress with error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateInstance', () => { + it('invokes updateInstance without error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.UpdateInstanceRequest(), + ); + request.resource ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.UpdateInstanceRequest', + ['resource', 'name'], + ); + request.resource.name = defaultValue1; + const expectedHeaderRequestParams = `resource.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateParameters without error using callback', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.UpdateParametersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.UpdateParametersRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateParameters = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateParameters( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateParameters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateParameters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateInstance without error using callback', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.UpdateInstanceRequest(), + ); + request.resource ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.UpdateInstanceRequest', + ['resource', 'name'], + ); + request.resource.name = defaultValue1; + const expectedHeaderRequestParams = `resource.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateParameters with call error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.UpdateParametersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.UpdateParametersRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateParameters = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateParameters(request), expectedError); - const actualRequest = (client.innerApiCalls.updateParameters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateParameters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateInstance with call error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.UpdateInstanceRequest(), + ); + request.resource ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.UpdateInstanceRequest', + ['resource', 'name'], + ); + request.resource.name = defaultValue1; + const expectedHeaderRequestParams = `resource.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateParameters with LRO error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.UpdateParametersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.UpdateParametersRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateParameters = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateParameters(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateParameters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateParameters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateInstance with LRO error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.UpdateInstanceRequest(), + ); + request.resource ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.UpdateInstanceRequest', + ['resource', 'name'], + ); + request.resource.name = defaultValue1; + const expectedHeaderRequestParams = `resource.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateParametersProgress without error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateParametersProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateInstanceProgress without error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkUpdateParametersProgress with error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateParametersProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpdateInstanceProgress with error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateParameters', () => { + it('invokes updateParameters without error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.UpdateParametersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.UpdateParametersRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateParameters = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateParameters(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateParameters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateParameters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteInstance', () => { - it('invokes deleteInstance without error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateParameters without error using callback', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.UpdateParametersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.UpdateParametersRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateParameters = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateParameters( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateParameters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateParameters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteInstance without error using callback', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateParameters with call error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.UpdateParametersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.UpdateParametersRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateParameters = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateParameters(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateParameters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateParameters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteInstance with call error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateParameters with LRO error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.UpdateParametersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.UpdateParametersRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateParameters = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateParameters(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateParameters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateParameters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteInstance with LRO error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateParametersProgress without error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateParametersProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteInstanceProgress without error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateParametersProgress with error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateParametersProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteInstance', () => { + it('invokes deleteInstance without error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.DeleteInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.DeleteInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteInstanceProgress with error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteInstance without error using callback', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.DeleteInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.DeleteInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('applyParameters', () => { - it('invokes applyParameters without error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.ApplyParametersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.ApplyParametersRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.applyParameters = stubLongRunningCall(expectedResponse); - const [operation] = await client.applyParameters(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.applyParameters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.applyParameters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteInstance with call error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.DeleteInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.DeleteInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes applyParameters without error using callback', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.ApplyParametersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.ApplyParametersRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.applyParameters = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.applyParameters( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.applyParameters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.applyParameters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteInstance with LRO error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.DeleteInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.DeleteInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes applyParameters with call error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.ApplyParametersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.ApplyParametersRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.applyParameters = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.applyParameters(request), expectedError); - const actualRequest = (client.innerApiCalls.applyParameters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.applyParameters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteInstanceProgress without error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes applyParameters with LRO error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.ApplyParametersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.ApplyParametersRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.applyParameters = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.applyParameters(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.applyParameters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.applyParameters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteInstanceProgress with error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('applyParameters', () => { + it('invokes applyParameters without error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.ApplyParametersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.ApplyParametersRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.applyParameters = + stubLongRunningCall(expectedResponse); + const [operation] = await client.applyParameters(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.applyParameters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.applyParameters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkApplyParametersProgress without error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkApplyParametersProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes applyParameters without error using callback', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.ApplyParametersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.ApplyParametersRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.applyParameters = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.applyParameters( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.applyParameters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.applyParameters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkApplyParametersProgress with error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkApplyParametersProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes applyParameters with call error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.ApplyParametersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.ApplyParametersRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.applyParameters = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.applyParameters(request), expectedError); + const actualRequest = ( + client.innerApiCalls.applyParameters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.applyParameters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('applySoftwareUpdate', () => { - it('invokes applySoftwareUpdate without error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.ApplySoftwareUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.ApplySoftwareUpdateRequest', ['instance']); - request.instance = defaultValue1; - const expectedHeaderRequestParams = `instance=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.applySoftwareUpdate = stubLongRunningCall(expectedResponse); - const [operation] = await client.applySoftwareUpdate(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.applySoftwareUpdate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.applySoftwareUpdate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes applyParameters with LRO error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.ApplyParametersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.ApplyParametersRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.applyParameters = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.applyParameters(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.applyParameters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.applyParameters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes applySoftwareUpdate without error using callback', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.ApplySoftwareUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.ApplySoftwareUpdateRequest', ['instance']); - request.instance = defaultValue1; - const expectedHeaderRequestParams = `instance=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.applySoftwareUpdate = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.applySoftwareUpdate( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.applySoftwareUpdate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.applySoftwareUpdate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkApplyParametersProgress without error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkApplyParametersProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes applySoftwareUpdate with call error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.ApplySoftwareUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.ApplySoftwareUpdateRequest', ['instance']); - request.instance = defaultValue1; - const expectedHeaderRequestParams = `instance=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.applySoftwareUpdate = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.applySoftwareUpdate(request), expectedError); - const actualRequest = (client.innerApiCalls.applySoftwareUpdate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.applySoftwareUpdate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkApplyParametersProgress with error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkApplyParametersProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('applySoftwareUpdate', () => { + it('invokes applySoftwareUpdate without error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.ApplySoftwareUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.ApplySoftwareUpdateRequest', + ['instance'], + ); + request.instance = defaultValue1; + const expectedHeaderRequestParams = `instance=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.applySoftwareUpdate = + stubLongRunningCall(expectedResponse); + const [operation] = await client.applySoftwareUpdate(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.applySoftwareUpdate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.applySoftwareUpdate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes applySoftwareUpdate with LRO error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.ApplySoftwareUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.ApplySoftwareUpdateRequest', ['instance']); - request.instance = defaultValue1; - const expectedHeaderRequestParams = `instance=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.applySoftwareUpdate = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.applySoftwareUpdate(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.applySoftwareUpdate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.applySoftwareUpdate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes applySoftwareUpdate without error using callback', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.ApplySoftwareUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.ApplySoftwareUpdateRequest', + ['instance'], + ); + request.instance = defaultValue1; + const expectedHeaderRequestParams = `instance=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.applySoftwareUpdate = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.applySoftwareUpdate( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.applySoftwareUpdate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.applySoftwareUpdate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkApplySoftwareUpdateProgress without error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkApplySoftwareUpdateProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes applySoftwareUpdate with call error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.ApplySoftwareUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.ApplySoftwareUpdateRequest', + ['instance'], + ); + request.instance = defaultValue1; + const expectedHeaderRequestParams = `instance=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.applySoftwareUpdate = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.applySoftwareUpdate(request), expectedError); + const actualRequest = ( + client.innerApiCalls.applySoftwareUpdate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.applySoftwareUpdate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkApplySoftwareUpdateProgress with error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkApplySoftwareUpdateProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes applySoftwareUpdate with LRO error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.ApplySoftwareUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.ApplySoftwareUpdateRequest', + ['instance'], + ); + request.instance = defaultValue1; + const expectedHeaderRequestParams = `instance=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.applySoftwareUpdate = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.applySoftwareUpdate(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.applySoftwareUpdate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.applySoftwareUpdate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('rescheduleMaintenance', () => { - it('invokes rescheduleMaintenance without error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.RescheduleMaintenanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.RescheduleMaintenanceRequest', ['instance']); - request.instance = defaultValue1; - const expectedHeaderRequestParams = `instance=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.rescheduleMaintenance = stubLongRunningCall(expectedResponse); - const [operation] = await client.rescheduleMaintenance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkApplySoftwareUpdateProgress without error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkApplySoftwareUpdateProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes rescheduleMaintenance without error using callback', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.RescheduleMaintenanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.RescheduleMaintenanceRequest', ['instance']); - request.instance = defaultValue1; - const expectedHeaderRequestParams = `instance=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.rescheduleMaintenance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rescheduleMaintenance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkApplySoftwareUpdateProgress with error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkApplySoftwareUpdateProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('rescheduleMaintenance', () => { + it('invokes rescheduleMaintenance without error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.RescheduleMaintenanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.RescheduleMaintenanceRequest', + ['instance'], + ); + request.instance = defaultValue1; + const expectedHeaderRequestParams = `instance=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.rescheduleMaintenance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.rescheduleMaintenance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rescheduleMaintenance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rescheduleMaintenance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes rescheduleMaintenance with call error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.RescheduleMaintenanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.RescheduleMaintenanceRequest', ['instance']); - request.instance = defaultValue1; - const expectedHeaderRequestParams = `instance=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rescheduleMaintenance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.rescheduleMaintenance(request), expectedError); - const actualRequest = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes rescheduleMaintenance without error using callback', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.RescheduleMaintenanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.RescheduleMaintenanceRequest', + ['instance'], + ); + request.instance = defaultValue1; + const expectedHeaderRequestParams = `instance=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.rescheduleMaintenance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rescheduleMaintenance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.memcache.v1beta2.IInstance, + protos.google.cloud.memcache.v1beta2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rescheduleMaintenance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rescheduleMaintenance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes rescheduleMaintenance with LRO error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.RescheduleMaintenanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.RescheduleMaintenanceRequest', ['instance']); - request.instance = defaultValue1; - const expectedHeaderRequestParams = `instance=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rescheduleMaintenance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.rescheduleMaintenance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes rescheduleMaintenance with call error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.RescheduleMaintenanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.RescheduleMaintenanceRequest', + ['instance'], + ); + request.instance = defaultValue1; + const expectedHeaderRequestParams = `instance=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rescheduleMaintenance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.rescheduleMaintenance(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.rescheduleMaintenance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rescheduleMaintenance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRescheduleMaintenanceProgress without error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkRescheduleMaintenanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes rescheduleMaintenance with LRO error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.RescheduleMaintenanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.RescheduleMaintenanceRequest', + ['instance'], + ); + request.instance = defaultValue1; + const expectedHeaderRequestParams = `instance=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rescheduleMaintenance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.rescheduleMaintenance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.rescheduleMaintenance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rescheduleMaintenance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRescheduleMaintenanceProgress with error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRescheduleMaintenanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkRescheduleMaintenanceProgress without error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkRescheduleMaintenanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('listInstances', () => { - it('invokes listInstances without error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.memcache.v1beta2.Instance()), - generateSampleMessage(new protos.google.cloud.memcache.v1beta2.Instance()), - generateSampleMessage(new protos.google.cloud.memcache.v1beta2.Instance()), - ]; - client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); - const [response] = await client.listInstances(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRescheduleMaintenanceProgress with error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkRescheduleMaintenanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listInstances', () => { + it('invokes listInstances without error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.Instance(), + ), + ]; + client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); + const [response] = await client.listInstances(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listInstances without error using callback', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.memcache.v1beta2.Instance()), - generateSampleMessage(new protos.google.cloud.memcache.v1beta2.Instance()), - generateSampleMessage(new protos.google.cloud.memcache.v1beta2.Instance()), - ]; - client.innerApiCalls.listInstances = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listInstances( - request, - (err?: Error|null, result?: protos.google.cloud.memcache.v1beta2.IInstance[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listInstances without error using callback', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.Instance(), + ), + ]; + client.innerApiCalls.listInstances = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listInstances( + request, + ( + err?: Error | null, + result?: protos.google.cloud.memcache.v1beta2.IInstance[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listInstances with error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listInstances = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listInstances(request), expectedError); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listInstances with error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listInstances = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listInstances(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listInstancesStream without error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.memcache.v1beta2.Instance()), - generateSampleMessage(new protos.google.cloud.memcache.v1beta2.Instance()), - generateSampleMessage(new protos.google.cloud.memcache.v1beta2.Instance()), - ]; - client.descriptors.page.listInstances.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listInstancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.memcache.v1beta2.Instance[] = []; - stream.on('data', (response: protos.google.cloud.memcache.v1beta2.Instance) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); - assert( - (client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listInstancesStream without error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.Instance(), + ), + ]; + client.descriptors.page.listInstances.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.memcache.v1beta2.Instance[] = []; + stream.on( + 'data', + (response: protos.google.cloud.memcache.v1beta2.Instance) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listInstances, request), + ); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listInstancesStream with error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstances.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listInstancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.memcache.v1beta2.Instance[] = []; - stream.on('data', (response: protos.google.cloud.memcache.v1beta2.Instance) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); - assert( - (client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listInstancesStream with error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstances.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.memcache.v1beta2.Instance[] = []; + stream.on( + 'data', + (response: protos.google.cloud.memcache.v1beta2.Instance) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listInstances, request), + ); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listInstances without error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.memcache.v1beta2.Instance()), - generateSampleMessage(new protos.google.cloud.memcache.v1beta2.Instance()), - generateSampleMessage(new protos.google.cloud.memcache.v1beta2.Instance()), - ]; - client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.memcache.v1beta2.IInstance[] = []; - const iterable = client.listInstancesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listInstances without error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.Instance(), + ), + ]; + client.descriptors.page.listInstances.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.memcache.v1beta2.IInstance[] = []; + const iterable = client.listInstancesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listInstances.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listInstances with error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memcache.v1beta2.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memcache.v1beta2.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listInstancesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.memcache.v1beta2.IInstance[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listInstances with error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memcache.v1beta2.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memcache.v1beta2.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstances.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listInstancesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.memcache.v1beta2.IInstance[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listInstances.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes getLocation without error using callback', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes getLocation with error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('uses async iteration with listLocations with error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('instance', async () => { + const fakePath = '/rendered/path/instance'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + instance: 'instanceValue', + }; + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.instancePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.instancePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('instancePath', () => { + const result = client.instancePath( + 'projectValue', + 'locationValue', + 'instanceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.instancePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromInstanceName', () => { + const result = client.matchProjectFromInstanceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromInstanceName', () => { + const result = client.matchLocationFromInstanceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchInstanceFromInstanceName', () => { + const result = client.matchInstanceFromInstanceName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('instance', async () => { - const fakePath = "/rendered/path/instance"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - instance: "instanceValue", - }; - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.instancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.instancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('instancePath', () => { - const result = client.instancePath("projectValue", "locationValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.instancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInstanceName', () => { - const result = client.matchProjectFromInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromInstanceName', () => { - const result = client.matchLocationFromInstanceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromInstanceName', () => { - const result = client.matchInstanceFromInstanceName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new cloudmemcacheModule.v1beta2.CloudMemcacheClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-memcache/webpack.config.js b/packages/google-cloud-memcache/webpack.config.js index c69c158b63cf..798f84c54f56 100644 --- a/packages/google-cloud-memcache/webpack.config.js +++ b/packages/google-cloud-memcache/webpack.config.js @@ -1,4 +1,4 @@ -// Copyright 2026 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-memorystore/.eslintignore b/packages/google-cloud-memorystore/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-memorystore/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-memorystore/.eslintrc.json b/packages/google-cloud-memorystore/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-memorystore/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-memorystore/README.md b/packages/google-cloud-memorystore/README.md index 28fd141e671a..937d9d9a4746 100644 --- a/packages/google-cloud-memorystore/README.md +++ b/packages/google-cloud-memorystore/README.md @@ -115,7 +115,7 @@ More Information: [Google Cloud Platform Launch Stages][launch_stages] ## Contributing -Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-memorystore/CONTRIBUTING.md). +Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/CONTRIBUTING.md). Please note that this `README.md` and a variety of configuration files in this repository (including `.nycrc` and `tsconfig.json`) @@ -125,7 +125,7 @@ are generated from a central template. Apache Version 2.0 -See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-memorystore/LICENSE) +See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/LICENSE) [shell_img]: https://gstatic.com/cloudssh/images/open-btn.png [projects]: https://console.cloud.google.com/project diff --git a/packages/google-cloud-memorystore/protos/protos.d.ts b/packages/google-cloud-memorystore/protos/protos.d.ts index 9b3de9090297..5d3681096cc5 100644 --- a/packages/google-cloud-memorystore/protos/protos.d.ts +++ b/packages/google-cloud-memorystore/protos/protos.d.ts @@ -10414,6 +10414,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -10431,6 +10434,9 @@ export namespace google { /** CommonLanguageSettings destinations. */ public destinations: google.api.ClientLibraryDestination[]; + /** CommonLanguageSettings selectiveGapicGeneration. */ + public selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); + /** * Creates a new CommonLanguageSettings instance using the specified properties. * @param [properties] Properties to set @@ -11131,6 +11137,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -11145,6 +11154,9 @@ export namespace google { /** PythonSettings common. */ public common?: (google.api.ICommonLanguageSettings|null); + /** PythonSettings experimentalFeatures. */ + public experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); + /** * Creates a new PythonSettings instance using the specified properties. * @param [properties] Properties to set @@ -11223,6 +11235,118 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + namespace PythonSettings { + + /** Properties of an ExperimentalFeatures. */ + interface IExperimentalFeatures { + + /** ExperimentalFeatures restAsyncIoEnabled */ + restAsyncIoEnabled?: (boolean|null); + + /** ExperimentalFeatures protobufPythonicTypesEnabled */ + protobufPythonicTypesEnabled?: (boolean|null); + + /** ExperimentalFeatures unversionedPackageDisabled */ + unversionedPackageDisabled?: (boolean|null); + } + + /** Represents an ExperimentalFeatures. */ + class ExperimentalFeatures implements IExperimentalFeatures { + + /** + * Constructs a new ExperimentalFeatures. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.PythonSettings.IExperimentalFeatures); + + /** ExperimentalFeatures restAsyncIoEnabled. */ + public restAsyncIoEnabled: boolean; + + /** ExperimentalFeatures protobufPythonicTypesEnabled. */ + public protobufPythonicTypesEnabled: boolean; + + /** ExperimentalFeatures unversionedPackageDisabled. */ + public unversionedPackageDisabled: boolean; + + /** + * Creates a new ExperimentalFeatures instance using the specified properties. + * @param [properties] Properties to set + * @returns ExperimentalFeatures instance + */ + public static create(properties?: google.api.PythonSettings.IExperimentalFeatures): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Encodes the specified ExperimentalFeatures message. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @param message ExperimentalFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.PythonSettings.IExperimentalFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExperimentalFeatures message, length delimited. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @param message ExperimentalFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.PythonSettings.IExperimentalFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExperimentalFeatures + * @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.api.PythonSettings.ExperimentalFeatures; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExperimentalFeatures + * @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.api.PythonSettings.ExperimentalFeatures; + + /** + * Verifies an ExperimentalFeatures 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 an ExperimentalFeatures message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExperimentalFeatures + */ + public static fromObject(object: { [k: string]: any }): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Creates a plain object from an ExperimentalFeatures message. Also converts values to other types if specified. + * @param message ExperimentalFeatures + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.PythonSettings.ExperimentalFeatures, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExperimentalFeatures to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExperimentalFeatures + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + /** Properties of a NodeSettings. */ interface INodeSettings { @@ -11549,6 +11673,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -11563,6 +11690,9 @@ export namespace google { /** GoSettings common. */ public common?: (google.api.ICommonLanguageSettings|null); + /** GoSettings renamedServices. */ + public renamedServices: { [k: string]: string }; + /** * Creates a new GoSettings instance using the specified properties. * @param [properties] Properties to set @@ -11887,6 +12017,109 @@ export namespace google { PACKAGE_MANAGER = 20 } + /** Properties of a SelectiveGapicGeneration. */ + interface ISelectiveGapicGeneration { + + /** SelectiveGapicGeneration methods */ + methods?: (string[]|null); + + /** SelectiveGapicGeneration generateOmittedAsInternal */ + generateOmittedAsInternal?: (boolean|null); + } + + /** Represents a SelectiveGapicGeneration. */ + class SelectiveGapicGeneration implements ISelectiveGapicGeneration { + + /** + * Constructs a new SelectiveGapicGeneration. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.ISelectiveGapicGeneration); + + /** SelectiveGapicGeneration methods. */ + public methods: string[]; + + /** SelectiveGapicGeneration generateOmittedAsInternal. */ + public generateOmittedAsInternal: boolean; + + /** + * Creates a new SelectiveGapicGeneration instance using the specified properties. + * @param [properties] Properties to set + * @returns SelectiveGapicGeneration instance + */ + public static create(properties?: google.api.ISelectiveGapicGeneration): google.api.SelectiveGapicGeneration; + + /** + * Encodes the specified SelectiveGapicGeneration message. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @param message SelectiveGapicGeneration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.ISelectiveGapicGeneration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SelectiveGapicGeneration message, length delimited. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @param message SelectiveGapicGeneration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.ISelectiveGapicGeneration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SelectiveGapicGeneration + * @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.api.SelectiveGapicGeneration; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SelectiveGapicGeneration + * @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.api.SelectiveGapicGeneration; + + /** + * Verifies a SelectiveGapicGeneration 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 SelectiveGapicGeneration message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SelectiveGapicGeneration + */ + public static fromObject(object: { [k: string]: any }): google.api.SelectiveGapicGeneration; + + /** + * Creates a plain object from a SelectiveGapicGeneration message. Also converts values to other types if specified. + * @param message SelectiveGapicGeneration + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.SelectiveGapicGeneration, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SelectiveGapicGeneration to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SelectiveGapicGeneration + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** LaunchStage enum. */ enum LaunchStage { LAUNCH_STAGE_UNSPECIFIED = 0, @@ -11917,6 +12150,9 @@ export namespace google { /** FieldInfo format */ format?: (google.api.FieldInfo.Format|keyof typeof google.api.FieldInfo.Format|null); + + /** FieldInfo referencedTypes */ + referencedTypes?: (google.api.ITypeReference[]|null); } /** Represents a FieldInfo. */ @@ -11931,6 +12167,9 @@ export namespace google { /** FieldInfo format. */ public format: (google.api.FieldInfo.Format|keyof typeof google.api.FieldInfo.Format); + /** FieldInfo referencedTypes. */ + public referencedTypes: google.api.ITypeReference[]; + /** * Creates a new FieldInfo instance using the specified properties. * @param [properties] Properties to set @@ -12021,6 +12260,103 @@ export namespace google { } } + /** Properties of a TypeReference. */ + interface ITypeReference { + + /** TypeReference typeName */ + typeName?: (string|null); + } + + /** Represents a TypeReference. */ + class TypeReference implements ITypeReference { + + /** + * Constructs a new TypeReference. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.ITypeReference); + + /** TypeReference typeName. */ + public typeName: string; + + /** + * Creates a new TypeReference instance using the specified properties. + * @param [properties] Properties to set + * @returns TypeReference instance + */ + public static create(properties?: google.api.ITypeReference): google.api.TypeReference; + + /** + * Encodes the specified TypeReference message. Does not implicitly {@link google.api.TypeReference.verify|verify} messages. + * @param message TypeReference message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.ITypeReference, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified TypeReference message, length delimited. Does not implicitly {@link google.api.TypeReference.verify|verify} messages. + * @param message TypeReference message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.ITypeReference, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TypeReference message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns TypeReference + * @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.api.TypeReference; + + /** + * Decodes a TypeReference message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns TypeReference + * @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.api.TypeReference; + + /** + * Verifies a TypeReference 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 TypeReference message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TypeReference + */ + public static fromObject(object: { [k: string]: any }): google.api.TypeReference; + + /** + * Creates a plain object from a TypeReference message. Also converts values to other types if specified. + * @param message TypeReference + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.TypeReference, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TypeReference to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for TypeReference + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** Properties of a ResourceDescriptor. */ interface IResourceDescriptor { @@ -12377,6 +12713,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -12407,6 +12744,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -12456,6 +12796,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -12590,6 +12933,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -12631,6 +12977,9 @@ export namespace google { /** DescriptorProto reservedName. */ public reservedName: string[]; + /** DescriptorProto visibility. */ + public visibility: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility); + /** * Creates a new DescriptorProto instance using the specified properties. * @param [properties] Properties to set @@ -13478,6 +13827,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -13504,6 +13856,9 @@ export namespace google { /** EnumDescriptorProto reservedName. */ public reservedName: string[]; + /** EnumDescriptorProto visibility. */ + public visibility: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility); + /** * Creates a new EnumDescriptorProto instance using the specified properties. * @param [properties] Properties to set @@ -14438,6 +14793,9 @@ export namespace google { /** FieldOptions features */ features?: (google.protobuf.IFeatureSet|null); + /** FieldOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** FieldOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); @@ -14496,6 +14854,9 @@ export namespace google { /** FieldOptions features. */ public features?: (google.protobuf.IFeatureSet|null); + /** FieldOptions featureSupport. */ + public featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** FieldOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; @@ -14716,6 +15077,121 @@ export namespace google { */ public static getTypeUrl(typeUrlPrefix?: string): string; } + + /** Properties of a FeatureSupport. */ + interface IFeatureSupport { + + /** FeatureSupport editionIntroduced */ + editionIntroduced?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSupport editionDeprecated */ + editionDeprecated?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSupport deprecationWarning */ + deprecationWarning?: (string|null); + + /** FeatureSupport editionRemoved */ + editionRemoved?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + } + + /** Represents a FeatureSupport. */ + class FeatureSupport implements IFeatureSupport { + + /** + * Constructs a new FeatureSupport. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.FieldOptions.IFeatureSupport); + + /** FeatureSupport editionIntroduced. */ + public editionIntroduced: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSupport editionDeprecated. */ + public editionDeprecated: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSupport deprecationWarning. */ + public deprecationWarning: string; + + /** FeatureSupport editionRemoved. */ + public editionRemoved: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** + * Creates a new FeatureSupport instance using the specified properties. + * @param [properties] Properties to set + * @returns FeatureSupport instance + */ + public static create(properties?: google.protobuf.FieldOptions.IFeatureSupport): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Encodes the specified FeatureSupport message. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @param message FeatureSupport message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.FieldOptions.IFeatureSupport, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FeatureSupport message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @param message FeatureSupport message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.FieldOptions.IFeatureSupport, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FeatureSupport + * @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.protobuf.FieldOptions.FeatureSupport; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FeatureSupport + * @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.protobuf.FieldOptions.FeatureSupport; + + /** + * Verifies a FeatureSupport 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 FeatureSupport message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FeatureSupport + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Creates a plain object from a FeatureSupport message. Also converts values to other types if specified. + * @param message FeatureSupport + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldOptions.FeatureSupport, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FeatureSupport to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FeatureSupport + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } } /** Properties of an OneofOptions. */ @@ -14954,6 +15430,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -14976,6 +15455,9 @@ export namespace google { /** EnumValueOptions debugRedact. */ public debugRedact: boolean; + /** EnumValueOptions featureSupport. */ + public featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; @@ -15568,6 +16050,12 @@ export namespace google { /** FeatureSet jsonFormat */ jsonFormat?: (google.protobuf.FeatureSet.JsonFormat|keyof typeof google.protobuf.FeatureSet.JsonFormat|null); + + /** FeatureSet enforceNamingStyle */ + enforceNamingStyle?: (google.protobuf.FeatureSet.EnforceNamingStyle|keyof typeof google.protobuf.FeatureSet.EnforceNamingStyle|null); + + /** FeatureSet defaultSymbolVisibility */ + defaultSymbolVisibility?: (google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|keyof typeof google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|null); } /** Represents a FeatureSet. */ @@ -15597,6 +16085,12 @@ export namespace google { /** FeatureSet jsonFormat. */ public jsonFormat: (google.protobuf.FeatureSet.JsonFormat|keyof typeof google.protobuf.FeatureSet.JsonFormat); + /** FeatureSet enforceNamingStyle. */ + public enforceNamingStyle: (google.protobuf.FeatureSet.EnforceNamingStyle|keyof typeof google.protobuf.FeatureSet.EnforceNamingStyle); + + /** FeatureSet defaultSymbolVisibility. */ + public defaultSymbolVisibility: (google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|keyof typeof google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility); + /** * Creates a new FeatureSet instance using the specified properties. * @param [properties] Properties to set @@ -15719,6 +16213,116 @@ export namespace google { ALLOW = 1, LEGACY_BEST_EFFORT = 2 } + + /** EnforceNamingStyle enum. */ + enum EnforceNamingStyle { + ENFORCE_NAMING_STYLE_UNKNOWN = 0, + STYLE2024 = 1, + STYLE_LEGACY = 2 + } + + /** Properties of a VisibilityFeature. */ + interface IVisibilityFeature { + } + + /** Represents a VisibilityFeature. */ + class VisibilityFeature implements IVisibilityFeature { + + /** + * Constructs a new VisibilityFeature. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.FeatureSet.IVisibilityFeature); + + /** + * Creates a new VisibilityFeature instance using the specified properties. + * @param [properties] Properties to set + * @returns VisibilityFeature instance + */ + public static create(properties?: google.protobuf.FeatureSet.IVisibilityFeature): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Encodes the specified VisibilityFeature message. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @param message VisibilityFeature message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.FeatureSet.IVisibilityFeature, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified VisibilityFeature message, length delimited. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @param message VisibilityFeature message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.FeatureSet.IVisibilityFeature, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns VisibilityFeature + * @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.protobuf.FeatureSet.VisibilityFeature; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns VisibilityFeature + * @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.protobuf.FeatureSet.VisibilityFeature; + + /** + * Verifies a VisibilityFeature 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 VisibilityFeature message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns VisibilityFeature + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Creates a plain object from a VisibilityFeature message. Also converts values to other types if specified. + * @param message VisibilityFeature + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FeatureSet.VisibilityFeature, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this VisibilityFeature to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for VisibilityFeature + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace VisibilityFeature { + + /** DefaultSymbolVisibility enum. */ + enum DefaultSymbolVisibility { + DEFAULT_SYMBOL_VISIBILITY_UNKNOWN = 0, + EXPORT_ALL = 1, + EXPORT_TOP_LEVEL = 2, + LOCAL_ALL = 3, + STRICT = 4 + } + } } /** Properties of a FeatureSetDefaults. */ @@ -15838,8 +16442,11 @@ export namespace google { /** FeatureSetEditionDefault edition */ edition?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); - /** FeatureSetEditionDefault features */ - features?: (google.protobuf.IFeatureSet|null); + /** FeatureSetEditionDefault overridableFeatures */ + overridableFeatures?: (google.protobuf.IFeatureSet|null); + + /** FeatureSetEditionDefault fixedFeatures */ + fixedFeatures?: (google.protobuf.IFeatureSet|null); } /** Represents a FeatureSetEditionDefault. */ @@ -15854,8 +16461,11 @@ export namespace google { /** FeatureSetEditionDefault edition. */ public edition: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); - /** FeatureSetEditionDefault features. */ - public features?: (google.protobuf.IFeatureSet|null); + /** FeatureSetEditionDefault overridableFeatures. */ + public overridableFeatures?: (google.protobuf.IFeatureSet|null); + + /** FeatureSetEditionDefault fixedFeatures. */ + public fixedFeatures?: (google.protobuf.IFeatureSet|null); /** * Creates a new FeatureSetEditionDefault instance using the specified properties. @@ -16388,6 +16998,13 @@ export namespace google { } } + /** SymbolVisibility enum. */ + enum SymbolVisibility { + VISIBILITY_UNSET = 0, + VISIBILITY_LOCAL = 1, + VISIBILITY_EXPORT = 2 + } + /** Properties of a Duration. */ interface IDuration { diff --git a/packages/google-cloud-memorystore/protos/protos.js b/packages/google-cloud-memorystore/protos/protos.js index 8576ebb43c17..5c7565b65480 100644 --- a/packages/google-cloud-memorystore/protos/protos.js +++ b/packages/google-cloud-memorystore/protos/protos.js @@ -26968,6 +26968,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -27002,6 +27003,14 @@ */ CommonLanguageSettings.prototype.destinations = $util.emptyArray; + /** + * CommonLanguageSettings selectiveGapicGeneration. + * @member {google.api.ISelectiveGapicGeneration|null|undefined} selectiveGapicGeneration + * @memberof google.api.CommonLanguageSettings + * @instance + */ + CommonLanguageSettings.prototype.selectiveGapicGeneration = null; + /** * Creates a new CommonLanguageSettings instance using the specified properties. * @function create @@ -27034,6 +27043,8 @@ writer.int32(message.destinations[i]); writer.ldelim(); } + if (message.selectiveGapicGeneration != null && Object.hasOwnProperty.call(message, "selectiveGapicGeneration")) + $root.google.api.SelectiveGapicGeneration.encode(message.selectiveGapicGeneration, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); return writer; }; @@ -27085,6 +27096,10 @@ message.destinations.push(reader.int32()); break; } + case 3: { + message.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -27136,6 +27151,11 @@ break; } } + if (message.selectiveGapicGeneration != null && message.hasOwnProperty("selectiveGapicGeneration")) { + var error = $root.google.api.SelectiveGapicGeneration.verify(message.selectiveGapicGeneration); + if (error) + return "selectiveGapicGeneration." + error; + } return null; }; @@ -27178,6 +27198,11 @@ break; } } + if (object.selectiveGapicGeneration != null) { + if (typeof object.selectiveGapicGeneration !== "object") + throw TypeError(".google.api.CommonLanguageSettings.selectiveGapicGeneration: object expected"); + message.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.fromObject(object.selectiveGapicGeneration); + } return message; }; @@ -27196,8 +27221,10 @@ var object = {}; if (options.arrays || options.defaults) object.destinations = []; - if (options.defaults) + if (options.defaults) { object.referenceDocsUri = ""; + object.selectiveGapicGeneration = null; + } if (message.referenceDocsUri != null && message.hasOwnProperty("referenceDocsUri")) object.referenceDocsUri = message.referenceDocsUri; if (message.destinations && message.destinations.length) { @@ -27205,6 +27232,8 @@ for (var j = 0; j < message.destinations.length; ++j) object.destinations[j] = options.enums === String ? $root.google.api.ClientLibraryDestination[message.destinations[j]] === undefined ? message.destinations[j] : $root.google.api.ClientLibraryDestination[message.destinations[j]] : message.destinations[j]; } + if (message.selectiveGapicGeneration != null && message.hasOwnProperty("selectiveGapicGeneration")) + object.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.toObject(message.selectiveGapicGeneration, options); return object; }; @@ -29027,6 +29056,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -29052,6 +29082,14 @@ */ PythonSettings.prototype.common = null; + /** + * PythonSettings experimentalFeatures. + * @member {google.api.PythonSettings.IExperimentalFeatures|null|undefined} experimentalFeatures + * @memberof google.api.PythonSettings + * @instance + */ + PythonSettings.prototype.experimentalFeatures = null; + /** * Creates a new PythonSettings instance using the specified properties. * @function create @@ -29078,6 +29116,8 @@ writer = $Writer.create(); if (message.common != null && Object.hasOwnProperty.call(message, "common")) $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.experimentalFeatures != null && Object.hasOwnProperty.call(message, "experimentalFeatures")) + $root.google.api.PythonSettings.ExperimentalFeatures.encode(message.experimentalFeatures, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; @@ -29118,6 +29158,10 @@ message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); break; } + case 2: { + message.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -29158,6 +29202,11 @@ if (error) return "common." + error; } + if (message.experimentalFeatures != null && message.hasOwnProperty("experimentalFeatures")) { + var error = $root.google.api.PythonSettings.ExperimentalFeatures.verify(message.experimentalFeatures); + if (error) + return "experimentalFeatures." + error; + } return null; }; @@ -29178,6 +29227,11 @@ throw TypeError(".google.api.PythonSettings.common: object expected"); message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); } + if (object.experimentalFeatures != null) { + if (typeof object.experimentalFeatures !== "object") + throw TypeError(".google.api.PythonSettings.experimentalFeatures: object expected"); + message.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.fromObject(object.experimentalFeatures); + } return message; }; @@ -29194,10 +29248,14 @@ if (!options) options = {}; var object = {}; - if (options.defaults) + if (options.defaults) { object.common = null; + object.experimentalFeatures = null; + } if (message.common != null && message.hasOwnProperty("common")) object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + if (message.experimentalFeatures != null && message.hasOwnProperty("experimentalFeatures")) + object.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.toObject(message.experimentalFeatures, options); return object; }; @@ -29227,6 +29285,258 @@ return typeUrlPrefix + "/google.api.PythonSettings"; }; + PythonSettings.ExperimentalFeatures = (function() { + + /** + * Properties of an ExperimentalFeatures. + * @memberof google.api.PythonSettings + * @interface IExperimentalFeatures + * @property {boolean|null} [restAsyncIoEnabled] ExperimentalFeatures restAsyncIoEnabled + * @property {boolean|null} [protobufPythonicTypesEnabled] ExperimentalFeatures protobufPythonicTypesEnabled + * @property {boolean|null} [unversionedPackageDisabled] ExperimentalFeatures unversionedPackageDisabled + */ + + /** + * Constructs a new ExperimentalFeatures. + * @memberof google.api.PythonSettings + * @classdesc Represents an ExperimentalFeatures. + * @implements IExperimentalFeatures + * @constructor + * @param {google.api.PythonSettings.IExperimentalFeatures=} [properties] Properties to set + */ + function ExperimentalFeatures(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]]; + } + + /** + * ExperimentalFeatures restAsyncIoEnabled. + * @member {boolean} restAsyncIoEnabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.restAsyncIoEnabled = false; + + /** + * ExperimentalFeatures protobufPythonicTypesEnabled. + * @member {boolean} protobufPythonicTypesEnabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.protobufPythonicTypesEnabled = false; + + /** + * ExperimentalFeatures unversionedPackageDisabled. + * @member {boolean} unversionedPackageDisabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.unversionedPackageDisabled = false; + + /** + * Creates a new ExperimentalFeatures instance using the specified properties. + * @function create + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures=} [properties] Properties to set + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures instance + */ + ExperimentalFeatures.create = function create(properties) { + return new ExperimentalFeatures(properties); + }; + + /** + * Encodes the specified ExperimentalFeatures message. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @function encode + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures} message ExperimentalFeatures message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExperimentalFeatures.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.restAsyncIoEnabled != null && Object.hasOwnProperty.call(message, "restAsyncIoEnabled")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.restAsyncIoEnabled); + if (message.protobufPythonicTypesEnabled != null && Object.hasOwnProperty.call(message, "protobufPythonicTypesEnabled")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.protobufPythonicTypesEnabled); + if (message.unversionedPackageDisabled != null && Object.hasOwnProperty.call(message, "unversionedPackageDisabled")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.unversionedPackageDisabled); + return writer; + }; + + /** + * Encodes the specified ExperimentalFeatures message, length delimited. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures} message ExperimentalFeatures message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExperimentalFeatures.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer. + * @function decode + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExperimentalFeatures.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.PythonSettings.ExperimentalFeatures(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.restAsyncIoEnabled = reader.bool(); + break; + } + case 2: { + message.protobufPythonicTypesEnabled = reader.bool(); + break; + } + case 3: { + message.unversionedPackageDisabled = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExperimentalFeatures.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExperimentalFeatures message. + * @function verify + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExperimentalFeatures.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.restAsyncIoEnabled != null && message.hasOwnProperty("restAsyncIoEnabled")) + if (typeof message.restAsyncIoEnabled !== "boolean") + return "restAsyncIoEnabled: boolean expected"; + if (message.protobufPythonicTypesEnabled != null && message.hasOwnProperty("protobufPythonicTypesEnabled")) + if (typeof message.protobufPythonicTypesEnabled !== "boolean") + return "protobufPythonicTypesEnabled: boolean expected"; + if (message.unversionedPackageDisabled != null && message.hasOwnProperty("unversionedPackageDisabled")) + if (typeof message.unversionedPackageDisabled !== "boolean") + return "unversionedPackageDisabled: boolean expected"; + return null; + }; + + /** + * Creates an ExperimentalFeatures message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {Object.} object Plain object + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + */ + ExperimentalFeatures.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.PythonSettings.ExperimentalFeatures) + return object; + var message = new $root.google.api.PythonSettings.ExperimentalFeatures(); + if (object.restAsyncIoEnabled != null) + message.restAsyncIoEnabled = Boolean(object.restAsyncIoEnabled); + if (object.protobufPythonicTypesEnabled != null) + message.protobufPythonicTypesEnabled = Boolean(object.protobufPythonicTypesEnabled); + if (object.unversionedPackageDisabled != null) + message.unversionedPackageDisabled = Boolean(object.unversionedPackageDisabled); + return message; + }; + + /** + * Creates a plain object from an ExperimentalFeatures message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.ExperimentalFeatures} message ExperimentalFeatures + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExperimentalFeatures.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.restAsyncIoEnabled = false; + object.protobufPythonicTypesEnabled = false; + object.unversionedPackageDisabled = false; + } + if (message.restAsyncIoEnabled != null && message.hasOwnProperty("restAsyncIoEnabled")) + object.restAsyncIoEnabled = message.restAsyncIoEnabled; + if (message.protobufPythonicTypesEnabled != null && message.hasOwnProperty("protobufPythonicTypesEnabled")) + object.protobufPythonicTypesEnabled = message.protobufPythonicTypesEnabled; + if (message.unversionedPackageDisabled != null && message.hasOwnProperty("unversionedPackageDisabled")) + object.unversionedPackageDisabled = message.unversionedPackageDisabled; + return object; + }; + + /** + * Converts this ExperimentalFeatures to JSON. + * @function toJSON + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + * @returns {Object.} JSON object + */ + ExperimentalFeatures.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExperimentalFeatures + * @function getTypeUrl + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExperimentalFeatures.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.PythonSettings.ExperimentalFeatures"; + }; + + return ExperimentalFeatures; + })(); + return PythonSettings; })(); @@ -30103,6 +30413,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -30114,6 +30425,7 @@ * @param {google.api.IGoSettings=} [properties] Properties to set */ function GoSettings(properties) { + this.renamedServices = {}; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -30128,6 +30440,14 @@ */ GoSettings.prototype.common = null; + /** + * GoSettings renamedServices. + * @member {Object.} renamedServices + * @memberof google.api.GoSettings + * @instance + */ + GoSettings.prototype.renamedServices = $util.emptyObject; + /** * Creates a new GoSettings instance using the specified properties. * @function create @@ -30154,6 +30474,9 @@ writer = $Writer.create(); if (message.common != null && Object.hasOwnProperty.call(message, "common")) $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.renamedServices != null && Object.hasOwnProperty.call(message, "renamedServices")) + for (var keys = Object.keys(message.renamedServices), i = 0; i < keys.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.renamedServices[keys[i]]).ldelim(); return writer; }; @@ -30184,7 +30507,7 @@ GoSettings.decode = function decode(reader, length, error) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.GoSettings(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.GoSettings(), key, value; while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) @@ -30194,6 +30517,29 @@ message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); break; } + case 2: { + if (message.renamedServices === $util.emptyObject) + message.renamedServices = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = ""; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = reader.string(); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.renamedServices[key] = value; + break; + } default: reader.skipType(tag & 7); break; @@ -30234,6 +30580,14 @@ if (error) return "common." + error; } + if (message.renamedServices != null && message.hasOwnProperty("renamedServices")) { + if (!$util.isObject(message.renamedServices)) + return "renamedServices: object expected"; + var key = Object.keys(message.renamedServices); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.renamedServices[key[i]])) + return "renamedServices: string{k:string} expected"; + } return null; }; @@ -30254,6 +30608,13 @@ throw TypeError(".google.api.GoSettings.common: object expected"); message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); } + if (object.renamedServices) { + if (typeof object.renamedServices !== "object") + throw TypeError(".google.api.GoSettings.renamedServices: object expected"); + message.renamedServices = {}; + for (var keys = Object.keys(object.renamedServices), i = 0; i < keys.length; ++i) + message.renamedServices[keys[i]] = String(object.renamedServices[keys[i]]); + } return message; }; @@ -30270,10 +30631,18 @@ if (!options) options = {}; var object = {}; + if (options.objects || options.defaults) + object.renamedServices = {}; if (options.defaults) object.common = null; if (message.common != null && message.hasOwnProperty("common")) object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + var keys2; + if (message.renamedServices && (keys2 = Object.keys(message.renamedServices)).length) { + object.renamedServices = {}; + for (var j = 0; j < keys2.length; ++j) + object.renamedServices[keys2[j]] = message.renamedServices[keys2[j]]; + } return object; }; @@ -30912,30 +31281,275 @@ return values; })(); - /** - * LaunchStage enum. - * @name google.api.LaunchStage - * @enum {number} - * @property {number} LAUNCH_STAGE_UNSPECIFIED=0 LAUNCH_STAGE_UNSPECIFIED value - * @property {number} UNIMPLEMENTED=6 UNIMPLEMENTED value - * @property {number} PRELAUNCH=7 PRELAUNCH value - * @property {number} EARLY_ACCESS=1 EARLY_ACCESS value - * @property {number} ALPHA=2 ALPHA value - * @property {number} BETA=3 BETA value - * @property {number} GA=4 GA value - * @property {number} DEPRECATED=5 DEPRECATED value - */ - api.LaunchStage = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "LAUNCH_STAGE_UNSPECIFIED"] = 0; - values[valuesById[6] = "UNIMPLEMENTED"] = 6; - values[valuesById[7] = "PRELAUNCH"] = 7; - values[valuesById[1] = "EARLY_ACCESS"] = 1; - values[valuesById[2] = "ALPHA"] = 2; - values[valuesById[3] = "BETA"] = 3; - values[valuesById[4] = "GA"] = 4; - values[valuesById[5] = "DEPRECATED"] = 5; - return values; + api.SelectiveGapicGeneration = (function() { + + /** + * Properties of a SelectiveGapicGeneration. + * @memberof google.api + * @interface ISelectiveGapicGeneration + * @property {Array.|null} [methods] SelectiveGapicGeneration methods + * @property {boolean|null} [generateOmittedAsInternal] SelectiveGapicGeneration generateOmittedAsInternal + */ + + /** + * Constructs a new SelectiveGapicGeneration. + * @memberof google.api + * @classdesc Represents a SelectiveGapicGeneration. + * @implements ISelectiveGapicGeneration + * @constructor + * @param {google.api.ISelectiveGapicGeneration=} [properties] Properties to set + */ + function SelectiveGapicGeneration(properties) { + this.methods = []; + 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]]; + } + + /** + * SelectiveGapicGeneration methods. + * @member {Array.} methods + * @memberof google.api.SelectiveGapicGeneration + * @instance + */ + SelectiveGapicGeneration.prototype.methods = $util.emptyArray; + + /** + * SelectiveGapicGeneration generateOmittedAsInternal. + * @member {boolean} generateOmittedAsInternal + * @memberof google.api.SelectiveGapicGeneration + * @instance + */ + SelectiveGapicGeneration.prototype.generateOmittedAsInternal = false; + + /** + * Creates a new SelectiveGapicGeneration instance using the specified properties. + * @function create + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration=} [properties] Properties to set + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration instance + */ + SelectiveGapicGeneration.create = function create(properties) { + return new SelectiveGapicGeneration(properties); + }; + + /** + * Encodes the specified SelectiveGapicGeneration message. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @function encode + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration} message SelectiveGapicGeneration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SelectiveGapicGeneration.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.methods != null && message.methods.length) + for (var i = 0; i < message.methods.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.methods[i]); + if (message.generateOmittedAsInternal != null && Object.hasOwnProperty.call(message, "generateOmittedAsInternal")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.generateOmittedAsInternal); + return writer; + }; + + /** + * Encodes the specified SelectiveGapicGeneration message, length delimited. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration} message SelectiveGapicGeneration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SelectiveGapicGeneration.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer. + * @function decode + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SelectiveGapicGeneration.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.SelectiveGapicGeneration(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + if (!(message.methods && message.methods.length)) + message.methods = []; + message.methods.push(reader.string()); + break; + } + case 2: { + message.generateOmittedAsInternal = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SelectiveGapicGeneration.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SelectiveGapicGeneration message. + * @function verify + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SelectiveGapicGeneration.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.methods != null && message.hasOwnProperty("methods")) { + if (!Array.isArray(message.methods)) + return "methods: array expected"; + for (var i = 0; i < message.methods.length; ++i) + if (!$util.isString(message.methods[i])) + return "methods: string[] expected"; + } + if (message.generateOmittedAsInternal != null && message.hasOwnProperty("generateOmittedAsInternal")) + if (typeof message.generateOmittedAsInternal !== "boolean") + return "generateOmittedAsInternal: boolean expected"; + return null; + }; + + /** + * Creates a SelectiveGapicGeneration message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {Object.} object Plain object + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + */ + SelectiveGapicGeneration.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.SelectiveGapicGeneration) + return object; + var message = new $root.google.api.SelectiveGapicGeneration(); + if (object.methods) { + if (!Array.isArray(object.methods)) + throw TypeError(".google.api.SelectiveGapicGeneration.methods: array expected"); + message.methods = []; + for (var i = 0; i < object.methods.length; ++i) + message.methods[i] = String(object.methods[i]); + } + if (object.generateOmittedAsInternal != null) + message.generateOmittedAsInternal = Boolean(object.generateOmittedAsInternal); + return message; + }; + + /** + * Creates a plain object from a SelectiveGapicGeneration message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.SelectiveGapicGeneration} message SelectiveGapicGeneration + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SelectiveGapicGeneration.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.methods = []; + if (options.defaults) + object.generateOmittedAsInternal = false; + if (message.methods && message.methods.length) { + object.methods = []; + for (var j = 0; j < message.methods.length; ++j) + object.methods[j] = message.methods[j]; + } + if (message.generateOmittedAsInternal != null && message.hasOwnProperty("generateOmittedAsInternal")) + object.generateOmittedAsInternal = message.generateOmittedAsInternal; + return object; + }; + + /** + * Converts this SelectiveGapicGeneration to JSON. + * @function toJSON + * @memberof google.api.SelectiveGapicGeneration + * @instance + * @returns {Object.} JSON object + */ + SelectiveGapicGeneration.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SelectiveGapicGeneration + * @function getTypeUrl + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SelectiveGapicGeneration.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.SelectiveGapicGeneration"; + }; + + return SelectiveGapicGeneration; + })(); + + /** + * LaunchStage enum. + * @name google.api.LaunchStage + * @enum {number} + * @property {number} LAUNCH_STAGE_UNSPECIFIED=0 LAUNCH_STAGE_UNSPECIFIED value + * @property {number} UNIMPLEMENTED=6 UNIMPLEMENTED value + * @property {number} PRELAUNCH=7 PRELAUNCH value + * @property {number} EARLY_ACCESS=1 EARLY_ACCESS value + * @property {number} ALPHA=2 ALPHA value + * @property {number} BETA=3 BETA value + * @property {number} GA=4 GA value + * @property {number} DEPRECATED=5 DEPRECATED value + */ + api.LaunchStage = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "LAUNCH_STAGE_UNSPECIFIED"] = 0; + values[valuesById[6] = "UNIMPLEMENTED"] = 6; + values[valuesById[7] = "PRELAUNCH"] = 7; + values[valuesById[1] = "EARLY_ACCESS"] = 1; + values[valuesById[2] = "ALPHA"] = 2; + values[valuesById[3] = "BETA"] = 3; + values[valuesById[4] = "GA"] = 4; + values[valuesById[5] = "DEPRECATED"] = 5; + return values; })(); /** @@ -30973,6 +31587,7 @@ * @memberof google.api * @interface IFieldInfo * @property {google.api.FieldInfo.Format|null} [format] FieldInfo format + * @property {Array.|null} [referencedTypes] FieldInfo referencedTypes */ /** @@ -30984,6 +31599,7 @@ * @param {google.api.IFieldInfo=} [properties] Properties to set */ function FieldInfo(properties) { + this.referencedTypes = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -30998,6 +31614,14 @@ */ FieldInfo.prototype.format = 0; + /** + * FieldInfo referencedTypes. + * @member {Array.} referencedTypes + * @memberof google.api.FieldInfo + * @instance + */ + FieldInfo.prototype.referencedTypes = $util.emptyArray; + /** * Creates a new FieldInfo instance using the specified properties. * @function create @@ -31024,6 +31648,9 @@ writer = $Writer.create(); if (message.format != null && Object.hasOwnProperty.call(message, "format")) writer.uint32(/* id 1, wireType 0 =*/8).int32(message.format); + if (message.referencedTypes != null && message.referencedTypes.length) + for (var i = 0; i < message.referencedTypes.length; ++i) + $root.google.api.TypeReference.encode(message.referencedTypes[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; @@ -31064,6 +31691,12 @@ message.format = reader.int32(); break; } + case 2: { + if (!(message.referencedTypes && message.referencedTypes.length)) + message.referencedTypes = []; + message.referencedTypes.push($root.google.api.TypeReference.decode(reader, reader.uint32())); + break; + } default: reader.skipType(tag & 7); break; @@ -31110,6 +31743,15 @@ case 4: break; } + if (message.referencedTypes != null && message.hasOwnProperty("referencedTypes")) { + if (!Array.isArray(message.referencedTypes)) + return "referencedTypes: array expected"; + for (var i = 0; i < message.referencedTypes.length; ++i) { + var error = $root.google.api.TypeReference.verify(message.referencedTypes[i]); + if (error) + return "referencedTypes." + error; + } + } return null; }; @@ -31153,6 +31795,16 @@ message.format = 4; break; } + if (object.referencedTypes) { + if (!Array.isArray(object.referencedTypes)) + throw TypeError(".google.api.FieldInfo.referencedTypes: array expected"); + message.referencedTypes = []; + for (var i = 0; i < object.referencedTypes.length; ++i) { + if (typeof object.referencedTypes[i] !== "object") + throw TypeError(".google.api.FieldInfo.referencedTypes: object expected"); + message.referencedTypes[i] = $root.google.api.TypeReference.fromObject(object.referencedTypes[i]); + } + } return message; }; @@ -31169,10 +31821,17 @@ if (!options) options = {}; var object = {}; + if (options.arrays || options.defaults) + object.referencedTypes = []; if (options.defaults) object.format = options.enums === String ? "FORMAT_UNSPECIFIED" : 0; if (message.format != null && message.hasOwnProperty("format")) object.format = options.enums === String ? $root.google.api.FieldInfo.Format[message.format] === undefined ? message.format : $root.google.api.FieldInfo.Format[message.format] : message.format; + if (message.referencedTypes && message.referencedTypes.length) { + object.referencedTypes = []; + for (var j = 0; j < message.referencedTypes.length; ++j) + object.referencedTypes[j] = $root.google.api.TypeReference.toObject(message.referencedTypes[j], options); + } return object; }; @@ -31225,32 +31884,24 @@ return FieldInfo; })(); - api.ResourceDescriptor = (function() { + api.TypeReference = (function() { /** - * Properties of a ResourceDescriptor. + * Properties of a TypeReference. * @memberof google.api - * @interface IResourceDescriptor - * @property {string|null} [type] ResourceDescriptor type - * @property {Array.|null} [pattern] ResourceDescriptor pattern - * @property {string|null} [nameField] ResourceDescriptor nameField - * @property {google.api.ResourceDescriptor.History|null} [history] ResourceDescriptor history - * @property {string|null} [plural] ResourceDescriptor plural - * @property {string|null} [singular] ResourceDescriptor singular - * @property {Array.|null} [style] ResourceDescriptor style + * @interface ITypeReference + * @property {string|null} [typeName] TypeReference typeName */ /** - * Constructs a new ResourceDescriptor. + * Constructs a new TypeReference. * @memberof google.api - * @classdesc Represents a ResourceDescriptor. - * @implements IResourceDescriptor + * @classdesc Represents a TypeReference. + * @implements ITypeReference * @constructor - * @param {google.api.IResourceDescriptor=} [properties] Properties to set + * @param {google.api.ITypeReference=} [properties] Properties to set */ - function ResourceDescriptor(properties) { - this.pattern = []; - this.style = []; + function TypeReference(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -31258,50 +31909,263 @@ } /** - * ResourceDescriptor type. - * @member {string} type - * @memberof google.api.ResourceDescriptor + * TypeReference typeName. + * @member {string} typeName + * @memberof google.api.TypeReference * @instance */ - ResourceDescriptor.prototype.type = ""; + TypeReference.prototype.typeName = ""; /** - * ResourceDescriptor pattern. - * @member {Array.} pattern - * @memberof google.api.ResourceDescriptor - * @instance + * Creates a new TypeReference instance using the specified properties. + * @function create + * @memberof google.api.TypeReference + * @static + * @param {google.api.ITypeReference=} [properties] Properties to set + * @returns {google.api.TypeReference} TypeReference instance */ - ResourceDescriptor.prototype.pattern = $util.emptyArray; + TypeReference.create = function create(properties) { + return new TypeReference(properties); + }; /** - * ResourceDescriptor nameField. - * @member {string} nameField - * @memberof google.api.ResourceDescriptor - * @instance + * Encodes the specified TypeReference message. Does not implicitly {@link google.api.TypeReference.verify|verify} messages. + * @function encode + * @memberof google.api.TypeReference + * @static + * @param {google.api.ITypeReference} message TypeReference message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer */ - ResourceDescriptor.prototype.nameField = ""; + TypeReference.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.typeName != null && Object.hasOwnProperty.call(message, "typeName")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.typeName); + return writer; + }; /** - * ResourceDescriptor history. - * @member {google.api.ResourceDescriptor.History} history - * @memberof google.api.ResourceDescriptor - * @instance + * Encodes the specified TypeReference message, length delimited. Does not implicitly {@link google.api.TypeReference.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.TypeReference + * @static + * @param {google.api.ITypeReference} message TypeReference message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer */ - ResourceDescriptor.prototype.history = 0; + TypeReference.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; /** - * ResourceDescriptor plural. - * @member {string} plural - * @memberof google.api.ResourceDescriptor - * @instance + * Decodes a TypeReference message from the specified reader or buffer. + * @function decode + * @memberof google.api.TypeReference + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.TypeReference} TypeReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - ResourceDescriptor.prototype.plural = ""; - - /** - * ResourceDescriptor singular. - * @member {string} singular - * @memberof google.api.ResourceDescriptor - * @instance + TypeReference.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.TypeReference(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.typeName = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a TypeReference message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.TypeReference + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.TypeReference} TypeReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TypeReference.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TypeReference message. + * @function verify + * @memberof google.api.TypeReference + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TypeReference.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.typeName != null && message.hasOwnProperty("typeName")) + if (!$util.isString(message.typeName)) + return "typeName: string expected"; + return null; + }; + + /** + * Creates a TypeReference message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.TypeReference + * @static + * @param {Object.} object Plain object + * @returns {google.api.TypeReference} TypeReference + */ + TypeReference.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.TypeReference) + return object; + var message = new $root.google.api.TypeReference(); + if (object.typeName != null) + message.typeName = String(object.typeName); + return message; + }; + + /** + * Creates a plain object from a TypeReference message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.TypeReference + * @static + * @param {google.api.TypeReference} message TypeReference + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TypeReference.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.typeName = ""; + if (message.typeName != null && message.hasOwnProperty("typeName")) + object.typeName = message.typeName; + return object; + }; + + /** + * Converts this TypeReference to JSON. + * @function toJSON + * @memberof google.api.TypeReference + * @instance + * @returns {Object.} JSON object + */ + TypeReference.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for TypeReference + * @function getTypeUrl + * @memberof google.api.TypeReference + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + TypeReference.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.TypeReference"; + }; + + return TypeReference; + })(); + + api.ResourceDescriptor = (function() { + + /** + * Properties of a ResourceDescriptor. + * @memberof google.api + * @interface IResourceDescriptor + * @property {string|null} [type] ResourceDescriptor type + * @property {Array.|null} [pattern] ResourceDescriptor pattern + * @property {string|null} [nameField] ResourceDescriptor nameField + * @property {google.api.ResourceDescriptor.History|null} [history] ResourceDescriptor history + * @property {string|null} [plural] ResourceDescriptor plural + * @property {string|null} [singular] ResourceDescriptor singular + * @property {Array.|null} [style] ResourceDescriptor style + */ + + /** + * Constructs a new ResourceDescriptor. + * @memberof google.api + * @classdesc Represents a ResourceDescriptor. + * @implements IResourceDescriptor + * @constructor + * @param {google.api.IResourceDescriptor=} [properties] Properties to set + */ + function ResourceDescriptor(properties) { + this.pattern = []; + this.style = []; + 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]]; + } + + /** + * ResourceDescriptor type. + * @member {string} type + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.type = ""; + + /** + * ResourceDescriptor pattern. + * @member {Array.} pattern + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.pattern = $util.emptyArray; + + /** + * ResourceDescriptor nameField. + * @member {string} nameField + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.nameField = ""; + + /** + * ResourceDescriptor history. + * @member {google.api.ResourceDescriptor.History} history + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.history = 0; + + /** + * ResourceDescriptor plural. + * @member {string} plural + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.plural = ""; + + /** + * ResourceDescriptor singular. + * @member {string} singular + * @memberof google.api.ResourceDescriptor + * @instance */ ResourceDescriptor.prototype.singular = ""; @@ -32156,6 +33020,7 @@ * @name google.protobuf.Edition * @enum {number} * @property {number} EDITION_UNKNOWN=0 EDITION_UNKNOWN value + * @property {number} EDITION_LEGACY=900 EDITION_LEGACY value * @property {number} EDITION_PROTO2=998 EDITION_PROTO2 value * @property {number} EDITION_PROTO3=999 EDITION_PROTO3 value * @property {number} EDITION_2023=1000 EDITION_2023 value @@ -32170,6 +33035,7 @@ protobuf.Edition = (function() { var valuesById = {}, values = Object.create(valuesById); values[valuesById[0] = "EDITION_UNKNOWN"] = 0; + values[valuesById[900] = "EDITION_LEGACY"] = 900; values[valuesById[998] = "EDITION_PROTO2"] = 998; values[valuesById[999] = "EDITION_PROTO3"] = 999; values[valuesById[1000] = "EDITION_2023"] = 1000; @@ -32194,6 +33060,7 @@ * @property {Array.|null} [dependency] FileDescriptorProto dependency * @property {Array.|null} [publicDependency] FileDescriptorProto publicDependency * @property {Array.|null} [weakDependency] FileDescriptorProto weakDependency + * @property {Array.|null} [optionDependency] FileDescriptorProto optionDependency * @property {Array.|null} [messageType] FileDescriptorProto messageType * @property {Array.|null} [enumType] FileDescriptorProto enumType * @property {Array.|null} [service] FileDescriptorProto service @@ -32216,6 +33083,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -32266,6 +33134,14 @@ */ FileDescriptorProto.prototype.weakDependency = $util.emptyArray; + /** + * FileDescriptorProto optionDependency. + * @member {Array.} optionDependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.optionDependency = $util.emptyArray; + /** * FileDescriptorProto messageType. * @member {Array.} messageType @@ -32387,6 +33263,9 @@ writer.uint32(/* id 12, wireType 2 =*/98).string(message.syntax); if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) writer.uint32(/* id 14, wireType 0 =*/112).int32(message.edition); + if (message.optionDependency != null && message.optionDependency.length) + for (var i = 0; i < message.optionDependency.length; ++i) + writer.uint32(/* id 15, wireType 2 =*/122).string(message.optionDependency[i]); return writer; }; @@ -32459,6 +33338,12 @@ message.weakDependency.push(reader.int32()); break; } + case 15: { + if (!(message.optionDependency && message.optionDependency.length)) + message.optionDependency = []; + message.optionDependency.push(reader.string()); + break; + } case 4: { if (!(message.messageType && message.messageType.length)) message.messageType = []; @@ -32561,6 +33446,13 @@ if (!$util.isInteger(message.weakDependency[i])) return "weakDependency: integer[] expected"; } + if (message.optionDependency != null && message.hasOwnProperty("optionDependency")) { + if (!Array.isArray(message.optionDependency)) + return "optionDependency: array expected"; + for (var i = 0; i < message.optionDependency.length; ++i) + if (!$util.isString(message.optionDependency[i])) + return "optionDependency: string[] expected"; + } if (message.messageType != null && message.hasOwnProperty("messageType")) { if (!Array.isArray(message.messageType)) return "messageType: array expected"; @@ -32615,6 +33507,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -32667,6 +33560,13 @@ for (var i = 0; i < object.weakDependency.length; ++i) message.weakDependency[i] = object.weakDependency[i] | 0; } + if (object.optionDependency) { + if (!Array.isArray(object.optionDependency)) + throw TypeError(".google.protobuf.FileDescriptorProto.optionDependency: array expected"); + message.optionDependency = []; + for (var i = 0; i < object.optionDependency.length; ++i) + message.optionDependency[i] = String(object.optionDependency[i]); + } if (object.messageType) { if (!Array.isArray(object.messageType)) throw TypeError(".google.protobuf.FileDescriptorProto.messageType: array expected"); @@ -32730,6 +33630,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -32795,6 +33699,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -32851,6 +33756,11 @@ object.syntax = message.syntax; if (message.edition != null && message.hasOwnProperty("edition")) object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.optionDependency && message.optionDependency.length) { + object.optionDependency = []; + for (var j = 0; j < message.optionDependency.length; ++j) + object.optionDependency[j] = message.optionDependency[j]; + } return object; }; @@ -32899,6 +33809,7 @@ * @property {google.protobuf.IMessageOptions|null} [options] DescriptorProto options * @property {Array.|null} [reservedRange] DescriptorProto reservedRange * @property {Array.|null} [reservedName] DescriptorProto reservedName + * @property {google.protobuf.SymbolVisibility|null} [visibility] DescriptorProto visibility */ /** @@ -33004,6 +33915,14 @@ */ DescriptorProto.prototype.reservedName = $util.emptyArray; + /** + * DescriptorProto visibility. + * @member {google.protobuf.SymbolVisibility} visibility + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.visibility = 0; + /** * Creates a new DescriptorProto instance using the specified properties. * @function create @@ -33056,6 +33975,8 @@ if (message.reservedName != null && message.reservedName.length) for (var i = 0; i < message.reservedName.length; ++i) writer.uint32(/* id 10, wireType 2 =*/82).string(message.reservedName[i]); + if (message.visibility != null && Object.hasOwnProperty.call(message, "visibility")) + writer.uint32(/* id 11, wireType 0 =*/88).int32(message.visibility); return writer; }; @@ -33148,6 +34069,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -33261,6 +34186,15 @@ if (!$util.isString(message.reservedName[i])) return "reservedName: string[] expected"; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + switch (message.visibility) { + default: + return "visibility: enum value expected"; + case 0: + case 1: + case 2: + break; + } return null; }; @@ -33360,6 +34294,26 @@ for (var i = 0; i < object.reservedName.length; ++i) message.reservedName[i] = String(object.reservedName[i]); } + switch (object.visibility) { + default: + if (typeof object.visibility === "number") { + message.visibility = object.visibility; + break; + } + break; + case "VISIBILITY_UNSET": + case 0: + message.visibility = 0; + break; + case "VISIBILITY_LOCAL": + case 1: + message.visibility = 1; + break; + case "VISIBILITY_EXPORT": + case 2: + message.visibility = 2; + break; + } return message; }; @@ -33389,6 +34343,7 @@ if (options.defaults) { object.name = ""; object.options = null; + object.visibility = options.enums === String ? "VISIBILITY_UNSET" : 0; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -33434,6 +34389,8 @@ for (var j = 0; j < message.reservedName.length; ++j) object.reservedName[j] = message.reservedName[j]; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + object.visibility = options.enums === String ? $root.google.protobuf.SymbolVisibility[message.visibility] === undefined ? message.visibility : $root.google.protobuf.SymbolVisibility[message.visibility] : message.visibility; return object; }; @@ -35478,6 +36435,7 @@ * @property {google.protobuf.IEnumOptions|null} [options] EnumDescriptorProto options * @property {Array.|null} [reservedRange] EnumDescriptorProto reservedRange * @property {Array.|null} [reservedName] EnumDescriptorProto reservedName + * @property {google.protobuf.SymbolVisibility|null} [visibility] EnumDescriptorProto visibility */ /** @@ -35538,6 +36496,14 @@ */ EnumDescriptorProto.prototype.reservedName = $util.emptyArray; + /** + * EnumDescriptorProto visibility. + * @member {google.protobuf.SymbolVisibility} visibility + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.visibility = 0; + /** * Creates a new EnumDescriptorProto instance using the specified properties. * @function create @@ -35575,6 +36541,8 @@ if (message.reservedName != null && message.reservedName.length) for (var i = 0; i < message.reservedName.length; ++i) writer.uint32(/* id 5, wireType 2 =*/42).string(message.reservedName[i]); + if (message.visibility != null && Object.hasOwnProperty.call(message, "visibility")) + writer.uint32(/* id 6, wireType 0 =*/48).int32(message.visibility); return writer; }; @@ -35637,6 +36605,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -35705,6 +36677,15 @@ if (!$util.isString(message.reservedName[i])) return "reservedName: string[] expected"; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + switch (message.visibility) { + default: + return "visibility: enum value expected"; + case 0: + case 1: + case 2: + break; + } return null; }; @@ -35754,6 +36735,26 @@ for (var i = 0; i < object.reservedName.length; ++i) message.reservedName[i] = String(object.reservedName[i]); } + switch (object.visibility) { + default: + if (typeof object.visibility === "number") { + message.visibility = object.visibility; + break; + } + break; + case "VISIBILITY_UNSET": + case 0: + message.visibility = 0; + break; + case "VISIBILITY_LOCAL": + case 1: + message.visibility = 1; + break; + case "VISIBILITY_EXPORT": + case 2: + message.visibility = 2; + break; + } return message; }; @@ -35778,6 +36779,7 @@ if (options.defaults) { object.name = ""; object.options = null; + object.visibility = options.enums === String ? "VISIBILITY_UNSET" : 0; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -35798,6 +36800,8 @@ for (var j = 0; j < message.reservedName.length; ++j) object.reservedName[j] = message.reservedName[j]; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + object.visibility = options.enums === String ? $root.google.protobuf.SymbolVisibility[message.visibility] === undefined ? message.visibility : $root.google.protobuf.SymbolVisibility[message.visibility] : message.visibility; return object; }; @@ -38116,6 +39120,7 @@ * @property {Array.|null} [targets] FieldOptions targets * @property {Array.|null} [editionDefaults] FieldOptions editionDefaults * @property {google.protobuf.IFeatureSet|null} [features] FieldOptions features + * @property {google.protobuf.FieldOptions.IFeatureSupport|null} [featureSupport] FieldOptions featureSupport * @property {Array.|null} [uninterpretedOption] FieldOptions uninterpretedOption * @property {Array.|null} [".google.api.fieldBehavior"] FieldOptions .google.api.fieldBehavior * @property {google.api.IFieldInfo|null} [".google.api.fieldInfo"] FieldOptions .google.api.fieldInfo @@ -38237,6 +39242,14 @@ */ FieldOptions.prototype.features = null; + /** + * FieldOptions featureSupport. + * @member {google.protobuf.FieldOptions.IFeatureSupport|null|undefined} featureSupport + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.featureSupport = null; + /** * FieldOptions uninterpretedOption. * @member {Array.} uninterpretedOption @@ -38319,6 +39332,8 @@ $root.google.protobuf.FieldOptions.EditionDefault.encode(message.editionDefaults[i], writer.uint32(/* id 20, wireType 2 =*/162).fork()).ldelim(); if (message.features != null && Object.hasOwnProperty.call(message, "features")) $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 21, wireType 2 =*/170).fork()).ldelim(); + if (message.featureSupport != null && Object.hasOwnProperty.call(message, "featureSupport")) + $root.google.protobuf.FieldOptions.FeatureSupport.encode(message.featureSupport, writer.uint32(/* id 22, wireType 2 =*/178).fork()).ldelim(); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); @@ -38422,6 +39437,10 @@ message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); break; } + case 22: { + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.decode(reader, reader.uint32()); + break; + } case 999: { if (!(message.uninterpretedOption && message.uninterpretedOption.length)) message.uninterpretedOption = []; @@ -38561,6 +39580,11 @@ if (error) return "features." + error; } + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) { + var error = $root.google.protobuf.FieldOptions.FeatureSupport.verify(message.featureSupport); + if (error) + return "featureSupport." + error; + } if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { if (!Array.isArray(message.uninterpretedOption)) return "uninterpretedOption: array expected"; @@ -38754,6 +39778,11 @@ throw TypeError(".google.protobuf.FieldOptions.features: object expected"); message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); } + if (object.featureSupport != null) { + if (typeof object.featureSupport !== "object") + throw TypeError(".google.protobuf.FieldOptions.featureSupport: object expected"); + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.fromObject(object.featureSupport); + } if (object.uninterpretedOption) { if (!Array.isArray(object.uninterpretedOption)) throw TypeError(".google.protobuf.FieldOptions.uninterpretedOption: array expected"); @@ -38856,6 +39885,7 @@ object.debugRedact = false; object.retention = options.enums === String ? "RETENTION_UNKNOWN" : 0; object.features = null; + object.featureSupport = null; object[".google.api.resourceReference"] = null; object[".google.api.fieldInfo"] = null; } @@ -38889,6 +39919,8 @@ } if (message.features != null && message.hasOwnProperty("features")) object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) + object.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.toObject(message.featureSupport, options); if (message.uninterpretedOption && message.uninterpretedOption.length) { object.uninterpretedOption = []; for (var j = 0; j < message.uninterpretedOption.length; ++j) @@ -39163,6 +40195,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -39204,103 +40237,589 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; break; case "EDITION_PROTO3": case 999: - message.edition = 999; + message.edition = 999; + break; + case "EDITION_2023": + case 1000: + message.edition = 1000; + break; + case "EDITION_2024": + case 1001: + message.edition = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.edition = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.edition = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.edition = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.edition = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.edition = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.edition = 2147483647; + break; + } + if (object.value != null) + message.value = String(object.value); + return message; + }; + + /** + * Creates a plain object from an EditionDefault message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {google.protobuf.FieldOptions.EditionDefault} message EditionDefault + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EditionDefault.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.value = ""; + object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + } + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + if (message.edition != null && message.hasOwnProperty("edition")) + object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + return object; + }; + + /** + * Converts this EditionDefault to JSON. + * @function toJSON + * @memberof google.protobuf.FieldOptions.EditionDefault + * @instance + * @returns {Object.} JSON object + */ + EditionDefault.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for EditionDefault + * @function getTypeUrl + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + EditionDefault.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FieldOptions.EditionDefault"; + }; + + return EditionDefault; + })(); + + FieldOptions.FeatureSupport = (function() { + + /** + * Properties of a FeatureSupport. + * @memberof google.protobuf.FieldOptions + * @interface IFeatureSupport + * @property {google.protobuf.Edition|null} [editionIntroduced] FeatureSupport editionIntroduced + * @property {google.protobuf.Edition|null} [editionDeprecated] FeatureSupport editionDeprecated + * @property {string|null} [deprecationWarning] FeatureSupport deprecationWarning + * @property {google.protobuf.Edition|null} [editionRemoved] FeatureSupport editionRemoved + */ + + /** + * Constructs a new FeatureSupport. + * @memberof google.protobuf.FieldOptions + * @classdesc Represents a FeatureSupport. + * @implements IFeatureSupport + * @constructor + * @param {google.protobuf.FieldOptions.IFeatureSupport=} [properties] Properties to set + */ + function FeatureSupport(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]]; + } + + /** + * FeatureSupport editionIntroduced. + * @member {google.protobuf.Edition} editionIntroduced + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionIntroduced = 0; + + /** + * FeatureSupport editionDeprecated. + * @member {google.protobuf.Edition} editionDeprecated + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionDeprecated = 0; + + /** + * FeatureSupport deprecationWarning. + * @member {string} deprecationWarning + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.deprecationWarning = ""; + + /** + * FeatureSupport editionRemoved. + * @member {google.protobuf.Edition} editionRemoved + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionRemoved = 0; + + /** + * Creates a new FeatureSupport instance using the specified properties. + * @function create + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport=} [properties] Properties to set + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport instance + */ + FeatureSupport.create = function create(properties) { + return new FeatureSupport(properties); + }; + + /** + * Encodes the specified FeatureSupport message. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport} message FeatureSupport message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSupport.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.editionIntroduced != null && Object.hasOwnProperty.call(message, "editionIntroduced")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.editionIntroduced); + if (message.editionDeprecated != null && Object.hasOwnProperty.call(message, "editionDeprecated")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.editionDeprecated); + if (message.deprecationWarning != null && Object.hasOwnProperty.call(message, "deprecationWarning")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.deprecationWarning); + if (message.editionRemoved != null && Object.hasOwnProperty.call(message, "editionRemoved")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.editionRemoved); + return writer; + }; + + /** + * Encodes the specified FeatureSupport message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport} message FeatureSupport message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSupport.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSupport.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FieldOptions.FeatureSupport(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.editionIntroduced = reader.int32(); + break; + } + case 2: { + message.editionDeprecated = reader.int32(); + break; + } + case 3: { + message.deprecationWarning = reader.string(); + break; + } + case 4: { + message.editionRemoved = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSupport.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FeatureSupport message. + * @function verify + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FeatureSupport.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.editionIntroduced != null && message.hasOwnProperty("editionIntroduced")) + switch (message.editionIntroduced) { + default: + return "editionIntroduced: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + if (message.editionDeprecated != null && message.hasOwnProperty("editionDeprecated")) + switch (message.editionDeprecated) { + default: + return "editionDeprecated: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + if (message.deprecationWarning != null && message.hasOwnProperty("deprecationWarning")) + if (!$util.isString(message.deprecationWarning)) + return "deprecationWarning: string expected"; + if (message.editionRemoved != null && message.hasOwnProperty("editionRemoved")) + switch (message.editionRemoved) { + default: + return "editionRemoved: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + return null; + }; + + /** + * Creates a FeatureSupport message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + */ + FeatureSupport.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FieldOptions.FeatureSupport) + return object; + var message = new $root.google.protobuf.FieldOptions.FeatureSupport(); + switch (object.editionIntroduced) { + default: + if (typeof object.editionIntroduced === "number") { + message.editionIntroduced = object.editionIntroduced; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionIntroduced = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionIntroduced = 900; + break; + case "EDITION_PROTO2": + case 998: + message.editionIntroduced = 998; + break; + case "EDITION_PROTO3": + case 999: + message.editionIntroduced = 999; + break; + case "EDITION_2023": + case 1000: + message.editionIntroduced = 1000; + break; + case "EDITION_2024": + case 1001: + message.editionIntroduced = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.editionIntroduced = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.editionIntroduced = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.editionIntroduced = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.editionIntroduced = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.editionIntroduced = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.editionIntroduced = 2147483647; + break; + } + switch (object.editionDeprecated) { + default: + if (typeof object.editionDeprecated === "number") { + message.editionDeprecated = object.editionDeprecated; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionDeprecated = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionDeprecated = 900; + break; + case "EDITION_PROTO2": + case 998: + message.editionDeprecated = 998; + break; + case "EDITION_PROTO3": + case 999: + message.editionDeprecated = 999; + break; + case "EDITION_2023": + case 1000: + message.editionDeprecated = 1000; + break; + case "EDITION_2024": + case 1001: + message.editionDeprecated = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.editionDeprecated = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.editionDeprecated = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.editionDeprecated = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.editionDeprecated = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.editionDeprecated = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.editionDeprecated = 2147483647; + break; + } + if (object.deprecationWarning != null) + message.deprecationWarning = String(object.deprecationWarning); + switch (object.editionRemoved) { + default: + if (typeof object.editionRemoved === "number") { + message.editionRemoved = object.editionRemoved; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionRemoved = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionRemoved = 900; + break; + case "EDITION_PROTO2": + case 998: + message.editionRemoved = 998; + break; + case "EDITION_PROTO3": + case 999: + message.editionRemoved = 999; break; case "EDITION_2023": case 1000: - message.edition = 1000; + message.editionRemoved = 1000; break; case "EDITION_2024": case 1001: - message.edition = 1001; + message.editionRemoved = 1001; break; case "EDITION_1_TEST_ONLY": case 1: - message.edition = 1; + message.editionRemoved = 1; break; case "EDITION_2_TEST_ONLY": case 2: - message.edition = 2; + message.editionRemoved = 2; break; case "EDITION_99997_TEST_ONLY": case 99997: - message.edition = 99997; + message.editionRemoved = 99997; break; case "EDITION_99998_TEST_ONLY": case 99998: - message.edition = 99998; + message.editionRemoved = 99998; break; case "EDITION_99999_TEST_ONLY": case 99999: - message.edition = 99999; + message.editionRemoved = 99999; break; case "EDITION_MAX": case 2147483647: - message.edition = 2147483647; + message.editionRemoved = 2147483647; break; } - if (object.value != null) - message.value = String(object.value); return message; }; /** - * Creates a plain object from an EditionDefault message. Also converts values to other types if specified. + * Creates a plain object from a FeatureSupport message. Also converts values to other types if specified. * @function toObject - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @static - * @param {google.protobuf.FieldOptions.EditionDefault} message EditionDefault + * @param {google.protobuf.FieldOptions.FeatureSupport} message FeatureSupport * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - EditionDefault.toObject = function toObject(message, options) { + FeatureSupport.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { - object.value = ""; - object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; - } - if (message.value != null && message.hasOwnProperty("value")) - object.value = message.value; - if (message.edition != null && message.hasOwnProperty("edition")) - object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + object.editionIntroduced = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.editionDeprecated = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.deprecationWarning = ""; + object.editionRemoved = options.enums === String ? "EDITION_UNKNOWN" : 0; + } + if (message.editionIntroduced != null && message.hasOwnProperty("editionIntroduced")) + object.editionIntroduced = options.enums === String ? $root.google.protobuf.Edition[message.editionIntroduced] === undefined ? message.editionIntroduced : $root.google.protobuf.Edition[message.editionIntroduced] : message.editionIntroduced; + if (message.editionDeprecated != null && message.hasOwnProperty("editionDeprecated")) + object.editionDeprecated = options.enums === String ? $root.google.protobuf.Edition[message.editionDeprecated] === undefined ? message.editionDeprecated : $root.google.protobuf.Edition[message.editionDeprecated] : message.editionDeprecated; + if (message.deprecationWarning != null && message.hasOwnProperty("deprecationWarning")) + object.deprecationWarning = message.deprecationWarning; + if (message.editionRemoved != null && message.hasOwnProperty("editionRemoved")) + object.editionRemoved = options.enums === String ? $root.google.protobuf.Edition[message.editionRemoved] === undefined ? message.editionRemoved : $root.google.protobuf.Edition[message.editionRemoved] : message.editionRemoved; return object; }; /** - * Converts this EditionDefault to JSON. + * Converts this FeatureSupport to JSON. * @function toJSON - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @instance * @returns {Object.} JSON object */ - EditionDefault.prototype.toJSON = function toJSON() { + FeatureSupport.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for EditionDefault + * Gets the default type url for FeatureSupport * @function getTypeUrl - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - EditionDefault.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + FeatureSupport.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.protobuf.FieldOptions.EditionDefault"; + return typeUrlPrefix + "/google.protobuf.FieldOptions.FeatureSupport"; }; - return EditionDefault; + return FeatureSupport; })(); return FieldOptions; @@ -39895,6 +41414,7 @@ * @property {boolean|null} [deprecated] EnumValueOptions deprecated * @property {google.protobuf.IFeatureSet|null} [features] EnumValueOptions features * @property {boolean|null} [debugRedact] EnumValueOptions debugRedact + * @property {google.protobuf.FieldOptions.IFeatureSupport|null} [featureSupport] EnumValueOptions featureSupport * @property {Array.|null} [uninterpretedOption] EnumValueOptions uninterpretedOption */ @@ -39938,6 +41458,14 @@ */ EnumValueOptions.prototype.debugRedact = false; + /** + * EnumValueOptions featureSupport. + * @member {google.protobuf.FieldOptions.IFeatureSupport|null|undefined} featureSupport + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.featureSupport = null; + /** * EnumValueOptions uninterpretedOption. * @member {Array.} uninterpretedOption @@ -39976,6 +41504,8 @@ $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.debugRedact != null && Object.hasOwnProperty.call(message, "debugRedact")) writer.uint32(/* id 3, wireType 0 =*/24).bool(message.debugRedact); + if (message.featureSupport != null && Object.hasOwnProperty.call(message, "featureSupport")) + $root.google.protobuf.FieldOptions.FeatureSupport.encode(message.featureSupport, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); @@ -40027,6 +41557,10 @@ message.debugRedact = reader.bool(); break; } + case 4: { + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.decode(reader, reader.uint32()); + break; + } case 999: { if (!(message.uninterpretedOption && message.uninterpretedOption.length)) message.uninterpretedOption = []; @@ -40079,6 +41613,11 @@ if (message.debugRedact != null && message.hasOwnProperty("debugRedact")) if (typeof message.debugRedact !== "boolean") return "debugRedact: boolean expected"; + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) { + var error = $root.google.protobuf.FieldOptions.FeatureSupport.verify(message.featureSupport); + if (error) + return "featureSupport." + error; + } if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { if (!Array.isArray(message.uninterpretedOption)) return "uninterpretedOption: array expected"; @@ -40112,6 +41651,11 @@ } if (object.debugRedact != null) message.debugRedact = Boolean(object.debugRedact); + if (object.featureSupport != null) { + if (typeof object.featureSupport !== "object") + throw TypeError(".google.protobuf.EnumValueOptions.featureSupport: object expected"); + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.fromObject(object.featureSupport); + } if (object.uninterpretedOption) { if (!Array.isArray(object.uninterpretedOption)) throw TypeError(".google.protobuf.EnumValueOptions.uninterpretedOption: array expected"); @@ -40144,6 +41688,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -40151,6 +41696,8 @@ object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); if (message.debugRedact != null && message.hasOwnProperty("debugRedact")) object.debugRedact = message.debugRedact; + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) + object.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.toObject(message.featureSupport, options); if (message.uninterpretedOption && message.uninterpretedOption.length) { object.uninterpretedOption = []; for (var j = 0; j < message.uninterpretedOption.length; ++j) @@ -41618,6 +43165,8 @@ * @property {google.protobuf.FeatureSet.Utf8Validation|null} [utf8Validation] FeatureSet utf8Validation * @property {google.protobuf.FeatureSet.MessageEncoding|null} [messageEncoding] FeatureSet messageEncoding * @property {google.protobuf.FeatureSet.JsonFormat|null} [jsonFormat] FeatureSet jsonFormat + * @property {google.protobuf.FeatureSet.EnforceNamingStyle|null} [enforceNamingStyle] FeatureSet enforceNamingStyle + * @property {google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|null} [defaultSymbolVisibility] FeatureSet defaultSymbolVisibility */ /** @@ -41683,6 +43232,22 @@ */ FeatureSet.prototype.jsonFormat = 0; + /** + * FeatureSet enforceNamingStyle. + * @member {google.protobuf.FeatureSet.EnforceNamingStyle} enforceNamingStyle + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.enforceNamingStyle = 0; + + /** + * FeatureSet defaultSymbolVisibility. + * @member {google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility} defaultSymbolVisibility + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.defaultSymbolVisibility = 0; + /** * Creates a new FeatureSet instance using the specified properties. * @function create @@ -41719,6 +43284,10 @@ writer.uint32(/* id 5, wireType 0 =*/40).int32(message.messageEncoding); if (message.jsonFormat != null && Object.hasOwnProperty.call(message, "jsonFormat")) writer.uint32(/* id 6, wireType 0 =*/48).int32(message.jsonFormat); + if (message.enforceNamingStyle != null && Object.hasOwnProperty.call(message, "enforceNamingStyle")) + writer.uint32(/* id 7, wireType 0 =*/56).int32(message.enforceNamingStyle); + if (message.defaultSymbolVisibility != null && Object.hasOwnProperty.call(message, "defaultSymbolVisibility")) + writer.uint32(/* id 8, wireType 0 =*/64).int32(message.defaultSymbolVisibility); return writer; }; @@ -41779,6 +43348,14 @@ message.jsonFormat = reader.int32(); break; } + case 7: { + message.enforceNamingStyle = reader.int32(); + break; + } + case 8: { + message.defaultSymbolVisibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -41869,6 +43446,26 @@ case 2: break; } + if (message.enforceNamingStyle != null && message.hasOwnProperty("enforceNamingStyle")) + switch (message.enforceNamingStyle) { + default: + return "enforceNamingStyle: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.defaultSymbolVisibility != null && message.hasOwnProperty("defaultSymbolVisibility")) + switch (message.defaultSymbolVisibility) { + default: + return "defaultSymbolVisibility: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } return null; }; @@ -42008,6 +43605,54 @@ message.jsonFormat = 2; break; } + switch (object.enforceNamingStyle) { + default: + if (typeof object.enforceNamingStyle === "number") { + message.enforceNamingStyle = object.enforceNamingStyle; + break; + } + break; + case "ENFORCE_NAMING_STYLE_UNKNOWN": + case 0: + message.enforceNamingStyle = 0; + break; + case "STYLE2024": + case 1: + message.enforceNamingStyle = 1; + break; + case "STYLE_LEGACY": + case 2: + message.enforceNamingStyle = 2; + break; + } + switch (object.defaultSymbolVisibility) { + default: + if (typeof object.defaultSymbolVisibility === "number") { + message.defaultSymbolVisibility = object.defaultSymbolVisibility; + break; + } + break; + case "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN": + case 0: + message.defaultSymbolVisibility = 0; + break; + case "EXPORT_ALL": + case 1: + message.defaultSymbolVisibility = 1; + break; + case "EXPORT_TOP_LEVEL": + case 2: + message.defaultSymbolVisibility = 2; + break; + case "LOCAL_ALL": + case 3: + message.defaultSymbolVisibility = 3; + break; + case "STRICT": + case 4: + message.defaultSymbolVisibility = 4; + break; + } return message; }; @@ -42031,6 +43676,8 @@ object.utf8Validation = options.enums === String ? "UTF8_VALIDATION_UNKNOWN" : 0; object.messageEncoding = options.enums === String ? "MESSAGE_ENCODING_UNKNOWN" : 0; object.jsonFormat = options.enums === String ? "JSON_FORMAT_UNKNOWN" : 0; + object.enforceNamingStyle = options.enums === String ? "ENFORCE_NAMING_STYLE_UNKNOWN" : 0; + object.defaultSymbolVisibility = options.enums === String ? "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN" : 0; } if (message.fieldPresence != null && message.hasOwnProperty("fieldPresence")) object.fieldPresence = options.enums === String ? $root.google.protobuf.FeatureSet.FieldPresence[message.fieldPresence] === undefined ? message.fieldPresence : $root.google.protobuf.FeatureSet.FieldPresence[message.fieldPresence] : message.fieldPresence; @@ -42044,6 +43691,10 @@ object.messageEncoding = options.enums === String ? $root.google.protobuf.FeatureSet.MessageEncoding[message.messageEncoding] === undefined ? message.messageEncoding : $root.google.protobuf.FeatureSet.MessageEncoding[message.messageEncoding] : message.messageEncoding; if (message.jsonFormat != null && message.hasOwnProperty("jsonFormat")) object.jsonFormat = options.enums === String ? $root.google.protobuf.FeatureSet.JsonFormat[message.jsonFormat] === undefined ? message.jsonFormat : $root.google.protobuf.FeatureSet.JsonFormat[message.jsonFormat] : message.jsonFormat; + if (message.enforceNamingStyle != null && message.hasOwnProperty("enforceNamingStyle")) + object.enforceNamingStyle = options.enums === String ? $root.google.protobuf.FeatureSet.EnforceNamingStyle[message.enforceNamingStyle] === undefined ? message.enforceNamingStyle : $root.google.protobuf.FeatureSet.EnforceNamingStyle[message.enforceNamingStyle] : message.enforceNamingStyle; + if (message.defaultSymbolVisibility != null && message.hasOwnProperty("defaultSymbolVisibility")) + object.defaultSymbolVisibility = options.enums === String ? $root.google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility[message.defaultSymbolVisibility] === undefined ? message.defaultSymbolVisibility : $root.google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility[message.defaultSymbolVisibility] : message.defaultSymbolVisibility; return object; }; @@ -42171,6 +43822,219 @@ return values; })(); + /** + * EnforceNamingStyle enum. + * @name google.protobuf.FeatureSet.EnforceNamingStyle + * @enum {number} + * @property {number} ENFORCE_NAMING_STYLE_UNKNOWN=0 ENFORCE_NAMING_STYLE_UNKNOWN value + * @property {number} STYLE2024=1 STYLE2024 value + * @property {number} STYLE_LEGACY=2 STYLE_LEGACY value + */ + FeatureSet.EnforceNamingStyle = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "ENFORCE_NAMING_STYLE_UNKNOWN"] = 0; + values[valuesById[1] = "STYLE2024"] = 1; + values[valuesById[2] = "STYLE_LEGACY"] = 2; + return values; + })(); + + FeatureSet.VisibilityFeature = (function() { + + /** + * Properties of a VisibilityFeature. + * @memberof google.protobuf.FeatureSet + * @interface IVisibilityFeature + */ + + /** + * Constructs a new VisibilityFeature. + * @memberof google.protobuf.FeatureSet + * @classdesc Represents a VisibilityFeature. + * @implements IVisibilityFeature + * @constructor + * @param {google.protobuf.FeatureSet.IVisibilityFeature=} [properties] Properties to set + */ + function VisibilityFeature(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]]; + } + + /** + * Creates a new VisibilityFeature instance using the specified properties. + * @function create + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature=} [properties] Properties to set + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature instance + */ + VisibilityFeature.create = function create(properties) { + return new VisibilityFeature(properties); + }; + + /** + * Encodes the specified VisibilityFeature message. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature} message VisibilityFeature message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VisibilityFeature.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified VisibilityFeature message, length delimited. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature} message VisibilityFeature message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VisibilityFeature.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VisibilityFeature.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FeatureSet.VisibilityFeature(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VisibilityFeature.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a VisibilityFeature message. + * @function verify + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + VisibilityFeature.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a VisibilityFeature message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + */ + VisibilityFeature.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FeatureSet.VisibilityFeature) + return object; + return new $root.google.protobuf.FeatureSet.VisibilityFeature(); + }; + + /** + * Creates a plain object from a VisibilityFeature message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.VisibilityFeature} message VisibilityFeature + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + VisibilityFeature.toObject = function toObject() { + return {}; + }; + + /** + * Converts this VisibilityFeature to JSON. + * @function toJSON + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @instance + * @returns {Object.} JSON object + */ + VisibilityFeature.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for VisibilityFeature + * @function getTypeUrl + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + VisibilityFeature.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FeatureSet.VisibilityFeature"; + }; + + /** + * DefaultSymbolVisibility enum. + * @name google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility + * @enum {number} + * @property {number} DEFAULT_SYMBOL_VISIBILITY_UNKNOWN=0 DEFAULT_SYMBOL_VISIBILITY_UNKNOWN value + * @property {number} EXPORT_ALL=1 EXPORT_ALL value + * @property {number} EXPORT_TOP_LEVEL=2 EXPORT_TOP_LEVEL value + * @property {number} LOCAL_ALL=3 LOCAL_ALL value + * @property {number} STRICT=4 STRICT value + */ + VisibilityFeature.DefaultSymbolVisibility = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN"] = 0; + values[valuesById[1] = "EXPORT_ALL"] = 1; + values[valuesById[2] = "EXPORT_TOP_LEVEL"] = 2; + values[valuesById[3] = "LOCAL_ALL"] = 3; + values[valuesById[4] = "STRICT"] = 4; + return values; + })(); + + return VisibilityFeature; + })(); + return FeatureSet; })(); @@ -42355,6 +44219,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -42372,6 +44237,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -42420,6 +44286,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -42472,6 +44342,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -42580,7 +44454,8 @@ * @memberof google.protobuf.FeatureSetDefaults * @interface IFeatureSetEditionDefault * @property {google.protobuf.Edition|null} [edition] FeatureSetEditionDefault edition - * @property {google.protobuf.IFeatureSet|null} [features] FeatureSetEditionDefault features + * @property {google.protobuf.IFeatureSet|null} [overridableFeatures] FeatureSetEditionDefault overridableFeatures + * @property {google.protobuf.IFeatureSet|null} [fixedFeatures] FeatureSetEditionDefault fixedFeatures */ /** @@ -42607,12 +44482,20 @@ FeatureSetEditionDefault.prototype.edition = 0; /** - * FeatureSetEditionDefault features. - * @member {google.protobuf.IFeatureSet|null|undefined} features + * FeatureSetEditionDefault overridableFeatures. + * @member {google.protobuf.IFeatureSet|null|undefined} overridableFeatures + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @instance + */ + FeatureSetEditionDefault.prototype.overridableFeatures = null; + + /** + * FeatureSetEditionDefault fixedFeatures. + * @member {google.protobuf.IFeatureSet|null|undefined} fixedFeatures * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault * @instance */ - FeatureSetEditionDefault.prototype.features = null; + FeatureSetEditionDefault.prototype.fixedFeatures = null; /** * Creates a new FeatureSetEditionDefault instance using the specified properties. @@ -42638,10 +44521,12 @@ FeatureSetEditionDefault.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.features != null && Object.hasOwnProperty.call(message, "features")) - $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) writer.uint32(/* id 3, wireType 0 =*/24).int32(message.edition); + if (message.overridableFeatures != null && Object.hasOwnProperty.call(message, "overridableFeatures")) + $root.google.protobuf.FeatureSet.encode(message.overridableFeatures, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.fixedFeatures != null && Object.hasOwnProperty.call(message, "fixedFeatures")) + $root.google.protobuf.FeatureSet.encode(message.fixedFeatures, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); return writer; }; @@ -42682,8 +44567,12 @@ message.edition = reader.int32(); break; } - case 2: { - message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + case 4: { + message.overridableFeatures = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + break; + } + case 5: { + message.fixedFeatures = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); break; } default: @@ -42726,6 +44615,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -42738,10 +44628,15 @@ case 2147483647: break; } - if (message.features != null && message.hasOwnProperty("features")) { - var error = $root.google.protobuf.FeatureSet.verify(message.features); + if (message.overridableFeatures != null && message.hasOwnProperty("overridableFeatures")) { + var error = $root.google.protobuf.FeatureSet.verify(message.overridableFeatures); + if (error) + return "overridableFeatures." + error; + } + if (message.fixedFeatures != null && message.hasOwnProperty("fixedFeatures")) { + var error = $root.google.protobuf.FeatureSet.verify(message.fixedFeatures); if (error) - return "features." + error; + return "fixedFeatures." + error; } return null; }; @@ -42769,6 +44664,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -42810,10 +44709,15 @@ message.edition = 2147483647; break; } - if (object.features != null) { - if (typeof object.features !== "object") - throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.features: object expected"); - message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); + if (object.overridableFeatures != null) { + if (typeof object.overridableFeatures !== "object") + throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.overridableFeatures: object expected"); + message.overridableFeatures = $root.google.protobuf.FeatureSet.fromObject(object.overridableFeatures); + } + if (object.fixedFeatures != null) { + if (typeof object.fixedFeatures !== "object") + throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.fixedFeatures: object expected"); + message.fixedFeatures = $root.google.protobuf.FeatureSet.fromObject(object.fixedFeatures); } return message; }; @@ -42832,13 +44736,16 @@ options = {}; var object = {}; if (options.defaults) { - object.features = null; object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.overridableFeatures = null; + object.fixedFeatures = null; } - if (message.features != null && message.hasOwnProperty("features")) - object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); if (message.edition != null && message.hasOwnProperty("edition")) object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.overridableFeatures != null && message.hasOwnProperty("overridableFeatures")) + object.overridableFeatures = $root.google.protobuf.FeatureSet.toObject(message.overridableFeatures, options); + if (message.fixedFeatures != null && message.hasOwnProperty("fixedFeatures")) + object.fixedFeatures = $root.google.protobuf.FeatureSet.toObject(message.fixedFeatures, options); return object; }; @@ -44053,6 +45960,22 @@ return GeneratedCodeInfo; })(); + /** + * SymbolVisibility enum. + * @name google.protobuf.SymbolVisibility + * @enum {number} + * @property {number} VISIBILITY_UNSET=0 VISIBILITY_UNSET value + * @property {number} VISIBILITY_LOCAL=1 VISIBILITY_LOCAL value + * @property {number} VISIBILITY_EXPORT=2 VISIBILITY_EXPORT value + */ + protobuf.SymbolVisibility = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "VISIBILITY_UNSET"] = 0; + values[valuesById[1] = "VISIBILITY_LOCAL"] = 1; + values[valuesById[2] = "VISIBILITY_EXPORT"] = 2; + return values; + })(); + protobuf.Duration = (function() { /** diff --git a/packages/google-cloud-memorystore/protos/protos.json b/packages/google-cloud-memorystore/protos/protos.json index b28532ba7d26..fbcb558091f5 100644 --- a/packages/google-cloud-memorystore/protos/protos.json +++ b/packages/google-cloud-memorystore/protos/protos.json @@ -3594,8 +3594,7 @@ "java_multiple_files": true, "java_outer_classname": "ResourceProto", "java_package": "com.google.api", - "objc_class_prefix": "GAPI", - "cc_enable_arenas": true + "objc_class_prefix": "GAPI" }, "nested": { "http": { @@ -3719,6 +3718,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -3859,6 +3862,28 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "experimentalFeatures": { + "type": "ExperimentalFeatures", + "id": 2 + } + }, + "nested": { + "ExperimentalFeatures": { + "fields": { + "restAsyncIoEnabled": { + "type": "bool", + "id": 1 + }, + "protobufPythonicTypesEnabled": { + "type": "bool", + "id": 2 + }, + "unversionedPackageDisabled": { + "type": "bool", + "id": 3 + } + } } } }, @@ -3916,6 +3941,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -3977,6 +4007,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -4021,6 +4064,11 @@ "format": { "type": "Format", "id": 1 + }, + "referencedTypes": { + "rule": "repeated", + "type": "TypeReference", + "id": 2 } }, "nested": { @@ -4035,6 +4083,14 @@ } } }, + "TypeReference": { + "fields": { + "typeName": { + "type": "string", + "id": 1 + } + } + }, "resourceReference": { "type": "google.api.ResourceReference", "id": 1055, @@ -4133,12 +4189,19 @@ "type": "FileDescriptorProto", "id": 1 } - } + }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ] }, "Edition": { "edition": "proto2", "values": { "EDITION_UNKNOWN": 0, + "EDITION_LEGACY": 900, "EDITION_PROTO2": 998, "EDITION_PROTO3": 999, "EDITION_2023": 1000, @@ -4177,6 +4240,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -4265,6 +4333,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -4490,6 +4562,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -4540,7 +4616,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -4704,6 +4787,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -4839,7 +4923,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -4867,6 +4952,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -4936,6 +5025,26 @@ "id": 2 } } + }, + "FeatureSupport": { + "fields": { + "editionIntroduced": { + "type": "Edition", + "id": 1 + }, + "editionDeprecated": { + "type": "Edition", + "id": 2 + }, + "deprecationWarning": { + "type": "string", + "id": 3 + }, + "editionRemoved": { + "type": "Edition", + "id": 4 + } + } } } }, @@ -5024,6 +5133,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -5166,6 +5279,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -5176,6 +5290,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -5186,6 +5301,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -5196,6 +5312,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -5206,7 +5323,8 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", - "edition_defaults.edition": "EDITION_PROTO2", + "feature_support.edition_introduced": "EDITION_2023", + "edition_defaults.edition": "EDITION_LEGACY", "edition_defaults.value": "LENGTH_PREFIXED" } }, @@ -5216,27 +5334,38 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "ALLOW" } + }, + "enforceNamingStyle": { + "type": "EnforceNamingStyle", + "id": 7, + "options": { + "retention": "RETENTION_SOURCE", + "targets": "TARGET_TYPE_METHOD", + "feature_support.edition_introduced": "EDITION_2024", + "edition_defaults.edition": "EDITION_2024", + "edition_defaults.value": "STYLE2024" + } + }, + "defaultSymbolVisibility": { + "type": "VisibilityFeature.DefaultSymbolVisibility", + "id": 8, + "options": { + "retention": "RETENTION_SOURCE", + "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2024", + "edition_defaults.edition": "EDITION_2024", + "edition_defaults.value": "EXPORT_TOP_LEVEL" + } } }, "extensions": [ [ 1000, - 1000 - ], - [ - 1001, - 1001 - ], - [ - 1002, - 1002 - ], - [ - 9990, - 9990 + 9994 ], [ 9995, @@ -5281,7 +5410,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -5296,6 +5431,33 @@ "ALLOW": 1, "LEGACY_BEST_EFFORT": 2 } + }, + "EnforceNamingStyle": { + "values": { + "ENFORCE_NAMING_STYLE_UNKNOWN": 0, + "STYLE2024": 1, + "STYLE_LEGACY": 2 + } + }, + "VisibilityFeature": { + "fields": {}, + "reserved": [ + [ + 1, + 536870911 + ] + ], + "nested": { + "DefaultSymbolVisibility": { + "values": { + "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN": 0, + "EXPORT_ALL": 1, + "EXPORT_TOP_LEVEL": 2, + "LOCAL_ALL": 3, + "STRICT": 4 + } + } + } } } }, @@ -5323,11 +5485,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -5340,6 +5517,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -5425,6 +5608,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Duration": { "fields": { "seconds": { @@ -5483,6 +5674,7 @@ "java_multiple_files": true, "java_outer_classname": "OperationsProto", "java_package": "com.google.longrunning", + "objc_class_prefix": "GLRUN", "php_namespace": "Google\\LongRunning" }, "nested": { diff --git a/packages/google-cloud-memorystore/samples/generated/v1/snippet_metadata_google.cloud.memorystore.v1.json b/packages/google-cloud-memorystore/samples/generated/v1/snippet_metadata_google.cloud.memorystore.v1.json index 82f7e5a99e4d..0d059e62e39f 100644 --- a/packages/google-cloud-memorystore/samples/generated/v1/snippet_metadata_google.cloud.memorystore.v1.json +++ b/packages/google-cloud-memorystore/samples/generated/v1/snippet_metadata_google.cloud.memorystore.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-memorystore", - "version": "0.5.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-memorystore/samples/generated/v1beta/snippet_metadata_google.cloud.memorystore.v1beta.json b/packages/google-cloud-memorystore/samples/generated/v1beta/snippet_metadata_google.cloud.memorystore.v1beta.json index 1a07162fd51a..7f763b050ce5 100644 --- a/packages/google-cloud-memorystore/samples/generated/v1beta/snippet_metadata_google.cloud.memorystore.v1beta.json +++ b/packages/google-cloud-memorystore/samples/generated/v1beta/snippet_metadata_google.cloud.memorystore.v1beta.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-memorystore", - "version": "0.5.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-memorystore/src/index.ts b/packages/google-cloud-memorystore/src/index.ts index 20b9ceed07a5..b09116799853 100644 --- a/packages/google-cloud-memorystore/src/index.ts +++ b/packages/google-cloud-memorystore/src/index.ts @@ -1,4 +1,4 @@ -// Copyright 2025 Google LLC +// Copyright 2026 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-memorystore/src/v1/index.ts b/packages/google-cloud-memorystore/src/v1/index.ts index fceb6f519bce..5bafc3441d86 100644 --- a/packages/google-cloud-memorystore/src/v1/index.ts +++ b/packages/google-cloud-memorystore/src/v1/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {MemorystoreClient} from './memorystore_client'; +export { MemorystoreClient } from './memorystore_client'; diff --git a/packages/google-cloud-memorystore/src/v1/memorystore_client.ts b/packages/google-cloud-memorystore/src/v1/memorystore_client.ts index 9b61ccff7c3a..024a2f6e49fd 100644 --- a/packages/google-cloud-memorystore/src/v1/memorystore_client.ts +++ b/packages/google-cloud-memorystore/src/v1/memorystore_client.ts @@ -18,11 +18,22 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -44,7 +55,7 @@ export class MemorystoreClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('memorystore'); @@ -57,11 +68,11 @@ export class MemorystoreClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - memorystoreStub?: Promise<{[name: string]: Function}>; + memorystoreStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of MemorystoreClient. @@ -102,21 +113,42 @@ export class MemorystoreClient { * const client = new MemorystoreClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof MemorystoreClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'memorystore.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -141,7 +173,7 @@ export class MemorystoreClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -155,15 +187,11 @@ export class MemorystoreClient { } this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -185,56 +213,66 @@ export class MemorystoreClient { // Create useful helper objects for these. this.pathTemplates = { backupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/backupCollections/{backup_collection}/backups/{backup}' + 'projects/{project}/locations/{location}/backupCollections/{backup_collection}/backups/{backup}', ), backupCollectionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/backupCollections/{backup_collection}' + 'projects/{project}/locations/{location}/backupCollections/{backup_collection}', ), caPoolPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/caPools/{ca_pool}' + 'projects/{project}/locations/{location}/caPools/{ca_pool}', ), certificateAuthorityPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/instances/{instance}/certificateAuthority' + 'projects/{project}/locations/{location}/instances/{instance}/certificateAuthority', ), cryptoKeyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}' + 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}', ), cryptoKeyVersionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}' + 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}', ), forwardingRulePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/regions/{region}/forwardingRules/{forwarding_rule}' + 'projects/{project}/regions/{region}/forwardingRules/{forwarding_rule}', ), instancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/instances/{instance}' + 'projects/{project}/locations/{location}/instances/{instance}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), networkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/global/networks/{network}' + 'projects/{project}/global/networks/{network}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), serviceAttachmentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/regions/{region}/serviceAttachments/{service_attachment}' - ), - sharedRegionalCertificateAuthorityPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/sharedRegionalCertificateAuthority' + 'projects/{project}/regions/{region}/serviceAttachments/{service_attachment}', ), + sharedRegionalCertificateAuthorityPathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/sharedRegionalCertificateAuthority', + ), }; // Some of the methods on this service return "paged" results, // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listInstances: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'instances'), - listBackupCollections: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'backupCollections'), - listBackups: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'backups') + listInstances: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'instances', + ), + listBackupCollections: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'backupCollections', + ), + listBackups: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'backups', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -243,77 +281,132 @@ export class MemorystoreClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1/{name=projects/*}/locations', + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1/{name=projects/*/locations/*/operations/*}:cancel', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.memorystore.v1.Instance') as gax.protobuf.Type; + '.google.cloud.memorystore.v1.Instance', + ) as gax.protobuf.Type; const createInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.memorystore.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.memorystore.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.memorystore.v1.Instance') as gax.protobuf.Type; + '.google.cloud.memorystore.v1.Instance', + ) as gax.protobuf.Type; const updateInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.memorystore.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.memorystore.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteInstanceResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.memorystore.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.memorystore.v1.OperationMetadata', + ) as gax.protobuf.Type; const rescheduleMaintenanceResponse = protoFilesRoot.lookup( - '.google.cloud.memorystore.v1.Instance') as gax.protobuf.Type; + '.google.cloud.memorystore.v1.Instance', + ) as gax.protobuf.Type; const rescheduleMaintenanceMetadata = protoFilesRoot.lookup( - '.google.cloud.memorystore.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.memorystore.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteBackupResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteBackupMetadata = protoFilesRoot.lookup( - '.google.cloud.memorystore.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.memorystore.v1.OperationMetadata', + ) as gax.protobuf.Type; const exportBackupResponse = protoFilesRoot.lookup( - '.google.cloud.memorystore.v1.Backup') as gax.protobuf.Type; + '.google.cloud.memorystore.v1.Backup', + ) as gax.protobuf.Type; const exportBackupMetadata = protoFilesRoot.lookup( - '.google.cloud.memorystore.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.memorystore.v1.OperationMetadata', + ) as gax.protobuf.Type; const backupInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.memorystore.v1.Instance') as gax.protobuf.Type; + '.google.cloud.memorystore.v1.Instance', + ) as gax.protobuf.Type; const backupInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.memorystore.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.memorystore.v1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createInstanceResponse.decode.bind(createInstanceResponse), - createInstanceMetadata.decode.bind(createInstanceMetadata)), + createInstanceMetadata.decode.bind(createInstanceMetadata), + ), updateInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateInstanceResponse.decode.bind(updateInstanceResponse), - updateInstanceMetadata.decode.bind(updateInstanceMetadata)), + updateInstanceMetadata.decode.bind(updateInstanceMetadata), + ), deleteInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteInstanceResponse.decode.bind(deleteInstanceResponse), - deleteInstanceMetadata.decode.bind(deleteInstanceMetadata)), + deleteInstanceMetadata.decode.bind(deleteInstanceMetadata), + ), rescheduleMaintenance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - rescheduleMaintenanceResponse.decode.bind(rescheduleMaintenanceResponse), - rescheduleMaintenanceMetadata.decode.bind(rescheduleMaintenanceMetadata)), + rescheduleMaintenanceResponse.decode.bind( + rescheduleMaintenanceResponse, + ), + rescheduleMaintenanceMetadata.decode.bind( + rescheduleMaintenanceMetadata, + ), + ), deleteBackup: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteBackupResponse.decode.bind(deleteBackupResponse), - deleteBackupMetadata.decode.bind(deleteBackupMetadata)), + deleteBackupMetadata.decode.bind(deleteBackupMetadata), + ), exportBackup: new this._gaxModule.LongrunningDescriptor( this.operationsClient, exportBackupResponse.decode.bind(exportBackupResponse), - exportBackupMetadata.decode.bind(exportBackupMetadata)), + exportBackupMetadata.decode.bind(exportBackupMetadata), + ), backupInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, backupInstanceResponse.decode.bind(backupInstanceResponse), - backupInstanceMetadata.decode.bind(backupInstanceMetadata)) + backupInstanceMetadata.decode.bind(backupInstanceMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.memorystore.v1.Memorystore', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.memorystore.v1.Memorystore', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -344,28 +437,49 @@ export class MemorystoreClient { // Put together the "service stub" for // google.cloud.memorystore.v1.Memorystore. this.memorystoreStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.memorystore.v1.Memorystore') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.memorystore.v1.Memorystore', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.memorystore.v1.Memorystore, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const memorystoreStubMethods = - ['listInstances', 'getInstance', 'createInstance', 'updateInstance', 'deleteInstance', 'getCertificateAuthority', 'getSharedRegionalCertificateAuthority', 'rescheduleMaintenance', 'listBackupCollections', 'getBackupCollection', 'listBackups', 'getBackup', 'deleteBackup', 'exportBackup', 'backupInstance']; + const memorystoreStubMethods = [ + 'listInstances', + 'getInstance', + 'createInstance', + 'updateInstance', + 'deleteInstance', + 'getCertificateAuthority', + 'getSharedRegionalCertificateAuthority', + 'rescheduleMaintenance', + 'listBackupCollections', + 'getBackupCollection', + 'listBackups', + 'getBackup', + 'deleteBackup', + 'exportBackup', + 'backupInstance', + ]; for (const methodName of memorystoreStubMethods) { const callPromise = this.memorystoreStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -375,7 +489,7 @@ export class MemorystoreClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -390,8 +504,14 @@ export class MemorystoreClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'memorystore.googleapis.com'; } @@ -402,8 +522,14 @@ export class MemorystoreClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'memorystore.googleapis.com'; } @@ -434,9 +560,7 @@ export class MemorystoreClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -445,8 +569,9 @@ export class MemorystoreClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -457,1415 +582,2095 @@ export class MemorystoreClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets details of a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the instance to retrieve. - * Format: projects/{project}/locations/{location}/instances/{instance} - * @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 {@link protos.google.cloud.memorystore.v1.Instance|Instance}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/memorystore.get_instance.js - * region_tag:memorystore_v1_generated_Memorystore_GetInstance_async - */ + /** + * Gets details of a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the instance to retrieve. + * Format: projects/{project}/locations/{location}/instances/{instance} + * @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 {@link protos.google.cloud.memorystore.v1.Instance|Instance}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/memorystore.get_instance.js + * region_tag:memorystore_v1_generated_Memorystore_GetInstance_async + */ getInstance( - request?: protos.google.cloud.memorystore.v1.IGetInstanceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.memorystore.v1.IInstance, - protos.google.cloud.memorystore.v1.IGetInstanceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memorystore.v1.IGetInstanceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IGetInstanceRequest | undefined, + {} | undefined, + ] + >; getInstance( - request: protos.google.cloud.memorystore.v1.IGetInstanceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.memorystore.v1.IInstance, - protos.google.cloud.memorystore.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1.IGetInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IGetInstanceRequest | null | undefined, + {} | null | undefined + >, + ): void; getInstance( - request: protos.google.cloud.memorystore.v1.IGetInstanceRequest, - callback: Callback< - protos.google.cloud.memorystore.v1.IInstance, - protos.google.cloud.memorystore.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1.IGetInstanceRequest, + callback: Callback< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IGetInstanceRequest | null | undefined, + {} | null | undefined + >, + ): void; getInstance( - request?: protos.google.cloud.memorystore.v1.IGetInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.memorystore.v1.IInstance, - protos.google.cloud.memorystore.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.memorystore.v1.IGetInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.memorystore.v1.IInstance, - protos.google.cloud.memorystore.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.memorystore.v1.IInstance, - protos.google.cloud.memorystore.v1.IGetInstanceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.memorystore.v1.IGetInstanceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IGetInstanceRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IGetInstanceRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getInstance request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.memorystore.v1.IInstance, - protos.google.cloud.memorystore.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.memorystore.v1.IInstance, + | protos.google.cloud.memorystore.v1.IGetInstanceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getInstance response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getInstance(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.memorystore.v1.IInstance, - protos.google.cloud.memorystore.v1.IGetInstanceRequest|undefined, - {}|undefined - ]) => { - this._log.info('getInstance response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getInstance(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IGetInstanceRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getInstance response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details about the certificate authority for an Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the certificate authority. - * Format: - * projects/{project}/locations/{location}/instances/{instance}/certificateAuthority - * @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 {@link protos.google.cloud.memorystore.v1.CertificateAuthority|CertificateAuthority}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/memorystore.get_certificate_authority.js - * region_tag:memorystore_v1_generated_Memorystore_GetCertificateAuthority_async - */ + /** + * Gets details about the certificate authority for an Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the certificate authority. + * Format: + * projects/{project}/locations/{location}/instances/{instance}/certificateAuthority + * @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 {@link protos.google.cloud.memorystore.v1.CertificateAuthority|CertificateAuthority}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/memorystore.get_certificate_authority.js + * region_tag:memorystore_v1_generated_Memorystore_GetCertificateAuthority_async + */ getCertificateAuthority( - request?: protos.google.cloud.memorystore.v1.IGetCertificateAuthorityRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.memorystore.v1.ICertificateAuthority, - protos.google.cloud.memorystore.v1.IGetCertificateAuthorityRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memorystore.v1.IGetCertificateAuthorityRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.memorystore.v1.ICertificateAuthority, + ( + | protos.google.cloud.memorystore.v1.IGetCertificateAuthorityRequest + | undefined + ), + {} | undefined, + ] + >; getCertificateAuthority( - request: protos.google.cloud.memorystore.v1.IGetCertificateAuthorityRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.memorystore.v1.ICertificateAuthority, - protos.google.cloud.memorystore.v1.IGetCertificateAuthorityRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1.IGetCertificateAuthorityRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.memorystore.v1.ICertificateAuthority, + | protos.google.cloud.memorystore.v1.IGetCertificateAuthorityRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getCertificateAuthority( - request: protos.google.cloud.memorystore.v1.IGetCertificateAuthorityRequest, - callback: Callback< - protos.google.cloud.memorystore.v1.ICertificateAuthority, - protos.google.cloud.memorystore.v1.IGetCertificateAuthorityRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1.IGetCertificateAuthorityRequest, + callback: Callback< + protos.google.cloud.memorystore.v1.ICertificateAuthority, + | protos.google.cloud.memorystore.v1.IGetCertificateAuthorityRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getCertificateAuthority( - request?: protos.google.cloud.memorystore.v1.IGetCertificateAuthorityRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.memorystore.v1.ICertificateAuthority, - protos.google.cloud.memorystore.v1.IGetCertificateAuthorityRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.memorystore.v1.IGetCertificateAuthorityRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.memorystore.v1.ICertificateAuthority, - protos.google.cloud.memorystore.v1.IGetCertificateAuthorityRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.memorystore.v1.ICertificateAuthority, - protos.google.cloud.memorystore.v1.IGetCertificateAuthorityRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.memorystore.v1.IGetCertificateAuthorityRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.memorystore.v1.ICertificateAuthority, + | protos.google.cloud.memorystore.v1.IGetCertificateAuthorityRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.memorystore.v1.ICertificateAuthority, + ( + | protos.google.cloud.memorystore.v1.IGetCertificateAuthorityRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getCertificateAuthority request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.memorystore.v1.ICertificateAuthority, - protos.google.cloud.memorystore.v1.IGetCertificateAuthorityRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.memorystore.v1.ICertificateAuthority, + | protos.google.cloud.memorystore.v1.IGetCertificateAuthorityRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getCertificateAuthority response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getCertificateAuthority(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.memorystore.v1.ICertificateAuthority, - protos.google.cloud.memorystore.v1.IGetCertificateAuthorityRequest|undefined, - {}|undefined - ]) => { - this._log.info('getCertificateAuthority response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getCertificateAuthority(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.memorystore.v1.ICertificateAuthority, + ( + | protos.google.cloud.memorystore.v1.IGetCertificateAuthorityRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getCertificateAuthority response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets the details of shared regional certificate authority information for - * Memorystore instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Regional certificate authority resource name using the form: - * `projects/{project}/locations/{location}/sharedRegionalCertificateAuthority` - * where `location_id` refers to a Google Cloud region. - * @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 {@link protos.google.cloud.memorystore.v1.SharedRegionalCertificateAuthority|SharedRegionalCertificateAuthority}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/memorystore.get_shared_regional_certificate_authority.js - * region_tag:memorystore_v1_generated_Memorystore_GetSharedRegionalCertificateAuthority_async - */ + /** + * Gets the details of shared regional certificate authority information for + * Memorystore instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Regional certificate authority resource name using the form: + * `projects/{project}/locations/{location}/sharedRegionalCertificateAuthority` + * where `location_id` refers to a Google Cloud region. + * @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 {@link protos.google.cloud.memorystore.v1.SharedRegionalCertificateAuthority|SharedRegionalCertificateAuthority}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/memorystore.get_shared_regional_certificate_authority.js + * region_tag:memorystore_v1_generated_Memorystore_GetSharedRegionalCertificateAuthority_async + */ getSharedRegionalCertificateAuthority( - request?: protos.google.cloud.memorystore.v1.IGetSharedRegionalCertificateAuthorityRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.memorystore.v1.ISharedRegionalCertificateAuthority, - protos.google.cloud.memorystore.v1.IGetSharedRegionalCertificateAuthorityRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memorystore.v1.IGetSharedRegionalCertificateAuthorityRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.memorystore.v1.ISharedRegionalCertificateAuthority, + ( + | protos.google.cloud.memorystore.v1.IGetSharedRegionalCertificateAuthorityRequest + | undefined + ), + {} | undefined, + ] + >; getSharedRegionalCertificateAuthority( - request: protos.google.cloud.memorystore.v1.IGetSharedRegionalCertificateAuthorityRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.memorystore.v1.ISharedRegionalCertificateAuthority, - protos.google.cloud.memorystore.v1.IGetSharedRegionalCertificateAuthorityRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1.IGetSharedRegionalCertificateAuthorityRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.memorystore.v1.ISharedRegionalCertificateAuthority, + | protos.google.cloud.memorystore.v1.IGetSharedRegionalCertificateAuthorityRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getSharedRegionalCertificateAuthority( - request: protos.google.cloud.memorystore.v1.IGetSharedRegionalCertificateAuthorityRequest, - callback: Callback< - protos.google.cloud.memorystore.v1.ISharedRegionalCertificateAuthority, - protos.google.cloud.memorystore.v1.IGetSharedRegionalCertificateAuthorityRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1.IGetSharedRegionalCertificateAuthorityRequest, + callback: Callback< + protos.google.cloud.memorystore.v1.ISharedRegionalCertificateAuthority, + | protos.google.cloud.memorystore.v1.IGetSharedRegionalCertificateAuthorityRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getSharedRegionalCertificateAuthority( - request?: protos.google.cloud.memorystore.v1.IGetSharedRegionalCertificateAuthorityRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.memorystore.v1.ISharedRegionalCertificateAuthority, - protos.google.cloud.memorystore.v1.IGetSharedRegionalCertificateAuthorityRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.memorystore.v1.IGetSharedRegionalCertificateAuthorityRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.memorystore.v1.ISharedRegionalCertificateAuthority, - protos.google.cloud.memorystore.v1.IGetSharedRegionalCertificateAuthorityRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.memorystore.v1.ISharedRegionalCertificateAuthority, - protos.google.cloud.memorystore.v1.IGetSharedRegionalCertificateAuthorityRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.memorystore.v1.IGetSharedRegionalCertificateAuthorityRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.memorystore.v1.ISharedRegionalCertificateAuthority, + | protos.google.cloud.memorystore.v1.IGetSharedRegionalCertificateAuthorityRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.memorystore.v1.ISharedRegionalCertificateAuthority, + ( + | protos.google.cloud.memorystore.v1.IGetSharedRegionalCertificateAuthorityRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getSharedRegionalCertificateAuthority request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.memorystore.v1.ISharedRegionalCertificateAuthority, - protos.google.cloud.memorystore.v1.IGetSharedRegionalCertificateAuthorityRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.memorystore.v1.ISharedRegionalCertificateAuthority, + | protos.google.cloud.memorystore.v1.IGetSharedRegionalCertificateAuthorityRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { - this._log.info('getSharedRegionalCertificateAuthority response %j', response); + this._log.info( + 'getSharedRegionalCertificateAuthority response %j', + response, + ); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getSharedRegionalCertificateAuthority(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.memorystore.v1.ISharedRegionalCertificateAuthority, - protos.google.cloud.memorystore.v1.IGetSharedRegionalCertificateAuthorityRequest|undefined, - {}|undefined - ]) => { - this._log.info('getSharedRegionalCertificateAuthority response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getSharedRegionalCertificateAuthority(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.memorystore.v1.ISharedRegionalCertificateAuthority, + ( + | protos.google.cloud.memorystore.v1.IGetSharedRegionalCertificateAuthorityRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info( + 'getSharedRegionalCertificateAuthority response %j', + response, + ); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Get a backup collection. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Instance backupCollection resource name using the form: - * `projects/{project_id}/locations/{location_id}/backupCollections/{backup_collection_id}` - * where `location_id` refers to a Google Cloud region. - * @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 {@link protos.google.cloud.memorystore.v1.BackupCollection|BackupCollection}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/memorystore.get_backup_collection.js - * region_tag:memorystore_v1_generated_Memorystore_GetBackupCollection_async - */ + /** + * Get a backup collection. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Instance backupCollection resource name using the form: + * `projects/{project_id}/locations/{location_id}/backupCollections/{backup_collection_id}` + * where `location_id` refers to a Google Cloud region. + * @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 {@link protos.google.cloud.memorystore.v1.BackupCollection|BackupCollection}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/memorystore.get_backup_collection.js + * region_tag:memorystore_v1_generated_Memorystore_GetBackupCollection_async + */ getBackupCollection( - request?: protos.google.cloud.memorystore.v1.IGetBackupCollectionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.memorystore.v1.IBackupCollection, - protos.google.cloud.memorystore.v1.IGetBackupCollectionRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memorystore.v1.IGetBackupCollectionRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.memorystore.v1.IBackupCollection, + ( + | protos.google.cloud.memorystore.v1.IGetBackupCollectionRequest + | undefined + ), + {} | undefined, + ] + >; getBackupCollection( - request: protos.google.cloud.memorystore.v1.IGetBackupCollectionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.memorystore.v1.IBackupCollection, - protos.google.cloud.memorystore.v1.IGetBackupCollectionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1.IGetBackupCollectionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.memorystore.v1.IBackupCollection, + | protos.google.cloud.memorystore.v1.IGetBackupCollectionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getBackupCollection( - request: protos.google.cloud.memorystore.v1.IGetBackupCollectionRequest, - callback: Callback< - protos.google.cloud.memorystore.v1.IBackupCollection, - protos.google.cloud.memorystore.v1.IGetBackupCollectionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1.IGetBackupCollectionRequest, + callback: Callback< + protos.google.cloud.memorystore.v1.IBackupCollection, + | protos.google.cloud.memorystore.v1.IGetBackupCollectionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getBackupCollection( - request?: protos.google.cloud.memorystore.v1.IGetBackupCollectionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.memorystore.v1.IBackupCollection, - protos.google.cloud.memorystore.v1.IGetBackupCollectionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.memorystore.v1.IGetBackupCollectionRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.memorystore.v1.IBackupCollection, - protos.google.cloud.memorystore.v1.IGetBackupCollectionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.memorystore.v1.IBackupCollection, - protos.google.cloud.memorystore.v1.IGetBackupCollectionRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.memorystore.v1.IGetBackupCollectionRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.memorystore.v1.IBackupCollection, + | protos.google.cloud.memorystore.v1.IGetBackupCollectionRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.memorystore.v1.IBackupCollection, + ( + | protos.google.cloud.memorystore.v1.IGetBackupCollectionRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getBackupCollection request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.memorystore.v1.IBackupCollection, - protos.google.cloud.memorystore.v1.IGetBackupCollectionRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.memorystore.v1.IBackupCollection, + | protos.google.cloud.memorystore.v1.IGetBackupCollectionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getBackupCollection response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getBackupCollection(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.memorystore.v1.IBackupCollection, - protos.google.cloud.memorystore.v1.IGetBackupCollectionRequest|undefined, - {}|undefined - ]) => { - this._log.info('getBackupCollection response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getBackupCollection(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.memorystore.v1.IBackupCollection, + ( + | protos.google.cloud.memorystore.v1.IGetBackupCollectionRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getBackupCollection response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets the details of a specific backup. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Instance backup resource name using the form: - * `projects/{project_id}/locations/{location_id}/backupCollections/{backup_collection_id}/backups/{backup_id}` - * @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 {@link protos.google.cloud.memorystore.v1.Backup|Backup}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/memorystore.get_backup.js - * region_tag:memorystore_v1_generated_Memorystore_GetBackup_async - */ + /** + * Gets the details of a specific backup. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Instance backup resource name using the form: + * `projects/{project_id}/locations/{location_id}/backupCollections/{backup_collection_id}/backups/{backup_id}` + * @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 {@link protos.google.cloud.memorystore.v1.Backup|Backup}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/memorystore.get_backup.js + * region_tag:memorystore_v1_generated_Memorystore_GetBackup_async + */ getBackup( - request?: protos.google.cloud.memorystore.v1.IGetBackupRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.memorystore.v1.IBackup, - protos.google.cloud.memorystore.v1.IGetBackupRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memorystore.v1.IGetBackupRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.memorystore.v1.IBackup, + protos.google.cloud.memorystore.v1.IGetBackupRequest | undefined, + {} | undefined, + ] + >; getBackup( - request: protos.google.cloud.memorystore.v1.IGetBackupRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.memorystore.v1.IBackup, - protos.google.cloud.memorystore.v1.IGetBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1.IGetBackupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.memorystore.v1.IBackup, + protos.google.cloud.memorystore.v1.IGetBackupRequest | null | undefined, + {} | null | undefined + >, + ): void; getBackup( - request: protos.google.cloud.memorystore.v1.IGetBackupRequest, - callback: Callback< - protos.google.cloud.memorystore.v1.IBackup, - protos.google.cloud.memorystore.v1.IGetBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1.IGetBackupRequest, + callback: Callback< + protos.google.cloud.memorystore.v1.IBackup, + protos.google.cloud.memorystore.v1.IGetBackupRequest | null | undefined, + {} | null | undefined + >, + ): void; getBackup( - request?: protos.google.cloud.memorystore.v1.IGetBackupRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.memorystore.v1.IBackup, - protos.google.cloud.memorystore.v1.IGetBackupRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.memorystore.v1.IGetBackupRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.memorystore.v1.IBackup, - protos.google.cloud.memorystore.v1.IGetBackupRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.memorystore.v1.IBackup, - protos.google.cloud.memorystore.v1.IGetBackupRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.memorystore.v1.IGetBackupRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.memorystore.v1.IBackup, + protos.google.cloud.memorystore.v1.IGetBackupRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.memorystore.v1.IBackup, + protos.google.cloud.memorystore.v1.IGetBackupRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getBackup request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.memorystore.v1.IBackup, - protos.google.cloud.memorystore.v1.IGetBackupRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.memorystore.v1.IBackup, + | protos.google.cloud.memorystore.v1.IGetBackupRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getBackup response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getBackup(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.memorystore.v1.IBackup, - protos.google.cloud.memorystore.v1.IGetBackupRequest|undefined, - {}|undefined - ]) => { - this._log.info('getBackup response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getBackup(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.memorystore.v1.IBackup, + protos.google.cloud.memorystore.v1.IGetBackupRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getBackup response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a new Instance in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource where this instance will be created. - * Format: projects/{project}/locations/{location} - * @param {string} request.instanceId - * Required. The ID to use for the instance, which will become the final - * component of the instance's resource name. - * - * This value is subject to the following restrictions: - * - * * Must be 4-63 characters in length - * * Must begin with a letter or digit - * * Must contain only lowercase letters, digits, and hyphens - * * Must not end with a hyphen - * * Must be unique within a location - * @param {google.cloud.memorystore.v1.Instance} request.instance - * Required. The instance to create. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/memorystore.create_instance.js - * region_tag:memorystore_v1_generated_Memorystore_CreateInstance_async - */ - createInstance( - request?: protos.google.cloud.memorystore.v1.ICreateInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createInstance( - request: protos.google.cloud.memorystore.v1.ICreateInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createInstance( - request: protos.google.cloud.memorystore.v1.ICreateInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createInstance( - request?: protos.google.cloud.memorystore.v1.ICreateInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + /** + * Creates a new Instance in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource where this instance will be created. + * Format: projects/{project}/locations/{location} + * @param {string} request.instanceId + * Required. The ID to use for the instance, which will become the final + * component of the instance's resource name. + * + * This value is subject to the following restrictions: + * + * * Must be 4-63 characters in length + * * Must begin with a letter or digit + * * Must contain only lowercase letters, digits, and hyphens + * * Must not end with a hyphen + * * Must be unique within a location + * @param {google.cloud.memorystore.v1.Instance} request.instance + * Required. The instance to create. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/memorystore.create_instance.js + * region_tag:memorystore_v1_generated_Memorystore_CreateInstance_async + */ + createInstance( + request?: protos.google.cloud.memorystore.v1.ICreateInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; + createInstance( + request: protos.google.cloud.memorystore.v1.ICreateInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; + createInstance( + request: protos.google.cloud.memorystore.v1.ICreateInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; + createInstance( + request?: protos.google.cloud.memorystore.v1.ICreateInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createInstance request %j', request); - return this.innerApiCalls.createInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createInstance()`. - * @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/memorystore.create_instance.js - * region_tag:memorystore_v1_generated_Memorystore_CreateInstance_async - */ - async checkCreateInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createInstance()`. + * @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/memorystore.create_instance.js + * region_tag:memorystore_v1_generated_Memorystore_CreateInstance_async + */ + async checkCreateInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.memorystore.v1.Instance, + protos.google.cloud.memorystore.v1.OperationMetadata + > + > { this._log.info('createInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.memorystore.v1.Instance, + protos.google.cloud.memorystore.v1.OperationMetadata + >; } -/** - * Updates the parameters of a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. The list of fields to be updated on the instance. At least one - * field must be specified. - * @param {google.cloud.memorystore.v1.Instance} request.instance - * Required. The instance to update. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/memorystore.update_instance.js - * region_tag:memorystore_v1_generated_Memorystore_UpdateInstance_async - */ + /** + * Updates the parameters of a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. The list of fields to be updated on the instance. At least one + * field must be specified. + * @param {google.cloud.memorystore.v1.Instance} request.instance + * Required. The instance to update. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/memorystore.update_instance.js + * region_tag:memorystore_v1_generated_Memorystore_UpdateInstance_async + */ updateInstance( - request?: protos.google.cloud.memorystore.v1.IUpdateInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memorystore.v1.IUpdateInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateInstance( - request: protos.google.cloud.memorystore.v1.IUpdateInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1.IUpdateInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateInstance( - request: protos.google.cloud.memorystore.v1.IUpdateInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1.IUpdateInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateInstance( - request?: protos.google.cloud.memorystore.v1.IUpdateInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.memorystore.v1.IUpdateInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'instance.name': request.instance!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'instance.name': request.instance!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateInstance request %j', request); - return this.innerApiCalls.updateInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateInstance()`. - * @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/memorystore.update_instance.js - * region_tag:memorystore_v1_generated_Memorystore_UpdateInstance_async - */ - async checkUpdateInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateInstance()`. + * @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/memorystore.update_instance.js + * region_tag:memorystore_v1_generated_Memorystore_UpdateInstance_async + */ + async checkUpdateInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.memorystore.v1.Instance, + protos.google.cloud.memorystore.v1.OperationMetadata + > + > { this._log.info('updateInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.memorystore.v1.Instance, + protos.google.cloud.memorystore.v1.OperationMetadata + >; } -/** - * Deletes a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the instance to delete. - * Format: projects/{project}/locations/{location}/instances/{instance} - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/memorystore.delete_instance.js - * region_tag:memorystore_v1_generated_Memorystore_DeleteInstance_async - */ + /** + * Deletes a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the instance to delete. + * Format: projects/{project}/locations/{location}/instances/{instance} + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/memorystore.delete_instance.js + * region_tag:memorystore_v1_generated_Memorystore_DeleteInstance_async + */ deleteInstance( - request?: protos.google.cloud.memorystore.v1.IDeleteInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memorystore.v1.IDeleteInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteInstance( - request: protos.google.cloud.memorystore.v1.IDeleteInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1.IDeleteInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteInstance( - request: protos.google.cloud.memorystore.v1.IDeleteInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1.IDeleteInstanceRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteInstance( - request?: protos.google.cloud.memorystore.v1.IDeleteInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.memorystore.v1.IDeleteInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteInstance request %j', request); - return this.innerApiCalls.deleteInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteInstance()`. - * @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/memorystore.delete_instance.js - * region_tag:memorystore_v1_generated_Memorystore_DeleteInstance_async - */ - async checkDeleteInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteInstance()`. + * @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/memorystore.delete_instance.js + * region_tag:memorystore_v1_generated_Memorystore_DeleteInstance_async + */ + async checkDeleteInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.memorystore.v1.OperationMetadata + > + > { this._log.info('deleteInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.memorystore.v1.OperationMetadata + >; } -/** - * Reschedules upcoming maintenance event. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the instance to reschedule maintenance for: - * `projects/{project}/locations/{location_id}/instances/{instance}` - * @param {google.cloud.memorystore.v1.RescheduleMaintenanceRequest.RescheduleType} request.rescheduleType - * Required. If reschedule type is SPECIFIC_TIME, schedule_time must be set. - * @param {google.protobuf.Timestamp} [request.scheduleTime] - * Optional. Timestamp when the maintenance shall be rescheduled to if - * reschedule_type=SPECIFIC_TIME, in RFC 3339 format. - * Example: `2012-11-15T16:19:00.094Z`. - * @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/memorystore.reschedule_maintenance.js - * region_tag:memorystore_v1_generated_Memorystore_RescheduleMaintenance_async - */ + /** + * Reschedules upcoming maintenance event. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the instance to reschedule maintenance for: + * `projects/{project}/locations/{location_id}/instances/{instance}` + * @param {google.cloud.memorystore.v1.RescheduleMaintenanceRequest.RescheduleType} request.rescheduleType + * Required. If reschedule type is SPECIFIC_TIME, schedule_time must be set. + * @param {google.protobuf.Timestamp} [request.scheduleTime] + * Optional. Timestamp when the maintenance shall be rescheduled to if + * reschedule_type=SPECIFIC_TIME, in RFC 3339 format. + * Example: `2012-11-15T16:19:00.094Z`. + * @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/memorystore.reschedule_maintenance.js + * region_tag:memorystore_v1_generated_Memorystore_RescheduleMaintenance_async + */ rescheduleMaintenance( - request?: protos.google.cloud.memorystore.v1.IRescheduleMaintenanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memorystore.v1.IRescheduleMaintenanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; rescheduleMaintenance( - request: protos.google.cloud.memorystore.v1.IRescheduleMaintenanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1.IRescheduleMaintenanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; rescheduleMaintenance( - request: protos.google.cloud.memorystore.v1.IRescheduleMaintenanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1.IRescheduleMaintenanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; rescheduleMaintenance( - request?: protos.google.cloud.memorystore.v1.IRescheduleMaintenanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.memorystore.v1.IRescheduleMaintenanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('rescheduleMaintenance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('rescheduleMaintenance request %j', request); - return this.innerApiCalls.rescheduleMaintenance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('rescheduleMaintenance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .rescheduleMaintenance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('rescheduleMaintenance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `rescheduleMaintenance()`. - * @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/memorystore.reschedule_maintenance.js - * region_tag:memorystore_v1_generated_Memorystore_RescheduleMaintenance_async - */ - async checkRescheduleMaintenanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `rescheduleMaintenance()`. + * @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/memorystore.reschedule_maintenance.js + * region_tag:memorystore_v1_generated_Memorystore_RescheduleMaintenance_async + */ + async checkRescheduleMaintenanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.memorystore.v1.Instance, + protos.google.cloud.memorystore.v1.OperationMetadata + > + > { this._log.info('rescheduleMaintenance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.rescheduleMaintenance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.rescheduleMaintenance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.memorystore.v1.Instance, + protos.google.cloud.memorystore.v1.OperationMetadata + >; } -/** - * Deletes a specific backup. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Instance backup resource name using the form: - * `projects/{project_id}/locations/{location_id}/backupCollections/{backup_collection_id}/backups/{backup_id}` - * @param {string} [request.requestId] - * Optional. Idempotent request UUID. - * @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/memorystore.delete_backup.js - * region_tag:memorystore_v1_generated_Memorystore_DeleteBackup_async - */ + /** + * Deletes a specific backup. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Instance backup resource name using the form: + * `projects/{project_id}/locations/{location_id}/backupCollections/{backup_collection_id}/backups/{backup_id}` + * @param {string} [request.requestId] + * Optional. Idempotent request UUID. + * @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/memorystore.delete_backup.js + * region_tag:memorystore_v1_generated_Memorystore_DeleteBackup_async + */ deleteBackup( - request?: protos.google.cloud.memorystore.v1.IDeleteBackupRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memorystore.v1.IDeleteBackupRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteBackup( - request: protos.google.cloud.memorystore.v1.IDeleteBackupRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1.IDeleteBackupRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteBackup( - request: protos.google.cloud.memorystore.v1.IDeleteBackupRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1.IDeleteBackupRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteBackup( - request?: protos.google.cloud.memorystore.v1.IDeleteBackupRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.memorystore.v1.IDeleteBackupRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteBackup response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteBackup request %j', request); - return this.innerApiCalls.deleteBackup(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteBackup response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteBackup(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteBackup response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteBackup()`. - * @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/memorystore.delete_backup.js - * region_tag:memorystore_v1_generated_Memorystore_DeleteBackup_async - */ - async checkDeleteBackupProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteBackup()`. + * @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/memorystore.delete_backup.js + * region_tag:memorystore_v1_generated_Memorystore_DeleteBackup_async + */ + async checkDeleteBackupProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.memorystore.v1.OperationMetadata + > + > { this._log.info('deleteBackup long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteBackup, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteBackup, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.memorystore.v1.OperationMetadata + >; } -/** - * Exports a specific backup to a customer target Cloud Storage URI. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.gcsBucket - * Google Cloud Storage bucket, like "my-bucket". - * @param {string} request.name - * Required. Instance backup resource name using the form: - * `projects/{project_id}/locations/{location_id}/backupCollections/{backup_collection_id}/backups/{backup_id}` - * @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/memorystore.export_backup.js - * region_tag:memorystore_v1_generated_Memorystore_ExportBackup_async - */ + /** + * Exports a specific backup to a customer target Cloud Storage URI. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.gcsBucket + * Google Cloud Storage bucket, like "my-bucket". + * @param {string} request.name + * Required. Instance backup resource name using the form: + * `projects/{project_id}/locations/{location_id}/backupCollections/{backup_collection_id}/backups/{backup_id}` + * @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/memorystore.export_backup.js + * region_tag:memorystore_v1_generated_Memorystore_ExportBackup_async + */ exportBackup( - request?: protos.google.cloud.memorystore.v1.IExportBackupRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memorystore.v1.IExportBackupRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.memorystore.v1.IBackup, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; exportBackup( - request: protos.google.cloud.memorystore.v1.IExportBackupRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1.IExportBackupRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.memorystore.v1.IBackup, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; exportBackup( - request: protos.google.cloud.memorystore.v1.IExportBackupRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1.IExportBackupRequest, + callback: Callback< + LROperation< + protos.google.cloud.memorystore.v1.IBackup, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; exportBackup( - request?: protos.google.cloud.memorystore.v1.IExportBackupRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.memorystore.v1.IExportBackupRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.memorystore.v1.IBackup, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.memorystore.v1.IBackup, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.memorystore.v1.IBackup, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.memorystore.v1.IBackup, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('exportBackup response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('exportBackup request %j', request); - return this.innerApiCalls.exportBackup(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('exportBackup response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .exportBackup(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.memorystore.v1.IBackup, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('exportBackup response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `exportBackup()`. - * @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/memorystore.export_backup.js - * region_tag:memorystore_v1_generated_Memorystore_ExportBackup_async - */ - async checkExportBackupProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `exportBackup()`. + * @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/memorystore.export_backup.js + * region_tag:memorystore_v1_generated_Memorystore_ExportBackup_async + */ + async checkExportBackupProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.memorystore.v1.Backup, + protos.google.cloud.memorystore.v1.OperationMetadata + > + > { this._log.info('exportBackup long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.exportBackup, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.exportBackup, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.memorystore.v1.Backup, + protos.google.cloud.memorystore.v1.OperationMetadata + >; } -/** - * Backup Instance. - * If this is the first time a backup is being created, a backup collection - * will be created at the backend, and this backup belongs to this collection. - * Both collection and backup will have a resource name. Backup will be - * executed for each shard. A replica (primary if nonHA) will be selected to - * perform the execution. Backup call will be rejected if there is an ongoing - * backup or update operation. Be aware that during preview, if the instance's - * internal software version is too old, critical update will be performed - * before actual backup. Once the internal software version is updated to the - * minimum version required by the backup feature, subsequent backups will not - * require critical update. After preview, there will be no critical update - * needed for backup. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Instance resource name using the form: - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` - * where `location_id` refers to a Google Cloud region. - * @param {google.protobuf.Duration} [request.ttl] - * Optional. TTL for the backup to expire. Value range is 1 day to 100 years. - * If not specified, the default value is 100 years. - * @param {string} [request.backupId] - * Optional. The id of the backup to be created. If not specified, the - * default value ([YYYYMMDDHHMMSS]_[Shortened Instance UID] is used. - * @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/memorystore.backup_instance.js - * region_tag:memorystore_v1_generated_Memorystore_BackupInstance_async - */ + /** + * Backup Instance. + * If this is the first time a backup is being created, a backup collection + * will be created at the backend, and this backup belongs to this collection. + * Both collection and backup will have a resource name. Backup will be + * executed for each shard. A replica (primary if nonHA) will be selected to + * perform the execution. Backup call will be rejected if there is an ongoing + * backup or update operation. Be aware that during preview, if the instance's + * internal software version is too old, critical update will be performed + * before actual backup. Once the internal software version is updated to the + * minimum version required by the backup feature, subsequent backups will not + * require critical update. After preview, there will be no critical update + * needed for backup. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Instance resource name using the form: + * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * where `location_id` refers to a Google Cloud region. + * @param {google.protobuf.Duration} [request.ttl] + * Optional. TTL for the backup to expire. Value range is 1 day to 100 years. + * If not specified, the default value is 100 years. + * @param {string} [request.backupId] + * Optional. The id of the backup to be created. If not specified, the + * default value ([YYYYMMDDHHMMSS]_[Shortened Instance UID] is used. + * @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/memorystore.backup_instance.js + * region_tag:memorystore_v1_generated_Memorystore_BackupInstance_async + */ backupInstance( - request?: protos.google.cloud.memorystore.v1.IBackupInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memorystore.v1.IBackupInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; backupInstance( - request: protos.google.cloud.memorystore.v1.IBackupInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1.IBackupInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; backupInstance( - request: protos.google.cloud.memorystore.v1.IBackupInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1.IBackupInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; backupInstance( - request?: protos.google.cloud.memorystore.v1.IBackupInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.memorystore.v1.IBackupInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('backupInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('backupInstance request %j', request); - return this.innerApiCalls.backupInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('backupInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .backupInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('backupInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `backupInstance()`. - * @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/memorystore.backup_instance.js - * region_tag:memorystore_v1_generated_Memorystore_BackupInstance_async - */ - async checkBackupInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `backupInstance()`. + * @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/memorystore.backup_instance.js + * region_tag:memorystore_v1_generated_Memorystore_BackupInstance_async + */ + async checkBackupInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.memorystore.v1.Instance, + protos.google.cloud.memorystore.v1.OperationMetadata + > + > { this._log.info('backupInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.backupInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists Instances in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent to list instances from. - * Format: projects/{project}/locations/{location} - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Expression for filtering results. - * @param {string} [request.orderBy] - * Optional. Sort results by a defined order. Supported values: "name", - * "create_time". - * @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 Array of {@link protos.google.cloud.memorystore.v1.Instance|Instance}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listInstancesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.backupInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.memorystore.v1.Instance, + protos.google.cloud.memorystore.v1.OperationMetadata + >; + } + /** + * Lists Instances in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent to list instances from. + * Format: projects/{project}/locations/{location} + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Expression for filtering results. + * @param {string} [request.orderBy] + * Optional. Sort results by a defined order. Supported values: "name", + * "create_time". + * @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 Array of {@link protos.google.cloud.memorystore.v1.Instance|Instance}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listInstances( - request?: protos.google.cloud.memorystore.v1.IListInstancesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.memorystore.v1.IInstance[], - protos.google.cloud.memorystore.v1.IListInstancesRequest|null, - protos.google.cloud.memorystore.v1.IListInstancesResponse - ]>; + request?: protos.google.cloud.memorystore.v1.IListInstancesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.memorystore.v1.IInstance[], + protos.google.cloud.memorystore.v1.IListInstancesRequest | null, + protos.google.cloud.memorystore.v1.IListInstancesResponse, + ] + >; listInstances( - request: protos.google.cloud.memorystore.v1.IListInstancesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.memorystore.v1.IListInstancesRequest, - protos.google.cloud.memorystore.v1.IListInstancesResponse|null|undefined, - protos.google.cloud.memorystore.v1.IInstance>): void; + request: protos.google.cloud.memorystore.v1.IListInstancesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.memorystore.v1.IListInstancesRequest, + | protos.google.cloud.memorystore.v1.IListInstancesResponse + | null + | undefined, + protos.google.cloud.memorystore.v1.IInstance + >, + ): void; listInstances( - request: protos.google.cloud.memorystore.v1.IListInstancesRequest, - callback: PaginationCallback< - protos.google.cloud.memorystore.v1.IListInstancesRequest, - protos.google.cloud.memorystore.v1.IListInstancesResponse|null|undefined, - protos.google.cloud.memorystore.v1.IInstance>): void; + request: protos.google.cloud.memorystore.v1.IListInstancesRequest, + callback: PaginationCallback< + protos.google.cloud.memorystore.v1.IListInstancesRequest, + | protos.google.cloud.memorystore.v1.IListInstancesResponse + | null + | undefined, + protos.google.cloud.memorystore.v1.IInstance + >, + ): void; listInstances( - request?: protos.google.cloud.memorystore.v1.IListInstancesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.memorystore.v1.IListInstancesRequest, - protos.google.cloud.memorystore.v1.IListInstancesResponse|null|undefined, - protos.google.cloud.memorystore.v1.IInstance>, - callback?: PaginationCallback< + request?: protos.google.cloud.memorystore.v1.IListInstancesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.memorystore.v1.IListInstancesRequest, - protos.google.cloud.memorystore.v1.IListInstancesResponse|null|undefined, - protos.google.cloud.memorystore.v1.IInstance>): - Promise<[ - protos.google.cloud.memorystore.v1.IInstance[], - protos.google.cloud.memorystore.v1.IListInstancesRequest|null, - protos.google.cloud.memorystore.v1.IListInstancesResponse - ]>|void { + | protos.google.cloud.memorystore.v1.IListInstancesResponse + | null + | undefined, + protos.google.cloud.memorystore.v1.IInstance + >, + callback?: PaginationCallback< + protos.google.cloud.memorystore.v1.IListInstancesRequest, + | protos.google.cloud.memorystore.v1.IListInstancesResponse + | null + | undefined, + protos.google.cloud.memorystore.v1.IInstance + >, + ): Promise< + [ + protos.google.cloud.memorystore.v1.IInstance[], + protos.google.cloud.memorystore.v1.IListInstancesRequest | null, + protos.google.cloud.memorystore.v1.IListInstancesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.memorystore.v1.IListInstancesRequest, - protos.google.cloud.memorystore.v1.IListInstancesResponse|null|undefined, - protos.google.cloud.memorystore.v1.IInstance>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.memorystore.v1.IListInstancesRequest, + | protos.google.cloud.memorystore.v1.IListInstancesResponse + | null + | undefined, + protos.google.cloud.memorystore.v1.IInstance + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listInstances values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1874,217 +2679,246 @@ export class MemorystoreClient { this._log.info('listInstances request %j', request); return this.innerApiCalls .listInstances(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.memorystore.v1.IInstance[], - protos.google.cloud.memorystore.v1.IListInstancesRequest|null, - protos.google.cloud.memorystore.v1.IListInstancesResponse - ]) => { - this._log.info('listInstances values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.memorystore.v1.IInstance[], + protos.google.cloud.memorystore.v1.IListInstancesRequest | null, + protos.google.cloud.memorystore.v1.IListInstancesResponse, + ]) => { + this._log.info('listInstances values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listInstances`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent to list instances from. - * Format: projects/{project}/locations/{location} - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Expression for filtering results. - * @param {string} [request.orderBy] - * Optional. Sort results by a defined order. Supported values: "name", - * "create_time". - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.memorystore.v1.Instance|Instance} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listInstancesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listInstances`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent to list instances from. + * Format: projects/{project}/locations/{location} + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Expression for filtering results. + * @param {string} [request.orderBy] + * Optional. Sort results by a defined order. Supported values: "name", + * "create_time". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.memorystore.v1.Instance|Instance} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listInstancesStream( - request?: protos.google.cloud.memorystore.v1.IListInstancesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.memorystore.v1.IListInstancesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listInstances']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listInstances stream %j', request); return this.descriptors.page.listInstances.createStream( this.innerApiCalls.listInstances as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listInstances`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent to list instances from. - * Format: projects/{project}/locations/{location} - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Expression for filtering results. - * @param {string} [request.orderBy] - * Optional. Sort results by a defined order. Supported values: "name", - * "create_time". - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.memorystore.v1.Instance|Instance}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/memorystore.list_instances.js - * region_tag:memorystore_v1_generated_Memorystore_ListInstances_async - */ + /** + * Equivalent to `listInstances`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent to list instances from. + * Format: projects/{project}/locations/{location} + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Expression for filtering results. + * @param {string} [request.orderBy] + * Optional. Sort results by a defined order. Supported values: "name", + * "create_time". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.memorystore.v1.Instance|Instance}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/memorystore.list_instances.js + * region_tag:memorystore_v1_generated_Memorystore_ListInstances_async + */ listInstancesAsync( - request?: protos.google.cloud.memorystore.v1.IListInstancesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.memorystore.v1.IListInstancesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listInstances']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listInstances iterate %j', request); return this.descriptors.page.listInstances.asyncIterate( this.innerApiCalls['listInstances'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists all backup collections owned by a consumer project in either the - * specified location (region) or all locations. - * - * If `location_id` is specified as `-` (wildcard), then all regions - * available to the project are queried, and the results are aggregated. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the backupCollection location using the - * form: - * `projects/{project_id}/locations/{location_id}` - * where `location_id` refers to a Google Cloud region. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * - * If not specified, a default value of 1000 will be used by the service. - * Regardless of the page_size value, the response may include a partial list - * and a caller should only rely on response's - * {@link protos.google.cloud.memorystore.v1.ListBackupCollectionsResponse.next_page_token|`next_page_token`} - * to determine if there are more clusters left to be queried. - * @param {string} [request.pageToken] - * Optional. The `next_page_token` value returned from a previous - * [ListBackupCollections] request, if any. - * @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 Array of {@link protos.google.cloud.memorystore.v1.BackupCollection|BackupCollection}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listBackupCollectionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists all backup collections owned by a consumer project in either the + * specified location (region) or all locations. + * + * If `location_id` is specified as `-` (wildcard), then all regions + * available to the project are queried, and the results are aggregated. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the backupCollection location using the + * form: + * `projects/{project_id}/locations/{location_id}` + * where `location_id` refers to a Google Cloud region. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * + * If not specified, a default value of 1000 will be used by the service. + * Regardless of the page_size value, the response may include a partial list + * and a caller should only rely on response's + * {@link protos.google.cloud.memorystore.v1.ListBackupCollectionsResponse.next_page_token|`next_page_token`} + * to determine if there are more clusters left to be queried. + * @param {string} [request.pageToken] + * Optional. The `next_page_token` value returned from a previous + * [ListBackupCollections] request, if any. + * @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 Array of {@link protos.google.cloud.memorystore.v1.BackupCollection|BackupCollection}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listBackupCollectionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listBackupCollections( - request?: protos.google.cloud.memorystore.v1.IListBackupCollectionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.memorystore.v1.IBackupCollection[], - protos.google.cloud.memorystore.v1.IListBackupCollectionsRequest|null, - protos.google.cloud.memorystore.v1.IListBackupCollectionsResponse - ]>; + request?: protos.google.cloud.memorystore.v1.IListBackupCollectionsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.memorystore.v1.IBackupCollection[], + protos.google.cloud.memorystore.v1.IListBackupCollectionsRequest | null, + protos.google.cloud.memorystore.v1.IListBackupCollectionsResponse, + ] + >; listBackupCollections( - request: protos.google.cloud.memorystore.v1.IListBackupCollectionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.memorystore.v1.IListBackupCollectionsRequest, - protos.google.cloud.memorystore.v1.IListBackupCollectionsResponse|null|undefined, - protos.google.cloud.memorystore.v1.IBackupCollection>): void; + request: protos.google.cloud.memorystore.v1.IListBackupCollectionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.memorystore.v1.IListBackupCollectionsRequest, + | protos.google.cloud.memorystore.v1.IListBackupCollectionsResponse + | null + | undefined, + protos.google.cloud.memorystore.v1.IBackupCollection + >, + ): void; listBackupCollections( - request: protos.google.cloud.memorystore.v1.IListBackupCollectionsRequest, - callback: PaginationCallback< - protos.google.cloud.memorystore.v1.IListBackupCollectionsRequest, - protos.google.cloud.memorystore.v1.IListBackupCollectionsResponse|null|undefined, - protos.google.cloud.memorystore.v1.IBackupCollection>): void; + request: protos.google.cloud.memorystore.v1.IListBackupCollectionsRequest, + callback: PaginationCallback< + protos.google.cloud.memorystore.v1.IListBackupCollectionsRequest, + | protos.google.cloud.memorystore.v1.IListBackupCollectionsResponse + | null + | undefined, + protos.google.cloud.memorystore.v1.IBackupCollection + >, + ): void; listBackupCollections( - request?: protos.google.cloud.memorystore.v1.IListBackupCollectionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.memorystore.v1.IListBackupCollectionsRequest, - protos.google.cloud.memorystore.v1.IListBackupCollectionsResponse|null|undefined, - protos.google.cloud.memorystore.v1.IBackupCollection>, - callback?: PaginationCallback< + request?: protos.google.cloud.memorystore.v1.IListBackupCollectionsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.memorystore.v1.IListBackupCollectionsRequest, - protos.google.cloud.memorystore.v1.IListBackupCollectionsResponse|null|undefined, - protos.google.cloud.memorystore.v1.IBackupCollection>): - Promise<[ - protos.google.cloud.memorystore.v1.IBackupCollection[], - protos.google.cloud.memorystore.v1.IListBackupCollectionsRequest|null, - protos.google.cloud.memorystore.v1.IListBackupCollectionsResponse - ]>|void { + | protos.google.cloud.memorystore.v1.IListBackupCollectionsResponse + | null + | undefined, + protos.google.cloud.memorystore.v1.IBackupCollection + >, + callback?: PaginationCallback< + protos.google.cloud.memorystore.v1.IListBackupCollectionsRequest, + | protos.google.cloud.memorystore.v1.IListBackupCollectionsResponse + | null + | undefined, + protos.google.cloud.memorystore.v1.IBackupCollection + >, + ): Promise< + [ + protos.google.cloud.memorystore.v1.IBackupCollection[], + protos.google.cloud.memorystore.v1.IListBackupCollectionsRequest | null, + protos.google.cloud.memorystore.v1.IListBackupCollectionsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.memorystore.v1.IListBackupCollectionsRequest, - protos.google.cloud.memorystore.v1.IListBackupCollectionsResponse|null|undefined, - protos.google.cloud.memorystore.v1.IBackupCollection>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.memorystore.v1.IListBackupCollectionsRequest, + | protos.google.cloud.memorystore.v1.IListBackupCollectionsResponse + | null + | undefined, + protos.google.cloud.memorystore.v1.IBackupCollection + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listBackupCollections values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2093,217 +2927,246 @@ export class MemorystoreClient { this._log.info('listBackupCollections request %j', request); return this.innerApiCalls .listBackupCollections(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.memorystore.v1.IBackupCollection[], - protos.google.cloud.memorystore.v1.IListBackupCollectionsRequest|null, - protos.google.cloud.memorystore.v1.IListBackupCollectionsResponse - ]) => { - this._log.info('listBackupCollections values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.memorystore.v1.IBackupCollection[], + protos.google.cloud.memorystore.v1.IListBackupCollectionsRequest | null, + protos.google.cloud.memorystore.v1.IListBackupCollectionsResponse, + ]) => { + this._log.info('listBackupCollections values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listBackupCollections`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the backupCollection location using the - * form: - * `projects/{project_id}/locations/{location_id}` - * where `location_id` refers to a Google Cloud region. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * - * If not specified, a default value of 1000 will be used by the service. - * Regardless of the page_size value, the response may include a partial list - * and a caller should only rely on response's - * {@link protos.google.cloud.memorystore.v1.ListBackupCollectionsResponse.next_page_token|`next_page_token`} - * to determine if there are more clusters left to be queried. - * @param {string} [request.pageToken] - * Optional. The `next_page_token` value returned from a previous - * [ListBackupCollections] request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.memorystore.v1.BackupCollection|BackupCollection} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listBackupCollectionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listBackupCollections`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the backupCollection location using the + * form: + * `projects/{project_id}/locations/{location_id}` + * where `location_id` refers to a Google Cloud region. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * + * If not specified, a default value of 1000 will be used by the service. + * Regardless of the page_size value, the response may include a partial list + * and a caller should only rely on response's + * {@link protos.google.cloud.memorystore.v1.ListBackupCollectionsResponse.next_page_token|`next_page_token`} + * to determine if there are more clusters left to be queried. + * @param {string} [request.pageToken] + * Optional. The `next_page_token` value returned from a previous + * [ListBackupCollections] request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.memorystore.v1.BackupCollection|BackupCollection} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listBackupCollectionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listBackupCollectionsStream( - request?: protos.google.cloud.memorystore.v1.IListBackupCollectionsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.memorystore.v1.IListBackupCollectionsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listBackupCollections']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listBackupCollections stream %j', request); return this.descriptors.page.listBackupCollections.createStream( this.innerApiCalls.listBackupCollections as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listBackupCollections`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the backupCollection location using the - * form: - * `projects/{project_id}/locations/{location_id}` - * where `location_id` refers to a Google Cloud region. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * - * If not specified, a default value of 1000 will be used by the service. - * Regardless of the page_size value, the response may include a partial list - * and a caller should only rely on response's - * {@link protos.google.cloud.memorystore.v1.ListBackupCollectionsResponse.next_page_token|`next_page_token`} - * to determine if there are more clusters left to be queried. - * @param {string} [request.pageToken] - * Optional. The `next_page_token` value returned from a previous - * [ListBackupCollections] request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.memorystore.v1.BackupCollection|BackupCollection}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/memorystore.list_backup_collections.js - * region_tag:memorystore_v1_generated_Memorystore_ListBackupCollections_async - */ + /** + * Equivalent to `listBackupCollections`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the backupCollection location using the + * form: + * `projects/{project_id}/locations/{location_id}` + * where `location_id` refers to a Google Cloud region. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * + * If not specified, a default value of 1000 will be used by the service. + * Regardless of the page_size value, the response may include a partial list + * and a caller should only rely on response's + * {@link protos.google.cloud.memorystore.v1.ListBackupCollectionsResponse.next_page_token|`next_page_token`} + * to determine if there are more clusters left to be queried. + * @param {string} [request.pageToken] + * Optional. The `next_page_token` value returned from a previous + * [ListBackupCollections] request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.memorystore.v1.BackupCollection|BackupCollection}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/memorystore.list_backup_collections.js + * region_tag:memorystore_v1_generated_Memorystore_ListBackupCollections_async + */ listBackupCollectionsAsync( - request?: protos.google.cloud.memorystore.v1.IListBackupCollectionsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.memorystore.v1.IListBackupCollectionsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listBackupCollections']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listBackupCollections iterate %j', request); return this.descriptors.page.listBackupCollections.asyncIterate( this.innerApiCalls['listBackupCollections'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists all backups owned by a backup collection. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the backupCollection using the form: - * `projects/{project_id}/locations/{location_id}/backupCollections/{backup_collection_id}` - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * - * If not specified, a default value of 1000 will be used by the service. - * Regardless of the page_size value, the response may include a partial list - * and a caller should only rely on response's - * {@link protos.google.cloud.memorystore.v1.ListBackupsResponse.next_page_token|`next_page_token`} - * to determine if there are more clusters left to be queried. - * @param {string} [request.pageToken] - * Optional. The `next_page_token` value returned from a previous - * [ListBackupCollections] request, if any. - * @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 Array of {@link protos.google.cloud.memorystore.v1.Backup|Backup}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listBackupsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists all backups owned by a backup collection. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the backupCollection using the form: + * `projects/{project_id}/locations/{location_id}/backupCollections/{backup_collection_id}` + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * + * If not specified, a default value of 1000 will be used by the service. + * Regardless of the page_size value, the response may include a partial list + * and a caller should only rely on response's + * {@link protos.google.cloud.memorystore.v1.ListBackupsResponse.next_page_token|`next_page_token`} + * to determine if there are more clusters left to be queried. + * @param {string} [request.pageToken] + * Optional. The `next_page_token` value returned from a previous + * [ListBackupCollections] request, if any. + * @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 Array of {@link protos.google.cloud.memorystore.v1.Backup|Backup}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listBackupsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listBackups( - request?: protos.google.cloud.memorystore.v1.IListBackupsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.memorystore.v1.IBackup[], - protos.google.cloud.memorystore.v1.IListBackupsRequest|null, - protos.google.cloud.memorystore.v1.IListBackupsResponse - ]>; + request?: protos.google.cloud.memorystore.v1.IListBackupsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.memorystore.v1.IBackup[], + protos.google.cloud.memorystore.v1.IListBackupsRequest | null, + protos.google.cloud.memorystore.v1.IListBackupsResponse, + ] + >; listBackups( - request: protos.google.cloud.memorystore.v1.IListBackupsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.memorystore.v1.IListBackupsRequest, - protos.google.cloud.memorystore.v1.IListBackupsResponse|null|undefined, - protos.google.cloud.memorystore.v1.IBackup>): void; + request: protos.google.cloud.memorystore.v1.IListBackupsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.memorystore.v1.IListBackupsRequest, + | protos.google.cloud.memorystore.v1.IListBackupsResponse + | null + | undefined, + protos.google.cloud.memorystore.v1.IBackup + >, + ): void; listBackups( - request: protos.google.cloud.memorystore.v1.IListBackupsRequest, - callback: PaginationCallback< - protos.google.cloud.memorystore.v1.IListBackupsRequest, - protos.google.cloud.memorystore.v1.IListBackupsResponse|null|undefined, - protos.google.cloud.memorystore.v1.IBackup>): void; + request: protos.google.cloud.memorystore.v1.IListBackupsRequest, + callback: PaginationCallback< + protos.google.cloud.memorystore.v1.IListBackupsRequest, + | protos.google.cloud.memorystore.v1.IListBackupsResponse + | null + | undefined, + protos.google.cloud.memorystore.v1.IBackup + >, + ): void; listBackups( - request?: protos.google.cloud.memorystore.v1.IListBackupsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.memorystore.v1.IListBackupsRequest, - protos.google.cloud.memorystore.v1.IListBackupsResponse|null|undefined, - protos.google.cloud.memorystore.v1.IBackup>, - callback?: PaginationCallback< + request?: protos.google.cloud.memorystore.v1.IListBackupsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.memorystore.v1.IListBackupsRequest, - protos.google.cloud.memorystore.v1.IListBackupsResponse|null|undefined, - protos.google.cloud.memorystore.v1.IBackup>): - Promise<[ - protos.google.cloud.memorystore.v1.IBackup[], - protos.google.cloud.memorystore.v1.IListBackupsRequest|null, - protos.google.cloud.memorystore.v1.IListBackupsResponse - ]>|void { + | protos.google.cloud.memorystore.v1.IListBackupsResponse + | null + | undefined, + protos.google.cloud.memorystore.v1.IBackup + >, + callback?: PaginationCallback< + protos.google.cloud.memorystore.v1.IListBackupsRequest, + | protos.google.cloud.memorystore.v1.IListBackupsResponse + | null + | undefined, + protos.google.cloud.memorystore.v1.IBackup + >, + ): Promise< + [ + protos.google.cloud.memorystore.v1.IBackup[], + protos.google.cloud.memorystore.v1.IListBackupsRequest | null, + protos.google.cloud.memorystore.v1.IListBackupsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.memorystore.v1.IListBackupsRequest, - protos.google.cloud.memorystore.v1.IListBackupsResponse|null|undefined, - protos.google.cloud.memorystore.v1.IBackup>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.memorystore.v1.IListBackupsRequest, + | protos.google.cloud.memorystore.v1.IListBackupsResponse + | null + | undefined, + protos.google.cloud.memorystore.v1.IBackup + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listBackups values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2312,125 +3175,130 @@ export class MemorystoreClient { this._log.info('listBackups request %j', request); return this.innerApiCalls .listBackups(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.memorystore.v1.IBackup[], - protos.google.cloud.memorystore.v1.IListBackupsRequest|null, - protos.google.cloud.memorystore.v1.IListBackupsResponse - ]) => { - this._log.info('listBackups values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.memorystore.v1.IBackup[], + protos.google.cloud.memorystore.v1.IListBackupsRequest | null, + protos.google.cloud.memorystore.v1.IListBackupsResponse, + ]) => { + this._log.info('listBackups values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listBackups`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the backupCollection using the form: - * `projects/{project_id}/locations/{location_id}/backupCollections/{backup_collection_id}` - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * - * If not specified, a default value of 1000 will be used by the service. - * Regardless of the page_size value, the response may include a partial list - * and a caller should only rely on response's - * {@link protos.google.cloud.memorystore.v1.ListBackupsResponse.next_page_token|`next_page_token`} - * to determine if there are more clusters left to be queried. - * @param {string} [request.pageToken] - * Optional. The `next_page_token` value returned from a previous - * [ListBackupCollections] request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.memorystore.v1.Backup|Backup} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listBackupsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listBackups`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the backupCollection using the form: + * `projects/{project_id}/locations/{location_id}/backupCollections/{backup_collection_id}` + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * + * If not specified, a default value of 1000 will be used by the service. + * Regardless of the page_size value, the response may include a partial list + * and a caller should only rely on response's + * {@link protos.google.cloud.memorystore.v1.ListBackupsResponse.next_page_token|`next_page_token`} + * to determine if there are more clusters left to be queried. + * @param {string} [request.pageToken] + * Optional. The `next_page_token` value returned from a previous + * [ListBackupCollections] request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.memorystore.v1.Backup|Backup} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listBackupsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listBackupsStream( - request?: protos.google.cloud.memorystore.v1.IListBackupsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.memorystore.v1.IListBackupsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listBackups']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listBackups stream %j', request); return this.descriptors.page.listBackups.createStream( this.innerApiCalls.listBackups as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listBackups`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the backupCollection using the form: - * `projects/{project_id}/locations/{location_id}/backupCollections/{backup_collection_id}` - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * - * If not specified, a default value of 1000 will be used by the service. - * Regardless of the page_size value, the response may include a partial list - * and a caller should only rely on response's - * {@link protos.google.cloud.memorystore.v1.ListBackupsResponse.next_page_token|`next_page_token`} - * to determine if there are more clusters left to be queried. - * @param {string} [request.pageToken] - * Optional. The `next_page_token` value returned from a previous - * [ListBackupCollections] request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.memorystore.v1.Backup|Backup}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/memorystore.list_backups.js - * region_tag:memorystore_v1_generated_Memorystore_ListBackups_async - */ + /** + * Equivalent to `listBackups`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the backupCollection using the form: + * `projects/{project_id}/locations/{location_id}/backupCollections/{backup_collection_id}` + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * + * If not specified, a default value of 1000 will be used by the service. + * Regardless of the page_size value, the response may include a partial list + * and a caller should only rely on response's + * {@link protos.google.cloud.memorystore.v1.ListBackupsResponse.next_page_token|`next_page_token`} + * to determine if there are more clusters left to be queried. + * @param {string} [request.pageToken] + * Optional. The `next_page_token` value returned from a previous + * [ListBackupCollections] request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.memorystore.v1.Backup|Backup}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/memorystore.list_backups.js + * region_tag:memorystore_v1_generated_Memorystore_ListBackups_async + */ listBackupsAsync( - request?: protos.google.cloud.memorystore.v1.IListBackupsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.memorystore.v1.IListBackupsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listBackups']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listBackups iterate %j', request); return this.descriptors.page.listBackups.asyncIterate( this.innerApiCalls['listBackups'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** + + /** * Gets information about a location. * * @param {Object} request @@ -2465,12 +3333,11 @@ export class MemorystoreClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -2503,12 +3370,12 @@ export class MemorystoreClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -2551,22 +3418,22 @@ export class MemorystoreClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -2601,15 +3468,15 @@ export class MemorystoreClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - 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 ?? '', - }); + 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 ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -2643,7 +3510,7 @@ export class MemorystoreClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -2656,25 +3523,24 @@ export class MemorystoreClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -2713,22 +3579,22 @@ export class MemorystoreClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -2745,7 +3611,12 @@ export class MemorystoreClient { * @param {string} backup * @returns {string} Resource name string. */ - backupPath(project:string,location:string,backupCollection:string,backup:string) { + backupPath( + project: string, + location: string, + backupCollection: string, + backup: string, + ) { return this.pathTemplates.backupPathTemplate.render({ project: project, location: location, @@ -2784,7 +3655,8 @@ export class MemorystoreClient { * @returns {string} A string representing the backup_collection. */ matchBackupCollectionFromBackupName(backupName: string) { - return this.pathTemplates.backupPathTemplate.match(backupName).backup_collection; + return this.pathTemplates.backupPathTemplate.match(backupName) + .backup_collection; } /** @@ -2806,7 +3678,11 @@ export class MemorystoreClient { * @param {string} backup_collection * @returns {string} Resource name string. */ - backupCollectionPath(project:string,location:string,backupCollection:string) { + backupCollectionPath( + project: string, + location: string, + backupCollection: string, + ) { return this.pathTemplates.backupCollectionPathTemplate.render({ project: project, location: location, @@ -2822,7 +3698,9 @@ export class MemorystoreClient { * @returns {string} A string representing the project. */ matchProjectFromBackupCollectionName(backupCollectionName: string) { - return this.pathTemplates.backupCollectionPathTemplate.match(backupCollectionName).project; + return this.pathTemplates.backupCollectionPathTemplate.match( + backupCollectionName, + ).project; } /** @@ -2833,7 +3711,9 @@ export class MemorystoreClient { * @returns {string} A string representing the location. */ matchLocationFromBackupCollectionName(backupCollectionName: string) { - return this.pathTemplates.backupCollectionPathTemplate.match(backupCollectionName).location; + return this.pathTemplates.backupCollectionPathTemplate.match( + backupCollectionName, + ).location; } /** @@ -2844,7 +3724,9 @@ export class MemorystoreClient { * @returns {string} A string representing the backup_collection. */ matchBackupCollectionFromBackupCollectionName(backupCollectionName: string) { - return this.pathTemplates.backupCollectionPathTemplate.match(backupCollectionName).backup_collection; + return this.pathTemplates.backupCollectionPathTemplate.match( + backupCollectionName, + ).backup_collection; } /** @@ -2855,7 +3737,7 @@ export class MemorystoreClient { * @param {string} ca_pool * @returns {string} Resource name string. */ - caPoolPath(project:string,location:string,caPool:string) { + caPoolPath(project: string, location: string, caPool: string) { return this.pathTemplates.caPoolPathTemplate.render({ project: project, location: location, @@ -2904,7 +3786,11 @@ export class MemorystoreClient { * @param {string} instance * @returns {string} Resource name string. */ - certificateAuthorityPath(project:string,location:string,instance:string) { + certificateAuthorityPath( + project: string, + location: string, + instance: string, + ) { return this.pathTemplates.certificateAuthorityPathTemplate.render({ project: project, location: location, @@ -2920,7 +3806,9 @@ export class MemorystoreClient { * @returns {string} A string representing the project. */ matchProjectFromCertificateAuthorityName(certificateAuthorityName: string) { - return this.pathTemplates.certificateAuthorityPathTemplate.match(certificateAuthorityName).project; + return this.pathTemplates.certificateAuthorityPathTemplate.match( + certificateAuthorityName, + ).project; } /** @@ -2931,7 +3819,9 @@ export class MemorystoreClient { * @returns {string} A string representing the location. */ matchLocationFromCertificateAuthorityName(certificateAuthorityName: string) { - return this.pathTemplates.certificateAuthorityPathTemplate.match(certificateAuthorityName).location; + return this.pathTemplates.certificateAuthorityPathTemplate.match( + certificateAuthorityName, + ).location; } /** @@ -2942,7 +3832,9 @@ export class MemorystoreClient { * @returns {string} A string representing the instance. */ matchInstanceFromCertificateAuthorityName(certificateAuthorityName: string) { - return this.pathTemplates.certificateAuthorityPathTemplate.match(certificateAuthorityName).instance; + return this.pathTemplates.certificateAuthorityPathTemplate.match( + certificateAuthorityName, + ).instance; } /** @@ -2954,7 +3846,12 @@ export class MemorystoreClient { * @param {string} crypto_key * @returns {string} Resource name string. */ - cryptoKeyPath(project:string,location:string,keyRing:string,cryptoKey:string) { + cryptoKeyPath( + project: string, + location: string, + keyRing: string, + cryptoKey: string, + ) { return this.pathTemplates.cryptoKeyPathTemplate.render({ project: project, location: location, @@ -2971,7 +3868,8 @@ export class MemorystoreClient { * @returns {string} A string representing the project. */ matchProjectFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).project; + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName) + .project; } /** @@ -2982,7 +3880,8 @@ export class MemorystoreClient { * @returns {string} A string representing the location. */ matchLocationFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).location; + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName) + .location; } /** @@ -2993,7 +3892,8 @@ export class MemorystoreClient { * @returns {string} A string representing the key_ring. */ matchKeyRingFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).key_ring; + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName) + .key_ring; } /** @@ -3004,7 +3904,8 @@ export class MemorystoreClient { * @returns {string} A string representing the crypto_key. */ matchCryptoKeyFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).crypto_key; + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName) + .crypto_key; } /** @@ -3017,7 +3918,13 @@ export class MemorystoreClient { * @param {string} crypto_key_version * @returns {string} Resource name string. */ - cryptoKeyVersionPath(project:string,location:string,keyRing:string,cryptoKey:string,cryptoKeyVersion:string) { + cryptoKeyVersionPath( + project: string, + location: string, + keyRing: string, + cryptoKey: string, + cryptoKeyVersion: string, + ) { return this.pathTemplates.cryptoKeyVersionPathTemplate.render({ project: project, location: location, @@ -3035,7 +3942,9 @@ export class MemorystoreClient { * @returns {string} A string representing the project. */ matchProjectFromCryptoKeyVersionName(cryptoKeyVersionName: string) { - return this.pathTemplates.cryptoKeyVersionPathTemplate.match(cryptoKeyVersionName).project; + return this.pathTemplates.cryptoKeyVersionPathTemplate.match( + cryptoKeyVersionName, + ).project; } /** @@ -3046,7 +3955,9 @@ export class MemorystoreClient { * @returns {string} A string representing the location. */ matchLocationFromCryptoKeyVersionName(cryptoKeyVersionName: string) { - return this.pathTemplates.cryptoKeyVersionPathTemplate.match(cryptoKeyVersionName).location; + return this.pathTemplates.cryptoKeyVersionPathTemplate.match( + cryptoKeyVersionName, + ).location; } /** @@ -3057,7 +3968,9 @@ export class MemorystoreClient { * @returns {string} A string representing the key_ring. */ matchKeyRingFromCryptoKeyVersionName(cryptoKeyVersionName: string) { - return this.pathTemplates.cryptoKeyVersionPathTemplate.match(cryptoKeyVersionName).key_ring; + return this.pathTemplates.cryptoKeyVersionPathTemplate.match( + cryptoKeyVersionName, + ).key_ring; } /** @@ -3068,7 +3981,9 @@ export class MemorystoreClient { * @returns {string} A string representing the crypto_key. */ matchCryptoKeyFromCryptoKeyVersionName(cryptoKeyVersionName: string) { - return this.pathTemplates.cryptoKeyVersionPathTemplate.match(cryptoKeyVersionName).crypto_key; + return this.pathTemplates.cryptoKeyVersionPathTemplate.match( + cryptoKeyVersionName, + ).crypto_key; } /** @@ -3079,7 +3994,9 @@ export class MemorystoreClient { * @returns {string} A string representing the crypto_key_version. */ matchCryptoKeyVersionFromCryptoKeyVersionName(cryptoKeyVersionName: string) { - return this.pathTemplates.cryptoKeyVersionPathTemplate.match(cryptoKeyVersionName).crypto_key_version; + return this.pathTemplates.cryptoKeyVersionPathTemplate.match( + cryptoKeyVersionName, + ).crypto_key_version; } /** @@ -3090,7 +4007,7 @@ export class MemorystoreClient { * @param {string} forwarding_rule * @returns {string} Resource name string. */ - forwardingRulePath(project:string,region:string,forwardingRule:string) { + forwardingRulePath(project: string, region: string, forwardingRule: string) { return this.pathTemplates.forwardingRulePathTemplate.render({ project: project, region: region, @@ -3106,7 +4023,9 @@ export class MemorystoreClient { * @returns {string} A string representing the project. */ matchProjectFromForwardingRuleName(forwardingRuleName: string) { - return this.pathTemplates.forwardingRulePathTemplate.match(forwardingRuleName).project; + return this.pathTemplates.forwardingRulePathTemplate.match( + forwardingRuleName, + ).project; } /** @@ -3117,7 +4036,9 @@ export class MemorystoreClient { * @returns {string} A string representing the region. */ matchRegionFromForwardingRuleName(forwardingRuleName: string) { - return this.pathTemplates.forwardingRulePathTemplate.match(forwardingRuleName).region; + return this.pathTemplates.forwardingRulePathTemplate.match( + forwardingRuleName, + ).region; } /** @@ -3128,7 +4049,9 @@ export class MemorystoreClient { * @returns {string} A string representing the forwarding_rule. */ matchForwardingRuleFromForwardingRuleName(forwardingRuleName: string) { - return this.pathTemplates.forwardingRulePathTemplate.match(forwardingRuleName).forwarding_rule; + return this.pathTemplates.forwardingRulePathTemplate.match( + forwardingRuleName, + ).forwarding_rule; } /** @@ -3139,7 +4062,7 @@ export class MemorystoreClient { * @param {string} instance * @returns {string} Resource name string. */ - instancePath(project:string,location:string,instance:string) { + instancePath(project: string, location: string, instance: string) { return this.pathTemplates.instancePathTemplate.render({ project: project, location: location, @@ -3187,7 +4110,7 @@ export class MemorystoreClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -3223,7 +4146,7 @@ export class MemorystoreClient { * @param {string} network * @returns {string} Resource name string. */ - networkPath(project:string,network:string) { + networkPath(project: string, network: string) { return this.pathTemplates.networkPathTemplate.render({ project: project, network: network, @@ -3258,7 +4181,7 @@ export class MemorystoreClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -3283,7 +4206,11 @@ export class MemorystoreClient { * @param {string} service_attachment * @returns {string} Resource name string. */ - serviceAttachmentPath(project:string,region:string,serviceAttachment:string) { + serviceAttachmentPath( + project: string, + region: string, + serviceAttachment: string, + ) { return this.pathTemplates.serviceAttachmentPathTemplate.render({ project: project, region: region, @@ -3299,7 +4226,9 @@ export class MemorystoreClient { * @returns {string} A string representing the project. */ matchProjectFromServiceAttachmentName(serviceAttachmentName: string) { - return this.pathTemplates.serviceAttachmentPathTemplate.match(serviceAttachmentName).project; + return this.pathTemplates.serviceAttachmentPathTemplate.match( + serviceAttachmentName, + ).project; } /** @@ -3310,7 +4239,9 @@ export class MemorystoreClient { * @returns {string} A string representing the region. */ matchRegionFromServiceAttachmentName(serviceAttachmentName: string) { - return this.pathTemplates.serviceAttachmentPathTemplate.match(serviceAttachmentName).region; + return this.pathTemplates.serviceAttachmentPathTemplate.match( + serviceAttachmentName, + ).region; } /** @@ -3320,8 +4251,12 @@ export class MemorystoreClient { * A fully-qualified path representing ServiceAttachment resource. * @returns {string} A string representing the service_attachment. */ - matchServiceAttachmentFromServiceAttachmentName(serviceAttachmentName: string) { - return this.pathTemplates.serviceAttachmentPathTemplate.match(serviceAttachmentName).service_attachment; + matchServiceAttachmentFromServiceAttachmentName( + serviceAttachmentName: string, + ) { + return this.pathTemplates.serviceAttachmentPathTemplate.match( + serviceAttachmentName, + ).service_attachment; } /** @@ -3331,11 +4266,13 @@ export class MemorystoreClient { * @param {string} location * @returns {string} Resource name string. */ - sharedRegionalCertificateAuthorityPath(project:string,location:string) { - return this.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate.render({ - project: project, - location: location, - }); + sharedRegionalCertificateAuthorityPath(project: string, location: string) { + return this.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate.render( + { + project: project, + location: location, + }, + ); } /** @@ -3345,8 +4282,12 @@ export class MemorystoreClient { * A fully-qualified path representing SharedRegionalCertificateAuthority resource. * @returns {string} A string representing the project. */ - matchProjectFromSharedRegionalCertificateAuthorityName(sharedRegionalCertificateAuthorityName: string) { - return this.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate.match(sharedRegionalCertificateAuthorityName).project; + matchProjectFromSharedRegionalCertificateAuthorityName( + sharedRegionalCertificateAuthorityName: string, + ) { + return this.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate.match( + sharedRegionalCertificateAuthorityName, + ).project; } /** @@ -3356,8 +4297,12 @@ export class MemorystoreClient { * A fully-qualified path representing SharedRegionalCertificateAuthority resource. * @returns {string} A string representing the location. */ - matchLocationFromSharedRegionalCertificateAuthorityName(sharedRegionalCertificateAuthorityName: string) { - return this.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate.match(sharedRegionalCertificateAuthorityName).location; + matchLocationFromSharedRegionalCertificateAuthorityName( + sharedRegionalCertificateAuthorityName: string, + ) { + return this.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate.match( + sharedRegionalCertificateAuthorityName, + ).location; } /** @@ -3368,14 +4313,16 @@ export class MemorystoreClient { */ close(): Promise { if (this.memorystoreStub && !this._terminated) { - return this.memorystoreStub.then(stub => { + return this.memorystoreStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.locationsClient.close().catch(err => {throw err}); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-memorystore/src/v1beta/index.ts b/packages/google-cloud-memorystore/src/v1beta/index.ts index fceb6f519bce..5bafc3441d86 100644 --- a/packages/google-cloud-memorystore/src/v1beta/index.ts +++ b/packages/google-cloud-memorystore/src/v1beta/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {MemorystoreClient} from './memorystore_client'; +export { MemorystoreClient } from './memorystore_client'; diff --git a/packages/google-cloud-memorystore/src/v1beta/memorystore_client.ts b/packages/google-cloud-memorystore/src/v1beta/memorystore_client.ts index b845543e5e79..c371166ada95 100644 --- a/packages/google-cloud-memorystore/src/v1beta/memorystore_client.ts +++ b/packages/google-cloud-memorystore/src/v1beta/memorystore_client.ts @@ -18,11 +18,22 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -44,7 +55,7 @@ export class MemorystoreClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('memorystore'); @@ -57,11 +68,11 @@ export class MemorystoreClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - memorystoreStub?: Promise<{[name: string]: Function}>; + memorystoreStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of MemorystoreClient. @@ -102,21 +113,42 @@ export class MemorystoreClient { * const client = new MemorystoreClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof MemorystoreClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'memorystore.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -141,7 +173,7 @@ export class MemorystoreClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -155,15 +187,11 @@ export class MemorystoreClient { } this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -185,40 +213,44 @@ export class MemorystoreClient { // Create useful helper objects for these. this.pathTemplates = { caPoolPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/caPools/{ca_pool}' + 'projects/{project}/locations/{location}/caPools/{ca_pool}', ), certificateAuthorityPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/instances/{instance}/certificateAuthority' + 'projects/{project}/locations/{location}/instances/{instance}/certificateAuthority', ), forwardingRulePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/regions/{region}/forwardingRules/{forwarding_rule}' + 'projects/{project}/regions/{region}/forwardingRules/{forwarding_rule}', ), instancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/instances/{instance}' + 'projects/{project}/locations/{location}/instances/{instance}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), networkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/global/networks/{network}' + 'projects/{project}/global/networks/{network}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), serviceAttachmentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/regions/{region}/serviceAttachments/{service_attachment}' - ), - sharedRegionalCertificateAuthorityPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/sharedRegionalCertificateAuthority' + 'projects/{project}/regions/{region}/serviceAttachments/{service_attachment}', ), + sharedRegionalCertificateAuthorityPathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/sharedRegionalCertificateAuthority', + ), }; // Some of the methods on this service return "paged" results, // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listInstances: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'instances') + listInstances: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'instances', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -227,45 +259,84 @@ export class MemorystoreClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1beta/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1beta/{name=projects/*}/locations',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1beta/{name=projects/*/locations/*/operations/*}:cancel',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1beta/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1beta/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1beta/{name=projects/*}/locations', + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1beta/{name=projects/*/locations/*/operations/*}:cancel', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1beta/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1beta/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1beta/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.memorystore.v1beta.Instance') as gax.protobuf.Type; + '.google.cloud.memorystore.v1beta.Instance', + ) as gax.protobuf.Type; const createInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.memorystore.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.memorystore.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const updateInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.memorystore.v1beta.Instance') as gax.protobuf.Type; + '.google.cloud.memorystore.v1beta.Instance', + ) as gax.protobuf.Type; const updateInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.memorystore.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.memorystore.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const deleteInstanceResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.memorystore.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.memorystore.v1beta.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createInstanceResponse.decode.bind(createInstanceResponse), - createInstanceMetadata.decode.bind(createInstanceMetadata)), + createInstanceMetadata.decode.bind(createInstanceMetadata), + ), updateInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateInstanceResponse.decode.bind(updateInstanceResponse), - updateInstanceMetadata.decode.bind(updateInstanceMetadata)), + updateInstanceMetadata.decode.bind(updateInstanceMetadata), + ), deleteInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteInstanceResponse.decode.bind(deleteInstanceResponse), - deleteInstanceMetadata.decode.bind(deleteInstanceMetadata)) + deleteInstanceMetadata.decode.bind(deleteInstanceMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.memorystore.v1beta.Memorystore', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.memorystore.v1beta.Memorystore', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -296,28 +367,41 @@ export class MemorystoreClient { // Put together the "service stub" for // google.cloud.memorystore.v1beta.Memorystore. this.memorystoreStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.memorystore.v1beta.Memorystore') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.memorystore.v1beta.Memorystore', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.memorystore.v1beta.Memorystore, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const memorystoreStubMethods = - ['listInstances', 'getInstance', 'createInstance', 'updateInstance', 'deleteInstance', 'getCertificateAuthority', 'getSharedRegionalCertificateAuthority']; + const memorystoreStubMethods = [ + 'listInstances', + 'getInstance', + 'createInstance', + 'updateInstance', + 'deleteInstance', + 'getCertificateAuthority', + 'getSharedRegionalCertificateAuthority', + ]; for (const methodName of memorystoreStubMethods) { const callPromise = this.memorystoreStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -327,7 +411,7 @@ export class MemorystoreClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -342,8 +426,14 @@ export class MemorystoreClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'memorystore.googleapis.com'; } @@ -354,8 +444,14 @@ export class MemorystoreClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'memorystore.googleapis.com'; } @@ -386,9 +482,7 @@ export class MemorystoreClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -397,8 +491,9 @@ export class MemorystoreClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -409,764 +504,1122 @@ export class MemorystoreClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets details of a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the instance to retrieve. - * Format: projects/{project}/locations/{location}/instances/{instance} - * @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 {@link protos.google.cloud.memorystore.v1beta.Instance|Instance}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/memorystore.get_instance.js - * region_tag:memorystore_v1beta_generated_Memorystore_GetInstance_async - */ + /** + * Gets details of a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the instance to retrieve. + * Format: projects/{project}/locations/{location}/instances/{instance} + * @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 {@link protos.google.cloud.memorystore.v1beta.Instance|Instance}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/memorystore.get_instance.js + * region_tag:memorystore_v1beta_generated_Memorystore_GetInstance_async + */ getInstance( - request?: protos.google.cloud.memorystore.v1beta.IGetInstanceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.memorystore.v1beta.IInstance, - protos.google.cloud.memorystore.v1beta.IGetInstanceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memorystore.v1beta.IGetInstanceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.memorystore.v1beta.IInstance, + protos.google.cloud.memorystore.v1beta.IGetInstanceRequest | undefined, + {} | undefined, + ] + >; getInstance( - request: protos.google.cloud.memorystore.v1beta.IGetInstanceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.memorystore.v1beta.IInstance, - protos.google.cloud.memorystore.v1beta.IGetInstanceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1beta.IGetInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.memorystore.v1beta.IInstance, + | protos.google.cloud.memorystore.v1beta.IGetInstanceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getInstance( - request: protos.google.cloud.memorystore.v1beta.IGetInstanceRequest, - callback: Callback< - protos.google.cloud.memorystore.v1beta.IInstance, - protos.google.cloud.memorystore.v1beta.IGetInstanceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1beta.IGetInstanceRequest, + callback: Callback< + protos.google.cloud.memorystore.v1beta.IInstance, + | protos.google.cloud.memorystore.v1beta.IGetInstanceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getInstance( - request?: protos.google.cloud.memorystore.v1beta.IGetInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.memorystore.v1beta.IInstance, - protos.google.cloud.memorystore.v1beta.IGetInstanceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.memorystore.v1beta.IGetInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.memorystore.v1beta.IInstance, - protos.google.cloud.memorystore.v1beta.IGetInstanceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.memorystore.v1beta.IInstance, - protos.google.cloud.memorystore.v1beta.IGetInstanceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.memorystore.v1beta.IGetInstanceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.memorystore.v1beta.IInstance, + | protos.google.cloud.memorystore.v1beta.IGetInstanceRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.memorystore.v1beta.IInstance, + protos.google.cloud.memorystore.v1beta.IGetInstanceRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getInstance request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.memorystore.v1beta.IInstance, - protos.google.cloud.memorystore.v1beta.IGetInstanceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.memorystore.v1beta.IInstance, + | protos.google.cloud.memorystore.v1beta.IGetInstanceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getInstance response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getInstance(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.memorystore.v1beta.IInstance, - protos.google.cloud.memorystore.v1beta.IGetInstanceRequest|undefined, - {}|undefined - ]) => { - this._log.info('getInstance response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getInstance(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.memorystore.v1beta.IInstance, + ( + | protos.google.cloud.memorystore.v1beta.IGetInstanceRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getInstance response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details about the certificate authority for an Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the certificate authority. - * Format: - * projects/{project}/locations/{location}/instances/{instance}/certificateAuthority - * @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 {@link protos.google.cloud.memorystore.v1beta.CertificateAuthority|CertificateAuthority}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/memorystore.get_certificate_authority.js - * region_tag:memorystore_v1beta_generated_Memorystore_GetCertificateAuthority_async - */ + /** + * Gets details about the certificate authority for an Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the certificate authority. + * Format: + * projects/{project}/locations/{location}/instances/{instance}/certificateAuthority + * @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 {@link protos.google.cloud.memorystore.v1beta.CertificateAuthority|CertificateAuthority}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/memorystore.get_certificate_authority.js + * region_tag:memorystore_v1beta_generated_Memorystore_GetCertificateAuthority_async + */ getCertificateAuthority( - request?: protos.google.cloud.memorystore.v1beta.IGetCertificateAuthorityRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.memorystore.v1beta.ICertificateAuthority, - protos.google.cloud.memorystore.v1beta.IGetCertificateAuthorityRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memorystore.v1beta.IGetCertificateAuthorityRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.memorystore.v1beta.ICertificateAuthority, + ( + | protos.google.cloud.memorystore.v1beta.IGetCertificateAuthorityRequest + | undefined + ), + {} | undefined, + ] + >; getCertificateAuthority( - request: protos.google.cloud.memorystore.v1beta.IGetCertificateAuthorityRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.memorystore.v1beta.ICertificateAuthority, - protos.google.cloud.memorystore.v1beta.IGetCertificateAuthorityRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1beta.IGetCertificateAuthorityRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.memorystore.v1beta.ICertificateAuthority, + | protos.google.cloud.memorystore.v1beta.IGetCertificateAuthorityRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getCertificateAuthority( - request: protos.google.cloud.memorystore.v1beta.IGetCertificateAuthorityRequest, - callback: Callback< - protos.google.cloud.memorystore.v1beta.ICertificateAuthority, - protos.google.cloud.memorystore.v1beta.IGetCertificateAuthorityRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1beta.IGetCertificateAuthorityRequest, + callback: Callback< + protos.google.cloud.memorystore.v1beta.ICertificateAuthority, + | protos.google.cloud.memorystore.v1beta.IGetCertificateAuthorityRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getCertificateAuthority( - request?: protos.google.cloud.memorystore.v1beta.IGetCertificateAuthorityRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.memorystore.v1beta.ICertificateAuthority, - protos.google.cloud.memorystore.v1beta.IGetCertificateAuthorityRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.memorystore.v1beta.IGetCertificateAuthorityRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.memorystore.v1beta.ICertificateAuthority, - protos.google.cloud.memorystore.v1beta.IGetCertificateAuthorityRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.memorystore.v1beta.ICertificateAuthority, - protos.google.cloud.memorystore.v1beta.IGetCertificateAuthorityRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.memorystore.v1beta.IGetCertificateAuthorityRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.memorystore.v1beta.ICertificateAuthority, + | protos.google.cloud.memorystore.v1beta.IGetCertificateAuthorityRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.memorystore.v1beta.ICertificateAuthority, + ( + | protos.google.cloud.memorystore.v1beta.IGetCertificateAuthorityRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getCertificateAuthority request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.memorystore.v1beta.ICertificateAuthority, - protos.google.cloud.memorystore.v1beta.IGetCertificateAuthorityRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.memorystore.v1beta.ICertificateAuthority, + | protos.google.cloud.memorystore.v1beta.IGetCertificateAuthorityRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getCertificateAuthority response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getCertificateAuthority(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.memorystore.v1beta.ICertificateAuthority, - protos.google.cloud.memorystore.v1beta.IGetCertificateAuthorityRequest|undefined, - {}|undefined - ]) => { - this._log.info('getCertificateAuthority response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getCertificateAuthority(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.memorystore.v1beta.ICertificateAuthority, + ( + | protos.google.cloud.memorystore.v1beta.IGetCertificateAuthorityRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getCertificateAuthority response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets the details of shared regional certificate authority information for - * Memorystore instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Regional certificate authority resource name using the form: - * `projects/{project}/locations/{location}/sharedRegionalCertificateAuthority` - * where `location_id` refers to a Google Cloud region. - * @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 {@link protos.google.cloud.memorystore.v1beta.SharedRegionalCertificateAuthority|SharedRegionalCertificateAuthority}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/memorystore.get_shared_regional_certificate_authority.js - * region_tag:memorystore_v1beta_generated_Memorystore_GetSharedRegionalCertificateAuthority_async - */ + /** + * Gets the details of shared regional certificate authority information for + * Memorystore instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Regional certificate authority resource name using the form: + * `projects/{project}/locations/{location}/sharedRegionalCertificateAuthority` + * where `location_id` refers to a Google Cloud region. + * @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 {@link protos.google.cloud.memorystore.v1beta.SharedRegionalCertificateAuthority|SharedRegionalCertificateAuthority}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/memorystore.get_shared_regional_certificate_authority.js + * region_tag:memorystore_v1beta_generated_Memorystore_GetSharedRegionalCertificateAuthority_async + */ getSharedRegionalCertificateAuthority( - request?: protos.google.cloud.memorystore.v1beta.IGetSharedRegionalCertificateAuthorityRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.memorystore.v1beta.ISharedRegionalCertificateAuthority, - protos.google.cloud.memorystore.v1beta.IGetSharedRegionalCertificateAuthorityRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memorystore.v1beta.IGetSharedRegionalCertificateAuthorityRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.memorystore.v1beta.ISharedRegionalCertificateAuthority, + ( + | protos.google.cloud.memorystore.v1beta.IGetSharedRegionalCertificateAuthorityRequest + | undefined + ), + {} | undefined, + ] + >; getSharedRegionalCertificateAuthority( - request: protos.google.cloud.memorystore.v1beta.IGetSharedRegionalCertificateAuthorityRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.memorystore.v1beta.ISharedRegionalCertificateAuthority, - protos.google.cloud.memorystore.v1beta.IGetSharedRegionalCertificateAuthorityRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1beta.IGetSharedRegionalCertificateAuthorityRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.memorystore.v1beta.ISharedRegionalCertificateAuthority, + | protos.google.cloud.memorystore.v1beta.IGetSharedRegionalCertificateAuthorityRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getSharedRegionalCertificateAuthority( - request: protos.google.cloud.memorystore.v1beta.IGetSharedRegionalCertificateAuthorityRequest, - callback: Callback< - protos.google.cloud.memorystore.v1beta.ISharedRegionalCertificateAuthority, - protos.google.cloud.memorystore.v1beta.IGetSharedRegionalCertificateAuthorityRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1beta.IGetSharedRegionalCertificateAuthorityRequest, + callback: Callback< + protos.google.cloud.memorystore.v1beta.ISharedRegionalCertificateAuthority, + | protos.google.cloud.memorystore.v1beta.IGetSharedRegionalCertificateAuthorityRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getSharedRegionalCertificateAuthority( - request?: protos.google.cloud.memorystore.v1beta.IGetSharedRegionalCertificateAuthorityRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.memorystore.v1beta.ISharedRegionalCertificateAuthority, - protos.google.cloud.memorystore.v1beta.IGetSharedRegionalCertificateAuthorityRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.memorystore.v1beta.IGetSharedRegionalCertificateAuthorityRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.memorystore.v1beta.ISharedRegionalCertificateAuthority, - protos.google.cloud.memorystore.v1beta.IGetSharedRegionalCertificateAuthorityRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.memorystore.v1beta.ISharedRegionalCertificateAuthority, - protos.google.cloud.memorystore.v1beta.IGetSharedRegionalCertificateAuthorityRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.memorystore.v1beta.IGetSharedRegionalCertificateAuthorityRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.memorystore.v1beta.ISharedRegionalCertificateAuthority, + | protos.google.cloud.memorystore.v1beta.IGetSharedRegionalCertificateAuthorityRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.memorystore.v1beta.ISharedRegionalCertificateAuthority, + ( + | protos.google.cloud.memorystore.v1beta.IGetSharedRegionalCertificateAuthorityRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getSharedRegionalCertificateAuthority request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.memorystore.v1beta.ISharedRegionalCertificateAuthority, - protos.google.cloud.memorystore.v1beta.IGetSharedRegionalCertificateAuthorityRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.memorystore.v1beta.ISharedRegionalCertificateAuthority, + | protos.google.cloud.memorystore.v1beta.IGetSharedRegionalCertificateAuthorityRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { - this._log.info('getSharedRegionalCertificateAuthority response %j', response); + this._log.info( + 'getSharedRegionalCertificateAuthority response %j', + response, + ); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getSharedRegionalCertificateAuthority(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.memorystore.v1beta.ISharedRegionalCertificateAuthority, - protos.google.cloud.memorystore.v1beta.IGetSharedRegionalCertificateAuthorityRequest|undefined, - {}|undefined - ]) => { - this._log.info('getSharedRegionalCertificateAuthority response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getSharedRegionalCertificateAuthority(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.memorystore.v1beta.ISharedRegionalCertificateAuthority, + ( + | protos.google.cloud.memorystore.v1beta.IGetSharedRegionalCertificateAuthorityRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info( + 'getSharedRegionalCertificateAuthority response %j', + response, + ); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a new Instance in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource where this instance will be created. - * Format: projects/{project}/locations/{location} - * @param {string} request.instanceId - * Required. The ID to use for the instance, which will become the final - * component of the instance's resource name. - * - * This value is subject to the following restrictions: - * - * * Must be 4-63 characters in length - * * Must begin with a letter or digit - * * Must contain only lowercase letters, digits, and hyphens - * * Must not end with a hyphen - * * Must be unique within a location - * @param {google.cloud.memorystore.v1beta.Instance} request.instance - * Required. The instance to create. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1beta/memorystore.create_instance.js - * region_tag:memorystore_v1beta_generated_Memorystore_CreateInstance_async - */ + /** + * Creates a new Instance in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource where this instance will be created. + * Format: projects/{project}/locations/{location} + * @param {string} request.instanceId + * Required. The ID to use for the instance, which will become the final + * component of the instance's resource name. + * + * This value is subject to the following restrictions: + * + * * Must be 4-63 characters in length + * * Must begin with a letter or digit + * * Must contain only lowercase letters, digits, and hyphens + * * Must not end with a hyphen + * * Must be unique within a location + * @param {google.cloud.memorystore.v1beta.Instance} request.instance + * Required. The instance to create. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1beta/memorystore.create_instance.js + * region_tag:memorystore_v1beta_generated_Memorystore_CreateInstance_async + */ createInstance( - request?: protos.google.cloud.memorystore.v1beta.ICreateInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memorystore.v1beta.ICreateInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.memorystore.v1beta.IInstance, + protos.google.cloud.memorystore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createInstance( - request: protos.google.cloud.memorystore.v1beta.ICreateInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1beta.ICreateInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.memorystore.v1beta.IInstance, + protos.google.cloud.memorystore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createInstance( - request: protos.google.cloud.memorystore.v1beta.ICreateInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1beta.ICreateInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.memorystore.v1beta.IInstance, + protos.google.cloud.memorystore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createInstance( - request?: protos.google.cloud.memorystore.v1beta.ICreateInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.memorystore.v1beta.ICreateInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.memorystore.v1beta.IInstance, + protos.google.cloud.memorystore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.memorystore.v1beta.IInstance, + protos.google.cloud.memorystore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.memorystore.v1beta.IInstance, + protos.google.cloud.memorystore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.memorystore.v1beta.IInstance, + protos.google.cloud.memorystore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createInstance request %j', request); - return this.innerApiCalls.createInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.memorystore.v1beta.IInstance, + protos.google.cloud.memorystore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createInstance()`. - * @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/v1beta/memorystore.create_instance.js - * region_tag:memorystore_v1beta_generated_Memorystore_CreateInstance_async - */ - async checkCreateInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createInstance()`. + * @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/v1beta/memorystore.create_instance.js + * region_tag:memorystore_v1beta_generated_Memorystore_CreateInstance_async + */ + async checkCreateInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.memorystore.v1beta.Instance, + protos.google.cloud.memorystore.v1beta.OperationMetadata + > + > { this._log.info('createInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.memorystore.v1beta.Instance, + protos.google.cloud.memorystore.v1beta.OperationMetadata + >; } -/** - * Updates the parameters of a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. The list of fields to be updated on the instance. At least one - * field must be specified. - * @param {google.cloud.memorystore.v1beta.Instance} request.instance - * Required. The instance to update. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1beta/memorystore.update_instance.js - * region_tag:memorystore_v1beta_generated_Memorystore_UpdateInstance_async - */ + /** + * Updates the parameters of a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. The list of fields to be updated on the instance. At least one + * field must be specified. + * @param {google.cloud.memorystore.v1beta.Instance} request.instance + * Required. The instance to update. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1beta/memorystore.update_instance.js + * region_tag:memorystore_v1beta_generated_Memorystore_UpdateInstance_async + */ updateInstance( - request?: protos.google.cloud.memorystore.v1beta.IUpdateInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memorystore.v1beta.IUpdateInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.memorystore.v1beta.IInstance, + protos.google.cloud.memorystore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateInstance( - request: protos.google.cloud.memorystore.v1beta.IUpdateInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1beta.IUpdateInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.memorystore.v1beta.IInstance, + protos.google.cloud.memorystore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateInstance( - request: protos.google.cloud.memorystore.v1beta.IUpdateInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1beta.IUpdateInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.memorystore.v1beta.IInstance, + protos.google.cloud.memorystore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateInstance( - request?: protos.google.cloud.memorystore.v1beta.IUpdateInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.memorystore.v1beta.IUpdateInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.memorystore.v1beta.IInstance, + protos.google.cloud.memorystore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.memorystore.v1beta.IInstance, + protos.google.cloud.memorystore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.memorystore.v1beta.IInstance, + protos.google.cloud.memorystore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'instance.name': request.instance!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'instance.name': request.instance!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.memorystore.v1beta.IInstance, + protos.google.cloud.memorystore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateInstance request %j', request); - return this.innerApiCalls.updateInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.memorystore.v1beta.IInstance, + protos.google.cloud.memorystore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateInstance()`. - * @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/v1beta/memorystore.update_instance.js - * region_tag:memorystore_v1beta_generated_Memorystore_UpdateInstance_async - */ - async checkUpdateInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateInstance()`. + * @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/v1beta/memorystore.update_instance.js + * region_tag:memorystore_v1beta_generated_Memorystore_UpdateInstance_async + */ + async checkUpdateInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.memorystore.v1beta.Instance, + protos.google.cloud.memorystore.v1beta.OperationMetadata + > + > { this._log.info('updateInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.memorystore.v1beta.Instance, + protos.google.cloud.memorystore.v1beta.OperationMetadata + >; } -/** - * Deletes a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the instance to delete. - * Format: projects/{project}/locations/{location}/instances/{instance} - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1beta/memorystore.delete_instance.js - * region_tag:memorystore_v1beta_generated_Memorystore_DeleteInstance_async - */ + /** + * Deletes a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the instance to delete. + * Format: projects/{project}/locations/{location}/instances/{instance} + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1beta/memorystore.delete_instance.js + * region_tag:memorystore_v1beta_generated_Memorystore_DeleteInstance_async + */ deleteInstance( - request?: protos.google.cloud.memorystore.v1beta.IDeleteInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.memorystore.v1beta.IDeleteInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memorystore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteInstance( - request: protos.google.cloud.memorystore.v1beta.IDeleteInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1beta.IDeleteInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memorystore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteInstance( - request: protos.google.cloud.memorystore.v1beta.IDeleteInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.memorystore.v1beta.IDeleteInstanceRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memorystore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteInstance( - request?: protos.google.cloud.memorystore.v1beta.IDeleteInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.memorystore.v1beta.IDeleteInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memorystore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memorystore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memorystore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memorystore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteInstance request %j', request); - return this.innerApiCalls.deleteInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memorystore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteInstance()`. - * @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/v1beta/memorystore.delete_instance.js - * region_tag:memorystore_v1beta_generated_Memorystore_DeleteInstance_async - */ - async checkDeleteInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteInstance()`. + * @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/v1beta/memorystore.delete_instance.js + * region_tag:memorystore_v1beta_generated_Memorystore_DeleteInstance_async + */ + async checkDeleteInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.memorystore.v1beta.OperationMetadata + > + > { this._log.info('deleteInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.memorystore.v1beta.OperationMetadata + >; } - /** - * Lists Instances in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent to list instances from. - * Format: projects/{project}/locations/{location} - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Expression for filtering results. - * @param {string} [request.orderBy] - * Optional. Sort results by a defined order. Supported values: "name", - * "create_time". - * @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 Array of {@link protos.google.cloud.memorystore.v1beta.Instance|Instance}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listInstancesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists Instances in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent to list instances from. + * Format: projects/{project}/locations/{location} + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Expression for filtering results. + * @param {string} [request.orderBy] + * Optional. Sort results by a defined order. Supported values: "name", + * "create_time". + * @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 Array of {@link protos.google.cloud.memorystore.v1beta.Instance|Instance}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listInstances( - request?: protos.google.cloud.memorystore.v1beta.IListInstancesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.memorystore.v1beta.IInstance[], - protos.google.cloud.memorystore.v1beta.IListInstancesRequest|null, - protos.google.cloud.memorystore.v1beta.IListInstancesResponse - ]>; + request?: protos.google.cloud.memorystore.v1beta.IListInstancesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.memorystore.v1beta.IInstance[], + protos.google.cloud.memorystore.v1beta.IListInstancesRequest | null, + protos.google.cloud.memorystore.v1beta.IListInstancesResponse, + ] + >; listInstances( - request: protos.google.cloud.memorystore.v1beta.IListInstancesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.memorystore.v1beta.IListInstancesRequest, - protos.google.cloud.memorystore.v1beta.IListInstancesResponse|null|undefined, - protos.google.cloud.memorystore.v1beta.IInstance>): void; + request: protos.google.cloud.memorystore.v1beta.IListInstancesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.memorystore.v1beta.IListInstancesRequest, + | protos.google.cloud.memorystore.v1beta.IListInstancesResponse + | null + | undefined, + protos.google.cloud.memorystore.v1beta.IInstance + >, + ): void; listInstances( - request: protos.google.cloud.memorystore.v1beta.IListInstancesRequest, - callback: PaginationCallback< - protos.google.cloud.memorystore.v1beta.IListInstancesRequest, - protos.google.cloud.memorystore.v1beta.IListInstancesResponse|null|undefined, - protos.google.cloud.memorystore.v1beta.IInstance>): void; + request: protos.google.cloud.memorystore.v1beta.IListInstancesRequest, + callback: PaginationCallback< + protos.google.cloud.memorystore.v1beta.IListInstancesRequest, + | protos.google.cloud.memorystore.v1beta.IListInstancesResponse + | null + | undefined, + protos.google.cloud.memorystore.v1beta.IInstance + >, + ): void; listInstances( - request?: protos.google.cloud.memorystore.v1beta.IListInstancesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.memorystore.v1beta.IListInstancesRequest, - protos.google.cloud.memorystore.v1beta.IListInstancesResponse|null|undefined, - protos.google.cloud.memorystore.v1beta.IInstance>, - callback?: PaginationCallback< + request?: protos.google.cloud.memorystore.v1beta.IListInstancesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.memorystore.v1beta.IListInstancesRequest, - protos.google.cloud.memorystore.v1beta.IListInstancesResponse|null|undefined, - protos.google.cloud.memorystore.v1beta.IInstance>): - Promise<[ - protos.google.cloud.memorystore.v1beta.IInstance[], - protos.google.cloud.memorystore.v1beta.IListInstancesRequest|null, - protos.google.cloud.memorystore.v1beta.IListInstancesResponse - ]>|void { + | protos.google.cloud.memorystore.v1beta.IListInstancesResponse + | null + | undefined, + protos.google.cloud.memorystore.v1beta.IInstance + >, + callback?: PaginationCallback< + protos.google.cloud.memorystore.v1beta.IListInstancesRequest, + | protos.google.cloud.memorystore.v1beta.IListInstancesResponse + | null + | undefined, + protos.google.cloud.memorystore.v1beta.IInstance + >, + ): Promise< + [ + protos.google.cloud.memorystore.v1beta.IInstance[], + protos.google.cloud.memorystore.v1beta.IListInstancesRequest | null, + protos.google.cloud.memorystore.v1beta.IListInstancesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.memorystore.v1beta.IListInstancesRequest, - protos.google.cloud.memorystore.v1beta.IListInstancesResponse|null|undefined, - protos.google.cloud.memorystore.v1beta.IInstance>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.memorystore.v1beta.IListInstancesRequest, + | protos.google.cloud.memorystore.v1beta.IListInstancesResponse + | null + | undefined, + protos.google.cloud.memorystore.v1beta.IInstance + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listInstances values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1175,123 +1628,128 @@ export class MemorystoreClient { this._log.info('listInstances request %j', request); return this.innerApiCalls .listInstances(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.memorystore.v1beta.IInstance[], - protos.google.cloud.memorystore.v1beta.IListInstancesRequest|null, - protos.google.cloud.memorystore.v1beta.IListInstancesResponse - ]) => { - this._log.info('listInstances values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.memorystore.v1beta.IInstance[], + protos.google.cloud.memorystore.v1beta.IListInstancesRequest | null, + protos.google.cloud.memorystore.v1beta.IListInstancesResponse, + ]) => { + this._log.info('listInstances values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listInstances`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent to list instances from. - * Format: projects/{project}/locations/{location} - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Expression for filtering results. - * @param {string} [request.orderBy] - * Optional. Sort results by a defined order. Supported values: "name", - * "create_time". - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.memorystore.v1beta.Instance|Instance} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listInstancesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listInstances`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent to list instances from. + * Format: projects/{project}/locations/{location} + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Expression for filtering results. + * @param {string} [request.orderBy] + * Optional. Sort results by a defined order. Supported values: "name", + * "create_time". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.memorystore.v1beta.Instance|Instance} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listInstancesStream( - request?: protos.google.cloud.memorystore.v1beta.IListInstancesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.memorystore.v1beta.IListInstancesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listInstances']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listInstances stream %j', request); return this.descriptors.page.listInstances.createStream( this.innerApiCalls.listInstances as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listInstances`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent to list instances from. - * Format: projects/{project}/locations/{location} - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Expression for filtering results. - * @param {string} [request.orderBy] - * Optional. Sort results by a defined order. Supported values: "name", - * "create_time". - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.memorystore.v1beta.Instance|Instance}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/memorystore.list_instances.js - * region_tag:memorystore_v1beta_generated_Memorystore_ListInstances_async - */ + /** + * Equivalent to `listInstances`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent to list instances from. + * Format: projects/{project}/locations/{location} + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Expression for filtering results. + * @param {string} [request.orderBy] + * Optional. Sort results by a defined order. Supported values: "name", + * "create_time". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.memorystore.v1beta.Instance|Instance}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/memorystore.list_instances.js + * region_tag:memorystore_v1beta_generated_Memorystore_ListInstances_async + */ listInstancesAsync( - request?: protos.google.cloud.memorystore.v1beta.IListInstancesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.memorystore.v1beta.IListInstancesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listInstances']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listInstances iterate %j', request); return this.descriptors.page.listInstances.asyncIterate( this.innerApiCalls['listInstances'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** + + /** * Gets information about a location. * * @param {Object} request @@ -1326,12 +1784,11 @@ export class MemorystoreClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -1364,12 +1821,12 @@ export class MemorystoreClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -1412,22 +1869,22 @@ export class MemorystoreClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -1462,15 +1919,15 @@ export class MemorystoreClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - 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 ?? '', - }); + 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 ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -1504,7 +1961,7 @@ export class MemorystoreClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -1517,25 +1974,24 @@ export class MemorystoreClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -1574,22 +2030,22 @@ export class MemorystoreClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -1605,7 +2061,7 @@ export class MemorystoreClient { * @param {string} ca_pool * @returns {string} Resource name string. */ - caPoolPath(project:string,location:string,caPool:string) { + caPoolPath(project: string, location: string, caPool: string) { return this.pathTemplates.caPoolPathTemplate.render({ project: project, location: location, @@ -1654,7 +2110,11 @@ export class MemorystoreClient { * @param {string} instance * @returns {string} Resource name string. */ - certificateAuthorityPath(project:string,location:string,instance:string) { + certificateAuthorityPath( + project: string, + location: string, + instance: string, + ) { return this.pathTemplates.certificateAuthorityPathTemplate.render({ project: project, location: location, @@ -1670,7 +2130,9 @@ export class MemorystoreClient { * @returns {string} A string representing the project. */ matchProjectFromCertificateAuthorityName(certificateAuthorityName: string) { - return this.pathTemplates.certificateAuthorityPathTemplate.match(certificateAuthorityName).project; + return this.pathTemplates.certificateAuthorityPathTemplate.match( + certificateAuthorityName, + ).project; } /** @@ -1681,7 +2143,9 @@ export class MemorystoreClient { * @returns {string} A string representing the location. */ matchLocationFromCertificateAuthorityName(certificateAuthorityName: string) { - return this.pathTemplates.certificateAuthorityPathTemplate.match(certificateAuthorityName).location; + return this.pathTemplates.certificateAuthorityPathTemplate.match( + certificateAuthorityName, + ).location; } /** @@ -1692,7 +2156,9 @@ export class MemorystoreClient { * @returns {string} A string representing the instance. */ matchInstanceFromCertificateAuthorityName(certificateAuthorityName: string) { - return this.pathTemplates.certificateAuthorityPathTemplate.match(certificateAuthorityName).instance; + return this.pathTemplates.certificateAuthorityPathTemplate.match( + certificateAuthorityName, + ).instance; } /** @@ -1703,7 +2169,7 @@ export class MemorystoreClient { * @param {string} forwarding_rule * @returns {string} Resource name string. */ - forwardingRulePath(project:string,region:string,forwardingRule:string) { + forwardingRulePath(project: string, region: string, forwardingRule: string) { return this.pathTemplates.forwardingRulePathTemplate.render({ project: project, region: region, @@ -1719,7 +2185,9 @@ export class MemorystoreClient { * @returns {string} A string representing the project. */ matchProjectFromForwardingRuleName(forwardingRuleName: string) { - return this.pathTemplates.forwardingRulePathTemplate.match(forwardingRuleName).project; + return this.pathTemplates.forwardingRulePathTemplate.match( + forwardingRuleName, + ).project; } /** @@ -1730,7 +2198,9 @@ export class MemorystoreClient { * @returns {string} A string representing the region. */ matchRegionFromForwardingRuleName(forwardingRuleName: string) { - return this.pathTemplates.forwardingRulePathTemplate.match(forwardingRuleName).region; + return this.pathTemplates.forwardingRulePathTemplate.match( + forwardingRuleName, + ).region; } /** @@ -1741,7 +2211,9 @@ export class MemorystoreClient { * @returns {string} A string representing the forwarding_rule. */ matchForwardingRuleFromForwardingRuleName(forwardingRuleName: string) { - return this.pathTemplates.forwardingRulePathTemplate.match(forwardingRuleName).forwarding_rule; + return this.pathTemplates.forwardingRulePathTemplate.match( + forwardingRuleName, + ).forwarding_rule; } /** @@ -1752,7 +2224,7 @@ export class MemorystoreClient { * @param {string} instance * @returns {string} Resource name string. */ - instancePath(project:string,location:string,instance:string) { + instancePath(project: string, location: string, instance: string) { return this.pathTemplates.instancePathTemplate.render({ project: project, location: location, @@ -1800,7 +2272,7 @@ export class MemorystoreClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -1836,7 +2308,7 @@ export class MemorystoreClient { * @param {string} network * @returns {string} Resource name string. */ - networkPath(project:string,network:string) { + networkPath(project: string, network: string) { return this.pathTemplates.networkPathTemplate.render({ project: project, network: network, @@ -1871,7 +2343,7 @@ export class MemorystoreClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -1896,7 +2368,11 @@ export class MemorystoreClient { * @param {string} service_attachment * @returns {string} Resource name string. */ - serviceAttachmentPath(project:string,region:string,serviceAttachment:string) { + serviceAttachmentPath( + project: string, + region: string, + serviceAttachment: string, + ) { return this.pathTemplates.serviceAttachmentPathTemplate.render({ project: project, region: region, @@ -1912,7 +2388,9 @@ export class MemorystoreClient { * @returns {string} A string representing the project. */ matchProjectFromServiceAttachmentName(serviceAttachmentName: string) { - return this.pathTemplates.serviceAttachmentPathTemplate.match(serviceAttachmentName).project; + return this.pathTemplates.serviceAttachmentPathTemplate.match( + serviceAttachmentName, + ).project; } /** @@ -1923,7 +2401,9 @@ export class MemorystoreClient { * @returns {string} A string representing the region. */ matchRegionFromServiceAttachmentName(serviceAttachmentName: string) { - return this.pathTemplates.serviceAttachmentPathTemplate.match(serviceAttachmentName).region; + return this.pathTemplates.serviceAttachmentPathTemplate.match( + serviceAttachmentName, + ).region; } /** @@ -1933,8 +2413,12 @@ export class MemorystoreClient { * A fully-qualified path representing ServiceAttachment resource. * @returns {string} A string representing the service_attachment. */ - matchServiceAttachmentFromServiceAttachmentName(serviceAttachmentName: string) { - return this.pathTemplates.serviceAttachmentPathTemplate.match(serviceAttachmentName).service_attachment; + matchServiceAttachmentFromServiceAttachmentName( + serviceAttachmentName: string, + ) { + return this.pathTemplates.serviceAttachmentPathTemplate.match( + serviceAttachmentName, + ).service_attachment; } /** @@ -1944,11 +2428,13 @@ export class MemorystoreClient { * @param {string} location * @returns {string} Resource name string. */ - sharedRegionalCertificateAuthorityPath(project:string,location:string) { - return this.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate.render({ - project: project, - location: location, - }); + sharedRegionalCertificateAuthorityPath(project: string, location: string) { + return this.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate.render( + { + project: project, + location: location, + }, + ); } /** @@ -1958,8 +2444,12 @@ export class MemorystoreClient { * A fully-qualified path representing SharedRegionalCertificateAuthority resource. * @returns {string} A string representing the project. */ - matchProjectFromSharedRegionalCertificateAuthorityName(sharedRegionalCertificateAuthorityName: string) { - return this.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate.match(sharedRegionalCertificateAuthorityName).project; + matchProjectFromSharedRegionalCertificateAuthorityName( + sharedRegionalCertificateAuthorityName: string, + ) { + return this.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate.match( + sharedRegionalCertificateAuthorityName, + ).project; } /** @@ -1969,8 +2459,12 @@ export class MemorystoreClient { * A fully-qualified path representing SharedRegionalCertificateAuthority resource. * @returns {string} A string representing the location. */ - matchLocationFromSharedRegionalCertificateAuthorityName(sharedRegionalCertificateAuthorityName: string) { - return this.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate.match(sharedRegionalCertificateAuthorityName).location; + matchLocationFromSharedRegionalCertificateAuthorityName( + sharedRegionalCertificateAuthorityName: string, + ) { + return this.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate.match( + sharedRegionalCertificateAuthorityName, + ).location; } /** @@ -1981,14 +2475,16 @@ export class MemorystoreClient { */ close(): Promise { if (this.memorystoreStub && !this._terminated) { - return this.memorystoreStub.then(stub => { + return this.memorystoreStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.locationsClient.close().catch(err => {throw err}); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-memorystore/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-memorystore/system-test/fixtures/sample/src/index.ts index 2b2ec5a9371b..c932b76577d4 100644 --- a/packages/google-cloud-memorystore/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-memorystore/system-test/fixtures/sample/src/index.ts @@ -16,7 +16,7 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {MemorystoreClient} from '@google-cloud/memorystore'; +import { MemorystoreClient } from '@google-cloud/memorystore'; // check that the client class type name can be used function doStuffWithMemorystoreClient(client: MemorystoreClient) { diff --git a/packages/google-cloud-memorystore/system-test/install.ts b/packages/google-cloud-memorystore/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-memorystore/system-test/install.ts +++ b/packages/google-cloud-memorystore/system-test/install.ts @@ -16,34 +16,36 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {packNTest} from 'pack-n-play'; -import {readFileSync} from 'fs'; -import {describe, it} from 'mocha'; +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; +import { describe, it } from 'mocha'; describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { + it('TypeScript code', async function () { this.timeout(300000); const options = { packageDir: process.cwd(), sample: { description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } + ts: readFileSync( + './system-test/fixtures/sample/src/index.ts', + ).toString(), + }, }; await packNTest(options); }); - it('JavaScript code', async function() { + it('JavaScript code', async function () { this.timeout(300000); const options = { packageDir: process.cwd(), sample: { description: 'JavaScript user can use the library', - cjs: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } + cjs: readFileSync( + './system-test/fixtures/sample/src/index.js', + ).toString(), + }, }; await packNTest(options); }); - }); diff --git a/packages/google-cloud-memorystore/test/gapic_memorystore_v1.ts b/packages/google-cloud-memorystore/test/gapic_memorystore_v1.ts index 00f5345dd201..9cb0c331cdc9 100644 --- a/packages/google-cloud-memorystore/test/gapic_memorystore_v1.ts +++ b/packages/google-cloud-memorystore/test/gapic_memorystore_v1.ts @@ -19,3630 +19,4726 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as memorystoreModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1.MemorystoreClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new memorystoreModule.v1.MemorystoreClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'memorystore.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new memorystoreModule.v1.MemorystoreClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = memorystoreModule.v1.MemorystoreClient.servicePath; - assert.strictEqual(servicePath, 'memorystore.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = memorystoreModule.v1.MemorystoreClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'memorystore.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new memorystoreModule.v1.MemorystoreClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'memorystore.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new memorystoreModule.v1.MemorystoreClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'memorystore.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new memorystoreModule.v1.MemorystoreClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'memorystore.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new memorystoreModule.v1.MemorystoreClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'memorystore.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new memorystoreModule.v1.MemorystoreClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = memorystoreModule.v1.MemorystoreClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new memorystoreModule.v1.MemorystoreClient(); - assert(client); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new memorystoreModule.v1.MemorystoreClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'memorystore.googleapis.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - fallback: true, - }); - assert(client); - }); + it('has universeDomain', () => { + const client = new memorystoreModule.v1.MemorystoreClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.memorystoreStub, undefined); - await client.initialize(); - assert(client.memorystoreStub); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = memorystoreModule.v1.MemorystoreClient.servicePath; + assert.strictEqual(servicePath, 'memorystore.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = memorystoreModule.v1.MemorystoreClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'memorystore.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'memorystore.example.com'); + }); - it('has close method for the initialized client', done => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.memorystoreStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'memorystore.example.com'); + }); - it('has close method for the non-initialized client', done => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.memorystoreStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new memorystoreModule.v1.MemorystoreClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'memorystore.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new memorystoreModule.v1.MemorystoreClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'memorystore.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new memorystoreModule.v1.MemorystoreClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); }); - describe('getInstance', () => { - it('invokes getInstance without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.memorystore.v1.Instance() - ); - client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); - const [response] = await client.getInstance(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has port', () => { + const port = memorystoreModule.v1.MemorystoreClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('invokes getInstance without error using callback', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.memorystore.v1.Instance() - ); - client.innerApiCalls.getInstance = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getInstance( - request, - (err?: Error|null, result?: protos.google.cloud.memorystore.v1.IInstance|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('should create a client with no option', () => { + const client = new memorystoreModule.v1.MemorystoreClient(); + assert(client); + }); - it('invokes getInstance with error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getInstance = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('should create a client with gRPC fallback', () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + fallback: true, + }); + assert(client); + }); - it('invokes getInstance with closed client', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getInstance(request), expectedError); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.memorystoreStub, undefined); + await client.initialize(); + assert(client.memorystoreStub); }); - describe('getCertificateAuthority', () => { - it('invokes getCertificateAuthority without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.GetCertificateAuthorityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.GetCertificateAuthorityRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.memorystore.v1.CertificateAuthority() - ); - client.innerApiCalls.getCertificateAuthority = stubSimpleCall(expectedResponse); - const [response] = await client.getCertificateAuthority(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCertificateAuthority as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCertificateAuthority as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the initialized client', (done) => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.memorystoreStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getCertificateAuthority without error using callback', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.GetCertificateAuthorityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.GetCertificateAuthorityRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.memorystore.v1.CertificateAuthority() - ); - client.innerApiCalls.getCertificateAuthority = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getCertificateAuthority( - request, - (err?: Error|null, result?: protos.google.cloud.memorystore.v1.ICertificateAuthority|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCertificateAuthority as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCertificateAuthority as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the non-initialized client', (done) => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.memorystoreStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getCertificateAuthority with error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.GetCertificateAuthorityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.GetCertificateAuthorityRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getCertificateAuthority = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getCertificateAuthority(request), expectedError); - const actualRequest = (client.innerApiCalls.getCertificateAuthority as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCertificateAuthority as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('invokes getCertificateAuthority with closed client', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.GetCertificateAuthorityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.GetCertificateAuthorityRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getCertificateAuthority(request), expectedError); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getInstance', () => { + it('invokes getInstance without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.memorystore.v1.Instance(), + ); + client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); + const [response] = await client.getInstance(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getSharedRegionalCertificateAuthority', () => { - it('invokes getSharedRegionalCertificateAuthority without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.GetSharedRegionalCertificateAuthorityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.GetSharedRegionalCertificateAuthorityRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.memorystore.v1.SharedRegionalCertificateAuthority() - ); - client.innerApiCalls.getSharedRegionalCertificateAuthority = stubSimpleCall(expectedResponse); - const [response] = await client.getSharedRegionalCertificateAuthority(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSharedRegionalCertificateAuthority as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSharedRegionalCertificateAuthority as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getInstance without error using callback', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.memorystore.v1.Instance(), + ); + client.innerApiCalls.getInstance = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getInstance( + request, + ( + err?: Error | null, + result?: protos.google.cloud.memorystore.v1.IInstance | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getSharedRegionalCertificateAuthority without error using callback', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.GetSharedRegionalCertificateAuthorityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.GetSharedRegionalCertificateAuthorityRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.memorystore.v1.SharedRegionalCertificateAuthority() - ); - client.innerApiCalls.getSharedRegionalCertificateAuthority = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getSharedRegionalCertificateAuthority( - request, - (err?: Error|null, result?: protos.google.cloud.memorystore.v1.ISharedRegionalCertificateAuthority|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSharedRegionalCertificateAuthority as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSharedRegionalCertificateAuthority as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getInstance with error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getInstance = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getSharedRegionalCertificateAuthority with error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.GetSharedRegionalCertificateAuthorityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.GetSharedRegionalCertificateAuthorityRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getSharedRegionalCertificateAuthority = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getSharedRegionalCertificateAuthority(request), expectedError); - const actualRequest = (client.innerApiCalls.getSharedRegionalCertificateAuthority as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSharedRegionalCertificateAuthority as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getInstance with closed client', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getInstance(request), expectedError); + }); + }); + + describe('getCertificateAuthority', () => { + it('invokes getCertificateAuthority without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.GetCertificateAuthorityRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.GetCertificateAuthorityRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.memorystore.v1.CertificateAuthority(), + ); + client.innerApiCalls.getCertificateAuthority = + stubSimpleCall(expectedResponse); + const [response] = await client.getCertificateAuthority(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCertificateAuthority as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCertificateAuthority as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getSharedRegionalCertificateAuthority with closed client', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.GetSharedRegionalCertificateAuthorityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.GetSharedRegionalCertificateAuthorityRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getSharedRegionalCertificateAuthority(request), expectedError); - }); + it('invokes getCertificateAuthority without error using callback', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.GetCertificateAuthorityRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.GetCertificateAuthorityRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.memorystore.v1.CertificateAuthority(), + ); + client.innerApiCalls.getCertificateAuthority = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCertificateAuthority( + request, + ( + err?: Error | null, + result?: protos.google.cloud.memorystore.v1.ICertificateAuthority | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCertificateAuthority as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCertificateAuthority as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getBackupCollection', () => { - it('invokes getBackupCollection without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.GetBackupCollectionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.GetBackupCollectionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.memorystore.v1.BackupCollection() - ); - client.innerApiCalls.getBackupCollection = stubSimpleCall(expectedResponse); - const [response] = await client.getBackupCollection(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getBackupCollection as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBackupCollection as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getCertificateAuthority with error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.GetCertificateAuthorityRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.GetCertificateAuthorityRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getCertificateAuthority = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getCertificateAuthority(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.getCertificateAuthority as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCertificateAuthority as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getBackupCollection without error using callback', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.GetBackupCollectionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.GetBackupCollectionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.memorystore.v1.BackupCollection() - ); - client.innerApiCalls.getBackupCollection = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getBackupCollection( - request, - (err?: Error|null, result?: protos.google.cloud.memorystore.v1.IBackupCollection|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getBackupCollection as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBackupCollection as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getCertificateAuthority with closed client', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.GetCertificateAuthorityRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.GetCertificateAuthorityRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.getCertificateAuthority(request), + expectedError, + ); + }); + }); + + describe('getSharedRegionalCertificateAuthority', () => { + it('invokes getSharedRegionalCertificateAuthority without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.GetSharedRegionalCertificateAuthorityRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.GetSharedRegionalCertificateAuthorityRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.memorystore.v1.SharedRegionalCertificateAuthority(), + ); + client.innerApiCalls.getSharedRegionalCertificateAuthority = + stubSimpleCall(expectedResponse); + const [response] = + await client.getSharedRegionalCertificateAuthority(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getSharedRegionalCertificateAuthority as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSharedRegionalCertificateAuthority as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getBackupCollection with error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.GetBackupCollectionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.GetBackupCollectionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getBackupCollection = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getBackupCollection(request), expectedError); - const actualRequest = (client.innerApiCalls.getBackupCollection as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBackupCollection as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getSharedRegionalCertificateAuthority without error using callback', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.GetSharedRegionalCertificateAuthorityRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.GetSharedRegionalCertificateAuthorityRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.memorystore.v1.SharedRegionalCertificateAuthority(), + ); + client.innerApiCalls.getSharedRegionalCertificateAuthority = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getSharedRegionalCertificateAuthority( + request, + ( + err?: Error | null, + result?: protos.google.cloud.memorystore.v1.ISharedRegionalCertificateAuthority | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getSharedRegionalCertificateAuthority as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSharedRegionalCertificateAuthority as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getBackupCollection with closed client', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.GetBackupCollectionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.GetBackupCollectionRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getBackupCollection(request), expectedError); - }); + it('invokes getSharedRegionalCertificateAuthority with error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.GetSharedRegionalCertificateAuthorityRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.GetSharedRegionalCertificateAuthorityRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getSharedRegionalCertificateAuthority = + stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getSharedRegionalCertificateAuthority(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.getSharedRegionalCertificateAuthority as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSharedRegionalCertificateAuthority as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getBackup', () => { - it('invokes getBackup without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.GetBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.memorystore.v1.Backup() - ); - client.innerApiCalls.getBackup = stubSimpleCall(expectedResponse); - const [response] = await client.getBackup(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getSharedRegionalCertificateAuthority with closed client', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.GetSharedRegionalCertificateAuthorityRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.GetSharedRegionalCertificateAuthorityRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.getSharedRegionalCertificateAuthority(request), + expectedError, + ); + }); + }); + + describe('getBackupCollection', () => { + it('invokes getBackupCollection without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.GetBackupCollectionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.GetBackupCollectionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.memorystore.v1.BackupCollection(), + ); + client.innerApiCalls.getBackupCollection = + stubSimpleCall(expectedResponse); + const [response] = await client.getBackupCollection(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getBackupCollection as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBackupCollection as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getBackup without error using callback', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.GetBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.memorystore.v1.Backup() - ); - client.innerApiCalls.getBackup = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getBackup( - request, - (err?: Error|null, result?: protos.google.cloud.memorystore.v1.IBackup|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getBackupCollection without error using callback', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.GetBackupCollectionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.GetBackupCollectionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.memorystore.v1.BackupCollection(), + ); + client.innerApiCalls.getBackupCollection = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getBackupCollection( + request, + ( + err?: Error | null, + result?: protos.google.cloud.memorystore.v1.IBackupCollection | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getBackupCollection as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBackupCollection as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getBackup with error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.GetBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getBackup = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getBackup(request), expectedError); - const actualRequest = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getBackupCollection with error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.GetBackupCollectionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.GetBackupCollectionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getBackupCollection = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getBackupCollection(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getBackupCollection as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBackupCollection as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getBackup with closed client', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.GetBackupRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getBackup(request), expectedError); - }); + it('invokes getBackupCollection with closed client', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.GetBackupCollectionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.GetBackupCollectionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getBackupCollection(request), expectedError); + }); + }); + + describe('getBackup', () => { + it('invokes getBackup without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.GetBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.GetBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.memorystore.v1.Backup(), + ); + client.innerApiCalls.getBackup = stubSimpleCall(expectedResponse); + const [response] = await client.getBackup(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createInstance', () => { - it('invokes createInstance without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.createInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getBackup without error using callback', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.GetBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.GetBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.memorystore.v1.Backup(), + ); + client.innerApiCalls.getBackup = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getBackup( + request, + ( + err?: Error | null, + result?: protos.google.cloud.memorystore.v1.IBackup | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createInstance without error using callback', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getBackup with error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.GetBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.GetBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getBackup = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getBackup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createInstance with call error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getBackup with closed client', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.GetBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.GetBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getBackup(request), expectedError); + }); + }); + + describe('createInstance', () => { + it('invokes createInstance without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.CreateInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.CreateInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createInstance with LRO error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createInstance without error using callback', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.CreateInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.CreateInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateInstanceProgress without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createInstance with call error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.CreateInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.CreateInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateInstanceProgress with error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createInstance with LRO error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.CreateInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.CreateInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateInstance', () => { - it('invokes updateInstance without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateInstanceProgress without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateInstance without error using callback', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateInstanceProgress with error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateInstance', () => { + it('invokes updateInstance without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.UpdateInstanceRequest(), + ); + request.instance ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.UpdateInstanceRequest', + ['instance', 'name'], + ); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateInstance with call error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateInstance without error using callback', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.UpdateInstanceRequest(), + ); + request.instance ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.UpdateInstanceRequest', + ['instance', 'name'], + ); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateInstance with LRO error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateInstance with call error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.UpdateInstanceRequest(), + ); + request.instance ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.UpdateInstanceRequest', + ['instance', 'name'], + ); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateInstanceProgress without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateInstance with LRO error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.UpdateInstanceRequest(), + ); + request.instance ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.UpdateInstanceRequest', + ['instance', 'name'], + ); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateInstanceProgress with error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpdateInstanceProgress without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('deleteInstance', () => { - it('invokes deleteInstance without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateInstanceProgress with error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteInstance', () => { + it('invokes deleteInstance without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.DeleteInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.DeleteInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteInstance without error using callback', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteInstance without error using callback', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.DeleteInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.DeleteInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memorystore.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memorystore.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteInstance with call error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteInstance with call error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.DeleteInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.DeleteInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteInstance with LRO error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteInstance with LRO error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.DeleteInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.DeleteInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteInstanceProgress without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkDeleteInstanceProgress without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteInstanceProgress with error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteInstanceProgress with error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('rescheduleMaintenance', () => { + it('invokes rescheduleMaintenance without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.RescheduleMaintenanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.RescheduleMaintenanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.rescheduleMaintenance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.rescheduleMaintenance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rescheduleMaintenance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rescheduleMaintenance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('rescheduleMaintenance', () => { - it('invokes rescheduleMaintenance without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.RescheduleMaintenanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.RescheduleMaintenanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.rescheduleMaintenance = stubLongRunningCall(expectedResponse); - const [operation] = await client.rescheduleMaintenance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes rescheduleMaintenance without error using callback', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.RescheduleMaintenanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.RescheduleMaintenanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.rescheduleMaintenance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rescheduleMaintenance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rescheduleMaintenance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rescheduleMaintenance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes rescheduleMaintenance without error using callback', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.RescheduleMaintenanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.RescheduleMaintenanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.rescheduleMaintenance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rescheduleMaintenance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes rescheduleMaintenance with call error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.RescheduleMaintenanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.RescheduleMaintenanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rescheduleMaintenance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.rescheduleMaintenance(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.rescheduleMaintenance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rescheduleMaintenance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes rescheduleMaintenance with call error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.RescheduleMaintenanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.RescheduleMaintenanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rescheduleMaintenance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.rescheduleMaintenance(request), expectedError); - const actualRequest = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes rescheduleMaintenance with LRO error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.RescheduleMaintenanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.RescheduleMaintenanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rescheduleMaintenance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.rescheduleMaintenance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.rescheduleMaintenance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rescheduleMaintenance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes rescheduleMaintenance with LRO error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.RescheduleMaintenanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.RescheduleMaintenanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rescheduleMaintenance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.rescheduleMaintenance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rescheduleMaintenance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRescheduleMaintenanceProgress without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkRescheduleMaintenanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkRescheduleMaintenanceProgress without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkRescheduleMaintenanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkRescheduleMaintenanceProgress with error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkRescheduleMaintenanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteBackup', () => { + it('invokes deleteBackup without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.DeleteBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.DeleteBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteBackup = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteBackup(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRescheduleMaintenanceProgress with error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRescheduleMaintenanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteBackup without error using callback', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.DeleteBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.DeleteBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteBackup = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteBackup( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memorystore.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memorystore.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteBackup', () => { - it('invokes deleteBackup without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteBackup = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteBackup(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteBackup with call error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.DeleteBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.DeleteBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteBackup = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteBackup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteBackup without error using callback', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteBackup = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteBackup( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteBackup with LRO error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.DeleteBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.DeleteBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteBackup = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteBackup(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteBackup with call error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteBackup = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteBackup(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteBackupProgress without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteBackupProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteBackup with LRO error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteBackup = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteBackup(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteBackupProgress with error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkDeleteBackupProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('exportBackup', () => { + it('invokes exportBackup without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.ExportBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.ExportBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.exportBackup = stubLongRunningCall(expectedResponse); + const [operation] = await client.exportBackup(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.exportBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteBackupProgress without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteBackupProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes exportBackup without error using callback', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.ExportBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.ExportBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.exportBackup = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.exportBackup( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.memorystore.v1.IBackup, + protos.google.cloud.memorystore.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.memorystore.v1.IBackup, + protos.google.cloud.memorystore.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.exportBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteBackupProgress with error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteBackupProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes exportBackup with call error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.ExportBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.ExportBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.exportBackup = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.exportBackup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.exportBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('exportBackup', () => { - it('invokes exportBackup without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.ExportBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.ExportBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.exportBackup = stubLongRunningCall(expectedResponse); - const [operation] = await client.exportBackup(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.exportBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes exportBackup with LRO error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.ExportBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.ExportBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.exportBackup = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.exportBackup(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.exportBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes exportBackup without error using callback', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.ExportBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.ExportBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.exportBackup = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.exportBackup( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.exportBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkExportBackupProgress without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkExportBackupProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes exportBackup with call error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.ExportBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.ExportBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.exportBackup = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.exportBackup(request), expectedError); - const actualRequest = (client.innerApiCalls.exportBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkExportBackupProgress with error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkExportBackupProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('backupInstance', () => { + it('invokes backupInstance without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.BackupInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.BackupInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.backupInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.backupInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.backupInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.backupInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes exportBackup with LRO error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.ExportBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.ExportBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.exportBackup = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.exportBackup(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.exportBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes backupInstance without error using callback', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.BackupInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.BackupInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.backupInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.backupInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.memorystore.v1.IInstance, + protos.google.cloud.memorystore.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.backupInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.backupInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkExportBackupProgress without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkExportBackupProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes backupInstance with call error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.BackupInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.BackupInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.backupInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.backupInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.backupInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.backupInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkExportBackupProgress with error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkExportBackupProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes backupInstance with LRO error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.BackupInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.BackupInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.backupInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.backupInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.backupInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.backupInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('backupInstance', () => { - it('invokes backupInstance without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.BackupInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.BackupInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.backupInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.backupInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.backupInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.backupInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkBackupInstanceProgress without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkBackupInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes backupInstance without error using callback', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.BackupInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.BackupInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.backupInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.backupInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.backupInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.backupInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkBackupInstanceProgress with error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkBackupInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listInstances', () => { + it('invokes listInstances without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.memorystore.v1.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.memorystore.v1.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.memorystore.v1.Instance(), + ), + ]; + client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); + const [response] = await client.listInstances(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes backupInstance with call error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.BackupInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.BackupInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.backupInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.backupInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.backupInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.backupInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listInstances without error using callback', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.memorystore.v1.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.memorystore.v1.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.memorystore.v1.Instance(), + ), + ]; + client.innerApiCalls.listInstances = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listInstances( + request, + ( + err?: Error | null, + result?: protos.google.cloud.memorystore.v1.IInstance[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes backupInstance with LRO error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.BackupInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.BackupInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.backupInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.backupInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.backupInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.backupInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listInstances with error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listInstances = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listInstances(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkBackupInstanceProgress without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkBackupInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + it('invokes listInstancesStream without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.memorystore.v1.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.memorystore.v1.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.memorystore.v1.Instance(), + ), + ]; + client.descriptors.page.listInstances.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.memorystore.v1.Instance[] = []; + stream.on( + 'data', + (response: protos.google.cloud.memorystore.v1.Instance) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes checkBackupInstanceProgress with error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkBackupInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); + stream.on('error', (err: Error) => { + reject(err); }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listInstances, request), + ); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('listInstances', () => { - it('invokes listInstances without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.memorystore.v1.Instance()), - generateSampleMessage(new protos.google.cloud.memorystore.v1.Instance()), - generateSampleMessage(new protos.google.cloud.memorystore.v1.Instance()), - ]; - client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); - const [response] = await client.listInstances(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listInstancesStream with error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstances.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.memorystore.v1.Instance[] = []; + stream.on( + 'data', + (response: protos.google.cloud.memorystore.v1.Instance) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listInstances without error using callback', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.memorystore.v1.Instance()), - generateSampleMessage(new protos.google.cloud.memorystore.v1.Instance()), - generateSampleMessage(new protos.google.cloud.memorystore.v1.Instance()), - ]; - client.innerApiCalls.listInstances = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listInstances( - request, - (err?: Error|null, result?: protos.google.cloud.memorystore.v1.IInstance[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInstances with error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listInstances = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listInstances(request), expectedError); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + stream.on('error', (err: Error) => { + reject(err); }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listInstances, request), + ); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listInstancesStream without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.memorystore.v1.Instance()), - generateSampleMessage(new protos.google.cloud.memorystore.v1.Instance()), - generateSampleMessage(new protos.google.cloud.memorystore.v1.Instance()), - ]; - client.descriptors.page.listInstances.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listInstancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.memorystore.v1.Instance[] = []; - stream.on('data', (response: protos.google.cloud.memorystore.v1.Instance) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); - assert( - (client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listInstances without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.memorystore.v1.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.memorystore.v1.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.memorystore.v1.Instance(), + ), + ]; + client.descriptors.page.listInstances.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.memorystore.v1.IInstance[] = []; + const iterable = client.listInstancesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listInstances.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listInstancesStream with error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstances.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listInstancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.memorystore.v1.Instance[] = []; - stream.on('data', (response: protos.google.cloud.memorystore.v1.Instance) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); - assert( - (client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listInstances with error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstances.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listInstancesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.memorystore.v1.IInstance[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listInstances.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listBackupCollections', () => { + it('invokes listBackupCollections without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.ListBackupCollectionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.ListBackupCollectionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.memorystore.v1.BackupCollection(), + ), + generateSampleMessage( + new protos.google.cloud.memorystore.v1.BackupCollection(), + ), + generateSampleMessage( + new protos.google.cloud.memorystore.v1.BackupCollection(), + ), + ]; + client.innerApiCalls.listBackupCollections = + stubSimpleCall(expectedResponse); + const [response] = await client.listBackupCollections(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listBackupCollections as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBackupCollections as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listInstances without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.memorystore.v1.Instance()), - generateSampleMessage(new protos.google.cloud.memorystore.v1.Instance()), - generateSampleMessage(new protos.google.cloud.memorystore.v1.Instance()), - ]; - client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.memorystore.v1.IInstance[] = []; - const iterable = client.listInstancesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listBackupCollections without error using callback', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.ListBackupCollectionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.ListBackupCollectionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.memorystore.v1.BackupCollection(), + ), + generateSampleMessage( + new protos.google.cloud.memorystore.v1.BackupCollection(), + ), + generateSampleMessage( + new protos.google.cloud.memorystore.v1.BackupCollection(), + ), + ]; + client.innerApiCalls.listBackupCollections = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listBackupCollections( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.memorystore.v1.IBackupCollection[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listBackupCollections as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBackupCollections as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listInstances with error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listInstancesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.memorystore.v1.IInstance[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listBackupCollections with error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.ListBackupCollectionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.ListBackupCollectionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listBackupCollections = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listBackupCollections(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listBackupCollections as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBackupCollections as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listBackupCollections', () => { - it('invokes listBackupCollections without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.ListBackupCollectionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.ListBackupCollectionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.memorystore.v1.BackupCollection()), - generateSampleMessage(new protos.google.cloud.memorystore.v1.BackupCollection()), - generateSampleMessage(new protos.google.cloud.memorystore.v1.BackupCollection()), - ]; - client.innerApiCalls.listBackupCollections = stubSimpleCall(expectedResponse); - const [response] = await client.listBackupCollections(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listBackupCollections as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBackupCollections as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listBackupCollectionsStream without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.ListBackupCollectionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.ListBackupCollectionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.memorystore.v1.BackupCollection(), + ), + generateSampleMessage( + new protos.google.cloud.memorystore.v1.BackupCollection(), + ), + generateSampleMessage( + new protos.google.cloud.memorystore.v1.BackupCollection(), + ), + ]; + client.descriptors.page.listBackupCollections.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listBackupCollectionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.memorystore.v1.BackupCollection[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.memorystore.v1.BackupCollection) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listBackupCollections without error using callback', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.ListBackupCollectionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.ListBackupCollectionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.memorystore.v1.BackupCollection()), - generateSampleMessage(new protos.google.cloud.memorystore.v1.BackupCollection()), - generateSampleMessage(new protos.google.cloud.memorystore.v1.BackupCollection()), - ]; - client.innerApiCalls.listBackupCollections = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listBackupCollections( - request, - (err?: Error|null, result?: protos.google.cloud.memorystore.v1.IBackupCollection[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listBackupCollections as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBackupCollections as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + stream.on('error', (err: Error) => { + reject(err); }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listBackupCollections + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listBackupCollections, request), + ); + assert( + ( + client.descriptors.page.listBackupCollections + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listBackupCollections with error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.ListBackupCollectionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.ListBackupCollectionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listBackupCollections = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listBackupCollections(request), expectedError); - const actualRequest = (client.innerApiCalls.listBackupCollections as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBackupCollections as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listBackupCollectionsStream with error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.ListBackupCollectionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.ListBackupCollectionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listBackupCollections.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listBackupCollectionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.memorystore.v1.BackupCollection[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.memorystore.v1.BackupCollection) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listBackupCollectionsStream without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.ListBackupCollectionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.ListBackupCollectionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.memorystore.v1.BackupCollection()), - generateSampleMessage(new protos.google.cloud.memorystore.v1.BackupCollection()), - generateSampleMessage(new protos.google.cloud.memorystore.v1.BackupCollection()), - ]; - client.descriptors.page.listBackupCollections.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listBackupCollectionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.memorystore.v1.BackupCollection[] = []; - stream.on('data', (response: protos.google.cloud.memorystore.v1.BackupCollection) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listBackupCollections.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listBackupCollections, request)); - assert( - (client.descriptors.page.listBackupCollections.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + stream.on('error', (err: Error) => { + reject(err); }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listBackupCollections + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listBackupCollections, request), + ); + assert( + ( + client.descriptors.page.listBackupCollections + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listBackupCollectionsStream with error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.ListBackupCollectionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.ListBackupCollectionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listBackupCollections.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listBackupCollectionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.memorystore.v1.BackupCollection[] = []; - stream.on('data', (response: protos.google.cloud.memorystore.v1.BackupCollection) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listBackupCollections.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listBackupCollections, request)); - assert( - (client.descriptors.page.listBackupCollections.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listBackupCollections without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.ListBackupCollectionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.ListBackupCollectionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.memorystore.v1.BackupCollection(), + ), + generateSampleMessage( + new protos.google.cloud.memorystore.v1.BackupCollection(), + ), + generateSampleMessage( + new protos.google.cloud.memorystore.v1.BackupCollection(), + ), + ]; + client.descriptors.page.listBackupCollections.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.memorystore.v1.IBackupCollection[] = + []; + const iterable = client.listBackupCollectionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listBackupCollections + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listBackupCollections + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('uses async iteration with listBackupCollections without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.ListBackupCollectionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.ListBackupCollectionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.memorystore.v1.BackupCollection()), - generateSampleMessage(new protos.google.cloud.memorystore.v1.BackupCollection()), - generateSampleMessage(new protos.google.cloud.memorystore.v1.BackupCollection()), - ]; - client.descriptors.page.listBackupCollections.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.memorystore.v1.IBackupCollection[] = []; - const iterable = client.listBackupCollectionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listBackupCollections.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listBackupCollections.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listBackupCollections with error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.ListBackupCollectionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.ListBackupCollectionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listBackupCollections.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listBackupCollectionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.memorystore.v1.IBackupCollection[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listBackupCollections + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listBackupCollections + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('listBackups', () => { + it('invokes listBackups without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.memorystore.v1.Backup()), + generateSampleMessage(new protos.google.cloud.memorystore.v1.Backup()), + generateSampleMessage(new protos.google.cloud.memorystore.v1.Backup()), + ]; + client.innerApiCalls.listBackups = stubSimpleCall(expectedResponse); + const [response] = await client.listBackups(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listBackupCollections with error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.ListBackupCollectionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.ListBackupCollectionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listBackupCollections.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listBackupCollectionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.memorystore.v1.IBackupCollection[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listBackupCollections.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listBackupCollections.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listBackups without error using callback', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.memorystore.v1.Backup()), + generateSampleMessage(new protos.google.cloud.memorystore.v1.Backup()), + generateSampleMessage(new protos.google.cloud.memorystore.v1.Backup()), + ]; + client.innerApiCalls.listBackups = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listBackups( + request, + ( + err?: Error | null, + result?: protos.google.cloud.memorystore.v1.IBackup[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listBackups', () => { - it('invokes listBackups without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.memorystore.v1.Backup()), - generateSampleMessage(new protos.google.cloud.memorystore.v1.Backup()), - generateSampleMessage(new protos.google.cloud.memorystore.v1.Backup()), - ]; - client.innerApiCalls.listBackups = stubSimpleCall(expectedResponse); - const [response] = await client.listBackups(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listBackups with error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listBackups = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listBackups(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listBackups without error using callback', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.memorystore.v1.Backup()), - generateSampleMessage(new protos.google.cloud.memorystore.v1.Backup()), - generateSampleMessage(new protos.google.cloud.memorystore.v1.Backup()), - ]; - client.innerApiCalls.listBackups = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listBackups( - request, - (err?: Error|null, result?: protos.google.cloud.memorystore.v1.IBackup[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listBackupsStream without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.memorystore.v1.Backup()), + generateSampleMessage(new protos.google.cloud.memorystore.v1.Backup()), + generateSampleMessage(new protos.google.cloud.memorystore.v1.Backup()), + ]; + client.descriptors.page.listBackups.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listBackupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.memorystore.v1.Backup[] = []; + stream.on( + 'data', + (response: protos.google.cloud.memorystore.v1.Backup) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listBackups with error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listBackups = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listBackups(request), expectedError); - const actualRequest = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + stream.on('error', (err: Error) => { + reject(err); }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listBackups.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listBackups, request), + ); + assert( + (client.descriptors.page.listBackups.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listBackupsStream without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.memorystore.v1.Backup()), - generateSampleMessage(new protos.google.cloud.memorystore.v1.Backup()), - generateSampleMessage(new protos.google.cloud.memorystore.v1.Backup()), - ]; - client.descriptors.page.listBackups.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listBackupsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.memorystore.v1.Backup[] = []; - stream.on('data', (response: protos.google.cloud.memorystore.v1.Backup) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listBackups.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listBackups, request)); - assert( - (client.descriptors.page.listBackups.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('invokes listBackupsStream with error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listBackups.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listBackupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.memorystore.v1.Backup[] = []; + stream.on( + 'data', + (response: protos.google.cloud.memorystore.v1.Backup) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listBackupsStream with error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listBackups.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listBackupsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.memorystore.v1.Backup[] = []; - stream.on('data', (response: protos.google.cloud.memorystore.v1.Backup) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listBackups.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listBackups, request)); - assert( - (client.descriptors.page.listBackups.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + stream.on('error', (err: Error) => { + reject(err); }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listBackups.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listBackups, request), + ); + assert( + (client.descriptors.page.listBackups.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listBackups without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.memorystore.v1.Backup()), - generateSampleMessage(new protos.google.cloud.memorystore.v1.Backup()), - generateSampleMessage(new protos.google.cloud.memorystore.v1.Backup()), - ]; - client.descriptors.page.listBackups.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.memorystore.v1.IBackup[] = []; - const iterable = client.listBackupsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listBackups.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listBackups.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listBackups without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.memorystore.v1.Backup()), + generateSampleMessage(new protos.google.cloud.memorystore.v1.Backup()), + generateSampleMessage(new protos.google.cloud.memorystore.v1.Backup()), + ]; + client.descriptors.page.listBackups.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.memorystore.v1.IBackup[] = []; + const iterable = client.listBackupsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listBackups.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listBackups.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listBackups with error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listBackups.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listBackupsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.memorystore.v1.IBackup[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listBackups.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listBackups.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listBackups with error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listBackups.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listBackupsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.memorystore.v1.IBackup[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listBackups.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listBackups.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes getLocation without error using callback', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes getLocation with error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('uses async iteration with listLocations with error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('backup', async () => { + const fakePath = '/rendered/path/backup'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + backup_collection: 'backupCollectionValue', + backup: 'backupValue', + }; + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.backupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.backupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('backupPath', () => { + const result = client.backupPath( + 'projectValue', + 'locationValue', + 'backupCollectionValue', + 'backupValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.backupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromBackupName', () => { + const result = client.matchProjectFromBackupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromBackupName', () => { + const result = client.matchLocationFromBackupName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchBackupCollectionFromBackupName', () => { + const result = client.matchBackupCollectionFromBackupName(fakePath); + assert.strictEqual(result, 'backupCollectionValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchBackupFromBackupName', () => { + const result = client.matchBackupFromBackupName(fakePath); + assert.strictEqual(result, 'backupValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('backup', async () => { - const fakePath = "/rendered/path/backup"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - backup_collection: "backupCollectionValue", - backup: "backupValue", - }; - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.backupPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.backupPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('backupPath', () => { - const result = client.backupPath("projectValue", "locationValue", "backupCollectionValue", "backupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.backupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBackupName', () => { - const result = client.matchProjectFromBackupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBackupName', () => { - const result = client.matchLocationFromBackupName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBackupCollectionFromBackupName', () => { - const result = client.matchBackupCollectionFromBackupName(fakePath); - assert.strictEqual(result, "backupCollectionValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBackupFromBackupName', () => { - const result = client.matchBackupFromBackupName(fakePath); - assert.strictEqual(result, "backupValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('backupCollection', async () => { - const fakePath = "/rendered/path/backupCollection"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - backup_collection: "backupCollectionValue", - }; - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.backupCollectionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.backupCollectionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('backupCollectionPath', () => { - const result = client.backupCollectionPath("projectValue", "locationValue", "backupCollectionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.backupCollectionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBackupCollectionName', () => { - const result = client.matchProjectFromBackupCollectionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.backupCollectionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBackupCollectionName', () => { - const result = client.matchLocationFromBackupCollectionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.backupCollectionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBackupCollectionFromBackupCollectionName', () => { - const result = client.matchBackupCollectionFromBackupCollectionName(fakePath); - assert.strictEqual(result, "backupCollectionValue"); - assert((client.pathTemplates.backupCollectionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('backupCollection', async () => { + const fakePath = '/rendered/path/backupCollection'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + backup_collection: 'backupCollectionValue', + }; + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.backupCollectionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.backupCollectionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('backupCollectionPath', () => { + const result = client.backupCollectionPath( + 'projectValue', + 'locationValue', + 'backupCollectionValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.backupCollectionPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromBackupCollectionName', () => { + const result = client.matchProjectFromBackupCollectionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.backupCollectionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromBackupCollectionName', () => { + const result = client.matchLocationFromBackupCollectionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.backupCollectionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchBackupCollectionFromBackupCollectionName', () => { + const result = + client.matchBackupCollectionFromBackupCollectionName(fakePath); + assert.strictEqual(result, 'backupCollectionValue'); + assert( + (client.pathTemplates.backupCollectionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('caPool', async () => { - const fakePath = "/rendered/path/caPool"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - ca_pool: "caPoolValue", - }; - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.caPoolPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.caPoolPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('caPoolPath', () => { - const result = client.caPoolPath("projectValue", "locationValue", "caPoolValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.caPoolPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCaPoolName', () => { - const result = client.matchProjectFromCaPoolName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.caPoolPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCaPoolName', () => { - const result = client.matchLocationFromCaPoolName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.caPoolPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaPoolFromCaPoolName', () => { - const result = client.matchCaPoolFromCaPoolName(fakePath); - assert.strictEqual(result, "caPoolValue"); - assert((client.pathTemplates.caPoolPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('caPool', async () => { + const fakePath = '/rendered/path/caPool'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + ca_pool: 'caPoolValue', + }; + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.caPoolPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.caPoolPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('caPoolPath', () => { + const result = client.caPoolPath( + 'projectValue', + 'locationValue', + 'caPoolValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.caPoolPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromCaPoolName', () => { + const result = client.matchProjectFromCaPoolName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.caPoolPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromCaPoolName', () => { + const result = client.matchLocationFromCaPoolName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.caPoolPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaPoolFromCaPoolName', () => { + const result = client.matchCaPoolFromCaPoolName(fakePath); + assert.strictEqual(result, 'caPoolValue'); + assert( + (client.pathTemplates.caPoolPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('certificateAuthority', async () => { - const fakePath = "/rendered/path/certificateAuthority"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - instance: "instanceValue", - }; - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.certificateAuthorityPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.certificateAuthorityPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('certificateAuthorityPath', () => { - const result = client.certificateAuthorityPath("projectValue", "locationValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.certificateAuthorityPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCertificateAuthorityName', () => { - const result = client.matchProjectFromCertificateAuthorityName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.certificateAuthorityPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCertificateAuthorityName', () => { - const result = client.matchLocationFromCertificateAuthorityName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.certificateAuthorityPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromCertificateAuthorityName', () => { - const result = client.matchInstanceFromCertificateAuthorityName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.certificateAuthorityPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('certificateAuthority', async () => { + const fakePath = '/rendered/path/certificateAuthority'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + instance: 'instanceValue', + }; + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.certificateAuthorityPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.certificateAuthorityPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('certificateAuthorityPath', () => { + const result = client.certificateAuthorityPath( + 'projectValue', + 'locationValue', + 'instanceValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.certificateAuthorityPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromCertificateAuthorityName', () => { + const result = + client.matchProjectFromCertificateAuthorityName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.certificateAuthorityPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromCertificateAuthorityName', () => { + const result = + client.matchLocationFromCertificateAuthorityName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.certificateAuthorityPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchInstanceFromCertificateAuthorityName', () => { + const result = + client.matchInstanceFromCertificateAuthorityName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + ( + client.pathTemplates.certificateAuthorityPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('cryptoKey', async () => { - const fakePath = "/rendered/path/cryptoKey"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - crypto_key: "cryptoKeyValue", - }; - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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('cryptoKey', async () => { + const fakePath = '/rendered/path/cryptoKey'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + crypto_key: 'cryptoKeyValue', + }; + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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('cryptoKeyVersion', async () => { - const fakePath = "/rendered/path/cryptoKeyVersion"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - crypto_key: "cryptoKeyValue", - crypto_key_version: "cryptoKeyVersionValue", - }; - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.cryptoKeyVersionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.cryptoKeyVersionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('cryptoKeyVersionPath', () => { - const result = client.cryptoKeyVersionPath("projectValue", "locationValue", "keyRingValue", "cryptoKeyValue", "cryptoKeyVersionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.cryptoKeyVersionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCryptoKeyVersionName', () => { - const result = client.matchProjectFromCryptoKeyVersionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.cryptoKeyVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCryptoKeyVersionName', () => { - const result = client.matchLocationFromCryptoKeyVersionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.cryptoKeyVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyRingFromCryptoKeyVersionName', () => { - const result = client.matchKeyRingFromCryptoKeyVersionName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.cryptoKeyVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCryptoKeyFromCryptoKeyVersionName', () => { - const result = client.matchCryptoKeyFromCryptoKeyVersionName(fakePath); - assert.strictEqual(result, "cryptoKeyValue"); - assert((client.pathTemplates.cryptoKeyVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCryptoKeyVersionFromCryptoKeyVersionName', () => { - const result = client.matchCryptoKeyVersionFromCryptoKeyVersionName(fakePath); - assert.strictEqual(result, "cryptoKeyVersionValue"); - assert((client.pathTemplates.cryptoKeyVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('cryptoKeyVersion', async () => { + const fakePath = '/rendered/path/cryptoKeyVersion'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + crypto_key: 'cryptoKeyValue', + crypto_key_version: 'cryptoKeyVersionValue', + }; + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.cryptoKeyVersionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.cryptoKeyVersionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('cryptoKeyVersionPath', () => { + const result = client.cryptoKeyVersionPath( + 'projectValue', + 'locationValue', + 'keyRingValue', + 'cryptoKeyValue', + 'cryptoKeyVersionValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.cryptoKeyVersionPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromCryptoKeyVersionName', () => { + const result = client.matchProjectFromCryptoKeyVersionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.cryptoKeyVersionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromCryptoKeyVersionName', () => { + const result = client.matchLocationFromCryptoKeyVersionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.cryptoKeyVersionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKeyRingFromCryptoKeyVersionName', () => { + const result = client.matchKeyRingFromCryptoKeyVersionName(fakePath); + assert.strictEqual(result, 'keyRingValue'); + assert( + (client.pathTemplates.cryptoKeyVersionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCryptoKeyFromCryptoKeyVersionName', () => { + const result = client.matchCryptoKeyFromCryptoKeyVersionName(fakePath); + assert.strictEqual(result, 'cryptoKeyValue'); + assert( + (client.pathTemplates.cryptoKeyVersionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCryptoKeyVersionFromCryptoKeyVersionName', () => { + const result = + client.matchCryptoKeyVersionFromCryptoKeyVersionName(fakePath); + assert.strictEqual(result, 'cryptoKeyVersionValue'); + assert( + (client.pathTemplates.cryptoKeyVersionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('forwardingRule', async () => { - const fakePath = "/rendered/path/forwardingRule"; - const expectedParameters = { - project: "projectValue", - region: "regionValue", - forwarding_rule: "forwardingRuleValue", - }; - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.forwardingRulePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.forwardingRulePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('forwardingRulePath', () => { - const result = client.forwardingRulePath("projectValue", "regionValue", "forwardingRuleValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.forwardingRulePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromForwardingRuleName', () => { - const result = client.matchProjectFromForwardingRuleName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.forwardingRulePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRegionFromForwardingRuleName', () => { - const result = client.matchRegionFromForwardingRuleName(fakePath); - assert.strictEqual(result, "regionValue"); - assert((client.pathTemplates.forwardingRulePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchForwardingRuleFromForwardingRuleName', () => { - const result = client.matchForwardingRuleFromForwardingRuleName(fakePath); - assert.strictEqual(result, "forwardingRuleValue"); - assert((client.pathTemplates.forwardingRulePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('forwardingRule', async () => { + const fakePath = '/rendered/path/forwardingRule'; + const expectedParameters = { + project: 'projectValue', + region: 'regionValue', + forwarding_rule: 'forwardingRuleValue', + }; + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.forwardingRulePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.forwardingRulePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('forwardingRulePath', () => { + const result = client.forwardingRulePath( + 'projectValue', + 'regionValue', + 'forwardingRuleValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.forwardingRulePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromForwardingRuleName', () => { + const result = client.matchProjectFromForwardingRuleName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.forwardingRulePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRegionFromForwardingRuleName', () => { + const result = client.matchRegionFromForwardingRuleName(fakePath); + assert.strictEqual(result, 'regionValue'); + assert( + (client.pathTemplates.forwardingRulePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchForwardingRuleFromForwardingRuleName', () => { + const result = + client.matchForwardingRuleFromForwardingRuleName(fakePath); + assert.strictEqual(result, 'forwardingRuleValue'); + assert( + (client.pathTemplates.forwardingRulePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('instance', async () => { - const fakePath = "/rendered/path/instance"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - instance: "instanceValue", - }; - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.instancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.instancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('instancePath', () => { - const result = client.instancePath("projectValue", "locationValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.instancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInstanceName', () => { - const result = client.matchProjectFromInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromInstanceName', () => { - const result = client.matchLocationFromInstanceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromInstanceName', () => { - const result = client.matchInstanceFromInstanceName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('instance', async () => { + const fakePath = '/rendered/path/instance'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + instance: 'instanceValue', + }; + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.instancePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.instancePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('instancePath', () => { + const result = client.instancePath( + 'projectValue', + 'locationValue', + 'instanceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.instancePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromInstanceName', () => { + const result = client.matchProjectFromInstanceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromInstanceName', () => { + const result = client.matchLocationFromInstanceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchInstanceFromInstanceName', () => { + const result = client.matchInstanceFromInstanceName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('network', async () => { - const fakePath = "/rendered/path/network"; - const expectedParameters = { - project: "projectValue", - network: "networkValue", - }; - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.networkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.networkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('networkPath', () => { - const result = client.networkPath("projectValue", "networkValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.networkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromNetworkName', () => { - const result = client.matchProjectFromNetworkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.networkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchNetworkFromNetworkName', () => { - const result = client.matchNetworkFromNetworkName(fakePath); - assert.strictEqual(result, "networkValue"); - assert((client.pathTemplates.networkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('network', async () => { + const fakePath = '/rendered/path/network'; + const expectedParameters = { + project: 'projectValue', + network: 'networkValue', + }; + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.networkPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.networkPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('networkPath', () => { + const result = client.networkPath('projectValue', 'networkValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.networkPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromNetworkName', () => { + const result = client.matchProjectFromNetworkName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.networkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchNetworkFromNetworkName', () => { + const result = client.matchNetworkFromNetworkName(fakePath); + assert.strictEqual(result, 'networkValue'); + assert( + (client.pathTemplates.networkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('serviceAttachment', async () => { - const fakePath = "/rendered/path/serviceAttachment"; - const expectedParameters = { - project: "projectValue", - region: "regionValue", - service_attachment: "serviceAttachmentValue", - }; - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.serviceAttachmentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.serviceAttachmentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('serviceAttachmentPath', () => { - const result = client.serviceAttachmentPath("projectValue", "regionValue", "serviceAttachmentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.serviceAttachmentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceAttachmentName', () => { - const result = client.matchProjectFromServiceAttachmentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.serviceAttachmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRegionFromServiceAttachmentName', () => { - const result = client.matchRegionFromServiceAttachmentName(fakePath); - assert.strictEqual(result, "regionValue"); - assert((client.pathTemplates.serviceAttachmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceAttachmentFromServiceAttachmentName', () => { - const result = client.matchServiceAttachmentFromServiceAttachmentName(fakePath); - assert.strictEqual(result, "serviceAttachmentValue"); - assert((client.pathTemplates.serviceAttachmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('serviceAttachment', async () => { + const fakePath = '/rendered/path/serviceAttachment'; + const expectedParameters = { + project: 'projectValue', + region: 'regionValue', + service_attachment: 'serviceAttachmentValue', + }; + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.serviceAttachmentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.serviceAttachmentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('serviceAttachmentPath', () => { + const result = client.serviceAttachmentPath( + 'projectValue', + 'regionValue', + 'serviceAttachmentValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.serviceAttachmentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceAttachmentName', () => { + const result = client.matchProjectFromServiceAttachmentName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.serviceAttachmentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRegionFromServiceAttachmentName', () => { + const result = client.matchRegionFromServiceAttachmentName(fakePath); + assert.strictEqual(result, 'regionValue'); + assert( + ( + client.pathTemplates.serviceAttachmentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceAttachmentFromServiceAttachmentName', () => { + const result = + client.matchServiceAttachmentFromServiceAttachmentName(fakePath); + assert.strictEqual(result, 'serviceAttachmentValue'); + assert( + ( + client.pathTemplates.serviceAttachmentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('sharedRegionalCertificateAuthority', async () => { - const fakePath = "/rendered/path/sharedRegionalCertificateAuthority"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new memorystoreModule.v1.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('sharedRegionalCertificateAuthorityPath', () => { - const result = client.sharedRegionalCertificateAuthorityPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromSharedRegionalCertificateAuthorityName', () => { - const result = client.matchProjectFromSharedRegionalCertificateAuthorityName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromSharedRegionalCertificateAuthorityName', () => { - const result = client.matchLocationFromSharedRegionalCertificateAuthorityName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('sharedRegionalCertificateAuthority', async () => { + const fakePath = '/rendered/path/sharedRegionalCertificateAuthority'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new memorystoreModule.v1.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('sharedRegionalCertificateAuthorityPath', () => { + const result = client.sharedRegionalCertificateAuthorityPath( + 'projectValue', + 'locationValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromSharedRegionalCertificateAuthorityName', () => { + const result = + client.matchProjectFromSharedRegionalCertificateAuthorityName( + fakePath, + ); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromSharedRegionalCertificateAuthorityName', () => { + const result = + client.matchLocationFromSharedRegionalCertificateAuthorityName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-memorystore/test/gapic_memorystore_v1beta.ts b/packages/google-cloud-memorystore/test/gapic_memorystore_v1beta.ts index fbf237f5b4b7..91145c8cb94e 100644 --- a/packages/google-cloud-memorystore/test/gapic_memorystore_v1beta.ts +++ b/packages/google-cloud-memorystore/test/gapic_memorystore_v1beta.ts @@ -19,2092 +19,2724 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as memorystoreModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1beta.MemorystoreClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new memorystoreModule.v1beta.MemorystoreClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'memorystore.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new memorystoreModule.v1beta.MemorystoreClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = memorystoreModule.v1beta.MemorystoreClient.servicePath; - assert.strictEqual(servicePath, 'memorystore.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = memorystoreModule.v1beta.MemorystoreClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'memorystore.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'memorystore.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'memorystore.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new memorystoreModule.v1beta.MemorystoreClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'memorystore.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new memorystoreModule.v1beta.MemorystoreClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'memorystore.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new memorystoreModule.v1beta.MemorystoreClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = memorystoreModule.v1beta.MemorystoreClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new memorystoreModule.v1beta.MemorystoreClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - fallback: true, - }); - assert(client); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new memorystoreModule.v1beta.MemorystoreClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'memorystore.googleapis.com'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.memorystoreStub, undefined); - await client.initialize(); - assert(client.memorystoreStub); - }); + it('has universeDomain', () => { + const client = new memorystoreModule.v1beta.MemorystoreClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has close method for the initialized client', done => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.memorystoreStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + memorystoreModule.v1beta.MemorystoreClient.servicePath; + assert.strictEqual(servicePath, 'memorystore.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + memorystoreModule.v1beta.MemorystoreClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'memorystore.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'memorystore.example.com'); + }); - it('has close method for the non-initialized client', done => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.memorystoreStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'memorystore.example.com'); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new memorystoreModule.v1beta.MemorystoreClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'memorystore.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new memorystoreModule.v1beta.MemorystoreClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'memorystore.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new memorystoreModule.v1beta.MemorystoreClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); + it('has port', () => { + const port = memorystoreModule.v1beta.MemorystoreClient.port; + assert(port); + assert(typeof port === 'number'); }); - describe('getInstance', () => { - it('invokes getInstance without error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1beta.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.Instance() - ); - client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); - const [response] = await client.getInstance(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('should create a client with no option', () => { + const client = new memorystoreModule.v1beta.MemorystoreClient(); + assert(client); + }); - it('invokes getInstance without error using callback', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1beta.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.Instance() - ); - client.innerApiCalls.getInstance = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getInstance( - request, - (err?: Error|null, result?: protos.google.cloud.memorystore.v1beta.IInstance|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('should create a client with gRPC fallback', () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + fallback: true, + }); + assert(client); + }); - it('invokes getInstance with error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1beta.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getInstance = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.memorystoreStub, undefined); + await client.initialize(); + assert(client.memorystoreStub); + }); - it('invokes getInstance with closed client', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1beta.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getInstance(request), expectedError); + it('has close method for the initialized client', (done) => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.memorystoreStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('getCertificateAuthority', () => { - it('invokes getCertificateAuthority without error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.GetCertificateAuthorityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1beta.GetCertificateAuthorityRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.CertificateAuthority() - ); - client.innerApiCalls.getCertificateAuthority = stubSimpleCall(expectedResponse); - const [response] = await client.getCertificateAuthority(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCertificateAuthority as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCertificateAuthority as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the non-initialized client', (done) => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.memorystoreStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getCertificateAuthority without error using callback', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.GetCertificateAuthorityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1beta.GetCertificateAuthorityRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.CertificateAuthority() - ); - client.innerApiCalls.getCertificateAuthority = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getCertificateAuthority( - request, - (err?: Error|null, result?: protos.google.cloud.memorystore.v1beta.ICertificateAuthority|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCertificateAuthority as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCertificateAuthority as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('invokes getCertificateAuthority with error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.GetCertificateAuthorityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1beta.GetCertificateAuthorityRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getCertificateAuthority = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getCertificateAuthority(request), expectedError); - const actualRequest = (client.innerApiCalls.getCertificateAuthority as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCertificateAuthority as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getInstance', () => { + it('invokes getInstance without error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1beta.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.Instance(), + ); + client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); + const [response] = await client.getInstance(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getCertificateAuthority with closed client', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.GetCertificateAuthorityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1beta.GetCertificateAuthorityRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getCertificateAuthority(request), expectedError); - }); + it('invokes getInstance without error using callback', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1beta.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.Instance(), + ); + client.innerApiCalls.getInstance = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getInstance( + request, + ( + err?: Error | null, + result?: protos.google.cloud.memorystore.v1beta.IInstance | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getSharedRegionalCertificateAuthority', () => { - it('invokes getSharedRegionalCertificateAuthority without error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.GetSharedRegionalCertificateAuthorityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1beta.GetSharedRegionalCertificateAuthorityRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.SharedRegionalCertificateAuthority() - ); - client.innerApiCalls.getSharedRegionalCertificateAuthority = stubSimpleCall(expectedResponse); - const [response] = await client.getSharedRegionalCertificateAuthority(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSharedRegionalCertificateAuthority as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSharedRegionalCertificateAuthority as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getInstance with error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1beta.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getInstance = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getSharedRegionalCertificateAuthority without error using callback', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.GetSharedRegionalCertificateAuthorityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1beta.GetSharedRegionalCertificateAuthorityRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.SharedRegionalCertificateAuthority() - ); - client.innerApiCalls.getSharedRegionalCertificateAuthority = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getSharedRegionalCertificateAuthority( - request, - (err?: Error|null, result?: protos.google.cloud.memorystore.v1beta.ISharedRegionalCertificateAuthority|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSharedRegionalCertificateAuthority as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSharedRegionalCertificateAuthority as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getInstance with closed client', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1beta.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getInstance(request), expectedError); + }); + }); + + describe('getCertificateAuthority', () => { + it('invokes getCertificateAuthority without error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.GetCertificateAuthorityRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1beta.GetCertificateAuthorityRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.CertificateAuthority(), + ); + client.innerApiCalls.getCertificateAuthority = + stubSimpleCall(expectedResponse); + const [response] = await client.getCertificateAuthority(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCertificateAuthority as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCertificateAuthority as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getSharedRegionalCertificateAuthority with error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.GetSharedRegionalCertificateAuthorityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1beta.GetSharedRegionalCertificateAuthorityRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getSharedRegionalCertificateAuthority = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getSharedRegionalCertificateAuthority(request), expectedError); - const actualRequest = (client.innerApiCalls.getSharedRegionalCertificateAuthority as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSharedRegionalCertificateAuthority as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getCertificateAuthority without error using callback', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.GetCertificateAuthorityRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1beta.GetCertificateAuthorityRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.CertificateAuthority(), + ); + client.innerApiCalls.getCertificateAuthority = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCertificateAuthority( + request, + ( + err?: Error | null, + result?: protos.google.cloud.memorystore.v1beta.ICertificateAuthority | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCertificateAuthority as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCertificateAuthority as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getSharedRegionalCertificateAuthority with closed client', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.GetSharedRegionalCertificateAuthorityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1beta.GetSharedRegionalCertificateAuthorityRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getSharedRegionalCertificateAuthority(request), expectedError); - }); + it('invokes getCertificateAuthority with error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.GetCertificateAuthorityRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1beta.GetCertificateAuthorityRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getCertificateAuthority = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getCertificateAuthority(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.getCertificateAuthority as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCertificateAuthority as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createInstance', () => { - it('invokes createInstance without error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1beta.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.createInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getCertificateAuthority with closed client', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.GetCertificateAuthorityRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1beta.GetCertificateAuthorityRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.getCertificateAuthority(request), + expectedError, + ); + }); + }); + + describe('getSharedRegionalCertificateAuthority', () => { + it('invokes getSharedRegionalCertificateAuthority without error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.GetSharedRegionalCertificateAuthorityRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1beta.GetSharedRegionalCertificateAuthorityRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.SharedRegionalCertificateAuthority(), + ); + client.innerApiCalls.getSharedRegionalCertificateAuthority = + stubSimpleCall(expectedResponse); + const [response] = + await client.getSharedRegionalCertificateAuthority(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getSharedRegionalCertificateAuthority as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSharedRegionalCertificateAuthority as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createInstance without error using callback', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1beta.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getSharedRegionalCertificateAuthority without error using callback', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.GetSharedRegionalCertificateAuthorityRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1beta.GetSharedRegionalCertificateAuthorityRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.SharedRegionalCertificateAuthority(), + ); + client.innerApiCalls.getSharedRegionalCertificateAuthority = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getSharedRegionalCertificateAuthority( + request, + ( + err?: Error | null, + result?: protos.google.cloud.memorystore.v1beta.ISharedRegionalCertificateAuthority | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getSharedRegionalCertificateAuthority as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSharedRegionalCertificateAuthority as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createInstance with call error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1beta.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getSharedRegionalCertificateAuthority with error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.GetSharedRegionalCertificateAuthorityRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1beta.GetSharedRegionalCertificateAuthorityRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getSharedRegionalCertificateAuthority = + stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getSharedRegionalCertificateAuthority(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.getSharedRegionalCertificateAuthority as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSharedRegionalCertificateAuthority as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createInstance with LRO error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1beta.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getSharedRegionalCertificateAuthority with closed client', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.GetSharedRegionalCertificateAuthorityRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1beta.GetSharedRegionalCertificateAuthorityRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.getSharedRegionalCertificateAuthority(request), + expectedError, + ); + }); + }); + + describe('createInstance', () => { + it('invokes createInstance without error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.CreateInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1beta.CreateInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateInstanceProgress without error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createInstance without error using callback', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.CreateInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1beta.CreateInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.memorystore.v1beta.IInstance, + protos.google.cloud.memorystore.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.memorystore.v1beta.IInstance, + protos.google.cloud.memorystore.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateInstanceProgress with error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createInstance with call error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.CreateInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1beta.CreateInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateInstance', () => { - it('invokes updateInstance without error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1beta.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createInstance with LRO error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.CreateInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1beta.CreateInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateInstance without error using callback', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1beta.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateInstanceProgress without error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateInstance with call error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1beta.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateInstanceProgress with error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateInstance', () => { + it('invokes updateInstance without error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.UpdateInstanceRequest(), + ); + request.instance ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1beta.UpdateInstanceRequest', + ['instance', 'name'], + ); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateInstance with LRO error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1beta.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateInstance without error using callback', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.UpdateInstanceRequest(), + ); + request.instance ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1beta.UpdateInstanceRequest', + ['instance', 'name'], + ); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.memorystore.v1beta.IInstance, + protos.google.cloud.memorystore.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.memorystore.v1beta.IInstance, + protos.google.cloud.memorystore.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateInstanceProgress without error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateInstance with call error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.UpdateInstanceRequest(), + ); + request.instance ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1beta.UpdateInstanceRequest', + ['instance', 'name'], + ); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateInstanceProgress with error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateInstance with LRO error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.UpdateInstanceRequest(), + ); + request.instance ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1beta.UpdateInstanceRequest', + ['instance', 'name'], + ); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteInstance', () => { - it('invokes deleteInstance without error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1beta.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateInstanceProgress without error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteInstance without error using callback', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1beta.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateInstanceProgress with error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteInstance', () => { + it('invokes deleteInstance without error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.DeleteInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1beta.DeleteInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteInstance with call error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1beta.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteInstance without error using callback', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.DeleteInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1beta.DeleteInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memorystore.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.memorystore.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteInstance with LRO error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1beta.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteInstance with call error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.DeleteInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1beta.DeleteInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteInstanceProgress without error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteInstance with LRO error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.DeleteInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1beta.DeleteInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteInstanceProgress with error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteInstanceProgress without error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('listInstances', () => { - it('invokes listInstances without error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1beta.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.memorystore.v1beta.Instance()), - generateSampleMessage(new protos.google.cloud.memorystore.v1beta.Instance()), - generateSampleMessage(new protos.google.cloud.memorystore.v1beta.Instance()), - ]; - client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); - const [response] = await client.listInstances(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteInstanceProgress with error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listInstances', () => { + it('invokes listInstances without error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1beta.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.Instance(), + ), + ]; + client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); + const [response] = await client.listInstances(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listInstances without error using callback', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1beta.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.memorystore.v1beta.Instance()), - generateSampleMessage(new protos.google.cloud.memorystore.v1beta.Instance()), - generateSampleMessage(new protos.google.cloud.memorystore.v1beta.Instance()), - ]; - client.innerApiCalls.listInstances = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listInstances( - request, - (err?: Error|null, result?: protos.google.cloud.memorystore.v1beta.IInstance[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listInstances without error using callback', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1beta.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.Instance(), + ), + ]; + client.innerApiCalls.listInstances = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listInstances( + request, + ( + err?: Error | null, + result?: protos.google.cloud.memorystore.v1beta.IInstance[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listInstances with error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1beta.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listInstances = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listInstances(request), expectedError); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listInstances with error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1beta.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listInstances = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listInstances(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listInstancesStream without error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1beta.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.memorystore.v1beta.Instance()), - generateSampleMessage(new protos.google.cloud.memorystore.v1beta.Instance()), - generateSampleMessage(new protos.google.cloud.memorystore.v1beta.Instance()), - ]; - client.descriptors.page.listInstances.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listInstancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.memorystore.v1beta.Instance[] = []; - stream.on('data', (response: protos.google.cloud.memorystore.v1beta.Instance) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); - assert( - (client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listInstancesStream without error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1beta.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.Instance(), + ), + ]; + client.descriptors.page.listInstances.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.memorystore.v1beta.Instance[] = []; + stream.on( + 'data', + (response: protos.google.cloud.memorystore.v1beta.Instance) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listInstances, request), + ); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listInstancesStream with error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1beta.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstances.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listInstancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.memorystore.v1beta.Instance[] = []; - stream.on('data', (response: protos.google.cloud.memorystore.v1beta.Instance) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); - assert( - (client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listInstancesStream with error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1beta.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstances.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.memorystore.v1beta.Instance[] = []; + stream.on( + 'data', + (response: protos.google.cloud.memorystore.v1beta.Instance) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listInstances, request), + ); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listInstances without error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1beta.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.memorystore.v1beta.Instance()), - generateSampleMessage(new protos.google.cloud.memorystore.v1beta.Instance()), - generateSampleMessage(new protos.google.cloud.memorystore.v1beta.Instance()), - ]; - client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.memorystore.v1beta.IInstance[] = []; - const iterable = client.listInstancesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listInstances without error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1beta.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.Instance(), + ), + ]; + client.descriptors.page.listInstances.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.memorystore.v1beta.IInstance[] = []; + const iterable = client.listInstancesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listInstances.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listInstances with error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.memorystore.v1beta.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.memorystore.v1beta.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listInstancesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.memorystore.v1beta.IInstance[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listInstances with error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.memorystore.v1beta.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.memorystore.v1beta.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstances.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listInstancesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.memorystore.v1beta.IInstance[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listInstances.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes getLocation without error using callback', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes getLocation with error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('uses async iteration with listLocations with error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('caPool', async () => { + const fakePath = '/rendered/path/caPool'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + ca_pool: 'caPoolValue', + }; + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.caPoolPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.caPoolPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('caPoolPath', () => { + const result = client.caPoolPath( + 'projectValue', + 'locationValue', + 'caPoolValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.caPoolPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromCaPoolName', () => { + const result = client.matchProjectFromCaPoolName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.caPoolPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromCaPoolName', () => { + const result = client.matchLocationFromCaPoolName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.caPoolPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaPoolFromCaPoolName', () => { + const result = client.matchCaPoolFromCaPoolName(fakePath); + assert.strictEqual(result, 'caPoolValue'); + assert( + (client.pathTemplates.caPoolPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('caPool', async () => { - const fakePath = "/rendered/path/caPool"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - ca_pool: "caPoolValue", - }; - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.caPoolPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.caPoolPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('caPoolPath', () => { - const result = client.caPoolPath("projectValue", "locationValue", "caPoolValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.caPoolPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCaPoolName', () => { - const result = client.matchProjectFromCaPoolName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.caPoolPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCaPoolName', () => { - const result = client.matchLocationFromCaPoolName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.caPoolPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaPoolFromCaPoolName', () => { - const result = client.matchCaPoolFromCaPoolName(fakePath); - assert.strictEqual(result, "caPoolValue"); - assert((client.pathTemplates.caPoolPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('certificateAuthority', async () => { - const fakePath = "/rendered/path/certificateAuthority"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - instance: "instanceValue", - }; - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.certificateAuthorityPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.certificateAuthorityPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('certificateAuthorityPath', () => { - const result = client.certificateAuthorityPath("projectValue", "locationValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.certificateAuthorityPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCertificateAuthorityName', () => { - const result = client.matchProjectFromCertificateAuthorityName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.certificateAuthorityPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCertificateAuthorityName', () => { - const result = client.matchLocationFromCertificateAuthorityName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.certificateAuthorityPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromCertificateAuthorityName', () => { - const result = client.matchInstanceFromCertificateAuthorityName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.certificateAuthorityPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('certificateAuthority', async () => { + const fakePath = '/rendered/path/certificateAuthority'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + instance: 'instanceValue', + }; + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.certificateAuthorityPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.certificateAuthorityPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('certificateAuthorityPath', () => { + const result = client.certificateAuthorityPath( + 'projectValue', + 'locationValue', + 'instanceValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.certificateAuthorityPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromCertificateAuthorityName', () => { + const result = + client.matchProjectFromCertificateAuthorityName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.certificateAuthorityPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromCertificateAuthorityName', () => { + const result = + client.matchLocationFromCertificateAuthorityName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.certificateAuthorityPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchInstanceFromCertificateAuthorityName', () => { + const result = + client.matchInstanceFromCertificateAuthorityName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + ( + client.pathTemplates.certificateAuthorityPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('forwardingRule', async () => { - const fakePath = "/rendered/path/forwardingRule"; - const expectedParameters = { - project: "projectValue", - region: "regionValue", - forwarding_rule: "forwardingRuleValue", - }; - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.forwardingRulePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.forwardingRulePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('forwardingRulePath', () => { - const result = client.forwardingRulePath("projectValue", "regionValue", "forwardingRuleValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.forwardingRulePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromForwardingRuleName', () => { - const result = client.matchProjectFromForwardingRuleName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.forwardingRulePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRegionFromForwardingRuleName', () => { - const result = client.matchRegionFromForwardingRuleName(fakePath); - assert.strictEqual(result, "regionValue"); - assert((client.pathTemplates.forwardingRulePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchForwardingRuleFromForwardingRuleName', () => { - const result = client.matchForwardingRuleFromForwardingRuleName(fakePath); - assert.strictEqual(result, "forwardingRuleValue"); - assert((client.pathTemplates.forwardingRulePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('forwardingRule', async () => { + const fakePath = '/rendered/path/forwardingRule'; + const expectedParameters = { + project: 'projectValue', + region: 'regionValue', + forwarding_rule: 'forwardingRuleValue', + }; + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.forwardingRulePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.forwardingRulePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('forwardingRulePath', () => { + const result = client.forwardingRulePath( + 'projectValue', + 'regionValue', + 'forwardingRuleValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.forwardingRulePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromForwardingRuleName', () => { + const result = client.matchProjectFromForwardingRuleName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.forwardingRulePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRegionFromForwardingRuleName', () => { + const result = client.matchRegionFromForwardingRuleName(fakePath); + assert.strictEqual(result, 'regionValue'); + assert( + (client.pathTemplates.forwardingRulePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchForwardingRuleFromForwardingRuleName', () => { + const result = + client.matchForwardingRuleFromForwardingRuleName(fakePath); + assert.strictEqual(result, 'forwardingRuleValue'); + assert( + (client.pathTemplates.forwardingRulePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('instance', async () => { - const fakePath = "/rendered/path/instance"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - instance: "instanceValue", - }; - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.instancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.instancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('instancePath', () => { - const result = client.instancePath("projectValue", "locationValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.instancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInstanceName', () => { - const result = client.matchProjectFromInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromInstanceName', () => { - const result = client.matchLocationFromInstanceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromInstanceName', () => { - const result = client.matchInstanceFromInstanceName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('instance', async () => { + const fakePath = '/rendered/path/instance'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + instance: 'instanceValue', + }; + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.instancePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.instancePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('instancePath', () => { + const result = client.instancePath( + 'projectValue', + 'locationValue', + 'instanceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.instancePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromInstanceName', () => { + const result = client.matchProjectFromInstanceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromInstanceName', () => { + const result = client.matchLocationFromInstanceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchInstanceFromInstanceName', () => { + const result = client.matchInstanceFromInstanceName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('network', async () => { - const fakePath = "/rendered/path/network"; - const expectedParameters = { - project: "projectValue", - network: "networkValue", - }; - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.networkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.networkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('networkPath', () => { - const result = client.networkPath("projectValue", "networkValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.networkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromNetworkName', () => { - const result = client.matchProjectFromNetworkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.networkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchNetworkFromNetworkName', () => { - const result = client.matchNetworkFromNetworkName(fakePath); - assert.strictEqual(result, "networkValue"); - assert((client.pathTemplates.networkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('network', async () => { + const fakePath = '/rendered/path/network'; + const expectedParameters = { + project: 'projectValue', + network: 'networkValue', + }; + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.networkPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.networkPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('networkPath', () => { + const result = client.networkPath('projectValue', 'networkValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.networkPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromNetworkName', () => { + const result = client.matchProjectFromNetworkName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.networkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchNetworkFromNetworkName', () => { + const result = client.matchNetworkFromNetworkName(fakePath); + assert.strictEqual(result, 'networkValue'); + assert( + (client.pathTemplates.networkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('serviceAttachment', async () => { - const fakePath = "/rendered/path/serviceAttachment"; - const expectedParameters = { - project: "projectValue", - region: "regionValue", - service_attachment: "serviceAttachmentValue", - }; - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.serviceAttachmentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.serviceAttachmentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('serviceAttachmentPath', () => { - const result = client.serviceAttachmentPath("projectValue", "regionValue", "serviceAttachmentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.serviceAttachmentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceAttachmentName', () => { - const result = client.matchProjectFromServiceAttachmentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.serviceAttachmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRegionFromServiceAttachmentName', () => { - const result = client.matchRegionFromServiceAttachmentName(fakePath); - assert.strictEqual(result, "regionValue"); - assert((client.pathTemplates.serviceAttachmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceAttachmentFromServiceAttachmentName', () => { - const result = client.matchServiceAttachmentFromServiceAttachmentName(fakePath); - assert.strictEqual(result, "serviceAttachmentValue"); - assert((client.pathTemplates.serviceAttachmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('serviceAttachment', async () => { + const fakePath = '/rendered/path/serviceAttachment'; + const expectedParameters = { + project: 'projectValue', + region: 'regionValue', + service_attachment: 'serviceAttachmentValue', + }; + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.serviceAttachmentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.serviceAttachmentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('serviceAttachmentPath', () => { + const result = client.serviceAttachmentPath( + 'projectValue', + 'regionValue', + 'serviceAttachmentValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.serviceAttachmentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceAttachmentName', () => { + const result = client.matchProjectFromServiceAttachmentName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.serviceAttachmentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRegionFromServiceAttachmentName', () => { + const result = client.matchRegionFromServiceAttachmentName(fakePath); + assert.strictEqual(result, 'regionValue'); + assert( + ( + client.pathTemplates.serviceAttachmentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceAttachmentFromServiceAttachmentName', () => { + const result = + client.matchServiceAttachmentFromServiceAttachmentName(fakePath); + assert.strictEqual(result, 'serviceAttachmentValue'); + assert( + ( + client.pathTemplates.serviceAttachmentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('sharedRegionalCertificateAuthority', async () => { - const fakePath = "/rendered/path/sharedRegionalCertificateAuthority"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new memorystoreModule.v1beta.MemorystoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('sharedRegionalCertificateAuthorityPath', () => { - const result = client.sharedRegionalCertificateAuthorityPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromSharedRegionalCertificateAuthorityName', () => { - const result = client.matchProjectFromSharedRegionalCertificateAuthorityName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromSharedRegionalCertificateAuthorityName', () => { - const result = client.matchLocationFromSharedRegionalCertificateAuthorityName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('sharedRegionalCertificateAuthority', async () => { + const fakePath = '/rendered/path/sharedRegionalCertificateAuthority'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new memorystoreModule.v1beta.MemorystoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('sharedRegionalCertificateAuthorityPath', () => { + const result = client.sharedRegionalCertificateAuthorityPath( + 'projectValue', + 'locationValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromSharedRegionalCertificateAuthorityName', () => { + const result = + client.matchProjectFromSharedRegionalCertificateAuthorityName( + fakePath, + ); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromSharedRegionalCertificateAuthorityName', () => { + const result = + client.matchLocationFromSharedRegionalCertificateAuthorityName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.sharedRegionalCertificateAuthorityPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-metastore/.eslintignore b/packages/google-cloud-metastore/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-metastore/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-metastore/.eslintrc.json b/packages/google-cloud-metastore/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-metastore/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-metastore/README.md b/packages/google-cloud-metastore/README.md index 02884218b94f..b7d9dd7899fa 100644 --- a/packages/google-cloud-metastore/README.md +++ b/packages/google-cloud-metastore/README.md @@ -165,7 +165,7 @@ More Information: [Google Cloud Platform Launch Stages][launch_stages] ## Contributing -Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-metastore/CONTRIBUTING.md). +Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/CONTRIBUTING.md). Please note that this `README.md` and a variety of configuration files in this repository (including `.nycrc` and `tsconfig.json`) @@ -175,7 +175,7 @@ are generated from a central template. Apache Version 2.0 -See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-metastore/LICENSE) +See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/LICENSE) [shell_img]: https://gstatic.com/cloudssh/images/open-btn.png [projects]: https://console.cloud.google.com/project diff --git a/packages/google-cloud-metastore/protos/protos.d.ts b/packages/google-cloud-metastore/protos/protos.d.ts index 4a92b108db5b..09e839109ec9 100644 --- a/packages/google-cloud-metastore/protos/protos.d.ts +++ b/packages/google-cloud-metastore/protos/protos.d.ts @@ -21857,6 +21857,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -21874,6 +21877,9 @@ export namespace google { /** CommonLanguageSettings destinations. */ public destinations: google.api.ClientLibraryDestination[]; + /** CommonLanguageSettings selectiveGapicGeneration. */ + public selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); + /** * Creates a new CommonLanguageSettings instance using the specified properties. * @param [properties] Properties to set @@ -22574,6 +22580,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -22588,6 +22597,9 @@ export namespace google { /** PythonSettings common. */ public common?: (google.api.ICommonLanguageSettings|null); + /** PythonSettings experimentalFeatures. */ + public experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); + /** * Creates a new PythonSettings instance using the specified properties. * @param [properties] Properties to set @@ -22666,6 +22678,118 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + namespace PythonSettings { + + /** Properties of an ExperimentalFeatures. */ + interface IExperimentalFeatures { + + /** ExperimentalFeatures restAsyncIoEnabled */ + restAsyncIoEnabled?: (boolean|null); + + /** ExperimentalFeatures protobufPythonicTypesEnabled */ + protobufPythonicTypesEnabled?: (boolean|null); + + /** ExperimentalFeatures unversionedPackageDisabled */ + unversionedPackageDisabled?: (boolean|null); + } + + /** Represents an ExperimentalFeatures. */ + class ExperimentalFeatures implements IExperimentalFeatures { + + /** + * Constructs a new ExperimentalFeatures. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.PythonSettings.IExperimentalFeatures); + + /** ExperimentalFeatures restAsyncIoEnabled. */ + public restAsyncIoEnabled: boolean; + + /** ExperimentalFeatures protobufPythonicTypesEnabled. */ + public protobufPythonicTypesEnabled: boolean; + + /** ExperimentalFeatures unversionedPackageDisabled. */ + public unversionedPackageDisabled: boolean; + + /** + * Creates a new ExperimentalFeatures instance using the specified properties. + * @param [properties] Properties to set + * @returns ExperimentalFeatures instance + */ + public static create(properties?: google.api.PythonSettings.IExperimentalFeatures): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Encodes the specified ExperimentalFeatures message. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @param message ExperimentalFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.PythonSettings.IExperimentalFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExperimentalFeatures message, length delimited. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @param message ExperimentalFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.PythonSettings.IExperimentalFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExperimentalFeatures + * @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.api.PythonSettings.ExperimentalFeatures; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExperimentalFeatures + * @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.api.PythonSettings.ExperimentalFeatures; + + /** + * Verifies an ExperimentalFeatures 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 an ExperimentalFeatures message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExperimentalFeatures + */ + public static fromObject(object: { [k: string]: any }): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Creates a plain object from an ExperimentalFeatures message. Also converts values to other types if specified. + * @param message ExperimentalFeatures + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.PythonSettings.ExperimentalFeatures, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExperimentalFeatures to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExperimentalFeatures + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + /** Properties of a NodeSettings. */ interface INodeSettings { @@ -22992,6 +23116,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -23006,6 +23133,9 @@ export namespace google { /** GoSettings common. */ public common?: (google.api.ICommonLanguageSettings|null); + /** GoSettings renamedServices. */ + public renamedServices: { [k: string]: string }; + /** * Creates a new GoSettings instance using the specified properties. * @param [properties] Properties to set @@ -23330,6 +23460,109 @@ export namespace google { PACKAGE_MANAGER = 20 } + /** Properties of a SelectiveGapicGeneration. */ + interface ISelectiveGapicGeneration { + + /** SelectiveGapicGeneration methods */ + methods?: (string[]|null); + + /** SelectiveGapicGeneration generateOmittedAsInternal */ + generateOmittedAsInternal?: (boolean|null); + } + + /** Represents a SelectiveGapicGeneration. */ + class SelectiveGapicGeneration implements ISelectiveGapicGeneration { + + /** + * Constructs a new SelectiveGapicGeneration. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.ISelectiveGapicGeneration); + + /** SelectiveGapicGeneration methods. */ + public methods: string[]; + + /** SelectiveGapicGeneration generateOmittedAsInternal. */ + public generateOmittedAsInternal: boolean; + + /** + * Creates a new SelectiveGapicGeneration instance using the specified properties. + * @param [properties] Properties to set + * @returns SelectiveGapicGeneration instance + */ + public static create(properties?: google.api.ISelectiveGapicGeneration): google.api.SelectiveGapicGeneration; + + /** + * Encodes the specified SelectiveGapicGeneration message. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @param message SelectiveGapicGeneration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.ISelectiveGapicGeneration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SelectiveGapicGeneration message, length delimited. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @param message SelectiveGapicGeneration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.ISelectiveGapicGeneration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SelectiveGapicGeneration + * @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.api.SelectiveGapicGeneration; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SelectiveGapicGeneration + * @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.api.SelectiveGapicGeneration; + + /** + * Verifies a SelectiveGapicGeneration 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 SelectiveGapicGeneration message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SelectiveGapicGeneration + */ + public static fromObject(object: { [k: string]: any }): google.api.SelectiveGapicGeneration; + + /** + * Creates a plain object from a SelectiveGapicGeneration message. Also converts values to other types if specified. + * @param message SelectiveGapicGeneration + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.SelectiveGapicGeneration, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SelectiveGapicGeneration to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SelectiveGapicGeneration + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** LaunchStage enum. */ enum LaunchStage { LAUNCH_STAGE_UNSPECIFIED = 0, @@ -23711,6 +23944,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -23741,6 +23975,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -23790,6 +24027,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -23924,6 +24164,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -23965,6 +24208,9 @@ export namespace google { /** DescriptorProto reservedName. */ public reservedName: string[]; + /** DescriptorProto visibility. */ + public visibility: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility); + /** * Creates a new DescriptorProto instance using the specified properties. * @param [properties] Properties to set @@ -24812,6 +25058,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -24838,6 +25087,9 @@ export namespace google { /** EnumDescriptorProto reservedName. */ public reservedName: string[]; + /** EnumDescriptorProto visibility. */ + public visibility: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility); + /** * Creates a new EnumDescriptorProto instance using the specified properties. * @param [properties] Properties to set @@ -25772,6 +26024,9 @@ export namespace google { /** FieldOptions features */ features?: (google.protobuf.IFeatureSet|null); + /** FieldOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** FieldOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); @@ -25827,6 +26082,9 @@ export namespace google { /** FieldOptions features. */ public features?: (google.protobuf.IFeatureSet|null); + /** FieldOptions featureSupport. */ + public featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** FieldOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; @@ -26047,6 +26305,121 @@ export namespace google { */ public static getTypeUrl(typeUrlPrefix?: string): string; } + + /** Properties of a FeatureSupport. */ + interface IFeatureSupport { + + /** FeatureSupport editionIntroduced */ + editionIntroduced?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSupport editionDeprecated */ + editionDeprecated?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSupport deprecationWarning */ + deprecationWarning?: (string|null); + + /** FeatureSupport editionRemoved */ + editionRemoved?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + } + + /** Represents a FeatureSupport. */ + class FeatureSupport implements IFeatureSupport { + + /** + * Constructs a new FeatureSupport. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.FieldOptions.IFeatureSupport); + + /** FeatureSupport editionIntroduced. */ + public editionIntroduced: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSupport editionDeprecated. */ + public editionDeprecated: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSupport deprecationWarning. */ + public deprecationWarning: string; + + /** FeatureSupport editionRemoved. */ + public editionRemoved: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** + * Creates a new FeatureSupport instance using the specified properties. + * @param [properties] Properties to set + * @returns FeatureSupport instance + */ + public static create(properties?: google.protobuf.FieldOptions.IFeatureSupport): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Encodes the specified FeatureSupport message. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @param message FeatureSupport message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.FieldOptions.IFeatureSupport, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FeatureSupport message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @param message FeatureSupport message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.FieldOptions.IFeatureSupport, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FeatureSupport + * @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.protobuf.FieldOptions.FeatureSupport; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FeatureSupport + * @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.protobuf.FieldOptions.FeatureSupport; + + /** + * Verifies a FeatureSupport 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 FeatureSupport message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FeatureSupport + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Creates a plain object from a FeatureSupport message. Also converts values to other types if specified. + * @param message FeatureSupport + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldOptions.FeatureSupport, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FeatureSupport to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FeatureSupport + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } } /** Properties of an OneofOptions. */ @@ -26285,6 +26658,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -26307,6 +26683,9 @@ export namespace google { /** EnumValueOptions debugRedact. */ public debugRedact: boolean; + /** EnumValueOptions featureSupport. */ + public featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; @@ -26899,6 +27278,12 @@ export namespace google { /** FeatureSet jsonFormat */ jsonFormat?: (google.protobuf.FeatureSet.JsonFormat|keyof typeof google.protobuf.FeatureSet.JsonFormat|null); + + /** FeatureSet enforceNamingStyle */ + enforceNamingStyle?: (google.protobuf.FeatureSet.EnforceNamingStyle|keyof typeof google.protobuf.FeatureSet.EnforceNamingStyle|null); + + /** FeatureSet defaultSymbolVisibility */ + defaultSymbolVisibility?: (google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|keyof typeof google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|null); } /** Represents a FeatureSet. */ @@ -26928,6 +27313,12 @@ export namespace google { /** FeatureSet jsonFormat. */ public jsonFormat: (google.protobuf.FeatureSet.JsonFormat|keyof typeof google.protobuf.FeatureSet.JsonFormat); + /** FeatureSet enforceNamingStyle. */ + public enforceNamingStyle: (google.protobuf.FeatureSet.EnforceNamingStyle|keyof typeof google.protobuf.FeatureSet.EnforceNamingStyle); + + /** FeatureSet defaultSymbolVisibility. */ + public defaultSymbolVisibility: (google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|keyof typeof google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility); + /** * Creates a new FeatureSet instance using the specified properties. * @param [properties] Properties to set @@ -27050,6 +27441,116 @@ export namespace google { ALLOW = 1, LEGACY_BEST_EFFORT = 2 } + + /** EnforceNamingStyle enum. */ + enum EnforceNamingStyle { + ENFORCE_NAMING_STYLE_UNKNOWN = 0, + STYLE2024 = 1, + STYLE_LEGACY = 2 + } + + /** Properties of a VisibilityFeature. */ + interface IVisibilityFeature { + } + + /** Represents a VisibilityFeature. */ + class VisibilityFeature implements IVisibilityFeature { + + /** + * Constructs a new VisibilityFeature. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.FeatureSet.IVisibilityFeature); + + /** + * Creates a new VisibilityFeature instance using the specified properties. + * @param [properties] Properties to set + * @returns VisibilityFeature instance + */ + public static create(properties?: google.protobuf.FeatureSet.IVisibilityFeature): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Encodes the specified VisibilityFeature message. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @param message VisibilityFeature message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.FeatureSet.IVisibilityFeature, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified VisibilityFeature message, length delimited. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @param message VisibilityFeature message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.FeatureSet.IVisibilityFeature, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns VisibilityFeature + * @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.protobuf.FeatureSet.VisibilityFeature; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns VisibilityFeature + * @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.protobuf.FeatureSet.VisibilityFeature; + + /** + * Verifies a VisibilityFeature 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 VisibilityFeature message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns VisibilityFeature + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Creates a plain object from a VisibilityFeature message. Also converts values to other types if specified. + * @param message VisibilityFeature + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FeatureSet.VisibilityFeature, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this VisibilityFeature to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for VisibilityFeature + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace VisibilityFeature { + + /** DefaultSymbolVisibility enum. */ + enum DefaultSymbolVisibility { + DEFAULT_SYMBOL_VISIBILITY_UNKNOWN = 0, + EXPORT_ALL = 1, + EXPORT_TOP_LEVEL = 2, + LOCAL_ALL = 3, + STRICT = 4 + } + } } /** Properties of a FeatureSetDefaults. */ @@ -27169,8 +27670,11 @@ export namespace google { /** FeatureSetEditionDefault edition */ edition?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); - /** FeatureSetEditionDefault features */ - features?: (google.protobuf.IFeatureSet|null); + /** FeatureSetEditionDefault overridableFeatures */ + overridableFeatures?: (google.protobuf.IFeatureSet|null); + + /** FeatureSetEditionDefault fixedFeatures */ + fixedFeatures?: (google.protobuf.IFeatureSet|null); } /** Represents a FeatureSetEditionDefault. */ @@ -27185,8 +27689,11 @@ export namespace google { /** FeatureSetEditionDefault edition. */ public edition: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); - /** FeatureSetEditionDefault features. */ - public features?: (google.protobuf.IFeatureSet|null); + /** FeatureSetEditionDefault overridableFeatures. */ + public overridableFeatures?: (google.protobuf.IFeatureSet|null); + + /** FeatureSetEditionDefault fixedFeatures. */ + public fixedFeatures?: (google.protobuf.IFeatureSet|null); /** * Creates a new FeatureSetEditionDefault instance using the specified properties. @@ -27719,6 +28226,13 @@ export namespace google { } } + /** SymbolVisibility enum. */ + enum SymbolVisibility { + VISIBILITY_UNSET = 0, + VISIBILITY_LOCAL = 1, + VISIBILITY_EXPORT = 2 + } + /** Properties of a Duration. */ interface IDuration { diff --git a/packages/google-cloud-metastore/protos/protos.js b/packages/google-cloud-metastore/protos/protos.js index ccca95001ab0..b67a916ca92c 100644 --- a/packages/google-cloud-metastore/protos/protos.js +++ b/packages/google-cloud-metastore/protos/protos.js @@ -53759,6 +53759,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -53793,6 +53794,14 @@ */ CommonLanguageSettings.prototype.destinations = $util.emptyArray; + /** + * CommonLanguageSettings selectiveGapicGeneration. + * @member {google.api.ISelectiveGapicGeneration|null|undefined} selectiveGapicGeneration + * @memberof google.api.CommonLanguageSettings + * @instance + */ + CommonLanguageSettings.prototype.selectiveGapicGeneration = null; + /** * Creates a new CommonLanguageSettings instance using the specified properties. * @function create @@ -53825,6 +53834,8 @@ writer.int32(message.destinations[i]); writer.ldelim(); } + if (message.selectiveGapicGeneration != null && Object.hasOwnProperty.call(message, "selectiveGapicGeneration")) + $root.google.api.SelectiveGapicGeneration.encode(message.selectiveGapicGeneration, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); return writer; }; @@ -53876,6 +53887,10 @@ message.destinations.push(reader.int32()); break; } + case 3: { + message.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -53927,6 +53942,11 @@ break; } } + if (message.selectiveGapicGeneration != null && message.hasOwnProperty("selectiveGapicGeneration")) { + var error = $root.google.api.SelectiveGapicGeneration.verify(message.selectiveGapicGeneration); + if (error) + return "selectiveGapicGeneration." + error; + } return null; }; @@ -53969,6 +53989,11 @@ break; } } + if (object.selectiveGapicGeneration != null) { + if (typeof object.selectiveGapicGeneration !== "object") + throw TypeError(".google.api.CommonLanguageSettings.selectiveGapicGeneration: object expected"); + message.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.fromObject(object.selectiveGapicGeneration); + } return message; }; @@ -53987,8 +54012,10 @@ var object = {}; if (options.arrays || options.defaults) object.destinations = []; - if (options.defaults) + if (options.defaults) { object.referenceDocsUri = ""; + object.selectiveGapicGeneration = null; + } if (message.referenceDocsUri != null && message.hasOwnProperty("referenceDocsUri")) object.referenceDocsUri = message.referenceDocsUri; if (message.destinations && message.destinations.length) { @@ -53996,6 +54023,8 @@ for (var j = 0; j < message.destinations.length; ++j) object.destinations[j] = options.enums === String ? $root.google.api.ClientLibraryDestination[message.destinations[j]] === undefined ? message.destinations[j] : $root.google.api.ClientLibraryDestination[message.destinations[j]] : message.destinations[j]; } + if (message.selectiveGapicGeneration != null && message.hasOwnProperty("selectiveGapicGeneration")) + object.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.toObject(message.selectiveGapicGeneration, options); return object; }; @@ -55818,6 +55847,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -55843,6 +55873,14 @@ */ PythonSettings.prototype.common = null; + /** + * PythonSettings experimentalFeatures. + * @member {google.api.PythonSettings.IExperimentalFeatures|null|undefined} experimentalFeatures + * @memberof google.api.PythonSettings + * @instance + */ + PythonSettings.prototype.experimentalFeatures = null; + /** * Creates a new PythonSettings instance using the specified properties. * @function create @@ -55869,6 +55907,8 @@ writer = $Writer.create(); if (message.common != null && Object.hasOwnProperty.call(message, "common")) $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.experimentalFeatures != null && Object.hasOwnProperty.call(message, "experimentalFeatures")) + $root.google.api.PythonSettings.ExperimentalFeatures.encode(message.experimentalFeatures, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; @@ -55909,6 +55949,10 @@ message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); break; } + case 2: { + message.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -55949,6 +55993,11 @@ if (error) return "common." + error; } + if (message.experimentalFeatures != null && message.hasOwnProperty("experimentalFeatures")) { + var error = $root.google.api.PythonSettings.ExperimentalFeatures.verify(message.experimentalFeatures); + if (error) + return "experimentalFeatures." + error; + } return null; }; @@ -55969,6 +56018,11 @@ throw TypeError(".google.api.PythonSettings.common: object expected"); message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); } + if (object.experimentalFeatures != null) { + if (typeof object.experimentalFeatures !== "object") + throw TypeError(".google.api.PythonSettings.experimentalFeatures: object expected"); + message.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.fromObject(object.experimentalFeatures); + } return message; }; @@ -55985,10 +56039,14 @@ if (!options) options = {}; var object = {}; - if (options.defaults) + if (options.defaults) { object.common = null; + object.experimentalFeatures = null; + } if (message.common != null && message.hasOwnProperty("common")) object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + if (message.experimentalFeatures != null && message.hasOwnProperty("experimentalFeatures")) + object.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.toObject(message.experimentalFeatures, options); return object; }; @@ -56018,6 +56076,258 @@ return typeUrlPrefix + "/google.api.PythonSettings"; }; + PythonSettings.ExperimentalFeatures = (function() { + + /** + * Properties of an ExperimentalFeatures. + * @memberof google.api.PythonSettings + * @interface IExperimentalFeatures + * @property {boolean|null} [restAsyncIoEnabled] ExperimentalFeatures restAsyncIoEnabled + * @property {boolean|null} [protobufPythonicTypesEnabled] ExperimentalFeatures protobufPythonicTypesEnabled + * @property {boolean|null} [unversionedPackageDisabled] ExperimentalFeatures unversionedPackageDisabled + */ + + /** + * Constructs a new ExperimentalFeatures. + * @memberof google.api.PythonSettings + * @classdesc Represents an ExperimentalFeatures. + * @implements IExperimentalFeatures + * @constructor + * @param {google.api.PythonSettings.IExperimentalFeatures=} [properties] Properties to set + */ + function ExperimentalFeatures(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]]; + } + + /** + * ExperimentalFeatures restAsyncIoEnabled. + * @member {boolean} restAsyncIoEnabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.restAsyncIoEnabled = false; + + /** + * ExperimentalFeatures protobufPythonicTypesEnabled. + * @member {boolean} protobufPythonicTypesEnabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.protobufPythonicTypesEnabled = false; + + /** + * ExperimentalFeatures unversionedPackageDisabled. + * @member {boolean} unversionedPackageDisabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.unversionedPackageDisabled = false; + + /** + * Creates a new ExperimentalFeatures instance using the specified properties. + * @function create + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures=} [properties] Properties to set + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures instance + */ + ExperimentalFeatures.create = function create(properties) { + return new ExperimentalFeatures(properties); + }; + + /** + * Encodes the specified ExperimentalFeatures message. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @function encode + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures} message ExperimentalFeatures message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExperimentalFeatures.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.restAsyncIoEnabled != null && Object.hasOwnProperty.call(message, "restAsyncIoEnabled")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.restAsyncIoEnabled); + if (message.protobufPythonicTypesEnabled != null && Object.hasOwnProperty.call(message, "protobufPythonicTypesEnabled")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.protobufPythonicTypesEnabled); + if (message.unversionedPackageDisabled != null && Object.hasOwnProperty.call(message, "unversionedPackageDisabled")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.unversionedPackageDisabled); + return writer; + }; + + /** + * Encodes the specified ExperimentalFeatures message, length delimited. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures} message ExperimentalFeatures message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExperimentalFeatures.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer. + * @function decode + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExperimentalFeatures.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.PythonSettings.ExperimentalFeatures(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.restAsyncIoEnabled = reader.bool(); + break; + } + case 2: { + message.protobufPythonicTypesEnabled = reader.bool(); + break; + } + case 3: { + message.unversionedPackageDisabled = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExperimentalFeatures.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExperimentalFeatures message. + * @function verify + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExperimentalFeatures.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.restAsyncIoEnabled != null && message.hasOwnProperty("restAsyncIoEnabled")) + if (typeof message.restAsyncIoEnabled !== "boolean") + return "restAsyncIoEnabled: boolean expected"; + if (message.protobufPythonicTypesEnabled != null && message.hasOwnProperty("protobufPythonicTypesEnabled")) + if (typeof message.protobufPythonicTypesEnabled !== "boolean") + return "protobufPythonicTypesEnabled: boolean expected"; + if (message.unversionedPackageDisabled != null && message.hasOwnProperty("unversionedPackageDisabled")) + if (typeof message.unversionedPackageDisabled !== "boolean") + return "unversionedPackageDisabled: boolean expected"; + return null; + }; + + /** + * Creates an ExperimentalFeatures message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {Object.} object Plain object + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + */ + ExperimentalFeatures.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.PythonSettings.ExperimentalFeatures) + return object; + var message = new $root.google.api.PythonSettings.ExperimentalFeatures(); + if (object.restAsyncIoEnabled != null) + message.restAsyncIoEnabled = Boolean(object.restAsyncIoEnabled); + if (object.protobufPythonicTypesEnabled != null) + message.protobufPythonicTypesEnabled = Boolean(object.protobufPythonicTypesEnabled); + if (object.unversionedPackageDisabled != null) + message.unversionedPackageDisabled = Boolean(object.unversionedPackageDisabled); + return message; + }; + + /** + * Creates a plain object from an ExperimentalFeatures message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.ExperimentalFeatures} message ExperimentalFeatures + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExperimentalFeatures.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.restAsyncIoEnabled = false; + object.protobufPythonicTypesEnabled = false; + object.unversionedPackageDisabled = false; + } + if (message.restAsyncIoEnabled != null && message.hasOwnProperty("restAsyncIoEnabled")) + object.restAsyncIoEnabled = message.restAsyncIoEnabled; + if (message.protobufPythonicTypesEnabled != null && message.hasOwnProperty("protobufPythonicTypesEnabled")) + object.protobufPythonicTypesEnabled = message.protobufPythonicTypesEnabled; + if (message.unversionedPackageDisabled != null && message.hasOwnProperty("unversionedPackageDisabled")) + object.unversionedPackageDisabled = message.unversionedPackageDisabled; + return object; + }; + + /** + * Converts this ExperimentalFeatures to JSON. + * @function toJSON + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + * @returns {Object.} JSON object + */ + ExperimentalFeatures.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExperimentalFeatures + * @function getTypeUrl + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExperimentalFeatures.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.PythonSettings.ExperimentalFeatures"; + }; + + return ExperimentalFeatures; + })(); + return PythonSettings; })(); @@ -56894,6 +57204,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -56905,6 +57216,7 @@ * @param {google.api.IGoSettings=} [properties] Properties to set */ function GoSettings(properties) { + this.renamedServices = {}; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -56919,6 +57231,14 @@ */ GoSettings.prototype.common = null; + /** + * GoSettings renamedServices. + * @member {Object.} renamedServices + * @memberof google.api.GoSettings + * @instance + */ + GoSettings.prototype.renamedServices = $util.emptyObject; + /** * Creates a new GoSettings instance using the specified properties. * @function create @@ -56945,6 +57265,9 @@ writer = $Writer.create(); if (message.common != null && Object.hasOwnProperty.call(message, "common")) $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.renamedServices != null && Object.hasOwnProperty.call(message, "renamedServices")) + for (var keys = Object.keys(message.renamedServices), i = 0; i < keys.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.renamedServices[keys[i]]).ldelim(); return writer; }; @@ -56975,7 +57298,7 @@ GoSettings.decode = function decode(reader, length, error) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.GoSettings(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.GoSettings(), key, value; while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) @@ -56985,6 +57308,29 @@ message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); break; } + case 2: { + if (message.renamedServices === $util.emptyObject) + message.renamedServices = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = ""; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = reader.string(); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.renamedServices[key] = value; + break; + } default: reader.skipType(tag & 7); break; @@ -57025,6 +57371,14 @@ if (error) return "common." + error; } + if (message.renamedServices != null && message.hasOwnProperty("renamedServices")) { + if (!$util.isObject(message.renamedServices)) + return "renamedServices: object expected"; + var key = Object.keys(message.renamedServices); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.renamedServices[key[i]])) + return "renamedServices: string{k:string} expected"; + } return null; }; @@ -57045,6 +57399,13 @@ throw TypeError(".google.api.GoSettings.common: object expected"); message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); } + if (object.renamedServices) { + if (typeof object.renamedServices !== "object") + throw TypeError(".google.api.GoSettings.renamedServices: object expected"); + message.renamedServices = {}; + for (var keys = Object.keys(object.renamedServices), i = 0; i < keys.length; ++i) + message.renamedServices[keys[i]] = String(object.renamedServices[keys[i]]); + } return message; }; @@ -57061,10 +57422,18 @@ if (!options) options = {}; var object = {}; + if (options.objects || options.defaults) + object.renamedServices = {}; if (options.defaults) object.common = null; if (message.common != null && message.hasOwnProperty("common")) object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + var keys2; + if (message.renamedServices && (keys2 = Object.keys(message.renamedServices)).length) { + object.renamedServices = {}; + for (var j = 0; j < keys2.length; ++j) + object.renamedServices[keys2[j]] = message.renamedServices[keys2[j]]; + } return object; }; @@ -57703,29 +58072,274 @@ return values; })(); - /** - * LaunchStage enum. - * @name google.api.LaunchStage - * @enum {number} - * @property {number} LAUNCH_STAGE_UNSPECIFIED=0 LAUNCH_STAGE_UNSPECIFIED value - * @property {number} UNIMPLEMENTED=6 UNIMPLEMENTED value - * @property {number} PRELAUNCH=7 PRELAUNCH value - * @property {number} EARLY_ACCESS=1 EARLY_ACCESS value - * @property {number} ALPHA=2 ALPHA value - * @property {number} BETA=3 BETA value - * @property {number} GA=4 GA value - * @property {number} DEPRECATED=5 DEPRECATED value - */ - api.LaunchStage = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "LAUNCH_STAGE_UNSPECIFIED"] = 0; - values[valuesById[6] = "UNIMPLEMENTED"] = 6; - values[valuesById[7] = "PRELAUNCH"] = 7; - values[valuesById[1] = "EARLY_ACCESS"] = 1; - values[valuesById[2] = "ALPHA"] = 2; - values[valuesById[3] = "BETA"] = 3; - values[valuesById[4] = "GA"] = 4; - values[valuesById[5] = "DEPRECATED"] = 5; + api.SelectiveGapicGeneration = (function() { + + /** + * Properties of a SelectiveGapicGeneration. + * @memberof google.api + * @interface ISelectiveGapicGeneration + * @property {Array.|null} [methods] SelectiveGapicGeneration methods + * @property {boolean|null} [generateOmittedAsInternal] SelectiveGapicGeneration generateOmittedAsInternal + */ + + /** + * Constructs a new SelectiveGapicGeneration. + * @memberof google.api + * @classdesc Represents a SelectiveGapicGeneration. + * @implements ISelectiveGapicGeneration + * @constructor + * @param {google.api.ISelectiveGapicGeneration=} [properties] Properties to set + */ + function SelectiveGapicGeneration(properties) { + this.methods = []; + 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]]; + } + + /** + * SelectiveGapicGeneration methods. + * @member {Array.} methods + * @memberof google.api.SelectiveGapicGeneration + * @instance + */ + SelectiveGapicGeneration.prototype.methods = $util.emptyArray; + + /** + * SelectiveGapicGeneration generateOmittedAsInternal. + * @member {boolean} generateOmittedAsInternal + * @memberof google.api.SelectiveGapicGeneration + * @instance + */ + SelectiveGapicGeneration.prototype.generateOmittedAsInternal = false; + + /** + * Creates a new SelectiveGapicGeneration instance using the specified properties. + * @function create + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration=} [properties] Properties to set + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration instance + */ + SelectiveGapicGeneration.create = function create(properties) { + return new SelectiveGapicGeneration(properties); + }; + + /** + * Encodes the specified SelectiveGapicGeneration message. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @function encode + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration} message SelectiveGapicGeneration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SelectiveGapicGeneration.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.methods != null && message.methods.length) + for (var i = 0; i < message.methods.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.methods[i]); + if (message.generateOmittedAsInternal != null && Object.hasOwnProperty.call(message, "generateOmittedAsInternal")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.generateOmittedAsInternal); + return writer; + }; + + /** + * Encodes the specified SelectiveGapicGeneration message, length delimited. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration} message SelectiveGapicGeneration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SelectiveGapicGeneration.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer. + * @function decode + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SelectiveGapicGeneration.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.SelectiveGapicGeneration(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + if (!(message.methods && message.methods.length)) + message.methods = []; + message.methods.push(reader.string()); + break; + } + case 2: { + message.generateOmittedAsInternal = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SelectiveGapicGeneration.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SelectiveGapicGeneration message. + * @function verify + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SelectiveGapicGeneration.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.methods != null && message.hasOwnProperty("methods")) { + if (!Array.isArray(message.methods)) + return "methods: array expected"; + for (var i = 0; i < message.methods.length; ++i) + if (!$util.isString(message.methods[i])) + return "methods: string[] expected"; + } + if (message.generateOmittedAsInternal != null && message.hasOwnProperty("generateOmittedAsInternal")) + if (typeof message.generateOmittedAsInternal !== "boolean") + return "generateOmittedAsInternal: boolean expected"; + return null; + }; + + /** + * Creates a SelectiveGapicGeneration message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {Object.} object Plain object + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + */ + SelectiveGapicGeneration.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.SelectiveGapicGeneration) + return object; + var message = new $root.google.api.SelectiveGapicGeneration(); + if (object.methods) { + if (!Array.isArray(object.methods)) + throw TypeError(".google.api.SelectiveGapicGeneration.methods: array expected"); + message.methods = []; + for (var i = 0; i < object.methods.length; ++i) + message.methods[i] = String(object.methods[i]); + } + if (object.generateOmittedAsInternal != null) + message.generateOmittedAsInternal = Boolean(object.generateOmittedAsInternal); + return message; + }; + + /** + * Creates a plain object from a SelectiveGapicGeneration message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.SelectiveGapicGeneration} message SelectiveGapicGeneration + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SelectiveGapicGeneration.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.methods = []; + if (options.defaults) + object.generateOmittedAsInternal = false; + if (message.methods && message.methods.length) { + object.methods = []; + for (var j = 0; j < message.methods.length; ++j) + object.methods[j] = message.methods[j]; + } + if (message.generateOmittedAsInternal != null && message.hasOwnProperty("generateOmittedAsInternal")) + object.generateOmittedAsInternal = message.generateOmittedAsInternal; + return object; + }; + + /** + * Converts this SelectiveGapicGeneration to JSON. + * @function toJSON + * @memberof google.api.SelectiveGapicGeneration + * @instance + * @returns {Object.} JSON object + */ + SelectiveGapicGeneration.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SelectiveGapicGeneration + * @function getTypeUrl + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SelectiveGapicGeneration.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.SelectiveGapicGeneration"; + }; + + return SelectiveGapicGeneration; + })(); + + /** + * LaunchStage enum. + * @name google.api.LaunchStage + * @enum {number} + * @property {number} LAUNCH_STAGE_UNSPECIFIED=0 LAUNCH_STAGE_UNSPECIFIED value + * @property {number} UNIMPLEMENTED=6 UNIMPLEMENTED value + * @property {number} PRELAUNCH=7 PRELAUNCH value + * @property {number} EARLY_ACCESS=1 EARLY_ACCESS value + * @property {number} ALPHA=2 ALPHA value + * @property {number} BETA=3 BETA value + * @property {number} GA=4 GA value + * @property {number} DEPRECATED=5 DEPRECATED value + */ + api.LaunchStage = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "LAUNCH_STAGE_UNSPECIFIED"] = 0; + values[valuesById[6] = "UNIMPLEMENTED"] = 6; + values[valuesById[7] = "PRELAUNCH"] = 7; + values[valuesById[1] = "EARLY_ACCESS"] = 1; + values[valuesById[2] = "ALPHA"] = 2; + values[valuesById[3] = "BETA"] = 3; + values[valuesById[4] = "GA"] = 4; + values[valuesById[5] = "DEPRECATED"] = 5; return values; })(); @@ -58688,6 +59302,7 @@ * @name google.protobuf.Edition * @enum {number} * @property {number} EDITION_UNKNOWN=0 EDITION_UNKNOWN value + * @property {number} EDITION_LEGACY=900 EDITION_LEGACY value * @property {number} EDITION_PROTO2=998 EDITION_PROTO2 value * @property {number} EDITION_PROTO3=999 EDITION_PROTO3 value * @property {number} EDITION_2023=1000 EDITION_2023 value @@ -58702,6 +59317,7 @@ protobuf.Edition = (function() { var valuesById = {}, values = Object.create(valuesById); values[valuesById[0] = "EDITION_UNKNOWN"] = 0; + values[valuesById[900] = "EDITION_LEGACY"] = 900; values[valuesById[998] = "EDITION_PROTO2"] = 998; values[valuesById[999] = "EDITION_PROTO3"] = 999; values[valuesById[1000] = "EDITION_2023"] = 1000; @@ -58726,6 +59342,7 @@ * @property {Array.|null} [dependency] FileDescriptorProto dependency * @property {Array.|null} [publicDependency] FileDescriptorProto publicDependency * @property {Array.|null} [weakDependency] FileDescriptorProto weakDependency + * @property {Array.|null} [optionDependency] FileDescriptorProto optionDependency * @property {Array.|null} [messageType] FileDescriptorProto messageType * @property {Array.|null} [enumType] FileDescriptorProto enumType * @property {Array.|null} [service] FileDescriptorProto service @@ -58748,6 +59365,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -58798,6 +59416,14 @@ */ FileDescriptorProto.prototype.weakDependency = $util.emptyArray; + /** + * FileDescriptorProto optionDependency. + * @member {Array.} optionDependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.optionDependency = $util.emptyArray; + /** * FileDescriptorProto messageType. * @member {Array.} messageType @@ -58919,6 +59545,9 @@ writer.uint32(/* id 12, wireType 2 =*/98).string(message.syntax); if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) writer.uint32(/* id 14, wireType 0 =*/112).int32(message.edition); + if (message.optionDependency != null && message.optionDependency.length) + for (var i = 0; i < message.optionDependency.length; ++i) + writer.uint32(/* id 15, wireType 2 =*/122).string(message.optionDependency[i]); return writer; }; @@ -58991,6 +59620,12 @@ message.weakDependency.push(reader.int32()); break; } + case 15: { + if (!(message.optionDependency && message.optionDependency.length)) + message.optionDependency = []; + message.optionDependency.push(reader.string()); + break; + } case 4: { if (!(message.messageType && message.messageType.length)) message.messageType = []; @@ -59093,6 +59728,13 @@ if (!$util.isInteger(message.weakDependency[i])) return "weakDependency: integer[] expected"; } + if (message.optionDependency != null && message.hasOwnProperty("optionDependency")) { + if (!Array.isArray(message.optionDependency)) + return "optionDependency: array expected"; + for (var i = 0; i < message.optionDependency.length; ++i) + if (!$util.isString(message.optionDependency[i])) + return "optionDependency: string[] expected"; + } if (message.messageType != null && message.hasOwnProperty("messageType")) { if (!Array.isArray(message.messageType)) return "messageType: array expected"; @@ -59147,6 +59789,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -59199,6 +59842,13 @@ for (var i = 0; i < object.weakDependency.length; ++i) message.weakDependency[i] = object.weakDependency[i] | 0; } + if (object.optionDependency) { + if (!Array.isArray(object.optionDependency)) + throw TypeError(".google.protobuf.FileDescriptorProto.optionDependency: array expected"); + message.optionDependency = []; + for (var i = 0; i < object.optionDependency.length; ++i) + message.optionDependency[i] = String(object.optionDependency[i]); + } if (object.messageType) { if (!Array.isArray(object.messageType)) throw TypeError(".google.protobuf.FileDescriptorProto.messageType: array expected"); @@ -59262,6 +59912,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -59327,6 +59981,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -59383,6 +60038,11 @@ object.syntax = message.syntax; if (message.edition != null && message.hasOwnProperty("edition")) object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.optionDependency && message.optionDependency.length) { + object.optionDependency = []; + for (var j = 0; j < message.optionDependency.length; ++j) + object.optionDependency[j] = message.optionDependency[j]; + } return object; }; @@ -59431,6 +60091,7 @@ * @property {google.protobuf.IMessageOptions|null} [options] DescriptorProto options * @property {Array.|null} [reservedRange] DescriptorProto reservedRange * @property {Array.|null} [reservedName] DescriptorProto reservedName + * @property {google.protobuf.SymbolVisibility|null} [visibility] DescriptorProto visibility */ /** @@ -59536,6 +60197,14 @@ */ DescriptorProto.prototype.reservedName = $util.emptyArray; + /** + * DescriptorProto visibility. + * @member {google.protobuf.SymbolVisibility} visibility + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.visibility = 0; + /** * Creates a new DescriptorProto instance using the specified properties. * @function create @@ -59588,6 +60257,8 @@ if (message.reservedName != null && message.reservedName.length) for (var i = 0; i < message.reservedName.length; ++i) writer.uint32(/* id 10, wireType 2 =*/82).string(message.reservedName[i]); + if (message.visibility != null && Object.hasOwnProperty.call(message, "visibility")) + writer.uint32(/* id 11, wireType 0 =*/88).int32(message.visibility); return writer; }; @@ -59680,6 +60351,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -59793,6 +60468,15 @@ if (!$util.isString(message.reservedName[i])) return "reservedName: string[] expected"; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + switch (message.visibility) { + default: + return "visibility: enum value expected"; + case 0: + case 1: + case 2: + break; + } return null; }; @@ -59892,6 +60576,26 @@ for (var i = 0; i < object.reservedName.length; ++i) message.reservedName[i] = String(object.reservedName[i]); } + switch (object.visibility) { + default: + if (typeof object.visibility === "number") { + message.visibility = object.visibility; + break; + } + break; + case "VISIBILITY_UNSET": + case 0: + message.visibility = 0; + break; + case "VISIBILITY_LOCAL": + case 1: + message.visibility = 1; + break; + case "VISIBILITY_EXPORT": + case 2: + message.visibility = 2; + break; + } return message; }; @@ -59921,6 +60625,7 @@ if (options.defaults) { object.name = ""; object.options = null; + object.visibility = options.enums === String ? "VISIBILITY_UNSET" : 0; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -59966,6 +60671,8 @@ for (var j = 0; j < message.reservedName.length; ++j) object.reservedName[j] = message.reservedName[j]; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + object.visibility = options.enums === String ? $root.google.protobuf.SymbolVisibility[message.visibility] === undefined ? message.visibility : $root.google.protobuf.SymbolVisibility[message.visibility] : message.visibility; return object; }; @@ -62010,6 +62717,7 @@ * @property {google.protobuf.IEnumOptions|null} [options] EnumDescriptorProto options * @property {Array.|null} [reservedRange] EnumDescriptorProto reservedRange * @property {Array.|null} [reservedName] EnumDescriptorProto reservedName + * @property {google.protobuf.SymbolVisibility|null} [visibility] EnumDescriptorProto visibility */ /** @@ -62070,6 +62778,14 @@ */ EnumDescriptorProto.prototype.reservedName = $util.emptyArray; + /** + * EnumDescriptorProto visibility. + * @member {google.protobuf.SymbolVisibility} visibility + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.visibility = 0; + /** * Creates a new EnumDescriptorProto instance using the specified properties. * @function create @@ -62107,6 +62823,8 @@ if (message.reservedName != null && message.reservedName.length) for (var i = 0; i < message.reservedName.length; ++i) writer.uint32(/* id 5, wireType 2 =*/42).string(message.reservedName[i]); + if (message.visibility != null && Object.hasOwnProperty.call(message, "visibility")) + writer.uint32(/* id 6, wireType 0 =*/48).int32(message.visibility); return writer; }; @@ -62169,6 +62887,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -62237,6 +62959,15 @@ if (!$util.isString(message.reservedName[i])) return "reservedName: string[] expected"; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + switch (message.visibility) { + default: + return "visibility: enum value expected"; + case 0: + case 1: + case 2: + break; + } return null; }; @@ -62286,6 +63017,26 @@ for (var i = 0; i < object.reservedName.length; ++i) message.reservedName[i] = String(object.reservedName[i]); } + switch (object.visibility) { + default: + if (typeof object.visibility === "number") { + message.visibility = object.visibility; + break; + } + break; + case "VISIBILITY_UNSET": + case 0: + message.visibility = 0; + break; + case "VISIBILITY_LOCAL": + case 1: + message.visibility = 1; + break; + case "VISIBILITY_EXPORT": + case 2: + message.visibility = 2; + break; + } return message; }; @@ -62310,6 +63061,7 @@ if (options.defaults) { object.name = ""; object.options = null; + object.visibility = options.enums === String ? "VISIBILITY_UNSET" : 0; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -62330,6 +63082,8 @@ for (var j = 0; j < message.reservedName.length; ++j) object.reservedName[j] = message.reservedName[j]; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + object.visibility = options.enums === String ? $root.google.protobuf.SymbolVisibility[message.visibility] === undefined ? message.visibility : $root.google.protobuf.SymbolVisibility[message.visibility] : message.visibility; return object; }; @@ -64648,6 +65402,7 @@ * @property {Array.|null} [targets] FieldOptions targets * @property {Array.|null} [editionDefaults] FieldOptions editionDefaults * @property {google.protobuf.IFeatureSet|null} [features] FieldOptions features + * @property {google.protobuf.FieldOptions.IFeatureSupport|null} [featureSupport] FieldOptions featureSupport * @property {Array.|null} [uninterpretedOption] FieldOptions uninterpretedOption * @property {Array.|null} [".google.api.fieldBehavior"] FieldOptions .google.api.fieldBehavior * @property {google.api.IResourceReference|null} [".google.api.resourceReference"] FieldOptions .google.api.resourceReference @@ -64768,6 +65523,14 @@ */ FieldOptions.prototype.features = null; + /** + * FieldOptions featureSupport. + * @member {google.protobuf.FieldOptions.IFeatureSupport|null|undefined} featureSupport + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.featureSupport = null; + /** * FieldOptions uninterpretedOption. * @member {Array.} uninterpretedOption @@ -64842,6 +65605,8 @@ $root.google.protobuf.FieldOptions.EditionDefault.encode(message.editionDefaults[i], writer.uint32(/* id 20, wireType 2 =*/162).fork()).ldelim(); if (message.features != null && Object.hasOwnProperty.call(message, "features")) $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 21, wireType 2 =*/170).fork()).ldelim(); + if (message.featureSupport != null && Object.hasOwnProperty.call(message, "featureSupport")) + $root.google.protobuf.FieldOptions.FeatureSupport.encode(message.featureSupport, writer.uint32(/* id 22, wireType 2 =*/178).fork()).ldelim(); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); @@ -64943,6 +65708,10 @@ message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); break; } + case 22: { + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.decode(reader, reader.uint32()); + break; + } case 999: { if (!(message.uninterpretedOption && message.uninterpretedOption.length)) message.uninterpretedOption = []; @@ -65078,6 +65847,11 @@ if (error) return "features." + error; } + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) { + var error = $root.google.protobuf.FieldOptions.FeatureSupport.verify(message.featureSupport); + if (error) + return "featureSupport." + error; + } if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { if (!Array.isArray(message.uninterpretedOption)) return "uninterpretedOption: array expected"; @@ -65266,6 +66040,11 @@ throw TypeError(".google.protobuf.FieldOptions.features: object expected"); message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); } + if (object.featureSupport != null) { + if (typeof object.featureSupport !== "object") + throw TypeError(".google.protobuf.FieldOptions.featureSupport: object expected"); + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.fromObject(object.featureSupport); + } if (object.uninterpretedOption) { if (!Array.isArray(object.uninterpretedOption)) throw TypeError(".google.protobuf.FieldOptions.uninterpretedOption: array expected"); @@ -65363,6 +66142,7 @@ object.debugRedact = false; object.retention = options.enums === String ? "RETENTION_UNKNOWN" : 0; object.features = null; + object.featureSupport = null; object[".google.api.resourceReference"] = null; } if (message.ctype != null && message.hasOwnProperty("ctype")) @@ -65395,6 +66175,8 @@ } if (message.features != null && message.hasOwnProperty("features")) object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) + object.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.toObject(message.featureSupport, options); if (message.uninterpretedOption && message.uninterpretedOption.length) { object.uninterpretedOption = []; for (var j = 0; j < message.uninterpretedOption.length; ++j) @@ -65667,6 +66449,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -65708,103 +66491,589 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; + case "EDITION_PROTO2": + case 998: + message.edition = 998; + break; + case "EDITION_PROTO3": + case 999: + message.edition = 999; + break; + case "EDITION_2023": + case 1000: + message.edition = 1000; + break; + case "EDITION_2024": + case 1001: + message.edition = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.edition = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.edition = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.edition = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.edition = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.edition = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.edition = 2147483647; + break; + } + if (object.value != null) + message.value = String(object.value); + return message; + }; + + /** + * Creates a plain object from an EditionDefault message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {google.protobuf.FieldOptions.EditionDefault} message EditionDefault + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EditionDefault.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.value = ""; + object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + } + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + if (message.edition != null && message.hasOwnProperty("edition")) + object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + return object; + }; + + /** + * Converts this EditionDefault to JSON. + * @function toJSON + * @memberof google.protobuf.FieldOptions.EditionDefault + * @instance + * @returns {Object.} JSON object + */ + EditionDefault.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for EditionDefault + * @function getTypeUrl + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + EditionDefault.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FieldOptions.EditionDefault"; + }; + + return EditionDefault; + })(); + + FieldOptions.FeatureSupport = (function() { + + /** + * Properties of a FeatureSupport. + * @memberof google.protobuf.FieldOptions + * @interface IFeatureSupport + * @property {google.protobuf.Edition|null} [editionIntroduced] FeatureSupport editionIntroduced + * @property {google.protobuf.Edition|null} [editionDeprecated] FeatureSupport editionDeprecated + * @property {string|null} [deprecationWarning] FeatureSupport deprecationWarning + * @property {google.protobuf.Edition|null} [editionRemoved] FeatureSupport editionRemoved + */ + + /** + * Constructs a new FeatureSupport. + * @memberof google.protobuf.FieldOptions + * @classdesc Represents a FeatureSupport. + * @implements IFeatureSupport + * @constructor + * @param {google.protobuf.FieldOptions.IFeatureSupport=} [properties] Properties to set + */ + function FeatureSupport(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]]; + } + + /** + * FeatureSupport editionIntroduced. + * @member {google.protobuf.Edition} editionIntroduced + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionIntroduced = 0; + + /** + * FeatureSupport editionDeprecated. + * @member {google.protobuf.Edition} editionDeprecated + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionDeprecated = 0; + + /** + * FeatureSupport deprecationWarning. + * @member {string} deprecationWarning + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.deprecationWarning = ""; + + /** + * FeatureSupport editionRemoved. + * @member {google.protobuf.Edition} editionRemoved + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionRemoved = 0; + + /** + * Creates a new FeatureSupport instance using the specified properties. + * @function create + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport=} [properties] Properties to set + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport instance + */ + FeatureSupport.create = function create(properties) { + return new FeatureSupport(properties); + }; + + /** + * Encodes the specified FeatureSupport message. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport} message FeatureSupport message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSupport.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.editionIntroduced != null && Object.hasOwnProperty.call(message, "editionIntroduced")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.editionIntroduced); + if (message.editionDeprecated != null && Object.hasOwnProperty.call(message, "editionDeprecated")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.editionDeprecated); + if (message.deprecationWarning != null && Object.hasOwnProperty.call(message, "deprecationWarning")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.deprecationWarning); + if (message.editionRemoved != null && Object.hasOwnProperty.call(message, "editionRemoved")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.editionRemoved); + return writer; + }; + + /** + * Encodes the specified FeatureSupport message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport} message FeatureSupport message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSupport.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSupport.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FieldOptions.FeatureSupport(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.editionIntroduced = reader.int32(); + break; + } + case 2: { + message.editionDeprecated = reader.int32(); + break; + } + case 3: { + message.deprecationWarning = reader.string(); + break; + } + case 4: { + message.editionRemoved = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSupport.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FeatureSupport message. + * @function verify + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FeatureSupport.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.editionIntroduced != null && message.hasOwnProperty("editionIntroduced")) + switch (message.editionIntroduced) { + default: + return "editionIntroduced: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + if (message.editionDeprecated != null && message.hasOwnProperty("editionDeprecated")) + switch (message.editionDeprecated) { + default: + return "editionDeprecated: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + if (message.deprecationWarning != null && message.hasOwnProperty("deprecationWarning")) + if (!$util.isString(message.deprecationWarning)) + return "deprecationWarning: string expected"; + if (message.editionRemoved != null && message.hasOwnProperty("editionRemoved")) + switch (message.editionRemoved) { + default: + return "editionRemoved: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + return null; + }; + + /** + * Creates a FeatureSupport message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + */ + FeatureSupport.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FieldOptions.FeatureSupport) + return object; + var message = new $root.google.protobuf.FieldOptions.FeatureSupport(); + switch (object.editionIntroduced) { + default: + if (typeof object.editionIntroduced === "number") { + message.editionIntroduced = object.editionIntroduced; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionIntroduced = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionIntroduced = 900; + break; + case "EDITION_PROTO2": + case 998: + message.editionIntroduced = 998; + break; + case "EDITION_PROTO3": + case 999: + message.editionIntroduced = 999; + break; + case "EDITION_2023": + case 1000: + message.editionIntroduced = 1000; + break; + case "EDITION_2024": + case 1001: + message.editionIntroduced = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.editionIntroduced = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.editionIntroduced = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.editionIntroduced = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.editionIntroduced = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.editionIntroduced = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.editionIntroduced = 2147483647; + break; + } + switch (object.editionDeprecated) { + default: + if (typeof object.editionDeprecated === "number") { + message.editionDeprecated = object.editionDeprecated; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionDeprecated = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionDeprecated = 900; + break; + case "EDITION_PROTO2": + case 998: + message.editionDeprecated = 998; + break; + case "EDITION_PROTO3": + case 999: + message.editionDeprecated = 999; + break; + case "EDITION_2023": + case 1000: + message.editionDeprecated = 1000; + break; + case "EDITION_2024": + case 1001: + message.editionDeprecated = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.editionDeprecated = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.editionDeprecated = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.editionDeprecated = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.editionDeprecated = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.editionDeprecated = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.editionDeprecated = 2147483647; + break; + } + if (object.deprecationWarning != null) + message.deprecationWarning = String(object.deprecationWarning); + switch (object.editionRemoved) { + default: + if (typeof object.editionRemoved === "number") { + message.editionRemoved = object.editionRemoved; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionRemoved = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionRemoved = 900; + break; case "EDITION_PROTO2": case 998: - message.edition = 998; + message.editionRemoved = 998; break; case "EDITION_PROTO3": case 999: - message.edition = 999; + message.editionRemoved = 999; break; case "EDITION_2023": case 1000: - message.edition = 1000; + message.editionRemoved = 1000; break; case "EDITION_2024": case 1001: - message.edition = 1001; + message.editionRemoved = 1001; break; case "EDITION_1_TEST_ONLY": case 1: - message.edition = 1; + message.editionRemoved = 1; break; case "EDITION_2_TEST_ONLY": case 2: - message.edition = 2; + message.editionRemoved = 2; break; case "EDITION_99997_TEST_ONLY": case 99997: - message.edition = 99997; + message.editionRemoved = 99997; break; case "EDITION_99998_TEST_ONLY": case 99998: - message.edition = 99998; + message.editionRemoved = 99998; break; case "EDITION_99999_TEST_ONLY": case 99999: - message.edition = 99999; + message.editionRemoved = 99999; break; case "EDITION_MAX": case 2147483647: - message.edition = 2147483647; + message.editionRemoved = 2147483647; break; } - if (object.value != null) - message.value = String(object.value); return message; }; /** - * Creates a plain object from an EditionDefault message. Also converts values to other types if specified. + * Creates a plain object from a FeatureSupport message. Also converts values to other types if specified. * @function toObject - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @static - * @param {google.protobuf.FieldOptions.EditionDefault} message EditionDefault + * @param {google.protobuf.FieldOptions.FeatureSupport} message FeatureSupport * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - EditionDefault.toObject = function toObject(message, options) { + FeatureSupport.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { - object.value = ""; - object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.editionIntroduced = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.editionDeprecated = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.deprecationWarning = ""; + object.editionRemoved = options.enums === String ? "EDITION_UNKNOWN" : 0; } - if (message.value != null && message.hasOwnProperty("value")) - object.value = message.value; - if (message.edition != null && message.hasOwnProperty("edition")) - object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.editionIntroduced != null && message.hasOwnProperty("editionIntroduced")) + object.editionIntroduced = options.enums === String ? $root.google.protobuf.Edition[message.editionIntroduced] === undefined ? message.editionIntroduced : $root.google.protobuf.Edition[message.editionIntroduced] : message.editionIntroduced; + if (message.editionDeprecated != null && message.hasOwnProperty("editionDeprecated")) + object.editionDeprecated = options.enums === String ? $root.google.protobuf.Edition[message.editionDeprecated] === undefined ? message.editionDeprecated : $root.google.protobuf.Edition[message.editionDeprecated] : message.editionDeprecated; + if (message.deprecationWarning != null && message.hasOwnProperty("deprecationWarning")) + object.deprecationWarning = message.deprecationWarning; + if (message.editionRemoved != null && message.hasOwnProperty("editionRemoved")) + object.editionRemoved = options.enums === String ? $root.google.protobuf.Edition[message.editionRemoved] === undefined ? message.editionRemoved : $root.google.protobuf.Edition[message.editionRemoved] : message.editionRemoved; return object; }; /** - * Converts this EditionDefault to JSON. + * Converts this FeatureSupport to JSON. * @function toJSON - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @instance * @returns {Object.} JSON object */ - EditionDefault.prototype.toJSON = function toJSON() { + FeatureSupport.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for EditionDefault + * Gets the default type url for FeatureSupport * @function getTypeUrl - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - EditionDefault.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + FeatureSupport.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.protobuf.FieldOptions.EditionDefault"; + return typeUrlPrefix + "/google.protobuf.FieldOptions.FeatureSupport"; }; - return EditionDefault; + return FeatureSupport; })(); return FieldOptions; @@ -66399,6 +67668,7 @@ * @property {boolean|null} [deprecated] EnumValueOptions deprecated * @property {google.protobuf.IFeatureSet|null} [features] EnumValueOptions features * @property {boolean|null} [debugRedact] EnumValueOptions debugRedact + * @property {google.protobuf.FieldOptions.IFeatureSupport|null} [featureSupport] EnumValueOptions featureSupport * @property {Array.|null} [uninterpretedOption] EnumValueOptions uninterpretedOption */ @@ -66442,6 +67712,14 @@ */ EnumValueOptions.prototype.debugRedact = false; + /** + * EnumValueOptions featureSupport. + * @member {google.protobuf.FieldOptions.IFeatureSupport|null|undefined} featureSupport + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.featureSupport = null; + /** * EnumValueOptions uninterpretedOption. * @member {Array.} uninterpretedOption @@ -66480,6 +67758,8 @@ $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.debugRedact != null && Object.hasOwnProperty.call(message, "debugRedact")) writer.uint32(/* id 3, wireType 0 =*/24).bool(message.debugRedact); + if (message.featureSupport != null && Object.hasOwnProperty.call(message, "featureSupport")) + $root.google.protobuf.FieldOptions.FeatureSupport.encode(message.featureSupport, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); @@ -66531,6 +67811,10 @@ message.debugRedact = reader.bool(); break; } + case 4: { + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.decode(reader, reader.uint32()); + break; + } case 999: { if (!(message.uninterpretedOption && message.uninterpretedOption.length)) message.uninterpretedOption = []; @@ -66583,6 +67867,11 @@ if (message.debugRedact != null && message.hasOwnProperty("debugRedact")) if (typeof message.debugRedact !== "boolean") return "debugRedact: boolean expected"; + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) { + var error = $root.google.protobuf.FieldOptions.FeatureSupport.verify(message.featureSupport); + if (error) + return "featureSupport." + error; + } if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { if (!Array.isArray(message.uninterpretedOption)) return "uninterpretedOption: array expected"; @@ -66616,6 +67905,11 @@ } if (object.debugRedact != null) message.debugRedact = Boolean(object.debugRedact); + if (object.featureSupport != null) { + if (typeof object.featureSupport !== "object") + throw TypeError(".google.protobuf.EnumValueOptions.featureSupport: object expected"); + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.fromObject(object.featureSupport); + } if (object.uninterpretedOption) { if (!Array.isArray(object.uninterpretedOption)) throw TypeError(".google.protobuf.EnumValueOptions.uninterpretedOption: array expected"); @@ -66648,6 +67942,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -66655,6 +67950,8 @@ object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); if (message.debugRedact != null && message.hasOwnProperty("debugRedact")) object.debugRedact = message.debugRedact; + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) + object.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.toObject(message.featureSupport, options); if (message.uninterpretedOption && message.uninterpretedOption.length) { object.uninterpretedOption = []; for (var j = 0; j < message.uninterpretedOption.length; ++j) @@ -68122,6 +69419,8 @@ * @property {google.protobuf.FeatureSet.Utf8Validation|null} [utf8Validation] FeatureSet utf8Validation * @property {google.protobuf.FeatureSet.MessageEncoding|null} [messageEncoding] FeatureSet messageEncoding * @property {google.protobuf.FeatureSet.JsonFormat|null} [jsonFormat] FeatureSet jsonFormat + * @property {google.protobuf.FeatureSet.EnforceNamingStyle|null} [enforceNamingStyle] FeatureSet enforceNamingStyle + * @property {google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|null} [defaultSymbolVisibility] FeatureSet defaultSymbolVisibility */ /** @@ -68187,6 +69486,22 @@ */ FeatureSet.prototype.jsonFormat = 0; + /** + * FeatureSet enforceNamingStyle. + * @member {google.protobuf.FeatureSet.EnforceNamingStyle} enforceNamingStyle + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.enforceNamingStyle = 0; + + /** + * FeatureSet defaultSymbolVisibility. + * @member {google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility} defaultSymbolVisibility + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.defaultSymbolVisibility = 0; + /** * Creates a new FeatureSet instance using the specified properties. * @function create @@ -68223,6 +69538,10 @@ writer.uint32(/* id 5, wireType 0 =*/40).int32(message.messageEncoding); if (message.jsonFormat != null && Object.hasOwnProperty.call(message, "jsonFormat")) writer.uint32(/* id 6, wireType 0 =*/48).int32(message.jsonFormat); + if (message.enforceNamingStyle != null && Object.hasOwnProperty.call(message, "enforceNamingStyle")) + writer.uint32(/* id 7, wireType 0 =*/56).int32(message.enforceNamingStyle); + if (message.defaultSymbolVisibility != null && Object.hasOwnProperty.call(message, "defaultSymbolVisibility")) + writer.uint32(/* id 8, wireType 0 =*/64).int32(message.defaultSymbolVisibility); return writer; }; @@ -68283,6 +69602,14 @@ message.jsonFormat = reader.int32(); break; } + case 7: { + message.enforceNamingStyle = reader.int32(); + break; + } + case 8: { + message.defaultSymbolVisibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -68373,6 +69700,26 @@ case 2: break; } + if (message.enforceNamingStyle != null && message.hasOwnProperty("enforceNamingStyle")) + switch (message.enforceNamingStyle) { + default: + return "enforceNamingStyle: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.defaultSymbolVisibility != null && message.hasOwnProperty("defaultSymbolVisibility")) + switch (message.defaultSymbolVisibility) { + default: + return "defaultSymbolVisibility: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } return null; }; @@ -68512,6 +69859,54 @@ message.jsonFormat = 2; break; } + switch (object.enforceNamingStyle) { + default: + if (typeof object.enforceNamingStyle === "number") { + message.enforceNamingStyle = object.enforceNamingStyle; + break; + } + break; + case "ENFORCE_NAMING_STYLE_UNKNOWN": + case 0: + message.enforceNamingStyle = 0; + break; + case "STYLE2024": + case 1: + message.enforceNamingStyle = 1; + break; + case "STYLE_LEGACY": + case 2: + message.enforceNamingStyle = 2; + break; + } + switch (object.defaultSymbolVisibility) { + default: + if (typeof object.defaultSymbolVisibility === "number") { + message.defaultSymbolVisibility = object.defaultSymbolVisibility; + break; + } + break; + case "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN": + case 0: + message.defaultSymbolVisibility = 0; + break; + case "EXPORT_ALL": + case 1: + message.defaultSymbolVisibility = 1; + break; + case "EXPORT_TOP_LEVEL": + case 2: + message.defaultSymbolVisibility = 2; + break; + case "LOCAL_ALL": + case 3: + message.defaultSymbolVisibility = 3; + break; + case "STRICT": + case 4: + message.defaultSymbolVisibility = 4; + break; + } return message; }; @@ -68535,6 +69930,8 @@ object.utf8Validation = options.enums === String ? "UTF8_VALIDATION_UNKNOWN" : 0; object.messageEncoding = options.enums === String ? "MESSAGE_ENCODING_UNKNOWN" : 0; object.jsonFormat = options.enums === String ? "JSON_FORMAT_UNKNOWN" : 0; + object.enforceNamingStyle = options.enums === String ? "ENFORCE_NAMING_STYLE_UNKNOWN" : 0; + object.defaultSymbolVisibility = options.enums === String ? "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN" : 0; } if (message.fieldPresence != null && message.hasOwnProperty("fieldPresence")) object.fieldPresence = options.enums === String ? $root.google.protobuf.FeatureSet.FieldPresence[message.fieldPresence] === undefined ? message.fieldPresence : $root.google.protobuf.FeatureSet.FieldPresence[message.fieldPresence] : message.fieldPresence; @@ -68548,6 +69945,10 @@ object.messageEncoding = options.enums === String ? $root.google.protobuf.FeatureSet.MessageEncoding[message.messageEncoding] === undefined ? message.messageEncoding : $root.google.protobuf.FeatureSet.MessageEncoding[message.messageEncoding] : message.messageEncoding; if (message.jsonFormat != null && message.hasOwnProperty("jsonFormat")) object.jsonFormat = options.enums === String ? $root.google.protobuf.FeatureSet.JsonFormat[message.jsonFormat] === undefined ? message.jsonFormat : $root.google.protobuf.FeatureSet.JsonFormat[message.jsonFormat] : message.jsonFormat; + if (message.enforceNamingStyle != null && message.hasOwnProperty("enforceNamingStyle")) + object.enforceNamingStyle = options.enums === String ? $root.google.protobuf.FeatureSet.EnforceNamingStyle[message.enforceNamingStyle] === undefined ? message.enforceNamingStyle : $root.google.protobuf.FeatureSet.EnforceNamingStyle[message.enforceNamingStyle] : message.enforceNamingStyle; + if (message.defaultSymbolVisibility != null && message.hasOwnProperty("defaultSymbolVisibility")) + object.defaultSymbolVisibility = options.enums === String ? $root.google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility[message.defaultSymbolVisibility] === undefined ? message.defaultSymbolVisibility : $root.google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility[message.defaultSymbolVisibility] : message.defaultSymbolVisibility; return object; }; @@ -68675,6 +70076,219 @@ return values; })(); + /** + * EnforceNamingStyle enum. + * @name google.protobuf.FeatureSet.EnforceNamingStyle + * @enum {number} + * @property {number} ENFORCE_NAMING_STYLE_UNKNOWN=0 ENFORCE_NAMING_STYLE_UNKNOWN value + * @property {number} STYLE2024=1 STYLE2024 value + * @property {number} STYLE_LEGACY=2 STYLE_LEGACY value + */ + FeatureSet.EnforceNamingStyle = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "ENFORCE_NAMING_STYLE_UNKNOWN"] = 0; + values[valuesById[1] = "STYLE2024"] = 1; + values[valuesById[2] = "STYLE_LEGACY"] = 2; + return values; + })(); + + FeatureSet.VisibilityFeature = (function() { + + /** + * Properties of a VisibilityFeature. + * @memberof google.protobuf.FeatureSet + * @interface IVisibilityFeature + */ + + /** + * Constructs a new VisibilityFeature. + * @memberof google.protobuf.FeatureSet + * @classdesc Represents a VisibilityFeature. + * @implements IVisibilityFeature + * @constructor + * @param {google.protobuf.FeatureSet.IVisibilityFeature=} [properties] Properties to set + */ + function VisibilityFeature(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]]; + } + + /** + * Creates a new VisibilityFeature instance using the specified properties. + * @function create + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature=} [properties] Properties to set + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature instance + */ + VisibilityFeature.create = function create(properties) { + return new VisibilityFeature(properties); + }; + + /** + * Encodes the specified VisibilityFeature message. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature} message VisibilityFeature message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VisibilityFeature.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified VisibilityFeature message, length delimited. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature} message VisibilityFeature message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VisibilityFeature.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VisibilityFeature.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FeatureSet.VisibilityFeature(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VisibilityFeature.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a VisibilityFeature message. + * @function verify + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + VisibilityFeature.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a VisibilityFeature message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + */ + VisibilityFeature.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FeatureSet.VisibilityFeature) + return object; + return new $root.google.protobuf.FeatureSet.VisibilityFeature(); + }; + + /** + * Creates a plain object from a VisibilityFeature message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.VisibilityFeature} message VisibilityFeature + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + VisibilityFeature.toObject = function toObject() { + return {}; + }; + + /** + * Converts this VisibilityFeature to JSON. + * @function toJSON + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @instance + * @returns {Object.} JSON object + */ + VisibilityFeature.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for VisibilityFeature + * @function getTypeUrl + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + VisibilityFeature.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FeatureSet.VisibilityFeature"; + }; + + /** + * DefaultSymbolVisibility enum. + * @name google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility + * @enum {number} + * @property {number} DEFAULT_SYMBOL_VISIBILITY_UNKNOWN=0 DEFAULT_SYMBOL_VISIBILITY_UNKNOWN value + * @property {number} EXPORT_ALL=1 EXPORT_ALL value + * @property {number} EXPORT_TOP_LEVEL=2 EXPORT_TOP_LEVEL value + * @property {number} LOCAL_ALL=3 LOCAL_ALL value + * @property {number} STRICT=4 STRICT value + */ + VisibilityFeature.DefaultSymbolVisibility = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN"] = 0; + values[valuesById[1] = "EXPORT_ALL"] = 1; + values[valuesById[2] = "EXPORT_TOP_LEVEL"] = 2; + values[valuesById[3] = "LOCAL_ALL"] = 3; + values[valuesById[4] = "STRICT"] = 4; + return values; + })(); + + return VisibilityFeature; + })(); + return FeatureSet; })(); @@ -68859,6 +70473,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -68876,6 +70491,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -68924,6 +70540,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -68976,6 +70596,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -69084,7 +70708,8 @@ * @memberof google.protobuf.FeatureSetDefaults * @interface IFeatureSetEditionDefault * @property {google.protobuf.Edition|null} [edition] FeatureSetEditionDefault edition - * @property {google.protobuf.IFeatureSet|null} [features] FeatureSetEditionDefault features + * @property {google.protobuf.IFeatureSet|null} [overridableFeatures] FeatureSetEditionDefault overridableFeatures + * @property {google.protobuf.IFeatureSet|null} [fixedFeatures] FeatureSetEditionDefault fixedFeatures */ /** @@ -69111,12 +70736,20 @@ FeatureSetEditionDefault.prototype.edition = 0; /** - * FeatureSetEditionDefault features. - * @member {google.protobuf.IFeatureSet|null|undefined} features + * FeatureSetEditionDefault overridableFeatures. + * @member {google.protobuf.IFeatureSet|null|undefined} overridableFeatures + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @instance + */ + FeatureSetEditionDefault.prototype.overridableFeatures = null; + + /** + * FeatureSetEditionDefault fixedFeatures. + * @member {google.protobuf.IFeatureSet|null|undefined} fixedFeatures * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault * @instance */ - FeatureSetEditionDefault.prototype.features = null; + FeatureSetEditionDefault.prototype.fixedFeatures = null; /** * Creates a new FeatureSetEditionDefault instance using the specified properties. @@ -69142,10 +70775,12 @@ FeatureSetEditionDefault.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.features != null && Object.hasOwnProperty.call(message, "features")) - $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) writer.uint32(/* id 3, wireType 0 =*/24).int32(message.edition); + if (message.overridableFeatures != null && Object.hasOwnProperty.call(message, "overridableFeatures")) + $root.google.protobuf.FeatureSet.encode(message.overridableFeatures, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.fixedFeatures != null && Object.hasOwnProperty.call(message, "fixedFeatures")) + $root.google.protobuf.FeatureSet.encode(message.fixedFeatures, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); return writer; }; @@ -69186,8 +70821,12 @@ message.edition = reader.int32(); break; } - case 2: { - message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + case 4: { + message.overridableFeatures = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + break; + } + case 5: { + message.fixedFeatures = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); break; } default: @@ -69230,6 +70869,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -69242,10 +70882,15 @@ case 2147483647: break; } - if (message.features != null && message.hasOwnProperty("features")) { - var error = $root.google.protobuf.FeatureSet.verify(message.features); + if (message.overridableFeatures != null && message.hasOwnProperty("overridableFeatures")) { + var error = $root.google.protobuf.FeatureSet.verify(message.overridableFeatures); + if (error) + return "overridableFeatures." + error; + } + if (message.fixedFeatures != null && message.hasOwnProperty("fixedFeatures")) { + var error = $root.google.protobuf.FeatureSet.verify(message.fixedFeatures); if (error) - return "features." + error; + return "fixedFeatures." + error; } return null; }; @@ -69273,6 +70918,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -69314,10 +70963,15 @@ message.edition = 2147483647; break; } - if (object.features != null) { - if (typeof object.features !== "object") - throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.features: object expected"); - message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); + if (object.overridableFeatures != null) { + if (typeof object.overridableFeatures !== "object") + throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.overridableFeatures: object expected"); + message.overridableFeatures = $root.google.protobuf.FeatureSet.fromObject(object.overridableFeatures); + } + if (object.fixedFeatures != null) { + if (typeof object.fixedFeatures !== "object") + throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.fixedFeatures: object expected"); + message.fixedFeatures = $root.google.protobuf.FeatureSet.fromObject(object.fixedFeatures); } return message; }; @@ -69336,13 +70990,16 @@ options = {}; var object = {}; if (options.defaults) { - object.features = null; object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.overridableFeatures = null; + object.fixedFeatures = null; } - if (message.features != null && message.hasOwnProperty("features")) - object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); if (message.edition != null && message.hasOwnProperty("edition")) object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.overridableFeatures != null && message.hasOwnProperty("overridableFeatures")) + object.overridableFeatures = $root.google.protobuf.FeatureSet.toObject(message.overridableFeatures, options); + if (message.fixedFeatures != null && message.hasOwnProperty("fixedFeatures")) + object.fixedFeatures = $root.google.protobuf.FeatureSet.toObject(message.fixedFeatures, options); return object; }; @@ -70557,6 +72214,22 @@ return GeneratedCodeInfo; })(); + /** + * SymbolVisibility enum. + * @name google.protobuf.SymbolVisibility + * @enum {number} + * @property {number} VISIBILITY_UNSET=0 VISIBILITY_UNSET value + * @property {number} VISIBILITY_LOCAL=1 VISIBILITY_LOCAL value + * @property {number} VISIBILITY_EXPORT=2 VISIBILITY_EXPORT value + */ + protobuf.SymbolVisibility = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "VISIBILITY_UNSET"] = 0; + values[valuesById[1] = "VISIBILITY_LOCAL"] = 1; + values[valuesById[2] = "VISIBILITY_EXPORT"] = 2; + return values; + })(); + protobuf.Duration = (function() { /** diff --git a/packages/google-cloud-metastore/protos/protos.json b/packages/google-cloud-metastore/protos/protos.json index c24490dc05b7..6ebbebaf662f 100644 --- a/packages/google-cloud-metastore/protos/protos.json +++ b/packages/google-cloud-metastore/protos/protos.json @@ -6743,8 +6743,7 @@ "java_multiple_files": true, "java_outer_classname": "ResourceProto", "java_package": "com.google.api", - "objc_class_prefix": "GAPI", - "cc_enable_arenas": true + "objc_class_prefix": "GAPI" }, "nested": { "http": { @@ -6868,6 +6867,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -7008,6 +7011,28 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "experimentalFeatures": { + "type": "ExperimentalFeatures", + "id": 2 + } + }, + "nested": { + "ExperimentalFeatures": { + "fields": { + "restAsyncIoEnabled": { + "type": "bool", + "id": 1 + }, + "protobufPythonicTypesEnabled": { + "type": "bool", + "id": 2 + }, + "unversionedPackageDisabled": { + "type": "bool", + "id": 3 + } + } } } }, @@ -7065,6 +7090,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -7126,6 +7156,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -7258,12 +7301,19 @@ "type": "FileDescriptorProto", "id": 1 } - } + }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ] }, "Edition": { "edition": "proto2", "values": { "EDITION_UNKNOWN": 0, + "EDITION_LEGACY": 900, "EDITION_PROTO2": 998, "EDITION_PROTO3": 999, "EDITION_2023": 1000, @@ -7302,6 +7352,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -7390,6 +7445,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -7615,6 +7674,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -7665,7 +7728,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -7829,6 +7899,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -7964,7 +8035,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -7992,6 +8064,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -8061,6 +8137,26 @@ "id": 2 } } + }, + "FeatureSupport": { + "fields": { + "editionIntroduced": { + "type": "Edition", + "id": 1 + }, + "editionDeprecated": { + "type": "Edition", + "id": 2 + }, + "deprecationWarning": { + "type": "string", + "id": 3 + }, + "editionRemoved": { + "type": "Edition", + "id": 4 + } + } } } }, @@ -8149,6 +8245,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -8291,6 +8391,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -8301,6 +8402,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -8311,6 +8413,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -8321,6 +8424,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -8331,7 +8435,8 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", - "edition_defaults.edition": "EDITION_PROTO2", + "feature_support.edition_introduced": "EDITION_2023", + "edition_defaults.edition": "EDITION_LEGACY", "edition_defaults.value": "LENGTH_PREFIXED" } }, @@ -8341,27 +8446,38 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "ALLOW" } + }, + "enforceNamingStyle": { + "type": "EnforceNamingStyle", + "id": 7, + "options": { + "retention": "RETENTION_SOURCE", + "targets": "TARGET_TYPE_METHOD", + "feature_support.edition_introduced": "EDITION_2024", + "edition_defaults.edition": "EDITION_2024", + "edition_defaults.value": "STYLE2024" + } + }, + "defaultSymbolVisibility": { + "type": "VisibilityFeature.DefaultSymbolVisibility", + "id": 8, + "options": { + "retention": "RETENTION_SOURCE", + "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2024", + "edition_defaults.edition": "EDITION_2024", + "edition_defaults.value": "EXPORT_TOP_LEVEL" + } } }, "extensions": [ [ 1000, - 1000 - ], - [ - 1001, - 1001 - ], - [ - 1002, - 1002 - ], - [ - 9990, - 9990 + 9994 ], [ 9995, @@ -8406,7 +8522,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -8421,6 +8543,33 @@ "ALLOW": 1, "LEGACY_BEST_EFFORT": 2 } + }, + "EnforceNamingStyle": { + "values": { + "ENFORCE_NAMING_STYLE_UNKNOWN": 0, + "STYLE2024": 1, + "STYLE_LEGACY": 2 + } + }, + "VisibilityFeature": { + "fields": {}, + "reserved": [ + [ + 1, + 536870911 + ] + ], + "nested": { + "DefaultSymbolVisibility": { + "values": { + "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN": 0, + "EXPORT_ALL": 1, + "EXPORT_TOP_LEVEL": 2, + "LOCAL_ALL": 3, + "STRICT": 4 + } + } + } } } }, @@ -8448,11 +8597,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -8465,6 +8629,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -8550,6 +8720,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Duration": { "fields": { "seconds": { @@ -8680,6 +8858,7 @@ "java_multiple_files": true, "java_outer_classname": "OperationsProto", "java_package": "com.google.longrunning", + "objc_class_prefix": "GLRUN", "php_namespace": "Google\\LongRunning" }, "nested": { diff --git a/packages/google-cloud-metastore/samples/generated/v1/snippet_metadata_google.cloud.metastore.v1.json b/packages/google-cloud-metastore/samples/generated/v1/snippet_metadata_google.cloud.metastore.v1.json index 527fd408cc1d..455874f87e78 100644 --- a/packages/google-cloud-metastore/samples/generated/v1/snippet_metadata_google.cloud.metastore.v1.json +++ b/packages/google-cloud-metastore/samples/generated/v1/snippet_metadata_google.cloud.metastore.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-metastore", - "version": "5.2.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-metastore/samples/generated/v1alpha/snippet_metadata_google.cloud.metastore.v1alpha.json b/packages/google-cloud-metastore/samples/generated/v1alpha/snippet_metadata_google.cloud.metastore.v1alpha.json index 569f3fa70c4d..d44e4ba53b97 100644 --- a/packages/google-cloud-metastore/samples/generated/v1alpha/snippet_metadata_google.cloud.metastore.v1alpha.json +++ b/packages/google-cloud-metastore/samples/generated/v1alpha/snippet_metadata_google.cloud.metastore.v1alpha.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-metastore", - "version": "5.2.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-metastore/samples/generated/v1beta/snippet_metadata_google.cloud.metastore.v1beta.json b/packages/google-cloud-metastore/samples/generated/v1beta/snippet_metadata_google.cloud.metastore.v1beta.json index 270235cd4063..efc6983feb18 100644 --- a/packages/google-cloud-metastore/samples/generated/v1beta/snippet_metadata_google.cloud.metastore.v1beta.json +++ b/packages/google-cloud-metastore/samples/generated/v1beta/snippet_metadata_google.cloud.metastore.v1beta.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-metastore", - "version": "5.2.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-metastore/src/v1/dataproc_metastore_client.ts b/packages/google-cloud-metastore/src/v1/dataproc_metastore_client.ts index 445a6afcdc54..190cc3e05fa7 100644 --- a/packages/google-cloud-metastore/src/v1/dataproc_metastore_client.ts +++ b/packages/google-cloud-metastore/src/v1/dataproc_metastore_client.ts @@ -18,11 +18,24 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -60,7 +73,7 @@ export class DataprocMetastoreClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('dataproc-metastore'); @@ -73,12 +86,12 @@ export class DataprocMetastoreClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - dataprocMetastoreStub?: Promise<{[name: string]: Function}>; + dataprocMetastoreStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of DataprocMetastoreClient. @@ -119,21 +132,42 @@ export class DataprocMetastoreClient { * const client = new DataprocMetastoreClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof DataprocMetastoreClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'metastore.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -158,7 +192,7 @@ export class DataprocMetastoreClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -171,18 +205,14 @@ export class DataprocMetastoreClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -204,25 +234,25 @@ export class DataprocMetastoreClient { // Create useful helper objects for these. this.pathTemplates = { backupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}/backups/{backup}' + 'projects/{project}/locations/{location}/services/{service}/backups/{backup}', ), federationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/federations/{federation}' + 'projects/{project}/locations/{location}/federations/{federation}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), metadataImportPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}/metadataImports/{metadata_import}' + 'projects/{project}/locations/{location}/services/{service}/metadataImports/{metadata_import}', ), networkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/global/networks/{network}' + 'projects/{project}/global/networks/{network}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), servicePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}' + 'projects/{project}/locations/{location}/services/{service}', ), }; @@ -230,12 +260,21 @@ export class DataprocMetastoreClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listServices: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'services'), - listMetadataImports: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'metadataImports'), - listBackups: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'backups') + listServices: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'services', + ), + listMetadataImports: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'metadataImports', + ), + listBackups: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'backups', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -244,120 +283,226 @@ export class DataprocMetastoreClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1/{resource=projects/*/locations/*/services/*}:getIamPolicy',additional_bindings: [{get: '/v1/{resource=projects/*/locations/*/services/*/backups/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/federations/*}:getIamPolicy',}], - },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1/{resource=projects/*/locations/*/services/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/services/*/backups/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/federations/*}:setIamPolicy',body: '*',}], - },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1/{resource=projects/*/locations/*/services/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/federations/*}:testIamPermissions',body: '*',}], - },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1/{resource=projects/*/locations/*/services/*}:getIamPolicy', + additional_bindings: [ + { + get: '/v1/{resource=projects/*/locations/*/services/*/backups/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/federations/*}:getIamPolicy', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1/{resource=projects/*/locations/*/services/*}:setIamPolicy', + body: '*', + additional_bindings: [ + { + post: '/v1/{resource=projects/*/locations/*/services/*/backups/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/federations/*}:setIamPolicy', + body: '*', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1/{resource=projects/*/locations/*/services/*}:testIamPermissions', + body: '*', + additional_bindings: [ + { + post: '/v1/{resource=projects/*/locations/*/federations/*}:testIamPermissions', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createServiceResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1.Service') as gax.protobuf.Type; + '.google.cloud.metastore.v1.Service', + ) as gax.protobuf.Type; const createServiceMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateServiceResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1.Service') as gax.protobuf.Type; + '.google.cloud.metastore.v1.Service', + ) as gax.protobuf.Type; const updateServiceMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteServiceResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteServiceMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1.OperationMetadata', + ) as gax.protobuf.Type; const createMetadataImportResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1.MetadataImport') as gax.protobuf.Type; + '.google.cloud.metastore.v1.MetadataImport', + ) as gax.protobuf.Type; const createMetadataImportMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateMetadataImportResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1.MetadataImport') as gax.protobuf.Type; + '.google.cloud.metastore.v1.MetadataImport', + ) as gax.protobuf.Type; const updateMetadataImportMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1.OperationMetadata', + ) as gax.protobuf.Type; const exportMetadataResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1.MetadataExport') as gax.protobuf.Type; + '.google.cloud.metastore.v1.MetadataExport', + ) as gax.protobuf.Type; const exportMetadataMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1.OperationMetadata', + ) as gax.protobuf.Type; const restoreServiceResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1.Restore') as gax.protobuf.Type; + '.google.cloud.metastore.v1.Restore', + ) as gax.protobuf.Type; const restoreServiceMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1.OperationMetadata', + ) as gax.protobuf.Type; const createBackupResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1.Backup') as gax.protobuf.Type; + '.google.cloud.metastore.v1.Backup', + ) as gax.protobuf.Type; const createBackupMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteBackupResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteBackupMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1.OperationMetadata', + ) as gax.protobuf.Type; const queryMetadataResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1.QueryMetadataResponse') as gax.protobuf.Type; + '.google.cloud.metastore.v1.QueryMetadataResponse', + ) as gax.protobuf.Type; const queryMetadataMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1.OperationMetadata', + ) as gax.protobuf.Type; const moveTableToDatabaseResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1.MoveTableToDatabaseResponse') as gax.protobuf.Type; + '.google.cloud.metastore.v1.MoveTableToDatabaseResponse', + ) as gax.protobuf.Type; const moveTableToDatabaseMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1.OperationMetadata', + ) as gax.protobuf.Type; const alterMetadataResourceLocationResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1.AlterMetadataResourceLocationResponse') as gax.protobuf.Type; + '.google.cloud.metastore.v1.AlterMetadataResourceLocationResponse', + ) as gax.protobuf.Type; const alterMetadataResourceLocationMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createService: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createServiceResponse.decode.bind(createServiceResponse), - createServiceMetadata.decode.bind(createServiceMetadata)), + createServiceMetadata.decode.bind(createServiceMetadata), + ), updateService: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateServiceResponse.decode.bind(updateServiceResponse), - updateServiceMetadata.decode.bind(updateServiceMetadata)), + updateServiceMetadata.decode.bind(updateServiceMetadata), + ), deleteService: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteServiceResponse.decode.bind(deleteServiceResponse), - deleteServiceMetadata.decode.bind(deleteServiceMetadata)), + deleteServiceMetadata.decode.bind(deleteServiceMetadata), + ), createMetadataImport: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createMetadataImportResponse.decode.bind(createMetadataImportResponse), - createMetadataImportMetadata.decode.bind(createMetadataImportMetadata)), + createMetadataImportMetadata.decode.bind(createMetadataImportMetadata), + ), updateMetadataImport: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateMetadataImportResponse.decode.bind(updateMetadataImportResponse), - updateMetadataImportMetadata.decode.bind(updateMetadataImportMetadata)), + updateMetadataImportMetadata.decode.bind(updateMetadataImportMetadata), + ), exportMetadata: new this._gaxModule.LongrunningDescriptor( this.operationsClient, exportMetadataResponse.decode.bind(exportMetadataResponse), - exportMetadataMetadata.decode.bind(exportMetadataMetadata)), + exportMetadataMetadata.decode.bind(exportMetadataMetadata), + ), restoreService: new this._gaxModule.LongrunningDescriptor( this.operationsClient, restoreServiceResponse.decode.bind(restoreServiceResponse), - restoreServiceMetadata.decode.bind(restoreServiceMetadata)), + restoreServiceMetadata.decode.bind(restoreServiceMetadata), + ), createBackup: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createBackupResponse.decode.bind(createBackupResponse), - createBackupMetadata.decode.bind(createBackupMetadata)), + createBackupMetadata.decode.bind(createBackupMetadata), + ), deleteBackup: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteBackupResponse.decode.bind(deleteBackupResponse), - deleteBackupMetadata.decode.bind(deleteBackupMetadata)), + deleteBackupMetadata.decode.bind(deleteBackupMetadata), + ), queryMetadata: new this._gaxModule.LongrunningDescriptor( this.operationsClient, queryMetadataResponse.decode.bind(queryMetadataResponse), - queryMetadataMetadata.decode.bind(queryMetadataMetadata)), + queryMetadataMetadata.decode.bind(queryMetadataMetadata), + ), moveTableToDatabase: new this._gaxModule.LongrunningDescriptor( this.operationsClient, moveTableToDatabaseResponse.decode.bind(moveTableToDatabaseResponse), - moveTableToDatabaseMetadata.decode.bind(moveTableToDatabaseMetadata)), + moveTableToDatabaseMetadata.decode.bind(moveTableToDatabaseMetadata), + ), alterMetadataResourceLocation: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - alterMetadataResourceLocationResponse.decode.bind(alterMetadataResourceLocationResponse), - alterMetadataResourceLocationMetadata.decode.bind(alterMetadataResourceLocationMetadata)) + alterMetadataResourceLocationResponse.decode.bind( + alterMetadataResourceLocationResponse, + ), + alterMetadataResourceLocationMetadata.decode.bind( + alterMetadataResourceLocationMetadata, + ), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.metastore.v1.DataprocMetastore', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.metastore.v1.DataprocMetastore', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -388,28 +533,52 @@ export class DataprocMetastoreClient { // Put together the "service stub" for // google.cloud.metastore.v1.DataprocMetastore. this.dataprocMetastoreStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.metastore.v1.DataprocMetastore') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.metastore.v1.DataprocMetastore', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.metastore.v1.DataprocMetastore, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const dataprocMetastoreStubMethods = - ['listServices', 'getService', 'createService', 'updateService', 'deleteService', 'listMetadataImports', 'getMetadataImport', 'createMetadataImport', 'updateMetadataImport', 'exportMetadata', 'restoreService', 'listBackups', 'getBackup', 'createBackup', 'deleteBackup', 'queryMetadata', 'moveTableToDatabase', 'alterMetadataResourceLocation']; + const dataprocMetastoreStubMethods = [ + 'listServices', + 'getService', + 'createService', + 'updateService', + 'deleteService', + 'listMetadataImports', + 'getMetadataImport', + 'createMetadataImport', + 'updateMetadataImport', + 'exportMetadata', + 'restoreService', + 'listBackups', + 'getBackup', + 'createBackup', + 'deleteBackup', + 'queryMetadata', + 'moveTableToDatabase', + 'alterMetadataResourceLocation', + ]; for (const methodName of dataprocMetastoreStubMethods) { const callPromise = this.dataprocMetastoreStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -419,7 +588,7 @@ export class DataprocMetastoreClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -434,8 +603,14 @@ export class DataprocMetastoreClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'metastore.googleapis.com'; } @@ -446,8 +621,14 @@ export class DataprocMetastoreClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'metastore.googleapis.com'; } @@ -478,9 +659,7 @@ export class DataprocMetastoreClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -489,8 +668,9 @@ export class DataprocMetastoreClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -501,1917 +681,2793 @@ export class DataprocMetastoreClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets the details of a single service. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The relative resource name of the metastore service to retrieve, - * in the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}`. - * @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 {@link protos.google.cloud.metastore.v1.Service|Service}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/dataproc_metastore.get_service.js - * region_tag:metastore_v1_generated_DataprocMetastore_GetService_async - */ + /** + * Gets the details of a single service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The relative resource name of the metastore service to retrieve, + * in the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}`. + * @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 {@link protos.google.cloud.metastore.v1.Service|Service}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/dataproc_metastore.get_service.js + * region_tag:metastore_v1_generated_DataprocMetastore_GetService_async + */ getService( - request?: protos.google.cloud.metastore.v1.IGetServiceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.metastore.v1.IService, - protos.google.cloud.metastore.v1.IGetServiceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1.IGetServiceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.metastore.v1.IService, + protos.google.cloud.metastore.v1.IGetServiceRequest | undefined, + {} | undefined, + ] + >; getService( - request: protos.google.cloud.metastore.v1.IGetServiceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.metastore.v1.IService, - protos.google.cloud.metastore.v1.IGetServiceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.IGetServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.metastore.v1.IService, + protos.google.cloud.metastore.v1.IGetServiceRequest | null | undefined, + {} | null | undefined + >, + ): void; getService( - request: protos.google.cloud.metastore.v1.IGetServiceRequest, - callback: Callback< - protos.google.cloud.metastore.v1.IService, - protos.google.cloud.metastore.v1.IGetServiceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.IGetServiceRequest, + callback: Callback< + protos.google.cloud.metastore.v1.IService, + protos.google.cloud.metastore.v1.IGetServiceRequest | null | undefined, + {} | null | undefined + >, + ): void; getService( - request?: protos.google.cloud.metastore.v1.IGetServiceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.metastore.v1.IService, - protos.google.cloud.metastore.v1.IGetServiceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.metastore.v1.IGetServiceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.metastore.v1.IService, - protos.google.cloud.metastore.v1.IGetServiceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.metastore.v1.IService, - protos.google.cloud.metastore.v1.IGetServiceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.metastore.v1.IGetServiceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.metastore.v1.IService, + protos.google.cloud.metastore.v1.IGetServiceRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.metastore.v1.IService, + protos.google.cloud.metastore.v1.IGetServiceRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getService request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.metastore.v1.IService, - protos.google.cloud.metastore.v1.IGetServiceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.metastore.v1.IService, + | protos.google.cloud.metastore.v1.IGetServiceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getService response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getService(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.metastore.v1.IService, - protos.google.cloud.metastore.v1.IGetServiceRequest|undefined, - {}|undefined - ]) => { - this._log.info('getService response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getService(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.metastore.v1.IService, + protos.google.cloud.metastore.v1.IGetServiceRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getService response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single import. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The relative resource name of the metadata import to retrieve, in - * the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}/metadataImports/{import_id}`. - * @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 {@link protos.google.cloud.metastore.v1.MetadataImport|MetadataImport}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/dataproc_metastore.get_metadata_import.js - * region_tag:metastore_v1_generated_DataprocMetastore_GetMetadataImport_async - */ + /** + * Gets details of a single import. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The relative resource name of the metadata import to retrieve, in + * the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}/metadataImports/{import_id}`. + * @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 {@link protos.google.cloud.metastore.v1.MetadataImport|MetadataImport}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/dataproc_metastore.get_metadata_import.js + * region_tag:metastore_v1_generated_DataprocMetastore_GetMetadataImport_async + */ getMetadataImport( - request?: protos.google.cloud.metastore.v1.IGetMetadataImportRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.metastore.v1.IMetadataImport, - protos.google.cloud.metastore.v1.IGetMetadataImportRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1.IGetMetadataImportRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.metastore.v1.IMetadataImport, + protos.google.cloud.metastore.v1.IGetMetadataImportRequest | undefined, + {} | undefined, + ] + >; getMetadataImport( - request: protos.google.cloud.metastore.v1.IGetMetadataImportRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.metastore.v1.IMetadataImport, - protos.google.cloud.metastore.v1.IGetMetadataImportRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.IGetMetadataImportRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.metastore.v1.IMetadataImport, + | protos.google.cloud.metastore.v1.IGetMetadataImportRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getMetadataImport( - request: protos.google.cloud.metastore.v1.IGetMetadataImportRequest, - callback: Callback< - protos.google.cloud.metastore.v1.IMetadataImport, - protos.google.cloud.metastore.v1.IGetMetadataImportRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.IGetMetadataImportRequest, + callback: Callback< + protos.google.cloud.metastore.v1.IMetadataImport, + | protos.google.cloud.metastore.v1.IGetMetadataImportRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getMetadataImport( - request?: protos.google.cloud.metastore.v1.IGetMetadataImportRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.metastore.v1.IMetadataImport, - protos.google.cloud.metastore.v1.IGetMetadataImportRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.metastore.v1.IGetMetadataImportRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.metastore.v1.IMetadataImport, - protos.google.cloud.metastore.v1.IGetMetadataImportRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.metastore.v1.IMetadataImport, - protos.google.cloud.metastore.v1.IGetMetadataImportRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.metastore.v1.IGetMetadataImportRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.metastore.v1.IMetadataImport, + | protos.google.cloud.metastore.v1.IGetMetadataImportRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.metastore.v1.IMetadataImport, + protos.google.cloud.metastore.v1.IGetMetadataImportRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getMetadataImport request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.metastore.v1.IMetadataImport, - protos.google.cloud.metastore.v1.IGetMetadataImportRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.metastore.v1.IMetadataImport, + | protos.google.cloud.metastore.v1.IGetMetadataImportRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getMetadataImport response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getMetadataImport(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.metastore.v1.IMetadataImport, - protos.google.cloud.metastore.v1.IGetMetadataImportRequest|undefined, - {}|undefined - ]) => { - this._log.info('getMetadataImport response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getMetadataImport(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.metastore.v1.IMetadataImport, + ( + | protos.google.cloud.metastore.v1.IGetMetadataImportRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getMetadataImport response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single backup. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The relative resource name of the backup to retrieve, in the - * following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}/backups/{backup_id}`. - * @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 {@link protos.google.cloud.metastore.v1.Backup|Backup}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/dataproc_metastore.get_backup.js - * region_tag:metastore_v1_generated_DataprocMetastore_GetBackup_async - */ + /** + * Gets details of a single backup. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The relative resource name of the backup to retrieve, in the + * following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}/backups/{backup_id}`. + * @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 {@link protos.google.cloud.metastore.v1.Backup|Backup}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/dataproc_metastore.get_backup.js + * region_tag:metastore_v1_generated_DataprocMetastore_GetBackup_async + */ getBackup( - request?: protos.google.cloud.metastore.v1.IGetBackupRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.metastore.v1.IBackup, - protos.google.cloud.metastore.v1.IGetBackupRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1.IGetBackupRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.metastore.v1.IBackup, + protos.google.cloud.metastore.v1.IGetBackupRequest | undefined, + {} | undefined, + ] + >; getBackup( - request: protos.google.cloud.metastore.v1.IGetBackupRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.metastore.v1.IBackup, - protos.google.cloud.metastore.v1.IGetBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.IGetBackupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.metastore.v1.IBackup, + protos.google.cloud.metastore.v1.IGetBackupRequest | null | undefined, + {} | null | undefined + >, + ): void; getBackup( - request: protos.google.cloud.metastore.v1.IGetBackupRequest, - callback: Callback< - protos.google.cloud.metastore.v1.IBackup, - protos.google.cloud.metastore.v1.IGetBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.IGetBackupRequest, + callback: Callback< + protos.google.cloud.metastore.v1.IBackup, + protos.google.cloud.metastore.v1.IGetBackupRequest | null | undefined, + {} | null | undefined + >, + ): void; getBackup( - request?: protos.google.cloud.metastore.v1.IGetBackupRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.metastore.v1.IBackup, - protos.google.cloud.metastore.v1.IGetBackupRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.metastore.v1.IGetBackupRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.metastore.v1.IBackup, - protos.google.cloud.metastore.v1.IGetBackupRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.metastore.v1.IBackup, - protos.google.cloud.metastore.v1.IGetBackupRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.metastore.v1.IGetBackupRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.metastore.v1.IBackup, + protos.google.cloud.metastore.v1.IGetBackupRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.metastore.v1.IBackup, + protos.google.cloud.metastore.v1.IGetBackupRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getBackup request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.metastore.v1.IBackup, - protos.google.cloud.metastore.v1.IGetBackupRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.metastore.v1.IBackup, + protos.google.cloud.metastore.v1.IGetBackupRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getBackup response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getBackup(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.metastore.v1.IBackup, - protos.google.cloud.metastore.v1.IGetBackupRequest|undefined, - {}|undefined - ]) => { - this._log.info('getBackup response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getBackup(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.metastore.v1.IBackup, + protos.google.cloud.metastore.v1.IGetBackupRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getBackup response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a metastore service in a project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the location in which to create a - * metastore service, in the following form: - * - * `projects/{project_number}/locations/{location_id}`. - * @param {string} request.serviceId - * Required. The ID of the metastore service, which is used as the final - * component of the metastore service's name. - * - * This value must be between 2 and 63 characters long inclusive, begin with a - * letter, end with a letter or number, and consist of alpha-numeric - * ASCII characters or hyphens. - * @param {google.cloud.metastore.v1.Service} request.service - * Required. The Metastore service to create. The `name` field is - * ignored. The ID of the created metastore service must be provided in - * the request's `service_id` field. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/dataproc_metastore.create_service.js - * region_tag:metastore_v1_generated_DataprocMetastore_CreateService_async - */ + /** + * Creates a metastore service in a project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the location in which to create a + * metastore service, in the following form: + * + * `projects/{project_number}/locations/{location_id}`. + * @param {string} request.serviceId + * Required. The ID of the metastore service, which is used as the final + * component of the metastore service's name. + * + * This value must be between 2 and 63 characters long inclusive, begin with a + * letter, end with a letter or number, and consist of alpha-numeric + * ASCII characters or hyphens. + * @param {google.cloud.metastore.v1.Service} request.service + * Required. The Metastore service to create. The `name` field is + * ignored. The ID of the created metastore service must be provided in + * the request's `service_id` field. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/dataproc_metastore.create_service.js + * region_tag:metastore_v1_generated_DataprocMetastore_CreateService_async + */ createService( - request?: protos.google.cloud.metastore.v1.ICreateServiceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1.ICreateServiceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1.IService, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createService( - request: protos.google.cloud.metastore.v1.ICreateServiceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.ICreateServiceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1.IService, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createService( - request: protos.google.cloud.metastore.v1.ICreateServiceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.ICreateServiceRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1.IService, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createService( - request?: protos.google.cloud.metastore.v1.ICreateServiceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1.ICreateServiceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1.IService, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1.IService, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1.IService, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1.IService, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createService response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createService request %j', request); - return this.innerApiCalls.createService(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createService response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createService(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1.IService, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createService response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createService()`. - * @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/dataproc_metastore.create_service.js - * region_tag:metastore_v1_generated_DataprocMetastore_CreateService_async - */ - async checkCreateServiceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createService()`. + * @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/dataproc_metastore.create_service.js + * region_tag:metastore_v1_generated_DataprocMetastore_CreateService_async + */ + async checkCreateServiceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1.Service, + protos.google.cloud.metastore.v1.OperationMetadata + > + > { this._log.info('createService long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createService, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createService, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1.Service, + protos.google.cloud.metastore.v1.OperationMetadata + >; } -/** - * Updates the parameters of a single service. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. A field mask used to specify the fields to be overwritten in the - * metastore service resource by the update. - * Fields specified in the `update_mask` are relative to the resource (not - * to the full request). A field is overwritten if it is in the mask. - * @param {google.cloud.metastore.v1.Service} request.service - * Required. The metastore service to update. The server only merges fields - * in the service if they are specified in `update_mask`. - * - * The metastore service's `name` field is used to identify the metastore - * service to be updated. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/dataproc_metastore.update_service.js - * region_tag:metastore_v1_generated_DataprocMetastore_UpdateService_async - */ + /** + * Updates the parameters of a single service. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. A field mask used to specify the fields to be overwritten in the + * metastore service resource by the update. + * Fields specified in the `update_mask` are relative to the resource (not + * to the full request). A field is overwritten if it is in the mask. + * @param {google.cloud.metastore.v1.Service} request.service + * Required. The metastore service to update. The server only merges fields + * in the service if they are specified in `update_mask`. + * + * The metastore service's `name` field is used to identify the metastore + * service to be updated. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/dataproc_metastore.update_service.js + * region_tag:metastore_v1_generated_DataprocMetastore_UpdateService_async + */ updateService( - request?: protos.google.cloud.metastore.v1.IUpdateServiceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1.IUpdateServiceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1.IService, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateService( - request: protos.google.cloud.metastore.v1.IUpdateServiceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.IUpdateServiceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1.IService, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateService( - request: protos.google.cloud.metastore.v1.IUpdateServiceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.IUpdateServiceRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1.IService, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateService( - request?: protos.google.cloud.metastore.v1.IUpdateServiceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { + request?: protos.google.cloud.metastore.v1.IUpdateServiceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1.IService, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1.IService, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1.IService, + protos.google.cloud.metastore.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({ - 'service.name': request.service!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'service.name': request.service!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1.IService, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateService response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateService request %j', request); - return this.innerApiCalls.updateService(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateService response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateService(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1.IService, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateService response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateService()`. - * @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/dataproc_metastore.update_service.js - * region_tag:metastore_v1_generated_DataprocMetastore_UpdateService_async - */ - async checkUpdateServiceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateService()`. + * @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/dataproc_metastore.update_service.js + * region_tag:metastore_v1_generated_DataprocMetastore_UpdateService_async + */ + async checkUpdateServiceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1.Service, + protos.google.cloud.metastore.v1.OperationMetadata + > + > { this._log.info('updateService long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateService, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateService, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1.Service, + protos.google.cloud.metastore.v1.OperationMetadata + >; } -/** - * Deletes a single service. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The relative resource name of the metastore service to delete, in - * the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}`. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/dataproc_metastore.delete_service.js - * region_tag:metastore_v1_generated_DataprocMetastore_DeleteService_async - */ + /** + * Deletes a single service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The relative resource name of the metastore service to delete, in + * the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}`. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/dataproc_metastore.delete_service.js + * region_tag:metastore_v1_generated_DataprocMetastore_DeleteService_async + */ deleteService( - request?: protos.google.cloud.metastore.v1.IDeleteServiceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1.IDeleteServiceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteService( - request: protos.google.cloud.metastore.v1.IDeleteServiceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.IDeleteServiceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteService( - request: protos.google.cloud.metastore.v1.IDeleteServiceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.IDeleteServiceRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteService( - request?: protos.google.cloud.metastore.v1.IDeleteServiceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1.IDeleteServiceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteService response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteService request %j', request); - return this.innerApiCalls.deleteService(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteService response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteService(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteService response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteService()`. - * @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/dataproc_metastore.delete_service.js - * region_tag:metastore_v1_generated_DataprocMetastore_DeleteService_async - */ - async checkDeleteServiceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteService()`. + * @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/dataproc_metastore.delete_service.js + * region_tag:metastore_v1_generated_DataprocMetastore_DeleteService_async + */ + async checkDeleteServiceProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.metastore.v1.OperationMetadata + > + > { this._log.info('deleteService long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteService, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteService, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.metastore.v1.OperationMetadata + >; } -/** - * Creates a new MetadataImport in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the service in which to create a - * metastore import, in the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}`. - * @param {string} request.metadataImportId - * Required. The ID of the metadata import, which is used as the final - * component of the metadata import's name. - * - * This value must be between 1 and 64 characters long, begin with a letter, - * end with a letter or number, and consist of alpha-numeric ASCII characters - * or hyphens. - * @param {google.cloud.metastore.v1.MetadataImport} request.metadataImport - * Required. The metadata import to create. The `name` field is ignored. The - * ID of the created metadata import must be provided in the request's - * `metadata_import_id` field. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/dataproc_metastore.create_metadata_import.js - * region_tag:metastore_v1_generated_DataprocMetastore_CreateMetadataImport_async - */ + /** + * Creates a new MetadataImport in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the service in which to create a + * metastore import, in the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}`. + * @param {string} request.metadataImportId + * Required. The ID of the metadata import, which is used as the final + * component of the metadata import's name. + * + * This value must be between 1 and 64 characters long, begin with a letter, + * end with a letter or number, and consist of alpha-numeric ASCII characters + * or hyphens. + * @param {google.cloud.metastore.v1.MetadataImport} request.metadataImport + * Required. The metadata import to create. The `name` field is ignored. The + * ID of the created metadata import must be provided in the request's + * `metadata_import_id` field. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/dataproc_metastore.create_metadata_import.js + * region_tag:metastore_v1_generated_DataprocMetastore_CreateMetadataImport_async + */ createMetadataImport( - request?: protos.google.cloud.metastore.v1.ICreateMetadataImportRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1.ICreateMetadataImportRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1.IMetadataImport, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createMetadataImport( - request: protos.google.cloud.metastore.v1.ICreateMetadataImportRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.ICreateMetadataImportRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1.IMetadataImport, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createMetadataImport( - request: protos.google.cloud.metastore.v1.ICreateMetadataImportRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.ICreateMetadataImportRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1.IMetadataImport, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createMetadataImport( - request?: protos.google.cloud.metastore.v1.ICreateMetadataImportRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1.ICreateMetadataImportRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1.IMetadataImport, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1.IMetadataImport, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1.IMetadataImport, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1.IMetadataImport, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createMetadataImport response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createMetadataImport request %j', request); - return this.innerApiCalls.createMetadataImport(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createMetadataImport response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createMetadataImport(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1.IMetadataImport, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createMetadataImport response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createMetadataImport()`. - * @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/dataproc_metastore.create_metadata_import.js - * region_tag:metastore_v1_generated_DataprocMetastore_CreateMetadataImport_async - */ - async checkCreateMetadataImportProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createMetadataImport()`. + * @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/dataproc_metastore.create_metadata_import.js + * region_tag:metastore_v1_generated_DataprocMetastore_CreateMetadataImport_async + */ + async checkCreateMetadataImportProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1.MetadataImport, + protos.google.cloud.metastore.v1.OperationMetadata + > + > { this._log.info('createMetadataImport long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createMetadataImport, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createMetadataImport, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1.MetadataImport, + protos.google.cloud.metastore.v1.OperationMetadata + >; } -/** - * Updates a single import. - * Only the description field of MetadataImport is supported to be updated. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. A field mask used to specify the fields to be overwritten in the - * metadata import resource by the update. - * Fields specified in the `update_mask` are relative to the resource (not - * to the full request). A field is overwritten if it is in the mask. - * @param {google.cloud.metastore.v1.MetadataImport} request.metadataImport - * Required. The metadata import to update. The server only merges fields - * in the import if they are specified in `update_mask`. - * - * The metadata import's `name` field is used to identify the metastore - * import to be updated. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/dataproc_metastore.update_metadata_import.js - * region_tag:metastore_v1_generated_DataprocMetastore_UpdateMetadataImport_async - */ + /** + * Updates a single import. + * Only the description field of MetadataImport is supported to be updated. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. A field mask used to specify the fields to be overwritten in the + * metadata import resource by the update. + * Fields specified in the `update_mask` are relative to the resource (not + * to the full request). A field is overwritten if it is in the mask. + * @param {google.cloud.metastore.v1.MetadataImport} request.metadataImport + * Required. The metadata import to update. The server only merges fields + * in the import if they are specified in `update_mask`. + * + * The metadata import's `name` field is used to identify the metastore + * import to be updated. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/dataproc_metastore.update_metadata_import.js + * region_tag:metastore_v1_generated_DataprocMetastore_UpdateMetadataImport_async + */ updateMetadataImport( - request?: protos.google.cloud.metastore.v1.IUpdateMetadataImportRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1.IUpdateMetadataImportRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1.IMetadataImport, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateMetadataImport( - request: protos.google.cloud.metastore.v1.IUpdateMetadataImportRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.IUpdateMetadataImportRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1.IMetadataImport, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateMetadataImport( - request: protos.google.cloud.metastore.v1.IUpdateMetadataImportRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.IUpdateMetadataImportRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1.IMetadataImport, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateMetadataImport( - request?: protos.google.cloud.metastore.v1.IUpdateMetadataImportRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1.IUpdateMetadataImportRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1.IMetadataImport, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1.IMetadataImport, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1.IMetadataImport, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'metadata_import.name': request.metadataImport!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'metadata_import.name': request.metadataImport!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1.IMetadataImport, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateMetadataImport response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateMetadataImport request %j', request); - return this.innerApiCalls.updateMetadataImport(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateMetadataImport response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateMetadataImport(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1.IMetadataImport, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateMetadataImport response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateMetadataImport()`. - * @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/dataproc_metastore.update_metadata_import.js - * region_tag:metastore_v1_generated_DataprocMetastore_UpdateMetadataImport_async - */ - async checkUpdateMetadataImportProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateMetadataImport()`. + * @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/dataproc_metastore.update_metadata_import.js + * region_tag:metastore_v1_generated_DataprocMetastore_UpdateMetadataImport_async + */ + async checkUpdateMetadataImportProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1.MetadataImport, + protos.google.cloud.metastore.v1.OperationMetadata + > + > { this._log.info('updateMetadataImport long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateMetadataImport, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateMetadataImport, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1.MetadataImport, + protos.google.cloud.metastore.v1.OperationMetadata + >; } -/** - * Exports metadata from a service. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.destinationGcsFolder - * A Cloud Storage URI of a folder, in the format - * `gs:///`. A sub-folder - * `` containing exported files will be created below it. - * @param {string} request.service - * Required. The relative resource name of the metastore service to run - * export, in the following form: - * - * `projects/{project_id}/locations/{location_id}/services/{service_id}`. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format). - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @param {google.cloud.metastore.v1.DatabaseDumpSpec.Type} [request.databaseDumpType] - * Optional. The type of the database dump. If unspecified, defaults to - * `MYSQL`. - * @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/dataproc_metastore.export_metadata.js - * region_tag:metastore_v1_generated_DataprocMetastore_ExportMetadata_async - */ + /** + * Exports metadata from a service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.destinationGcsFolder + * A Cloud Storage URI of a folder, in the format + * `gs:///`. A sub-folder + * `` containing exported files will be created below it. + * @param {string} request.service + * Required. The relative resource name of the metastore service to run + * export, in the following form: + * + * `projects/{project_id}/locations/{location_id}/services/{service_id}`. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format). + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @param {google.cloud.metastore.v1.DatabaseDumpSpec.Type} [request.databaseDumpType] + * Optional. The type of the database dump. If unspecified, defaults to + * `MYSQL`. + * @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/dataproc_metastore.export_metadata.js + * region_tag:metastore_v1_generated_DataprocMetastore_ExportMetadata_async + */ exportMetadata( - request?: protos.google.cloud.metastore.v1.IExportMetadataRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1.IExportMetadataRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1.IMetadataExport, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; exportMetadata( - request: protos.google.cloud.metastore.v1.IExportMetadataRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.IExportMetadataRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1.IMetadataExport, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; exportMetadata( - request: protos.google.cloud.metastore.v1.IExportMetadataRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.IExportMetadataRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1.IMetadataExport, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; exportMetadata( - request?: protos.google.cloud.metastore.v1.IExportMetadataRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1.IExportMetadataRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1.IMetadataExport, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1.IMetadataExport, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1.IMetadataExport, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'service': request.service ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + service: request.service ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1.IMetadataExport, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('exportMetadata response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('exportMetadata request %j', request); - return this.innerApiCalls.exportMetadata(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('exportMetadata response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .exportMetadata(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1.IMetadataExport, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('exportMetadata response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `exportMetadata()`. - * @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/dataproc_metastore.export_metadata.js - * region_tag:metastore_v1_generated_DataprocMetastore_ExportMetadata_async - */ - async checkExportMetadataProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `exportMetadata()`. + * @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/dataproc_metastore.export_metadata.js + * region_tag:metastore_v1_generated_DataprocMetastore_ExportMetadata_async + */ + async checkExportMetadataProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1.MetadataExport, + protos.google.cloud.metastore.v1.OperationMetadata + > + > { this._log.info('exportMetadata long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.exportMetadata, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.exportMetadata, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1.MetadataExport, + protos.google.cloud.metastore.v1.OperationMetadata + >; } -/** - * Restores a service from a backup. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.service - * Required. The relative resource name of the metastore service to run - * restore, in the following form: - * - * `projects/{project_id}/locations/{location_id}/services/{service_id}`. - * @param {string} request.backup - * Required. The relative resource name of the metastore service backup to - * restore from, in the following form: - * - * `projects/{project_id}/locations/{location_id}/services/{service_id}/backups/{backup_id}`. - * @param {google.cloud.metastore.v1.Restore.RestoreType} [request.restoreType] - * Optional. The type of restore. If unspecified, defaults to `METADATA_ONLY`. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format). - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/dataproc_metastore.restore_service.js - * region_tag:metastore_v1_generated_DataprocMetastore_RestoreService_async - */ + /** + * Restores a service from a backup. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.service + * Required. The relative resource name of the metastore service to run + * restore, in the following form: + * + * `projects/{project_id}/locations/{location_id}/services/{service_id}`. + * @param {string} request.backup + * Required. The relative resource name of the metastore service backup to + * restore from, in the following form: + * + * `projects/{project_id}/locations/{location_id}/services/{service_id}/backups/{backup_id}`. + * @param {google.cloud.metastore.v1.Restore.RestoreType} [request.restoreType] + * Optional. The type of restore. If unspecified, defaults to `METADATA_ONLY`. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format). + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/dataproc_metastore.restore_service.js + * region_tag:metastore_v1_generated_DataprocMetastore_RestoreService_async + */ restoreService( - request?: protos.google.cloud.metastore.v1.IRestoreServiceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1.IRestoreServiceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1.IRestore, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; restoreService( - request: protos.google.cloud.metastore.v1.IRestoreServiceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.IRestoreServiceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1.IRestore, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; restoreService( - request: protos.google.cloud.metastore.v1.IRestoreServiceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.IRestoreServiceRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1.IRestore, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; restoreService( - request?: protos.google.cloud.metastore.v1.IRestoreServiceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1.IRestoreServiceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1.IRestore, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1.IRestore, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1.IRestore, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'service': request.service ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + service: request.service ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1.IRestore, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('restoreService response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('restoreService request %j', request); - return this.innerApiCalls.restoreService(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('restoreService response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .restoreService(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1.IRestore, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('restoreService response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `restoreService()`. - * @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/dataproc_metastore.restore_service.js - * region_tag:metastore_v1_generated_DataprocMetastore_RestoreService_async - */ - async checkRestoreServiceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `restoreService()`. + * @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/dataproc_metastore.restore_service.js + * region_tag:metastore_v1_generated_DataprocMetastore_RestoreService_async + */ + async checkRestoreServiceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1.Restore, + protos.google.cloud.metastore.v1.OperationMetadata + > + > { this._log.info('restoreService long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.restoreService, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.restoreService, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1.Restore, + protos.google.cloud.metastore.v1.OperationMetadata + >; } -/** - * Creates a new backup in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the service in which to create a - * backup of the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}`. - * @param {string} request.backupId - * Required. The ID of the backup, which is used as the final component of the - * backup's name. - * - * This value must be between 1 and 64 characters long, begin with a letter, - * end with a letter or number, and consist of alpha-numeric ASCII characters - * or hyphens. - * @param {google.cloud.metastore.v1.Backup} request.backup - * Required. The backup to create. The `name` field is ignored. The ID of the - * created backup must be provided in the request's `backup_id` field. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/dataproc_metastore.create_backup.js - * region_tag:metastore_v1_generated_DataprocMetastore_CreateBackup_async - */ + /** + * Creates a new backup in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the service in which to create a + * backup of the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}`. + * @param {string} request.backupId + * Required. The ID of the backup, which is used as the final component of the + * backup's name. + * + * This value must be between 1 and 64 characters long, begin with a letter, + * end with a letter or number, and consist of alpha-numeric ASCII characters + * or hyphens. + * @param {google.cloud.metastore.v1.Backup} request.backup + * Required. The backup to create. The `name` field is ignored. The ID of the + * created backup must be provided in the request's `backup_id` field. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/dataproc_metastore.create_backup.js + * region_tag:metastore_v1_generated_DataprocMetastore_CreateBackup_async + */ createBackup( - request?: protos.google.cloud.metastore.v1.ICreateBackupRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1.ICreateBackupRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1.IBackup, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createBackup( - request: protos.google.cloud.metastore.v1.ICreateBackupRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.ICreateBackupRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1.IBackup, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createBackup( - request: protos.google.cloud.metastore.v1.ICreateBackupRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.ICreateBackupRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1.IBackup, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createBackup( - request?: protos.google.cloud.metastore.v1.ICreateBackupRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1.ICreateBackupRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1.IBackup, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1.IBackup, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1.IBackup, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1.IBackup, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createBackup response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createBackup request %j', request); - return this.innerApiCalls.createBackup(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createBackup response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createBackup(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1.IBackup, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createBackup response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createBackup()`. - * @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/dataproc_metastore.create_backup.js - * region_tag:metastore_v1_generated_DataprocMetastore_CreateBackup_async - */ - async checkCreateBackupProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createBackup()`. + * @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/dataproc_metastore.create_backup.js + * region_tag:metastore_v1_generated_DataprocMetastore_CreateBackup_async + */ + async checkCreateBackupProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1.Backup, + protos.google.cloud.metastore.v1.OperationMetadata + > + > { this._log.info('createBackup long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createBackup, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createBackup, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1.Backup, + protos.google.cloud.metastore.v1.OperationMetadata + >; } -/** - * Deletes a single backup. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The relative resource name of the backup to delete, in the - * following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}/backups/{backup_id}`. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/dataproc_metastore.delete_backup.js - * region_tag:metastore_v1_generated_DataprocMetastore_DeleteBackup_async - */ + /** + * Deletes a single backup. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The relative resource name of the backup to delete, in the + * following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}/backups/{backup_id}`. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/dataproc_metastore.delete_backup.js + * region_tag:metastore_v1_generated_DataprocMetastore_DeleteBackup_async + */ deleteBackup( - request?: protos.google.cloud.metastore.v1.IDeleteBackupRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1.IDeleteBackupRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteBackup( - request: protos.google.cloud.metastore.v1.IDeleteBackupRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.IDeleteBackupRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteBackup( - request: protos.google.cloud.metastore.v1.IDeleteBackupRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.IDeleteBackupRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteBackup( - request?: protos.google.cloud.metastore.v1.IDeleteBackupRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1.IDeleteBackupRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteBackup response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteBackup request %j', request); - return this.innerApiCalls.deleteBackup(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteBackup response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteBackup(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteBackup response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteBackup()`. - * @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/dataproc_metastore.delete_backup.js - * region_tag:metastore_v1_generated_DataprocMetastore_DeleteBackup_async - */ - async checkDeleteBackupProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteBackup()`. + * @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/dataproc_metastore.delete_backup.js + * region_tag:metastore_v1_generated_DataprocMetastore_DeleteBackup_async + */ + async checkDeleteBackupProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.metastore.v1.OperationMetadata + > + > { this._log.info('deleteBackup long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteBackup, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteBackup, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.metastore.v1.OperationMetadata + >; } -/** - * Query DPMS metadata. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.service - * Required. The relative resource name of the metastore service to query - * metadata, in the following format: - * - * `projects/{project_id}/locations/{location_id}/services/{service_id}`. - * @param {string} request.query - * Required. A read-only SQL query to execute against the metadata database. - * The query cannot change or mutate the data. - * @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/dataproc_metastore.query_metadata.js - * region_tag:metastore_v1_generated_DataprocMetastore_QueryMetadata_async - */ + /** + * Query DPMS metadata. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.service + * Required. The relative resource name of the metastore service to query + * metadata, in the following format: + * + * `projects/{project_id}/locations/{location_id}/services/{service_id}`. + * @param {string} request.query + * Required. A read-only SQL query to execute against the metadata database. + * The query cannot change or mutate the data. + * @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/dataproc_metastore.query_metadata.js + * region_tag:metastore_v1_generated_DataprocMetastore_QueryMetadata_async + */ queryMetadata( - request?: protos.google.cloud.metastore.v1.IQueryMetadataRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1.IQueryMetadataRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1.IQueryMetadataResponse, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; queryMetadata( - request: protos.google.cloud.metastore.v1.IQueryMetadataRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.IQueryMetadataRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1.IQueryMetadataResponse, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; queryMetadata( - request: protos.google.cloud.metastore.v1.IQueryMetadataRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.IQueryMetadataRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1.IQueryMetadataResponse, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; queryMetadata( - request?: protos.google.cloud.metastore.v1.IQueryMetadataRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1.IQueryMetadataRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1.IQueryMetadataResponse, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1.IQueryMetadataResponse, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1.IQueryMetadataResponse, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'service': request.service ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + service: request.service ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1.IQueryMetadataResponse, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('queryMetadata response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('queryMetadata request %j', request); - return this.innerApiCalls.queryMetadata(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('queryMetadata response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .queryMetadata(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1.IQueryMetadataResponse, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('queryMetadata response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `queryMetadata()`. - * @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/dataproc_metastore.query_metadata.js - * region_tag:metastore_v1_generated_DataprocMetastore_QueryMetadata_async - */ - async checkQueryMetadataProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `queryMetadata()`. + * @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/dataproc_metastore.query_metadata.js + * region_tag:metastore_v1_generated_DataprocMetastore_QueryMetadata_async + */ + async checkQueryMetadataProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1.QueryMetadataResponse, + protos.google.cloud.metastore.v1.OperationMetadata + > + > { this._log.info('queryMetadata long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.queryMetadata, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.queryMetadata, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1.QueryMetadataResponse, + protos.google.cloud.metastore.v1.OperationMetadata + >; } -/** - * Move a table to another database. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.service - * Required. The relative resource name of the metastore service to mutate - * metadata, in the following format: - * - * `projects/{project_id}/locations/{location_id}/services/{service_id}`. - * @param {string} request.tableName - * Required. The name of the table to be moved. - * @param {string} request.dbName - * Required. The name of the database where the table resides. - * @param {string} request.destinationDbName - * Required. The name of the database where the table should be moved. - * @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/dataproc_metastore.move_table_to_database.js - * region_tag:metastore_v1_generated_DataprocMetastore_MoveTableToDatabase_async - */ + /** + * Move a table to another database. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.service + * Required. The relative resource name of the metastore service to mutate + * metadata, in the following format: + * + * `projects/{project_id}/locations/{location_id}/services/{service_id}`. + * @param {string} request.tableName + * Required. The name of the table to be moved. + * @param {string} request.dbName + * Required. The name of the database where the table resides. + * @param {string} request.destinationDbName + * Required. The name of the database where the table should be moved. + * @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/dataproc_metastore.move_table_to_database.js + * region_tag:metastore_v1_generated_DataprocMetastore_MoveTableToDatabase_async + */ moveTableToDatabase( - request?: protos.google.cloud.metastore.v1.IMoveTableToDatabaseRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1.IMoveTableToDatabaseRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1.IMoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; moveTableToDatabase( - request: protos.google.cloud.metastore.v1.IMoveTableToDatabaseRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.IMoveTableToDatabaseRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1.IMoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; moveTableToDatabase( - request: protos.google.cloud.metastore.v1.IMoveTableToDatabaseRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.IMoveTableToDatabaseRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1.IMoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; moveTableToDatabase( - request?: protos.google.cloud.metastore.v1.IMoveTableToDatabaseRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1.IMoveTableToDatabaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1.IMoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1.IMoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1.IMoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'service': request.service ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + service: request.service ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1.IMoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('moveTableToDatabase response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('moveTableToDatabase request %j', request); - return this.innerApiCalls.moveTableToDatabase(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('moveTableToDatabase response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .moveTableToDatabase(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1.IMoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('moveTableToDatabase response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `moveTableToDatabase()`. - * @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/dataproc_metastore.move_table_to_database.js - * region_tag:metastore_v1_generated_DataprocMetastore_MoveTableToDatabase_async - */ - async checkMoveTableToDatabaseProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `moveTableToDatabase()`. + * @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/dataproc_metastore.move_table_to_database.js + * region_tag:metastore_v1_generated_DataprocMetastore_MoveTableToDatabase_async + */ + async checkMoveTableToDatabaseProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1.MoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1.OperationMetadata + > + > { this._log.info('moveTableToDatabase long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.moveTableToDatabase, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.moveTableToDatabase, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1.MoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1.OperationMetadata + >; } -/** - * Alter metadata resource location. The metadata resource can be a database, - * table, or partition. This functionality only updates the parent directory - * for the respective metadata resource and does not transfer any existing - * data to the new location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.service - * Required. The relative resource name of the metastore service to mutate - * metadata, in the following format: - * - * `projects/{project_id}/locations/{location_id}/services/{service_id}`. - * @param {string} request.resourceName - * Required. The relative metadata resource name in the following format. - * - * `databases/{database_id}` - * or - * `databases/{database_id}/tables/{table_id}` - * or - * `databases/{database_id}/tables/{table_id}/partitions/{partition_id}` - * @param {string} request.locationUri - * Required. The new location URI for the metadata resource. - * @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/dataproc_metastore.alter_metadata_resource_location.js - * region_tag:metastore_v1_generated_DataprocMetastore_AlterMetadataResourceLocation_async - */ + /** + * Alter metadata resource location. The metadata resource can be a database, + * table, or partition. This functionality only updates the parent directory + * for the respective metadata resource and does not transfer any existing + * data to the new location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.service + * Required. The relative resource name of the metastore service to mutate + * metadata, in the following format: + * + * `projects/{project_id}/locations/{location_id}/services/{service_id}`. + * @param {string} request.resourceName + * Required. The relative metadata resource name in the following format. + * + * `databases/{database_id}` + * or + * `databases/{database_id}/tables/{table_id}` + * or + * `databases/{database_id}/tables/{table_id}/partitions/{partition_id}` + * @param {string} request.locationUri + * Required. The new location URI for the metadata resource. + * @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/dataproc_metastore.alter_metadata_resource_location.js + * region_tag:metastore_v1_generated_DataprocMetastore_AlterMetadataResourceLocation_async + */ alterMetadataResourceLocation( - request?: protos.google.cloud.metastore.v1.IAlterMetadataResourceLocationRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1.IAlterMetadataResourceLocationRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1.IAlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; alterMetadataResourceLocation( - request: protos.google.cloud.metastore.v1.IAlterMetadataResourceLocationRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.IAlterMetadataResourceLocationRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1.IAlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; alterMetadataResourceLocation( - request: protos.google.cloud.metastore.v1.IAlterMetadataResourceLocationRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.IAlterMetadataResourceLocationRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1.IAlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; alterMetadataResourceLocation( - request?: protos.google.cloud.metastore.v1.IAlterMetadataResourceLocationRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1.IAlterMetadataResourceLocationRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1.IAlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1.IAlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1.IAlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'service': request.service ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + service: request.service ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1.IAlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { - this._log.info('alterMetadataResourceLocation response %j', rawResponse); + this._log.info( + 'alterMetadataResourceLocation response %j', + rawResponse, + ); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('alterMetadataResourceLocation request %j', request); - return this.innerApiCalls.alterMetadataResourceLocation(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('alterMetadataResourceLocation response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .alterMetadataResourceLocation(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1.IAlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info( + 'alterMetadataResourceLocation response %j', + rawResponse, + ); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `alterMetadataResourceLocation()`. - * @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/dataproc_metastore.alter_metadata_resource_location.js - * region_tag:metastore_v1_generated_DataprocMetastore_AlterMetadataResourceLocation_async - */ - async checkAlterMetadataResourceLocationProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `alterMetadataResourceLocation()`. + * @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/dataproc_metastore.alter_metadata_resource_location.js + * region_tag:metastore_v1_generated_DataprocMetastore_AlterMetadataResourceLocation_async + */ + async checkAlterMetadataResourceLocationProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1.AlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1.OperationMetadata + > + > { this._log.info('alterMetadataResourceLocation long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.alterMetadataResourceLocation, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.alterMetadataResourceLocation, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1.AlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1.OperationMetadata + >; } - /** - * Lists services in a project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the location of metastore services - * to list, in the following form: - * - * `projects/{project_number}/locations/{location_id}`. - * @param {number} [request.pageSize] - * Optional. The maximum number of services to return. The response may - * contain less than the maximum number. If unspecified, no more than 500 - * services are returned. The maximum value is 1000; values above 1000 are - * changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @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 Array of {@link protos.google.cloud.metastore.v1.Service|Service}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listServicesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists services in a project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the location of metastore services + * to list, in the following form: + * + * `projects/{project_number}/locations/{location_id}`. + * @param {number} [request.pageSize] + * Optional. The maximum number of services to return. The response may + * contain less than the maximum number. If unspecified, no more than 500 + * services are returned. The maximum value is 1000; values above 1000 are + * changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @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 Array of {@link protos.google.cloud.metastore.v1.Service|Service}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listServicesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listServices( - request?: protos.google.cloud.metastore.v1.IListServicesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.metastore.v1.IService[], - protos.google.cloud.metastore.v1.IListServicesRequest|null, - protos.google.cloud.metastore.v1.IListServicesResponse - ]>; + request?: protos.google.cloud.metastore.v1.IListServicesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.metastore.v1.IService[], + protos.google.cloud.metastore.v1.IListServicesRequest | null, + protos.google.cloud.metastore.v1.IListServicesResponse, + ] + >; listServices( - request: protos.google.cloud.metastore.v1.IListServicesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.metastore.v1.IListServicesRequest, - protos.google.cloud.metastore.v1.IListServicesResponse|null|undefined, - protos.google.cloud.metastore.v1.IService>): void; + request: protos.google.cloud.metastore.v1.IListServicesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.metastore.v1.IListServicesRequest, + protos.google.cloud.metastore.v1.IListServicesResponse | null | undefined, + protos.google.cloud.metastore.v1.IService + >, + ): void; listServices( - request: protos.google.cloud.metastore.v1.IListServicesRequest, - callback: PaginationCallback< - protos.google.cloud.metastore.v1.IListServicesRequest, - protos.google.cloud.metastore.v1.IListServicesResponse|null|undefined, - protos.google.cloud.metastore.v1.IService>): void; + request: protos.google.cloud.metastore.v1.IListServicesRequest, + callback: PaginationCallback< + protos.google.cloud.metastore.v1.IListServicesRequest, + protos.google.cloud.metastore.v1.IListServicesResponse | null | undefined, + protos.google.cloud.metastore.v1.IService + >, + ): void; listServices( - request?: protos.google.cloud.metastore.v1.IListServicesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.metastore.v1.IListServicesRequest, - protos.google.cloud.metastore.v1.IListServicesResponse|null|undefined, - protos.google.cloud.metastore.v1.IService>, - callback?: PaginationCallback< + request?: protos.google.cloud.metastore.v1.IListServicesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.metastore.v1.IListServicesRequest, - protos.google.cloud.metastore.v1.IListServicesResponse|null|undefined, - protos.google.cloud.metastore.v1.IService>): - Promise<[ - protos.google.cloud.metastore.v1.IService[], - protos.google.cloud.metastore.v1.IListServicesRequest|null, - protos.google.cloud.metastore.v1.IListServicesResponse - ]>|void { + | protos.google.cloud.metastore.v1.IListServicesResponse + | null + | undefined, + protos.google.cloud.metastore.v1.IService + >, + callback?: PaginationCallback< + protos.google.cloud.metastore.v1.IListServicesRequest, + protos.google.cloud.metastore.v1.IListServicesResponse | null | undefined, + protos.google.cloud.metastore.v1.IService + >, + ): Promise< + [ + protos.google.cloud.metastore.v1.IService[], + protos.google.cloud.metastore.v1.IListServicesRequest | null, + protos.google.cloud.metastore.v1.IListServicesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.metastore.v1.IListServicesRequest, - protos.google.cloud.metastore.v1.IListServicesResponse|null|undefined, - protos.google.cloud.metastore.v1.IService>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.metastore.v1.IListServicesRequest, + | protos.google.cloud.metastore.v1.IListServicesResponse + | null + | undefined, + protos.google.cloud.metastore.v1.IService + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listServices values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2420,248 +3476,277 @@ export class DataprocMetastoreClient { this._log.info('listServices request %j', request); return this.innerApiCalls .listServices(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.metastore.v1.IService[], - protos.google.cloud.metastore.v1.IListServicesRequest|null, - protos.google.cloud.metastore.v1.IListServicesResponse - ]) => { - this._log.info('listServices values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.metastore.v1.IService[], + protos.google.cloud.metastore.v1.IListServicesRequest | null, + protos.google.cloud.metastore.v1.IListServicesResponse, + ]) => { + this._log.info('listServices values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listServices`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the location of metastore services - * to list, in the following form: - * - * `projects/{project_number}/locations/{location_id}`. - * @param {number} [request.pageSize] - * Optional. The maximum number of services to return. The response may - * contain less than the maximum number. If unspecified, no more than 500 - * services are returned. The maximum value is 1000; values above 1000 are - * changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.metastore.v1.Service|Service} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listServicesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listServices`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the location of metastore services + * to list, in the following form: + * + * `projects/{project_number}/locations/{location_id}`. + * @param {number} [request.pageSize] + * Optional. The maximum number of services to return. The response may + * contain less than the maximum number. If unspecified, no more than 500 + * services are returned. The maximum value is 1000; values above 1000 are + * changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.metastore.v1.Service|Service} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listServicesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listServicesStream( - request?: protos.google.cloud.metastore.v1.IListServicesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.metastore.v1.IListServicesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listServices']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listServices stream %j', request); return this.descriptors.page.listServices.createStream( this.innerApiCalls.listServices as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listServices`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the location of metastore services - * to list, in the following form: - * - * `projects/{project_number}/locations/{location_id}`. - * @param {number} [request.pageSize] - * Optional. The maximum number of services to return. The response may - * contain less than the maximum number. If unspecified, no more than 500 - * services are returned. The maximum value is 1000; values above 1000 are - * changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.metastore.v1.Service|Service}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/dataproc_metastore.list_services.js - * region_tag:metastore_v1_generated_DataprocMetastore_ListServices_async - */ + /** + * Equivalent to `listServices`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the location of metastore services + * to list, in the following form: + * + * `projects/{project_number}/locations/{location_id}`. + * @param {number} [request.pageSize] + * Optional. The maximum number of services to return. The response may + * contain less than the maximum number. If unspecified, no more than 500 + * services are returned. The maximum value is 1000; values above 1000 are + * changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.metastore.v1.Service|Service}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/dataproc_metastore.list_services.js + * region_tag:metastore_v1_generated_DataprocMetastore_ListServices_async + */ listServicesAsync( - request?: protos.google.cloud.metastore.v1.IListServicesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.metastore.v1.IListServicesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listServices']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listServices iterate %j', request); return this.descriptors.page.listServices.asyncIterate( this.innerApiCalls['listServices'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists imports in a service. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the service whose metadata imports - * to list, in the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}/metadataImports`. - * @param {number} [request.pageSize] - * Optional. The maximum number of imports to return. The response may contain - * less than the maximum number. If unspecified, no more than 500 imports are - * returned. The maximum value is 1000; values above 1000 are changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @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 Array of {@link protos.google.cloud.metastore.v1.MetadataImport|MetadataImport}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listMetadataImportsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists imports in a service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the service whose metadata imports + * to list, in the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}/metadataImports`. + * @param {number} [request.pageSize] + * Optional. The maximum number of imports to return. The response may contain + * less than the maximum number. If unspecified, no more than 500 imports are + * returned. The maximum value is 1000; values above 1000 are changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @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 Array of {@link protos.google.cloud.metastore.v1.MetadataImport|MetadataImport}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listMetadataImportsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMetadataImports( - request?: protos.google.cloud.metastore.v1.IListMetadataImportsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.metastore.v1.IMetadataImport[], - protos.google.cloud.metastore.v1.IListMetadataImportsRequest|null, - protos.google.cloud.metastore.v1.IListMetadataImportsResponse - ]>; + request?: protos.google.cloud.metastore.v1.IListMetadataImportsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.metastore.v1.IMetadataImport[], + protos.google.cloud.metastore.v1.IListMetadataImportsRequest | null, + protos.google.cloud.metastore.v1.IListMetadataImportsResponse, + ] + >; listMetadataImports( - request: protos.google.cloud.metastore.v1.IListMetadataImportsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.metastore.v1.IListMetadataImportsRequest, - protos.google.cloud.metastore.v1.IListMetadataImportsResponse|null|undefined, - protos.google.cloud.metastore.v1.IMetadataImport>): void; + request: protos.google.cloud.metastore.v1.IListMetadataImportsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.metastore.v1.IListMetadataImportsRequest, + | protos.google.cloud.metastore.v1.IListMetadataImportsResponse + | null + | undefined, + protos.google.cloud.metastore.v1.IMetadataImport + >, + ): void; listMetadataImports( - request: protos.google.cloud.metastore.v1.IListMetadataImportsRequest, - callback: PaginationCallback< - protos.google.cloud.metastore.v1.IListMetadataImportsRequest, - protos.google.cloud.metastore.v1.IListMetadataImportsResponse|null|undefined, - protos.google.cloud.metastore.v1.IMetadataImport>): void; + request: protos.google.cloud.metastore.v1.IListMetadataImportsRequest, + callback: PaginationCallback< + protos.google.cloud.metastore.v1.IListMetadataImportsRequest, + | protos.google.cloud.metastore.v1.IListMetadataImportsResponse + | null + | undefined, + protos.google.cloud.metastore.v1.IMetadataImport + >, + ): void; listMetadataImports( - request?: protos.google.cloud.metastore.v1.IListMetadataImportsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.metastore.v1.IListMetadataImportsRequest, - protos.google.cloud.metastore.v1.IListMetadataImportsResponse|null|undefined, - protos.google.cloud.metastore.v1.IMetadataImport>, - callback?: PaginationCallback< + request?: protos.google.cloud.metastore.v1.IListMetadataImportsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.metastore.v1.IListMetadataImportsRequest, - protos.google.cloud.metastore.v1.IListMetadataImportsResponse|null|undefined, - protos.google.cloud.metastore.v1.IMetadataImport>): - Promise<[ - protos.google.cloud.metastore.v1.IMetadataImport[], - protos.google.cloud.metastore.v1.IListMetadataImportsRequest|null, - protos.google.cloud.metastore.v1.IListMetadataImportsResponse - ]>|void { + | protos.google.cloud.metastore.v1.IListMetadataImportsResponse + | null + | undefined, + protos.google.cloud.metastore.v1.IMetadataImport + >, + callback?: PaginationCallback< + protos.google.cloud.metastore.v1.IListMetadataImportsRequest, + | protos.google.cloud.metastore.v1.IListMetadataImportsResponse + | null + | undefined, + protos.google.cloud.metastore.v1.IMetadataImport + >, + ): Promise< + [ + protos.google.cloud.metastore.v1.IMetadataImport[], + protos.google.cloud.metastore.v1.IListMetadataImportsRequest | null, + protos.google.cloud.metastore.v1.IListMetadataImportsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.metastore.v1.IListMetadataImportsRequest, - protos.google.cloud.metastore.v1.IListMetadataImportsResponse|null|undefined, - protos.google.cloud.metastore.v1.IMetadataImport>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.metastore.v1.IListMetadataImportsRequest, + | protos.google.cloud.metastore.v1.IListMetadataImportsResponse + | null + | undefined, + protos.google.cloud.metastore.v1.IMetadataImport + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listMetadataImports values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2670,246 +3755,269 @@ export class DataprocMetastoreClient { this._log.info('listMetadataImports request %j', request); return this.innerApiCalls .listMetadataImports(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.metastore.v1.IMetadataImport[], - protos.google.cloud.metastore.v1.IListMetadataImportsRequest|null, - protos.google.cloud.metastore.v1.IListMetadataImportsResponse - ]) => { - this._log.info('listMetadataImports values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.metastore.v1.IMetadataImport[], + protos.google.cloud.metastore.v1.IListMetadataImportsRequest | null, + protos.google.cloud.metastore.v1.IListMetadataImportsResponse, + ]) => { + this._log.info('listMetadataImports values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listMetadataImports`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the service whose metadata imports - * to list, in the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}/metadataImports`. - * @param {number} [request.pageSize] - * Optional. The maximum number of imports to return. The response may contain - * less than the maximum number. If unspecified, no more than 500 imports are - * returned. The maximum value is 1000; values above 1000 are changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.metastore.v1.MetadataImport|MetadataImport} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listMetadataImportsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listMetadataImports`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the service whose metadata imports + * to list, in the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}/metadataImports`. + * @param {number} [request.pageSize] + * Optional. The maximum number of imports to return. The response may contain + * less than the maximum number. If unspecified, no more than 500 imports are + * returned. The maximum value is 1000; values above 1000 are changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.metastore.v1.MetadataImport|MetadataImport} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listMetadataImportsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMetadataImportsStream( - request?: protos.google.cloud.metastore.v1.IListMetadataImportsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.metastore.v1.IListMetadataImportsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listMetadataImports']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listMetadataImports stream %j', request); return this.descriptors.page.listMetadataImports.createStream( this.innerApiCalls.listMetadataImports as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listMetadataImports`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the service whose metadata imports - * to list, in the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}/metadataImports`. - * @param {number} [request.pageSize] - * Optional. The maximum number of imports to return. The response may contain - * less than the maximum number. If unspecified, no more than 500 imports are - * returned. The maximum value is 1000; values above 1000 are changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.metastore.v1.MetadataImport|MetadataImport}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/dataproc_metastore.list_metadata_imports.js - * region_tag:metastore_v1_generated_DataprocMetastore_ListMetadataImports_async - */ + /** + * Equivalent to `listMetadataImports`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the service whose metadata imports + * to list, in the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}/metadataImports`. + * @param {number} [request.pageSize] + * Optional. The maximum number of imports to return. The response may contain + * less than the maximum number. If unspecified, no more than 500 imports are + * returned. The maximum value is 1000; values above 1000 are changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.metastore.v1.MetadataImport|MetadataImport}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/dataproc_metastore.list_metadata_imports.js + * region_tag:metastore_v1_generated_DataprocMetastore_ListMetadataImports_async + */ listMetadataImportsAsync( - request?: protos.google.cloud.metastore.v1.IListMetadataImportsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.metastore.v1.IListMetadataImportsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listMetadataImports']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listMetadataImports iterate %j', request); return this.descriptors.page.listMetadataImports.asyncIterate( this.innerApiCalls['listMetadataImports'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists backups in a service. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the service whose backups to - * list, in the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}/backups`. - * @param {number} [request.pageSize] - * Optional. The maximum number of backups to return. The response may contain - * less than the maximum number. If unspecified, no more than 500 backups are - * returned. The maximum value is 1000; values above 1000 are changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @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 Array of {@link protos.google.cloud.metastore.v1.Backup|Backup}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listBackupsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists backups in a service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the service whose backups to + * list, in the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}/backups`. + * @param {number} [request.pageSize] + * Optional. The maximum number of backups to return. The response may contain + * less than the maximum number. If unspecified, no more than 500 backups are + * returned. The maximum value is 1000; values above 1000 are changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @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 Array of {@link protos.google.cloud.metastore.v1.Backup|Backup}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listBackupsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listBackups( - request?: protos.google.cloud.metastore.v1.IListBackupsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.metastore.v1.IBackup[], - protos.google.cloud.metastore.v1.IListBackupsRequest|null, - protos.google.cloud.metastore.v1.IListBackupsResponse - ]>; + request?: protos.google.cloud.metastore.v1.IListBackupsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.metastore.v1.IBackup[], + protos.google.cloud.metastore.v1.IListBackupsRequest | null, + protos.google.cloud.metastore.v1.IListBackupsResponse, + ] + >; listBackups( - request: protos.google.cloud.metastore.v1.IListBackupsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.metastore.v1.IListBackupsRequest, - protos.google.cloud.metastore.v1.IListBackupsResponse|null|undefined, - protos.google.cloud.metastore.v1.IBackup>): void; + request: protos.google.cloud.metastore.v1.IListBackupsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.metastore.v1.IListBackupsRequest, + protos.google.cloud.metastore.v1.IListBackupsResponse | null | undefined, + protos.google.cloud.metastore.v1.IBackup + >, + ): void; listBackups( - request: protos.google.cloud.metastore.v1.IListBackupsRequest, - callback: PaginationCallback< - protos.google.cloud.metastore.v1.IListBackupsRequest, - protos.google.cloud.metastore.v1.IListBackupsResponse|null|undefined, - protos.google.cloud.metastore.v1.IBackup>): void; + request: protos.google.cloud.metastore.v1.IListBackupsRequest, + callback: PaginationCallback< + protos.google.cloud.metastore.v1.IListBackupsRequest, + protos.google.cloud.metastore.v1.IListBackupsResponse | null | undefined, + protos.google.cloud.metastore.v1.IBackup + >, + ): void; listBackups( - request?: protos.google.cloud.metastore.v1.IListBackupsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.metastore.v1.IListBackupsRequest, - protos.google.cloud.metastore.v1.IListBackupsResponse|null|undefined, - protos.google.cloud.metastore.v1.IBackup>, - callback?: PaginationCallback< + request?: protos.google.cloud.metastore.v1.IListBackupsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.metastore.v1.IListBackupsRequest, - protos.google.cloud.metastore.v1.IListBackupsResponse|null|undefined, - protos.google.cloud.metastore.v1.IBackup>): - Promise<[ - protos.google.cloud.metastore.v1.IBackup[], - protos.google.cloud.metastore.v1.IListBackupsRequest|null, - protos.google.cloud.metastore.v1.IListBackupsResponse - ]>|void { + | protos.google.cloud.metastore.v1.IListBackupsResponse + | null + | undefined, + protos.google.cloud.metastore.v1.IBackup + >, + callback?: PaginationCallback< + protos.google.cloud.metastore.v1.IListBackupsRequest, + protos.google.cloud.metastore.v1.IListBackupsResponse | null | undefined, + protos.google.cloud.metastore.v1.IBackup + >, + ): Promise< + [ + protos.google.cloud.metastore.v1.IBackup[], + protos.google.cloud.metastore.v1.IListBackupsRequest | null, + protos.google.cloud.metastore.v1.IListBackupsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.metastore.v1.IListBackupsRequest, - protos.google.cloud.metastore.v1.IListBackupsResponse|null|undefined, - protos.google.cloud.metastore.v1.IBackup>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.metastore.v1.IListBackupsRequest, + | protos.google.cloud.metastore.v1.IListBackupsResponse + | null + | undefined, + protos.google.cloud.metastore.v1.IBackup + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listBackups values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2918,171 +4026,175 @@ export class DataprocMetastoreClient { this._log.info('listBackups request %j', request); return this.innerApiCalls .listBackups(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.metastore.v1.IBackup[], - protos.google.cloud.metastore.v1.IListBackupsRequest|null, - protos.google.cloud.metastore.v1.IListBackupsResponse - ]) => { - this._log.info('listBackups values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.metastore.v1.IBackup[], + protos.google.cloud.metastore.v1.IListBackupsRequest | null, + protos.google.cloud.metastore.v1.IListBackupsResponse, + ]) => { + this._log.info('listBackups values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listBackups`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the service whose backups to - * list, in the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}/backups`. - * @param {number} [request.pageSize] - * Optional. The maximum number of backups to return. The response may contain - * less than the maximum number. If unspecified, no more than 500 backups are - * returned. The maximum value is 1000; values above 1000 are changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.metastore.v1.Backup|Backup} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listBackupsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listBackups`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the service whose backups to + * list, in the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}/backups`. + * @param {number} [request.pageSize] + * Optional. The maximum number of backups to return. The response may contain + * less than the maximum number. If unspecified, no more than 500 backups are + * returned. The maximum value is 1000; values above 1000 are changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.metastore.v1.Backup|Backup} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listBackupsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listBackupsStream( - request?: protos.google.cloud.metastore.v1.IListBackupsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.metastore.v1.IListBackupsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listBackups']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listBackups stream %j', request); return this.descriptors.page.listBackups.createStream( this.innerApiCalls.listBackups as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listBackups`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the service whose backups to - * list, in the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}/backups`. - * @param {number} [request.pageSize] - * Optional. The maximum number of backups to return. The response may contain - * less than the maximum number. If unspecified, no more than 500 backups are - * returned. The maximum value is 1000; values above 1000 are changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.metastore.v1.Backup|Backup}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/dataproc_metastore.list_backups.js - * region_tag:metastore_v1_generated_DataprocMetastore_ListBackups_async - */ + /** + * Equivalent to `listBackups`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the service whose backups to + * list, in the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}/backups`. + * @param {number} [request.pageSize] + * Optional. The maximum number of backups to return. The response may contain + * less than the maximum number. If unspecified, no more than 500 backups are + * returned. The maximum value is 1000; values above 1000 are changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * {@link protos.google.cloud.metastore.v1.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.metastore.v1.Backup|Backup}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/dataproc_metastore.list_backups.js + * region_tag:metastore_v1_generated_DataprocMetastore_ListBackups_async + */ listBackupsAsync( - request?: protos.google.cloud.metastore.v1.IListBackupsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.metastore.v1.IListBackupsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listBackups']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listBackups iterate %j', request); return this.descriptors.page.listBackups.asyncIterate( this.innerApiCalls['listBackups'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -3096,40 +4208,40 @@ export class DataprocMetastoreClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -3143,41 +4255,41 @@ export class DataprocMetastoreClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -3191,12 +4303,12 @@ export class DataprocMetastoreClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -3231,12 +4343,11 @@ export class DataprocMetastoreClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -3269,12 +4380,12 @@ export class DataprocMetastoreClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -3317,22 +4428,22 @@ export class DataprocMetastoreClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -3367,15 +4478,15 @@ export class DataprocMetastoreClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - 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 ?? '', - }); + 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 ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -3409,7 +4520,7 @@ export class DataprocMetastoreClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -3422,25 +4533,24 @@ export class DataprocMetastoreClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -3479,22 +4589,22 @@ export class DataprocMetastoreClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -3511,7 +4621,12 @@ export class DataprocMetastoreClient { * @param {string} backup * @returns {string} Resource name string. */ - backupPath(project:string,location:string,service:string,backup:string) { + backupPath( + project: string, + location: string, + service: string, + backup: string, + ) { return this.pathTemplates.backupPathTemplate.render({ project: project, location: location, @@ -3572,7 +4687,7 @@ export class DataprocMetastoreClient { * @param {string} federation * @returns {string} Resource name string. */ - federationPath(project:string,location:string,federation:string) { + federationPath(project: string, location: string, federation: string) { return this.pathTemplates.federationPathTemplate.render({ project: project, location: location, @@ -3588,7 +4703,8 @@ export class DataprocMetastoreClient { * @returns {string} A string representing the project. */ matchProjectFromFederationName(federationName: string) { - return this.pathTemplates.federationPathTemplate.match(federationName).project; + return this.pathTemplates.federationPathTemplate.match(federationName) + .project; } /** @@ -3599,7 +4715,8 @@ export class DataprocMetastoreClient { * @returns {string} A string representing the location. */ matchLocationFromFederationName(federationName: string) { - return this.pathTemplates.federationPathTemplate.match(federationName).location; + return this.pathTemplates.federationPathTemplate.match(federationName) + .location; } /** @@ -3610,7 +4727,8 @@ export class DataprocMetastoreClient { * @returns {string} A string representing the federation. */ matchFederationFromFederationName(federationName: string) { - return this.pathTemplates.federationPathTemplate.match(federationName).federation; + return this.pathTemplates.federationPathTemplate.match(federationName) + .federation; } /** @@ -3620,7 +4738,7 @@ export class DataprocMetastoreClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -3658,7 +4776,12 @@ export class DataprocMetastoreClient { * @param {string} metadata_import * @returns {string} Resource name string. */ - metadataImportPath(project:string,location:string,service:string,metadataImport:string) { + metadataImportPath( + project: string, + location: string, + service: string, + metadataImport: string, + ) { return this.pathTemplates.metadataImportPathTemplate.render({ project: project, location: location, @@ -3675,7 +4798,9 @@ export class DataprocMetastoreClient { * @returns {string} A string representing the project. */ matchProjectFromMetadataImportName(metadataImportName: string) { - return this.pathTemplates.metadataImportPathTemplate.match(metadataImportName).project; + return this.pathTemplates.metadataImportPathTemplate.match( + metadataImportName, + ).project; } /** @@ -3686,7 +4811,9 @@ export class DataprocMetastoreClient { * @returns {string} A string representing the location. */ matchLocationFromMetadataImportName(metadataImportName: string) { - return this.pathTemplates.metadataImportPathTemplate.match(metadataImportName).location; + return this.pathTemplates.metadataImportPathTemplate.match( + metadataImportName, + ).location; } /** @@ -3697,7 +4824,9 @@ export class DataprocMetastoreClient { * @returns {string} A string representing the service. */ matchServiceFromMetadataImportName(metadataImportName: string) { - return this.pathTemplates.metadataImportPathTemplate.match(metadataImportName).service; + return this.pathTemplates.metadataImportPathTemplate.match( + metadataImportName, + ).service; } /** @@ -3708,7 +4837,9 @@ export class DataprocMetastoreClient { * @returns {string} A string representing the metadata_import. */ matchMetadataImportFromMetadataImportName(metadataImportName: string) { - return this.pathTemplates.metadataImportPathTemplate.match(metadataImportName).metadata_import; + return this.pathTemplates.metadataImportPathTemplate.match( + metadataImportName, + ).metadata_import; } /** @@ -3718,7 +4849,7 @@ export class DataprocMetastoreClient { * @param {string} network * @returns {string} Resource name string. */ - networkPath(project:string,network:string) { + networkPath(project: string, network: string) { return this.pathTemplates.networkPathTemplate.render({ project: project, network: network, @@ -3753,7 +4884,7 @@ export class DataprocMetastoreClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -3778,7 +4909,7 @@ export class DataprocMetastoreClient { * @param {string} service * @returns {string} Resource name string. */ - servicePath(project:string,location:string,service:string) { + servicePath(project: string, location: string, service: string) { return this.pathTemplates.servicePathTemplate.render({ project: project, location: location, @@ -3827,15 +4958,19 @@ export class DataprocMetastoreClient { */ close(): Promise { if (this.dataprocMetastoreStub && !this._terminated) { - return this.dataprocMetastoreStub.then(stub => { + return this.dataprocMetastoreStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-metastore/src/v1/dataproc_metastore_federation_client.ts b/packages/google-cloud-metastore/src/v1/dataproc_metastore_federation_client.ts index b293a843163a..8a756915d68c 100644 --- a/packages/google-cloud-metastore/src/v1/dataproc_metastore_federation_client.ts +++ b/packages/google-cloud-metastore/src/v1/dataproc_metastore_federation_client.ts @@ -18,11 +18,24 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -56,7 +69,7 @@ export class DataprocMetastoreFederationClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('dataproc-metastore'); @@ -69,12 +82,12 @@ export class DataprocMetastoreFederationClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - dataprocMetastoreFederationStub?: Promise<{[name: string]: Function}>; + dataprocMetastoreFederationStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of DataprocMetastoreFederationClient. @@ -115,21 +128,43 @@ export class DataprocMetastoreFederationClient { * const client = new DataprocMetastoreFederationClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof DataprocMetastoreFederationClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + const staticMembers = this + .constructor as typeof DataprocMetastoreFederationClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'metastore.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -154,7 +189,7 @@ export class DataprocMetastoreFederationClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -167,18 +202,14 @@ export class DataprocMetastoreFederationClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -200,22 +231,22 @@ export class DataprocMetastoreFederationClient { // Create useful helper objects for these. this.pathTemplates = { backupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}/backups/{backup}' + 'projects/{project}/locations/{location}/services/{service}/backups/{backup}', ), federationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/federations/{federation}' + 'projects/{project}/locations/{location}/federations/{federation}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), metadataImportPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}/metadataImports/{metadata_import}' + 'projects/{project}/locations/{location}/services/{service}/metadataImports/{metadata_import}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), servicePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}' + 'projects/{project}/locations/{location}/services/{service}', ), }; @@ -223,8 +254,11 @@ export class DataprocMetastoreFederationClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listFederations: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'federations') + listFederations: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'federations', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -233,48 +267,123 @@ export class DataprocMetastoreFederationClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1/{resource=projects/*/locations/*/services/*}:getIamPolicy',additional_bindings: [{get: '/v1/{resource=projects/*/locations/*/services/*/backups/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/federations/*}:getIamPolicy',}], - },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1/{resource=projects/*/locations/*/services/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/services/*/backups/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/federations/*}:setIamPolicy',body: '*',}], - },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1/{resource=projects/*/locations/*/services/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/federations/*}:testIamPermissions',body: '*',}], - },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1/{resource=projects/*/locations/*/services/*}:getIamPolicy', + additional_bindings: [ + { + get: '/v1/{resource=projects/*/locations/*/services/*/backups/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/federations/*}:getIamPolicy', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1/{resource=projects/*/locations/*/services/*}:setIamPolicy', + body: '*', + additional_bindings: [ + { + post: '/v1/{resource=projects/*/locations/*/services/*/backups/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/federations/*}:setIamPolicy', + body: '*', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1/{resource=projects/*/locations/*/services/*}:testIamPermissions', + body: '*', + additional_bindings: [ + { + post: '/v1/{resource=projects/*/locations/*/federations/*}:testIamPermissions', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createFederationResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1.Federation') as gax.protobuf.Type; + '.google.cloud.metastore.v1.Federation', + ) as gax.protobuf.Type; const createFederationMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateFederationResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1.Federation') as gax.protobuf.Type; + '.google.cloud.metastore.v1.Federation', + ) as gax.protobuf.Type; const updateFederationMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteFederationResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteFederationMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createFederation: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createFederationResponse.decode.bind(createFederationResponse), - createFederationMetadata.decode.bind(createFederationMetadata)), + createFederationMetadata.decode.bind(createFederationMetadata), + ), updateFederation: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateFederationResponse.decode.bind(updateFederationResponse), - updateFederationMetadata.decode.bind(updateFederationMetadata)), + updateFederationMetadata.decode.bind(updateFederationMetadata), + ), deleteFederation: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteFederationResponse.decode.bind(deleteFederationResponse), - deleteFederationMetadata.decode.bind(deleteFederationMetadata)) + deleteFederationMetadata.decode.bind(deleteFederationMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.metastore.v1.DataprocMetastoreFederation', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.metastore.v1.DataprocMetastoreFederation', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -305,28 +414,40 @@ export class DataprocMetastoreFederationClient { // Put together the "service stub" for // google.cloud.metastore.v1.DataprocMetastoreFederation. this.dataprocMetastoreFederationStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.metastore.v1.DataprocMetastoreFederation') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.metastore.v1.DataprocMetastoreFederation, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.metastore.v1.DataprocMetastoreFederation', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.metastore.v1 + .DataprocMetastoreFederation, + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const dataprocMetastoreFederationStubMethods = - ['listFederations', 'getFederation', 'createFederation', 'updateFederation', 'deleteFederation']; + const dataprocMetastoreFederationStubMethods = [ + 'listFederations', + 'getFederation', + 'createFederation', + 'updateFederation', + 'deleteFederation', + ]; for (const methodName of dataprocMetastoreFederationStubMethods) { const callPromise = this.dataprocMetastoreFederationStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -336,7 +457,7 @@ export class DataprocMetastoreFederationClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -351,8 +472,14 @@ export class DataprocMetastoreFederationClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'metastore.googleapis.com'; } @@ -363,8 +490,14 @@ export class DataprocMetastoreFederationClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'metastore.googleapis.com'; } @@ -395,9 +528,7 @@ export class DataprocMetastoreFederationClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -406,8 +537,9 @@ export class DataprocMetastoreFederationClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -418,589 +550,834 @@ export class DataprocMetastoreFederationClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets the details of a single federation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The relative resource name of the metastore federation to - * retrieve, in the following form: - * - * `projects/{project_number}/locations/{location_id}/federations/{federation_id}`. - * @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 {@link protos.google.cloud.metastore.v1.Federation|Federation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/dataproc_metastore_federation.get_federation.js - * region_tag:metastore_v1_generated_DataprocMetastoreFederation_GetFederation_async - */ + /** + * Gets the details of a single federation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The relative resource name of the metastore federation to + * retrieve, in the following form: + * + * `projects/{project_number}/locations/{location_id}/federations/{federation_id}`. + * @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 {@link protos.google.cloud.metastore.v1.Federation|Federation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/dataproc_metastore_federation.get_federation.js + * region_tag:metastore_v1_generated_DataprocMetastoreFederation_GetFederation_async + */ getFederation( - request?: protos.google.cloud.metastore.v1.IGetFederationRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.metastore.v1.IFederation, - protos.google.cloud.metastore.v1.IGetFederationRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1.IGetFederationRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.metastore.v1.IFederation, + protos.google.cloud.metastore.v1.IGetFederationRequest | undefined, + {} | undefined, + ] + >; getFederation( - request: protos.google.cloud.metastore.v1.IGetFederationRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.metastore.v1.IFederation, - protos.google.cloud.metastore.v1.IGetFederationRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.IGetFederationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.metastore.v1.IFederation, + protos.google.cloud.metastore.v1.IGetFederationRequest | null | undefined, + {} | null | undefined + >, + ): void; getFederation( - request: protos.google.cloud.metastore.v1.IGetFederationRequest, - callback: Callback< - protos.google.cloud.metastore.v1.IFederation, - protos.google.cloud.metastore.v1.IGetFederationRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.IGetFederationRequest, + callback: Callback< + protos.google.cloud.metastore.v1.IFederation, + protos.google.cloud.metastore.v1.IGetFederationRequest | null | undefined, + {} | null | undefined + >, + ): void; getFederation( - request?: protos.google.cloud.metastore.v1.IGetFederationRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.metastore.v1.IFederation, - protos.google.cloud.metastore.v1.IGetFederationRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.metastore.v1.IGetFederationRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.metastore.v1.IFederation, - protos.google.cloud.metastore.v1.IGetFederationRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.metastore.v1.IFederation, - protos.google.cloud.metastore.v1.IGetFederationRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.metastore.v1.IGetFederationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.metastore.v1.IFederation, + protos.google.cloud.metastore.v1.IGetFederationRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.metastore.v1.IFederation, + protos.google.cloud.metastore.v1.IGetFederationRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getFederation request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.metastore.v1.IFederation, - protos.google.cloud.metastore.v1.IGetFederationRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.metastore.v1.IFederation, + | protos.google.cloud.metastore.v1.IGetFederationRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getFederation response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getFederation(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.metastore.v1.IFederation, - protos.google.cloud.metastore.v1.IGetFederationRequest|undefined, - {}|undefined - ]) => { - this._log.info('getFederation response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getFederation(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.metastore.v1.IFederation, + protos.google.cloud.metastore.v1.IGetFederationRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getFederation response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a metastore federation in a project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the location in which to create a - * federation service, in the following form: - * - * `projects/{project_number}/locations/{location_id}`. - * @param {string} request.federationId - * Required. The ID of the metastore federation, which is used as the final - * component of the metastore federation's name. - * - * This value must be between 2 and 63 characters long inclusive, begin with a - * letter, end with a letter or number, and consist of alpha-numeric - * ASCII characters or hyphens. - * @param {google.cloud.metastore.v1.Federation} request.federation - * Required. The Metastore Federation to create. The `name` field is - * ignored. The ID of the created metastore federation must be - * provided in the request's `federation_id` field. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/dataproc_metastore_federation.create_federation.js - * region_tag:metastore_v1_generated_DataprocMetastoreFederation_CreateFederation_async - */ + /** + * Creates a metastore federation in a project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the location in which to create a + * federation service, in the following form: + * + * `projects/{project_number}/locations/{location_id}`. + * @param {string} request.federationId + * Required. The ID of the metastore federation, which is used as the final + * component of the metastore federation's name. + * + * This value must be between 2 and 63 characters long inclusive, begin with a + * letter, end with a letter or number, and consist of alpha-numeric + * ASCII characters or hyphens. + * @param {google.cloud.metastore.v1.Federation} request.federation + * Required. The Metastore Federation to create. The `name` field is + * ignored. The ID of the created metastore federation must be + * provided in the request's `federation_id` field. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/dataproc_metastore_federation.create_federation.js + * region_tag:metastore_v1_generated_DataprocMetastoreFederation_CreateFederation_async + */ createFederation( - request?: protos.google.cloud.metastore.v1.ICreateFederationRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1.ICreateFederationRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1.IFederation, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createFederation( - request: protos.google.cloud.metastore.v1.ICreateFederationRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.ICreateFederationRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1.IFederation, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createFederation( - request: protos.google.cloud.metastore.v1.ICreateFederationRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.ICreateFederationRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1.IFederation, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createFederation( - request?: protos.google.cloud.metastore.v1.ICreateFederationRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1.ICreateFederationRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1.IFederation, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1.IFederation, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1.IFederation, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1.IFederation, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createFederation response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createFederation request %j', request); - return this.innerApiCalls.createFederation(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createFederation response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createFederation(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1.IFederation, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createFederation response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createFederation()`. - * @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/dataproc_metastore_federation.create_federation.js - * region_tag:metastore_v1_generated_DataprocMetastoreFederation_CreateFederation_async - */ - async checkCreateFederationProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createFederation()`. + * @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/dataproc_metastore_federation.create_federation.js + * region_tag:metastore_v1_generated_DataprocMetastoreFederation_CreateFederation_async + */ + async checkCreateFederationProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1.Federation, + protos.google.cloud.metastore.v1.OperationMetadata + > + > { this._log.info('createFederation long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createFederation, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createFederation, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1.Federation, + protos.google.cloud.metastore.v1.OperationMetadata + >; } -/** - * Updates the fields of a federation. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. A field mask used to specify the fields to be overwritten in the - * metastore federation resource by the update. - * Fields specified in the `update_mask` are relative to the resource (not - * to the full request). A field is overwritten if it is in the mask. - * @param {google.cloud.metastore.v1.Federation} request.federation - * Required. The metastore federation to update. The server only merges fields - * in the service if they are specified in `update_mask`. - * - * The metastore federation's `name` field is used to identify the - * metastore service to be updated. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/dataproc_metastore_federation.update_federation.js - * region_tag:metastore_v1_generated_DataprocMetastoreFederation_UpdateFederation_async - */ + /** + * Updates the fields of a federation. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. A field mask used to specify the fields to be overwritten in the + * metastore federation resource by the update. + * Fields specified in the `update_mask` are relative to the resource (not + * to the full request). A field is overwritten if it is in the mask. + * @param {google.cloud.metastore.v1.Federation} request.federation + * Required. The metastore federation to update. The server only merges fields + * in the service if they are specified in `update_mask`. + * + * The metastore federation's `name` field is used to identify the + * metastore service to be updated. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/dataproc_metastore_federation.update_federation.js + * region_tag:metastore_v1_generated_DataprocMetastoreFederation_UpdateFederation_async + */ updateFederation( - request?: protos.google.cloud.metastore.v1.IUpdateFederationRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1.IUpdateFederationRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1.IFederation, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateFederation( - request: protos.google.cloud.metastore.v1.IUpdateFederationRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.IUpdateFederationRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1.IFederation, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateFederation( - request: protos.google.cloud.metastore.v1.IUpdateFederationRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.IUpdateFederationRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1.IFederation, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateFederation( - request?: protos.google.cloud.metastore.v1.IUpdateFederationRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1.IUpdateFederationRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1.IFederation, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1.IFederation, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1.IFederation, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'federation.name': request.federation!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'federation.name': request.federation!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1.IFederation, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateFederation response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateFederation request %j', request); - return this.innerApiCalls.updateFederation(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateFederation response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateFederation(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1.IFederation, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateFederation response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateFederation()`. - * @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/dataproc_metastore_federation.update_federation.js - * region_tag:metastore_v1_generated_DataprocMetastoreFederation_UpdateFederation_async - */ - async checkUpdateFederationProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateFederation()`. + * @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/dataproc_metastore_federation.update_federation.js + * region_tag:metastore_v1_generated_DataprocMetastoreFederation_UpdateFederation_async + */ + async checkUpdateFederationProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1.Federation, + protos.google.cloud.metastore.v1.OperationMetadata + > + > { this._log.info('updateFederation long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateFederation, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateFederation, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1.Federation, + protos.google.cloud.metastore.v1.OperationMetadata + >; } -/** - * Deletes a single federation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The relative resource name of the metastore federation to delete, - * in the following form: - * - * `projects/{project_number}/locations/{location_id}/federations/{federation_id}`. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/dataproc_metastore_federation.delete_federation.js - * region_tag:metastore_v1_generated_DataprocMetastoreFederation_DeleteFederation_async - */ + /** + * Deletes a single federation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The relative resource name of the metastore federation to delete, + * in the following form: + * + * `projects/{project_number}/locations/{location_id}/federations/{federation_id}`. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/dataproc_metastore_federation.delete_federation.js + * region_tag:metastore_v1_generated_DataprocMetastoreFederation_DeleteFederation_async + */ deleteFederation( - request?: protos.google.cloud.metastore.v1.IDeleteFederationRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1.IDeleteFederationRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteFederation( - request: protos.google.cloud.metastore.v1.IDeleteFederationRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.IDeleteFederationRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteFederation( - request: protos.google.cloud.metastore.v1.IDeleteFederationRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1.IDeleteFederationRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteFederation( - request?: protos.google.cloud.metastore.v1.IDeleteFederationRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1.IDeleteFederationRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteFederation response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteFederation request %j', request); - return this.innerApiCalls.deleteFederation(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteFederation response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteFederation(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteFederation response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteFederation()`. - * @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/dataproc_metastore_federation.delete_federation.js - * region_tag:metastore_v1_generated_DataprocMetastoreFederation_DeleteFederation_async - */ - async checkDeleteFederationProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteFederation()`. + * @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/dataproc_metastore_federation.delete_federation.js + * region_tag:metastore_v1_generated_DataprocMetastoreFederation_DeleteFederation_async + */ + async checkDeleteFederationProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.metastore.v1.OperationMetadata + > + > { this._log.info('deleteFederation long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteFederation, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteFederation, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.metastore.v1.OperationMetadata + >; } - /** - * Lists federations in a project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the location of metastore - * federations to list, in the following form: - * `projects/{project_number}/locations/{location_id}`. - * @param {number} [request.pageSize] - * Optional. The maximum number of federations to return. The response may - * contain less than the maximum number. If unspecified, no more than 500 - * services are returned. The maximum value is 1000; values above 1000 are - * changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous ListFederationServices - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * ListFederationServices must match the call that provided the - * page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @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 Array of {@link protos.google.cloud.metastore.v1.Federation|Federation}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listFederationsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists federations in a project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the location of metastore + * federations to list, in the following form: + * `projects/{project_number}/locations/{location_id}`. + * @param {number} [request.pageSize] + * Optional. The maximum number of federations to return. The response may + * contain less than the maximum number. If unspecified, no more than 500 + * services are returned. The maximum value is 1000; values above 1000 are + * changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous ListFederationServices + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * ListFederationServices must match the call that provided the + * page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @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 Array of {@link protos.google.cloud.metastore.v1.Federation|Federation}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listFederationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listFederations( - request?: protos.google.cloud.metastore.v1.IListFederationsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.metastore.v1.IFederation[], - protos.google.cloud.metastore.v1.IListFederationsRequest|null, - protos.google.cloud.metastore.v1.IListFederationsResponse - ]>; + request?: protos.google.cloud.metastore.v1.IListFederationsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.metastore.v1.IFederation[], + protos.google.cloud.metastore.v1.IListFederationsRequest | null, + protos.google.cloud.metastore.v1.IListFederationsResponse, + ] + >; listFederations( - request: protos.google.cloud.metastore.v1.IListFederationsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.metastore.v1.IListFederationsRequest, - protos.google.cloud.metastore.v1.IListFederationsResponse|null|undefined, - protos.google.cloud.metastore.v1.IFederation>): void; + request: protos.google.cloud.metastore.v1.IListFederationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.metastore.v1.IListFederationsRequest, + | protos.google.cloud.metastore.v1.IListFederationsResponse + | null + | undefined, + protos.google.cloud.metastore.v1.IFederation + >, + ): void; listFederations( - request: protos.google.cloud.metastore.v1.IListFederationsRequest, - callback: PaginationCallback< - protos.google.cloud.metastore.v1.IListFederationsRequest, - protos.google.cloud.metastore.v1.IListFederationsResponse|null|undefined, - protos.google.cloud.metastore.v1.IFederation>): void; + request: protos.google.cloud.metastore.v1.IListFederationsRequest, + callback: PaginationCallback< + protos.google.cloud.metastore.v1.IListFederationsRequest, + | protos.google.cloud.metastore.v1.IListFederationsResponse + | null + | undefined, + protos.google.cloud.metastore.v1.IFederation + >, + ): void; listFederations( - request?: protos.google.cloud.metastore.v1.IListFederationsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.metastore.v1.IListFederationsRequest, - protos.google.cloud.metastore.v1.IListFederationsResponse|null|undefined, - protos.google.cloud.metastore.v1.IFederation>, - callback?: PaginationCallback< + request?: protos.google.cloud.metastore.v1.IListFederationsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.metastore.v1.IListFederationsRequest, - protos.google.cloud.metastore.v1.IListFederationsResponse|null|undefined, - protos.google.cloud.metastore.v1.IFederation>): - Promise<[ - protos.google.cloud.metastore.v1.IFederation[], - protos.google.cloud.metastore.v1.IListFederationsRequest|null, - protos.google.cloud.metastore.v1.IListFederationsResponse - ]>|void { + | protos.google.cloud.metastore.v1.IListFederationsResponse + | null + | undefined, + protos.google.cloud.metastore.v1.IFederation + >, + callback?: PaginationCallback< + protos.google.cloud.metastore.v1.IListFederationsRequest, + | protos.google.cloud.metastore.v1.IListFederationsResponse + | null + | undefined, + protos.google.cloud.metastore.v1.IFederation + >, + ): Promise< + [ + protos.google.cloud.metastore.v1.IFederation[], + protos.google.cloud.metastore.v1.IListFederationsRequest | null, + protos.google.cloud.metastore.v1.IListFederationsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.metastore.v1.IListFederationsRequest, - protos.google.cloud.metastore.v1.IListFederationsResponse|null|undefined, - protos.google.cloud.metastore.v1.IFederation>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.metastore.v1.IListFederationsRequest, + | protos.google.cloud.metastore.v1.IListFederationsResponse + | null + | undefined, + protos.google.cloud.metastore.v1.IFederation + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listFederations values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1009,169 +1386,173 @@ export class DataprocMetastoreFederationClient { this._log.info('listFederations request %j', request); return this.innerApiCalls .listFederations(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.metastore.v1.IFederation[], - protos.google.cloud.metastore.v1.IListFederationsRequest|null, - protos.google.cloud.metastore.v1.IListFederationsResponse - ]) => { - this._log.info('listFederations values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.metastore.v1.IFederation[], + protos.google.cloud.metastore.v1.IListFederationsRequest | null, + protos.google.cloud.metastore.v1.IListFederationsResponse, + ]) => { + this._log.info('listFederations values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listFederations`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the location of metastore - * federations to list, in the following form: - * `projects/{project_number}/locations/{location_id}`. - * @param {number} [request.pageSize] - * Optional. The maximum number of federations to return. The response may - * contain less than the maximum number. If unspecified, no more than 500 - * services are returned. The maximum value is 1000; values above 1000 are - * changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous ListFederationServices - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * ListFederationServices must match the call that provided the - * page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.metastore.v1.Federation|Federation} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listFederationsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listFederations`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the location of metastore + * federations to list, in the following form: + * `projects/{project_number}/locations/{location_id}`. + * @param {number} [request.pageSize] + * Optional. The maximum number of federations to return. The response may + * contain less than the maximum number. If unspecified, no more than 500 + * services are returned. The maximum value is 1000; values above 1000 are + * changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous ListFederationServices + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * ListFederationServices must match the call that provided the + * page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.metastore.v1.Federation|Federation} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listFederationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listFederationsStream( - request?: protos.google.cloud.metastore.v1.IListFederationsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.metastore.v1.IListFederationsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listFederations']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listFederations stream %j', request); return this.descriptors.page.listFederations.createStream( this.innerApiCalls.listFederations as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listFederations`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the location of metastore - * federations to list, in the following form: - * `projects/{project_number}/locations/{location_id}`. - * @param {number} [request.pageSize] - * Optional. The maximum number of federations to return. The response may - * contain less than the maximum number. If unspecified, no more than 500 - * services are returned. The maximum value is 1000; values above 1000 are - * changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous ListFederationServices - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * ListFederationServices must match the call that provided the - * page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.metastore.v1.Federation|Federation}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/dataproc_metastore_federation.list_federations.js - * region_tag:metastore_v1_generated_DataprocMetastoreFederation_ListFederations_async - */ + /** + * Equivalent to `listFederations`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the location of metastore + * federations to list, in the following form: + * `projects/{project_number}/locations/{location_id}`. + * @param {number} [request.pageSize] + * Optional. The maximum number of federations to return. The response may + * contain less than the maximum number. If unspecified, no more than 500 + * services are returned. The maximum value is 1000; values above 1000 are + * changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous ListFederationServices + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * ListFederationServices must match the call that provided the + * page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.metastore.v1.Federation|Federation}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/dataproc_metastore_federation.list_federations.js + * region_tag:metastore_v1_generated_DataprocMetastoreFederation_ListFederations_async + */ listFederationsAsync( - request?: protos.google.cloud.metastore.v1.IListFederationsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.metastore.v1.IListFederationsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listFederations']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listFederations iterate %j', request); return this.descriptors.page.listFederations.asyncIterate( this.innerApiCalls['listFederations'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -1185,40 +1566,40 @@ export class DataprocMetastoreFederationClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -1232,41 +1613,41 @@ export class DataprocMetastoreFederationClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -1280,12 +1661,12 @@ export class DataprocMetastoreFederationClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -1320,12 +1701,11 @@ export class DataprocMetastoreFederationClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -1358,12 +1738,12 @@ export class DataprocMetastoreFederationClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -1406,22 +1786,22 @@ export class DataprocMetastoreFederationClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -1456,15 +1836,15 @@ export class DataprocMetastoreFederationClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - 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 ?? '', - }); + 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 ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -1498,7 +1878,7 @@ export class DataprocMetastoreFederationClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -1511,25 +1891,24 @@ export class DataprocMetastoreFederationClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -1568,22 +1947,22 @@ export class DataprocMetastoreFederationClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -1600,7 +1979,12 @@ export class DataprocMetastoreFederationClient { * @param {string} backup * @returns {string} Resource name string. */ - backupPath(project:string,location:string,service:string,backup:string) { + backupPath( + project: string, + location: string, + service: string, + backup: string, + ) { return this.pathTemplates.backupPathTemplate.render({ project: project, location: location, @@ -1661,7 +2045,7 @@ export class DataprocMetastoreFederationClient { * @param {string} federation * @returns {string} Resource name string. */ - federationPath(project:string,location:string,federation:string) { + federationPath(project: string, location: string, federation: string) { return this.pathTemplates.federationPathTemplate.render({ project: project, location: location, @@ -1677,7 +2061,8 @@ export class DataprocMetastoreFederationClient { * @returns {string} A string representing the project. */ matchProjectFromFederationName(federationName: string) { - return this.pathTemplates.federationPathTemplate.match(federationName).project; + return this.pathTemplates.federationPathTemplate.match(federationName) + .project; } /** @@ -1688,7 +2073,8 @@ export class DataprocMetastoreFederationClient { * @returns {string} A string representing the location. */ matchLocationFromFederationName(federationName: string) { - return this.pathTemplates.federationPathTemplate.match(federationName).location; + return this.pathTemplates.federationPathTemplate.match(federationName) + .location; } /** @@ -1699,7 +2085,8 @@ export class DataprocMetastoreFederationClient { * @returns {string} A string representing the federation. */ matchFederationFromFederationName(federationName: string) { - return this.pathTemplates.federationPathTemplate.match(federationName).federation; + return this.pathTemplates.federationPathTemplate.match(federationName) + .federation; } /** @@ -1709,7 +2096,7 @@ export class DataprocMetastoreFederationClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -1747,7 +2134,12 @@ export class DataprocMetastoreFederationClient { * @param {string} metadata_import * @returns {string} Resource name string. */ - metadataImportPath(project:string,location:string,service:string,metadataImport:string) { + metadataImportPath( + project: string, + location: string, + service: string, + metadataImport: string, + ) { return this.pathTemplates.metadataImportPathTemplate.render({ project: project, location: location, @@ -1764,7 +2156,9 @@ export class DataprocMetastoreFederationClient { * @returns {string} A string representing the project. */ matchProjectFromMetadataImportName(metadataImportName: string) { - return this.pathTemplates.metadataImportPathTemplate.match(metadataImportName).project; + return this.pathTemplates.metadataImportPathTemplate.match( + metadataImportName, + ).project; } /** @@ -1775,7 +2169,9 @@ export class DataprocMetastoreFederationClient { * @returns {string} A string representing the location. */ matchLocationFromMetadataImportName(metadataImportName: string) { - return this.pathTemplates.metadataImportPathTemplate.match(metadataImportName).location; + return this.pathTemplates.metadataImportPathTemplate.match( + metadataImportName, + ).location; } /** @@ -1786,7 +2182,9 @@ export class DataprocMetastoreFederationClient { * @returns {string} A string representing the service. */ matchServiceFromMetadataImportName(metadataImportName: string) { - return this.pathTemplates.metadataImportPathTemplate.match(metadataImportName).service; + return this.pathTemplates.metadataImportPathTemplate.match( + metadataImportName, + ).service; } /** @@ -1797,7 +2195,9 @@ export class DataprocMetastoreFederationClient { * @returns {string} A string representing the metadata_import. */ matchMetadataImportFromMetadataImportName(metadataImportName: string) { - return this.pathTemplates.metadataImportPathTemplate.match(metadataImportName).metadata_import; + return this.pathTemplates.metadataImportPathTemplate.match( + metadataImportName, + ).metadata_import; } /** @@ -1806,7 +2206,7 @@ export class DataprocMetastoreFederationClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -1831,7 +2231,7 @@ export class DataprocMetastoreFederationClient { * @param {string} service * @returns {string} Resource name string. */ - servicePath(project:string,location:string,service:string) { + servicePath(project: string, location: string, service: string) { return this.pathTemplates.servicePathTemplate.render({ project: project, location: location, @@ -1880,15 +2280,19 @@ export class DataprocMetastoreFederationClient { */ close(): Promise { if (this.dataprocMetastoreFederationStub && !this._terminated) { - return this.dataprocMetastoreFederationStub.then(stub => { + return this.dataprocMetastoreFederationStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-metastore/src/v1/index.ts b/packages/google-cloud-metastore/src/v1/index.ts index 649f07b7cdab..a6d4bbf0896b 100644 --- a/packages/google-cloud-metastore/src/v1/index.ts +++ b/packages/google-cloud-metastore/src/v1/index.ts @@ -16,5 +16,5 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {DataprocMetastoreClient} from './dataproc_metastore_client'; -export {DataprocMetastoreFederationClient} from './dataproc_metastore_federation_client'; +export { DataprocMetastoreClient } from './dataproc_metastore_client'; +export { DataprocMetastoreFederationClient } from './dataproc_metastore_federation_client'; diff --git a/packages/google-cloud-metastore/src/v1alpha/dataproc_metastore_client.ts b/packages/google-cloud-metastore/src/v1alpha/dataproc_metastore_client.ts index 08bd43311530..f567657fe8a4 100644 --- a/packages/google-cloud-metastore/src/v1alpha/dataproc_metastore_client.ts +++ b/packages/google-cloud-metastore/src/v1alpha/dataproc_metastore_client.ts @@ -18,11 +18,24 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -60,7 +73,7 @@ export class DataprocMetastoreClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('dataproc-metastore'); @@ -73,12 +86,12 @@ export class DataprocMetastoreClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - dataprocMetastoreStub?: Promise<{[name: string]: Function}>; + dataprocMetastoreStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of DataprocMetastoreClient. @@ -119,21 +132,42 @@ export class DataprocMetastoreClient { * const client = new DataprocMetastoreClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof DataprocMetastoreClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'metastore.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -158,7 +192,7 @@ export class DataprocMetastoreClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -171,18 +205,14 @@ export class DataprocMetastoreClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -204,28 +234,28 @@ export class DataprocMetastoreClient { // Create useful helper objects for these. this.pathTemplates = { backupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}/backups/{backup}' + 'projects/{project}/locations/{location}/services/{service}/backups/{backup}', ), federationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/federations/{federation}' + 'projects/{project}/locations/{location}/federations/{federation}', ), lakePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/lakes/{lake}' + 'projects/{project}/locations/{location}/lakes/{lake}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), metadataImportPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}/metadataImports/{metadata_import}' + 'projects/{project}/locations/{location}/services/{service}/metadataImports/{metadata_import}', ), networkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/global/networks/{network}' + 'projects/{project}/global/networks/{network}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), servicePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}' + 'projects/{project}/locations/{location}/services/{service}', ), }; @@ -233,12 +263,21 @@ export class DataprocMetastoreClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listServices: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'services'), - listMetadataImports: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'metadataImports'), - listBackups: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'backups') + listServices: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'services', + ), + listMetadataImports: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'metadataImports', + ), + listBackups: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'backups', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -247,120 +286,252 @@ export class DataprocMetastoreClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1alpha/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1alpha/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1alpha/{resource=projects/*/locations/*/services/*}:getIamPolicy',additional_bindings: [{get: '/v1alpha/{resource=projects/*/locations/*/services/*/backups/*}:getIamPolicy',},{get: '/v1alpha/{resource=projects/*/locations/*/services/*/databases/*}:getIamPolicy',},{get: '/v1alpha/{resource=projects/*/locations/*/services/*/databases/*/tables/*}:getIamPolicy',},{get: '/v1alpha/{resource=projects/*/locations/*/federations/*}:getIamPolicy',}], - },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1alpha/{resource=projects/*/locations/*/services/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1alpha/{resource=projects/*/locations/*/services/*/backups/*}:setIamPolicy',body: '*',},{post: '/v1alpha/{resource=projects/*/locations/*/services/*/databases/*}:setIamPolicy',body: '*',},{post: '/v1alpha/{resource=projects/*/locations/*/services/*/databases/*/tables/*}:setIamPolicy',body: '*',},{post: '/v1alpha/{resource=projects/*/locations/*/federations/*}:setIamPolicy',body: '*',}], - },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1alpha/{resource=projects/*/locations/*/services/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1alpha/{resource=projects/*/locations/*/services/*/backups/*}:testIamPermissions',body: '*',},{post: '/v1alpha/{resource=projects/*/locations/*/services/*/databases/*}:testIamPermissions',body: '*',},{post: '/v1alpha/{resource=projects/*/locations/*/services/*/databases/*/tables/*}:testIamPermissions',body: '*',},{post: '/v1alpha/{resource=projects/*/locations/*/federations/*}:testIamPermissions',body: '*',}], - },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1alpha/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1alpha/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1alpha/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1alpha/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1alpha/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1alpha/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1alpha/{resource=projects/*/locations/*/services/*}:getIamPolicy', + additional_bindings: [ + { + get: '/v1alpha/{resource=projects/*/locations/*/services/*/backups/*}:getIamPolicy', + }, + { + get: '/v1alpha/{resource=projects/*/locations/*/services/*/databases/*}:getIamPolicy', + }, + { + get: '/v1alpha/{resource=projects/*/locations/*/services/*/databases/*/tables/*}:getIamPolicy', + }, + { + get: '/v1alpha/{resource=projects/*/locations/*/federations/*}:getIamPolicy', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1alpha/{resource=projects/*/locations/*/services/*}:setIamPolicy', + body: '*', + additional_bindings: [ + { + post: '/v1alpha/{resource=projects/*/locations/*/services/*/backups/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1alpha/{resource=projects/*/locations/*/services/*/databases/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1alpha/{resource=projects/*/locations/*/services/*/databases/*/tables/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1alpha/{resource=projects/*/locations/*/federations/*}:setIamPolicy', + body: '*', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1alpha/{resource=projects/*/locations/*/services/*}:testIamPermissions', + body: '*', + additional_bindings: [ + { + post: '/v1alpha/{resource=projects/*/locations/*/services/*/backups/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1alpha/{resource=projects/*/locations/*/services/*/databases/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1alpha/{resource=projects/*/locations/*/services/*/databases/*/tables/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1alpha/{resource=projects/*/locations/*/federations/*}:testIamPermissions', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1alpha/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1alpha/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1alpha/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1alpha/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createServiceResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1alpha.Service') as gax.protobuf.Type; + '.google.cloud.metastore.v1alpha.Service', + ) as gax.protobuf.Type; const createServiceMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1alpha.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1alpha.OperationMetadata', + ) as gax.protobuf.Type; const updateServiceResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1alpha.Service') as gax.protobuf.Type; + '.google.cloud.metastore.v1alpha.Service', + ) as gax.protobuf.Type; const updateServiceMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1alpha.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1alpha.OperationMetadata', + ) as gax.protobuf.Type; const deleteServiceResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteServiceMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1alpha.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1alpha.OperationMetadata', + ) as gax.protobuf.Type; const createMetadataImportResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1alpha.MetadataImport') as gax.protobuf.Type; + '.google.cloud.metastore.v1alpha.MetadataImport', + ) as gax.protobuf.Type; const createMetadataImportMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1alpha.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1alpha.OperationMetadata', + ) as gax.protobuf.Type; const updateMetadataImportResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1alpha.MetadataImport') as gax.protobuf.Type; + '.google.cloud.metastore.v1alpha.MetadataImport', + ) as gax.protobuf.Type; const updateMetadataImportMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1alpha.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1alpha.OperationMetadata', + ) as gax.protobuf.Type; const exportMetadataResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1alpha.MetadataExport') as gax.protobuf.Type; + '.google.cloud.metastore.v1alpha.MetadataExport', + ) as gax.protobuf.Type; const exportMetadataMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1alpha.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1alpha.OperationMetadata', + ) as gax.protobuf.Type; const restoreServiceResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1alpha.Restore') as gax.protobuf.Type; + '.google.cloud.metastore.v1alpha.Restore', + ) as gax.protobuf.Type; const restoreServiceMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1alpha.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1alpha.OperationMetadata', + ) as gax.protobuf.Type; const createBackupResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1alpha.Backup') as gax.protobuf.Type; + '.google.cloud.metastore.v1alpha.Backup', + ) as gax.protobuf.Type; const createBackupMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1alpha.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1alpha.OperationMetadata', + ) as gax.protobuf.Type; const deleteBackupResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteBackupMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1alpha.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1alpha.OperationMetadata', + ) as gax.protobuf.Type; const queryMetadataResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1alpha.QueryMetadataResponse') as gax.protobuf.Type; + '.google.cloud.metastore.v1alpha.QueryMetadataResponse', + ) as gax.protobuf.Type; const queryMetadataMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1alpha.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1alpha.OperationMetadata', + ) as gax.protobuf.Type; const moveTableToDatabaseResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1alpha.MoveTableToDatabaseResponse') as gax.protobuf.Type; + '.google.cloud.metastore.v1alpha.MoveTableToDatabaseResponse', + ) as gax.protobuf.Type; const moveTableToDatabaseMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1alpha.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1alpha.OperationMetadata', + ) as gax.protobuf.Type; const alterMetadataResourceLocationResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1alpha.AlterMetadataResourceLocationResponse') as gax.protobuf.Type; + '.google.cloud.metastore.v1alpha.AlterMetadataResourceLocationResponse', + ) as gax.protobuf.Type; const alterMetadataResourceLocationMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1alpha.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1alpha.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createService: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createServiceResponse.decode.bind(createServiceResponse), - createServiceMetadata.decode.bind(createServiceMetadata)), + createServiceMetadata.decode.bind(createServiceMetadata), + ), updateService: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateServiceResponse.decode.bind(updateServiceResponse), - updateServiceMetadata.decode.bind(updateServiceMetadata)), + updateServiceMetadata.decode.bind(updateServiceMetadata), + ), deleteService: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteServiceResponse.decode.bind(deleteServiceResponse), - deleteServiceMetadata.decode.bind(deleteServiceMetadata)), + deleteServiceMetadata.decode.bind(deleteServiceMetadata), + ), createMetadataImport: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createMetadataImportResponse.decode.bind(createMetadataImportResponse), - createMetadataImportMetadata.decode.bind(createMetadataImportMetadata)), + createMetadataImportMetadata.decode.bind(createMetadataImportMetadata), + ), updateMetadataImport: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateMetadataImportResponse.decode.bind(updateMetadataImportResponse), - updateMetadataImportMetadata.decode.bind(updateMetadataImportMetadata)), + updateMetadataImportMetadata.decode.bind(updateMetadataImportMetadata), + ), exportMetadata: new this._gaxModule.LongrunningDescriptor( this.operationsClient, exportMetadataResponse.decode.bind(exportMetadataResponse), - exportMetadataMetadata.decode.bind(exportMetadataMetadata)), + exportMetadataMetadata.decode.bind(exportMetadataMetadata), + ), restoreService: new this._gaxModule.LongrunningDescriptor( this.operationsClient, restoreServiceResponse.decode.bind(restoreServiceResponse), - restoreServiceMetadata.decode.bind(restoreServiceMetadata)), + restoreServiceMetadata.decode.bind(restoreServiceMetadata), + ), createBackup: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createBackupResponse.decode.bind(createBackupResponse), - createBackupMetadata.decode.bind(createBackupMetadata)), + createBackupMetadata.decode.bind(createBackupMetadata), + ), deleteBackup: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteBackupResponse.decode.bind(deleteBackupResponse), - deleteBackupMetadata.decode.bind(deleteBackupMetadata)), + deleteBackupMetadata.decode.bind(deleteBackupMetadata), + ), queryMetadata: new this._gaxModule.LongrunningDescriptor( this.operationsClient, queryMetadataResponse.decode.bind(queryMetadataResponse), - queryMetadataMetadata.decode.bind(queryMetadataMetadata)), + queryMetadataMetadata.decode.bind(queryMetadataMetadata), + ), moveTableToDatabase: new this._gaxModule.LongrunningDescriptor( this.operationsClient, moveTableToDatabaseResponse.decode.bind(moveTableToDatabaseResponse), - moveTableToDatabaseMetadata.decode.bind(moveTableToDatabaseMetadata)), + moveTableToDatabaseMetadata.decode.bind(moveTableToDatabaseMetadata), + ), alterMetadataResourceLocation: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - alterMetadataResourceLocationResponse.decode.bind(alterMetadataResourceLocationResponse), - alterMetadataResourceLocationMetadata.decode.bind(alterMetadataResourceLocationMetadata)) + alterMetadataResourceLocationResponse.decode.bind( + alterMetadataResourceLocationResponse, + ), + alterMetadataResourceLocationMetadata.decode.bind( + alterMetadataResourceLocationMetadata, + ), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.metastore.v1alpha.DataprocMetastore', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.metastore.v1alpha.DataprocMetastore', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -391,28 +562,54 @@ export class DataprocMetastoreClient { // Put together the "service stub" for // google.cloud.metastore.v1alpha.DataprocMetastore. this.dataprocMetastoreStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.metastore.v1alpha.DataprocMetastore') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.metastore.v1alpha.DataprocMetastore, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.metastore.v1alpha.DataprocMetastore', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.metastore.v1alpha + .DataprocMetastore, + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const dataprocMetastoreStubMethods = - ['listServices', 'getService', 'createService', 'updateService', 'deleteService', 'listMetadataImports', 'getMetadataImport', 'createMetadataImport', 'updateMetadataImport', 'exportMetadata', 'restoreService', 'listBackups', 'getBackup', 'createBackup', 'deleteBackup', 'removeIamPolicy', 'queryMetadata', 'moveTableToDatabase', 'alterMetadataResourceLocation']; + const dataprocMetastoreStubMethods = [ + 'listServices', + 'getService', + 'createService', + 'updateService', + 'deleteService', + 'listMetadataImports', + 'getMetadataImport', + 'createMetadataImport', + 'updateMetadataImport', + 'exportMetadata', + 'restoreService', + 'listBackups', + 'getBackup', + 'createBackup', + 'deleteBackup', + 'removeIamPolicy', + 'queryMetadata', + 'moveTableToDatabase', + 'alterMetadataResourceLocation', + ]; for (const methodName of dataprocMetastoreStubMethods) { const callPromise = this.dataprocMetastoreStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -422,7 +619,7 @@ export class DataprocMetastoreClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -437,8 +634,14 @@ export class DataprocMetastoreClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'metastore.googleapis.com'; } @@ -449,8 +652,14 @@ export class DataprocMetastoreClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'metastore.googleapis.com'; } @@ -481,9 +690,7 @@ export class DataprocMetastoreClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -492,8 +699,9 @@ export class DataprocMetastoreClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -504,2019 +712,2966 @@ export class DataprocMetastoreClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets the details of a single service. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The relative resource name of the metastore service to retrieve, - * in the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}`. - * @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 {@link protos.google.cloud.metastore.v1alpha.Service|Service}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/dataproc_metastore.get_service.js - * region_tag:metastore_v1alpha_generated_DataprocMetastore_GetService_async - */ + /** + * Gets the details of a single service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The relative resource name of the metastore service to retrieve, + * in the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}`. + * @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 {@link protos.google.cloud.metastore.v1alpha.Service|Service}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/dataproc_metastore.get_service.js + * region_tag:metastore_v1alpha_generated_DataprocMetastore_GetService_async + */ getService( - request?: protos.google.cloud.metastore.v1alpha.IGetServiceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.metastore.v1alpha.IService, - protos.google.cloud.metastore.v1alpha.IGetServiceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1alpha.IGetServiceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.metastore.v1alpha.IService, + protos.google.cloud.metastore.v1alpha.IGetServiceRequest | undefined, + {} | undefined, + ] + >; getService( - request: protos.google.cloud.metastore.v1alpha.IGetServiceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.metastore.v1alpha.IService, - protos.google.cloud.metastore.v1alpha.IGetServiceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IGetServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.metastore.v1alpha.IService, + | protos.google.cloud.metastore.v1alpha.IGetServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getService( - request: protos.google.cloud.metastore.v1alpha.IGetServiceRequest, - callback: Callback< - protos.google.cloud.metastore.v1alpha.IService, - protos.google.cloud.metastore.v1alpha.IGetServiceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IGetServiceRequest, + callback: Callback< + protos.google.cloud.metastore.v1alpha.IService, + | protos.google.cloud.metastore.v1alpha.IGetServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getService( - request?: protos.google.cloud.metastore.v1alpha.IGetServiceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.metastore.v1alpha.IService, - protos.google.cloud.metastore.v1alpha.IGetServiceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.metastore.v1alpha.IGetServiceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.metastore.v1alpha.IService, - protos.google.cloud.metastore.v1alpha.IGetServiceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.metastore.v1alpha.IService, - protos.google.cloud.metastore.v1alpha.IGetServiceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.metastore.v1alpha.IGetServiceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.metastore.v1alpha.IService, + | protos.google.cloud.metastore.v1alpha.IGetServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.metastore.v1alpha.IService, + protos.google.cloud.metastore.v1alpha.IGetServiceRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getService request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.metastore.v1alpha.IService, - protos.google.cloud.metastore.v1alpha.IGetServiceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.metastore.v1alpha.IService, + | protos.google.cloud.metastore.v1alpha.IGetServiceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getService response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getService(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.metastore.v1alpha.IService, - protos.google.cloud.metastore.v1alpha.IGetServiceRequest|undefined, - {}|undefined - ]) => { - this._log.info('getService response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getService(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.metastore.v1alpha.IService, + protos.google.cloud.metastore.v1alpha.IGetServiceRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getService response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single import. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The relative resource name of the metadata import to retrieve, in - * the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}/metadataImports/{import_id}`. - * @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 {@link protos.google.cloud.metastore.v1alpha.MetadataImport|MetadataImport}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/dataproc_metastore.get_metadata_import.js - * region_tag:metastore_v1alpha_generated_DataprocMetastore_GetMetadataImport_async - */ + /** + * Gets details of a single import. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The relative resource name of the metadata import to retrieve, in + * the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}/metadataImports/{import_id}`. + * @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 {@link protos.google.cloud.metastore.v1alpha.MetadataImport|MetadataImport}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/dataproc_metastore.get_metadata_import.js + * region_tag:metastore_v1alpha_generated_DataprocMetastore_GetMetadataImport_async + */ getMetadataImport( - request?: protos.google.cloud.metastore.v1alpha.IGetMetadataImportRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.metastore.v1alpha.IMetadataImport, - protos.google.cloud.metastore.v1alpha.IGetMetadataImportRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1alpha.IGetMetadataImportRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.metastore.v1alpha.IMetadataImport, + ( + | protos.google.cloud.metastore.v1alpha.IGetMetadataImportRequest + | undefined + ), + {} | undefined, + ] + >; getMetadataImport( - request: protos.google.cloud.metastore.v1alpha.IGetMetadataImportRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.metastore.v1alpha.IMetadataImport, - protos.google.cloud.metastore.v1alpha.IGetMetadataImportRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IGetMetadataImportRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.metastore.v1alpha.IMetadataImport, + | protos.google.cloud.metastore.v1alpha.IGetMetadataImportRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getMetadataImport( - request: protos.google.cloud.metastore.v1alpha.IGetMetadataImportRequest, - callback: Callback< - protos.google.cloud.metastore.v1alpha.IMetadataImport, - protos.google.cloud.metastore.v1alpha.IGetMetadataImportRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IGetMetadataImportRequest, + callback: Callback< + protos.google.cloud.metastore.v1alpha.IMetadataImport, + | protos.google.cloud.metastore.v1alpha.IGetMetadataImportRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getMetadataImport( - request?: protos.google.cloud.metastore.v1alpha.IGetMetadataImportRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.metastore.v1alpha.IMetadataImport, - protos.google.cloud.metastore.v1alpha.IGetMetadataImportRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.metastore.v1alpha.IGetMetadataImportRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.metastore.v1alpha.IMetadataImport, - protos.google.cloud.metastore.v1alpha.IGetMetadataImportRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.metastore.v1alpha.IMetadataImport, - protos.google.cloud.metastore.v1alpha.IGetMetadataImportRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.metastore.v1alpha.IGetMetadataImportRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.metastore.v1alpha.IMetadataImport, + | protos.google.cloud.metastore.v1alpha.IGetMetadataImportRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.metastore.v1alpha.IMetadataImport, + ( + | protos.google.cloud.metastore.v1alpha.IGetMetadataImportRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getMetadataImport request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.metastore.v1alpha.IMetadataImport, - protos.google.cloud.metastore.v1alpha.IGetMetadataImportRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.metastore.v1alpha.IMetadataImport, + | protos.google.cloud.metastore.v1alpha.IGetMetadataImportRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getMetadataImport response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getMetadataImport(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.metastore.v1alpha.IMetadataImport, - protos.google.cloud.metastore.v1alpha.IGetMetadataImportRequest|undefined, - {}|undefined - ]) => { - this._log.info('getMetadataImport response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getMetadataImport(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.metastore.v1alpha.IMetadataImport, + ( + | protos.google.cloud.metastore.v1alpha.IGetMetadataImportRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getMetadataImport response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single backup. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The relative resource name of the backup to retrieve, in the - * following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}/backups/{backup_id}`. - * @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 {@link protos.google.cloud.metastore.v1alpha.Backup|Backup}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/dataproc_metastore.get_backup.js - * region_tag:metastore_v1alpha_generated_DataprocMetastore_GetBackup_async - */ + /** + * Gets details of a single backup. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The relative resource name of the backup to retrieve, in the + * following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}/backups/{backup_id}`. + * @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 {@link protos.google.cloud.metastore.v1alpha.Backup|Backup}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/dataproc_metastore.get_backup.js + * region_tag:metastore_v1alpha_generated_DataprocMetastore_GetBackup_async + */ getBackup( - request?: protos.google.cloud.metastore.v1alpha.IGetBackupRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.metastore.v1alpha.IBackup, - protos.google.cloud.metastore.v1alpha.IGetBackupRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1alpha.IGetBackupRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.metastore.v1alpha.IBackup, + protos.google.cloud.metastore.v1alpha.IGetBackupRequest | undefined, + {} | undefined, + ] + >; getBackup( - request: protos.google.cloud.metastore.v1alpha.IGetBackupRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.metastore.v1alpha.IBackup, - protos.google.cloud.metastore.v1alpha.IGetBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IGetBackupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.metastore.v1alpha.IBackup, + | protos.google.cloud.metastore.v1alpha.IGetBackupRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getBackup( - request: protos.google.cloud.metastore.v1alpha.IGetBackupRequest, - callback: Callback< - protos.google.cloud.metastore.v1alpha.IBackup, - protos.google.cloud.metastore.v1alpha.IGetBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IGetBackupRequest, + callback: Callback< + protos.google.cloud.metastore.v1alpha.IBackup, + | protos.google.cloud.metastore.v1alpha.IGetBackupRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getBackup( - request?: protos.google.cloud.metastore.v1alpha.IGetBackupRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.metastore.v1alpha.IBackup, - protos.google.cloud.metastore.v1alpha.IGetBackupRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.metastore.v1alpha.IGetBackupRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.metastore.v1alpha.IBackup, - protos.google.cloud.metastore.v1alpha.IGetBackupRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.metastore.v1alpha.IBackup, - protos.google.cloud.metastore.v1alpha.IGetBackupRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.metastore.v1alpha.IGetBackupRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.metastore.v1alpha.IBackup, + | protos.google.cloud.metastore.v1alpha.IGetBackupRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.metastore.v1alpha.IBackup, + protos.google.cloud.metastore.v1alpha.IGetBackupRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getBackup request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.metastore.v1alpha.IBackup, - protos.google.cloud.metastore.v1alpha.IGetBackupRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.metastore.v1alpha.IBackup, + | protos.google.cloud.metastore.v1alpha.IGetBackupRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getBackup response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getBackup(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.metastore.v1alpha.IBackup, - protos.google.cloud.metastore.v1alpha.IGetBackupRequest|undefined, - {}|undefined - ]) => { - this._log.info('getBackup response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getBackup(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.metastore.v1alpha.IBackup, + protos.google.cloud.metastore.v1alpha.IGetBackupRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getBackup response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Removes the attached IAM policies for a resource - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * Required. The relative resource name of the dataplane resource to remove - * IAM policy, in the following form: - * - * `projects/{project_id}/locations/{location_id}/services/{service_id}/databases/{database_id}` - * or - * `projects/{project_id}/locations/{location_id}/services/{service_id}/databases/{database_id}/tables/{table_id}`. - * @param {boolean} [request.asynchronous] - * Optional. Removes IAM policy attached to database or table asynchronously - * when it is set. The default is false. - * @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 {@link protos.google.cloud.metastore.v1alpha.RemoveIamPolicyResponse|RemoveIamPolicyResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/dataproc_metastore.remove_iam_policy.js - * region_tag:metastore_v1alpha_generated_DataprocMetastore_RemoveIamPolicy_async - */ + /** + * Removes the attached IAM policies for a resource + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * Required. The relative resource name of the dataplane resource to remove + * IAM policy, in the following form: + * + * `projects/{project_id}/locations/{location_id}/services/{service_id}/databases/{database_id}` + * or + * `projects/{project_id}/locations/{location_id}/services/{service_id}/databases/{database_id}/tables/{table_id}`. + * @param {boolean} [request.asynchronous] + * Optional. Removes IAM policy attached to database or table asynchronously + * when it is set. The default is false. + * @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 {@link protos.google.cloud.metastore.v1alpha.RemoveIamPolicyResponse|RemoveIamPolicyResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/dataproc_metastore.remove_iam_policy.js + * region_tag:metastore_v1alpha_generated_DataprocMetastore_RemoveIamPolicy_async + */ removeIamPolicy( - request?: protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyResponse, - protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyResponse, + protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyRequest | undefined, + {} | undefined, + ] + >; removeIamPolicy( - request: protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyResponse, - protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyResponse, + | protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyRequest + | null + | undefined, + {} | null | undefined + >, + ): void; removeIamPolicy( - request: protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyRequest, - callback: Callback< - protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyResponse, - protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyRequest, + callback: Callback< + protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyResponse, + | protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyRequest + | null + | undefined, + {} | null | undefined + >, + ): void; removeIamPolicy( - request?: protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyResponse, - protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyResponse, - protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyResponse, - protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyResponse, + | protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyResponse, + protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'resource': request.resource ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + resource: request.resource ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('removeIamPolicy request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyResponse, - protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyResponse, + | protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('removeIamPolicy response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.removeIamPolicy(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyResponse, - protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyRequest|undefined, - {}|undefined - ]) => { - this._log.info('removeIamPolicy response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .removeIamPolicy(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyResponse, + ( + | protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('removeIamPolicy response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a metastore service in a project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the location in which to create a - * metastore service, in the following form: - * - * `projects/{project_number}/locations/{location_id}`. - * @param {string} request.serviceId - * Required. The ID of the metastore service, which is used as the final - * component of the metastore service's name. - * - * This value must be between 2 and 63 characters long inclusive, begin with a - * letter, end with a letter or number, and consist of alpha-numeric - * ASCII characters or hyphens. - * @param {google.cloud.metastore.v1alpha.Service} request.service - * Required. The Metastore service to create. The `name` field is - * ignored. The ID of the created metastore service must be provided in - * the request's `service_id` field. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/v1alpha/dataproc_metastore.create_service.js - * region_tag:metastore_v1alpha_generated_DataprocMetastore_CreateService_async - */ - createService( - request?: protos.google.cloud.metastore.v1alpha.ICreateServiceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createService( - request: protos.google.cloud.metastore.v1alpha.ICreateServiceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createService( - request: protos.google.cloud.metastore.v1alpha.ICreateServiceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createService( - request?: protos.google.cloud.metastore.v1alpha.ICreateServiceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - 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; + /** + * Creates a metastore service in a project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the location in which to create a + * metastore service, in the following form: + * + * `projects/{project_number}/locations/{location_id}`. + * @param {string} request.serviceId + * Required. The ID of the metastore service, which is used as the final + * component of the metastore service's name. + * + * This value must be between 2 and 63 characters long inclusive, begin with a + * letter, end with a letter or number, and consist of alpha-numeric + * ASCII characters or hyphens. + * @param {google.cloud.metastore.v1alpha.Service} request.service + * Required. The Metastore service to create. The `name` field is + * ignored. The ID of the created metastore service must be provided in + * the request's `service_id` field. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/v1alpha/dataproc_metastore.create_service.js + * region_tag:metastore_v1alpha_generated_DataprocMetastore_CreateService_async + */ + createService( + request?: protos.google.cloud.metastore.v1alpha.ICreateServiceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1alpha.IService, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; + createService( + request: protos.google.cloud.metastore.v1alpha.ICreateServiceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IService, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; + createService( + request: protos.google.cloud.metastore.v1alpha.ICreateServiceRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IService, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; + createService( + request?: protos.google.cloud.metastore.v1alpha.ICreateServiceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IService, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IService, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1alpha.IService, + protos.google.cloud.metastore.v1alpha.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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IService, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createService response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createService request %j', request); - return this.innerApiCalls.createService(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createService response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createService(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1alpha.IService, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createService response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createService()`. - * @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/v1alpha/dataproc_metastore.create_service.js - * region_tag:metastore_v1alpha_generated_DataprocMetastore_CreateService_async - */ - async checkCreateServiceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createService()`. + * @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/v1alpha/dataproc_metastore.create_service.js + * region_tag:metastore_v1alpha_generated_DataprocMetastore_CreateService_async + */ + async checkCreateServiceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1alpha.Service, + protos.google.cloud.metastore.v1alpha.OperationMetadata + > + > { this._log.info('createService long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createService, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createService, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1alpha.Service, + protos.google.cloud.metastore.v1alpha.OperationMetadata + >; } -/** - * Updates the parameters of a single service. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. A field mask used to specify the fields to be overwritten in the - * metastore service resource by the update. - * Fields specified in the `update_mask` are relative to the resource (not - * to the full request). A field is overwritten if it is in the mask. - * @param {google.cloud.metastore.v1alpha.Service} request.service - * Required. The metastore service to update. The server only merges fields - * in the service if they are specified in `update_mask`. - * - * The metastore service's `name` field is used to identify the metastore - * service to be updated. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/v1alpha/dataproc_metastore.update_service.js - * region_tag:metastore_v1alpha_generated_DataprocMetastore_UpdateService_async - */ + /** + * Updates the parameters of a single service. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. A field mask used to specify the fields to be overwritten in the + * metastore service resource by the update. + * Fields specified in the `update_mask` are relative to the resource (not + * to the full request). A field is overwritten if it is in the mask. + * @param {google.cloud.metastore.v1alpha.Service} request.service + * Required. The metastore service to update. The server only merges fields + * in the service if they are specified in `update_mask`. + * + * The metastore service's `name` field is used to identify the metastore + * service to be updated. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/v1alpha/dataproc_metastore.update_service.js + * region_tag:metastore_v1alpha_generated_DataprocMetastore_UpdateService_async + */ updateService( - request?: protos.google.cloud.metastore.v1alpha.IUpdateServiceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1alpha.IUpdateServiceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1alpha.IService, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateService( - request: protos.google.cloud.metastore.v1alpha.IUpdateServiceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IUpdateServiceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IService, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateService( - request: protos.google.cloud.metastore.v1alpha.IUpdateServiceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IUpdateServiceRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IService, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateService( - request?: protos.google.cloud.metastore.v1alpha.IUpdateServiceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1alpha.IUpdateServiceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IService, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IService, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1alpha.IService, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'service.name': request.service!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'service.name': request.service!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IService, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateService response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateService request %j', request); - return this.innerApiCalls.updateService(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateService response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateService(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1alpha.IService, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateService response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateService()`. - * @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/v1alpha/dataproc_metastore.update_service.js - * region_tag:metastore_v1alpha_generated_DataprocMetastore_UpdateService_async - */ - async checkUpdateServiceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateService()`. + * @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/v1alpha/dataproc_metastore.update_service.js + * region_tag:metastore_v1alpha_generated_DataprocMetastore_UpdateService_async + */ + async checkUpdateServiceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1alpha.Service, + protos.google.cloud.metastore.v1alpha.OperationMetadata + > + > { this._log.info('updateService long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateService, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateService, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1alpha.Service, + protos.google.cloud.metastore.v1alpha.OperationMetadata + >; } -/** - * Deletes a single service. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The relative resource name of the metastore service to delete, in - * the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}`. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/v1alpha/dataproc_metastore.delete_service.js - * region_tag:metastore_v1alpha_generated_DataprocMetastore_DeleteService_async - */ + /** + * Deletes a single service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The relative resource name of the metastore service to delete, in + * the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}`. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/v1alpha/dataproc_metastore.delete_service.js + * region_tag:metastore_v1alpha_generated_DataprocMetastore_DeleteService_async + */ deleteService( - request?: protos.google.cloud.metastore.v1alpha.IDeleteServiceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1alpha.IDeleteServiceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteService( - request: protos.google.cloud.metastore.v1alpha.IDeleteServiceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IDeleteServiceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteService( - request: protos.google.cloud.metastore.v1alpha.IDeleteServiceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IDeleteServiceRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteService( - request?: protos.google.cloud.metastore.v1alpha.IDeleteServiceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1alpha.IDeleteServiceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteService response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteService request %j', request); - return this.innerApiCalls.deleteService(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteService response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteService(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteService response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteService()`. - * @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/v1alpha/dataproc_metastore.delete_service.js - * region_tag:metastore_v1alpha_generated_DataprocMetastore_DeleteService_async - */ - async checkDeleteServiceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteService()`. + * @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/v1alpha/dataproc_metastore.delete_service.js + * region_tag:metastore_v1alpha_generated_DataprocMetastore_DeleteService_async + */ + async checkDeleteServiceProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.metastore.v1alpha.OperationMetadata + > + > { this._log.info('deleteService long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteService, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteService, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.metastore.v1alpha.OperationMetadata + >; } -/** - * Creates a new MetadataImport in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the service in which to create a - * metastore import, in the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}`. - * @param {string} request.metadataImportId - * Required. The ID of the metadata import, which is used as the final - * component of the metadata import's name. - * - * This value must be between 1 and 64 characters long, begin with a letter, - * end with a letter or number, and consist of alpha-numeric ASCII characters - * or hyphens. - * @param {google.cloud.metastore.v1alpha.MetadataImport} request.metadataImport - * Required. The metadata import to create. The `name` field is ignored. The - * ID of the created metadata import must be provided in the request's - * `metadata_import_id` field. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/v1alpha/dataproc_metastore.create_metadata_import.js - * region_tag:metastore_v1alpha_generated_DataprocMetastore_CreateMetadataImport_async - */ + /** + * Creates a new MetadataImport in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the service in which to create a + * metastore import, in the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}`. + * @param {string} request.metadataImportId + * Required. The ID of the metadata import, which is used as the final + * component of the metadata import's name. + * + * This value must be between 1 and 64 characters long, begin with a letter, + * end with a letter or number, and consist of alpha-numeric ASCII characters + * or hyphens. + * @param {google.cloud.metastore.v1alpha.MetadataImport} request.metadataImport + * Required. The metadata import to create. The `name` field is ignored. The + * ID of the created metadata import must be provided in the request's + * `metadata_import_id` field. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/v1alpha/dataproc_metastore.create_metadata_import.js + * region_tag:metastore_v1alpha_generated_DataprocMetastore_CreateMetadataImport_async + */ createMetadataImport( - request?: protos.google.cloud.metastore.v1alpha.ICreateMetadataImportRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1alpha.ICreateMetadataImportRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1alpha.IMetadataImport, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createMetadataImport( - request: protos.google.cloud.metastore.v1alpha.ICreateMetadataImportRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.ICreateMetadataImportRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IMetadataImport, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createMetadataImport( - request: protos.google.cloud.metastore.v1alpha.ICreateMetadataImportRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.ICreateMetadataImportRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IMetadataImport, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createMetadataImport( - request?: protos.google.cloud.metastore.v1alpha.ICreateMetadataImportRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1alpha.ICreateMetadataImportRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IMetadataImport, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IMetadataImport, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1alpha.IMetadataImport, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IMetadataImport, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createMetadataImport response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createMetadataImport request %j', request); - return this.innerApiCalls.createMetadataImport(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createMetadataImport response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createMetadataImport(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1alpha.IMetadataImport, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createMetadataImport response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createMetadataImport()`. - * @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/v1alpha/dataproc_metastore.create_metadata_import.js - * region_tag:metastore_v1alpha_generated_DataprocMetastore_CreateMetadataImport_async - */ - async checkCreateMetadataImportProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createMetadataImport()`. + * @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/v1alpha/dataproc_metastore.create_metadata_import.js + * region_tag:metastore_v1alpha_generated_DataprocMetastore_CreateMetadataImport_async + */ + async checkCreateMetadataImportProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1alpha.MetadataImport, + protos.google.cloud.metastore.v1alpha.OperationMetadata + > + > { this._log.info('createMetadataImport long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createMetadataImport, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createMetadataImport, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1alpha.MetadataImport, + protos.google.cloud.metastore.v1alpha.OperationMetadata + >; } -/** - * Updates a single import. - * Only the description field of MetadataImport is supported to be updated. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. A field mask used to specify the fields to be overwritten in the - * metadata import resource by the update. - * Fields specified in the `update_mask` are relative to the resource (not - * to the full request). A field is overwritten if it is in the mask. - * @param {google.cloud.metastore.v1alpha.MetadataImport} request.metadataImport - * Required. The metadata import to update. The server only merges fields - * in the import if they are specified in `update_mask`. - * - * The metadata import's `name` field is used to identify the metastore - * import to be updated. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/v1alpha/dataproc_metastore.update_metadata_import.js - * region_tag:metastore_v1alpha_generated_DataprocMetastore_UpdateMetadataImport_async - */ + /** + * Updates a single import. + * Only the description field of MetadataImport is supported to be updated. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. A field mask used to specify the fields to be overwritten in the + * metadata import resource by the update. + * Fields specified in the `update_mask` are relative to the resource (not + * to the full request). A field is overwritten if it is in the mask. + * @param {google.cloud.metastore.v1alpha.MetadataImport} request.metadataImport + * Required. The metadata import to update. The server only merges fields + * in the import if they are specified in `update_mask`. + * + * The metadata import's `name` field is used to identify the metastore + * import to be updated. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/v1alpha/dataproc_metastore.update_metadata_import.js + * region_tag:metastore_v1alpha_generated_DataprocMetastore_UpdateMetadataImport_async + */ updateMetadataImport( - request?: protos.google.cloud.metastore.v1alpha.IUpdateMetadataImportRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1alpha.IUpdateMetadataImportRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1alpha.IMetadataImport, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateMetadataImport( - request: protos.google.cloud.metastore.v1alpha.IUpdateMetadataImportRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IUpdateMetadataImportRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IMetadataImport, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateMetadataImport( - request: protos.google.cloud.metastore.v1alpha.IUpdateMetadataImportRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IUpdateMetadataImportRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IMetadataImport, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateMetadataImport( - request?: protos.google.cloud.metastore.v1alpha.IUpdateMetadataImportRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1alpha.IUpdateMetadataImportRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IMetadataImport, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IMetadataImport, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1alpha.IMetadataImport, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'metadata_import.name': request.metadataImport!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'metadata_import.name': request.metadataImport!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IMetadataImport, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateMetadataImport response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateMetadataImport request %j', request); - return this.innerApiCalls.updateMetadataImport(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateMetadataImport response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateMetadataImport(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1alpha.IMetadataImport, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateMetadataImport response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateMetadataImport()`. - * @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/v1alpha/dataproc_metastore.update_metadata_import.js - * region_tag:metastore_v1alpha_generated_DataprocMetastore_UpdateMetadataImport_async - */ - async checkUpdateMetadataImportProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateMetadataImport()`. + * @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/v1alpha/dataproc_metastore.update_metadata_import.js + * region_tag:metastore_v1alpha_generated_DataprocMetastore_UpdateMetadataImport_async + */ + async checkUpdateMetadataImportProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1alpha.MetadataImport, + protos.google.cloud.metastore.v1alpha.OperationMetadata + > + > { this._log.info('updateMetadataImport long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateMetadataImport, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateMetadataImport, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1alpha.MetadataImport, + protos.google.cloud.metastore.v1alpha.OperationMetadata + >; } -/** - * Exports metadata from a service. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.destinationGcsFolder - * A Cloud Storage URI of a folder, in the format - * `gs:///`. A sub-folder - * `` containing exported files will be created below it. - * @param {string} request.service - * Required. The relative resource name of the metastore service to run - * export, in the following form: - * - * `projects/{project_id}/locations/{location_id}/services/{service_id}`. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format). - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @param {google.cloud.metastore.v1alpha.DatabaseDumpSpec.Type} [request.databaseDumpType] - * Optional. The type of the database dump. If unspecified, defaults to - * `MYSQL`. - * @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/v1alpha/dataproc_metastore.export_metadata.js - * region_tag:metastore_v1alpha_generated_DataprocMetastore_ExportMetadata_async - */ + /** + * Exports metadata from a service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.destinationGcsFolder + * A Cloud Storage URI of a folder, in the format + * `gs:///`. A sub-folder + * `` containing exported files will be created below it. + * @param {string} request.service + * Required. The relative resource name of the metastore service to run + * export, in the following form: + * + * `projects/{project_id}/locations/{location_id}/services/{service_id}`. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format). + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @param {google.cloud.metastore.v1alpha.DatabaseDumpSpec.Type} [request.databaseDumpType] + * Optional. The type of the database dump. If unspecified, defaults to + * `MYSQL`. + * @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/v1alpha/dataproc_metastore.export_metadata.js + * region_tag:metastore_v1alpha_generated_DataprocMetastore_ExportMetadata_async + */ exportMetadata( - request?: protos.google.cloud.metastore.v1alpha.IExportMetadataRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1alpha.IExportMetadataRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1alpha.IMetadataExport, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; exportMetadata( - request: protos.google.cloud.metastore.v1alpha.IExportMetadataRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IExportMetadataRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IMetadataExport, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; exportMetadata( - request: protos.google.cloud.metastore.v1alpha.IExportMetadataRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IExportMetadataRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IMetadataExport, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; exportMetadata( - request?: protos.google.cloud.metastore.v1alpha.IExportMetadataRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1alpha.IExportMetadataRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IMetadataExport, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IMetadataExport, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1alpha.IMetadataExport, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'service': request.service ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + service: request.service ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IMetadataExport, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('exportMetadata response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('exportMetadata request %j', request); - return this.innerApiCalls.exportMetadata(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('exportMetadata response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .exportMetadata(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1alpha.IMetadataExport, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('exportMetadata response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `exportMetadata()`. - * @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/v1alpha/dataproc_metastore.export_metadata.js - * region_tag:metastore_v1alpha_generated_DataprocMetastore_ExportMetadata_async - */ - async checkExportMetadataProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `exportMetadata()`. + * @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/v1alpha/dataproc_metastore.export_metadata.js + * region_tag:metastore_v1alpha_generated_DataprocMetastore_ExportMetadata_async + */ + async checkExportMetadataProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1alpha.MetadataExport, + protos.google.cloud.metastore.v1alpha.OperationMetadata + > + > { this._log.info('exportMetadata long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.exportMetadata, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.exportMetadata, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1alpha.MetadataExport, + protos.google.cloud.metastore.v1alpha.OperationMetadata + >; } -/** - * Restores a service from a backup. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.service - * Required. The relative resource name of the metastore service to run - * restore, in the following form: - * - * `projects/{project_id}/locations/{location_id}/services/{service_id}`. - * @param {string} request.backup - * Required. The relative resource name of the metastore service backup to - * restore from, in the following form: - * - * `projects/{project_id}/locations/{location_id}/services/{service_id}/backups/{backup_id}`. - * @param {google.cloud.metastore.v1alpha.Restore.RestoreType} [request.restoreType] - * Optional. The type of restore. If unspecified, defaults to `METADATA_ONLY`. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format). - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/v1alpha/dataproc_metastore.restore_service.js - * region_tag:metastore_v1alpha_generated_DataprocMetastore_RestoreService_async - */ + /** + * Restores a service from a backup. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.service + * Required. The relative resource name of the metastore service to run + * restore, in the following form: + * + * `projects/{project_id}/locations/{location_id}/services/{service_id}`. + * @param {string} request.backup + * Required. The relative resource name of the metastore service backup to + * restore from, in the following form: + * + * `projects/{project_id}/locations/{location_id}/services/{service_id}/backups/{backup_id}`. + * @param {google.cloud.metastore.v1alpha.Restore.RestoreType} [request.restoreType] + * Optional. The type of restore. If unspecified, defaults to `METADATA_ONLY`. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format). + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/v1alpha/dataproc_metastore.restore_service.js + * region_tag:metastore_v1alpha_generated_DataprocMetastore_RestoreService_async + */ restoreService( - request?: protos.google.cloud.metastore.v1alpha.IRestoreServiceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1alpha.IRestoreServiceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1alpha.IRestore, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; restoreService( - request: protos.google.cloud.metastore.v1alpha.IRestoreServiceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IRestoreServiceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IRestore, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; restoreService( - request: protos.google.cloud.metastore.v1alpha.IRestoreServiceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IRestoreServiceRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IRestore, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; restoreService( - request?: protos.google.cloud.metastore.v1alpha.IRestoreServiceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1alpha.IRestoreServiceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IRestore, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IRestore, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1alpha.IRestore, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'service': request.service ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + service: request.service ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IRestore, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('restoreService response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('restoreService request %j', request); - return this.innerApiCalls.restoreService(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('restoreService response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .restoreService(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1alpha.IRestore, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('restoreService response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `restoreService()`. - * @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/v1alpha/dataproc_metastore.restore_service.js - * region_tag:metastore_v1alpha_generated_DataprocMetastore_RestoreService_async - */ - async checkRestoreServiceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `restoreService()`. + * @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/v1alpha/dataproc_metastore.restore_service.js + * region_tag:metastore_v1alpha_generated_DataprocMetastore_RestoreService_async + */ + async checkRestoreServiceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1alpha.Restore, + protos.google.cloud.metastore.v1alpha.OperationMetadata + > + > { this._log.info('restoreService long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.restoreService, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.restoreService, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1alpha.Restore, + protos.google.cloud.metastore.v1alpha.OperationMetadata + >; } -/** - * Creates a new backup in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the service in which to create a - * backup of the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}`. - * @param {string} request.backupId - * Required. The ID of the backup, which is used as the final component of the - * backup's name. - * - * This value must be between 1 and 64 characters long, begin with a letter, - * end with a letter or number, and consist of alpha-numeric ASCII characters - * or hyphens. - * @param {google.cloud.metastore.v1alpha.Backup} request.backup - * Required. The backup to create. The `name` field is ignored. The ID of the - * created backup must be provided in the request's `backup_id` field. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/v1alpha/dataproc_metastore.create_backup.js - * region_tag:metastore_v1alpha_generated_DataprocMetastore_CreateBackup_async - */ + /** + * Creates a new backup in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the service in which to create a + * backup of the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}`. + * @param {string} request.backupId + * Required. The ID of the backup, which is used as the final component of the + * backup's name. + * + * This value must be between 1 and 64 characters long, begin with a letter, + * end with a letter or number, and consist of alpha-numeric ASCII characters + * or hyphens. + * @param {google.cloud.metastore.v1alpha.Backup} request.backup + * Required. The backup to create. The `name` field is ignored. The ID of the + * created backup must be provided in the request's `backup_id` field. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/v1alpha/dataproc_metastore.create_backup.js + * region_tag:metastore_v1alpha_generated_DataprocMetastore_CreateBackup_async + */ createBackup( - request?: protos.google.cloud.metastore.v1alpha.ICreateBackupRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1alpha.ICreateBackupRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1alpha.IBackup, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createBackup( - request: protos.google.cloud.metastore.v1alpha.ICreateBackupRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.ICreateBackupRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IBackup, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createBackup( - request: protos.google.cloud.metastore.v1alpha.ICreateBackupRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.ICreateBackupRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IBackup, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createBackup( - request?: protos.google.cloud.metastore.v1alpha.ICreateBackupRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1alpha.ICreateBackupRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IBackup, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IBackup, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1alpha.IBackup, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IBackup, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createBackup response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createBackup request %j', request); - return this.innerApiCalls.createBackup(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createBackup response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createBackup(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1alpha.IBackup, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createBackup response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createBackup()`. - * @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/v1alpha/dataproc_metastore.create_backup.js - * region_tag:metastore_v1alpha_generated_DataprocMetastore_CreateBackup_async - */ - async checkCreateBackupProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createBackup()`. + * @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/v1alpha/dataproc_metastore.create_backup.js + * region_tag:metastore_v1alpha_generated_DataprocMetastore_CreateBackup_async + */ + async checkCreateBackupProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1alpha.Backup, + protos.google.cloud.metastore.v1alpha.OperationMetadata + > + > { this._log.info('createBackup long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createBackup, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createBackup, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1alpha.Backup, + protos.google.cloud.metastore.v1alpha.OperationMetadata + >; } -/** - * Deletes a single backup. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The relative resource name of the backup to delete, in the - * following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}/backups/{backup_id}`. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/v1alpha/dataproc_metastore.delete_backup.js - * region_tag:metastore_v1alpha_generated_DataprocMetastore_DeleteBackup_async - */ + /** + * Deletes a single backup. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The relative resource name of the backup to delete, in the + * following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}/backups/{backup_id}`. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/v1alpha/dataproc_metastore.delete_backup.js + * region_tag:metastore_v1alpha_generated_DataprocMetastore_DeleteBackup_async + */ deleteBackup( - request?: protos.google.cloud.metastore.v1alpha.IDeleteBackupRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1alpha.IDeleteBackupRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteBackup( - request: protos.google.cloud.metastore.v1alpha.IDeleteBackupRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IDeleteBackupRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteBackup( - request: protos.google.cloud.metastore.v1alpha.IDeleteBackupRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IDeleteBackupRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteBackup( - request?: protos.google.cloud.metastore.v1alpha.IDeleteBackupRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1alpha.IDeleteBackupRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteBackup response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteBackup request %j', request); - return this.innerApiCalls.deleteBackup(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteBackup response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteBackup(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteBackup response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteBackup()`. - * @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/v1alpha/dataproc_metastore.delete_backup.js - * region_tag:metastore_v1alpha_generated_DataprocMetastore_DeleteBackup_async - */ - async checkDeleteBackupProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteBackup()`. + * @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/v1alpha/dataproc_metastore.delete_backup.js + * region_tag:metastore_v1alpha_generated_DataprocMetastore_DeleteBackup_async + */ + async checkDeleteBackupProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.metastore.v1alpha.OperationMetadata + > + > { this._log.info('deleteBackup long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteBackup, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteBackup, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.metastore.v1alpha.OperationMetadata + >; } -/** - * Query DPMS metadata. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.service - * Required. The relative resource name of the metastore service to query - * metadata, in the following format: - * - * `projects/{project_id}/locations/{location_id}/services/{service_id}`. - * @param {string} request.query - * Required. A read-only SQL query to execute against the metadata database. - * The query cannot change or mutate the data. - * @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/v1alpha/dataproc_metastore.query_metadata.js - * region_tag:metastore_v1alpha_generated_DataprocMetastore_QueryMetadata_async - */ + /** + * Query DPMS metadata. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.service + * Required. The relative resource name of the metastore service to query + * metadata, in the following format: + * + * `projects/{project_id}/locations/{location_id}/services/{service_id}`. + * @param {string} request.query + * Required. A read-only SQL query to execute against the metadata database. + * The query cannot change or mutate the data. + * @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/v1alpha/dataproc_metastore.query_metadata.js + * region_tag:metastore_v1alpha_generated_DataprocMetastore_QueryMetadata_async + */ queryMetadata( - request?: protos.google.cloud.metastore.v1alpha.IQueryMetadataRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1alpha.IQueryMetadataRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1alpha.IQueryMetadataResponse, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; queryMetadata( - request: protos.google.cloud.metastore.v1alpha.IQueryMetadataRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IQueryMetadataRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IQueryMetadataResponse, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; queryMetadata( - request: protos.google.cloud.metastore.v1alpha.IQueryMetadataRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IQueryMetadataRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IQueryMetadataResponse, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; queryMetadata( - request?: protos.google.cloud.metastore.v1alpha.IQueryMetadataRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1alpha.IQueryMetadataRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IQueryMetadataResponse, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IQueryMetadataResponse, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1alpha.IQueryMetadataResponse, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'service': request.service ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + service: request.service ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IQueryMetadataResponse, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('queryMetadata response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('queryMetadata request %j', request); - return this.innerApiCalls.queryMetadata(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('queryMetadata response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .queryMetadata(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1alpha.IQueryMetadataResponse, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('queryMetadata response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `queryMetadata()`. - * @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/v1alpha/dataproc_metastore.query_metadata.js - * region_tag:metastore_v1alpha_generated_DataprocMetastore_QueryMetadata_async - */ - async checkQueryMetadataProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `queryMetadata()`. + * @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/v1alpha/dataproc_metastore.query_metadata.js + * region_tag:metastore_v1alpha_generated_DataprocMetastore_QueryMetadata_async + */ + async checkQueryMetadataProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1alpha.QueryMetadataResponse, + protos.google.cloud.metastore.v1alpha.OperationMetadata + > + > { this._log.info('queryMetadata long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.queryMetadata, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.queryMetadata, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1alpha.QueryMetadataResponse, + protos.google.cloud.metastore.v1alpha.OperationMetadata + >; } -/** - * Move a table to another database. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.service - * Required. The relative resource name of the metastore service to mutate - * metadata, in the following format: - * - * `projects/{project_id}/locations/{location_id}/services/{service_id}`. - * @param {string} request.tableName - * Required. The name of the table to be moved. - * @param {string} request.dbName - * Required. The name of the database where the table resides. - * @param {string} request.destinationDbName - * Required. The name of the database where the table should be moved. - * @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/v1alpha/dataproc_metastore.move_table_to_database.js - * region_tag:metastore_v1alpha_generated_DataprocMetastore_MoveTableToDatabase_async - */ + /** + * Move a table to another database. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.service + * Required. The relative resource name of the metastore service to mutate + * metadata, in the following format: + * + * `projects/{project_id}/locations/{location_id}/services/{service_id}`. + * @param {string} request.tableName + * Required. The name of the table to be moved. + * @param {string} request.dbName + * Required. The name of the database where the table resides. + * @param {string} request.destinationDbName + * Required. The name of the database where the table should be moved. + * @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/v1alpha/dataproc_metastore.move_table_to_database.js + * region_tag:metastore_v1alpha_generated_DataprocMetastore_MoveTableToDatabase_async + */ moveTableToDatabase( - request?: protos.google.cloud.metastore.v1alpha.IMoveTableToDatabaseRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1alpha.IMoveTableToDatabaseRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1alpha.IMoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; moveTableToDatabase( - request: protos.google.cloud.metastore.v1alpha.IMoveTableToDatabaseRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IMoveTableToDatabaseRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IMoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; moveTableToDatabase( - request: protos.google.cloud.metastore.v1alpha.IMoveTableToDatabaseRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IMoveTableToDatabaseRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IMoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; moveTableToDatabase( - request?: protos.google.cloud.metastore.v1alpha.IMoveTableToDatabaseRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1alpha.IMoveTableToDatabaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IMoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IMoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1alpha.IMoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'service': request.service ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + service: request.service ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IMoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('moveTableToDatabase response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('moveTableToDatabase request %j', request); - return this.innerApiCalls.moveTableToDatabase(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('moveTableToDatabase response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .moveTableToDatabase(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1alpha.IMoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('moveTableToDatabase response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `moveTableToDatabase()`. - * @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/v1alpha/dataproc_metastore.move_table_to_database.js - * region_tag:metastore_v1alpha_generated_DataprocMetastore_MoveTableToDatabase_async - */ - async checkMoveTableToDatabaseProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `moveTableToDatabase()`. + * @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/v1alpha/dataproc_metastore.move_table_to_database.js + * region_tag:metastore_v1alpha_generated_DataprocMetastore_MoveTableToDatabase_async + */ + async checkMoveTableToDatabaseProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1alpha.MoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1alpha.OperationMetadata + > + > { this._log.info('moveTableToDatabase long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.moveTableToDatabase, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.moveTableToDatabase, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1alpha.MoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1alpha.OperationMetadata + >; } -/** - * Alter metadata resource location. The metadata resource can be a database, - * table, or partition. This functionality only updates the parent directory - * for the respective metadata resource and does not transfer any existing - * data to the new location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.service - * Required. The relative resource name of the metastore service to mutate - * metadata, in the following format: - * - * `projects/{project_id}/locations/{location_id}/services/{service_id}`. - * @param {string} request.resourceName - * Required. The relative metadata resource name in the following format. - * - * `databases/{database_id}` - * or - * `databases/{database_id}/tables/{table_id}` - * or - * `databases/{database_id}/tables/{table_id}/partitions/{partition_id}` - * @param {string} request.locationUri - * Required. The new location URI for the metadata resource. - * @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/v1alpha/dataproc_metastore.alter_metadata_resource_location.js - * region_tag:metastore_v1alpha_generated_DataprocMetastore_AlterMetadataResourceLocation_async - */ + /** + * Alter metadata resource location. The metadata resource can be a database, + * table, or partition. This functionality only updates the parent directory + * for the respective metadata resource and does not transfer any existing + * data to the new location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.service + * Required. The relative resource name of the metastore service to mutate + * metadata, in the following format: + * + * `projects/{project_id}/locations/{location_id}/services/{service_id}`. + * @param {string} request.resourceName + * Required. The relative metadata resource name in the following format. + * + * `databases/{database_id}` + * or + * `databases/{database_id}/tables/{table_id}` + * or + * `databases/{database_id}/tables/{table_id}/partitions/{partition_id}` + * @param {string} request.locationUri + * Required. The new location URI for the metadata resource. + * @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/v1alpha/dataproc_metastore.alter_metadata_resource_location.js + * region_tag:metastore_v1alpha_generated_DataprocMetastore_AlterMetadataResourceLocation_async + */ alterMetadataResourceLocation( - request?: protos.google.cloud.metastore.v1alpha.IAlterMetadataResourceLocationRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1alpha.IAlterMetadataResourceLocationRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1alpha.IAlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; alterMetadataResourceLocation( - request: protos.google.cloud.metastore.v1alpha.IAlterMetadataResourceLocationRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IAlterMetadataResourceLocationRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IAlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; alterMetadataResourceLocation( - request: protos.google.cloud.metastore.v1alpha.IAlterMetadataResourceLocationRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IAlterMetadataResourceLocationRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IAlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; alterMetadataResourceLocation( - request?: protos.google.cloud.metastore.v1alpha.IAlterMetadataResourceLocationRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1alpha.IAlterMetadataResourceLocationRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IAlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IAlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1alpha.IAlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'service': request.service ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + service: request.service ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IAlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { - this._log.info('alterMetadataResourceLocation response %j', rawResponse); + this._log.info( + 'alterMetadataResourceLocation response %j', + rawResponse, + ); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('alterMetadataResourceLocation request %j', request); - return this.innerApiCalls.alterMetadataResourceLocation(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('alterMetadataResourceLocation response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .alterMetadataResourceLocation(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1alpha.IAlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info( + 'alterMetadataResourceLocation response %j', + rawResponse, + ); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `alterMetadataResourceLocation()`. - * @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/v1alpha/dataproc_metastore.alter_metadata_resource_location.js - * region_tag:metastore_v1alpha_generated_DataprocMetastore_AlterMetadataResourceLocation_async - */ - async checkAlterMetadataResourceLocationProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `alterMetadataResourceLocation()`. + * @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/v1alpha/dataproc_metastore.alter_metadata_resource_location.js + * region_tag:metastore_v1alpha_generated_DataprocMetastore_AlterMetadataResourceLocation_async + */ + async checkAlterMetadataResourceLocationProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1alpha.AlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1alpha.OperationMetadata + > + > { this._log.info('alterMetadataResourceLocation long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.alterMetadataResourceLocation, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.alterMetadataResourceLocation, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1alpha.AlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1alpha.OperationMetadata + >; } - /** - * Lists services in a project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the location of metastore services - * to list, in the following form: - * - * `projects/{project_number}/locations/{location_id}`. - * @param {number} [request.pageSize] - * Optional. The maximum number of services to return. The response may - * contain less than the maximum number. If unspecified, no more than 500 - * services are returned. The maximum value is 1000; values above 1000 are - * changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @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 Array of {@link protos.google.cloud.metastore.v1alpha.Service|Service}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listServicesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists services in a project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the location of metastore services + * to list, in the following form: + * + * `projects/{project_number}/locations/{location_id}`. + * @param {number} [request.pageSize] + * Optional. The maximum number of services to return. The response may + * contain less than the maximum number. If unspecified, no more than 500 + * services are returned. The maximum value is 1000; values above 1000 are + * changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @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 Array of {@link protos.google.cloud.metastore.v1alpha.Service|Service}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listServicesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listServices( - request?: protos.google.cloud.metastore.v1alpha.IListServicesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.metastore.v1alpha.IService[], - protos.google.cloud.metastore.v1alpha.IListServicesRequest|null, - protos.google.cloud.metastore.v1alpha.IListServicesResponse - ]>; + request?: protos.google.cloud.metastore.v1alpha.IListServicesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.metastore.v1alpha.IService[], + protos.google.cloud.metastore.v1alpha.IListServicesRequest | null, + protos.google.cloud.metastore.v1alpha.IListServicesResponse, + ] + >; listServices( - request: protos.google.cloud.metastore.v1alpha.IListServicesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.metastore.v1alpha.IListServicesRequest, - protos.google.cloud.metastore.v1alpha.IListServicesResponse|null|undefined, - protos.google.cloud.metastore.v1alpha.IService>): void; + request: protos.google.cloud.metastore.v1alpha.IListServicesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.metastore.v1alpha.IListServicesRequest, + | protos.google.cloud.metastore.v1alpha.IListServicesResponse + | null + | undefined, + protos.google.cloud.metastore.v1alpha.IService + >, + ): void; listServices( - request: protos.google.cloud.metastore.v1alpha.IListServicesRequest, - callback: PaginationCallback< - protos.google.cloud.metastore.v1alpha.IListServicesRequest, - protos.google.cloud.metastore.v1alpha.IListServicesResponse|null|undefined, - protos.google.cloud.metastore.v1alpha.IService>): void; + request: protos.google.cloud.metastore.v1alpha.IListServicesRequest, + callback: PaginationCallback< + protos.google.cloud.metastore.v1alpha.IListServicesRequest, + | protos.google.cloud.metastore.v1alpha.IListServicesResponse + | null + | undefined, + protos.google.cloud.metastore.v1alpha.IService + >, + ): void; listServices( - request?: protos.google.cloud.metastore.v1alpha.IListServicesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.metastore.v1alpha.IListServicesRequest, - protos.google.cloud.metastore.v1alpha.IListServicesResponse|null|undefined, - protos.google.cloud.metastore.v1alpha.IService>, - callback?: PaginationCallback< + request?: protos.google.cloud.metastore.v1alpha.IListServicesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.metastore.v1alpha.IListServicesRequest, - protos.google.cloud.metastore.v1alpha.IListServicesResponse|null|undefined, - protos.google.cloud.metastore.v1alpha.IService>): - Promise<[ - protos.google.cloud.metastore.v1alpha.IService[], - protos.google.cloud.metastore.v1alpha.IListServicesRequest|null, - protos.google.cloud.metastore.v1alpha.IListServicesResponse - ]>|void { + | protos.google.cloud.metastore.v1alpha.IListServicesResponse + | null + | undefined, + protos.google.cloud.metastore.v1alpha.IService + >, + callback?: PaginationCallback< + protos.google.cloud.metastore.v1alpha.IListServicesRequest, + | protos.google.cloud.metastore.v1alpha.IListServicesResponse + | null + | undefined, + protos.google.cloud.metastore.v1alpha.IService + >, + ): Promise< + [ + protos.google.cloud.metastore.v1alpha.IService[], + protos.google.cloud.metastore.v1alpha.IListServicesRequest | null, + protos.google.cloud.metastore.v1alpha.IListServicesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.metastore.v1alpha.IListServicesRequest, - protos.google.cloud.metastore.v1alpha.IListServicesResponse|null|undefined, - protos.google.cloud.metastore.v1alpha.IService>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.metastore.v1alpha.IListServicesRequest, + | protos.google.cloud.metastore.v1alpha.IListServicesResponse + | null + | undefined, + protos.google.cloud.metastore.v1alpha.IService + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listServices values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2525,248 +3680,277 @@ export class DataprocMetastoreClient { this._log.info('listServices request %j', request); return this.innerApiCalls .listServices(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.metastore.v1alpha.IService[], - protos.google.cloud.metastore.v1alpha.IListServicesRequest|null, - protos.google.cloud.metastore.v1alpha.IListServicesResponse - ]) => { - this._log.info('listServices values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.metastore.v1alpha.IService[], + protos.google.cloud.metastore.v1alpha.IListServicesRequest | null, + protos.google.cloud.metastore.v1alpha.IListServicesResponse, + ]) => { + this._log.info('listServices values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listServices`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the location of metastore services - * to list, in the following form: - * - * `projects/{project_number}/locations/{location_id}`. - * @param {number} [request.pageSize] - * Optional. The maximum number of services to return. The response may - * contain less than the maximum number. If unspecified, no more than 500 - * services are returned. The maximum value is 1000; values above 1000 are - * changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.metastore.v1alpha.Service|Service} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listServicesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listServices`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the location of metastore services + * to list, in the following form: + * + * `projects/{project_number}/locations/{location_id}`. + * @param {number} [request.pageSize] + * Optional. The maximum number of services to return. The response may + * contain less than the maximum number. If unspecified, no more than 500 + * services are returned. The maximum value is 1000; values above 1000 are + * changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.metastore.v1alpha.Service|Service} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listServicesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listServicesStream( - request?: protos.google.cloud.metastore.v1alpha.IListServicesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.metastore.v1alpha.IListServicesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listServices']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listServices stream %j', request); return this.descriptors.page.listServices.createStream( this.innerApiCalls.listServices as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listServices`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the location of metastore services - * to list, in the following form: - * - * `projects/{project_number}/locations/{location_id}`. - * @param {number} [request.pageSize] - * Optional. The maximum number of services to return. The response may - * contain less than the maximum number. If unspecified, no more than 500 - * services are returned. The maximum value is 1000; values above 1000 are - * changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.metastore.v1alpha.Service|Service}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/dataproc_metastore.list_services.js - * region_tag:metastore_v1alpha_generated_DataprocMetastore_ListServices_async - */ + /** + * Equivalent to `listServices`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the location of metastore services + * to list, in the following form: + * + * `projects/{project_number}/locations/{location_id}`. + * @param {number} [request.pageSize] + * Optional. The maximum number of services to return. The response may + * contain less than the maximum number. If unspecified, no more than 500 + * services are returned. The maximum value is 1000; values above 1000 are + * changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.metastore.v1alpha.Service|Service}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/dataproc_metastore.list_services.js + * region_tag:metastore_v1alpha_generated_DataprocMetastore_ListServices_async + */ listServicesAsync( - request?: protos.google.cloud.metastore.v1alpha.IListServicesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.metastore.v1alpha.IListServicesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listServices']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listServices iterate %j', request); return this.descriptors.page.listServices.asyncIterate( this.innerApiCalls['listServices'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists imports in a service. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the service whose metadata imports - * to list, in the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}/metadataImports`. - * @param {number} [request.pageSize] - * Optional. The maximum number of imports to return. The response may contain - * less than the maximum number. If unspecified, no more than 500 imports are - * returned. The maximum value is 1000; values above 1000 are changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @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 Array of {@link protos.google.cloud.metastore.v1alpha.MetadataImport|MetadataImport}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listMetadataImportsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists imports in a service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the service whose metadata imports + * to list, in the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}/metadataImports`. + * @param {number} [request.pageSize] + * Optional. The maximum number of imports to return. The response may contain + * less than the maximum number. If unspecified, no more than 500 imports are + * returned. The maximum value is 1000; values above 1000 are changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @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 Array of {@link protos.google.cloud.metastore.v1alpha.MetadataImport|MetadataImport}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listMetadataImportsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMetadataImports( - request?: protos.google.cloud.metastore.v1alpha.IListMetadataImportsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.metastore.v1alpha.IMetadataImport[], - protos.google.cloud.metastore.v1alpha.IListMetadataImportsRequest|null, - protos.google.cloud.metastore.v1alpha.IListMetadataImportsResponse - ]>; + request?: protos.google.cloud.metastore.v1alpha.IListMetadataImportsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.metastore.v1alpha.IMetadataImport[], + protos.google.cloud.metastore.v1alpha.IListMetadataImportsRequest | null, + protos.google.cloud.metastore.v1alpha.IListMetadataImportsResponse, + ] + >; listMetadataImports( - request: protos.google.cloud.metastore.v1alpha.IListMetadataImportsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.metastore.v1alpha.IListMetadataImportsRequest, - protos.google.cloud.metastore.v1alpha.IListMetadataImportsResponse|null|undefined, - protos.google.cloud.metastore.v1alpha.IMetadataImport>): void; + request: protos.google.cloud.metastore.v1alpha.IListMetadataImportsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.metastore.v1alpha.IListMetadataImportsRequest, + | protos.google.cloud.metastore.v1alpha.IListMetadataImportsResponse + | null + | undefined, + protos.google.cloud.metastore.v1alpha.IMetadataImport + >, + ): void; listMetadataImports( - request: protos.google.cloud.metastore.v1alpha.IListMetadataImportsRequest, - callback: PaginationCallback< - protos.google.cloud.metastore.v1alpha.IListMetadataImportsRequest, - protos.google.cloud.metastore.v1alpha.IListMetadataImportsResponse|null|undefined, - protos.google.cloud.metastore.v1alpha.IMetadataImport>): void; + request: protos.google.cloud.metastore.v1alpha.IListMetadataImportsRequest, + callback: PaginationCallback< + protos.google.cloud.metastore.v1alpha.IListMetadataImportsRequest, + | protos.google.cloud.metastore.v1alpha.IListMetadataImportsResponse + | null + | undefined, + protos.google.cloud.metastore.v1alpha.IMetadataImport + >, + ): void; listMetadataImports( - request?: protos.google.cloud.metastore.v1alpha.IListMetadataImportsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.metastore.v1alpha.IListMetadataImportsRequest, - protos.google.cloud.metastore.v1alpha.IListMetadataImportsResponse|null|undefined, - protos.google.cloud.metastore.v1alpha.IMetadataImport>, - callback?: PaginationCallback< + request?: protos.google.cloud.metastore.v1alpha.IListMetadataImportsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.metastore.v1alpha.IListMetadataImportsRequest, - protos.google.cloud.metastore.v1alpha.IListMetadataImportsResponse|null|undefined, - protos.google.cloud.metastore.v1alpha.IMetadataImport>): - Promise<[ - protos.google.cloud.metastore.v1alpha.IMetadataImport[], - protos.google.cloud.metastore.v1alpha.IListMetadataImportsRequest|null, - protos.google.cloud.metastore.v1alpha.IListMetadataImportsResponse - ]>|void { + | protos.google.cloud.metastore.v1alpha.IListMetadataImportsResponse + | null + | undefined, + protos.google.cloud.metastore.v1alpha.IMetadataImport + >, + callback?: PaginationCallback< + protos.google.cloud.metastore.v1alpha.IListMetadataImportsRequest, + | protos.google.cloud.metastore.v1alpha.IListMetadataImportsResponse + | null + | undefined, + protos.google.cloud.metastore.v1alpha.IMetadataImport + >, + ): Promise< + [ + protos.google.cloud.metastore.v1alpha.IMetadataImport[], + protos.google.cloud.metastore.v1alpha.IListMetadataImportsRequest | null, + protos.google.cloud.metastore.v1alpha.IListMetadataImportsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.metastore.v1alpha.IListMetadataImportsRequest, - protos.google.cloud.metastore.v1alpha.IListMetadataImportsResponse|null|undefined, - protos.google.cloud.metastore.v1alpha.IMetadataImport>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.metastore.v1alpha.IListMetadataImportsRequest, + | protos.google.cloud.metastore.v1alpha.IListMetadataImportsResponse + | null + | undefined, + protos.google.cloud.metastore.v1alpha.IMetadataImport + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listMetadataImports values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2775,246 +3959,275 @@ export class DataprocMetastoreClient { this._log.info('listMetadataImports request %j', request); return this.innerApiCalls .listMetadataImports(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.metastore.v1alpha.IMetadataImport[], - protos.google.cloud.metastore.v1alpha.IListMetadataImportsRequest|null, - protos.google.cloud.metastore.v1alpha.IListMetadataImportsResponse - ]) => { - this._log.info('listMetadataImports values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.metastore.v1alpha.IMetadataImport[], + protos.google.cloud.metastore.v1alpha.IListMetadataImportsRequest | null, + protos.google.cloud.metastore.v1alpha.IListMetadataImportsResponse, + ]) => { + this._log.info('listMetadataImports values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listMetadataImports`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the service whose metadata imports - * to list, in the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}/metadataImports`. - * @param {number} [request.pageSize] - * Optional. The maximum number of imports to return. The response may contain - * less than the maximum number. If unspecified, no more than 500 imports are - * returned. The maximum value is 1000; values above 1000 are changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.metastore.v1alpha.MetadataImport|MetadataImport} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listMetadataImportsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listMetadataImports`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the service whose metadata imports + * to list, in the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}/metadataImports`. + * @param {number} [request.pageSize] + * Optional. The maximum number of imports to return. The response may contain + * less than the maximum number. If unspecified, no more than 500 imports are + * returned. The maximum value is 1000; values above 1000 are changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.metastore.v1alpha.MetadataImport|MetadataImport} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listMetadataImportsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMetadataImportsStream( - request?: protos.google.cloud.metastore.v1alpha.IListMetadataImportsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.metastore.v1alpha.IListMetadataImportsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listMetadataImports']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listMetadataImports stream %j', request); return this.descriptors.page.listMetadataImports.createStream( this.innerApiCalls.listMetadataImports as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listMetadataImports`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the service whose metadata imports - * to list, in the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}/metadataImports`. - * @param {number} [request.pageSize] - * Optional. The maximum number of imports to return. The response may contain - * less than the maximum number. If unspecified, no more than 500 imports are - * returned. The maximum value is 1000; values above 1000 are changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.metastore.v1alpha.MetadataImport|MetadataImport}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/dataproc_metastore.list_metadata_imports.js - * region_tag:metastore_v1alpha_generated_DataprocMetastore_ListMetadataImports_async - */ + /** + * Equivalent to `listMetadataImports`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the service whose metadata imports + * to list, in the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}/metadataImports`. + * @param {number} [request.pageSize] + * Optional. The maximum number of imports to return. The response may contain + * less than the maximum number. If unspecified, no more than 500 imports are + * returned. The maximum value is 1000; values above 1000 are changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.metastore.v1alpha.MetadataImport|MetadataImport}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/dataproc_metastore.list_metadata_imports.js + * region_tag:metastore_v1alpha_generated_DataprocMetastore_ListMetadataImports_async + */ listMetadataImportsAsync( - request?: protos.google.cloud.metastore.v1alpha.IListMetadataImportsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.metastore.v1alpha.IListMetadataImportsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listMetadataImports']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listMetadataImports iterate %j', request); return this.descriptors.page.listMetadataImports.asyncIterate( this.innerApiCalls['listMetadataImports'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists backups in a service. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the service whose backups to - * list, in the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}/backups`. - * @param {number} [request.pageSize] - * Optional. The maximum number of backups to return. The response may contain - * less than the maximum number. If unspecified, no more than 500 backups are - * returned. The maximum value is 1000; values above 1000 are changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @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 Array of {@link protos.google.cloud.metastore.v1alpha.Backup|Backup}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listBackupsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists backups in a service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the service whose backups to + * list, in the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}/backups`. + * @param {number} [request.pageSize] + * Optional. The maximum number of backups to return. The response may contain + * less than the maximum number. If unspecified, no more than 500 backups are + * returned. The maximum value is 1000; values above 1000 are changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @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 Array of {@link protos.google.cloud.metastore.v1alpha.Backup|Backup}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listBackupsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listBackups( - request?: protos.google.cloud.metastore.v1alpha.IListBackupsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.metastore.v1alpha.IBackup[], - protos.google.cloud.metastore.v1alpha.IListBackupsRequest|null, - protos.google.cloud.metastore.v1alpha.IListBackupsResponse - ]>; + request?: protos.google.cloud.metastore.v1alpha.IListBackupsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.metastore.v1alpha.IBackup[], + protos.google.cloud.metastore.v1alpha.IListBackupsRequest | null, + protos.google.cloud.metastore.v1alpha.IListBackupsResponse, + ] + >; listBackups( - request: protos.google.cloud.metastore.v1alpha.IListBackupsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.metastore.v1alpha.IListBackupsRequest, - protos.google.cloud.metastore.v1alpha.IListBackupsResponse|null|undefined, - protos.google.cloud.metastore.v1alpha.IBackup>): void; + request: protos.google.cloud.metastore.v1alpha.IListBackupsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.metastore.v1alpha.IListBackupsRequest, + | protos.google.cloud.metastore.v1alpha.IListBackupsResponse + | null + | undefined, + protos.google.cloud.metastore.v1alpha.IBackup + >, + ): void; listBackups( - request: protos.google.cloud.metastore.v1alpha.IListBackupsRequest, - callback: PaginationCallback< - protos.google.cloud.metastore.v1alpha.IListBackupsRequest, - protos.google.cloud.metastore.v1alpha.IListBackupsResponse|null|undefined, - protos.google.cloud.metastore.v1alpha.IBackup>): void; + request: protos.google.cloud.metastore.v1alpha.IListBackupsRequest, + callback: PaginationCallback< + protos.google.cloud.metastore.v1alpha.IListBackupsRequest, + | protos.google.cloud.metastore.v1alpha.IListBackupsResponse + | null + | undefined, + protos.google.cloud.metastore.v1alpha.IBackup + >, + ): void; listBackups( - request?: protos.google.cloud.metastore.v1alpha.IListBackupsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.metastore.v1alpha.IListBackupsRequest, - protos.google.cloud.metastore.v1alpha.IListBackupsResponse|null|undefined, - protos.google.cloud.metastore.v1alpha.IBackup>, - callback?: PaginationCallback< + request?: protos.google.cloud.metastore.v1alpha.IListBackupsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.metastore.v1alpha.IListBackupsRequest, - protos.google.cloud.metastore.v1alpha.IListBackupsResponse|null|undefined, - protos.google.cloud.metastore.v1alpha.IBackup>): - Promise<[ - protos.google.cloud.metastore.v1alpha.IBackup[], - protos.google.cloud.metastore.v1alpha.IListBackupsRequest|null, - protos.google.cloud.metastore.v1alpha.IListBackupsResponse - ]>|void { + | protos.google.cloud.metastore.v1alpha.IListBackupsResponse + | null + | undefined, + protos.google.cloud.metastore.v1alpha.IBackup + >, + callback?: PaginationCallback< + protos.google.cloud.metastore.v1alpha.IListBackupsRequest, + | protos.google.cloud.metastore.v1alpha.IListBackupsResponse + | null + | undefined, + protos.google.cloud.metastore.v1alpha.IBackup + >, + ): Promise< + [ + protos.google.cloud.metastore.v1alpha.IBackup[], + protos.google.cloud.metastore.v1alpha.IListBackupsRequest | null, + protos.google.cloud.metastore.v1alpha.IListBackupsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.metastore.v1alpha.IListBackupsRequest, - protos.google.cloud.metastore.v1alpha.IListBackupsResponse|null|undefined, - protos.google.cloud.metastore.v1alpha.IBackup>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.metastore.v1alpha.IListBackupsRequest, + | protos.google.cloud.metastore.v1alpha.IListBackupsResponse + | null + | undefined, + protos.google.cloud.metastore.v1alpha.IBackup + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listBackups values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -3023,171 +4236,175 @@ export class DataprocMetastoreClient { this._log.info('listBackups request %j', request); return this.innerApiCalls .listBackups(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.metastore.v1alpha.IBackup[], - protos.google.cloud.metastore.v1alpha.IListBackupsRequest|null, - protos.google.cloud.metastore.v1alpha.IListBackupsResponse - ]) => { - this._log.info('listBackups values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.metastore.v1alpha.IBackup[], + protos.google.cloud.metastore.v1alpha.IListBackupsRequest | null, + protos.google.cloud.metastore.v1alpha.IListBackupsResponse, + ]) => { + this._log.info('listBackups values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listBackups`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the service whose backups to - * list, in the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}/backups`. - * @param {number} [request.pageSize] - * Optional. The maximum number of backups to return. The response may contain - * less than the maximum number. If unspecified, no more than 500 backups are - * returned. The maximum value is 1000; values above 1000 are changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.metastore.v1alpha.Backup|Backup} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listBackupsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listBackups`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the service whose backups to + * list, in the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}/backups`. + * @param {number} [request.pageSize] + * Optional. The maximum number of backups to return. The response may contain + * less than the maximum number. If unspecified, no more than 500 backups are + * returned. The maximum value is 1000; values above 1000 are changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.metastore.v1alpha.Backup|Backup} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listBackupsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listBackupsStream( - request?: protos.google.cloud.metastore.v1alpha.IListBackupsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.metastore.v1alpha.IListBackupsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listBackups']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listBackups stream %j', request); return this.descriptors.page.listBackups.createStream( this.innerApiCalls.listBackups as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listBackups`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the service whose backups to - * list, in the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}/backups`. - * @param {number} [request.pageSize] - * Optional. The maximum number of backups to return. The response may contain - * less than the maximum number. If unspecified, no more than 500 backups are - * returned. The maximum value is 1000; values above 1000 are changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.metastore.v1alpha.Backup|Backup}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/dataproc_metastore.list_backups.js - * region_tag:metastore_v1alpha_generated_DataprocMetastore_ListBackups_async - */ + /** + * Equivalent to `listBackups`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the service whose backups to + * list, in the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}/backups`. + * @param {number} [request.pageSize] + * Optional. The maximum number of backups to return. The response may contain + * less than the maximum number. If unspecified, no more than 500 backups are + * returned. The maximum value is 1000; values above 1000 are changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * {@link protos.google.cloud.metastore.v1alpha.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.metastore.v1alpha.Backup|Backup}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/dataproc_metastore.list_backups.js + * region_tag:metastore_v1alpha_generated_DataprocMetastore_ListBackups_async + */ listBackupsAsync( - request?: protos.google.cloud.metastore.v1alpha.IListBackupsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.metastore.v1alpha.IListBackupsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listBackups']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listBackups iterate %j', request); return this.descriptors.page.listBackups.asyncIterate( this.innerApiCalls['listBackups'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -3201,40 +4418,40 @@ export class DataprocMetastoreClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -3248,41 +4465,41 @@ export class DataprocMetastoreClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -3296,12 +4513,12 @@ export class DataprocMetastoreClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -3336,12 +4553,11 @@ export class DataprocMetastoreClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -3374,12 +4590,12 @@ export class DataprocMetastoreClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -3422,22 +4638,22 @@ export class DataprocMetastoreClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -3472,15 +4688,15 @@ export class DataprocMetastoreClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - 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 ?? '', - }); + 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 ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -3514,7 +4730,7 @@ export class DataprocMetastoreClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -3527,25 +4743,24 @@ export class DataprocMetastoreClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -3584,22 +4799,22 @@ export class DataprocMetastoreClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -3616,7 +4831,12 @@ export class DataprocMetastoreClient { * @param {string} backup * @returns {string} Resource name string. */ - backupPath(project:string,location:string,service:string,backup:string) { + backupPath( + project: string, + location: string, + service: string, + backup: string, + ) { return this.pathTemplates.backupPathTemplate.render({ project: project, location: location, @@ -3677,7 +4897,7 @@ export class DataprocMetastoreClient { * @param {string} federation * @returns {string} Resource name string. */ - federationPath(project:string,location:string,federation:string) { + federationPath(project: string, location: string, federation: string) { return this.pathTemplates.federationPathTemplate.render({ project: project, location: location, @@ -3693,7 +4913,8 @@ export class DataprocMetastoreClient { * @returns {string} A string representing the project. */ matchProjectFromFederationName(federationName: string) { - return this.pathTemplates.federationPathTemplate.match(federationName).project; + return this.pathTemplates.federationPathTemplate.match(federationName) + .project; } /** @@ -3704,7 +4925,8 @@ export class DataprocMetastoreClient { * @returns {string} A string representing the location. */ matchLocationFromFederationName(federationName: string) { - return this.pathTemplates.federationPathTemplate.match(federationName).location; + return this.pathTemplates.federationPathTemplate.match(federationName) + .location; } /** @@ -3715,7 +4937,8 @@ export class DataprocMetastoreClient { * @returns {string} A string representing the federation. */ matchFederationFromFederationName(federationName: string) { - return this.pathTemplates.federationPathTemplate.match(federationName).federation; + return this.pathTemplates.federationPathTemplate.match(federationName) + .federation; } /** @@ -3726,7 +4949,7 @@ export class DataprocMetastoreClient { * @param {string} lake * @returns {string} Resource name string. */ - lakePath(project:string,location:string,lake:string) { + lakePath(project: string, location: string, lake: string) { return this.pathTemplates.lakePathTemplate.render({ project: project, location: location, @@ -3774,7 +4997,7 @@ export class DataprocMetastoreClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -3812,7 +5035,12 @@ export class DataprocMetastoreClient { * @param {string} metadata_import * @returns {string} Resource name string. */ - metadataImportPath(project:string,location:string,service:string,metadataImport:string) { + metadataImportPath( + project: string, + location: string, + service: string, + metadataImport: string, + ) { return this.pathTemplates.metadataImportPathTemplate.render({ project: project, location: location, @@ -3829,7 +5057,9 @@ export class DataprocMetastoreClient { * @returns {string} A string representing the project. */ matchProjectFromMetadataImportName(metadataImportName: string) { - return this.pathTemplates.metadataImportPathTemplate.match(metadataImportName).project; + return this.pathTemplates.metadataImportPathTemplate.match( + metadataImportName, + ).project; } /** @@ -3840,7 +5070,9 @@ export class DataprocMetastoreClient { * @returns {string} A string representing the location. */ matchLocationFromMetadataImportName(metadataImportName: string) { - return this.pathTemplates.metadataImportPathTemplate.match(metadataImportName).location; + return this.pathTemplates.metadataImportPathTemplate.match( + metadataImportName, + ).location; } /** @@ -3851,7 +5083,9 @@ export class DataprocMetastoreClient { * @returns {string} A string representing the service. */ matchServiceFromMetadataImportName(metadataImportName: string) { - return this.pathTemplates.metadataImportPathTemplate.match(metadataImportName).service; + return this.pathTemplates.metadataImportPathTemplate.match( + metadataImportName, + ).service; } /** @@ -3862,7 +5096,9 @@ export class DataprocMetastoreClient { * @returns {string} A string representing the metadata_import. */ matchMetadataImportFromMetadataImportName(metadataImportName: string) { - return this.pathTemplates.metadataImportPathTemplate.match(metadataImportName).metadata_import; + return this.pathTemplates.metadataImportPathTemplate.match( + metadataImportName, + ).metadata_import; } /** @@ -3872,7 +5108,7 @@ export class DataprocMetastoreClient { * @param {string} network * @returns {string} Resource name string. */ - networkPath(project:string,network:string) { + networkPath(project: string, network: string) { return this.pathTemplates.networkPathTemplate.render({ project: project, network: network, @@ -3907,7 +5143,7 @@ export class DataprocMetastoreClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -3932,7 +5168,7 @@ export class DataprocMetastoreClient { * @param {string} service * @returns {string} Resource name string. */ - servicePath(project:string,location:string,service:string) { + servicePath(project: string, location: string, service: string) { return this.pathTemplates.servicePathTemplate.render({ project: project, location: location, @@ -3981,15 +5217,19 @@ export class DataprocMetastoreClient { */ close(): Promise { if (this.dataprocMetastoreStub && !this._terminated) { - return this.dataprocMetastoreStub.then(stub => { + return this.dataprocMetastoreStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-metastore/src/v1alpha/dataproc_metastore_federation_client.ts b/packages/google-cloud-metastore/src/v1alpha/dataproc_metastore_federation_client.ts index 17c4a13418d1..228e319b5b29 100644 --- a/packages/google-cloud-metastore/src/v1alpha/dataproc_metastore_federation_client.ts +++ b/packages/google-cloud-metastore/src/v1alpha/dataproc_metastore_federation_client.ts @@ -18,11 +18,24 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -56,7 +69,7 @@ export class DataprocMetastoreFederationClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('dataproc-metastore'); @@ -69,12 +82,12 @@ export class DataprocMetastoreFederationClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - dataprocMetastoreFederationStub?: Promise<{[name: string]: Function}>; + dataprocMetastoreFederationStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of DataprocMetastoreFederationClient. @@ -115,21 +128,43 @@ export class DataprocMetastoreFederationClient { * const client = new DataprocMetastoreFederationClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof DataprocMetastoreFederationClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + const staticMembers = this + .constructor as typeof DataprocMetastoreFederationClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'metastore.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -154,7 +189,7 @@ export class DataprocMetastoreFederationClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -167,18 +202,14 @@ export class DataprocMetastoreFederationClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -200,22 +231,22 @@ export class DataprocMetastoreFederationClient { // Create useful helper objects for these. this.pathTemplates = { backupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}/backups/{backup}' + 'projects/{project}/locations/{location}/services/{service}/backups/{backup}', ), federationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/federations/{federation}' + 'projects/{project}/locations/{location}/federations/{federation}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), metadataImportPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}/metadataImports/{metadata_import}' + 'projects/{project}/locations/{location}/services/{service}/metadataImports/{metadata_import}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), servicePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}' + 'projects/{project}/locations/{location}/services/{service}', ), }; @@ -223,8 +254,11 @@ export class DataprocMetastoreFederationClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listFederations: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'federations') + listFederations: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'federations', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -233,48 +267,149 @@ export class DataprocMetastoreFederationClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1alpha/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1alpha/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1alpha/{resource=projects/*/locations/*/services/*}:getIamPolicy',additional_bindings: [{get: '/v1alpha/{resource=projects/*/locations/*/services/*/backups/*}:getIamPolicy',},{get: '/v1alpha/{resource=projects/*/locations/*/services/*/databases/*}:getIamPolicy',},{get: '/v1alpha/{resource=projects/*/locations/*/services/*/databases/*/tables/*}:getIamPolicy',},{get: '/v1alpha/{resource=projects/*/locations/*/federations/*}:getIamPolicy',}], - },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1alpha/{resource=projects/*/locations/*/services/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1alpha/{resource=projects/*/locations/*/services/*/backups/*}:setIamPolicy',body: '*',},{post: '/v1alpha/{resource=projects/*/locations/*/services/*/databases/*}:setIamPolicy',body: '*',},{post: '/v1alpha/{resource=projects/*/locations/*/services/*/databases/*/tables/*}:setIamPolicy',body: '*',},{post: '/v1alpha/{resource=projects/*/locations/*/federations/*}:setIamPolicy',body: '*',}], - },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1alpha/{resource=projects/*/locations/*/services/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1alpha/{resource=projects/*/locations/*/services/*/backups/*}:testIamPermissions',body: '*',},{post: '/v1alpha/{resource=projects/*/locations/*/services/*/databases/*}:testIamPermissions',body: '*',},{post: '/v1alpha/{resource=projects/*/locations/*/services/*/databases/*/tables/*}:testIamPermissions',body: '*',},{post: '/v1alpha/{resource=projects/*/locations/*/federations/*}:testIamPermissions',body: '*',}], - },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1alpha/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1alpha/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1alpha/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1alpha/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1alpha/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1alpha/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1alpha/{resource=projects/*/locations/*/services/*}:getIamPolicy', + additional_bindings: [ + { + get: '/v1alpha/{resource=projects/*/locations/*/services/*/backups/*}:getIamPolicy', + }, + { + get: '/v1alpha/{resource=projects/*/locations/*/services/*/databases/*}:getIamPolicy', + }, + { + get: '/v1alpha/{resource=projects/*/locations/*/services/*/databases/*/tables/*}:getIamPolicy', + }, + { + get: '/v1alpha/{resource=projects/*/locations/*/federations/*}:getIamPolicy', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1alpha/{resource=projects/*/locations/*/services/*}:setIamPolicy', + body: '*', + additional_bindings: [ + { + post: '/v1alpha/{resource=projects/*/locations/*/services/*/backups/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1alpha/{resource=projects/*/locations/*/services/*/databases/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1alpha/{resource=projects/*/locations/*/services/*/databases/*/tables/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1alpha/{resource=projects/*/locations/*/federations/*}:setIamPolicy', + body: '*', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1alpha/{resource=projects/*/locations/*/services/*}:testIamPermissions', + body: '*', + additional_bindings: [ + { + post: '/v1alpha/{resource=projects/*/locations/*/services/*/backups/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1alpha/{resource=projects/*/locations/*/services/*/databases/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1alpha/{resource=projects/*/locations/*/services/*/databases/*/tables/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1alpha/{resource=projects/*/locations/*/federations/*}:testIamPermissions', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1alpha/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1alpha/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1alpha/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1alpha/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createFederationResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1alpha.Federation') as gax.protobuf.Type; + '.google.cloud.metastore.v1alpha.Federation', + ) as gax.protobuf.Type; const createFederationMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1alpha.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1alpha.OperationMetadata', + ) as gax.protobuf.Type; const updateFederationResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1alpha.Federation') as gax.protobuf.Type; + '.google.cloud.metastore.v1alpha.Federation', + ) as gax.protobuf.Type; const updateFederationMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1alpha.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1alpha.OperationMetadata', + ) as gax.protobuf.Type; const deleteFederationResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteFederationMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1alpha.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1alpha.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createFederation: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createFederationResponse.decode.bind(createFederationResponse), - createFederationMetadata.decode.bind(createFederationMetadata)), + createFederationMetadata.decode.bind(createFederationMetadata), + ), updateFederation: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateFederationResponse.decode.bind(updateFederationResponse), - updateFederationMetadata.decode.bind(updateFederationMetadata)), + updateFederationMetadata.decode.bind(updateFederationMetadata), + ), deleteFederation: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteFederationResponse.decode.bind(deleteFederationResponse), - deleteFederationMetadata.decode.bind(deleteFederationMetadata)) + deleteFederationMetadata.decode.bind(deleteFederationMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.metastore.v1alpha.DataprocMetastoreFederation', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.metastore.v1alpha.DataprocMetastoreFederation', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -305,28 +440,40 @@ export class DataprocMetastoreFederationClient { // Put together the "service stub" for // google.cloud.metastore.v1alpha.DataprocMetastoreFederation. this.dataprocMetastoreFederationStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.metastore.v1alpha.DataprocMetastoreFederation') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.metastore.v1alpha.DataprocMetastoreFederation, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.metastore.v1alpha.DataprocMetastoreFederation', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.metastore.v1alpha + .DataprocMetastoreFederation, + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const dataprocMetastoreFederationStubMethods = - ['listFederations', 'getFederation', 'createFederation', 'updateFederation', 'deleteFederation']; + const dataprocMetastoreFederationStubMethods = [ + 'listFederations', + 'getFederation', + 'createFederation', + 'updateFederation', + 'deleteFederation', + ]; for (const methodName of dataprocMetastoreFederationStubMethods) { const callPromise = this.dataprocMetastoreFederationStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -336,7 +483,7 @@ export class DataprocMetastoreFederationClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -351,8 +498,14 @@ export class DataprocMetastoreFederationClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'metastore.googleapis.com'; } @@ -363,8 +516,14 @@ export class DataprocMetastoreFederationClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'metastore.googleapis.com'; } @@ -395,9 +554,7 @@ export class DataprocMetastoreFederationClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -406,8 +563,9 @@ export class DataprocMetastoreFederationClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -418,589 +576,843 @@ export class DataprocMetastoreFederationClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets the details of a single federation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The relative resource name of the metastore federation to - * retrieve, in the following form: - * - * `projects/{project_number}/locations/{location_id}/federations/{federation_id}`. - * @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 {@link protos.google.cloud.metastore.v1alpha.Federation|Federation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/dataproc_metastore_federation.get_federation.js - * region_tag:metastore_v1alpha_generated_DataprocMetastoreFederation_GetFederation_async - */ + /** + * Gets the details of a single federation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The relative resource name of the metastore federation to + * retrieve, in the following form: + * + * `projects/{project_number}/locations/{location_id}/federations/{federation_id}`. + * @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 {@link protos.google.cloud.metastore.v1alpha.Federation|Federation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/dataproc_metastore_federation.get_federation.js + * region_tag:metastore_v1alpha_generated_DataprocMetastoreFederation_GetFederation_async + */ getFederation( - request?: protos.google.cloud.metastore.v1alpha.IGetFederationRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.metastore.v1alpha.IFederation, - protos.google.cloud.metastore.v1alpha.IGetFederationRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1alpha.IGetFederationRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.metastore.v1alpha.IFederation, + protos.google.cloud.metastore.v1alpha.IGetFederationRequest | undefined, + {} | undefined, + ] + >; getFederation( - request: protos.google.cloud.metastore.v1alpha.IGetFederationRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.metastore.v1alpha.IFederation, - protos.google.cloud.metastore.v1alpha.IGetFederationRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IGetFederationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.metastore.v1alpha.IFederation, + | protos.google.cloud.metastore.v1alpha.IGetFederationRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getFederation( - request: protos.google.cloud.metastore.v1alpha.IGetFederationRequest, - callback: Callback< - protos.google.cloud.metastore.v1alpha.IFederation, - protos.google.cloud.metastore.v1alpha.IGetFederationRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IGetFederationRequest, + callback: Callback< + protos.google.cloud.metastore.v1alpha.IFederation, + | protos.google.cloud.metastore.v1alpha.IGetFederationRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getFederation( - request?: protos.google.cloud.metastore.v1alpha.IGetFederationRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.metastore.v1alpha.IFederation, - protos.google.cloud.metastore.v1alpha.IGetFederationRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.metastore.v1alpha.IGetFederationRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.metastore.v1alpha.IFederation, - protos.google.cloud.metastore.v1alpha.IGetFederationRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.metastore.v1alpha.IFederation, - protos.google.cloud.metastore.v1alpha.IGetFederationRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.metastore.v1alpha.IGetFederationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.metastore.v1alpha.IFederation, + | protos.google.cloud.metastore.v1alpha.IGetFederationRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.metastore.v1alpha.IFederation, + protos.google.cloud.metastore.v1alpha.IGetFederationRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getFederation request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.metastore.v1alpha.IFederation, - protos.google.cloud.metastore.v1alpha.IGetFederationRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.metastore.v1alpha.IFederation, + | protos.google.cloud.metastore.v1alpha.IGetFederationRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getFederation response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getFederation(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.metastore.v1alpha.IFederation, - protos.google.cloud.metastore.v1alpha.IGetFederationRequest|undefined, - {}|undefined - ]) => { - this._log.info('getFederation response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getFederation(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.metastore.v1alpha.IFederation, + ( + | protos.google.cloud.metastore.v1alpha.IGetFederationRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getFederation response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a metastore federation in a project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the location in which to create a - * federation service, in the following form: - * - * `projects/{project_number}/locations/{location_id}`. - * @param {string} request.federationId - * Required. The ID of the metastore federation, which is used as the final - * component of the metastore federation's name. - * - * This value must be between 2 and 63 characters long inclusive, begin with a - * letter, end with a letter or number, and consist of alpha-numeric - * ASCII characters or hyphens. - * @param {google.cloud.metastore.v1alpha.Federation} request.federation - * Required. The Metastore Federation to create. The `name` field is - * ignored. The ID of the created metastore federation must be - * provided in the request's `federation_id` field. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/v1alpha/dataproc_metastore_federation.create_federation.js - * region_tag:metastore_v1alpha_generated_DataprocMetastoreFederation_CreateFederation_async - */ + /** + * Creates a metastore federation in a project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the location in which to create a + * federation service, in the following form: + * + * `projects/{project_number}/locations/{location_id}`. + * @param {string} request.federationId + * Required. The ID of the metastore federation, which is used as the final + * component of the metastore federation's name. + * + * This value must be between 2 and 63 characters long inclusive, begin with a + * letter, end with a letter or number, and consist of alpha-numeric + * ASCII characters or hyphens. + * @param {google.cloud.metastore.v1alpha.Federation} request.federation + * Required. The Metastore Federation to create. The `name` field is + * ignored. The ID of the created metastore federation must be + * provided in the request's `federation_id` field. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/v1alpha/dataproc_metastore_federation.create_federation.js + * region_tag:metastore_v1alpha_generated_DataprocMetastoreFederation_CreateFederation_async + */ createFederation( - request?: protos.google.cloud.metastore.v1alpha.ICreateFederationRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1alpha.ICreateFederationRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1alpha.IFederation, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createFederation( - request: protos.google.cloud.metastore.v1alpha.ICreateFederationRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.ICreateFederationRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IFederation, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createFederation( - request: protos.google.cloud.metastore.v1alpha.ICreateFederationRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.ICreateFederationRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IFederation, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createFederation( - request?: protos.google.cloud.metastore.v1alpha.ICreateFederationRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1alpha.ICreateFederationRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IFederation, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IFederation, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1alpha.IFederation, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IFederation, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createFederation response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createFederation request %j', request); - return this.innerApiCalls.createFederation(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createFederation response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createFederation(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1alpha.IFederation, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createFederation response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createFederation()`. - * @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/v1alpha/dataproc_metastore_federation.create_federation.js - * region_tag:metastore_v1alpha_generated_DataprocMetastoreFederation_CreateFederation_async - */ - async checkCreateFederationProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createFederation()`. + * @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/v1alpha/dataproc_metastore_federation.create_federation.js + * region_tag:metastore_v1alpha_generated_DataprocMetastoreFederation_CreateFederation_async + */ + async checkCreateFederationProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1alpha.Federation, + protos.google.cloud.metastore.v1alpha.OperationMetadata + > + > { this._log.info('createFederation long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createFederation, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createFederation, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1alpha.Federation, + protos.google.cloud.metastore.v1alpha.OperationMetadata + >; } -/** - * Updates the fields of a federation. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. A field mask used to specify the fields to be overwritten in the - * metastore federation resource by the update. - * Fields specified in the `update_mask` are relative to the resource (not - * to the full request). A field is overwritten if it is in the mask. - * @param {google.cloud.metastore.v1alpha.Federation} request.federation - * Required. The metastore federation to update. The server only merges fields - * in the service if they are specified in `update_mask`. - * - * The metastore federation's `name` field is used to identify the - * metastore service to be updated. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/v1alpha/dataproc_metastore_federation.update_federation.js - * region_tag:metastore_v1alpha_generated_DataprocMetastoreFederation_UpdateFederation_async - */ + /** + * Updates the fields of a federation. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. A field mask used to specify the fields to be overwritten in the + * metastore federation resource by the update. + * Fields specified in the `update_mask` are relative to the resource (not + * to the full request). A field is overwritten if it is in the mask. + * @param {google.cloud.metastore.v1alpha.Federation} request.federation + * Required. The metastore federation to update. The server only merges fields + * in the service if they are specified in `update_mask`. + * + * The metastore federation's `name` field is used to identify the + * metastore service to be updated. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/v1alpha/dataproc_metastore_federation.update_federation.js + * region_tag:metastore_v1alpha_generated_DataprocMetastoreFederation_UpdateFederation_async + */ updateFederation( - request?: protos.google.cloud.metastore.v1alpha.IUpdateFederationRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1alpha.IUpdateFederationRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1alpha.IFederation, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateFederation( - request: protos.google.cloud.metastore.v1alpha.IUpdateFederationRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IUpdateFederationRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IFederation, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateFederation( - request: protos.google.cloud.metastore.v1alpha.IUpdateFederationRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IUpdateFederationRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IFederation, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateFederation( - request?: protos.google.cloud.metastore.v1alpha.IUpdateFederationRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1alpha.IUpdateFederationRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IFederation, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IFederation, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1alpha.IFederation, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'federation.name': request.federation!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'federation.name': request.federation!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1alpha.IFederation, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateFederation response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateFederation request %j', request); - return this.innerApiCalls.updateFederation(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateFederation response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateFederation(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1alpha.IFederation, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateFederation response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateFederation()`. - * @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/v1alpha/dataproc_metastore_federation.update_federation.js - * region_tag:metastore_v1alpha_generated_DataprocMetastoreFederation_UpdateFederation_async - */ - async checkUpdateFederationProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateFederation()`. + * @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/v1alpha/dataproc_metastore_federation.update_federation.js + * region_tag:metastore_v1alpha_generated_DataprocMetastoreFederation_UpdateFederation_async + */ + async checkUpdateFederationProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1alpha.Federation, + protos.google.cloud.metastore.v1alpha.OperationMetadata + > + > { this._log.info('updateFederation long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateFederation, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateFederation, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1alpha.Federation, + protos.google.cloud.metastore.v1alpha.OperationMetadata + >; } -/** - * Deletes a single federation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The relative resource name of the metastore federation to delete, - * in the following form: - * - * `projects/{project_number}/locations/{location_id}/federations/{federation_id}`. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/v1alpha/dataproc_metastore_federation.delete_federation.js - * region_tag:metastore_v1alpha_generated_DataprocMetastoreFederation_DeleteFederation_async - */ + /** + * Deletes a single federation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The relative resource name of the metastore federation to delete, + * in the following form: + * + * `projects/{project_number}/locations/{location_id}/federations/{federation_id}`. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/v1alpha/dataproc_metastore_federation.delete_federation.js + * region_tag:metastore_v1alpha_generated_DataprocMetastoreFederation_DeleteFederation_async + */ deleteFederation( - request?: protos.google.cloud.metastore.v1alpha.IDeleteFederationRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1alpha.IDeleteFederationRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteFederation( - request: protos.google.cloud.metastore.v1alpha.IDeleteFederationRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IDeleteFederationRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteFederation( - request: protos.google.cloud.metastore.v1alpha.IDeleteFederationRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1alpha.IDeleteFederationRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteFederation( - request?: protos.google.cloud.metastore.v1alpha.IDeleteFederationRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1alpha.IDeleteFederationRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteFederation response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteFederation request %j', request); - return this.innerApiCalls.deleteFederation(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteFederation response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteFederation(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteFederation response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteFederation()`. - * @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/v1alpha/dataproc_metastore_federation.delete_federation.js - * region_tag:metastore_v1alpha_generated_DataprocMetastoreFederation_DeleteFederation_async - */ - async checkDeleteFederationProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteFederation()`. + * @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/v1alpha/dataproc_metastore_federation.delete_federation.js + * region_tag:metastore_v1alpha_generated_DataprocMetastoreFederation_DeleteFederation_async + */ + async checkDeleteFederationProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.metastore.v1alpha.OperationMetadata + > + > { this._log.info('deleteFederation long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteFederation, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteFederation, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.metastore.v1alpha.OperationMetadata + >; } - /** - * Lists federations in a project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the location of metastore - * federations to list, in the following form: - * `projects/{project_number}/locations/{location_id}`. - * @param {number} [request.pageSize] - * Optional. The maximum number of federations to return. The response may - * contain less than the maximum number. If unspecified, no more than 500 - * services are returned. The maximum value is 1000; values above 1000 are - * changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous ListFederationServices - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * ListFederationServices must match the call that provided the - * page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @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 Array of {@link protos.google.cloud.metastore.v1alpha.Federation|Federation}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listFederationsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists federations in a project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the location of metastore + * federations to list, in the following form: + * `projects/{project_number}/locations/{location_id}`. + * @param {number} [request.pageSize] + * Optional. The maximum number of federations to return. The response may + * contain less than the maximum number. If unspecified, no more than 500 + * services are returned. The maximum value is 1000; values above 1000 are + * changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous ListFederationServices + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * ListFederationServices must match the call that provided the + * page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @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 Array of {@link protos.google.cloud.metastore.v1alpha.Federation|Federation}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listFederationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listFederations( - request?: protos.google.cloud.metastore.v1alpha.IListFederationsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.metastore.v1alpha.IFederation[], - protos.google.cloud.metastore.v1alpha.IListFederationsRequest|null, - protos.google.cloud.metastore.v1alpha.IListFederationsResponse - ]>; + request?: protos.google.cloud.metastore.v1alpha.IListFederationsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.metastore.v1alpha.IFederation[], + protos.google.cloud.metastore.v1alpha.IListFederationsRequest | null, + protos.google.cloud.metastore.v1alpha.IListFederationsResponse, + ] + >; listFederations( - request: protos.google.cloud.metastore.v1alpha.IListFederationsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.metastore.v1alpha.IListFederationsRequest, - protos.google.cloud.metastore.v1alpha.IListFederationsResponse|null|undefined, - protos.google.cloud.metastore.v1alpha.IFederation>): void; + request: protos.google.cloud.metastore.v1alpha.IListFederationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.metastore.v1alpha.IListFederationsRequest, + | protos.google.cloud.metastore.v1alpha.IListFederationsResponse + | null + | undefined, + protos.google.cloud.metastore.v1alpha.IFederation + >, + ): void; listFederations( - request: protos.google.cloud.metastore.v1alpha.IListFederationsRequest, - callback: PaginationCallback< - protos.google.cloud.metastore.v1alpha.IListFederationsRequest, - protos.google.cloud.metastore.v1alpha.IListFederationsResponse|null|undefined, - protos.google.cloud.metastore.v1alpha.IFederation>): void; + request: protos.google.cloud.metastore.v1alpha.IListFederationsRequest, + callback: PaginationCallback< + protos.google.cloud.metastore.v1alpha.IListFederationsRequest, + | protos.google.cloud.metastore.v1alpha.IListFederationsResponse + | null + | undefined, + protos.google.cloud.metastore.v1alpha.IFederation + >, + ): void; listFederations( - request?: protos.google.cloud.metastore.v1alpha.IListFederationsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.metastore.v1alpha.IListFederationsRequest, - protos.google.cloud.metastore.v1alpha.IListFederationsResponse|null|undefined, - protos.google.cloud.metastore.v1alpha.IFederation>, - callback?: PaginationCallback< + request?: protos.google.cloud.metastore.v1alpha.IListFederationsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.metastore.v1alpha.IListFederationsRequest, - protos.google.cloud.metastore.v1alpha.IListFederationsResponse|null|undefined, - protos.google.cloud.metastore.v1alpha.IFederation>): - Promise<[ - protos.google.cloud.metastore.v1alpha.IFederation[], - protos.google.cloud.metastore.v1alpha.IListFederationsRequest|null, - protos.google.cloud.metastore.v1alpha.IListFederationsResponse - ]>|void { + | protos.google.cloud.metastore.v1alpha.IListFederationsResponse + | null + | undefined, + protos.google.cloud.metastore.v1alpha.IFederation + >, + callback?: PaginationCallback< + protos.google.cloud.metastore.v1alpha.IListFederationsRequest, + | protos.google.cloud.metastore.v1alpha.IListFederationsResponse + | null + | undefined, + protos.google.cloud.metastore.v1alpha.IFederation + >, + ): Promise< + [ + protos.google.cloud.metastore.v1alpha.IFederation[], + protos.google.cloud.metastore.v1alpha.IListFederationsRequest | null, + protos.google.cloud.metastore.v1alpha.IListFederationsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.metastore.v1alpha.IListFederationsRequest, - protos.google.cloud.metastore.v1alpha.IListFederationsResponse|null|undefined, - protos.google.cloud.metastore.v1alpha.IFederation>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.metastore.v1alpha.IListFederationsRequest, + | protos.google.cloud.metastore.v1alpha.IListFederationsResponse + | null + | undefined, + protos.google.cloud.metastore.v1alpha.IFederation + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listFederations values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1009,169 +1421,173 @@ export class DataprocMetastoreFederationClient { this._log.info('listFederations request %j', request); return this.innerApiCalls .listFederations(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.metastore.v1alpha.IFederation[], - protos.google.cloud.metastore.v1alpha.IListFederationsRequest|null, - protos.google.cloud.metastore.v1alpha.IListFederationsResponse - ]) => { - this._log.info('listFederations values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.metastore.v1alpha.IFederation[], + protos.google.cloud.metastore.v1alpha.IListFederationsRequest | null, + protos.google.cloud.metastore.v1alpha.IListFederationsResponse, + ]) => { + this._log.info('listFederations values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listFederations`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the location of metastore - * federations to list, in the following form: - * `projects/{project_number}/locations/{location_id}`. - * @param {number} [request.pageSize] - * Optional. The maximum number of federations to return. The response may - * contain less than the maximum number. If unspecified, no more than 500 - * services are returned. The maximum value is 1000; values above 1000 are - * changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous ListFederationServices - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * ListFederationServices must match the call that provided the - * page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.metastore.v1alpha.Federation|Federation} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listFederationsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listFederations`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the location of metastore + * federations to list, in the following form: + * `projects/{project_number}/locations/{location_id}`. + * @param {number} [request.pageSize] + * Optional. The maximum number of federations to return. The response may + * contain less than the maximum number. If unspecified, no more than 500 + * services are returned. The maximum value is 1000; values above 1000 are + * changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous ListFederationServices + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * ListFederationServices must match the call that provided the + * page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.metastore.v1alpha.Federation|Federation} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listFederationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listFederationsStream( - request?: protos.google.cloud.metastore.v1alpha.IListFederationsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.metastore.v1alpha.IListFederationsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listFederations']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listFederations stream %j', request); return this.descriptors.page.listFederations.createStream( this.innerApiCalls.listFederations as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listFederations`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the location of metastore - * federations to list, in the following form: - * `projects/{project_number}/locations/{location_id}`. - * @param {number} [request.pageSize] - * Optional. The maximum number of federations to return. The response may - * contain less than the maximum number. If unspecified, no more than 500 - * services are returned. The maximum value is 1000; values above 1000 are - * changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous ListFederationServices - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * ListFederationServices must match the call that provided the - * page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.metastore.v1alpha.Federation|Federation}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/dataproc_metastore_federation.list_federations.js - * region_tag:metastore_v1alpha_generated_DataprocMetastoreFederation_ListFederations_async - */ + /** + * Equivalent to `listFederations`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the location of metastore + * federations to list, in the following form: + * `projects/{project_number}/locations/{location_id}`. + * @param {number} [request.pageSize] + * Optional. The maximum number of federations to return. The response may + * contain less than the maximum number. If unspecified, no more than 500 + * services are returned. The maximum value is 1000; values above 1000 are + * changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous ListFederationServices + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * ListFederationServices must match the call that provided the + * page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.metastore.v1alpha.Federation|Federation}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/dataproc_metastore_federation.list_federations.js + * region_tag:metastore_v1alpha_generated_DataprocMetastoreFederation_ListFederations_async + */ listFederationsAsync( - request?: protos.google.cloud.metastore.v1alpha.IListFederationsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.metastore.v1alpha.IListFederationsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listFederations']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listFederations iterate %j', request); return this.descriptors.page.listFederations.asyncIterate( this.innerApiCalls['listFederations'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -1185,40 +1601,40 @@ export class DataprocMetastoreFederationClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -1232,41 +1648,41 @@ export class DataprocMetastoreFederationClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -1280,12 +1696,12 @@ export class DataprocMetastoreFederationClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -1320,12 +1736,11 @@ export class DataprocMetastoreFederationClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -1358,12 +1773,12 @@ export class DataprocMetastoreFederationClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -1406,22 +1821,22 @@ export class DataprocMetastoreFederationClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -1456,15 +1871,15 @@ export class DataprocMetastoreFederationClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - 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 ?? '', - }); + 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 ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -1498,7 +1913,7 @@ export class DataprocMetastoreFederationClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -1511,25 +1926,24 @@ export class DataprocMetastoreFederationClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -1568,22 +1982,22 @@ export class DataprocMetastoreFederationClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -1600,7 +2014,12 @@ export class DataprocMetastoreFederationClient { * @param {string} backup * @returns {string} Resource name string. */ - backupPath(project:string,location:string,service:string,backup:string) { + backupPath( + project: string, + location: string, + service: string, + backup: string, + ) { return this.pathTemplates.backupPathTemplate.render({ project: project, location: location, @@ -1661,7 +2080,7 @@ export class DataprocMetastoreFederationClient { * @param {string} federation * @returns {string} Resource name string. */ - federationPath(project:string,location:string,federation:string) { + federationPath(project: string, location: string, federation: string) { return this.pathTemplates.federationPathTemplate.render({ project: project, location: location, @@ -1677,7 +2096,8 @@ export class DataprocMetastoreFederationClient { * @returns {string} A string representing the project. */ matchProjectFromFederationName(federationName: string) { - return this.pathTemplates.federationPathTemplate.match(federationName).project; + return this.pathTemplates.federationPathTemplate.match(federationName) + .project; } /** @@ -1688,7 +2108,8 @@ export class DataprocMetastoreFederationClient { * @returns {string} A string representing the location. */ matchLocationFromFederationName(federationName: string) { - return this.pathTemplates.federationPathTemplate.match(federationName).location; + return this.pathTemplates.federationPathTemplate.match(federationName) + .location; } /** @@ -1699,7 +2120,8 @@ export class DataprocMetastoreFederationClient { * @returns {string} A string representing the federation. */ matchFederationFromFederationName(federationName: string) { - return this.pathTemplates.federationPathTemplate.match(federationName).federation; + return this.pathTemplates.federationPathTemplate.match(federationName) + .federation; } /** @@ -1709,7 +2131,7 @@ export class DataprocMetastoreFederationClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -1747,7 +2169,12 @@ export class DataprocMetastoreFederationClient { * @param {string} metadata_import * @returns {string} Resource name string. */ - metadataImportPath(project:string,location:string,service:string,metadataImport:string) { + metadataImportPath( + project: string, + location: string, + service: string, + metadataImport: string, + ) { return this.pathTemplates.metadataImportPathTemplate.render({ project: project, location: location, @@ -1764,7 +2191,9 @@ export class DataprocMetastoreFederationClient { * @returns {string} A string representing the project. */ matchProjectFromMetadataImportName(metadataImportName: string) { - return this.pathTemplates.metadataImportPathTemplate.match(metadataImportName).project; + return this.pathTemplates.metadataImportPathTemplate.match( + metadataImportName, + ).project; } /** @@ -1775,7 +2204,9 @@ export class DataprocMetastoreFederationClient { * @returns {string} A string representing the location. */ matchLocationFromMetadataImportName(metadataImportName: string) { - return this.pathTemplates.metadataImportPathTemplate.match(metadataImportName).location; + return this.pathTemplates.metadataImportPathTemplate.match( + metadataImportName, + ).location; } /** @@ -1786,7 +2217,9 @@ export class DataprocMetastoreFederationClient { * @returns {string} A string representing the service. */ matchServiceFromMetadataImportName(metadataImportName: string) { - return this.pathTemplates.metadataImportPathTemplate.match(metadataImportName).service; + return this.pathTemplates.metadataImportPathTemplate.match( + metadataImportName, + ).service; } /** @@ -1797,7 +2230,9 @@ export class DataprocMetastoreFederationClient { * @returns {string} A string representing the metadata_import. */ matchMetadataImportFromMetadataImportName(metadataImportName: string) { - return this.pathTemplates.metadataImportPathTemplate.match(metadataImportName).metadata_import; + return this.pathTemplates.metadataImportPathTemplate.match( + metadataImportName, + ).metadata_import; } /** @@ -1806,7 +2241,7 @@ export class DataprocMetastoreFederationClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -1831,7 +2266,7 @@ export class DataprocMetastoreFederationClient { * @param {string} service * @returns {string} Resource name string. */ - servicePath(project:string,location:string,service:string) { + servicePath(project: string, location: string, service: string) { return this.pathTemplates.servicePathTemplate.render({ project: project, location: location, @@ -1880,15 +2315,19 @@ export class DataprocMetastoreFederationClient { */ close(): Promise { if (this.dataprocMetastoreFederationStub && !this._terminated) { - return this.dataprocMetastoreFederationStub.then(stub => { + return this.dataprocMetastoreFederationStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-metastore/src/v1alpha/index.ts b/packages/google-cloud-metastore/src/v1alpha/index.ts index 649f07b7cdab..a6d4bbf0896b 100644 --- a/packages/google-cloud-metastore/src/v1alpha/index.ts +++ b/packages/google-cloud-metastore/src/v1alpha/index.ts @@ -16,5 +16,5 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {DataprocMetastoreClient} from './dataproc_metastore_client'; -export {DataprocMetastoreFederationClient} from './dataproc_metastore_federation_client'; +export { DataprocMetastoreClient } from './dataproc_metastore_client'; +export { DataprocMetastoreFederationClient } from './dataproc_metastore_federation_client'; diff --git a/packages/google-cloud-metastore/src/v1beta/dataproc_metastore_client.ts b/packages/google-cloud-metastore/src/v1beta/dataproc_metastore_client.ts index 968a09525ef1..061b311fb594 100644 --- a/packages/google-cloud-metastore/src/v1beta/dataproc_metastore_client.ts +++ b/packages/google-cloud-metastore/src/v1beta/dataproc_metastore_client.ts @@ -18,11 +18,24 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -60,7 +73,7 @@ export class DataprocMetastoreClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('dataproc-metastore'); @@ -73,12 +86,12 @@ export class DataprocMetastoreClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - dataprocMetastoreStub?: Promise<{[name: string]: Function}>; + dataprocMetastoreStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of DataprocMetastoreClient. @@ -119,21 +132,42 @@ export class DataprocMetastoreClient { * const client = new DataprocMetastoreClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof DataprocMetastoreClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'metastore.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -158,7 +192,7 @@ export class DataprocMetastoreClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -171,18 +205,14 @@ export class DataprocMetastoreClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -204,28 +234,28 @@ export class DataprocMetastoreClient { // Create useful helper objects for these. this.pathTemplates = { backupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}/backups/{backup}' + 'projects/{project}/locations/{location}/services/{service}/backups/{backup}', ), federationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/federations/{federation}' + 'projects/{project}/locations/{location}/federations/{federation}', ), lakePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/lakes/{lake}' + 'projects/{project}/locations/{location}/lakes/{lake}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), metadataImportPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}/metadataImports/{metadata_import}' + 'projects/{project}/locations/{location}/services/{service}/metadataImports/{metadata_import}', ), networkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/global/networks/{network}' + 'projects/{project}/global/networks/{network}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), servicePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}' + 'projects/{project}/locations/{location}/services/{service}', ), }; @@ -233,12 +263,21 @@ export class DataprocMetastoreClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listServices: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'services'), - listMetadataImports: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'metadataImports'), - listBackups: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'backups') + listServices: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'services', + ), + listMetadataImports: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'metadataImports', + ), + listBackups: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'backups', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -247,120 +286,252 @@ export class DataprocMetastoreClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1beta/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1beta/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1beta/{resource=projects/*/locations/*/services/*}:getIamPolicy',additional_bindings: [{get: '/v1beta/{resource=projects/*/locations/*/services/*/backups/*}:getIamPolicy',},{get: '/v1beta/{resource=projects/*/locations/*/services/*/databases/*}:getIamPolicy',},{get: '/v1beta/{resource=projects/*/locations/*/services/*/databases/*/tables/*}:getIamPolicy',},{get: '/v1beta/{resource=projects/*/locations/*/federations/*}:getIamPolicy',}], - },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1beta/{resource=projects/*/locations/*/services/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1beta/{resource=projects/*/locations/*/services/*/backups/*}:setIamPolicy',body: '*',},{post: '/v1beta/{resource=projects/*/locations/*/services/*/databases/*}:setIamPolicy',body: '*',},{post: '/v1beta/{resource=projects/*/locations/*/services/*/databases/*/tables/*}:setIamPolicy',body: '*',},{post: '/v1beta/{resource=projects/*/locations/*/federations/*}:setIamPolicy',body: '*',}], - },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1beta/{resource=projects/*/locations/*/services/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1beta/{resource=projects/*/locations/*/services/*/backups/*}:testIamPermissions',body: '*',},{post: '/v1beta/{resource=projects/*/locations/*/services/*/databases/*}:testIamPermissions',body: '*',},{post: '/v1beta/{resource=projects/*/locations/*/services/*/databases/*/tables/*}:testIamPermissions',body: '*',},{post: '/v1beta/{resource=projects/*/locations/*/federations/*}:testIamPermissions',body: '*',}], - },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1beta/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1beta/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1beta/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1beta/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1beta/{resource=projects/*/locations/*/services/*}:getIamPolicy', + additional_bindings: [ + { + get: '/v1beta/{resource=projects/*/locations/*/services/*/backups/*}:getIamPolicy', + }, + { + get: '/v1beta/{resource=projects/*/locations/*/services/*/databases/*}:getIamPolicy', + }, + { + get: '/v1beta/{resource=projects/*/locations/*/services/*/databases/*/tables/*}:getIamPolicy', + }, + { + get: '/v1beta/{resource=projects/*/locations/*/federations/*}:getIamPolicy', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1beta/{resource=projects/*/locations/*/services/*}:setIamPolicy', + body: '*', + additional_bindings: [ + { + post: '/v1beta/{resource=projects/*/locations/*/services/*/backups/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1beta/{resource=projects/*/locations/*/services/*/databases/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1beta/{resource=projects/*/locations/*/services/*/databases/*/tables/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1beta/{resource=projects/*/locations/*/federations/*}:setIamPolicy', + body: '*', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1beta/{resource=projects/*/locations/*/services/*}:testIamPermissions', + body: '*', + additional_bindings: [ + { + post: '/v1beta/{resource=projects/*/locations/*/services/*/backups/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1beta/{resource=projects/*/locations/*/services/*/databases/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1beta/{resource=projects/*/locations/*/services/*/databases/*/tables/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1beta/{resource=projects/*/locations/*/federations/*}:testIamPermissions', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1beta/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1beta/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1beta/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1beta/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createServiceResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1beta.Service') as gax.protobuf.Type; + '.google.cloud.metastore.v1beta.Service', + ) as gax.protobuf.Type; const createServiceMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const updateServiceResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1beta.Service') as gax.protobuf.Type; + '.google.cloud.metastore.v1beta.Service', + ) as gax.protobuf.Type; const updateServiceMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const deleteServiceResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteServiceMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const createMetadataImportResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1beta.MetadataImport') as gax.protobuf.Type; + '.google.cloud.metastore.v1beta.MetadataImport', + ) as gax.protobuf.Type; const createMetadataImportMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const updateMetadataImportResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1beta.MetadataImport') as gax.protobuf.Type; + '.google.cloud.metastore.v1beta.MetadataImport', + ) as gax.protobuf.Type; const updateMetadataImportMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const exportMetadataResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1beta.MetadataExport') as gax.protobuf.Type; + '.google.cloud.metastore.v1beta.MetadataExport', + ) as gax.protobuf.Type; const exportMetadataMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const restoreServiceResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1beta.Restore') as gax.protobuf.Type; + '.google.cloud.metastore.v1beta.Restore', + ) as gax.protobuf.Type; const restoreServiceMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const createBackupResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1beta.Backup') as gax.protobuf.Type; + '.google.cloud.metastore.v1beta.Backup', + ) as gax.protobuf.Type; const createBackupMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const deleteBackupResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteBackupMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const queryMetadataResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1beta.QueryMetadataResponse') as gax.protobuf.Type; + '.google.cloud.metastore.v1beta.QueryMetadataResponse', + ) as gax.protobuf.Type; const queryMetadataMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const moveTableToDatabaseResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1beta.MoveTableToDatabaseResponse') as gax.protobuf.Type; + '.google.cloud.metastore.v1beta.MoveTableToDatabaseResponse', + ) as gax.protobuf.Type; const moveTableToDatabaseMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const alterMetadataResourceLocationResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1beta.AlterMetadataResourceLocationResponse') as gax.protobuf.Type; + '.google.cloud.metastore.v1beta.AlterMetadataResourceLocationResponse', + ) as gax.protobuf.Type; const alterMetadataResourceLocationMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1beta.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createService: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createServiceResponse.decode.bind(createServiceResponse), - createServiceMetadata.decode.bind(createServiceMetadata)), + createServiceMetadata.decode.bind(createServiceMetadata), + ), updateService: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateServiceResponse.decode.bind(updateServiceResponse), - updateServiceMetadata.decode.bind(updateServiceMetadata)), + updateServiceMetadata.decode.bind(updateServiceMetadata), + ), deleteService: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteServiceResponse.decode.bind(deleteServiceResponse), - deleteServiceMetadata.decode.bind(deleteServiceMetadata)), + deleteServiceMetadata.decode.bind(deleteServiceMetadata), + ), createMetadataImport: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createMetadataImportResponse.decode.bind(createMetadataImportResponse), - createMetadataImportMetadata.decode.bind(createMetadataImportMetadata)), + createMetadataImportMetadata.decode.bind(createMetadataImportMetadata), + ), updateMetadataImport: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateMetadataImportResponse.decode.bind(updateMetadataImportResponse), - updateMetadataImportMetadata.decode.bind(updateMetadataImportMetadata)), + updateMetadataImportMetadata.decode.bind(updateMetadataImportMetadata), + ), exportMetadata: new this._gaxModule.LongrunningDescriptor( this.operationsClient, exportMetadataResponse.decode.bind(exportMetadataResponse), - exportMetadataMetadata.decode.bind(exportMetadataMetadata)), + exportMetadataMetadata.decode.bind(exportMetadataMetadata), + ), restoreService: new this._gaxModule.LongrunningDescriptor( this.operationsClient, restoreServiceResponse.decode.bind(restoreServiceResponse), - restoreServiceMetadata.decode.bind(restoreServiceMetadata)), + restoreServiceMetadata.decode.bind(restoreServiceMetadata), + ), createBackup: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createBackupResponse.decode.bind(createBackupResponse), - createBackupMetadata.decode.bind(createBackupMetadata)), + createBackupMetadata.decode.bind(createBackupMetadata), + ), deleteBackup: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteBackupResponse.decode.bind(deleteBackupResponse), - deleteBackupMetadata.decode.bind(deleteBackupMetadata)), + deleteBackupMetadata.decode.bind(deleteBackupMetadata), + ), queryMetadata: new this._gaxModule.LongrunningDescriptor( this.operationsClient, queryMetadataResponse.decode.bind(queryMetadataResponse), - queryMetadataMetadata.decode.bind(queryMetadataMetadata)), + queryMetadataMetadata.decode.bind(queryMetadataMetadata), + ), moveTableToDatabase: new this._gaxModule.LongrunningDescriptor( this.operationsClient, moveTableToDatabaseResponse.decode.bind(moveTableToDatabaseResponse), - moveTableToDatabaseMetadata.decode.bind(moveTableToDatabaseMetadata)), + moveTableToDatabaseMetadata.decode.bind(moveTableToDatabaseMetadata), + ), alterMetadataResourceLocation: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - alterMetadataResourceLocationResponse.decode.bind(alterMetadataResourceLocationResponse), - alterMetadataResourceLocationMetadata.decode.bind(alterMetadataResourceLocationMetadata)) + alterMetadataResourceLocationResponse.decode.bind( + alterMetadataResourceLocationResponse, + ), + alterMetadataResourceLocationMetadata.decode.bind( + alterMetadataResourceLocationMetadata, + ), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.metastore.v1beta.DataprocMetastore', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.metastore.v1beta.DataprocMetastore', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -391,28 +562,53 @@ export class DataprocMetastoreClient { // Put together the "service stub" for // google.cloud.metastore.v1beta.DataprocMetastore. this.dataprocMetastoreStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.metastore.v1beta.DataprocMetastore') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.metastore.v1beta.DataprocMetastore', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.metastore.v1beta.DataprocMetastore, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const dataprocMetastoreStubMethods = - ['listServices', 'getService', 'createService', 'updateService', 'deleteService', 'listMetadataImports', 'getMetadataImport', 'createMetadataImport', 'updateMetadataImport', 'exportMetadata', 'restoreService', 'listBackups', 'getBackup', 'createBackup', 'deleteBackup', 'removeIamPolicy', 'queryMetadata', 'moveTableToDatabase', 'alterMetadataResourceLocation']; + const dataprocMetastoreStubMethods = [ + 'listServices', + 'getService', + 'createService', + 'updateService', + 'deleteService', + 'listMetadataImports', + 'getMetadataImport', + 'createMetadataImport', + 'updateMetadataImport', + 'exportMetadata', + 'restoreService', + 'listBackups', + 'getBackup', + 'createBackup', + 'deleteBackup', + 'removeIamPolicy', + 'queryMetadata', + 'moveTableToDatabase', + 'alterMetadataResourceLocation', + ]; for (const methodName of dataprocMetastoreStubMethods) { const callPromise = this.dataprocMetastoreStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -422,7 +618,7 @@ export class DataprocMetastoreClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -437,8 +633,14 @@ export class DataprocMetastoreClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'metastore.googleapis.com'; } @@ -449,8 +651,14 @@ export class DataprocMetastoreClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'metastore.googleapis.com'; } @@ -481,9 +689,7 @@ export class DataprocMetastoreClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -492,8 +698,9 @@ export class DataprocMetastoreClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -504,2019 +711,2960 @@ export class DataprocMetastoreClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets the details of a single service. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The relative resource name of the metastore service to retrieve, - * in the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}`. - * @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 {@link protos.google.cloud.metastore.v1beta.Service|Service}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/dataproc_metastore.get_service.js - * region_tag:metastore_v1beta_generated_DataprocMetastore_GetService_async - */ + /** + * Gets the details of a single service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The relative resource name of the metastore service to retrieve, + * in the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}`. + * @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 {@link protos.google.cloud.metastore.v1beta.Service|Service}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/dataproc_metastore.get_service.js + * region_tag:metastore_v1beta_generated_DataprocMetastore_GetService_async + */ getService( - request?: protos.google.cloud.metastore.v1beta.IGetServiceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.metastore.v1beta.IService, - protos.google.cloud.metastore.v1beta.IGetServiceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1beta.IGetServiceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.metastore.v1beta.IService, + protos.google.cloud.metastore.v1beta.IGetServiceRequest | undefined, + {} | undefined, + ] + >; getService( - request: protos.google.cloud.metastore.v1beta.IGetServiceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.metastore.v1beta.IService, - protos.google.cloud.metastore.v1beta.IGetServiceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IGetServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.metastore.v1beta.IService, + | protos.google.cloud.metastore.v1beta.IGetServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getService( - request: protos.google.cloud.metastore.v1beta.IGetServiceRequest, - callback: Callback< - protos.google.cloud.metastore.v1beta.IService, - protos.google.cloud.metastore.v1beta.IGetServiceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IGetServiceRequest, + callback: Callback< + protos.google.cloud.metastore.v1beta.IService, + | protos.google.cloud.metastore.v1beta.IGetServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getService( - request?: protos.google.cloud.metastore.v1beta.IGetServiceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.metastore.v1beta.IService, - protos.google.cloud.metastore.v1beta.IGetServiceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.metastore.v1beta.IGetServiceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.metastore.v1beta.IService, - protos.google.cloud.metastore.v1beta.IGetServiceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.metastore.v1beta.IService, - protos.google.cloud.metastore.v1beta.IGetServiceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.metastore.v1beta.IGetServiceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.metastore.v1beta.IService, + | protos.google.cloud.metastore.v1beta.IGetServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.metastore.v1beta.IService, + protos.google.cloud.metastore.v1beta.IGetServiceRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getService request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.metastore.v1beta.IService, - protos.google.cloud.metastore.v1beta.IGetServiceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.metastore.v1beta.IService, + | protos.google.cloud.metastore.v1beta.IGetServiceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getService response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getService(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.metastore.v1beta.IService, - protos.google.cloud.metastore.v1beta.IGetServiceRequest|undefined, - {}|undefined - ]) => { - this._log.info('getService response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getService(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.metastore.v1beta.IService, + protos.google.cloud.metastore.v1beta.IGetServiceRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getService response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single import. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The relative resource name of the metadata import to retrieve, in - * the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}/metadataImports/{import_id}`. - * @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 {@link protos.google.cloud.metastore.v1beta.MetadataImport|MetadataImport}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/dataproc_metastore.get_metadata_import.js - * region_tag:metastore_v1beta_generated_DataprocMetastore_GetMetadataImport_async - */ + /** + * Gets details of a single import. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The relative resource name of the metadata import to retrieve, in + * the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}/metadataImports/{import_id}`. + * @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 {@link protos.google.cloud.metastore.v1beta.MetadataImport|MetadataImport}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/dataproc_metastore.get_metadata_import.js + * region_tag:metastore_v1beta_generated_DataprocMetastore_GetMetadataImport_async + */ getMetadataImport( - request?: protos.google.cloud.metastore.v1beta.IGetMetadataImportRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.metastore.v1beta.IMetadataImport, - protos.google.cloud.metastore.v1beta.IGetMetadataImportRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1beta.IGetMetadataImportRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.metastore.v1beta.IMetadataImport, + ( + | protos.google.cloud.metastore.v1beta.IGetMetadataImportRequest + | undefined + ), + {} | undefined, + ] + >; getMetadataImport( - request: protos.google.cloud.metastore.v1beta.IGetMetadataImportRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.metastore.v1beta.IMetadataImport, - protos.google.cloud.metastore.v1beta.IGetMetadataImportRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IGetMetadataImportRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.metastore.v1beta.IMetadataImport, + | protos.google.cloud.metastore.v1beta.IGetMetadataImportRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getMetadataImport( - request: protos.google.cloud.metastore.v1beta.IGetMetadataImportRequest, - callback: Callback< - protos.google.cloud.metastore.v1beta.IMetadataImport, - protos.google.cloud.metastore.v1beta.IGetMetadataImportRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IGetMetadataImportRequest, + callback: Callback< + protos.google.cloud.metastore.v1beta.IMetadataImport, + | protos.google.cloud.metastore.v1beta.IGetMetadataImportRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getMetadataImport( - request?: protos.google.cloud.metastore.v1beta.IGetMetadataImportRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.metastore.v1beta.IMetadataImport, - protos.google.cloud.metastore.v1beta.IGetMetadataImportRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.metastore.v1beta.IGetMetadataImportRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.metastore.v1beta.IMetadataImport, - protos.google.cloud.metastore.v1beta.IGetMetadataImportRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.metastore.v1beta.IMetadataImport, - protos.google.cloud.metastore.v1beta.IGetMetadataImportRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.metastore.v1beta.IGetMetadataImportRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.metastore.v1beta.IMetadataImport, + | protos.google.cloud.metastore.v1beta.IGetMetadataImportRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.metastore.v1beta.IMetadataImport, + ( + | protos.google.cloud.metastore.v1beta.IGetMetadataImportRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getMetadataImport request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.metastore.v1beta.IMetadataImport, - protos.google.cloud.metastore.v1beta.IGetMetadataImportRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.metastore.v1beta.IMetadataImport, + | protos.google.cloud.metastore.v1beta.IGetMetadataImportRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getMetadataImport response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getMetadataImport(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.metastore.v1beta.IMetadataImport, - protos.google.cloud.metastore.v1beta.IGetMetadataImportRequest|undefined, - {}|undefined - ]) => { - this._log.info('getMetadataImport response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getMetadataImport(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.metastore.v1beta.IMetadataImport, + ( + | protos.google.cloud.metastore.v1beta.IGetMetadataImportRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getMetadataImport response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single backup. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The relative resource name of the backup to retrieve, in the - * following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}/backups/{backup_id}`. - * @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 {@link protos.google.cloud.metastore.v1beta.Backup|Backup}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/dataproc_metastore.get_backup.js - * region_tag:metastore_v1beta_generated_DataprocMetastore_GetBackup_async - */ + /** + * Gets details of a single backup. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The relative resource name of the backup to retrieve, in the + * following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}/backups/{backup_id}`. + * @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 {@link protos.google.cloud.metastore.v1beta.Backup|Backup}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/dataproc_metastore.get_backup.js + * region_tag:metastore_v1beta_generated_DataprocMetastore_GetBackup_async + */ getBackup( - request?: protos.google.cloud.metastore.v1beta.IGetBackupRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.metastore.v1beta.IBackup, - protos.google.cloud.metastore.v1beta.IGetBackupRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1beta.IGetBackupRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.metastore.v1beta.IBackup, + protos.google.cloud.metastore.v1beta.IGetBackupRequest | undefined, + {} | undefined, + ] + >; getBackup( - request: protos.google.cloud.metastore.v1beta.IGetBackupRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.metastore.v1beta.IBackup, - protos.google.cloud.metastore.v1beta.IGetBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IGetBackupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.metastore.v1beta.IBackup, + protos.google.cloud.metastore.v1beta.IGetBackupRequest | null | undefined, + {} | null | undefined + >, + ): void; getBackup( - request: protos.google.cloud.metastore.v1beta.IGetBackupRequest, - callback: Callback< - protos.google.cloud.metastore.v1beta.IBackup, - protos.google.cloud.metastore.v1beta.IGetBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IGetBackupRequest, + callback: Callback< + protos.google.cloud.metastore.v1beta.IBackup, + protos.google.cloud.metastore.v1beta.IGetBackupRequest | null | undefined, + {} | null | undefined + >, + ): void; getBackup( - request?: protos.google.cloud.metastore.v1beta.IGetBackupRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.metastore.v1beta.IBackup, - protos.google.cloud.metastore.v1beta.IGetBackupRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.metastore.v1beta.IGetBackupRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.metastore.v1beta.IBackup, - protos.google.cloud.metastore.v1beta.IGetBackupRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.metastore.v1beta.IBackup, - protos.google.cloud.metastore.v1beta.IGetBackupRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.metastore.v1beta.IGetBackupRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.metastore.v1beta.IBackup, + protos.google.cloud.metastore.v1beta.IGetBackupRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.metastore.v1beta.IBackup, + protos.google.cloud.metastore.v1beta.IGetBackupRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getBackup request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.metastore.v1beta.IBackup, - protos.google.cloud.metastore.v1beta.IGetBackupRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.metastore.v1beta.IBackup, + | protos.google.cloud.metastore.v1beta.IGetBackupRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getBackup response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getBackup(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.metastore.v1beta.IBackup, - protos.google.cloud.metastore.v1beta.IGetBackupRequest|undefined, - {}|undefined - ]) => { - this._log.info('getBackup response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getBackup(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.metastore.v1beta.IBackup, + protos.google.cloud.metastore.v1beta.IGetBackupRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getBackup response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Removes the attached IAM policies for a resource - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * Required. The relative resource name of the dataplane resource to remove - * IAM policy, in the following form: - * - * `projects/{project_id}/locations/{location_id}/services/{service_id}/databases/{database_id}` - * or - * `projects/{project_id}/locations/{location_id}/services/{service_id}/databases/{database_id}/tables/{table_id}`. - * @param {boolean} [request.asynchronous] - * Optional. Removes IAM policy attached to database or table asynchronously - * when it is set. The default is false. - * @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 {@link protos.google.cloud.metastore.v1beta.RemoveIamPolicyResponse|RemoveIamPolicyResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/dataproc_metastore.remove_iam_policy.js - * region_tag:metastore_v1beta_generated_DataprocMetastore_RemoveIamPolicy_async - */ + /** + * Removes the attached IAM policies for a resource + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * Required. The relative resource name of the dataplane resource to remove + * IAM policy, in the following form: + * + * `projects/{project_id}/locations/{location_id}/services/{service_id}/databases/{database_id}` + * or + * `projects/{project_id}/locations/{location_id}/services/{service_id}/databases/{database_id}/tables/{table_id}`. + * @param {boolean} [request.asynchronous] + * Optional. Removes IAM policy attached to database or table asynchronously + * when it is set. The default is false. + * @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 {@link protos.google.cloud.metastore.v1beta.RemoveIamPolicyResponse|RemoveIamPolicyResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/dataproc_metastore.remove_iam_policy.js + * region_tag:metastore_v1beta_generated_DataprocMetastore_RemoveIamPolicy_async + */ removeIamPolicy( - request?: protos.google.cloud.metastore.v1beta.IRemoveIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.metastore.v1beta.IRemoveIamPolicyResponse, - protos.google.cloud.metastore.v1beta.IRemoveIamPolicyRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1beta.IRemoveIamPolicyRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.metastore.v1beta.IRemoveIamPolicyResponse, + protos.google.cloud.metastore.v1beta.IRemoveIamPolicyRequest | undefined, + {} | undefined, + ] + >; removeIamPolicy( - request: protos.google.cloud.metastore.v1beta.IRemoveIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.metastore.v1beta.IRemoveIamPolicyResponse, - protos.google.cloud.metastore.v1beta.IRemoveIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IRemoveIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.metastore.v1beta.IRemoveIamPolicyResponse, + | protos.google.cloud.metastore.v1beta.IRemoveIamPolicyRequest + | null + | undefined, + {} | null | undefined + >, + ): void; removeIamPolicy( - request: protos.google.cloud.metastore.v1beta.IRemoveIamPolicyRequest, - callback: Callback< - protos.google.cloud.metastore.v1beta.IRemoveIamPolicyResponse, - protos.google.cloud.metastore.v1beta.IRemoveIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IRemoveIamPolicyRequest, + callback: Callback< + protos.google.cloud.metastore.v1beta.IRemoveIamPolicyResponse, + | protos.google.cloud.metastore.v1beta.IRemoveIamPolicyRequest + | null + | undefined, + {} | null | undefined + >, + ): void; removeIamPolicy( - request?: protos.google.cloud.metastore.v1beta.IRemoveIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.metastore.v1beta.IRemoveIamPolicyResponse, - protos.google.cloud.metastore.v1beta.IRemoveIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.metastore.v1beta.IRemoveIamPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.metastore.v1beta.IRemoveIamPolicyResponse, - protos.google.cloud.metastore.v1beta.IRemoveIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.metastore.v1beta.IRemoveIamPolicyResponse, - protos.google.cloud.metastore.v1beta.IRemoveIamPolicyRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.metastore.v1beta.IRemoveIamPolicyRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.metastore.v1beta.IRemoveIamPolicyResponse, + | protos.google.cloud.metastore.v1beta.IRemoveIamPolicyRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.metastore.v1beta.IRemoveIamPolicyResponse, + protos.google.cloud.metastore.v1beta.IRemoveIamPolicyRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'resource': request.resource ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + resource: request.resource ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('removeIamPolicy request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.metastore.v1beta.IRemoveIamPolicyResponse, - protos.google.cloud.metastore.v1beta.IRemoveIamPolicyRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.metastore.v1beta.IRemoveIamPolicyResponse, + | protos.google.cloud.metastore.v1beta.IRemoveIamPolicyRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('removeIamPolicy response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.removeIamPolicy(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.metastore.v1beta.IRemoveIamPolicyResponse, - protos.google.cloud.metastore.v1beta.IRemoveIamPolicyRequest|undefined, - {}|undefined - ]) => { - this._log.info('removeIamPolicy response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .removeIamPolicy(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.metastore.v1beta.IRemoveIamPolicyResponse, + ( + | protos.google.cloud.metastore.v1beta.IRemoveIamPolicyRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('removeIamPolicy response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a metastore service in a project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the location in which to create a - * metastore service, in the following form: - * - * `projects/{project_number}/locations/{location_id}`. - * @param {string} request.serviceId - * Required. The ID of the metastore service, which is used as the final - * component of the metastore service's name. - * - * This value must be between 2 and 63 characters long inclusive, begin with a - * letter, end with a letter or number, and consist of alpha-numeric - * ASCII characters or hyphens. - * @param {google.cloud.metastore.v1beta.Service} request.service - * Required. The Metastore service to create. The `name` field is - * ignored. The ID of the created metastore service must be provided in - * the request's `service_id` field. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/v1beta/dataproc_metastore.create_service.js - * region_tag:metastore_v1beta_generated_DataprocMetastore_CreateService_async - */ + /** + * Creates a metastore service in a project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the location in which to create a + * metastore service, in the following form: + * + * `projects/{project_number}/locations/{location_id}`. + * @param {string} request.serviceId + * Required. The ID of the metastore service, which is used as the final + * component of the metastore service's name. + * + * This value must be between 2 and 63 characters long inclusive, begin with a + * letter, end with a letter or number, and consist of alpha-numeric + * ASCII characters or hyphens. + * @param {google.cloud.metastore.v1beta.Service} request.service + * Required. The Metastore service to create. The `name` field is + * ignored. The ID of the created metastore service must be provided in + * the request's `service_id` field. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/v1beta/dataproc_metastore.create_service.js + * region_tag:metastore_v1beta_generated_DataprocMetastore_CreateService_async + */ createService( - request?: protos.google.cloud.metastore.v1beta.ICreateServiceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1beta.ICreateServiceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1beta.IService, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createService( - request: protos.google.cloud.metastore.v1beta.ICreateServiceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.ICreateServiceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IService, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createService( - request: protos.google.cloud.metastore.v1beta.ICreateServiceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.ICreateServiceRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IService, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createService( - request?: protos.google.cloud.metastore.v1beta.ICreateServiceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1beta.ICreateServiceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IService, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IService, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1beta.IService, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IService, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createService response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createService request %j', request); - return this.innerApiCalls.createService(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createService response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createService(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1beta.IService, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createService response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createService()`. - * @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/v1beta/dataproc_metastore.create_service.js - * region_tag:metastore_v1beta_generated_DataprocMetastore_CreateService_async - */ - async checkCreateServiceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createService()`. + * @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/v1beta/dataproc_metastore.create_service.js + * region_tag:metastore_v1beta_generated_DataprocMetastore_CreateService_async + */ + async checkCreateServiceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1beta.Service, + protos.google.cloud.metastore.v1beta.OperationMetadata + > + > { this._log.info('createService long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createService, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createService, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1beta.Service, + protos.google.cloud.metastore.v1beta.OperationMetadata + >; } -/** - * Updates the parameters of a single service. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. A field mask used to specify the fields to be overwritten in the - * metastore service resource by the update. - * Fields specified in the `update_mask` are relative to the resource (not - * to the full request). A field is overwritten if it is in the mask. - * @param {google.cloud.metastore.v1beta.Service} request.service - * Required. The metastore service to update. The server only merges fields - * in the service if they are specified in `update_mask`. - * - * The metastore service's `name` field is used to identify the metastore - * service to be updated. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/v1beta/dataproc_metastore.update_service.js - * region_tag:metastore_v1beta_generated_DataprocMetastore_UpdateService_async - */ + /** + * Updates the parameters of a single service. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. A field mask used to specify the fields to be overwritten in the + * metastore service resource by the update. + * Fields specified in the `update_mask` are relative to the resource (not + * to the full request). A field is overwritten if it is in the mask. + * @param {google.cloud.metastore.v1beta.Service} request.service + * Required. The metastore service to update. The server only merges fields + * in the service if they are specified in `update_mask`. + * + * The metastore service's `name` field is used to identify the metastore + * service to be updated. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/v1beta/dataproc_metastore.update_service.js + * region_tag:metastore_v1beta_generated_DataprocMetastore_UpdateService_async + */ updateService( - request?: protos.google.cloud.metastore.v1beta.IUpdateServiceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1beta.IUpdateServiceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1beta.IService, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateService( - request: protos.google.cloud.metastore.v1beta.IUpdateServiceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IUpdateServiceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IService, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateService( - request: protos.google.cloud.metastore.v1beta.IUpdateServiceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IUpdateServiceRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IService, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateService( - request?: protos.google.cloud.metastore.v1beta.IUpdateServiceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1beta.IUpdateServiceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IService, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IService, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1beta.IService, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'service.name': request.service!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'service.name': request.service!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IService, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateService response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateService request %j', request); - return this.innerApiCalls.updateService(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateService response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateService(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1beta.IService, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateService response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateService()`. - * @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/v1beta/dataproc_metastore.update_service.js - * region_tag:metastore_v1beta_generated_DataprocMetastore_UpdateService_async - */ - async checkUpdateServiceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateService()`. + * @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/v1beta/dataproc_metastore.update_service.js + * region_tag:metastore_v1beta_generated_DataprocMetastore_UpdateService_async + */ + async checkUpdateServiceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1beta.Service, + protos.google.cloud.metastore.v1beta.OperationMetadata + > + > { this._log.info('updateService long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateService, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateService, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1beta.Service, + protos.google.cloud.metastore.v1beta.OperationMetadata + >; } -/** - * Deletes a single service. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The relative resource name of the metastore service to delete, in - * the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}`. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/v1beta/dataproc_metastore.delete_service.js - * region_tag:metastore_v1beta_generated_DataprocMetastore_DeleteService_async - */ + /** + * Deletes a single service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The relative resource name of the metastore service to delete, in + * the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}`. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/v1beta/dataproc_metastore.delete_service.js + * region_tag:metastore_v1beta_generated_DataprocMetastore_DeleteService_async + */ deleteService( - request?: protos.google.cloud.metastore.v1beta.IDeleteServiceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1beta.IDeleteServiceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteService( - request: protos.google.cloud.metastore.v1beta.IDeleteServiceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IDeleteServiceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteService( - request: protos.google.cloud.metastore.v1beta.IDeleteServiceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IDeleteServiceRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteService( - request?: protos.google.cloud.metastore.v1beta.IDeleteServiceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1beta.IDeleteServiceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteService response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteService request %j', request); - return this.innerApiCalls.deleteService(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteService response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteService(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteService response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteService()`. - * @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/v1beta/dataproc_metastore.delete_service.js - * region_tag:metastore_v1beta_generated_DataprocMetastore_DeleteService_async - */ - async checkDeleteServiceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteService()`. + * @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/v1beta/dataproc_metastore.delete_service.js + * region_tag:metastore_v1beta_generated_DataprocMetastore_DeleteService_async + */ + async checkDeleteServiceProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.metastore.v1beta.OperationMetadata + > + > { this._log.info('deleteService long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteService, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteService, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.metastore.v1beta.OperationMetadata + >; } -/** - * Creates a new MetadataImport in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the service in which to create a - * metastore import, in the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}`. - * @param {string} request.metadataImportId - * Required. The ID of the metadata import, which is used as the final - * component of the metadata import's name. - * - * This value must be between 1 and 64 characters long, begin with a letter, - * end with a letter or number, and consist of alpha-numeric ASCII characters - * or hyphens. - * @param {google.cloud.metastore.v1beta.MetadataImport} request.metadataImport - * Required. The metadata import to create. The `name` field is ignored. The - * ID of the created metadata import must be provided in the request's - * `metadata_import_id` field. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/v1beta/dataproc_metastore.create_metadata_import.js - * region_tag:metastore_v1beta_generated_DataprocMetastore_CreateMetadataImport_async - */ + /** + * Creates a new MetadataImport in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the service in which to create a + * metastore import, in the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}`. + * @param {string} request.metadataImportId + * Required. The ID of the metadata import, which is used as the final + * component of the metadata import's name. + * + * This value must be between 1 and 64 characters long, begin with a letter, + * end with a letter or number, and consist of alpha-numeric ASCII characters + * or hyphens. + * @param {google.cloud.metastore.v1beta.MetadataImport} request.metadataImport + * Required. The metadata import to create. The `name` field is ignored. The + * ID of the created metadata import must be provided in the request's + * `metadata_import_id` field. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/v1beta/dataproc_metastore.create_metadata_import.js + * region_tag:metastore_v1beta_generated_DataprocMetastore_CreateMetadataImport_async + */ createMetadataImport( - request?: protos.google.cloud.metastore.v1beta.ICreateMetadataImportRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1beta.ICreateMetadataImportRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1beta.IMetadataImport, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createMetadataImport( - request: protos.google.cloud.metastore.v1beta.ICreateMetadataImportRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.ICreateMetadataImportRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IMetadataImport, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createMetadataImport( - request: protos.google.cloud.metastore.v1beta.ICreateMetadataImportRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.ICreateMetadataImportRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IMetadataImport, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createMetadataImport( - request?: protos.google.cloud.metastore.v1beta.ICreateMetadataImportRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1beta.ICreateMetadataImportRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IMetadataImport, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IMetadataImport, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1beta.IMetadataImport, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IMetadataImport, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createMetadataImport response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createMetadataImport request %j', request); - return this.innerApiCalls.createMetadataImport(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createMetadataImport response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createMetadataImport(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1beta.IMetadataImport, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createMetadataImport response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createMetadataImport()`. - * @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/v1beta/dataproc_metastore.create_metadata_import.js - * region_tag:metastore_v1beta_generated_DataprocMetastore_CreateMetadataImport_async - */ - async checkCreateMetadataImportProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createMetadataImport()`. + * @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/v1beta/dataproc_metastore.create_metadata_import.js + * region_tag:metastore_v1beta_generated_DataprocMetastore_CreateMetadataImport_async + */ + async checkCreateMetadataImportProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1beta.MetadataImport, + protos.google.cloud.metastore.v1beta.OperationMetadata + > + > { this._log.info('createMetadataImport long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createMetadataImport, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createMetadataImport, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1beta.MetadataImport, + protos.google.cloud.metastore.v1beta.OperationMetadata + >; } -/** - * Updates a single import. - * Only the description field of MetadataImport is supported to be updated. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. A field mask used to specify the fields to be overwritten in the - * metadata import resource by the update. - * Fields specified in the `update_mask` are relative to the resource (not - * to the full request). A field is overwritten if it is in the mask. - * @param {google.cloud.metastore.v1beta.MetadataImport} request.metadataImport - * Required. The metadata import to update. The server only merges fields - * in the import if they are specified in `update_mask`. - * - * The metadata import's `name` field is used to identify the metastore - * import to be updated. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/v1beta/dataproc_metastore.update_metadata_import.js - * region_tag:metastore_v1beta_generated_DataprocMetastore_UpdateMetadataImport_async - */ + /** + * Updates a single import. + * Only the description field of MetadataImport is supported to be updated. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. A field mask used to specify the fields to be overwritten in the + * metadata import resource by the update. + * Fields specified in the `update_mask` are relative to the resource (not + * to the full request). A field is overwritten if it is in the mask. + * @param {google.cloud.metastore.v1beta.MetadataImport} request.metadataImport + * Required. The metadata import to update. The server only merges fields + * in the import if they are specified in `update_mask`. + * + * The metadata import's `name` field is used to identify the metastore + * import to be updated. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/v1beta/dataproc_metastore.update_metadata_import.js + * region_tag:metastore_v1beta_generated_DataprocMetastore_UpdateMetadataImport_async + */ updateMetadataImport( - request?: protos.google.cloud.metastore.v1beta.IUpdateMetadataImportRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1beta.IUpdateMetadataImportRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1beta.IMetadataImport, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateMetadataImport( - request: protos.google.cloud.metastore.v1beta.IUpdateMetadataImportRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IUpdateMetadataImportRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IMetadataImport, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateMetadataImport( - request: protos.google.cloud.metastore.v1beta.IUpdateMetadataImportRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IUpdateMetadataImportRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IMetadataImport, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateMetadataImport( - request?: protos.google.cloud.metastore.v1beta.IUpdateMetadataImportRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1beta.IUpdateMetadataImportRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IMetadataImport, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IMetadataImport, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1beta.IMetadataImport, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'metadata_import.name': request.metadataImport!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'metadata_import.name': request.metadataImport!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IMetadataImport, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateMetadataImport response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateMetadataImport request %j', request); - return this.innerApiCalls.updateMetadataImport(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateMetadataImport response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateMetadataImport(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1beta.IMetadataImport, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateMetadataImport response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateMetadataImport()`. - * @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/v1beta/dataproc_metastore.update_metadata_import.js - * region_tag:metastore_v1beta_generated_DataprocMetastore_UpdateMetadataImport_async - */ - async checkUpdateMetadataImportProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateMetadataImport()`. + * @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/v1beta/dataproc_metastore.update_metadata_import.js + * region_tag:metastore_v1beta_generated_DataprocMetastore_UpdateMetadataImport_async + */ + async checkUpdateMetadataImportProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1beta.MetadataImport, + protos.google.cloud.metastore.v1beta.OperationMetadata + > + > { this._log.info('updateMetadataImport long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateMetadataImport, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateMetadataImport, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1beta.MetadataImport, + protos.google.cloud.metastore.v1beta.OperationMetadata + >; } -/** - * Exports metadata from a service. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.destinationGcsFolder - * A Cloud Storage URI of a folder, in the format - * `gs:///`. A sub-folder - * `` containing exported files will be created below it. - * @param {string} request.service - * Required. The relative resource name of the metastore service to run - * export, in the following form: - * - * `projects/{project_id}/locations/{location_id}/services/{service_id}`. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format). - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @param {google.cloud.metastore.v1beta.DatabaseDumpSpec.Type} [request.databaseDumpType] - * Optional. The type of the database dump. If unspecified, defaults to - * `MYSQL`. - * @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/v1beta/dataproc_metastore.export_metadata.js - * region_tag:metastore_v1beta_generated_DataprocMetastore_ExportMetadata_async - */ + /** + * Exports metadata from a service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.destinationGcsFolder + * A Cloud Storage URI of a folder, in the format + * `gs:///`. A sub-folder + * `` containing exported files will be created below it. + * @param {string} request.service + * Required. The relative resource name of the metastore service to run + * export, in the following form: + * + * `projects/{project_id}/locations/{location_id}/services/{service_id}`. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format). + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @param {google.cloud.metastore.v1beta.DatabaseDumpSpec.Type} [request.databaseDumpType] + * Optional. The type of the database dump. If unspecified, defaults to + * `MYSQL`. + * @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/v1beta/dataproc_metastore.export_metadata.js + * region_tag:metastore_v1beta_generated_DataprocMetastore_ExportMetadata_async + */ exportMetadata( - request?: protos.google.cloud.metastore.v1beta.IExportMetadataRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1beta.IExportMetadataRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1beta.IMetadataExport, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; exportMetadata( - request: protos.google.cloud.metastore.v1beta.IExportMetadataRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IExportMetadataRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IMetadataExport, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; exportMetadata( - request: protos.google.cloud.metastore.v1beta.IExportMetadataRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IExportMetadataRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IMetadataExport, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; exportMetadata( - request?: protos.google.cloud.metastore.v1beta.IExportMetadataRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1beta.IExportMetadataRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IMetadataExport, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IMetadataExport, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1beta.IMetadataExport, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'service': request.service ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + service: request.service ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IMetadataExport, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('exportMetadata response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('exportMetadata request %j', request); - return this.innerApiCalls.exportMetadata(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('exportMetadata response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .exportMetadata(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1beta.IMetadataExport, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('exportMetadata response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `exportMetadata()`. - * @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/v1beta/dataproc_metastore.export_metadata.js - * region_tag:metastore_v1beta_generated_DataprocMetastore_ExportMetadata_async - */ - async checkExportMetadataProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `exportMetadata()`. + * @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/v1beta/dataproc_metastore.export_metadata.js + * region_tag:metastore_v1beta_generated_DataprocMetastore_ExportMetadata_async + */ + async checkExportMetadataProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1beta.MetadataExport, + protos.google.cloud.metastore.v1beta.OperationMetadata + > + > { this._log.info('exportMetadata long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.exportMetadata, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.exportMetadata, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1beta.MetadataExport, + protos.google.cloud.metastore.v1beta.OperationMetadata + >; } -/** - * Restores a service from a backup. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.service - * Required. The relative resource name of the metastore service to run - * restore, in the following form: - * - * `projects/{project_id}/locations/{location_id}/services/{service_id}`. - * @param {string} request.backup - * Required. The relative resource name of the metastore service backup to - * restore from, in the following form: - * - * `projects/{project_id}/locations/{location_id}/services/{service_id}/backups/{backup_id}`. - * @param {google.cloud.metastore.v1beta.Restore.RestoreType} [request.restoreType] - * Optional. The type of restore. If unspecified, defaults to `METADATA_ONLY`. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format). - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/v1beta/dataproc_metastore.restore_service.js - * region_tag:metastore_v1beta_generated_DataprocMetastore_RestoreService_async - */ + /** + * Restores a service from a backup. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.service + * Required. The relative resource name of the metastore service to run + * restore, in the following form: + * + * `projects/{project_id}/locations/{location_id}/services/{service_id}`. + * @param {string} request.backup + * Required. The relative resource name of the metastore service backup to + * restore from, in the following form: + * + * `projects/{project_id}/locations/{location_id}/services/{service_id}/backups/{backup_id}`. + * @param {google.cloud.metastore.v1beta.Restore.RestoreType} [request.restoreType] + * Optional. The type of restore. If unspecified, defaults to `METADATA_ONLY`. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format). + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/v1beta/dataproc_metastore.restore_service.js + * region_tag:metastore_v1beta_generated_DataprocMetastore_RestoreService_async + */ restoreService( - request?: protos.google.cloud.metastore.v1beta.IRestoreServiceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1beta.IRestoreServiceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1beta.IRestore, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; restoreService( - request: protos.google.cloud.metastore.v1beta.IRestoreServiceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IRestoreServiceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IRestore, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; restoreService( - request: protos.google.cloud.metastore.v1beta.IRestoreServiceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IRestoreServiceRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IRestore, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; restoreService( - request?: protos.google.cloud.metastore.v1beta.IRestoreServiceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1beta.IRestoreServiceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IRestore, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IRestore, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1beta.IRestore, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'service': request.service ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + service: request.service ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IRestore, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('restoreService response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('restoreService request %j', request); - return this.innerApiCalls.restoreService(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('restoreService response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .restoreService(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1beta.IRestore, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('restoreService response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `restoreService()`. - * @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/v1beta/dataproc_metastore.restore_service.js - * region_tag:metastore_v1beta_generated_DataprocMetastore_RestoreService_async - */ - async checkRestoreServiceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `restoreService()`. + * @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/v1beta/dataproc_metastore.restore_service.js + * region_tag:metastore_v1beta_generated_DataprocMetastore_RestoreService_async + */ + async checkRestoreServiceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1beta.Restore, + protos.google.cloud.metastore.v1beta.OperationMetadata + > + > { this._log.info('restoreService long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.restoreService, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.restoreService, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1beta.Restore, + protos.google.cloud.metastore.v1beta.OperationMetadata + >; } -/** - * Creates a new backup in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the service in which to create a - * backup of the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}`. - * @param {string} request.backupId - * Required. The ID of the backup, which is used as the final component of the - * backup's name. - * - * This value must be between 1 and 64 characters long, begin with a letter, - * end with a letter or number, and consist of alpha-numeric ASCII characters - * or hyphens. - * @param {google.cloud.metastore.v1beta.Backup} request.backup - * Required. The backup to create. The `name` field is ignored. The ID of the - * created backup must be provided in the request's `backup_id` field. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/v1beta/dataproc_metastore.create_backup.js - * region_tag:metastore_v1beta_generated_DataprocMetastore_CreateBackup_async - */ + /** + * Creates a new backup in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the service in which to create a + * backup of the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}`. + * @param {string} request.backupId + * Required. The ID of the backup, which is used as the final component of the + * backup's name. + * + * This value must be between 1 and 64 characters long, begin with a letter, + * end with a letter or number, and consist of alpha-numeric ASCII characters + * or hyphens. + * @param {google.cloud.metastore.v1beta.Backup} request.backup + * Required. The backup to create. The `name` field is ignored. The ID of the + * created backup must be provided in the request's `backup_id` field. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/v1beta/dataproc_metastore.create_backup.js + * region_tag:metastore_v1beta_generated_DataprocMetastore_CreateBackup_async + */ createBackup( - request?: protos.google.cloud.metastore.v1beta.ICreateBackupRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1beta.ICreateBackupRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1beta.IBackup, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createBackup( - request: protos.google.cloud.metastore.v1beta.ICreateBackupRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.ICreateBackupRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IBackup, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createBackup( - request: protos.google.cloud.metastore.v1beta.ICreateBackupRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.ICreateBackupRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IBackup, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createBackup( - request?: protos.google.cloud.metastore.v1beta.ICreateBackupRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1beta.ICreateBackupRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IBackup, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IBackup, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1beta.IBackup, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IBackup, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createBackup response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createBackup request %j', request); - return this.innerApiCalls.createBackup(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createBackup response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createBackup(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1beta.IBackup, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createBackup response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createBackup()`. - * @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/v1beta/dataproc_metastore.create_backup.js - * region_tag:metastore_v1beta_generated_DataprocMetastore_CreateBackup_async - */ - async checkCreateBackupProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createBackup()`. + * @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/v1beta/dataproc_metastore.create_backup.js + * region_tag:metastore_v1beta_generated_DataprocMetastore_CreateBackup_async + */ + async checkCreateBackupProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1beta.Backup, + protos.google.cloud.metastore.v1beta.OperationMetadata + > + > { this._log.info('createBackup long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createBackup, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createBackup, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1beta.Backup, + protos.google.cloud.metastore.v1beta.OperationMetadata + >; } -/** - * Deletes a single backup. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The relative resource name of the backup to delete, in the - * following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}/backups/{backup_id}`. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/v1beta/dataproc_metastore.delete_backup.js - * region_tag:metastore_v1beta_generated_DataprocMetastore_DeleteBackup_async - */ + /** + * Deletes a single backup. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The relative resource name of the backup to delete, in the + * following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}/backups/{backup_id}`. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/v1beta/dataproc_metastore.delete_backup.js + * region_tag:metastore_v1beta_generated_DataprocMetastore_DeleteBackup_async + */ deleteBackup( - request?: protos.google.cloud.metastore.v1beta.IDeleteBackupRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1beta.IDeleteBackupRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteBackup( - request: protos.google.cloud.metastore.v1beta.IDeleteBackupRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IDeleteBackupRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteBackup( - request: protos.google.cloud.metastore.v1beta.IDeleteBackupRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IDeleteBackupRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteBackup( - request?: protos.google.cloud.metastore.v1beta.IDeleteBackupRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1beta.IDeleteBackupRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteBackup response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteBackup request %j', request); - return this.innerApiCalls.deleteBackup(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteBackup response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteBackup(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteBackup response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteBackup()`. - * @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/v1beta/dataproc_metastore.delete_backup.js - * region_tag:metastore_v1beta_generated_DataprocMetastore_DeleteBackup_async - */ - async checkDeleteBackupProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteBackup()`. + * @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/v1beta/dataproc_metastore.delete_backup.js + * region_tag:metastore_v1beta_generated_DataprocMetastore_DeleteBackup_async + */ + async checkDeleteBackupProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.metastore.v1beta.OperationMetadata + > + > { this._log.info('deleteBackup long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteBackup, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteBackup, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.metastore.v1beta.OperationMetadata + >; } -/** - * Query DPMS metadata. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.service - * Required. The relative resource name of the metastore service to query - * metadata, in the following format: - * - * `projects/{project_id}/locations/{location_id}/services/{service_id}`. - * @param {string} request.query - * Required. A read-only SQL query to execute against the metadata database. - * The query cannot change or mutate the data. - * @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/v1beta/dataproc_metastore.query_metadata.js - * region_tag:metastore_v1beta_generated_DataprocMetastore_QueryMetadata_async - */ + /** + * Query DPMS metadata. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.service + * Required. The relative resource name of the metastore service to query + * metadata, in the following format: + * + * `projects/{project_id}/locations/{location_id}/services/{service_id}`. + * @param {string} request.query + * Required. A read-only SQL query to execute against the metadata database. + * The query cannot change or mutate the data. + * @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/v1beta/dataproc_metastore.query_metadata.js + * region_tag:metastore_v1beta_generated_DataprocMetastore_QueryMetadata_async + */ queryMetadata( - request?: protos.google.cloud.metastore.v1beta.IQueryMetadataRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1beta.IQueryMetadataRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1beta.IQueryMetadataResponse, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; queryMetadata( - request: protos.google.cloud.metastore.v1beta.IQueryMetadataRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IQueryMetadataRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IQueryMetadataResponse, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; queryMetadata( - request: protos.google.cloud.metastore.v1beta.IQueryMetadataRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IQueryMetadataRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IQueryMetadataResponse, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; queryMetadata( - request?: protos.google.cloud.metastore.v1beta.IQueryMetadataRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1beta.IQueryMetadataRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IQueryMetadataResponse, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IQueryMetadataResponse, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1beta.IQueryMetadataResponse, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'service': request.service ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + service: request.service ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IQueryMetadataResponse, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('queryMetadata response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('queryMetadata request %j', request); - return this.innerApiCalls.queryMetadata(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('queryMetadata response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .queryMetadata(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1beta.IQueryMetadataResponse, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('queryMetadata response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `queryMetadata()`. - * @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/v1beta/dataproc_metastore.query_metadata.js - * region_tag:metastore_v1beta_generated_DataprocMetastore_QueryMetadata_async - */ - async checkQueryMetadataProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `queryMetadata()`. + * @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/v1beta/dataproc_metastore.query_metadata.js + * region_tag:metastore_v1beta_generated_DataprocMetastore_QueryMetadata_async + */ + async checkQueryMetadataProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1beta.QueryMetadataResponse, + protos.google.cloud.metastore.v1beta.OperationMetadata + > + > { this._log.info('queryMetadata long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.queryMetadata, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.queryMetadata, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1beta.QueryMetadataResponse, + protos.google.cloud.metastore.v1beta.OperationMetadata + >; } -/** - * Move a table to another database. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.service - * Required. The relative resource name of the metastore service to mutate - * metadata, in the following format: - * - * `projects/{project_id}/locations/{location_id}/services/{service_id}`. - * @param {string} request.tableName - * Required. The name of the table to be moved. - * @param {string} request.dbName - * Required. The name of the database where the table resides. - * @param {string} request.destinationDbName - * Required. The name of the database where the table should be moved. - * @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/v1beta/dataproc_metastore.move_table_to_database.js - * region_tag:metastore_v1beta_generated_DataprocMetastore_MoveTableToDatabase_async - */ + /** + * Move a table to another database. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.service + * Required. The relative resource name of the metastore service to mutate + * metadata, in the following format: + * + * `projects/{project_id}/locations/{location_id}/services/{service_id}`. + * @param {string} request.tableName + * Required. The name of the table to be moved. + * @param {string} request.dbName + * Required. The name of the database where the table resides. + * @param {string} request.destinationDbName + * Required. The name of the database where the table should be moved. + * @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/v1beta/dataproc_metastore.move_table_to_database.js + * region_tag:metastore_v1beta_generated_DataprocMetastore_MoveTableToDatabase_async + */ moveTableToDatabase( - request?: protos.google.cloud.metastore.v1beta.IMoveTableToDatabaseRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1beta.IMoveTableToDatabaseRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1beta.IMoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; moveTableToDatabase( - request: protos.google.cloud.metastore.v1beta.IMoveTableToDatabaseRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IMoveTableToDatabaseRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IMoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; moveTableToDatabase( - request: protos.google.cloud.metastore.v1beta.IMoveTableToDatabaseRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IMoveTableToDatabaseRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IMoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; moveTableToDatabase( - request?: protos.google.cloud.metastore.v1beta.IMoveTableToDatabaseRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1beta.IMoveTableToDatabaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IMoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IMoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1beta.IMoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'service': request.service ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + service: request.service ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IMoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('moveTableToDatabase response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('moveTableToDatabase request %j', request); - return this.innerApiCalls.moveTableToDatabase(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('moveTableToDatabase response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .moveTableToDatabase(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1beta.IMoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('moveTableToDatabase response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `moveTableToDatabase()`. - * @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/v1beta/dataproc_metastore.move_table_to_database.js - * region_tag:metastore_v1beta_generated_DataprocMetastore_MoveTableToDatabase_async - */ - async checkMoveTableToDatabaseProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `moveTableToDatabase()`. + * @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/v1beta/dataproc_metastore.move_table_to_database.js + * region_tag:metastore_v1beta_generated_DataprocMetastore_MoveTableToDatabase_async + */ + async checkMoveTableToDatabaseProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1beta.MoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1beta.OperationMetadata + > + > { this._log.info('moveTableToDatabase long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.moveTableToDatabase, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.moveTableToDatabase, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1beta.MoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1beta.OperationMetadata + >; } -/** - * Alter metadata resource location. The metadata resource can be a database, - * table, or partition. This functionality only updates the parent directory - * for the respective metadata resource and does not transfer any existing - * data to the new location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.service - * Required. The relative resource name of the metastore service to mutate - * metadata, in the following format: - * - * `projects/{project_id}/locations/{location_id}/services/{service_id}`. - * @param {string} request.resourceName - * Required. The relative metadata resource name in the following format. - * - * `databases/{database_id}` - * or - * `databases/{database_id}/tables/{table_id}` - * or - * `databases/{database_id}/tables/{table_id}/partitions/{partition_id}` - * @param {string} request.locationUri - * Required. The new location URI for the metadata resource. - * @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/v1beta/dataproc_metastore.alter_metadata_resource_location.js - * region_tag:metastore_v1beta_generated_DataprocMetastore_AlterMetadataResourceLocation_async - */ + /** + * Alter metadata resource location. The metadata resource can be a database, + * table, or partition. This functionality only updates the parent directory + * for the respective metadata resource and does not transfer any existing + * data to the new location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.service + * Required. The relative resource name of the metastore service to mutate + * metadata, in the following format: + * + * `projects/{project_id}/locations/{location_id}/services/{service_id}`. + * @param {string} request.resourceName + * Required. The relative metadata resource name in the following format. + * + * `databases/{database_id}` + * or + * `databases/{database_id}/tables/{table_id}` + * or + * `databases/{database_id}/tables/{table_id}/partitions/{partition_id}` + * @param {string} request.locationUri + * Required. The new location URI for the metadata resource. + * @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/v1beta/dataproc_metastore.alter_metadata_resource_location.js + * region_tag:metastore_v1beta_generated_DataprocMetastore_AlterMetadataResourceLocation_async + */ alterMetadataResourceLocation( - request?: protos.google.cloud.metastore.v1beta.IAlterMetadataResourceLocationRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1beta.IAlterMetadataResourceLocationRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1beta.IAlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; alterMetadataResourceLocation( - request: protos.google.cloud.metastore.v1beta.IAlterMetadataResourceLocationRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IAlterMetadataResourceLocationRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IAlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; alterMetadataResourceLocation( - request: protos.google.cloud.metastore.v1beta.IAlterMetadataResourceLocationRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IAlterMetadataResourceLocationRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IAlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; alterMetadataResourceLocation( - request?: protos.google.cloud.metastore.v1beta.IAlterMetadataResourceLocationRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1beta.IAlterMetadataResourceLocationRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IAlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IAlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1beta.IAlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'service': request.service ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + service: request.service ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IAlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { - this._log.info('alterMetadataResourceLocation response %j', rawResponse); + this._log.info( + 'alterMetadataResourceLocation response %j', + rawResponse, + ); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('alterMetadataResourceLocation request %j', request); - return this.innerApiCalls.alterMetadataResourceLocation(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('alterMetadataResourceLocation response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .alterMetadataResourceLocation(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1beta.IAlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info( + 'alterMetadataResourceLocation response %j', + rawResponse, + ); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `alterMetadataResourceLocation()`. - * @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/v1beta/dataproc_metastore.alter_metadata_resource_location.js - * region_tag:metastore_v1beta_generated_DataprocMetastore_AlterMetadataResourceLocation_async - */ - async checkAlterMetadataResourceLocationProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `alterMetadataResourceLocation()`. + * @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/v1beta/dataproc_metastore.alter_metadata_resource_location.js + * region_tag:metastore_v1beta_generated_DataprocMetastore_AlterMetadataResourceLocation_async + */ + async checkAlterMetadataResourceLocationProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1beta.AlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1beta.OperationMetadata + > + > { this._log.info('alterMetadataResourceLocation long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.alterMetadataResourceLocation, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.alterMetadataResourceLocation, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1beta.AlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1beta.OperationMetadata + >; } - /** - * Lists services in a project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the location of metastore services - * to list, in the following form: - * - * `projects/{project_number}/locations/{location_id}`. - * @param {number} [request.pageSize] - * Optional. The maximum number of services to return. The response may - * contain less than the maximum number. If unspecified, no more than 500 - * services are returned. The maximum value is 1000; values above 1000 are - * changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @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 Array of {@link protos.google.cloud.metastore.v1beta.Service|Service}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listServicesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists services in a project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the location of metastore services + * to list, in the following form: + * + * `projects/{project_number}/locations/{location_id}`. + * @param {number} [request.pageSize] + * Optional. The maximum number of services to return. The response may + * contain less than the maximum number. If unspecified, no more than 500 + * services are returned. The maximum value is 1000; values above 1000 are + * changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @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 Array of {@link protos.google.cloud.metastore.v1beta.Service|Service}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listServicesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listServices( - request?: protos.google.cloud.metastore.v1beta.IListServicesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.metastore.v1beta.IService[], - protos.google.cloud.metastore.v1beta.IListServicesRequest|null, - protos.google.cloud.metastore.v1beta.IListServicesResponse - ]>; + request?: protos.google.cloud.metastore.v1beta.IListServicesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.metastore.v1beta.IService[], + protos.google.cloud.metastore.v1beta.IListServicesRequest | null, + protos.google.cloud.metastore.v1beta.IListServicesResponse, + ] + >; listServices( - request: protos.google.cloud.metastore.v1beta.IListServicesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.metastore.v1beta.IListServicesRequest, - protos.google.cloud.metastore.v1beta.IListServicesResponse|null|undefined, - protos.google.cloud.metastore.v1beta.IService>): void; + request: protos.google.cloud.metastore.v1beta.IListServicesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.metastore.v1beta.IListServicesRequest, + | protos.google.cloud.metastore.v1beta.IListServicesResponse + | null + | undefined, + protos.google.cloud.metastore.v1beta.IService + >, + ): void; listServices( - request: protos.google.cloud.metastore.v1beta.IListServicesRequest, - callback: PaginationCallback< - protos.google.cloud.metastore.v1beta.IListServicesRequest, - protos.google.cloud.metastore.v1beta.IListServicesResponse|null|undefined, - protos.google.cloud.metastore.v1beta.IService>): void; + request: protos.google.cloud.metastore.v1beta.IListServicesRequest, + callback: PaginationCallback< + protos.google.cloud.metastore.v1beta.IListServicesRequest, + | protos.google.cloud.metastore.v1beta.IListServicesResponse + | null + | undefined, + protos.google.cloud.metastore.v1beta.IService + >, + ): void; listServices( - request?: protos.google.cloud.metastore.v1beta.IListServicesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.metastore.v1beta.IListServicesRequest, - protos.google.cloud.metastore.v1beta.IListServicesResponse|null|undefined, - protos.google.cloud.metastore.v1beta.IService>, - callback?: PaginationCallback< + request?: protos.google.cloud.metastore.v1beta.IListServicesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.metastore.v1beta.IListServicesRequest, - protos.google.cloud.metastore.v1beta.IListServicesResponse|null|undefined, - protos.google.cloud.metastore.v1beta.IService>): - Promise<[ - protos.google.cloud.metastore.v1beta.IService[], - protos.google.cloud.metastore.v1beta.IListServicesRequest|null, - protos.google.cloud.metastore.v1beta.IListServicesResponse - ]>|void { + | protos.google.cloud.metastore.v1beta.IListServicesResponse + | null + | undefined, + protos.google.cloud.metastore.v1beta.IService + >, + callback?: PaginationCallback< + protos.google.cloud.metastore.v1beta.IListServicesRequest, + | protos.google.cloud.metastore.v1beta.IListServicesResponse + | null + | undefined, + protos.google.cloud.metastore.v1beta.IService + >, + ): Promise< + [ + protos.google.cloud.metastore.v1beta.IService[], + protos.google.cloud.metastore.v1beta.IListServicesRequest | null, + protos.google.cloud.metastore.v1beta.IListServicesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.metastore.v1beta.IListServicesRequest, - protos.google.cloud.metastore.v1beta.IListServicesResponse|null|undefined, - protos.google.cloud.metastore.v1beta.IService>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.metastore.v1beta.IListServicesRequest, + | protos.google.cloud.metastore.v1beta.IListServicesResponse + | null + | undefined, + protos.google.cloud.metastore.v1beta.IService + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listServices values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2525,248 +3673,277 @@ export class DataprocMetastoreClient { this._log.info('listServices request %j', request); return this.innerApiCalls .listServices(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.metastore.v1beta.IService[], - protos.google.cloud.metastore.v1beta.IListServicesRequest|null, - protos.google.cloud.metastore.v1beta.IListServicesResponse - ]) => { - this._log.info('listServices values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.metastore.v1beta.IService[], + protos.google.cloud.metastore.v1beta.IListServicesRequest | null, + protos.google.cloud.metastore.v1beta.IListServicesResponse, + ]) => { + this._log.info('listServices values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listServices`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the location of metastore services - * to list, in the following form: - * - * `projects/{project_number}/locations/{location_id}`. - * @param {number} [request.pageSize] - * Optional. The maximum number of services to return. The response may - * contain less than the maximum number. If unspecified, no more than 500 - * services are returned. The maximum value is 1000; values above 1000 are - * changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.metastore.v1beta.Service|Service} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listServicesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listServices`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the location of metastore services + * to list, in the following form: + * + * `projects/{project_number}/locations/{location_id}`. + * @param {number} [request.pageSize] + * Optional. The maximum number of services to return. The response may + * contain less than the maximum number. If unspecified, no more than 500 + * services are returned. The maximum value is 1000; values above 1000 are + * changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.metastore.v1beta.Service|Service} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listServicesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listServicesStream( - request?: protos.google.cloud.metastore.v1beta.IListServicesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.metastore.v1beta.IListServicesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listServices']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listServices stream %j', request); return this.descriptors.page.listServices.createStream( this.innerApiCalls.listServices as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listServices`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the location of metastore services - * to list, in the following form: - * - * `projects/{project_number}/locations/{location_id}`. - * @param {number} [request.pageSize] - * Optional. The maximum number of services to return. The response may - * contain less than the maximum number. If unspecified, no more than 500 - * services are returned. The maximum value is 1000; values above 1000 are - * changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.metastore.v1beta.Service|Service}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/dataproc_metastore.list_services.js - * region_tag:metastore_v1beta_generated_DataprocMetastore_ListServices_async - */ + /** + * Equivalent to `listServices`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the location of metastore services + * to list, in the following form: + * + * `projects/{project_number}/locations/{location_id}`. + * @param {number} [request.pageSize] + * Optional. The maximum number of services to return. The response may + * contain less than the maximum number. If unspecified, no more than 500 + * services are returned. The maximum value is 1000; values above 1000 are + * changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.metastore.v1beta.Service|Service}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/dataproc_metastore.list_services.js + * region_tag:metastore_v1beta_generated_DataprocMetastore_ListServices_async + */ listServicesAsync( - request?: protos.google.cloud.metastore.v1beta.IListServicesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.metastore.v1beta.IListServicesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listServices']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listServices iterate %j', request); return this.descriptors.page.listServices.asyncIterate( this.innerApiCalls['listServices'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists imports in a service. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the service whose metadata imports - * to list, in the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}/metadataImports`. - * @param {number} [request.pageSize] - * Optional. The maximum number of imports to return. The response may contain - * less than the maximum number. If unspecified, no more than 500 imports are - * returned. The maximum value is 1000; values above 1000 are changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @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 Array of {@link protos.google.cloud.metastore.v1beta.MetadataImport|MetadataImport}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listMetadataImportsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists imports in a service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the service whose metadata imports + * to list, in the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}/metadataImports`. + * @param {number} [request.pageSize] + * Optional. The maximum number of imports to return. The response may contain + * less than the maximum number. If unspecified, no more than 500 imports are + * returned. The maximum value is 1000; values above 1000 are changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @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 Array of {@link protos.google.cloud.metastore.v1beta.MetadataImport|MetadataImport}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listMetadataImportsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMetadataImports( - request?: protos.google.cloud.metastore.v1beta.IListMetadataImportsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.metastore.v1beta.IMetadataImport[], - protos.google.cloud.metastore.v1beta.IListMetadataImportsRequest|null, - protos.google.cloud.metastore.v1beta.IListMetadataImportsResponse - ]>; + request?: protos.google.cloud.metastore.v1beta.IListMetadataImportsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.metastore.v1beta.IMetadataImport[], + protos.google.cloud.metastore.v1beta.IListMetadataImportsRequest | null, + protos.google.cloud.metastore.v1beta.IListMetadataImportsResponse, + ] + >; listMetadataImports( - request: protos.google.cloud.metastore.v1beta.IListMetadataImportsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.metastore.v1beta.IListMetadataImportsRequest, - protos.google.cloud.metastore.v1beta.IListMetadataImportsResponse|null|undefined, - protos.google.cloud.metastore.v1beta.IMetadataImport>): void; + request: protos.google.cloud.metastore.v1beta.IListMetadataImportsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.metastore.v1beta.IListMetadataImportsRequest, + | protos.google.cloud.metastore.v1beta.IListMetadataImportsResponse + | null + | undefined, + protos.google.cloud.metastore.v1beta.IMetadataImport + >, + ): void; listMetadataImports( - request: protos.google.cloud.metastore.v1beta.IListMetadataImportsRequest, - callback: PaginationCallback< - protos.google.cloud.metastore.v1beta.IListMetadataImportsRequest, - protos.google.cloud.metastore.v1beta.IListMetadataImportsResponse|null|undefined, - protos.google.cloud.metastore.v1beta.IMetadataImport>): void; + request: protos.google.cloud.metastore.v1beta.IListMetadataImportsRequest, + callback: PaginationCallback< + protos.google.cloud.metastore.v1beta.IListMetadataImportsRequest, + | protos.google.cloud.metastore.v1beta.IListMetadataImportsResponse + | null + | undefined, + protos.google.cloud.metastore.v1beta.IMetadataImport + >, + ): void; listMetadataImports( - request?: protos.google.cloud.metastore.v1beta.IListMetadataImportsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.metastore.v1beta.IListMetadataImportsRequest, - protos.google.cloud.metastore.v1beta.IListMetadataImportsResponse|null|undefined, - protos.google.cloud.metastore.v1beta.IMetadataImport>, - callback?: PaginationCallback< + request?: protos.google.cloud.metastore.v1beta.IListMetadataImportsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.metastore.v1beta.IListMetadataImportsRequest, - protos.google.cloud.metastore.v1beta.IListMetadataImportsResponse|null|undefined, - protos.google.cloud.metastore.v1beta.IMetadataImport>): - Promise<[ - protos.google.cloud.metastore.v1beta.IMetadataImport[], - protos.google.cloud.metastore.v1beta.IListMetadataImportsRequest|null, - protos.google.cloud.metastore.v1beta.IListMetadataImportsResponse - ]>|void { + | protos.google.cloud.metastore.v1beta.IListMetadataImportsResponse + | null + | undefined, + protos.google.cloud.metastore.v1beta.IMetadataImport + >, + callback?: PaginationCallback< + protos.google.cloud.metastore.v1beta.IListMetadataImportsRequest, + | protos.google.cloud.metastore.v1beta.IListMetadataImportsResponse + | null + | undefined, + protos.google.cloud.metastore.v1beta.IMetadataImport + >, + ): Promise< + [ + protos.google.cloud.metastore.v1beta.IMetadataImport[], + protos.google.cloud.metastore.v1beta.IListMetadataImportsRequest | null, + protos.google.cloud.metastore.v1beta.IListMetadataImportsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.metastore.v1beta.IListMetadataImportsRequest, - protos.google.cloud.metastore.v1beta.IListMetadataImportsResponse|null|undefined, - protos.google.cloud.metastore.v1beta.IMetadataImport>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.metastore.v1beta.IListMetadataImportsRequest, + | protos.google.cloud.metastore.v1beta.IListMetadataImportsResponse + | null + | undefined, + protos.google.cloud.metastore.v1beta.IMetadataImport + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listMetadataImports values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2775,246 +3952,275 @@ export class DataprocMetastoreClient { this._log.info('listMetadataImports request %j', request); return this.innerApiCalls .listMetadataImports(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.metastore.v1beta.IMetadataImport[], - protos.google.cloud.metastore.v1beta.IListMetadataImportsRequest|null, - protos.google.cloud.metastore.v1beta.IListMetadataImportsResponse - ]) => { - this._log.info('listMetadataImports values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.metastore.v1beta.IMetadataImport[], + protos.google.cloud.metastore.v1beta.IListMetadataImportsRequest | null, + protos.google.cloud.metastore.v1beta.IListMetadataImportsResponse, + ]) => { + this._log.info('listMetadataImports values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listMetadataImports`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the service whose metadata imports - * to list, in the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}/metadataImports`. - * @param {number} [request.pageSize] - * Optional. The maximum number of imports to return. The response may contain - * less than the maximum number. If unspecified, no more than 500 imports are - * returned. The maximum value is 1000; values above 1000 are changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.metastore.v1beta.MetadataImport|MetadataImport} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listMetadataImportsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listMetadataImports`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the service whose metadata imports + * to list, in the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}/metadataImports`. + * @param {number} [request.pageSize] + * Optional. The maximum number of imports to return. The response may contain + * less than the maximum number. If unspecified, no more than 500 imports are + * returned. The maximum value is 1000; values above 1000 are changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.metastore.v1beta.MetadataImport|MetadataImport} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listMetadataImportsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMetadataImportsStream( - request?: protos.google.cloud.metastore.v1beta.IListMetadataImportsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.metastore.v1beta.IListMetadataImportsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listMetadataImports']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listMetadataImports stream %j', request); return this.descriptors.page.listMetadataImports.createStream( this.innerApiCalls.listMetadataImports as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listMetadataImports`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the service whose metadata imports - * to list, in the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}/metadataImports`. - * @param {number} [request.pageSize] - * Optional. The maximum number of imports to return. The response may contain - * less than the maximum number. If unspecified, no more than 500 imports are - * returned. The maximum value is 1000; values above 1000 are changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListServices|DataprocMetastore.ListServices} - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.metastore.v1beta.MetadataImport|MetadataImport}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/dataproc_metastore.list_metadata_imports.js - * region_tag:metastore_v1beta_generated_DataprocMetastore_ListMetadataImports_async - */ + /** + * Equivalent to `listMetadataImports`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the service whose metadata imports + * to list, in the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}/metadataImports`. + * @param {number} [request.pageSize] + * Optional. The maximum number of imports to return. The response may contain + * less than the maximum number. If unspecified, no more than 500 imports are + * returned. The maximum value is 1000; values above 1000 are changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListServices|DataprocMetastore.ListServices} + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.metastore.v1beta.MetadataImport|MetadataImport}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/dataproc_metastore.list_metadata_imports.js + * region_tag:metastore_v1beta_generated_DataprocMetastore_ListMetadataImports_async + */ listMetadataImportsAsync( - request?: protos.google.cloud.metastore.v1beta.IListMetadataImportsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.metastore.v1beta.IListMetadataImportsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listMetadataImports']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listMetadataImports iterate %j', request); return this.descriptors.page.listMetadataImports.asyncIterate( this.innerApiCalls['listMetadataImports'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists backups in a service. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the service whose backups to - * list, in the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}/backups`. - * @param {number} [request.pageSize] - * Optional. The maximum number of backups to return. The response may contain - * less than the maximum number. If unspecified, no more than 500 backups are - * returned. The maximum value is 1000; values above 1000 are changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @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 Array of {@link protos.google.cloud.metastore.v1beta.Backup|Backup}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listBackupsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists backups in a service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the service whose backups to + * list, in the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}/backups`. + * @param {number} [request.pageSize] + * Optional. The maximum number of backups to return. The response may contain + * less than the maximum number. If unspecified, no more than 500 backups are + * returned. The maximum value is 1000; values above 1000 are changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @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 Array of {@link protos.google.cloud.metastore.v1beta.Backup|Backup}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listBackupsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listBackups( - request?: protos.google.cloud.metastore.v1beta.IListBackupsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.metastore.v1beta.IBackup[], - protos.google.cloud.metastore.v1beta.IListBackupsRequest|null, - protos.google.cloud.metastore.v1beta.IListBackupsResponse - ]>; + request?: protos.google.cloud.metastore.v1beta.IListBackupsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.metastore.v1beta.IBackup[], + protos.google.cloud.metastore.v1beta.IListBackupsRequest | null, + protos.google.cloud.metastore.v1beta.IListBackupsResponse, + ] + >; listBackups( - request: protos.google.cloud.metastore.v1beta.IListBackupsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.metastore.v1beta.IListBackupsRequest, - protos.google.cloud.metastore.v1beta.IListBackupsResponse|null|undefined, - protos.google.cloud.metastore.v1beta.IBackup>): void; + request: protos.google.cloud.metastore.v1beta.IListBackupsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.metastore.v1beta.IListBackupsRequest, + | protos.google.cloud.metastore.v1beta.IListBackupsResponse + | null + | undefined, + protos.google.cloud.metastore.v1beta.IBackup + >, + ): void; listBackups( - request: protos.google.cloud.metastore.v1beta.IListBackupsRequest, - callback: PaginationCallback< - protos.google.cloud.metastore.v1beta.IListBackupsRequest, - protos.google.cloud.metastore.v1beta.IListBackupsResponse|null|undefined, - protos.google.cloud.metastore.v1beta.IBackup>): void; + request: protos.google.cloud.metastore.v1beta.IListBackupsRequest, + callback: PaginationCallback< + protos.google.cloud.metastore.v1beta.IListBackupsRequest, + | protos.google.cloud.metastore.v1beta.IListBackupsResponse + | null + | undefined, + protos.google.cloud.metastore.v1beta.IBackup + >, + ): void; listBackups( - request?: protos.google.cloud.metastore.v1beta.IListBackupsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.metastore.v1beta.IListBackupsRequest, - protos.google.cloud.metastore.v1beta.IListBackupsResponse|null|undefined, - protos.google.cloud.metastore.v1beta.IBackup>, - callback?: PaginationCallback< + request?: protos.google.cloud.metastore.v1beta.IListBackupsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.metastore.v1beta.IListBackupsRequest, - protos.google.cloud.metastore.v1beta.IListBackupsResponse|null|undefined, - protos.google.cloud.metastore.v1beta.IBackup>): - Promise<[ - protos.google.cloud.metastore.v1beta.IBackup[], - protos.google.cloud.metastore.v1beta.IListBackupsRequest|null, - protos.google.cloud.metastore.v1beta.IListBackupsResponse - ]>|void { + | protos.google.cloud.metastore.v1beta.IListBackupsResponse + | null + | undefined, + protos.google.cloud.metastore.v1beta.IBackup + >, + callback?: PaginationCallback< + protos.google.cloud.metastore.v1beta.IListBackupsRequest, + | protos.google.cloud.metastore.v1beta.IListBackupsResponse + | null + | undefined, + protos.google.cloud.metastore.v1beta.IBackup + >, + ): Promise< + [ + protos.google.cloud.metastore.v1beta.IBackup[], + protos.google.cloud.metastore.v1beta.IListBackupsRequest | null, + protos.google.cloud.metastore.v1beta.IListBackupsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.metastore.v1beta.IListBackupsRequest, - protos.google.cloud.metastore.v1beta.IListBackupsResponse|null|undefined, - protos.google.cloud.metastore.v1beta.IBackup>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.metastore.v1beta.IListBackupsRequest, + | protos.google.cloud.metastore.v1beta.IListBackupsResponse + | null + | undefined, + protos.google.cloud.metastore.v1beta.IBackup + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listBackups values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -3023,171 +4229,175 @@ export class DataprocMetastoreClient { this._log.info('listBackups request %j', request); return this.innerApiCalls .listBackups(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.metastore.v1beta.IBackup[], - protos.google.cloud.metastore.v1beta.IListBackupsRequest|null, - protos.google.cloud.metastore.v1beta.IListBackupsResponse - ]) => { - this._log.info('listBackups values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.metastore.v1beta.IBackup[], + protos.google.cloud.metastore.v1beta.IListBackupsRequest | null, + protos.google.cloud.metastore.v1beta.IListBackupsResponse, + ]) => { + this._log.info('listBackups values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listBackups`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the service whose backups to - * list, in the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}/backups`. - * @param {number} [request.pageSize] - * Optional. The maximum number of backups to return. The response may contain - * less than the maximum number. If unspecified, no more than 500 backups are - * returned. The maximum value is 1000; values above 1000 are changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.metastore.v1beta.Backup|Backup} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listBackupsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listBackups`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the service whose backups to + * list, in the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}/backups`. + * @param {number} [request.pageSize] + * Optional. The maximum number of backups to return. The response may contain + * less than the maximum number. If unspecified, no more than 500 backups are + * returned. The maximum value is 1000; values above 1000 are changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.metastore.v1beta.Backup|Backup} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listBackupsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listBackupsStream( - request?: protos.google.cloud.metastore.v1beta.IListBackupsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.metastore.v1beta.IListBackupsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listBackups']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listBackups stream %j', request); return this.descriptors.page.listBackups.createStream( this.innerApiCalls.listBackups as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listBackups`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the service whose backups to - * list, in the following form: - * - * `projects/{project_number}/locations/{location_id}/services/{service_id}/backups`. - * @param {number} [request.pageSize] - * Optional. The maximum number of backups to return. The response may contain - * less than the maximum number. If unspecified, no more than 500 backups are - * returned. The maximum value is 1000; values above 1000 are changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.metastore.v1beta.Backup|Backup}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/dataproc_metastore.list_backups.js - * region_tag:metastore_v1beta_generated_DataprocMetastore_ListBackups_async - */ + /** + * Equivalent to `listBackups`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the service whose backups to + * list, in the following form: + * + * `projects/{project_number}/locations/{location_id}/services/{service_id}/backups`. + * @param {number} [request.pageSize] + * Optional. The maximum number of backups to return. The response may contain + * less than the maximum number. If unspecified, no more than 500 backups are + * returned. The maximum value is 1000; values above 1000 are changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * {@link protos.google.cloud.metastore.v1beta.DataprocMetastore.ListBackups|DataprocMetastore.ListBackups} + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.metastore.v1beta.Backup|Backup}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/dataproc_metastore.list_backups.js + * region_tag:metastore_v1beta_generated_DataprocMetastore_ListBackups_async + */ listBackupsAsync( - request?: protos.google.cloud.metastore.v1beta.IListBackupsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.metastore.v1beta.IListBackupsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listBackups']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listBackups iterate %j', request); return this.descriptors.page.listBackups.asyncIterate( this.innerApiCalls['listBackups'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -3201,40 +4411,40 @@ export class DataprocMetastoreClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -3248,41 +4458,41 @@ export class DataprocMetastoreClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -3296,12 +4506,12 @@ export class DataprocMetastoreClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -3336,12 +4546,11 @@ export class DataprocMetastoreClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -3374,12 +4583,12 @@ export class DataprocMetastoreClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -3422,22 +4631,22 @@ export class DataprocMetastoreClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -3472,15 +4681,15 @@ export class DataprocMetastoreClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - 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 ?? '', - }); + 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 ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -3514,7 +4723,7 @@ export class DataprocMetastoreClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -3527,25 +4736,24 @@ export class DataprocMetastoreClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -3584,22 +4792,22 @@ export class DataprocMetastoreClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -3616,7 +4824,12 @@ export class DataprocMetastoreClient { * @param {string} backup * @returns {string} Resource name string. */ - backupPath(project:string,location:string,service:string,backup:string) { + backupPath( + project: string, + location: string, + service: string, + backup: string, + ) { return this.pathTemplates.backupPathTemplate.render({ project: project, location: location, @@ -3677,7 +4890,7 @@ export class DataprocMetastoreClient { * @param {string} federation * @returns {string} Resource name string. */ - federationPath(project:string,location:string,federation:string) { + federationPath(project: string, location: string, federation: string) { return this.pathTemplates.federationPathTemplate.render({ project: project, location: location, @@ -3693,7 +4906,8 @@ export class DataprocMetastoreClient { * @returns {string} A string representing the project. */ matchProjectFromFederationName(federationName: string) { - return this.pathTemplates.federationPathTemplate.match(federationName).project; + return this.pathTemplates.federationPathTemplate.match(federationName) + .project; } /** @@ -3704,7 +4918,8 @@ export class DataprocMetastoreClient { * @returns {string} A string representing the location. */ matchLocationFromFederationName(federationName: string) { - return this.pathTemplates.federationPathTemplate.match(federationName).location; + return this.pathTemplates.federationPathTemplate.match(federationName) + .location; } /** @@ -3715,7 +4930,8 @@ export class DataprocMetastoreClient { * @returns {string} A string representing the federation. */ matchFederationFromFederationName(federationName: string) { - return this.pathTemplates.federationPathTemplate.match(federationName).federation; + return this.pathTemplates.federationPathTemplate.match(federationName) + .federation; } /** @@ -3726,7 +4942,7 @@ export class DataprocMetastoreClient { * @param {string} lake * @returns {string} Resource name string. */ - lakePath(project:string,location:string,lake:string) { + lakePath(project: string, location: string, lake: string) { return this.pathTemplates.lakePathTemplate.render({ project: project, location: location, @@ -3774,7 +4990,7 @@ export class DataprocMetastoreClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -3812,7 +5028,12 @@ export class DataprocMetastoreClient { * @param {string} metadata_import * @returns {string} Resource name string. */ - metadataImportPath(project:string,location:string,service:string,metadataImport:string) { + metadataImportPath( + project: string, + location: string, + service: string, + metadataImport: string, + ) { return this.pathTemplates.metadataImportPathTemplate.render({ project: project, location: location, @@ -3829,7 +5050,9 @@ export class DataprocMetastoreClient { * @returns {string} A string representing the project. */ matchProjectFromMetadataImportName(metadataImportName: string) { - return this.pathTemplates.metadataImportPathTemplate.match(metadataImportName).project; + return this.pathTemplates.metadataImportPathTemplate.match( + metadataImportName, + ).project; } /** @@ -3840,7 +5063,9 @@ export class DataprocMetastoreClient { * @returns {string} A string representing the location. */ matchLocationFromMetadataImportName(metadataImportName: string) { - return this.pathTemplates.metadataImportPathTemplate.match(metadataImportName).location; + return this.pathTemplates.metadataImportPathTemplate.match( + metadataImportName, + ).location; } /** @@ -3851,7 +5076,9 @@ export class DataprocMetastoreClient { * @returns {string} A string representing the service. */ matchServiceFromMetadataImportName(metadataImportName: string) { - return this.pathTemplates.metadataImportPathTemplate.match(metadataImportName).service; + return this.pathTemplates.metadataImportPathTemplate.match( + metadataImportName, + ).service; } /** @@ -3862,7 +5089,9 @@ export class DataprocMetastoreClient { * @returns {string} A string representing the metadata_import. */ matchMetadataImportFromMetadataImportName(metadataImportName: string) { - return this.pathTemplates.metadataImportPathTemplate.match(metadataImportName).metadata_import; + return this.pathTemplates.metadataImportPathTemplate.match( + metadataImportName, + ).metadata_import; } /** @@ -3872,7 +5101,7 @@ export class DataprocMetastoreClient { * @param {string} network * @returns {string} Resource name string. */ - networkPath(project:string,network:string) { + networkPath(project: string, network: string) { return this.pathTemplates.networkPathTemplate.render({ project: project, network: network, @@ -3907,7 +5136,7 @@ export class DataprocMetastoreClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -3932,7 +5161,7 @@ export class DataprocMetastoreClient { * @param {string} service * @returns {string} Resource name string. */ - servicePath(project:string,location:string,service:string) { + servicePath(project: string, location: string, service: string) { return this.pathTemplates.servicePathTemplate.render({ project: project, location: location, @@ -3981,15 +5210,19 @@ export class DataprocMetastoreClient { */ close(): Promise { if (this.dataprocMetastoreStub && !this._terminated) { - return this.dataprocMetastoreStub.then(stub => { + return this.dataprocMetastoreStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-metastore/src/v1beta/dataproc_metastore_federation_client.ts b/packages/google-cloud-metastore/src/v1beta/dataproc_metastore_federation_client.ts index 3df7d18e91c9..75d5d69de964 100644 --- a/packages/google-cloud-metastore/src/v1beta/dataproc_metastore_federation_client.ts +++ b/packages/google-cloud-metastore/src/v1beta/dataproc_metastore_federation_client.ts @@ -18,11 +18,24 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -56,7 +69,7 @@ export class DataprocMetastoreFederationClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('dataproc-metastore'); @@ -69,12 +82,12 @@ export class DataprocMetastoreFederationClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - dataprocMetastoreFederationStub?: Promise<{[name: string]: Function}>; + dataprocMetastoreFederationStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of DataprocMetastoreFederationClient. @@ -115,21 +128,43 @@ export class DataprocMetastoreFederationClient { * const client = new DataprocMetastoreFederationClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof DataprocMetastoreFederationClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + const staticMembers = this + .constructor as typeof DataprocMetastoreFederationClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'metastore.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -154,7 +189,7 @@ export class DataprocMetastoreFederationClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -167,18 +202,14 @@ export class DataprocMetastoreFederationClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -200,22 +231,22 @@ export class DataprocMetastoreFederationClient { // Create useful helper objects for these. this.pathTemplates = { backupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}/backups/{backup}' + 'projects/{project}/locations/{location}/services/{service}/backups/{backup}', ), federationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/federations/{federation}' + 'projects/{project}/locations/{location}/federations/{federation}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), metadataImportPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}/metadataImports/{metadata_import}' + 'projects/{project}/locations/{location}/services/{service}/metadataImports/{metadata_import}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), servicePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}' + 'projects/{project}/locations/{location}/services/{service}', ), }; @@ -223,8 +254,11 @@ export class DataprocMetastoreFederationClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listFederations: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'federations') + listFederations: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'federations', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -233,48 +267,149 @@ export class DataprocMetastoreFederationClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1beta/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1beta/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1beta/{resource=projects/*/locations/*/services/*}:getIamPolicy',additional_bindings: [{get: '/v1beta/{resource=projects/*/locations/*/services/*/backups/*}:getIamPolicy',},{get: '/v1beta/{resource=projects/*/locations/*/services/*/databases/*}:getIamPolicy',},{get: '/v1beta/{resource=projects/*/locations/*/services/*/databases/*/tables/*}:getIamPolicy',},{get: '/v1beta/{resource=projects/*/locations/*/federations/*}:getIamPolicy',}], - },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1beta/{resource=projects/*/locations/*/services/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1beta/{resource=projects/*/locations/*/services/*/backups/*}:setIamPolicy',body: '*',},{post: '/v1beta/{resource=projects/*/locations/*/services/*/databases/*}:setIamPolicy',body: '*',},{post: '/v1beta/{resource=projects/*/locations/*/services/*/databases/*/tables/*}:setIamPolicy',body: '*',},{post: '/v1beta/{resource=projects/*/locations/*/federations/*}:setIamPolicy',body: '*',}], - },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1beta/{resource=projects/*/locations/*/services/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1beta/{resource=projects/*/locations/*/services/*/backups/*}:testIamPermissions',body: '*',},{post: '/v1beta/{resource=projects/*/locations/*/services/*/databases/*}:testIamPermissions',body: '*',},{post: '/v1beta/{resource=projects/*/locations/*/services/*/databases/*/tables/*}:testIamPermissions',body: '*',},{post: '/v1beta/{resource=projects/*/locations/*/federations/*}:testIamPermissions',body: '*',}], - },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1beta/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1beta/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1beta/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1beta/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1beta/{resource=projects/*/locations/*/services/*}:getIamPolicy', + additional_bindings: [ + { + get: '/v1beta/{resource=projects/*/locations/*/services/*/backups/*}:getIamPolicy', + }, + { + get: '/v1beta/{resource=projects/*/locations/*/services/*/databases/*}:getIamPolicy', + }, + { + get: '/v1beta/{resource=projects/*/locations/*/services/*/databases/*/tables/*}:getIamPolicy', + }, + { + get: '/v1beta/{resource=projects/*/locations/*/federations/*}:getIamPolicy', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1beta/{resource=projects/*/locations/*/services/*}:setIamPolicy', + body: '*', + additional_bindings: [ + { + post: '/v1beta/{resource=projects/*/locations/*/services/*/backups/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1beta/{resource=projects/*/locations/*/services/*/databases/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1beta/{resource=projects/*/locations/*/services/*/databases/*/tables/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1beta/{resource=projects/*/locations/*/federations/*}:setIamPolicy', + body: '*', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1beta/{resource=projects/*/locations/*/services/*}:testIamPermissions', + body: '*', + additional_bindings: [ + { + post: '/v1beta/{resource=projects/*/locations/*/services/*/backups/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1beta/{resource=projects/*/locations/*/services/*/databases/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1beta/{resource=projects/*/locations/*/services/*/databases/*/tables/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1beta/{resource=projects/*/locations/*/federations/*}:testIamPermissions', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1beta/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1beta/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1beta/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1beta/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createFederationResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1beta.Federation') as gax.protobuf.Type; + '.google.cloud.metastore.v1beta.Federation', + ) as gax.protobuf.Type; const createFederationMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const updateFederationResponse = protoFilesRoot.lookup( - '.google.cloud.metastore.v1beta.Federation') as gax.protobuf.Type; + '.google.cloud.metastore.v1beta.Federation', + ) as gax.protobuf.Type; const updateFederationMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const deleteFederationResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteFederationMetadata = protoFilesRoot.lookup( - '.google.cloud.metastore.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.metastore.v1beta.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createFederation: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createFederationResponse.decode.bind(createFederationResponse), - createFederationMetadata.decode.bind(createFederationMetadata)), + createFederationMetadata.decode.bind(createFederationMetadata), + ), updateFederation: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateFederationResponse.decode.bind(updateFederationResponse), - updateFederationMetadata.decode.bind(updateFederationMetadata)), + updateFederationMetadata.decode.bind(updateFederationMetadata), + ), deleteFederation: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteFederationResponse.decode.bind(deleteFederationResponse), - deleteFederationMetadata.decode.bind(deleteFederationMetadata)) + deleteFederationMetadata.decode.bind(deleteFederationMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.metastore.v1beta.DataprocMetastoreFederation', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.metastore.v1beta.DataprocMetastoreFederation', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -305,28 +440,40 @@ export class DataprocMetastoreFederationClient { // Put together the "service stub" for // google.cloud.metastore.v1beta.DataprocMetastoreFederation. this.dataprocMetastoreFederationStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.metastore.v1beta.DataprocMetastoreFederation') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.metastore.v1beta.DataprocMetastoreFederation, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.metastore.v1beta.DataprocMetastoreFederation', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.metastore.v1beta + .DataprocMetastoreFederation, + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const dataprocMetastoreFederationStubMethods = - ['listFederations', 'getFederation', 'createFederation', 'updateFederation', 'deleteFederation']; + const dataprocMetastoreFederationStubMethods = [ + 'listFederations', + 'getFederation', + 'createFederation', + 'updateFederation', + 'deleteFederation', + ]; for (const methodName of dataprocMetastoreFederationStubMethods) { const callPromise = this.dataprocMetastoreFederationStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -336,7 +483,7 @@ export class DataprocMetastoreFederationClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -351,8 +498,14 @@ export class DataprocMetastoreFederationClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'metastore.googleapis.com'; } @@ -363,8 +516,14 @@ export class DataprocMetastoreFederationClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'metastore.googleapis.com'; } @@ -395,9 +554,7 @@ export class DataprocMetastoreFederationClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -406,8 +563,9 @@ export class DataprocMetastoreFederationClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -418,589 +576,843 @@ export class DataprocMetastoreFederationClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets the details of a single federation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The relative resource name of the metastore federation to - * retrieve, in the following form: - * - * `projects/{project_number}/locations/{location_id}/federations/{federation_id}`. - * @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 {@link protos.google.cloud.metastore.v1beta.Federation|Federation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/dataproc_metastore_federation.get_federation.js - * region_tag:metastore_v1beta_generated_DataprocMetastoreFederation_GetFederation_async - */ + /** + * Gets the details of a single federation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The relative resource name of the metastore federation to + * retrieve, in the following form: + * + * `projects/{project_number}/locations/{location_id}/federations/{federation_id}`. + * @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 {@link protos.google.cloud.metastore.v1beta.Federation|Federation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/dataproc_metastore_federation.get_federation.js + * region_tag:metastore_v1beta_generated_DataprocMetastoreFederation_GetFederation_async + */ getFederation( - request?: protos.google.cloud.metastore.v1beta.IGetFederationRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.metastore.v1beta.IFederation, - protos.google.cloud.metastore.v1beta.IGetFederationRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1beta.IGetFederationRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.metastore.v1beta.IFederation, + protos.google.cloud.metastore.v1beta.IGetFederationRequest | undefined, + {} | undefined, + ] + >; getFederation( - request: protos.google.cloud.metastore.v1beta.IGetFederationRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.metastore.v1beta.IFederation, - protos.google.cloud.metastore.v1beta.IGetFederationRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IGetFederationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.metastore.v1beta.IFederation, + | protos.google.cloud.metastore.v1beta.IGetFederationRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getFederation( - request: protos.google.cloud.metastore.v1beta.IGetFederationRequest, - callback: Callback< - protos.google.cloud.metastore.v1beta.IFederation, - protos.google.cloud.metastore.v1beta.IGetFederationRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IGetFederationRequest, + callback: Callback< + protos.google.cloud.metastore.v1beta.IFederation, + | protos.google.cloud.metastore.v1beta.IGetFederationRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getFederation( - request?: protos.google.cloud.metastore.v1beta.IGetFederationRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.metastore.v1beta.IFederation, - protos.google.cloud.metastore.v1beta.IGetFederationRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.metastore.v1beta.IGetFederationRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.metastore.v1beta.IFederation, - protos.google.cloud.metastore.v1beta.IGetFederationRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.metastore.v1beta.IFederation, - protos.google.cloud.metastore.v1beta.IGetFederationRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.metastore.v1beta.IGetFederationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.metastore.v1beta.IFederation, + | protos.google.cloud.metastore.v1beta.IGetFederationRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.metastore.v1beta.IFederation, + protos.google.cloud.metastore.v1beta.IGetFederationRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getFederation request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.metastore.v1beta.IFederation, - protos.google.cloud.metastore.v1beta.IGetFederationRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.metastore.v1beta.IFederation, + | protos.google.cloud.metastore.v1beta.IGetFederationRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getFederation response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getFederation(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.metastore.v1beta.IFederation, - protos.google.cloud.metastore.v1beta.IGetFederationRequest|undefined, - {}|undefined - ]) => { - this._log.info('getFederation response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getFederation(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.metastore.v1beta.IFederation, + ( + | protos.google.cloud.metastore.v1beta.IGetFederationRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getFederation response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a metastore federation in a project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the location in which to create a - * federation service, in the following form: - * - * `projects/{project_number}/locations/{location_id}`. - * @param {string} request.federationId - * Required. The ID of the metastore federation, which is used as the final - * component of the metastore federation's name. - * - * This value must be between 2 and 63 characters long inclusive, begin with a - * letter, end with a letter or number, and consist of alpha-numeric - * ASCII characters or hyphens. - * @param {google.cloud.metastore.v1beta.Federation} request.federation - * Required. The Metastore Federation to create. The `name` field is - * ignored. The ID of the created metastore federation must be - * provided in the request's `federation_id` field. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/v1beta/dataproc_metastore_federation.create_federation.js - * region_tag:metastore_v1beta_generated_DataprocMetastoreFederation_CreateFederation_async - */ + /** + * Creates a metastore federation in a project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the location in which to create a + * federation service, in the following form: + * + * `projects/{project_number}/locations/{location_id}`. + * @param {string} request.federationId + * Required. The ID of the metastore federation, which is used as the final + * component of the metastore federation's name. + * + * This value must be between 2 and 63 characters long inclusive, begin with a + * letter, end with a letter or number, and consist of alpha-numeric + * ASCII characters or hyphens. + * @param {google.cloud.metastore.v1beta.Federation} request.federation + * Required. The Metastore Federation to create. The `name` field is + * ignored. The ID of the created metastore federation must be + * provided in the request's `federation_id` field. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/v1beta/dataproc_metastore_federation.create_federation.js + * region_tag:metastore_v1beta_generated_DataprocMetastoreFederation_CreateFederation_async + */ createFederation( - request?: protos.google.cloud.metastore.v1beta.ICreateFederationRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1beta.ICreateFederationRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1beta.IFederation, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createFederation( - request: protos.google.cloud.metastore.v1beta.ICreateFederationRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.ICreateFederationRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IFederation, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createFederation( - request: protos.google.cloud.metastore.v1beta.ICreateFederationRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.ICreateFederationRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IFederation, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createFederation( - request?: protos.google.cloud.metastore.v1beta.ICreateFederationRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1beta.ICreateFederationRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IFederation, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IFederation, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1beta.IFederation, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IFederation, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createFederation response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createFederation request %j', request); - return this.innerApiCalls.createFederation(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createFederation response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createFederation(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1beta.IFederation, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createFederation response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createFederation()`. - * @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/v1beta/dataproc_metastore_federation.create_federation.js - * region_tag:metastore_v1beta_generated_DataprocMetastoreFederation_CreateFederation_async - */ - async checkCreateFederationProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createFederation()`. + * @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/v1beta/dataproc_metastore_federation.create_federation.js + * region_tag:metastore_v1beta_generated_DataprocMetastoreFederation_CreateFederation_async + */ + async checkCreateFederationProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1beta.Federation, + protos.google.cloud.metastore.v1beta.OperationMetadata + > + > { this._log.info('createFederation long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createFederation, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createFederation, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1beta.Federation, + protos.google.cloud.metastore.v1beta.OperationMetadata + >; } -/** - * Updates the fields of a federation. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. A field mask used to specify the fields to be overwritten in the - * metastore federation resource by the update. - * Fields specified in the `update_mask` are relative to the resource (not - * to the full request). A field is overwritten if it is in the mask. - * @param {google.cloud.metastore.v1beta.Federation} request.federation - * Required. The metastore federation to update. The server only merges fields - * in the service if they are specified in `update_mask`. - * - * The metastore federation's `name` field is used to identify the - * metastore service to be updated. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/v1beta/dataproc_metastore_federation.update_federation.js - * region_tag:metastore_v1beta_generated_DataprocMetastoreFederation_UpdateFederation_async - */ + /** + * Updates the fields of a federation. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. A field mask used to specify the fields to be overwritten in the + * metastore federation resource by the update. + * Fields specified in the `update_mask` are relative to the resource (not + * to the full request). A field is overwritten if it is in the mask. + * @param {google.cloud.metastore.v1beta.Federation} request.federation + * Required. The metastore federation to update. The server only merges fields + * in the service if they are specified in `update_mask`. + * + * The metastore federation's `name` field is used to identify the + * metastore service to be updated. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/v1beta/dataproc_metastore_federation.update_federation.js + * region_tag:metastore_v1beta_generated_DataprocMetastoreFederation_UpdateFederation_async + */ updateFederation( - request?: protos.google.cloud.metastore.v1beta.IUpdateFederationRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1beta.IUpdateFederationRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1beta.IFederation, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateFederation( - request: protos.google.cloud.metastore.v1beta.IUpdateFederationRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IUpdateFederationRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IFederation, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateFederation( - request: protos.google.cloud.metastore.v1beta.IUpdateFederationRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IUpdateFederationRequest, + callback: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IFederation, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateFederation( - request?: protos.google.cloud.metastore.v1beta.IUpdateFederationRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1beta.IUpdateFederationRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IFederation, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IFederation, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.metastore.v1beta.IFederation, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'federation.name': request.federation!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'federation.name': request.federation!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.metastore.v1beta.IFederation, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateFederation response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateFederation request %j', request); - return this.innerApiCalls.updateFederation(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateFederation response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateFederation(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.metastore.v1beta.IFederation, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateFederation response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateFederation()`. - * @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/v1beta/dataproc_metastore_federation.update_federation.js - * region_tag:metastore_v1beta_generated_DataprocMetastoreFederation_UpdateFederation_async - */ - async checkUpdateFederationProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateFederation()`. + * @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/v1beta/dataproc_metastore_federation.update_federation.js + * region_tag:metastore_v1beta_generated_DataprocMetastoreFederation_UpdateFederation_async + */ + async checkUpdateFederationProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.metastore.v1beta.Federation, + protos.google.cloud.metastore.v1beta.OperationMetadata + > + > { this._log.info('updateFederation long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateFederation, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateFederation, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.metastore.v1beta.Federation, + protos.google.cloud.metastore.v1beta.OperationMetadata + >; } -/** - * Deletes a single federation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The relative resource name of the metastore federation to delete, - * in the following form: - * - * `projects/{project_number}/locations/{location_id}/federations/{federation_id}`. - * @param {string} [request.requestId] - * Optional. A request ID. Specify a unique request ID to allow the server to - * ignore the request if it has completed. The server will ignore subsequent - * requests that provide a duplicate request ID for at least 60 minutes after - * the first request. - * - * For example, if an initial request times out, followed by another request - * with the same request ID, the server ignores the second request to prevent - * the creation of duplicate commitments. - * - * The request ID must be a valid - * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) - * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. - * @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/v1beta/dataproc_metastore_federation.delete_federation.js - * region_tag:metastore_v1beta_generated_DataprocMetastoreFederation_DeleteFederation_async - */ + /** + * Deletes a single federation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The relative resource name of the metastore federation to delete, + * in the following form: + * + * `projects/{project_number}/locations/{location_id}/federations/{federation_id}`. + * @param {string} [request.requestId] + * Optional. A request ID. Specify a unique request ID to allow the server to + * ignore the request if it has completed. The server will ignore subsequent + * requests that provide a duplicate request ID for at least 60 minutes after + * the first request. + * + * For example, if an initial request times out, followed by another request + * with the same request ID, the server ignores the second request to prevent + * the creation of duplicate commitments. + * + * The request ID must be a valid + * [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. + * @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/v1beta/dataproc_metastore_federation.delete_federation.js + * region_tag:metastore_v1beta_generated_DataprocMetastoreFederation_DeleteFederation_async + */ deleteFederation( - request?: protos.google.cloud.metastore.v1beta.IDeleteFederationRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.metastore.v1beta.IDeleteFederationRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteFederation( - request: protos.google.cloud.metastore.v1beta.IDeleteFederationRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IDeleteFederationRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteFederation( - request: protos.google.cloud.metastore.v1beta.IDeleteFederationRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.metastore.v1beta.IDeleteFederationRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteFederation( - request?: protos.google.cloud.metastore.v1beta.IDeleteFederationRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.metastore.v1beta.IDeleteFederationRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteFederation response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteFederation request %j', request); - return this.innerApiCalls.deleteFederation(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteFederation response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteFederation(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteFederation response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteFederation()`. - * @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/v1beta/dataproc_metastore_federation.delete_federation.js - * region_tag:metastore_v1beta_generated_DataprocMetastoreFederation_DeleteFederation_async - */ - async checkDeleteFederationProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteFederation()`. + * @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/v1beta/dataproc_metastore_federation.delete_federation.js + * region_tag:metastore_v1beta_generated_DataprocMetastoreFederation_DeleteFederation_async + */ + async checkDeleteFederationProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.metastore.v1beta.OperationMetadata + > + > { this._log.info('deleteFederation long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteFederation, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteFederation, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.metastore.v1beta.OperationMetadata + >; } - /** - * Lists federations in a project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the location of metastore - * federations to list, in the following form: - * `projects/{project_number}/locations/{location_id}`. - * @param {number} [request.pageSize] - * Optional. The maximum number of federations to return. The response may - * contain less than the maximum number. If unspecified, no more than 500 - * services are returned. The maximum value is 1000; values above 1000 are - * changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous ListFederationServices - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * ListFederationServices must match the call that provided the - * page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @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 Array of {@link protos.google.cloud.metastore.v1beta.Federation|Federation}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listFederationsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists federations in a project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the location of metastore + * federations to list, in the following form: + * `projects/{project_number}/locations/{location_id}`. + * @param {number} [request.pageSize] + * Optional. The maximum number of federations to return. The response may + * contain less than the maximum number. If unspecified, no more than 500 + * services are returned. The maximum value is 1000; values above 1000 are + * changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous ListFederationServices + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * ListFederationServices must match the call that provided the + * page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @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 Array of {@link protos.google.cloud.metastore.v1beta.Federation|Federation}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listFederationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listFederations( - request?: protos.google.cloud.metastore.v1beta.IListFederationsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.metastore.v1beta.IFederation[], - protos.google.cloud.metastore.v1beta.IListFederationsRequest|null, - protos.google.cloud.metastore.v1beta.IListFederationsResponse - ]>; + request?: protos.google.cloud.metastore.v1beta.IListFederationsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.metastore.v1beta.IFederation[], + protos.google.cloud.metastore.v1beta.IListFederationsRequest | null, + protos.google.cloud.metastore.v1beta.IListFederationsResponse, + ] + >; listFederations( - request: protos.google.cloud.metastore.v1beta.IListFederationsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.metastore.v1beta.IListFederationsRequest, - protos.google.cloud.metastore.v1beta.IListFederationsResponse|null|undefined, - protos.google.cloud.metastore.v1beta.IFederation>): void; + request: protos.google.cloud.metastore.v1beta.IListFederationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.metastore.v1beta.IListFederationsRequest, + | protos.google.cloud.metastore.v1beta.IListFederationsResponse + | null + | undefined, + protos.google.cloud.metastore.v1beta.IFederation + >, + ): void; listFederations( - request: protos.google.cloud.metastore.v1beta.IListFederationsRequest, - callback: PaginationCallback< - protos.google.cloud.metastore.v1beta.IListFederationsRequest, - protos.google.cloud.metastore.v1beta.IListFederationsResponse|null|undefined, - protos.google.cloud.metastore.v1beta.IFederation>): void; + request: protos.google.cloud.metastore.v1beta.IListFederationsRequest, + callback: PaginationCallback< + protos.google.cloud.metastore.v1beta.IListFederationsRequest, + | protos.google.cloud.metastore.v1beta.IListFederationsResponse + | null + | undefined, + protos.google.cloud.metastore.v1beta.IFederation + >, + ): void; listFederations( - request?: protos.google.cloud.metastore.v1beta.IListFederationsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.metastore.v1beta.IListFederationsRequest, - protos.google.cloud.metastore.v1beta.IListFederationsResponse|null|undefined, - protos.google.cloud.metastore.v1beta.IFederation>, - callback?: PaginationCallback< + request?: protos.google.cloud.metastore.v1beta.IListFederationsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.metastore.v1beta.IListFederationsRequest, - protos.google.cloud.metastore.v1beta.IListFederationsResponse|null|undefined, - protos.google.cloud.metastore.v1beta.IFederation>): - Promise<[ - protos.google.cloud.metastore.v1beta.IFederation[], - protos.google.cloud.metastore.v1beta.IListFederationsRequest|null, - protos.google.cloud.metastore.v1beta.IListFederationsResponse - ]>|void { + | protos.google.cloud.metastore.v1beta.IListFederationsResponse + | null + | undefined, + protos.google.cloud.metastore.v1beta.IFederation + >, + callback?: PaginationCallback< + protos.google.cloud.metastore.v1beta.IListFederationsRequest, + | protos.google.cloud.metastore.v1beta.IListFederationsResponse + | null + | undefined, + protos.google.cloud.metastore.v1beta.IFederation + >, + ): Promise< + [ + protos.google.cloud.metastore.v1beta.IFederation[], + protos.google.cloud.metastore.v1beta.IListFederationsRequest | null, + protos.google.cloud.metastore.v1beta.IListFederationsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.metastore.v1beta.IListFederationsRequest, - protos.google.cloud.metastore.v1beta.IListFederationsResponse|null|undefined, - protos.google.cloud.metastore.v1beta.IFederation>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.metastore.v1beta.IListFederationsRequest, + | protos.google.cloud.metastore.v1beta.IListFederationsResponse + | null + | undefined, + protos.google.cloud.metastore.v1beta.IFederation + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listFederations values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1009,169 +1421,173 @@ export class DataprocMetastoreFederationClient { this._log.info('listFederations request %j', request); return this.innerApiCalls .listFederations(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.metastore.v1beta.IFederation[], - protos.google.cloud.metastore.v1beta.IListFederationsRequest|null, - protos.google.cloud.metastore.v1beta.IListFederationsResponse - ]) => { - this._log.info('listFederations values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.metastore.v1beta.IFederation[], + protos.google.cloud.metastore.v1beta.IListFederationsRequest | null, + protos.google.cloud.metastore.v1beta.IListFederationsResponse, + ]) => { + this._log.info('listFederations values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listFederations`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the location of metastore - * federations to list, in the following form: - * `projects/{project_number}/locations/{location_id}`. - * @param {number} [request.pageSize] - * Optional. The maximum number of federations to return. The response may - * contain less than the maximum number. If unspecified, no more than 500 - * services are returned. The maximum value is 1000; values above 1000 are - * changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous ListFederationServices - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * ListFederationServices must match the call that provided the - * page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.metastore.v1beta.Federation|Federation} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listFederationsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listFederations`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the location of metastore + * federations to list, in the following form: + * `projects/{project_number}/locations/{location_id}`. + * @param {number} [request.pageSize] + * Optional. The maximum number of federations to return. The response may + * contain less than the maximum number. If unspecified, no more than 500 + * services are returned. The maximum value is 1000; values above 1000 are + * changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous ListFederationServices + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * ListFederationServices must match the call that provided the + * page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.metastore.v1beta.Federation|Federation} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listFederationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listFederationsStream( - request?: protos.google.cloud.metastore.v1beta.IListFederationsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.metastore.v1beta.IListFederationsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listFederations']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listFederations stream %j', request); return this.descriptors.page.listFederations.createStream( this.innerApiCalls.listFederations as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listFederations`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The relative resource name of the location of metastore - * federations to list, in the following form: - * `projects/{project_number}/locations/{location_id}`. - * @param {number} [request.pageSize] - * Optional. The maximum number of federations to return. The response may - * contain less than the maximum number. If unspecified, no more than 500 - * services are returned. The maximum value is 1000; values above 1000 are - * changed to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous ListFederationServices - * call. Provide this token to retrieve the subsequent page. - * - * To retrieve the first page, supply an empty page token. - * - * When paginating, other parameters provided to - * ListFederationServices must match the call that provided the - * page token. - * @param {string} [request.filter] - * Optional. The filter to apply to list results. - * @param {string} [request.orderBy] - * Optional. Specify the ordering of results as described in [Sorting - * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). - * If not specified, the results will be sorted in the default order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.metastore.v1beta.Federation|Federation}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/dataproc_metastore_federation.list_federations.js - * region_tag:metastore_v1beta_generated_DataprocMetastoreFederation_ListFederations_async - */ + /** + * Equivalent to `listFederations`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The relative resource name of the location of metastore + * federations to list, in the following form: + * `projects/{project_number}/locations/{location_id}`. + * @param {number} [request.pageSize] + * Optional. The maximum number of federations to return. The response may + * contain less than the maximum number. If unspecified, no more than 500 + * services are returned. The maximum value is 1000; values above 1000 are + * changed to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous ListFederationServices + * call. Provide this token to retrieve the subsequent page. + * + * To retrieve the first page, supply an empty page token. + * + * When paginating, other parameters provided to + * ListFederationServices must match the call that provided the + * page token. + * @param {string} [request.filter] + * Optional. The filter to apply to list results. + * @param {string} [request.orderBy] + * Optional. Specify the ordering of results as described in [Sorting + * Order](https://cloud.google.com/apis/design/design_patterns#sorting_order). + * If not specified, the results will be sorted in the default order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.metastore.v1beta.Federation|Federation}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/dataproc_metastore_federation.list_federations.js + * region_tag:metastore_v1beta_generated_DataprocMetastoreFederation_ListFederations_async + */ listFederationsAsync( - request?: protos.google.cloud.metastore.v1beta.IListFederationsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.metastore.v1beta.IListFederationsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listFederations']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listFederations iterate %j', request); return this.descriptors.page.listFederations.asyncIterate( this.innerApiCalls['listFederations'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -1185,40 +1601,40 @@ export class DataprocMetastoreFederationClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -1232,41 +1648,41 @@ export class DataprocMetastoreFederationClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -1280,12 +1696,12 @@ export class DataprocMetastoreFederationClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -1320,12 +1736,11 @@ export class DataprocMetastoreFederationClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -1358,12 +1773,12 @@ export class DataprocMetastoreFederationClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -1406,22 +1821,22 @@ export class DataprocMetastoreFederationClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -1456,15 +1871,15 @@ export class DataprocMetastoreFederationClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - 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 ?? '', - }); + 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 ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -1498,7 +1913,7 @@ export class DataprocMetastoreFederationClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -1511,25 +1926,24 @@ export class DataprocMetastoreFederationClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -1568,22 +1982,22 @@ export class DataprocMetastoreFederationClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -1600,7 +2014,12 @@ export class DataprocMetastoreFederationClient { * @param {string} backup * @returns {string} Resource name string. */ - backupPath(project:string,location:string,service:string,backup:string) { + backupPath( + project: string, + location: string, + service: string, + backup: string, + ) { return this.pathTemplates.backupPathTemplate.render({ project: project, location: location, @@ -1661,7 +2080,7 @@ export class DataprocMetastoreFederationClient { * @param {string} federation * @returns {string} Resource name string. */ - federationPath(project:string,location:string,federation:string) { + federationPath(project: string, location: string, federation: string) { return this.pathTemplates.federationPathTemplate.render({ project: project, location: location, @@ -1677,7 +2096,8 @@ export class DataprocMetastoreFederationClient { * @returns {string} A string representing the project. */ matchProjectFromFederationName(federationName: string) { - return this.pathTemplates.federationPathTemplate.match(federationName).project; + return this.pathTemplates.federationPathTemplate.match(federationName) + .project; } /** @@ -1688,7 +2108,8 @@ export class DataprocMetastoreFederationClient { * @returns {string} A string representing the location. */ matchLocationFromFederationName(federationName: string) { - return this.pathTemplates.federationPathTemplate.match(federationName).location; + return this.pathTemplates.federationPathTemplate.match(federationName) + .location; } /** @@ -1699,7 +2120,8 @@ export class DataprocMetastoreFederationClient { * @returns {string} A string representing the federation. */ matchFederationFromFederationName(federationName: string) { - return this.pathTemplates.federationPathTemplate.match(federationName).federation; + return this.pathTemplates.federationPathTemplate.match(federationName) + .federation; } /** @@ -1709,7 +2131,7 @@ export class DataprocMetastoreFederationClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -1747,7 +2169,12 @@ export class DataprocMetastoreFederationClient { * @param {string} metadata_import * @returns {string} Resource name string. */ - metadataImportPath(project:string,location:string,service:string,metadataImport:string) { + metadataImportPath( + project: string, + location: string, + service: string, + metadataImport: string, + ) { return this.pathTemplates.metadataImportPathTemplate.render({ project: project, location: location, @@ -1764,7 +2191,9 @@ export class DataprocMetastoreFederationClient { * @returns {string} A string representing the project. */ matchProjectFromMetadataImportName(metadataImportName: string) { - return this.pathTemplates.metadataImportPathTemplate.match(metadataImportName).project; + return this.pathTemplates.metadataImportPathTemplate.match( + metadataImportName, + ).project; } /** @@ -1775,7 +2204,9 @@ export class DataprocMetastoreFederationClient { * @returns {string} A string representing the location. */ matchLocationFromMetadataImportName(metadataImportName: string) { - return this.pathTemplates.metadataImportPathTemplate.match(metadataImportName).location; + return this.pathTemplates.metadataImportPathTemplate.match( + metadataImportName, + ).location; } /** @@ -1786,7 +2217,9 @@ export class DataprocMetastoreFederationClient { * @returns {string} A string representing the service. */ matchServiceFromMetadataImportName(metadataImportName: string) { - return this.pathTemplates.metadataImportPathTemplate.match(metadataImportName).service; + return this.pathTemplates.metadataImportPathTemplate.match( + metadataImportName, + ).service; } /** @@ -1797,7 +2230,9 @@ export class DataprocMetastoreFederationClient { * @returns {string} A string representing the metadata_import. */ matchMetadataImportFromMetadataImportName(metadataImportName: string) { - return this.pathTemplates.metadataImportPathTemplate.match(metadataImportName).metadata_import; + return this.pathTemplates.metadataImportPathTemplate.match( + metadataImportName, + ).metadata_import; } /** @@ -1806,7 +2241,7 @@ export class DataprocMetastoreFederationClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -1831,7 +2266,7 @@ export class DataprocMetastoreFederationClient { * @param {string} service * @returns {string} Resource name string. */ - servicePath(project:string,location:string,service:string) { + servicePath(project: string, location: string, service: string) { return this.pathTemplates.servicePathTemplate.render({ project: project, location: location, @@ -1880,15 +2315,19 @@ export class DataprocMetastoreFederationClient { */ close(): Promise { if (this.dataprocMetastoreFederationStub && !this._terminated) { - return this.dataprocMetastoreFederationStub.then(stub => { + return this.dataprocMetastoreFederationStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-metastore/src/v1beta/index.ts b/packages/google-cloud-metastore/src/v1beta/index.ts index 649f07b7cdab..a6d4bbf0896b 100644 --- a/packages/google-cloud-metastore/src/v1beta/index.ts +++ b/packages/google-cloud-metastore/src/v1beta/index.ts @@ -16,5 +16,5 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {DataprocMetastoreClient} from './dataproc_metastore_client'; -export {DataprocMetastoreFederationClient} from './dataproc_metastore_federation_client'; +export { DataprocMetastoreClient } from './dataproc_metastore_client'; +export { DataprocMetastoreFederationClient } from './dataproc_metastore_federation_client'; diff --git a/packages/google-cloud-metastore/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-metastore/system-test/fixtures/sample/src/index.ts index 1d3ebc0fc7e4..564ca880f553 100644 --- a/packages/google-cloud-metastore/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-metastore/system-test/fixtures/sample/src/index.ts @@ -16,13 +16,18 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {DataprocMetastoreClient, DataprocMetastoreFederationClient} from '@google-cloud/dataproc-metastore'; +import { + DataprocMetastoreClient, + DataprocMetastoreFederationClient, +} from '@google-cloud/dataproc-metastore'; // check that the client class type name can be used function doStuffWithDataprocMetastoreClient(client: DataprocMetastoreClient) { client.close(); } -function doStuffWithDataprocMetastoreFederationClient(client: DataprocMetastoreFederationClient) { +function doStuffWithDataprocMetastoreFederationClient( + client: DataprocMetastoreFederationClient, +) { client.close(); } @@ -31,8 +36,11 @@ function main() { const dataprocMetastoreClient = new DataprocMetastoreClient(); doStuffWithDataprocMetastoreClient(dataprocMetastoreClient); // check that the client instance can be created - const dataprocMetastoreFederationClient = new DataprocMetastoreFederationClient(); - doStuffWithDataprocMetastoreFederationClient(dataprocMetastoreFederationClient); + const dataprocMetastoreFederationClient = + new DataprocMetastoreFederationClient(); + doStuffWithDataprocMetastoreFederationClient( + dataprocMetastoreFederationClient, + ); } main(); diff --git a/packages/google-cloud-metastore/system-test/install.ts b/packages/google-cloud-metastore/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-metastore/system-test/install.ts +++ b/packages/google-cloud-metastore/system-test/install.ts @@ -16,34 +16,36 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {packNTest} from 'pack-n-play'; -import {readFileSync} from 'fs'; -import {describe, it} from 'mocha'; +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; +import { describe, it } from 'mocha'; describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { + it('TypeScript code', async function () { this.timeout(300000); const options = { packageDir: process.cwd(), sample: { description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } + ts: readFileSync( + './system-test/fixtures/sample/src/index.ts', + ).toString(), + }, }; await packNTest(options); }); - it('JavaScript code', async function() { + it('JavaScript code', async function () { this.timeout(300000); const options = { packageDir: process.cwd(), sample: { description: 'JavaScript user can use the library', - cjs: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } + cjs: readFileSync( + './system-test/fixtures/sample/src/index.js', + ).toString(), + }, }; await packNTest(options); }); - }); diff --git a/packages/google-cloud-metastore/test/gapic_dataproc_metastore_federation_v1.ts b/packages/google-cloud-metastore/test/gapic_dataproc_metastore_federation_v1.ts index 0c514953f97a..8ad6806a3371 100644 --- a/packages/google-cloud-metastore/test/gapic_dataproc_metastore_federation_v1.ts +++ b/packages/google-cloud-metastore/test/gapic_dataproc_metastore_federation_v1.ts @@ -19,2046 +19,2809 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as dataprocmetastorefederationModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + IamProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1.DataprocMetastoreFederationClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'metastore.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient.servicePath; - assert.strictEqual(servicePath, 'metastore.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'metastore.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'metastore.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'metastore.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'metastore.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'metastore.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient.port; - assert(port); - assert(typeof port === 'number'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'metastore.googleapis.com'); + }); - it('should create a client with no option', () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient(); - assert(client); - }); + it('has universeDomain', () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - fallback: true, - }); - assert(client); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient + .servicePath; + assert.strictEqual(servicePath, 'metastore.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient + .apiEndpoint; + assert.strictEqual(apiEndpoint, 'metastore.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { universeDomain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'metastore.example.com'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.dataprocMetastoreFederationStub, undefined); - await client.initialize(); - assert(client.dataprocMetastoreFederationStub); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { universe_domain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'metastore.example.com'); + }); - it('has close method for the initialized client', done => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.dataprocMetastoreFederationStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'metastore.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { universeDomain: 'configured.example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'metastore.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { universe_domain: 'example.com', universeDomain: 'example.net' }, + ); + }); + }); - it('has close method for the non-initialized client', done => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.dataprocMetastoreFederationStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has port', () => { + const port = + dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient + .port; + assert(port); + assert(typeof port === 'number'); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); + it('should create a client with no option', () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient(); + assert(client); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); + it('should create a client with gRPC fallback', () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + fallback: true, + }, + ); + assert(client); }); - describe('getFederation', () => { - it('invokes getFederation without error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.GetFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.GetFederationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.metastore.v1.Federation() - ); - client.innerApiCalls.getFederation = stubSimpleCall(expectedResponse); - const [response] = await client.getFederation(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.dataprocMetastoreFederationStub, undefined); + await client.initialize(); + assert(client.dataprocMetastoreFederationStub); + }); - it('invokes getFederation without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.GetFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.GetFederationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.metastore.v1.Federation() - ); - client.innerApiCalls.getFederation = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getFederation( - request, - (err?: Error|null, result?: protos.google.cloud.metastore.v1.IFederation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the initialized client', (done) => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.initialize().catch((err) => { + throw err; + }); + assert(client.dataprocMetastoreFederationStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getFederation with error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.GetFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.GetFederationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getFederation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getFederation(request), expectedError); - const actualRequest = (client.innerApiCalls.getFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the non-initialized client', (done) => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.dataprocMetastoreFederationStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getFederation with closed client', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.GetFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.GetFederationRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getFederation(request), expectedError); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); }); - describe('createFederation', () => { - it('invokes createFederation without error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.CreateFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.CreateFederationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createFederation = stubLongRunningCall(expectedResponse); - const [operation] = await client.createFederation(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getFederation', () => { + it('invokes getFederation without error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.GetFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.GetFederationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.metastore.v1.Federation(), + ); + client.innerApiCalls.getFederation = stubSimpleCall(expectedResponse); + const [response] = await client.getFederation(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createFederation without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.CreateFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.CreateFederationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createFederation = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createFederation( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getFederation without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.GetFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.GetFederationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.metastore.v1.Federation(), + ); + client.innerApiCalls.getFederation = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getFederation( + request, + ( + err?: Error | null, + result?: protos.google.cloud.metastore.v1.IFederation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createFederation with call error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.CreateFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.CreateFederationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createFederation = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createFederation(request), expectedError); - const actualRequest = (client.innerApiCalls.createFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getFederation with error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.GetFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.GetFederationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getFederation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getFederation(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createFederation with LRO error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.CreateFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.CreateFederationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createFederation = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createFederation(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getFederation with closed client', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.GetFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.GetFederationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getFederation(request), expectedError); + }); + }); + + describe('createFederation', () => { + it('invokes createFederation without error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.CreateFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.CreateFederationRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createFederation = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createFederation(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateFederationProgress without error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateFederationProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createFederation without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.CreateFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.CreateFederationRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createFederation = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createFederation( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1.IFederation, + protos.google.cloud.metastore.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1.IFederation, + protos.google.cloud.metastore.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateFederationProgress with error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateFederationProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createFederation with call error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.CreateFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.CreateFederationRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createFederation = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createFederation(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateFederation', () => { - it('invokes updateFederation without error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.UpdateFederationRequest() - ); - request.federation ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.UpdateFederationRequest', ['federation', 'name']); - request.federation.name = defaultValue1; - const expectedHeaderRequestParams = `federation.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateFederation = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateFederation(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createFederation with LRO error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.CreateFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.CreateFederationRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createFederation = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createFederation(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateFederation without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.UpdateFederationRequest() - ); - request.federation ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.UpdateFederationRequest', ['federation', 'name']); - request.federation.name = defaultValue1; - const expectedHeaderRequestParams = `federation.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateFederation = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateFederation( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateFederationProgress without error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkCreateFederationProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateFederation with call error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.UpdateFederationRequest() - ); - request.federation ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.UpdateFederationRequest', ['federation', 'name']); - request.federation.name = defaultValue1; - const expectedHeaderRequestParams = `federation.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateFederation = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateFederation(request), expectedError); - const actualRequest = (client.innerApiCalls.updateFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateFederationProgress with error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateFederationProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateFederation', () => { + it('invokes updateFederation without error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.UpdateFederationRequest(), + ); + request.federation ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.UpdateFederationRequest', + ['federation', 'name'], + ); + request.federation.name = defaultValue1; + const expectedHeaderRequestParams = `federation.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateFederation = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateFederation(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateFederation with LRO error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.UpdateFederationRequest() - ); - request.federation ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.UpdateFederationRequest', ['federation', 'name']); - request.federation.name = defaultValue1; - const expectedHeaderRequestParams = `federation.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateFederation = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateFederation(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateFederation without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.UpdateFederationRequest(), + ); + request.federation ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.UpdateFederationRequest', + ['federation', 'name'], + ); + request.federation.name = defaultValue1; + const expectedHeaderRequestParams = `federation.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateFederation = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateFederation( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1.IFederation, + protos.google.cloud.metastore.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1.IFederation, + protos.google.cloud.metastore.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateFederationProgress without error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateFederationProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateFederation with call error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.UpdateFederationRequest(), + ); + request.federation ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.UpdateFederationRequest', + ['federation', 'name'], + ); + request.federation.name = defaultValue1; + const expectedHeaderRequestParams = `federation.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateFederation = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateFederation(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateFederationProgress with error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateFederationProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateFederation with LRO error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.UpdateFederationRequest(), + ); + request.federation ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.UpdateFederationRequest', + ['federation', 'name'], + ); + request.federation.name = defaultValue1; + const expectedHeaderRequestParams = `federation.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateFederation = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateFederation(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteFederation', () => { - it('invokes deleteFederation without error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.DeleteFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.DeleteFederationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteFederation = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteFederation(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateFederationProgress without error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkUpdateFederationProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteFederation without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.DeleteFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.DeleteFederationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteFederation = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteFederation( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateFederationProgress with error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateFederationProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteFederation', () => { + it('invokes deleteFederation without error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.DeleteFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.DeleteFederationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteFederation = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteFederation(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteFederation with call error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.DeleteFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.DeleteFederationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteFederation = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteFederation(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteFederation without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.DeleteFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.DeleteFederationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteFederation = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteFederation( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteFederation with LRO error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.DeleteFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.DeleteFederationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteFederation = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteFederation(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteFederation with call error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.DeleteFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.DeleteFederationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteFederation = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteFederation(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteFederationProgress without error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteFederationProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteFederation with LRO error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.DeleteFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.DeleteFederationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteFederation = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteFederation(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteFederationProgress with error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteFederationProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteFederationProgress without error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkDeleteFederationProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('listFederations', () => { - it('invokes listFederations without error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ListFederationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ListFederationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1.Federation()), - generateSampleMessage(new protos.google.cloud.metastore.v1.Federation()), - generateSampleMessage(new protos.google.cloud.metastore.v1.Federation()), - ]; - client.innerApiCalls.listFederations = stubSimpleCall(expectedResponse); - const [response] = await client.listFederations(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listFederations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listFederations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteFederationProgress with error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteFederationProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listFederations', () => { + it('invokes listFederations without error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ListFederationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ListFederationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1.Federation(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1.Federation(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1.Federation(), + ), + ]; + client.innerApiCalls.listFederations = stubSimpleCall(expectedResponse); + const [response] = await client.listFederations(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listFederations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFederations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listFederations without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ListFederationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ListFederationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1.Federation()), - generateSampleMessage(new protos.google.cloud.metastore.v1.Federation()), - generateSampleMessage(new protos.google.cloud.metastore.v1.Federation()), - ]; - client.innerApiCalls.listFederations = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listFederations( - request, - (err?: Error|null, result?: protos.google.cloud.metastore.v1.IFederation[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listFederations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listFederations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listFederations without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ListFederationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ListFederationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1.Federation(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1.Federation(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1.Federation(), + ), + ]; + client.innerApiCalls.listFederations = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listFederations( + request, + ( + err?: Error | null, + result?: protos.google.cloud.metastore.v1.IFederation[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listFederations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFederations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listFederations with error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ListFederationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ListFederationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listFederations = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listFederations(request), expectedError); - const actualRequest = (client.innerApiCalls.listFederations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listFederations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listFederations with error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ListFederationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ListFederationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listFederations = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listFederations(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listFederations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFederations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listFederationsStream without error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ListFederationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ListFederationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1.Federation()), - generateSampleMessage(new protos.google.cloud.metastore.v1.Federation()), - generateSampleMessage(new protos.google.cloud.metastore.v1.Federation()), - ]; - client.descriptors.page.listFederations.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listFederationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.metastore.v1.Federation[] = []; - stream.on('data', (response: protos.google.cloud.metastore.v1.Federation) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listFederations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listFederations, request)); - assert( - (client.descriptors.page.listFederations.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listFederationsStream without error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ListFederationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ListFederationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1.Federation(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1.Federation(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1.Federation(), + ), + ]; + client.descriptors.page.listFederations.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listFederationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.metastore.v1.Federation[] = []; + stream.on( + 'data', + (response: protos.google.cloud.metastore.v1.Federation) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listFederations.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listFederations, request), + ); + assert( + (client.descriptors.page.listFederations.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listFederationsStream with error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ListFederationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ListFederationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listFederations.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listFederationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.metastore.v1.Federation[] = []; - stream.on('data', (response: protos.google.cloud.metastore.v1.Federation) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listFederations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listFederations, request)); - assert( - (client.descriptors.page.listFederations.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listFederationsStream with error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ListFederationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ListFederationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listFederations.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listFederationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.metastore.v1.Federation[] = []; + stream.on( + 'data', + (response: protos.google.cloud.metastore.v1.Federation) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listFederations.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listFederations, request), + ); + assert( + (client.descriptors.page.listFederations.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listFederations without error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ListFederationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ListFederationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1.Federation()), - generateSampleMessage(new protos.google.cloud.metastore.v1.Federation()), - generateSampleMessage(new protos.google.cloud.metastore.v1.Federation()), - ]; - client.descriptors.page.listFederations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.metastore.v1.IFederation[] = []; - const iterable = client.listFederationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listFederations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listFederations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listFederations without error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ListFederationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ListFederationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1.Federation(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1.Federation(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1.Federation(), + ), + ]; + client.descriptors.page.listFederations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.metastore.v1.IFederation[] = []; + const iterable = client.listFederationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listFederations.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listFederations.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listFederations with error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ListFederationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ListFederationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listFederations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listFederationsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.metastore.v1.IFederation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listFederations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listFederations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listFederations with error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ListFederationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ListFederationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listFederations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listFederationsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.metastore.v1.IFederation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listFederations.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listFederations.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy with error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes setIamPolicy without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes setIamPolicy with error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes testIamPermissions without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes testIamPermissions with error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('backup', async () => { + const fakePath = '/rendered/path/backup'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service: 'serviceValue', + backup: 'backupValue', + }; + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.backupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.backupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('backupPath', () => { + const result = client.backupPath( + 'projectValue', + 'locationValue', + 'serviceValue', + 'backupValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.backupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromBackupName', () => { + const result = client.matchProjectFromBackupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromBackupName', () => { + const result = client.matchLocationFromBackupName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceFromBackupName', () => { + const result = client.matchServiceFromBackupName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchBackupFromBackupName', () => { + const result = client.matchBackupFromBackupName(fakePath); + assert.strictEqual(result, 'backupValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('backup', async () => { - const fakePath = "/rendered/path/backup"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - backup: "backupValue", - }; - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.backupPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.backupPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('backupPath', () => { - const result = client.backupPath("projectValue", "locationValue", "serviceValue", "backupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.backupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBackupName', () => { - const result = client.matchProjectFromBackupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBackupName', () => { - const result = client.matchLocationFromBackupName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromBackupName', () => { - const result = client.matchServiceFromBackupName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBackupFromBackupName', () => { - const result = client.matchBackupFromBackupName(fakePath); - assert.strictEqual(result, "backupValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('federation', async () => { - const fakePath = "/rendered/path/federation"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - federation: "federationValue", - }; - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.federationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.federationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('federationPath', () => { - const result = client.federationPath("projectValue", "locationValue", "federationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.federationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromFederationName', () => { - const result = client.matchProjectFromFederationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.federationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromFederationName', () => { - const result = client.matchLocationFromFederationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.federationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchFederationFromFederationName', () => { - const result = client.matchFederationFromFederationName(fakePath); - assert.strictEqual(result, "federationValue"); - assert((client.pathTemplates.federationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('federation', async () => { + const fakePath = '/rendered/path/federation'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + federation: 'federationValue', + }; + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.federationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.federationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('federationPath', () => { + const result = client.federationPath( + 'projectValue', + 'locationValue', + 'federationValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.federationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromFederationName', () => { + const result = client.matchProjectFromFederationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.federationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromFederationName', () => { + const result = client.matchLocationFromFederationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.federationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchFederationFromFederationName', () => { + const result = client.matchFederationFromFederationName(fakePath); + assert.strictEqual(result, 'federationValue'); + assert( + (client.pathTemplates.federationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('metadataImport', async () => { - const fakePath = "/rendered/path/metadataImport"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - metadata_import: "metadataImportValue", - }; - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.metadataImportPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.metadataImportPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('metadataImportPath', () => { - const result = client.metadataImportPath("projectValue", "locationValue", "serviceValue", "metadataImportValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.metadataImportPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMetadataImportName', () => { - const result = client.matchProjectFromMetadataImportName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.metadataImportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMetadataImportName', () => { - const result = client.matchLocationFromMetadataImportName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.metadataImportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromMetadataImportName', () => { - const result = client.matchServiceFromMetadataImportName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.metadataImportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMetadataImportFromMetadataImportName', () => { - const result = client.matchMetadataImportFromMetadataImportName(fakePath); - assert.strictEqual(result, "metadataImportValue"); - assert((client.pathTemplates.metadataImportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('metadataImport', async () => { + const fakePath = '/rendered/path/metadataImport'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service: 'serviceValue', + metadata_import: 'metadataImportValue', + }; + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.metadataImportPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.metadataImportPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('metadataImportPath', () => { + const result = client.metadataImportPath( + 'projectValue', + 'locationValue', + 'serviceValue', + 'metadataImportValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.metadataImportPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMetadataImportName', () => { + const result = client.matchProjectFromMetadataImportName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.metadataImportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMetadataImportName', () => { + const result = client.matchLocationFromMetadataImportName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.metadataImportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceFromMetadataImportName', () => { + const result = client.matchServiceFromMetadataImportName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.metadataImportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMetadataImportFromMetadataImportName', () => { + const result = + client.matchMetadataImportFromMetadataImportName(fakePath); + assert.strictEqual(result, 'metadataImportValue'); + assert( + (client.pathTemplates.metadataImportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.projectPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('service', async () => { - const fakePath = "/rendered/path/service"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - }; - const client = new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.servicePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servicePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servicePath', () => { - const result = client.servicePath("projectValue", "locationValue", "serviceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servicePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceName', () => { - const result = client.matchProjectFromServiceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServiceName', () => { - const result = client.matchLocationFromServiceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromServiceName', () => { - const result = client.matchServiceFromServiceName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('service', async () => { + const fakePath = '/rendered/path/service'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service: 'serviceValue', + }; + const client = + new dataprocmetastorefederationModule.v1.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.servicePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servicePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servicePath', () => { + const result = client.servicePath( + 'projectValue', + 'locationValue', + 'serviceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servicePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceName', () => { + const result = client.matchProjectFromServiceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromServiceName', () => { + const result = client.matchLocationFromServiceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceFromServiceName', () => { + const result = client.matchServiceFromServiceName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-metastore/test/gapic_dataproc_metastore_federation_v1alpha.ts b/packages/google-cloud-metastore/test/gapic_dataproc_metastore_federation_v1alpha.ts index a32a80b5efe5..8c564d6f888d 100644 --- a/packages/google-cloud-metastore/test/gapic_dataproc_metastore_federation_v1alpha.ts +++ b/packages/google-cloud-metastore/test/gapic_dataproc_metastore_federation_v1alpha.ts @@ -19,2046 +19,2812 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as dataprocmetastorefederationModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + IamProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1alpha.DataprocMetastoreFederationClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'metastore.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient.servicePath; - assert.strictEqual(servicePath, 'metastore.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'metastore.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'metastore.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'metastore.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'metastore.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'metastore.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient.port; - assert(port); - assert(typeof port === 'number'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'metastore.googleapis.com'); + }); - it('should create a client with no option', () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient(); - assert(client); - }); + it('has universeDomain', () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - fallback: true, - }); - assert(client); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + dataprocmetastorefederationModule.v1alpha + .DataprocMetastoreFederationClient.servicePath; + assert.strictEqual(servicePath, 'metastore.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + dataprocmetastorefederationModule.v1alpha + .DataprocMetastoreFederationClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'metastore.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { universeDomain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'metastore.example.com'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.dataprocMetastoreFederationStub, undefined); - await client.initialize(); - assert(client.dataprocMetastoreFederationStub); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { universe_domain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'metastore.example.com'); + }); - it('has close method for the initialized client', done => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.dataprocMetastoreFederationStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'metastore.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { universeDomain: 'configured.example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'metastore.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { universe_domain: 'example.com', universeDomain: 'example.net' }, + ); + }); + }); - it('has close method for the non-initialized client', done => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.dataprocMetastoreFederationStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has port', () => { + const port = + dataprocmetastorefederationModule.v1alpha + .DataprocMetastoreFederationClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); + it('should create a client with no option', () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient(); + assert(client); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); + it('should create a client with gRPC fallback', () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + fallback: true, + }, + ); + assert(client); }); - describe('getFederation', () => { - it('invokes getFederation without error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.GetFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.GetFederationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.Federation() - ); - client.innerApiCalls.getFederation = stubSimpleCall(expectedResponse); - const [response] = await client.getFederation(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.dataprocMetastoreFederationStub, undefined); + await client.initialize(); + assert(client.dataprocMetastoreFederationStub); + }); - it('invokes getFederation without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.GetFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.GetFederationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.Federation() - ); - client.innerApiCalls.getFederation = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getFederation( - request, - (err?: Error|null, result?: protos.google.cloud.metastore.v1alpha.IFederation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the initialized client', (done) => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.initialize().catch((err) => { + throw err; + }); + assert(client.dataprocMetastoreFederationStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getFederation with error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.GetFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.GetFederationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getFederation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getFederation(request), expectedError); - const actualRequest = (client.innerApiCalls.getFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the non-initialized client', (done) => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.dataprocMetastoreFederationStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getFederation with closed client', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.GetFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.GetFederationRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getFederation(request), expectedError); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); }); - describe('createFederation', () => { - it('invokes createFederation without error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.CreateFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.CreateFederationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createFederation = stubLongRunningCall(expectedResponse); - const [operation] = await client.createFederation(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getFederation', () => { + it('invokes getFederation without error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.GetFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.GetFederationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Federation(), + ); + client.innerApiCalls.getFederation = stubSimpleCall(expectedResponse); + const [response] = await client.getFederation(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createFederation without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.CreateFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.CreateFederationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createFederation = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createFederation( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getFederation without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.GetFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.GetFederationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Federation(), + ); + client.innerApiCalls.getFederation = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getFederation( + request, + ( + err?: Error | null, + result?: protos.google.cloud.metastore.v1alpha.IFederation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createFederation with call error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.CreateFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.CreateFederationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createFederation = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createFederation(request), expectedError); - const actualRequest = (client.innerApiCalls.createFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getFederation with error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.GetFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.GetFederationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getFederation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getFederation(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createFederation with LRO error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.CreateFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.CreateFederationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createFederation = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createFederation(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getFederation with closed client', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.GetFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.GetFederationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getFederation(request), expectedError); + }); + }); + + describe('createFederation', () => { + it('invokes createFederation without error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.CreateFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.CreateFederationRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createFederation = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createFederation(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateFederationProgress without error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateFederationProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createFederation without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.CreateFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.CreateFederationRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createFederation = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createFederation( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1alpha.IFederation, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1alpha.IFederation, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateFederationProgress with error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateFederationProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createFederation with call error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.CreateFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.CreateFederationRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createFederation = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createFederation(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateFederation', () => { - it('invokes updateFederation without error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.UpdateFederationRequest() - ); - request.federation ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.UpdateFederationRequest', ['federation', 'name']); - request.federation.name = defaultValue1; - const expectedHeaderRequestParams = `federation.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateFederation = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateFederation(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createFederation with LRO error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.CreateFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.CreateFederationRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createFederation = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createFederation(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateFederation without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.UpdateFederationRequest() - ); - request.federation ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.UpdateFederationRequest', ['federation', 'name']); - request.federation.name = defaultValue1; - const expectedHeaderRequestParams = `federation.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateFederation = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateFederation( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateFederationProgress without error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkCreateFederationProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateFederation with call error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.UpdateFederationRequest() - ); - request.federation ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.UpdateFederationRequest', ['federation', 'name']); - request.federation.name = defaultValue1; - const expectedHeaderRequestParams = `federation.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateFederation = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateFederation(request), expectedError); - const actualRequest = (client.innerApiCalls.updateFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateFederationProgress with error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateFederationProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateFederation', () => { + it('invokes updateFederation without error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.UpdateFederationRequest(), + ); + request.federation ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.UpdateFederationRequest', + ['federation', 'name'], + ); + request.federation.name = defaultValue1; + const expectedHeaderRequestParams = `federation.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateFederation = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateFederation(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateFederation with LRO error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.UpdateFederationRequest() - ); - request.federation ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.UpdateFederationRequest', ['federation', 'name']); - request.federation.name = defaultValue1; - const expectedHeaderRequestParams = `federation.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateFederation = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateFederation(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateFederation without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.UpdateFederationRequest(), + ); + request.federation ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.UpdateFederationRequest', + ['federation', 'name'], + ); + request.federation.name = defaultValue1; + const expectedHeaderRequestParams = `federation.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateFederation = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateFederation( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1alpha.IFederation, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1alpha.IFederation, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateFederationProgress without error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateFederationProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateFederation with call error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.UpdateFederationRequest(), + ); + request.federation ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.UpdateFederationRequest', + ['federation', 'name'], + ); + request.federation.name = defaultValue1; + const expectedHeaderRequestParams = `federation.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateFederation = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateFederation(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateFederationProgress with error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateFederationProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateFederation with LRO error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.UpdateFederationRequest(), + ); + request.federation ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.UpdateFederationRequest', + ['federation', 'name'], + ); + request.federation.name = defaultValue1; + const expectedHeaderRequestParams = `federation.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateFederation = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateFederation(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteFederation', () => { - it('invokes deleteFederation without error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.DeleteFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.DeleteFederationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteFederation = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteFederation(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateFederationProgress without error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkUpdateFederationProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteFederation without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.DeleteFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.DeleteFederationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteFederation = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteFederation( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateFederationProgress with error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateFederationProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteFederation', () => { + it('invokes deleteFederation without error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.DeleteFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.DeleteFederationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteFederation = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteFederation(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteFederation with call error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.DeleteFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.DeleteFederationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteFederation = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteFederation(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteFederation without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.DeleteFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.DeleteFederationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteFederation = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteFederation( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteFederation with LRO error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.DeleteFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.DeleteFederationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteFederation = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteFederation(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteFederation with call error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.DeleteFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.DeleteFederationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteFederation = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteFederation(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteFederationProgress without error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteFederationProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteFederation with LRO error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.DeleteFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.DeleteFederationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteFederation = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteFederation(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteFederationProgress with error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteFederationProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteFederationProgress without error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkDeleteFederationProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('listFederations', () => { - it('invokes listFederations without error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ListFederationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ListFederationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Federation()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Federation()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Federation()), - ]; - client.innerApiCalls.listFederations = stubSimpleCall(expectedResponse); - const [response] = await client.listFederations(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listFederations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listFederations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteFederationProgress with error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteFederationProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listFederations', () => { + it('invokes listFederations without error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ListFederationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ListFederationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Federation(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Federation(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Federation(), + ), + ]; + client.innerApiCalls.listFederations = stubSimpleCall(expectedResponse); + const [response] = await client.listFederations(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listFederations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFederations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listFederations without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ListFederationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ListFederationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Federation()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Federation()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Federation()), - ]; - client.innerApiCalls.listFederations = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listFederations( - request, - (err?: Error|null, result?: protos.google.cloud.metastore.v1alpha.IFederation[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listFederations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listFederations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listFederations without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ListFederationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ListFederationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Federation(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Federation(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Federation(), + ), + ]; + client.innerApiCalls.listFederations = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listFederations( + request, + ( + err?: Error | null, + result?: protos.google.cloud.metastore.v1alpha.IFederation[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listFederations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFederations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listFederations with error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ListFederationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ListFederationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listFederations = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listFederations(request), expectedError); - const actualRequest = (client.innerApiCalls.listFederations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listFederations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listFederations with error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ListFederationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ListFederationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listFederations = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listFederations(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listFederations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFederations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listFederationsStream without error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ListFederationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ListFederationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Federation()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Federation()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Federation()), - ]; - client.descriptors.page.listFederations.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listFederationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.metastore.v1alpha.Federation[] = []; - stream.on('data', (response: protos.google.cloud.metastore.v1alpha.Federation) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listFederations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listFederations, request)); - assert( - (client.descriptors.page.listFederations.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listFederationsStream without error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ListFederationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ListFederationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Federation(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Federation(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Federation(), + ), + ]; + client.descriptors.page.listFederations.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listFederationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.metastore.v1alpha.Federation[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.metastore.v1alpha.Federation) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listFederations.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listFederations, request), + ); + assert( + (client.descriptors.page.listFederations.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listFederationsStream with error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ListFederationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ListFederationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listFederations.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listFederationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.metastore.v1alpha.Federation[] = []; - stream.on('data', (response: protos.google.cloud.metastore.v1alpha.Federation) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listFederations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listFederations, request)); - assert( - (client.descriptors.page.listFederations.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listFederationsStream with error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ListFederationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ListFederationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listFederations.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listFederationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.metastore.v1alpha.Federation[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.metastore.v1alpha.Federation) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listFederations.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listFederations, request), + ); + assert( + (client.descriptors.page.listFederations.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listFederations without error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ListFederationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ListFederationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Federation()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Federation()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Federation()), - ]; - client.descriptors.page.listFederations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.metastore.v1alpha.IFederation[] = []; - const iterable = client.listFederationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listFederations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listFederations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listFederations without error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ListFederationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ListFederationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Federation(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Federation(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Federation(), + ), + ]; + client.descriptors.page.listFederations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.metastore.v1alpha.IFederation[] = []; + const iterable = client.listFederationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listFederations.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listFederations.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listFederations with error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ListFederationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ListFederationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listFederations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listFederationsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.metastore.v1alpha.IFederation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listFederations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listFederations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listFederations with error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ListFederationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ListFederationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listFederations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listFederationsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.metastore.v1alpha.IFederation[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listFederations.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listFederations.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy with error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes setIamPolicy without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes setIamPolicy with error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes testIamPermissions without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes testIamPermissions with error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('backup', async () => { + const fakePath = '/rendered/path/backup'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service: 'serviceValue', + backup: 'backupValue', + }; + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.backupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.backupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('backupPath', () => { + const result = client.backupPath( + 'projectValue', + 'locationValue', + 'serviceValue', + 'backupValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.backupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromBackupName', () => { + const result = client.matchProjectFromBackupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromBackupName', () => { + const result = client.matchLocationFromBackupName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceFromBackupName', () => { + const result = client.matchServiceFromBackupName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchBackupFromBackupName', () => { + const result = client.matchBackupFromBackupName(fakePath); + assert.strictEqual(result, 'backupValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('backup', async () => { - const fakePath = "/rendered/path/backup"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - backup: "backupValue", - }; - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.backupPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.backupPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('backupPath', () => { - const result = client.backupPath("projectValue", "locationValue", "serviceValue", "backupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.backupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBackupName', () => { - const result = client.matchProjectFromBackupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBackupName', () => { - const result = client.matchLocationFromBackupName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromBackupName', () => { - const result = client.matchServiceFromBackupName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBackupFromBackupName', () => { - const result = client.matchBackupFromBackupName(fakePath); - assert.strictEqual(result, "backupValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('federation', async () => { - const fakePath = "/rendered/path/federation"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - federation: "federationValue", - }; - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.federationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.federationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('federationPath', () => { - const result = client.federationPath("projectValue", "locationValue", "federationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.federationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromFederationName', () => { - const result = client.matchProjectFromFederationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.federationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromFederationName', () => { - const result = client.matchLocationFromFederationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.federationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchFederationFromFederationName', () => { - const result = client.matchFederationFromFederationName(fakePath); - assert.strictEqual(result, "federationValue"); - assert((client.pathTemplates.federationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('federation', async () => { + const fakePath = '/rendered/path/federation'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + federation: 'federationValue', + }; + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.federationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.federationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('federationPath', () => { + const result = client.federationPath( + 'projectValue', + 'locationValue', + 'federationValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.federationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromFederationName', () => { + const result = client.matchProjectFromFederationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.federationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromFederationName', () => { + const result = client.matchLocationFromFederationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.federationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchFederationFromFederationName', () => { + const result = client.matchFederationFromFederationName(fakePath); + assert.strictEqual(result, 'federationValue'); + assert( + (client.pathTemplates.federationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('metadataImport', async () => { - const fakePath = "/rendered/path/metadataImport"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - metadata_import: "metadataImportValue", - }; - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.metadataImportPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.metadataImportPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('metadataImportPath', () => { - const result = client.metadataImportPath("projectValue", "locationValue", "serviceValue", "metadataImportValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.metadataImportPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMetadataImportName', () => { - const result = client.matchProjectFromMetadataImportName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.metadataImportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMetadataImportName', () => { - const result = client.matchLocationFromMetadataImportName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.metadataImportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromMetadataImportName', () => { - const result = client.matchServiceFromMetadataImportName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.metadataImportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMetadataImportFromMetadataImportName', () => { - const result = client.matchMetadataImportFromMetadataImportName(fakePath); - assert.strictEqual(result, "metadataImportValue"); - assert((client.pathTemplates.metadataImportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('metadataImport', async () => { + const fakePath = '/rendered/path/metadataImport'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service: 'serviceValue', + metadata_import: 'metadataImportValue', + }; + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.metadataImportPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.metadataImportPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('metadataImportPath', () => { + const result = client.metadataImportPath( + 'projectValue', + 'locationValue', + 'serviceValue', + 'metadataImportValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.metadataImportPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMetadataImportName', () => { + const result = client.matchProjectFromMetadataImportName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.metadataImportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMetadataImportName', () => { + const result = client.matchLocationFromMetadataImportName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.metadataImportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceFromMetadataImportName', () => { + const result = client.matchServiceFromMetadataImportName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.metadataImportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMetadataImportFromMetadataImportName', () => { + const result = + client.matchMetadataImportFromMetadataImportName(fakePath); + assert.strictEqual(result, 'metadataImportValue'); + assert( + (client.pathTemplates.metadataImportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.projectPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('service', async () => { - const fakePath = "/rendered/path/service"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - }; - const client = new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.servicePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servicePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servicePath', () => { - const result = client.servicePath("projectValue", "locationValue", "serviceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servicePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceName', () => { - const result = client.matchProjectFromServiceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServiceName', () => { - const result = client.matchLocationFromServiceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromServiceName', () => { - const result = client.matchServiceFromServiceName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('service', async () => { + const fakePath = '/rendered/path/service'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service: 'serviceValue', + }; + const client = + new dataprocmetastorefederationModule.v1alpha.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.servicePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servicePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servicePath', () => { + const result = client.servicePath( + 'projectValue', + 'locationValue', + 'serviceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servicePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceName', () => { + const result = client.matchProjectFromServiceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromServiceName', () => { + const result = client.matchLocationFromServiceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceFromServiceName', () => { + const result = client.matchServiceFromServiceName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-metastore/test/gapic_dataproc_metastore_federation_v1beta.ts b/packages/google-cloud-metastore/test/gapic_dataproc_metastore_federation_v1beta.ts index 1d28729e0934..5da9dc446c27 100644 --- a/packages/google-cloud-metastore/test/gapic_dataproc_metastore_federation_v1beta.ts +++ b/packages/google-cloud-metastore/test/gapic_dataproc_metastore_federation_v1beta.ts @@ -19,2046 +19,2810 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as dataprocmetastorefederationModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + IamProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1beta.DataprocMetastoreFederationClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'metastore.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient.servicePath; - assert.strictEqual(servicePath, 'metastore.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'metastore.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'metastore.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'metastore.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'metastore.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'metastore.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient.port; - assert(port); - assert(typeof port === 'number'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'metastore.googleapis.com'); + }); - it('should create a client with no option', () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient(); - assert(client); - }); + it('has universeDomain', () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - fallback: true, - }); - assert(client); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + dataprocmetastorefederationModule.v1beta + .DataprocMetastoreFederationClient.servicePath; + assert.strictEqual(servicePath, 'metastore.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + dataprocmetastorefederationModule.v1beta + .DataprocMetastoreFederationClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'metastore.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { universeDomain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'metastore.example.com'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.dataprocMetastoreFederationStub, undefined); - await client.initialize(); - assert(client.dataprocMetastoreFederationStub); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { universe_domain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'metastore.example.com'); + }); - it('has close method for the initialized client', done => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.dataprocMetastoreFederationStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'metastore.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { universeDomain: 'configured.example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'metastore.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { universe_domain: 'example.com', universeDomain: 'example.net' }, + ); + }); + }); - it('has close method for the non-initialized client', done => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.dataprocMetastoreFederationStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has port', () => { + const port = + dataprocmetastorefederationModule.v1beta + .DataprocMetastoreFederationClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); + it('should create a client with no option', () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient(); + assert(client); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); + it('should create a client with gRPC fallback', () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + fallback: true, + }, + ); + assert(client); }); - describe('getFederation', () => { - it('invokes getFederation without error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.GetFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.GetFederationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.Federation() - ); - client.innerApiCalls.getFederation = stubSimpleCall(expectedResponse); - const [response] = await client.getFederation(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.dataprocMetastoreFederationStub, undefined); + await client.initialize(); + assert(client.dataprocMetastoreFederationStub); + }); - it('invokes getFederation without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.GetFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.GetFederationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.Federation() - ); - client.innerApiCalls.getFederation = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getFederation( - request, - (err?: Error|null, result?: protos.google.cloud.metastore.v1beta.IFederation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the initialized client', (done) => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.initialize().catch((err) => { + throw err; + }); + assert(client.dataprocMetastoreFederationStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getFederation with error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.GetFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.GetFederationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getFederation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getFederation(request), expectedError); - const actualRequest = (client.innerApiCalls.getFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the non-initialized client', (done) => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.dataprocMetastoreFederationStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getFederation with closed client', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.GetFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.GetFederationRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getFederation(request), expectedError); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); }); - describe('createFederation', () => { - it('invokes createFederation without error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.CreateFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.CreateFederationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createFederation = stubLongRunningCall(expectedResponse); - const [operation] = await client.createFederation(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getFederation', () => { + it('invokes getFederation without error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.GetFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.GetFederationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Federation(), + ); + client.innerApiCalls.getFederation = stubSimpleCall(expectedResponse); + const [response] = await client.getFederation(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createFederation without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.CreateFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.CreateFederationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createFederation = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createFederation( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getFederation without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.GetFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.GetFederationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Federation(), + ); + client.innerApiCalls.getFederation = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getFederation( + request, + ( + err?: Error | null, + result?: protos.google.cloud.metastore.v1beta.IFederation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createFederation with call error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.CreateFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.CreateFederationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createFederation = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createFederation(request), expectedError); - const actualRequest = (client.innerApiCalls.createFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getFederation with error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.GetFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.GetFederationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getFederation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getFederation(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createFederation with LRO error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.CreateFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.CreateFederationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createFederation = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createFederation(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getFederation with closed client', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.GetFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.GetFederationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getFederation(request), expectedError); + }); + }); + + describe('createFederation', () => { + it('invokes createFederation without error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.CreateFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.CreateFederationRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createFederation = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createFederation(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateFederationProgress without error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateFederationProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createFederation without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.CreateFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.CreateFederationRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createFederation = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createFederation( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1beta.IFederation, + protos.google.cloud.metastore.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1beta.IFederation, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateFederationProgress with error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateFederationProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createFederation with call error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.CreateFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.CreateFederationRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createFederation = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createFederation(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateFederation', () => { - it('invokes updateFederation without error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.UpdateFederationRequest() - ); - request.federation ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.UpdateFederationRequest', ['federation', 'name']); - request.federation.name = defaultValue1; - const expectedHeaderRequestParams = `federation.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateFederation = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateFederation(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createFederation with LRO error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.CreateFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.CreateFederationRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createFederation = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createFederation(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateFederation without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.UpdateFederationRequest() - ); - request.federation ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.UpdateFederationRequest', ['federation', 'name']); - request.federation.name = defaultValue1; - const expectedHeaderRequestParams = `federation.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateFederation = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateFederation( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateFederationProgress without error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkCreateFederationProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateFederation with call error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.UpdateFederationRequest() - ); - request.federation ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.UpdateFederationRequest', ['federation', 'name']); - request.federation.name = defaultValue1; - const expectedHeaderRequestParams = `federation.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateFederation = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateFederation(request), expectedError); - const actualRequest = (client.innerApiCalls.updateFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateFederationProgress with error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateFederationProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateFederation', () => { + it('invokes updateFederation without error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.UpdateFederationRequest(), + ); + request.federation ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.UpdateFederationRequest', + ['federation', 'name'], + ); + request.federation.name = defaultValue1; + const expectedHeaderRequestParams = `federation.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateFederation = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateFederation(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateFederation with LRO error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.UpdateFederationRequest() - ); - request.federation ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.UpdateFederationRequest', ['federation', 'name']); - request.federation.name = defaultValue1; - const expectedHeaderRequestParams = `federation.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateFederation = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateFederation(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateFederation without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.UpdateFederationRequest(), + ); + request.federation ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.UpdateFederationRequest', + ['federation', 'name'], + ); + request.federation.name = defaultValue1; + const expectedHeaderRequestParams = `federation.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateFederation = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateFederation( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1beta.IFederation, + protos.google.cloud.metastore.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1beta.IFederation, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateFederationProgress without error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateFederationProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateFederation with call error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.UpdateFederationRequest(), + ); + request.federation ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.UpdateFederationRequest', + ['federation', 'name'], + ); + request.federation.name = defaultValue1; + const expectedHeaderRequestParams = `federation.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateFederation = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateFederation(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateFederationProgress with error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateFederationProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateFederation with LRO error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.UpdateFederationRequest(), + ); + request.federation ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.UpdateFederationRequest', + ['federation', 'name'], + ); + request.federation.name = defaultValue1; + const expectedHeaderRequestParams = `federation.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateFederation = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateFederation(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteFederation', () => { - it('invokes deleteFederation without error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.DeleteFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.DeleteFederationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteFederation = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteFederation(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateFederationProgress without error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkUpdateFederationProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteFederation without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.DeleteFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.DeleteFederationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteFederation = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteFederation( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateFederationProgress with error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateFederationProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteFederation', () => { + it('invokes deleteFederation without error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.DeleteFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.DeleteFederationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteFederation = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteFederation(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteFederation with call error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.DeleteFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.DeleteFederationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteFederation = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteFederation(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteFederation without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.DeleteFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.DeleteFederationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteFederation = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteFederation( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteFederation with LRO error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.DeleteFederationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.DeleteFederationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteFederation = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteFederation(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteFederation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFederation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteFederation with call error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.DeleteFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.DeleteFederationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteFederation = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteFederation(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteFederationProgress without error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteFederationProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteFederation with LRO error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.DeleteFederationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.DeleteFederationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteFederation = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteFederation(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteFederation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFederation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteFederationProgress with error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteFederationProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteFederationProgress without error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkDeleteFederationProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('listFederations', () => { - it('invokes listFederations without error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ListFederationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ListFederationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Federation()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Federation()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Federation()), - ]; - client.innerApiCalls.listFederations = stubSimpleCall(expectedResponse); - const [response] = await client.listFederations(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listFederations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listFederations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteFederationProgress with error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteFederationProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listFederations', () => { + it('invokes listFederations without error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ListFederationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ListFederationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Federation(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Federation(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Federation(), + ), + ]; + client.innerApiCalls.listFederations = stubSimpleCall(expectedResponse); + const [response] = await client.listFederations(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listFederations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFederations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listFederations without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ListFederationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ListFederationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Federation()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Federation()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Federation()), - ]; - client.innerApiCalls.listFederations = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listFederations( - request, - (err?: Error|null, result?: protos.google.cloud.metastore.v1beta.IFederation[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listFederations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listFederations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listFederations without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ListFederationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ListFederationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Federation(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Federation(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Federation(), + ), + ]; + client.innerApiCalls.listFederations = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listFederations( + request, + ( + err?: Error | null, + result?: protos.google.cloud.metastore.v1beta.IFederation[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listFederations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFederations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listFederations with error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ListFederationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ListFederationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listFederations = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listFederations(request), expectedError); - const actualRequest = (client.innerApiCalls.listFederations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listFederations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listFederations with error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ListFederationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ListFederationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listFederations = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listFederations(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listFederations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFederations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listFederationsStream without error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ListFederationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ListFederationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Federation()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Federation()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Federation()), - ]; - client.descriptors.page.listFederations.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listFederationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.metastore.v1beta.Federation[] = []; - stream.on('data', (response: protos.google.cloud.metastore.v1beta.Federation) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listFederations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listFederations, request)); - assert( - (client.descriptors.page.listFederations.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listFederationsStream without error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ListFederationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ListFederationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Federation(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Federation(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Federation(), + ), + ]; + client.descriptors.page.listFederations.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listFederationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.metastore.v1beta.Federation[] = []; + stream.on( + 'data', + (response: protos.google.cloud.metastore.v1beta.Federation) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listFederations.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listFederations, request), + ); + assert( + (client.descriptors.page.listFederations.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listFederationsStream with error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ListFederationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ListFederationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listFederations.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listFederationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.metastore.v1beta.Federation[] = []; - stream.on('data', (response: protos.google.cloud.metastore.v1beta.Federation) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listFederations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listFederations, request)); - assert( - (client.descriptors.page.listFederations.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listFederationsStream with error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ListFederationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ListFederationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listFederations.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listFederationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.metastore.v1beta.Federation[] = []; + stream.on( + 'data', + (response: protos.google.cloud.metastore.v1beta.Federation) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listFederations.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listFederations, request), + ); + assert( + (client.descriptors.page.listFederations.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listFederations without error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ListFederationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ListFederationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Federation()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Federation()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Federation()), - ]; - client.descriptors.page.listFederations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.metastore.v1beta.IFederation[] = []; - const iterable = client.listFederationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listFederations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listFederations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listFederations without error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ListFederationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ListFederationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Federation(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Federation(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Federation(), + ), + ]; + client.descriptors.page.listFederations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.metastore.v1beta.IFederation[] = []; + const iterable = client.listFederationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listFederations.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listFederations.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listFederations with error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ListFederationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ListFederationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listFederations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listFederationsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.metastore.v1beta.IFederation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listFederations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listFederations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listFederations with error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ListFederationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ListFederationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listFederations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listFederationsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.metastore.v1beta.IFederation[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listFederations.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listFederations.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy with error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes setIamPolicy without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes setIamPolicy with error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes testIamPermissions without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes testIamPermissions with error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('backup', async () => { + const fakePath = '/rendered/path/backup'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service: 'serviceValue', + backup: 'backupValue', + }; + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.backupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.backupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('backupPath', () => { + const result = client.backupPath( + 'projectValue', + 'locationValue', + 'serviceValue', + 'backupValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.backupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromBackupName', () => { + const result = client.matchProjectFromBackupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromBackupName', () => { + const result = client.matchLocationFromBackupName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceFromBackupName', () => { + const result = client.matchServiceFromBackupName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchBackupFromBackupName', () => { + const result = client.matchBackupFromBackupName(fakePath); + assert.strictEqual(result, 'backupValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('backup', async () => { - const fakePath = "/rendered/path/backup"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - backup: "backupValue", - }; - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.backupPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.backupPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('backupPath', () => { - const result = client.backupPath("projectValue", "locationValue", "serviceValue", "backupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.backupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBackupName', () => { - const result = client.matchProjectFromBackupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBackupName', () => { - const result = client.matchLocationFromBackupName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromBackupName', () => { - const result = client.matchServiceFromBackupName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBackupFromBackupName', () => { - const result = client.matchBackupFromBackupName(fakePath); - assert.strictEqual(result, "backupValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('federation', async () => { - const fakePath = "/rendered/path/federation"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - federation: "federationValue", - }; - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.federationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.federationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('federationPath', () => { - const result = client.federationPath("projectValue", "locationValue", "federationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.federationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromFederationName', () => { - const result = client.matchProjectFromFederationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.federationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromFederationName', () => { - const result = client.matchLocationFromFederationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.federationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchFederationFromFederationName', () => { - const result = client.matchFederationFromFederationName(fakePath); - assert.strictEqual(result, "federationValue"); - assert((client.pathTemplates.federationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('federation', async () => { + const fakePath = '/rendered/path/federation'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + federation: 'federationValue', + }; + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.federationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.federationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('federationPath', () => { + const result = client.federationPath( + 'projectValue', + 'locationValue', + 'federationValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.federationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromFederationName', () => { + const result = client.matchProjectFromFederationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.federationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromFederationName', () => { + const result = client.matchLocationFromFederationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.federationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchFederationFromFederationName', () => { + const result = client.matchFederationFromFederationName(fakePath); + assert.strictEqual(result, 'federationValue'); + assert( + (client.pathTemplates.federationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('metadataImport', async () => { - const fakePath = "/rendered/path/metadataImport"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - metadata_import: "metadataImportValue", - }; - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.metadataImportPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.metadataImportPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('metadataImportPath', () => { - const result = client.metadataImportPath("projectValue", "locationValue", "serviceValue", "metadataImportValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.metadataImportPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMetadataImportName', () => { - const result = client.matchProjectFromMetadataImportName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.metadataImportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMetadataImportName', () => { - const result = client.matchLocationFromMetadataImportName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.metadataImportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromMetadataImportName', () => { - const result = client.matchServiceFromMetadataImportName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.metadataImportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMetadataImportFromMetadataImportName', () => { - const result = client.matchMetadataImportFromMetadataImportName(fakePath); - assert.strictEqual(result, "metadataImportValue"); - assert((client.pathTemplates.metadataImportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('metadataImport', async () => { + const fakePath = '/rendered/path/metadataImport'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service: 'serviceValue', + metadata_import: 'metadataImportValue', + }; + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.metadataImportPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.metadataImportPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('metadataImportPath', () => { + const result = client.metadataImportPath( + 'projectValue', + 'locationValue', + 'serviceValue', + 'metadataImportValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.metadataImportPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMetadataImportName', () => { + const result = client.matchProjectFromMetadataImportName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.metadataImportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMetadataImportName', () => { + const result = client.matchLocationFromMetadataImportName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.metadataImportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceFromMetadataImportName', () => { + const result = client.matchServiceFromMetadataImportName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.metadataImportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMetadataImportFromMetadataImportName', () => { + const result = + client.matchMetadataImportFromMetadataImportName(fakePath); + assert.strictEqual(result, 'metadataImportValue'); + assert( + (client.pathTemplates.metadataImportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.projectPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('service', async () => { - const fakePath = "/rendered/path/service"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - }; - const client = new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.servicePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servicePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servicePath', () => { - const result = client.servicePath("projectValue", "locationValue", "serviceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servicePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceName', () => { - const result = client.matchProjectFromServiceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServiceName', () => { - const result = client.matchLocationFromServiceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromServiceName', () => { - const result = client.matchServiceFromServiceName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('service', async () => { + const fakePath = '/rendered/path/service'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service: 'serviceValue', + }; + const client = + new dataprocmetastorefederationModule.v1beta.DataprocMetastoreFederationClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.servicePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servicePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servicePath', () => { + const result = client.servicePath( + 'projectValue', + 'locationValue', + 'serviceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servicePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceName', () => { + const result = client.matchProjectFromServiceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromServiceName', () => { + const result = client.matchLocationFromServiceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceFromServiceName', () => { + const result = client.matchServiceFromServiceName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-metastore/test/gapic_dataproc_metastore_v1.ts b/packages/google-cloud-metastore/test/gapic_dataproc_metastore_v1.ts index 9702874ea4f2..497f0535fd14 100644 --- a/packages/google-cloud-metastore/test/gapic_dataproc_metastore_v1.ts +++ b/packages/google-cloud-metastore/test/gapic_dataproc_metastore_v1.ts @@ -19,4180 +19,5268 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as dataprocmetastoreModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + IamProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1.DataprocMetastoreClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'metastore.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = dataprocmetastoreModule.v1.DataprocMetastoreClient.servicePath; - assert.strictEqual(servicePath, 'metastore.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = dataprocmetastoreModule.v1.DataprocMetastoreClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'metastore.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'metastore.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'metastore.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'metastore.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'metastore.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new dataprocmetastoreModule.v1.DataprocMetastoreClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = dataprocmetastoreModule.v1.DataprocMetastoreClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.dataprocMetastoreStub, undefined); - await client.initialize(); - assert(client.dataprocMetastoreStub); - }); - - it('has close method for the initialized client', done => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.dataprocMetastoreStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has close method for the non-initialized client', done => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.dataprocMetastoreStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'metastore.googleapis.com'); }); - describe('getService', () => { - it('invokes getService without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.GetServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.GetServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.metastore.v1.Service() - ); - client.innerApiCalls.getService = stubSimpleCall(expectedResponse); - const [response] = await client.getService(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getService without error using callback', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.GetServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.GetServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.metastore.v1.Service() - ); - client.innerApiCalls.getService = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getService( - request, - (err?: Error|null, result?: protos.google.cloud.metastore.v1.IService|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getService with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.GetServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.GetServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getService = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getService(request), expectedError); - const actualRequest = (client.innerApiCalls.getService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has universeDomain', () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('invokes getService with closed client', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.GetServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.GetServiceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getService(request), expectedError); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + dataprocmetastoreModule.v1.DataprocMetastoreClient.servicePath; + assert.strictEqual(servicePath, 'metastore.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + dataprocmetastoreModule.v1.DataprocMetastoreClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'metastore.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'metastore.example.com'); }); - describe('getMetadataImport', () => { - it('invokes getMetadataImport without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.GetMetadataImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.GetMetadataImportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.metastore.v1.MetadataImport() - ); - client.innerApiCalls.getMetadataImport = stubSimpleCall(expectedResponse); - const [response] = await client.getMetadataImport(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'metastore.example.com'); + }); - it('invokes getMetadataImport without error using callback', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.GetMetadataImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.GetMetadataImportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.metastore.v1.MetadataImport() - ); - client.innerApiCalls.getMetadataImport = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getMetadataImport( - request, - (err?: Error|null, result?: protos.google.cloud.metastore.v1.IMetadataImport|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new dataprocmetastoreModule.v1.DataprocMetastoreClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'metastore.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient( + { universeDomain: 'configured.example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'metastore.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('invokes getMetadataImport with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.GetMetadataImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.GetMetadataImportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getMetadataImport = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getMetadataImport(request), expectedError); - const actualRequest = (client.innerApiCalls.getMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has port', () => { + const port = dataprocmetastoreModule.v1.DataprocMetastoreClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('invokes getMetadataImport with closed client', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.GetMetadataImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.GetMetadataImportRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getMetadataImport(request), expectedError); - }); + it('should create a client with no option', () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient(); + assert(client); }); - describe('getBackup', () => { - it('invokes getBackup without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.GetBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.metastore.v1.Backup() - ); - client.innerApiCalls.getBackup = stubSimpleCall(expectedResponse); - const [response] = await client.getBackup(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('should create a client with gRPC fallback', () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + fallback: true, + }); + assert(client); + }); - it('invokes getBackup without error using callback', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.GetBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.metastore.v1.Backup() - ); - client.innerApiCalls.getBackup = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getBackup( - request, - (err?: Error|null, result?: protos.google.cloud.metastore.v1.IBackup|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.dataprocMetastoreStub, undefined); + await client.initialize(); + assert(client.dataprocMetastoreStub); + }); - it('invokes getBackup with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.GetBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getBackup = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getBackup(request), expectedError); - const actualRequest = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the initialized client', (done) => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.dataprocMetastoreStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getBackup with closed client', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.GetBackupRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getBackup(request), expectedError); + it('has close method for the non-initialized client', (done) => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.dataprocMetastoreStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('createService', () => { - it('invokes createService without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.CreateServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.CreateServiceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createService = stubLongRunningCall(expectedResponse); - const [operation] = await client.createService(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('invokes createService without error using callback', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.CreateServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.CreateServiceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createService = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createService( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getService', () => { + it('invokes getService without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.GetServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.GetServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.metastore.v1.Service(), + ); + client.innerApiCalls.getService = stubSimpleCall(expectedResponse); + const [response] = await client.getService(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createService with call error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.CreateServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.CreateServiceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createService = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createService(request), expectedError); - const actualRequest = (client.innerApiCalls.createService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getService without error using callback', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.GetServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.GetServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.metastore.v1.Service(), + ); + client.innerApiCalls.getService = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getService( + request, + ( + err?: Error | null, + result?: protos.google.cloud.metastore.v1.IService | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createService with LRO error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.CreateServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.CreateServiceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createService = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createService(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getService with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.GetServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.GetServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getService = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getService(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateServiceProgress without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateServiceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes getService with closed client', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.GetServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.GetServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getService(request), expectedError); + }); + }); + + describe('getMetadataImport', () => { + it('invokes getMetadataImport without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.GetMetadataImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.GetMetadataImportRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.metastore.v1.MetadataImport(), + ); + client.innerApiCalls.getMetadataImport = stubSimpleCall(expectedResponse); + const [response] = await client.getMetadataImport(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateServiceProgress with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateServiceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes getMetadataImport without error using callback', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.GetMetadataImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.GetMetadataImportRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.metastore.v1.MetadataImport(), + ); + client.innerApiCalls.getMetadataImport = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getMetadataImport( + request, + ( + err?: Error | null, + result?: protos.google.cloud.metastore.v1.IMetadataImport | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateService', () => { - it('invokes updateService without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.UpdateServiceRequest() - ); - request.service ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.UpdateServiceRequest', ['service', 'name']); - request.service.name = defaultValue1; - const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateService = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateService(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getMetadataImport with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.GetMetadataImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.GetMetadataImportRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getMetadataImport = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getMetadataImport(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateService without error using callback', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.UpdateServiceRequest() - ); - request.service ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.UpdateServiceRequest', ['service', 'name']); - request.service.name = defaultValue1; - const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateService = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateService( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getMetadataImport with closed client', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.GetMetadataImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.GetMetadataImportRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getMetadataImport(request), expectedError); + }); + }); + + describe('getBackup', () => { + it('invokes getBackup without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.GetBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.GetBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.metastore.v1.Backup(), + ); + client.innerApiCalls.getBackup = stubSimpleCall(expectedResponse); + const [response] = await client.getBackup(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateService with call error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.UpdateServiceRequest() - ); - request.service ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.UpdateServiceRequest', ['service', 'name']); - request.service.name = defaultValue1; - const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateService = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateService(request), expectedError); - const actualRequest = (client.innerApiCalls.updateService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getBackup without error using callback', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.GetBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.GetBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.metastore.v1.Backup(), + ); + client.innerApiCalls.getBackup = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getBackup( + request, + ( + err?: Error | null, + result?: protos.google.cloud.metastore.v1.IBackup | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateService with LRO error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.UpdateServiceRequest() - ); - request.service ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.UpdateServiceRequest', ['service', 'name']); - request.service.name = defaultValue1; - const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateService = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateService(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getBackup with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.GetBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.GetBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getBackup = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getBackup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateServiceProgress without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateServiceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes getBackup with closed client', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.GetBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.GetBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getBackup(request), expectedError); + }); + }); + + describe('createService', () => { + it('invokes createService without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.CreateServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.CreateServiceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createService = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createService(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateServiceProgress with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateServiceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createService without error using callback', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.CreateServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.CreateServiceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createService = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createService( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1.IService, + protos.google.cloud.metastore.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1.IService, + protos.google.cloud.metastore.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteService', () => { - it('invokes deleteService without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.DeleteServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.DeleteServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteService = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteService(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createService with call error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.CreateServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.CreateServiceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createService = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createService(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteService without error using callback', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.DeleteServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.DeleteServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteService = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteService( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createService with LRO error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.CreateServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.CreateServiceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createService = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createService(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteService with call error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.DeleteServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.DeleteServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteService = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteService(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateServiceProgress without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateServiceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteService with LRO error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.DeleteServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.DeleteServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteService = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteService(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateServiceProgress with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateServiceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateService', () => { + it('invokes updateService without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.UpdateServiceRequest(), + ); + request.service ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.UpdateServiceRequest', + ['service', 'name'], + ); + request.service.name = defaultValue1; + const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateService = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateService(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteServiceProgress without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteServiceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateService without error using callback', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.UpdateServiceRequest(), + ); + request.service ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.UpdateServiceRequest', + ['service', 'name'], + ); + request.service.name = defaultValue1; + const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateService = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateService( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1.IService, + protos.google.cloud.metastore.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1.IService, + protos.google.cloud.metastore.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteServiceProgress with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteServiceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateService with call error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.UpdateServiceRequest(), + ); + request.service ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.UpdateServiceRequest', + ['service', 'name'], + ); + request.service.name = defaultValue1; + const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateService = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateService(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createMetadataImport', () => { - it('invokes createMetadataImport without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.CreateMetadataImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.CreateMetadataImportRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createMetadataImport = stubLongRunningCall(expectedResponse); - const [operation] = await client.createMetadataImport(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateService with LRO error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.UpdateServiceRequest(), + ); + request.service ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.UpdateServiceRequest', + ['service', 'name'], + ); + request.service.name = defaultValue1; + const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateService = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateService(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createMetadataImport without error using callback', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.CreateMetadataImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.CreateMetadataImportRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createMetadataImport = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createMetadataImport( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateServiceProgress without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateServiceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createMetadataImport with call error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.CreateMetadataImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.CreateMetadataImportRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createMetadataImport = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createMetadataImport(request), expectedError); - const actualRequest = (client.innerApiCalls.createMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateServiceProgress with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateServiceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteService', () => { + it('invokes deleteService without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.DeleteServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.DeleteServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteService = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteService(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createMetadataImport with LRO error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.CreateMetadataImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.CreateMetadataImportRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createMetadataImport = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createMetadataImport(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteService without error using callback', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.DeleteServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.DeleteServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteService = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteService( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateMetadataImportProgress without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateMetadataImportProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteService with call error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.DeleteServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.DeleteServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteService = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteService(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateMetadataImportProgress with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateMetadataImportProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteService with LRO error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.DeleteServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.DeleteServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteService = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteService(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateMetadataImport', () => { - it('invokes updateMetadataImport without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.UpdateMetadataImportRequest() - ); - request.metadataImport ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.UpdateMetadataImportRequest', ['metadataImport', 'name']); - request.metadataImport.name = defaultValue1; - const expectedHeaderRequestParams = `metadata_import.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateMetadataImport = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateMetadataImport(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteServiceProgress without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteServiceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateMetadataImport without error using callback', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.UpdateMetadataImportRequest() - ); - request.metadataImport ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.UpdateMetadataImportRequest', ['metadataImport', 'name']); - request.metadataImport.name = defaultValue1; - const expectedHeaderRequestParams = `metadata_import.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateMetadataImport = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateMetadataImport( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteServiceProgress with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteServiceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createMetadataImport', () => { + it('invokes createMetadataImport without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.CreateMetadataImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.CreateMetadataImportRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createMetadataImport = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createMetadataImport(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateMetadataImport with call error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.UpdateMetadataImportRequest() - ); - request.metadataImport ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.UpdateMetadataImportRequest', ['metadataImport', 'name']); - request.metadataImport.name = defaultValue1; - const expectedHeaderRequestParams = `metadata_import.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateMetadataImport = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateMetadataImport(request), expectedError); - const actualRequest = (client.innerApiCalls.updateMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createMetadataImport without error using callback', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.CreateMetadataImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.CreateMetadataImportRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createMetadataImport = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createMetadataImport( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1.IMetadataImport, + protos.google.cloud.metastore.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1.IMetadataImport, + protos.google.cloud.metastore.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateMetadataImport with LRO error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.UpdateMetadataImportRequest() - ); - request.metadataImport ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.UpdateMetadataImportRequest', ['metadataImport', 'name']); - request.metadataImport.name = defaultValue1; - const expectedHeaderRequestParams = `metadata_import.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateMetadataImport = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateMetadataImport(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createMetadataImport with call error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.CreateMetadataImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.CreateMetadataImportRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createMetadataImport = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createMetadataImport(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateMetadataImportProgress without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateMetadataImportProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createMetadataImport with LRO error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.CreateMetadataImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.CreateMetadataImportRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createMetadataImport = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createMetadataImport(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateMetadataImportProgress with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateMetadataImportProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateMetadataImportProgress without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateMetadataImportProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('exportMetadata', () => { - it('invokes exportMetadata without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ExportMetadataRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ExportMetadataRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.exportMetadata = stubLongRunningCall(expectedResponse); - const [operation] = await client.exportMetadata(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.exportMetadata as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportMetadata as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateMetadataImportProgress with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateMetadataImportProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateMetadataImport', () => { + it('invokes updateMetadataImport without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.UpdateMetadataImportRequest(), + ); + request.metadataImport ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.UpdateMetadataImportRequest', + ['metadataImport', 'name'], + ); + request.metadataImport.name = defaultValue1; + const expectedHeaderRequestParams = `metadata_import.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateMetadataImport = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateMetadataImport(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes exportMetadata without error using callback', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ExportMetadataRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ExportMetadataRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.exportMetadata = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.exportMetadata( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.exportMetadata as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportMetadata as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateMetadataImport without error using callback', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.UpdateMetadataImportRequest(), + ); + request.metadataImport ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.UpdateMetadataImportRequest', + ['metadataImport', 'name'], + ); + request.metadataImport.name = defaultValue1; + const expectedHeaderRequestParams = `metadata_import.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateMetadataImport = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateMetadataImport( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1.IMetadataImport, + protos.google.cloud.metastore.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1.IMetadataImport, + protos.google.cloud.metastore.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes exportMetadata with call error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ExportMetadataRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ExportMetadataRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.exportMetadata = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.exportMetadata(request), expectedError); - const actualRequest = (client.innerApiCalls.exportMetadata as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportMetadata as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateMetadataImport with call error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.UpdateMetadataImportRequest(), + ); + request.metadataImport ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.UpdateMetadataImportRequest', + ['metadataImport', 'name'], + ); + request.metadataImport.name = defaultValue1; + const expectedHeaderRequestParams = `metadata_import.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateMetadataImport = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateMetadataImport(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes exportMetadata with LRO error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ExportMetadataRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ExportMetadataRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.exportMetadata = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.exportMetadata(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.exportMetadata as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportMetadata as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateMetadataImport with LRO error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.UpdateMetadataImportRequest(), + ); + request.metadataImport ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.UpdateMetadataImportRequest', + ['metadataImport', 'name'], + ); + request.metadataImport.name = defaultValue1; + const expectedHeaderRequestParams = `metadata_import.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateMetadataImport = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateMetadataImport(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkExportMetadataProgress without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkExportMetadataProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateMetadataImportProgress without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateMetadataImportProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkExportMetadataProgress with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkExportMetadataProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpdateMetadataImportProgress with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateMetadataImportProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('exportMetadata', () => { + it('invokes exportMetadata without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ExportMetadataRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ExportMetadataRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.exportMetadata = + stubLongRunningCall(expectedResponse); + const [operation] = await client.exportMetadata(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.exportMetadata as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportMetadata as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('restoreService', () => { - it('invokes restoreService without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.RestoreServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.RestoreServiceRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.restoreService = stubLongRunningCall(expectedResponse); - const [operation] = await client.restoreService(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.restoreService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes exportMetadata without error using callback', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ExportMetadataRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ExportMetadataRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.exportMetadata = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.exportMetadata( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1.IMetadataExport, + protos.google.cloud.metastore.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1.IMetadataExport, + protos.google.cloud.metastore.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.exportMetadata as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportMetadata as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes restoreService without error using callback', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.RestoreServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.RestoreServiceRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.restoreService = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.restoreService( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.restoreService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes exportMetadata with call error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ExportMetadataRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ExportMetadataRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.exportMetadata = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.exportMetadata(request), expectedError); + const actualRequest = ( + client.innerApiCalls.exportMetadata as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportMetadata as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes restoreService with call error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.RestoreServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.RestoreServiceRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.restoreService = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.restoreService(request), expectedError); - const actualRequest = (client.innerApiCalls.restoreService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes exportMetadata with LRO error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ExportMetadataRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ExportMetadataRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.exportMetadata = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.exportMetadata(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.exportMetadata as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportMetadata as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes restoreService with LRO error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.RestoreServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.RestoreServiceRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.restoreService = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.restoreService(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.restoreService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkExportMetadataProgress without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkExportMetadataProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkRestoreServiceProgress without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkRestoreServiceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkExportMetadataProgress with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkExportMetadataProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('restoreService', () => { + it('invokes restoreService without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.RestoreServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.RestoreServiceRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.restoreService = + stubLongRunningCall(expectedResponse); + const [operation] = await client.restoreService(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.restoreService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRestoreServiceProgress with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRestoreServiceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes restoreService without error using callback', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.RestoreServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.RestoreServiceRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.restoreService = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.restoreService( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1.IRestore, + protos.google.cloud.metastore.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1.IRestore, + protos.google.cloud.metastore.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.restoreService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createBackup', () => { - it('invokes createBackup without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.CreateBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.CreateBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createBackup = stubLongRunningCall(expectedResponse); - const [operation] = await client.createBackup(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes restoreService with call error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.RestoreServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.RestoreServiceRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.restoreService = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.restoreService(request), expectedError); + const actualRequest = ( + client.innerApiCalls.restoreService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createBackup without error using callback', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.CreateBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.CreateBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createBackup = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createBackup( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes restoreService with LRO error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.RestoreServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.RestoreServiceRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.restoreService = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.restoreService(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.restoreService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createBackup with call error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.CreateBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.CreateBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createBackup = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createBackup(request), expectedError); - const actualRequest = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRestoreServiceProgress without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkRestoreServiceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createBackup with LRO error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.CreateBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.CreateBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createBackup = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createBackup(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRestoreServiceProgress with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkRestoreServiceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createBackup', () => { + it('invokes createBackup without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.CreateBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.CreateBackupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createBackup = stubLongRunningCall(expectedResponse); + const [operation] = await client.createBackup(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateBackupProgress without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateBackupProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createBackup without error using callback', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.CreateBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.CreateBackupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createBackup = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createBackup( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1.IBackup, + protos.google.cloud.metastore.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1.IBackup, + protos.google.cloud.metastore.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateBackupProgress with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateBackupProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createBackup with call error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.CreateBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.CreateBackupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createBackup = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createBackup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteBackup', () => { - it('invokes deleteBackup without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteBackup = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteBackup(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createBackup with LRO error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.CreateBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.CreateBackupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createBackup = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createBackup(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteBackup without error using callback', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteBackup = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteBackup( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateBackupProgress without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateBackupProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteBackup with call error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteBackup = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteBackup(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateBackupProgress with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkCreateBackupProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteBackup', () => { + it('invokes deleteBackup without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.DeleteBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.DeleteBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteBackup = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteBackup(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteBackup with LRO error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteBackup = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteBackup(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteBackup without error using callback', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.DeleteBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.DeleteBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteBackup = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteBackup( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteBackupProgress without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteBackupProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteBackup with call error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.DeleteBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.DeleteBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteBackup = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteBackup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteBackupProgress with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteBackupProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteBackup with LRO error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.DeleteBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.DeleteBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteBackup = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteBackup(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('queryMetadata', () => { - it('invokes queryMetadata without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.QueryMetadataRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.QueryMetadataRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.queryMetadata = stubLongRunningCall(expectedResponse); - const [operation] = await client.queryMetadata(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.queryMetadata as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.queryMetadata as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteBackupProgress without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteBackupProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes queryMetadata without error using callback', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.QueryMetadataRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.QueryMetadataRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.queryMetadata = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.queryMetadata( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.queryMetadata as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.queryMetadata as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteBackupProgress with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkDeleteBackupProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('queryMetadata', () => { + it('invokes queryMetadata without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.QueryMetadataRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.QueryMetadataRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.queryMetadata = + stubLongRunningCall(expectedResponse); + const [operation] = await client.queryMetadata(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.queryMetadata as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryMetadata as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes queryMetadata with call error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.QueryMetadataRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.QueryMetadataRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.queryMetadata = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.queryMetadata(request), expectedError); - const actualRequest = (client.innerApiCalls.queryMetadata as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.queryMetadata as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes queryMetadata without error using callback', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.QueryMetadataRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.QueryMetadataRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.queryMetadata = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.queryMetadata( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1.IQueryMetadataResponse, + protos.google.cloud.metastore.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1.IQueryMetadataResponse, + protos.google.cloud.metastore.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.queryMetadata as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryMetadata as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes queryMetadata with LRO error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.QueryMetadataRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.QueryMetadataRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.queryMetadata = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.queryMetadata(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.queryMetadata as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.queryMetadata as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes queryMetadata with call error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.QueryMetadataRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.QueryMetadataRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.queryMetadata = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.queryMetadata(request), expectedError); + const actualRequest = ( + client.innerApiCalls.queryMetadata as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryMetadata as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkQueryMetadataProgress without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkQueryMetadataProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes queryMetadata with LRO error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.QueryMetadataRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.QueryMetadataRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.queryMetadata = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.queryMetadata(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.queryMetadata as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryMetadata as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkQueryMetadataProgress with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkQueryMetadataProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkQueryMetadataProgress without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkQueryMetadataProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('moveTableToDatabase', () => { - it('invokes moveTableToDatabase without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.MoveTableToDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.MoveTableToDatabaseRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.moveTableToDatabase = stubLongRunningCall(expectedResponse); - const [operation] = await client.moveTableToDatabase(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.moveTableToDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.moveTableToDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkQueryMetadataProgress with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkQueryMetadataProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('moveTableToDatabase', () => { + it('invokes moveTableToDatabase without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.MoveTableToDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.MoveTableToDatabaseRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.moveTableToDatabase = + stubLongRunningCall(expectedResponse); + const [operation] = await client.moveTableToDatabase(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.moveTableToDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.moveTableToDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes moveTableToDatabase without error using callback', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.MoveTableToDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.MoveTableToDatabaseRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.moveTableToDatabase = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.moveTableToDatabase( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.moveTableToDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.moveTableToDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes moveTableToDatabase without error using callback', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.MoveTableToDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.MoveTableToDatabaseRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.moveTableToDatabase = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.moveTableToDatabase( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1.IMoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1.IMoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.moveTableToDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.moveTableToDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes moveTableToDatabase with call error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.MoveTableToDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.MoveTableToDatabaseRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.moveTableToDatabase = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.moveTableToDatabase(request), expectedError); - const actualRequest = (client.innerApiCalls.moveTableToDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.moveTableToDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes moveTableToDatabase with call error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.MoveTableToDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.MoveTableToDatabaseRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.moveTableToDatabase = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.moveTableToDatabase(request), expectedError); + const actualRequest = ( + client.innerApiCalls.moveTableToDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.moveTableToDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes moveTableToDatabase with LRO error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.MoveTableToDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.MoveTableToDatabaseRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.moveTableToDatabase = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.moveTableToDatabase(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.moveTableToDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.moveTableToDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes moveTableToDatabase with LRO error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.MoveTableToDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.MoveTableToDatabaseRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.moveTableToDatabase = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.moveTableToDatabase(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.moveTableToDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.moveTableToDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkMoveTableToDatabaseProgress without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkMoveTableToDatabaseProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkMoveTableToDatabaseProgress without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkMoveTableToDatabaseProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkMoveTableToDatabaseProgress with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkMoveTableToDatabaseProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkMoveTableToDatabaseProgress with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkMoveTableToDatabaseProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('alterMetadataResourceLocation', () => { + it('invokes alterMetadataResourceLocation without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.AlterMetadataResourceLocationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.AlterMetadataResourceLocationRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.alterMetadataResourceLocation = + stubLongRunningCall(expectedResponse); + const [operation] = await client.alterMetadataResourceLocation(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.alterMetadataResourceLocation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.alterMetadataResourceLocation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('alterMetadataResourceLocation', () => { - it('invokes alterMetadataResourceLocation without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.AlterMetadataResourceLocationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.AlterMetadataResourceLocationRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.alterMetadataResourceLocation = stubLongRunningCall(expectedResponse); - const [operation] = await client.alterMetadataResourceLocation(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.alterMetadataResourceLocation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.alterMetadataResourceLocation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes alterMetadataResourceLocation without error using callback', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.AlterMetadataResourceLocationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.AlterMetadataResourceLocationRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.alterMetadataResourceLocation = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.alterMetadataResourceLocation( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1.IAlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1.IAlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.alterMetadataResourceLocation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.alterMetadataResourceLocation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes alterMetadataResourceLocation without error using callback', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.AlterMetadataResourceLocationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.AlterMetadataResourceLocationRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.alterMetadataResourceLocation = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.alterMetadataResourceLocation( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.alterMetadataResourceLocation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.alterMetadataResourceLocation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes alterMetadataResourceLocation with call error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.AlterMetadataResourceLocationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.AlterMetadataResourceLocationRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.alterMetadataResourceLocation = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.alterMetadataResourceLocation(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.alterMetadataResourceLocation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.alterMetadataResourceLocation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes alterMetadataResourceLocation with call error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.AlterMetadataResourceLocationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.AlterMetadataResourceLocationRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.alterMetadataResourceLocation = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.alterMetadataResourceLocation(request), expectedError); - const actualRequest = (client.innerApiCalls.alterMetadataResourceLocation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.alterMetadataResourceLocation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes alterMetadataResourceLocation with LRO error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.AlterMetadataResourceLocationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.AlterMetadataResourceLocationRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.alterMetadataResourceLocation = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.alterMetadataResourceLocation(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.alterMetadataResourceLocation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.alterMetadataResourceLocation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes alterMetadataResourceLocation with LRO error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.AlterMetadataResourceLocationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.AlterMetadataResourceLocationRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.alterMetadataResourceLocation = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.alterMetadataResourceLocation(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.alterMetadataResourceLocation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.alterMetadataResourceLocation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkAlterMetadataResourceLocationProgress without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkAlterMetadataResourceLocationProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkAlterMetadataResourceLocationProgress without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkAlterMetadataResourceLocationProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkAlterMetadataResourceLocationProgress with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkAlterMetadataResourceLocationProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listServices', () => { + it('invokes listServices without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ListServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.metastore.v1.Service()), + generateSampleMessage(new protos.google.cloud.metastore.v1.Service()), + generateSampleMessage(new protos.google.cloud.metastore.v1.Service()), + ]; + client.innerApiCalls.listServices = stubSimpleCall(expectedResponse); + const [response] = await client.listServices(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServices as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServices as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkAlterMetadataResourceLocationProgress with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkAlterMetadataResourceLocationProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes listServices without error using callback', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ListServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.metastore.v1.Service()), + generateSampleMessage(new protos.google.cloud.metastore.v1.Service()), + generateSampleMessage(new protos.google.cloud.metastore.v1.Service()), + ]; + client.innerApiCalls.listServices = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listServices( + request, + ( + err?: Error | null, + result?: protos.google.cloud.metastore.v1.IService[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServices as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServices as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listServices', () => { - it('invokes listServices without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ListServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1.Service()), - generateSampleMessage(new protos.google.cloud.metastore.v1.Service()), - generateSampleMessage(new protos.google.cloud.metastore.v1.Service()), - ]; - client.innerApiCalls.listServices = stubSimpleCall(expectedResponse); - const [response] = await client.listServices(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServices as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServices as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listServices with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ListServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listServices = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listServices(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listServices as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServices as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listServices without error using callback', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ListServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1.Service()), - generateSampleMessage(new protos.google.cloud.metastore.v1.Service()), - generateSampleMessage(new protos.google.cloud.metastore.v1.Service()), - ]; - client.innerApiCalls.listServices = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listServices( - request, - (err?: Error|null, result?: protos.google.cloud.metastore.v1.IService[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServices as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServices as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listServicesStream without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ListServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.metastore.v1.Service()), + generateSampleMessage(new protos.google.cloud.metastore.v1.Service()), + generateSampleMessage(new protos.google.cloud.metastore.v1.Service()), + ]; + client.descriptors.page.listServices.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listServicesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.metastore.v1.Service[] = []; + stream.on( + 'data', + (response: protos.google.cloud.metastore.v1.Service) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listServices.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listServices, request), + ); + assert( + (client.descriptors.page.listServices.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listServices with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ListServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listServices = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listServices(request), expectedError); - const actualRequest = (client.innerApiCalls.listServices as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServices as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listServicesStream with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ListServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listServices.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listServicesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.metastore.v1.Service[] = []; + stream.on( + 'data', + (response: protos.google.cloud.metastore.v1.Service) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listServices.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listServices, request), + ); + assert( + (client.descriptors.page.listServices.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listServicesStream without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ListServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1.Service()), - generateSampleMessage(new protos.google.cloud.metastore.v1.Service()), - generateSampleMessage(new protos.google.cloud.metastore.v1.Service()), - ]; - client.descriptors.page.listServices.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listServicesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.metastore.v1.Service[] = []; - stream.on('data', (response: protos.google.cloud.metastore.v1.Service) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listServices.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServices, request)); - assert( - (client.descriptors.page.listServices.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listServices without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ListServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.metastore.v1.Service()), + generateSampleMessage(new protos.google.cloud.metastore.v1.Service()), + generateSampleMessage(new protos.google.cloud.metastore.v1.Service()), + ]; + client.descriptors.page.listServices.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.metastore.v1.IService[] = []; + const iterable = client.listServicesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listServices.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listServices.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listServicesStream with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ListServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listServices.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listServicesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.metastore.v1.Service[] = []; - stream.on('data', (response: protos.google.cloud.metastore.v1.Service) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listServices.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServices, request)); - assert( - (client.descriptors.page.listServices.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listServices with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ListServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listServices.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listServicesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.metastore.v1.IService[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listServices.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listServices.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listMetadataImports', () => { + it('invokes listMetadataImports without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ListMetadataImportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ListMetadataImportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1.MetadataImport(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1.MetadataImport(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1.MetadataImport(), + ), + ]; + client.innerApiCalls.listMetadataImports = + stubSimpleCall(expectedResponse); + const [response] = await client.listMetadataImports(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listMetadataImports as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMetadataImports as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listServices without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ListServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1.Service()), - generateSampleMessage(new protos.google.cloud.metastore.v1.Service()), - generateSampleMessage(new protos.google.cloud.metastore.v1.Service()), - ]; - client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.metastore.v1.IService[] = []; - const iterable = client.listServicesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listMetadataImports without error using callback', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ListMetadataImportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ListMetadataImportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1.MetadataImport(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1.MetadataImport(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1.MetadataImport(), + ), + ]; + client.innerApiCalls.listMetadataImports = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listMetadataImports( + request, + ( + err?: Error | null, + result?: protos.google.cloud.metastore.v1.IMetadataImport[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listServices.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listServices.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listServices with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ListServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listServicesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.metastore.v1.IService[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listServices.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listServices.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listMetadataImports as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMetadataImports as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listMetadataImports', () => { - it('invokes listMetadataImports without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ListMetadataImportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ListMetadataImportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1.MetadataImport()), - generateSampleMessage(new protos.google.cloud.metastore.v1.MetadataImport()), - generateSampleMessage(new protos.google.cloud.metastore.v1.MetadataImport()), - ]; - client.innerApiCalls.listMetadataImports = stubSimpleCall(expectedResponse); - const [response] = await client.listMetadataImports(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMetadataImports as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMetadataImports as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listMetadataImports with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ListMetadataImportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ListMetadataImportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listMetadataImports = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listMetadataImports(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listMetadataImports as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMetadataImports as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listMetadataImports without error using callback', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ListMetadataImportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ListMetadataImportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1.MetadataImport()), - generateSampleMessage(new protos.google.cloud.metastore.v1.MetadataImport()), - generateSampleMessage(new protos.google.cloud.metastore.v1.MetadataImport()), - ]; - client.innerApiCalls.listMetadataImports = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listMetadataImports( - request, - (err?: Error|null, result?: protos.google.cloud.metastore.v1.IMetadataImport[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMetadataImports as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMetadataImports as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listMetadataImportsStream without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ListMetadataImportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ListMetadataImportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1.MetadataImport(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1.MetadataImport(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1.MetadataImport(), + ), + ]; + client.descriptors.page.listMetadataImports.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listMetadataImportsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.metastore.v1.MetadataImport[] = []; + stream.on( + 'data', + (response: protos.google.cloud.metastore.v1.MetadataImport) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listMetadataImports.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listMetadataImports, request), + ); + assert( + (client.descriptors.page.listMetadataImports.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listMetadataImports with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ListMetadataImportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ListMetadataImportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listMetadataImports = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listMetadataImports(request), expectedError); - const actualRequest = (client.innerApiCalls.listMetadataImports as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMetadataImports as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listMetadataImportsStream with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ListMetadataImportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ListMetadataImportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMetadataImports.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listMetadataImportsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.metastore.v1.MetadataImport[] = []; + stream.on( + 'data', + (response: protos.google.cloud.metastore.v1.MetadataImport) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listMetadataImports.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listMetadataImports, request), + ); + assert( + (client.descriptors.page.listMetadataImports.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listMetadataImportsStream without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ListMetadataImportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ListMetadataImportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1.MetadataImport()), - generateSampleMessage(new protos.google.cloud.metastore.v1.MetadataImport()), - generateSampleMessage(new protos.google.cloud.metastore.v1.MetadataImport()), - ]; - client.descriptors.page.listMetadataImports.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listMetadataImportsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.metastore.v1.MetadataImport[] = []; - stream.on('data', (response: protos.google.cloud.metastore.v1.MetadataImport) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listMetadataImports.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMetadataImports, request)); - assert( - (client.descriptors.page.listMetadataImports.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listMetadataImports without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ListMetadataImportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ListMetadataImportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1.MetadataImport(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1.MetadataImport(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1.MetadataImport(), + ), + ]; + client.descriptors.page.listMetadataImports.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.metastore.v1.IMetadataImport[] = []; + const iterable = client.listMetadataImportsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listMetadataImports.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listMetadataImports.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listMetadataImportsStream with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ListMetadataImportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ListMetadataImportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMetadataImports.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listMetadataImportsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.metastore.v1.MetadataImport[] = []; - stream.on('data', (response: protos.google.cloud.metastore.v1.MetadataImport) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listMetadataImports.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMetadataImports, request)); - assert( - (client.descriptors.page.listMetadataImports.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listMetadataImports with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ListMetadataImportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ListMetadataImportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMetadataImports.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listMetadataImportsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.metastore.v1.IMetadataImport[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listMetadataImports.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listMetadataImports.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listBackups', () => { + it('invokes listBackups without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.metastore.v1.Backup()), + generateSampleMessage(new protos.google.cloud.metastore.v1.Backup()), + generateSampleMessage(new protos.google.cloud.metastore.v1.Backup()), + ]; + client.innerApiCalls.listBackups = stubSimpleCall(expectedResponse); + const [response] = await client.listBackups(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listMetadataImports without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ListMetadataImportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ListMetadataImportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1.MetadataImport()), - generateSampleMessage(new protos.google.cloud.metastore.v1.MetadataImport()), - generateSampleMessage(new protos.google.cloud.metastore.v1.MetadataImport()), - ]; - client.descriptors.page.listMetadataImports.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.metastore.v1.IMetadataImport[] = []; - const iterable = client.listMetadataImportsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listBackups without error using callback', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.metastore.v1.Backup()), + generateSampleMessage(new protos.google.cloud.metastore.v1.Backup()), + generateSampleMessage(new protos.google.cloud.metastore.v1.Backup()), + ]; + client.innerApiCalls.listBackups = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listBackups( + request, + ( + err?: Error | null, + result?: protos.google.cloud.metastore.v1.IBackup[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listMetadataImports.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMetadataImports.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listMetadataImports with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ListMetadataImportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ListMetadataImportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMetadataImports.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listMetadataImportsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.metastore.v1.IMetadataImport[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listMetadataImports.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMetadataImports.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listBackups', () => { - it('invokes listBackups without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1.Backup()), - generateSampleMessage(new protos.google.cloud.metastore.v1.Backup()), - generateSampleMessage(new protos.google.cloud.metastore.v1.Backup()), - ]; - client.innerApiCalls.listBackups = stubSimpleCall(expectedResponse); - const [response] = await client.listBackups(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listBackups without error using callback', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1.Backup()), - generateSampleMessage(new protos.google.cloud.metastore.v1.Backup()), - generateSampleMessage(new protos.google.cloud.metastore.v1.Backup()), - ]; - client.innerApiCalls.listBackups = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listBackups( - request, - (err?: Error|null, result?: protos.google.cloud.metastore.v1.IBackup[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listBackups with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listBackups = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listBackups(request), expectedError); - const actualRequest = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listBackups with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listBackups = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listBackups(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listBackupsStream without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1.Backup()), - generateSampleMessage(new protos.google.cloud.metastore.v1.Backup()), - generateSampleMessage(new protos.google.cloud.metastore.v1.Backup()), - ]; - client.descriptors.page.listBackups.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listBackupsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.metastore.v1.Backup[] = []; - stream.on('data', (response: protos.google.cloud.metastore.v1.Backup) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listBackups.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listBackups, request)); - assert( - (client.descriptors.page.listBackups.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listBackupsStream without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.metastore.v1.Backup()), + generateSampleMessage(new protos.google.cloud.metastore.v1.Backup()), + generateSampleMessage(new protos.google.cloud.metastore.v1.Backup()), + ]; + client.descriptors.page.listBackups.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listBackupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.metastore.v1.Backup[] = []; + stream.on( + 'data', + (response: protos.google.cloud.metastore.v1.Backup) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listBackups.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listBackups, request), + ); + assert( + (client.descriptors.page.listBackups.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listBackupsStream with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listBackups.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listBackupsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.metastore.v1.Backup[] = []; - stream.on('data', (response: protos.google.cloud.metastore.v1.Backup) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listBackups.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listBackups, request)); - assert( - (client.descriptors.page.listBackups.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listBackupsStream with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listBackups.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listBackupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.metastore.v1.Backup[] = []; + stream.on( + 'data', + (response: protos.google.cloud.metastore.v1.Backup) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listBackups.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listBackups, request), + ); + assert( + (client.descriptors.page.listBackups.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listBackups without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1.Backup()), - generateSampleMessage(new protos.google.cloud.metastore.v1.Backup()), - generateSampleMessage(new protos.google.cloud.metastore.v1.Backup()), - ]; - client.descriptors.page.listBackups.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.metastore.v1.IBackup[] = []; - const iterable = client.listBackupsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listBackups.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listBackups.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listBackups without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.metastore.v1.Backup()), + generateSampleMessage(new protos.google.cloud.metastore.v1.Backup()), + generateSampleMessage(new protos.google.cloud.metastore.v1.Backup()), + ]; + client.descriptors.page.listBackups.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.metastore.v1.IBackup[] = []; + const iterable = client.listBackupsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listBackups.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listBackups.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listBackups with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listBackups.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listBackupsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.metastore.v1.IBackup[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listBackups.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listBackups.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listBackups with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listBackups.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listBackupsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.metastore.v1.IBackup[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listBackups.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listBackups.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy without error using callback', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes setIamPolicy with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); + }); + it('invokes testIamPermissions with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes getLocation without error using callback', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('backup', async () => { + const fakePath = '/rendered/path/backup'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service: 'serviceValue', + backup: 'backupValue', + }; + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.backupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.backupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('backupPath', () => { + const result = client.backupPath( + 'projectValue', + 'locationValue', + 'serviceValue', + 'backupValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.backupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromBackupName', () => { + const result = client.matchProjectFromBackupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromBackupName', () => { + const result = client.matchLocationFromBackupName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceFromBackupName', () => { + const result = client.matchServiceFromBackupName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchBackupFromBackupName', () => { + const result = client.matchBackupFromBackupName(fakePath); + assert.strictEqual(result, 'backupValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('backup', async () => { - const fakePath = "/rendered/path/backup"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - backup: "backupValue", - }; - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.backupPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.backupPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('backupPath', () => { - const result = client.backupPath("projectValue", "locationValue", "serviceValue", "backupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.backupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBackupName', () => { - const result = client.matchProjectFromBackupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBackupName', () => { - const result = client.matchLocationFromBackupName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromBackupName', () => { - const result = client.matchServiceFromBackupName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBackupFromBackupName', () => { - const result = client.matchBackupFromBackupName(fakePath); - assert.strictEqual(result, "backupValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('federation', async () => { - const fakePath = "/rendered/path/federation"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - federation: "federationValue", - }; - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.federationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.federationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('federationPath', () => { - const result = client.federationPath("projectValue", "locationValue", "federationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.federationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromFederationName', () => { - const result = client.matchProjectFromFederationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.federationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromFederationName', () => { - const result = client.matchLocationFromFederationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.federationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchFederationFromFederationName', () => { - const result = client.matchFederationFromFederationName(fakePath); - assert.strictEqual(result, "federationValue"); - assert((client.pathTemplates.federationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('federation', async () => { + const fakePath = '/rendered/path/federation'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + federation: 'federationValue', + }; + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.federationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.federationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('federationPath', () => { + const result = client.federationPath( + 'projectValue', + 'locationValue', + 'federationValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.federationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromFederationName', () => { + const result = client.matchProjectFromFederationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.federationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromFederationName', () => { + const result = client.matchLocationFromFederationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.federationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchFederationFromFederationName', () => { + const result = client.matchFederationFromFederationName(fakePath); + assert.strictEqual(result, 'federationValue'); + assert( + (client.pathTemplates.federationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('metadataImport', async () => { - const fakePath = "/rendered/path/metadataImport"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - metadata_import: "metadataImportValue", - }; - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.metadataImportPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.metadataImportPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('metadataImportPath', () => { - const result = client.metadataImportPath("projectValue", "locationValue", "serviceValue", "metadataImportValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.metadataImportPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMetadataImportName', () => { - const result = client.matchProjectFromMetadataImportName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.metadataImportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMetadataImportName', () => { - const result = client.matchLocationFromMetadataImportName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.metadataImportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromMetadataImportName', () => { - const result = client.matchServiceFromMetadataImportName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.metadataImportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMetadataImportFromMetadataImportName', () => { - const result = client.matchMetadataImportFromMetadataImportName(fakePath); - assert.strictEqual(result, "metadataImportValue"); - assert((client.pathTemplates.metadataImportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('metadataImport', async () => { + const fakePath = '/rendered/path/metadataImport'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service: 'serviceValue', + metadata_import: 'metadataImportValue', + }; + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.metadataImportPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.metadataImportPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('metadataImportPath', () => { + const result = client.metadataImportPath( + 'projectValue', + 'locationValue', + 'serviceValue', + 'metadataImportValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.metadataImportPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMetadataImportName', () => { + const result = client.matchProjectFromMetadataImportName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.metadataImportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMetadataImportName', () => { + const result = client.matchLocationFromMetadataImportName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.metadataImportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceFromMetadataImportName', () => { + const result = client.matchServiceFromMetadataImportName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.metadataImportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMetadataImportFromMetadataImportName', () => { + const result = + client.matchMetadataImportFromMetadataImportName(fakePath); + assert.strictEqual(result, 'metadataImportValue'); + assert( + (client.pathTemplates.metadataImportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('network', async () => { - const fakePath = "/rendered/path/network"; - const expectedParameters = { - project: "projectValue", - network: "networkValue", - }; - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.networkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.networkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('networkPath', () => { - const result = client.networkPath("projectValue", "networkValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.networkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromNetworkName', () => { - const result = client.matchProjectFromNetworkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.networkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchNetworkFromNetworkName', () => { - const result = client.matchNetworkFromNetworkName(fakePath); - assert.strictEqual(result, "networkValue"); - assert((client.pathTemplates.networkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('network', async () => { + const fakePath = '/rendered/path/network'; + const expectedParameters = { + project: 'projectValue', + network: 'networkValue', + }; + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.networkPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.networkPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('networkPath', () => { + const result = client.networkPath('projectValue', 'networkValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.networkPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromNetworkName', () => { + const result = client.matchProjectFromNetworkName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.networkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchNetworkFromNetworkName', () => { + const result = client.matchNetworkFromNetworkName(fakePath); + assert.strictEqual(result, 'networkValue'); + assert( + (client.pathTemplates.networkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('service', async () => { - const fakePath = "/rendered/path/service"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - }; - const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.servicePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servicePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servicePath', () => { - const result = client.servicePath("projectValue", "locationValue", "serviceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servicePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceName', () => { - const result = client.matchProjectFromServiceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServiceName', () => { - const result = client.matchLocationFromServiceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromServiceName', () => { - const result = client.matchServiceFromServiceName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('service', async () => { + const fakePath = '/rendered/path/service'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service: 'serviceValue', + }; + const client = new dataprocmetastoreModule.v1.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.servicePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servicePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servicePath', () => { + const result = client.servicePath( + 'projectValue', + 'locationValue', + 'serviceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servicePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceName', () => { + const result = client.matchProjectFromServiceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromServiceName', () => { + const result = client.matchLocationFromServiceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceFromServiceName', () => { + const result = client.matchServiceFromServiceName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-metastore/test/gapic_dataproc_metastore_v1alpha.ts b/packages/google-cloud-metastore/test/gapic_dataproc_metastore_v1alpha.ts index 27f42a0bd82d..d1e17017cabb 100644 --- a/packages/google-cloud-metastore/test/gapic_dataproc_metastore_v1alpha.ts +++ b/packages/google-cloud-metastore/test/gapic_dataproc_metastore_v1alpha.ts @@ -19,4334 +19,5671 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as dataprocmetastoreModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + IamProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1alpha.DataprocMetastoreClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'metastore.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = dataprocmetastoreModule.v1alpha.DataprocMetastoreClient.servicePath; - assert.strictEqual(servicePath, 'metastore.googleapis.com'); - assert(stub.called); - stub.restore(); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'metastore.googleapis.com'); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = dataprocmetastoreModule.v1alpha.DataprocMetastoreClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'metastore.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'metastore.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'metastore.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'metastore.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'metastore.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + it('has universeDomain', () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has port', () => { - const port = dataprocmetastoreModule.v1alpha.DataprocMetastoreClient.port; - assert(port); - assert(typeof port === 'number'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + dataprocmetastoreModule.v1alpha.DataprocMetastoreClient.servicePath; + assert.strictEqual(servicePath, 'metastore.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + dataprocmetastoreModule.v1alpha.DataprocMetastoreClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'metastore.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + universeDomain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'metastore.example.com'); + }); - it('should create a client with no option', () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient(); - assert(client); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + universe_domain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'metastore.example.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - fallback: true, - }); - assert(client); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'metastore.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'metastore.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.dataprocMetastoreStub, undefined); - await client.initialize(); - assert(client.dataprocMetastoreStub); - }); + it('has port', () => { + const port = dataprocmetastoreModule.v1alpha.DataprocMetastoreClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has close method for the initialized client', done => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.dataprocMetastoreStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('should create a client with no option', () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + fallback: true, }); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.dataprocMetastoreStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has initialize method and supports deferred initialization', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.dataprocMetastoreStub, undefined); + await client.initialize(); + assert(client.dataprocMetastoreStub); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + it('has close method for the initialized client', (done) => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.dataprocMetastoreStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); + it('has close method for the non-initialized client', (done) => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.dataprocMetastoreStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('getService', () => { - it('invokes getService without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.GetServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.GetServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.Service() - ); - client.innerApiCalls.getService = stubSimpleCall(expectedResponse); - const [response] = await client.getService(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getService without error using callback', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.GetServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.GetServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.Service() - ); - client.innerApiCalls.getService = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getService( - request, - (err?: Error|null, result?: protos.google.cloud.metastore.v1alpha.IService|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getService with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.GetServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.GetServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getService = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getService(request), expectedError); - const actualRequest = (client.innerApiCalls.getService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getService with closed client', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.GetServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.GetServiceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getService(request), expectedError); - }); - }); - - describe('getMetadataImport', () => { - it('invokes getMetadataImport without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.GetMetadataImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.GetMetadataImportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.MetadataImport() - ); - client.innerApiCalls.getMetadataImport = stubSimpleCall(expectedResponse); - const [response] = await client.getMetadataImport(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getMetadataImport without error using callback', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.GetMetadataImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.GetMetadataImportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.MetadataImport() - ); - client.innerApiCalls.getMetadataImport = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getMetadataImport( - request, - (err?: Error|null, result?: protos.google.cloud.metastore.v1alpha.IMetadataImport|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getMetadataImport with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.GetMetadataImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.GetMetadataImportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getMetadataImport = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getMetadataImport(request), expectedError); - const actualRequest = (client.innerApiCalls.getMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getMetadataImport with closed client', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.GetMetadataImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.GetMetadataImportRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getMetadataImport(request), expectedError); - }); - }); - - describe('getBackup', () => { - it('invokes getBackup without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.GetBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.Backup() - ); - client.innerApiCalls.getBackup = stubSimpleCall(expectedResponse); - const [response] = await client.getBackup(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getBackup without error using callback', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.GetBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.Backup() - ); - client.innerApiCalls.getBackup = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getBackup( - request, - (err?: Error|null, result?: protos.google.cloud.metastore.v1alpha.IBackup|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getBackup with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.GetBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getBackup = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getBackup(request), expectedError); - const actualRequest = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getBackup with closed client', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.GetBackupRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getBackup(request), expectedError); - }); - }); - - describe('removeIamPolicy', () => { - it('invokes removeIamPolicy without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.RemoveIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.RemoveIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.RemoveIamPolicyResponse() - ); - client.innerApiCalls.removeIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.removeIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.removeIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes removeIamPolicy without error using callback', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.RemoveIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.RemoveIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.RemoveIamPolicyResponse() - ); - client.innerApiCalls.removeIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeIamPolicy( - request, - (err?: Error|null, result?: protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.removeIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes removeIamPolicy with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.RemoveIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.RemoveIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.removeIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.removeIamPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.removeIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes removeIamPolicy with closed client', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.RemoveIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.RemoveIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.removeIamPolicy(request), expectedError); - }); - }); - - describe('createService', () => { - it('invokes createService without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.CreateServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.CreateServiceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createService = stubLongRunningCall(expectedResponse); - const [operation] = await client.createService(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createService without error using callback', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.CreateServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.CreateServiceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createService = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createService( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createService with call error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.CreateServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.CreateServiceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createService = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createService(request), expectedError); - const actualRequest = (client.innerApiCalls.createService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createService with LRO error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.CreateServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.CreateServiceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createService = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createService(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateServiceProgress without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateServiceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateServiceProgress with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateServiceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getService', () => { + it('invokes getService without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.GetServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.GetServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Service(), + ); + client.innerApiCalls.getService = stubSimpleCall(expectedResponse); + const [response] = await client.getService(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateService', () => { - it('invokes updateService without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.UpdateServiceRequest() - ); - request.service ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.UpdateServiceRequest', ['service', 'name']); - request.service.name = defaultValue1; - const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateService = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateService(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateService without error using callback', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.UpdateServiceRequest() - ); - request.service ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.UpdateServiceRequest', ['service', 'name']); - request.service.name = defaultValue1; - const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateService = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateService( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateService with call error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.UpdateServiceRequest() - ); - request.service ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.UpdateServiceRequest', ['service', 'name']); - request.service.name = defaultValue1; - const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateService = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateService(request), expectedError); - const actualRequest = (client.innerApiCalls.updateService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateService with LRO error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.UpdateServiceRequest() - ); - request.service ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.UpdateServiceRequest', ['service', 'name']); - request.service.name = defaultValue1; - const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateService = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateService(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateServiceProgress without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateServiceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateServiceProgress with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes getService without error using callback', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.GetServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.GetServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Service(), + ); + client.innerApiCalls.getService = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getService( + request, + ( + err?: Error | null, + result?: protos.google.cloud.metastore.v1alpha.IService | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateServiceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes getService with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.GetServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.GetServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getService = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getService(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteService', () => { - it('invokes deleteService without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.DeleteServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.DeleteServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteService = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteService(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteService without error using callback', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.DeleteServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.DeleteServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteService = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteService( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteService with call error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.DeleteServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.DeleteServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteService = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteService(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteService with LRO error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.DeleteServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.DeleteServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteService = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteService(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteServiceProgress without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteServiceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteServiceProgress with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes getService with closed client', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.GetServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.GetServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getService(request), expectedError); + }); + }); + + describe('getMetadataImport', () => { + it('invokes getMetadataImport without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.GetMetadataImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.GetMetadataImportRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.MetadataImport(), + ); + client.innerApiCalls.getMetadataImport = stubSimpleCall(expectedResponse); + const [response] = await client.getMetadataImport(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteServiceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes getMetadataImport without error using callback', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.GetMetadataImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.GetMetadataImportRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.MetadataImport(), + ); + client.innerApiCalls.getMetadataImport = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getMetadataImport( + request, + ( + err?: Error | null, + result?: protos.google.cloud.metastore.v1alpha.IMetadataImport | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createMetadataImport', () => { - it('invokes createMetadataImport without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.CreateMetadataImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.CreateMetadataImportRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createMetadataImport = stubLongRunningCall(expectedResponse); - const [operation] = await client.createMetadataImport(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createMetadataImport without error using callback', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.CreateMetadataImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.CreateMetadataImportRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createMetadataImport = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createMetadataImport( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createMetadataImport with call error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.CreateMetadataImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.CreateMetadataImportRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createMetadataImport = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createMetadataImport(request), expectedError); - const actualRequest = (client.innerApiCalls.createMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createMetadataImport with LRO error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.CreateMetadataImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.CreateMetadataImportRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createMetadataImport = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createMetadataImport(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateMetadataImportProgress without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateMetadataImportProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateMetadataImportProgress with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes getMetadataImport with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.GetMetadataImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.GetMetadataImportRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getMetadataImport = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getMetadataImport(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateMetadataImportProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes getMetadataImport with closed client', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.GetMetadataImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.GetMetadataImportRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getMetadataImport(request), expectedError); + }); + }); + + describe('getBackup', () => { + it('invokes getBackup without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.GetBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.GetBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Backup(), + ); + client.innerApiCalls.getBackup = stubSimpleCall(expectedResponse); + const [response] = await client.getBackup(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateMetadataImport', () => { - it('invokes updateMetadataImport without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.UpdateMetadataImportRequest() - ); - request.metadataImport ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.UpdateMetadataImportRequest', ['metadataImport', 'name']); - request.metadataImport.name = defaultValue1; - const expectedHeaderRequestParams = `metadata_import.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateMetadataImport = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateMetadataImport(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateMetadataImport without error using callback', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.UpdateMetadataImportRequest() - ); - request.metadataImport ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.UpdateMetadataImportRequest', ['metadataImport', 'name']); - request.metadataImport.name = defaultValue1; - const expectedHeaderRequestParams = `metadata_import.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateMetadataImport = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateMetadataImport( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateMetadataImport with call error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.UpdateMetadataImportRequest() - ); - request.metadataImport ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.UpdateMetadataImportRequest', ['metadataImport', 'name']); - request.metadataImport.name = defaultValue1; - const expectedHeaderRequestParams = `metadata_import.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateMetadataImport = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateMetadataImport(request), expectedError); - const actualRequest = (client.innerApiCalls.updateMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateMetadataImport with LRO error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.UpdateMetadataImportRequest() - ); - request.metadataImport ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.UpdateMetadataImportRequest', ['metadataImport', 'name']); - request.metadataImport.name = defaultValue1; - const expectedHeaderRequestParams = `metadata_import.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateMetadataImport = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateMetadataImport(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateMetadataImportProgress without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateMetadataImportProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateMetadataImportProgress with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes getBackup without error using callback', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.GetBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.GetBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Backup(), + ); + client.innerApiCalls.getBackup = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getBackup( + request, + ( + err?: Error | null, + result?: protos.google.cloud.metastore.v1alpha.IBackup | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateMetadataImportProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes getBackup with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.GetBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.GetBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getBackup = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getBackup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('exportMetadata', () => { - it('invokes exportMetadata without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ExportMetadataRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ExportMetadataRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.exportMetadata = stubLongRunningCall(expectedResponse); - const [operation] = await client.exportMetadata(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.exportMetadata as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportMetadata as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes exportMetadata without error using callback', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ExportMetadataRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ExportMetadataRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.exportMetadata = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.exportMetadata( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.exportMetadata as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportMetadata as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes exportMetadata with call error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ExportMetadataRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ExportMetadataRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.exportMetadata = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.exportMetadata(request), expectedError); - const actualRequest = (client.innerApiCalls.exportMetadata as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportMetadata as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes exportMetadata with LRO error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ExportMetadataRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ExportMetadataRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.exportMetadata = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.exportMetadata(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.exportMetadata as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportMetadata as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkExportMetadataProgress without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkExportMetadataProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkExportMetadataProgress with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes getBackup with closed client', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.GetBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.GetBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getBackup(request), expectedError); + }); + }); + + describe('removeIamPolicy', () => { + it('invokes removeIamPolicy without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.RemoveIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.RemoveIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.RemoveIamPolicyResponse(), + ); + client.innerApiCalls.removeIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.removeIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkExportMetadataProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes removeIamPolicy without error using callback', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.RemoveIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.RemoveIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.RemoveIamPolicyResponse(), + ); + client.innerApiCalls.removeIamPolicy = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeIamPolicy( + request, + ( + err?: Error | null, + result?: protos.google.cloud.metastore.v1alpha.IRemoveIamPolicyResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('restoreService', () => { - it('invokes restoreService without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.RestoreServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.RestoreServiceRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.restoreService = stubLongRunningCall(expectedResponse); - const [operation] = await client.restoreService(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.restoreService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes restoreService without error using callback', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.RestoreServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.RestoreServiceRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.restoreService = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.restoreService( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.restoreService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes restoreService with call error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.RestoreServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.RestoreServiceRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.restoreService = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.restoreService(request), expectedError); - const actualRequest = (client.innerApiCalls.restoreService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes restoreService with LRO error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.RestoreServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.RestoreServiceRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.restoreService = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.restoreService(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.restoreService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkRestoreServiceProgress without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkRestoreServiceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRestoreServiceProgress with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes removeIamPolicy with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.RemoveIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.RemoveIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeIamPolicy = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.removeIamPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.removeIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRestoreServiceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes removeIamPolicy with closed client', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.RemoveIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.RemoveIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.removeIamPolicy(request), expectedError); + }); + }); + + describe('createService', () => { + it('invokes createService without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.CreateServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.CreateServiceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createService = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createService(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createBackup', () => { - it('invokes createBackup without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.CreateBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.CreateBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createBackup = stubLongRunningCall(expectedResponse); - const [operation] = await client.createBackup(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createBackup without error using callback', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.CreateBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.CreateBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createBackup = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createBackup( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createBackup with call error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.CreateBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.CreateBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createBackup = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createBackup(request), expectedError); - const actualRequest = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createBackup with LRO error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.CreateBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.CreateBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createBackup = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createBackup(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateBackupProgress without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateBackupProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateBackupProgress with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes createService without error using callback', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.CreateServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.CreateServiceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createService = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createService( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1alpha.IService, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1alpha.IService, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateBackupProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createService with call error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.CreateServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.CreateServiceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createService = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createService(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteBackup', () => { - it('invokes deleteBackup without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteBackup = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteBackup(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteBackup without error using callback', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteBackup = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteBackup( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteBackup with call error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteBackup = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteBackup(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteBackup with LRO error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteBackup = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteBackup(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteBackupProgress without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteBackupProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteBackupProgress with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes createService with LRO error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.CreateServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.CreateServiceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createService = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createService(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteBackupProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateServiceProgress without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateServiceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('queryMetadata', () => { - it('invokes queryMetadata without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.QueryMetadataRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.QueryMetadataRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.queryMetadata = stubLongRunningCall(expectedResponse); - const [operation] = await client.queryMetadata(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.queryMetadata as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.queryMetadata as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes queryMetadata without error using callback', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.QueryMetadataRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.QueryMetadataRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.queryMetadata = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.queryMetadata( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.queryMetadata as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.queryMetadata as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes queryMetadata with call error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.QueryMetadataRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.QueryMetadataRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.queryMetadata = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.queryMetadata(request), expectedError); - const actualRequest = (client.innerApiCalls.queryMetadata as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.queryMetadata as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes queryMetadata with LRO error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.QueryMetadataRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.QueryMetadataRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.queryMetadata = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.queryMetadata(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.queryMetadata as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.queryMetadata as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkQueryMetadataProgress without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkQueryMetadataProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkQueryMetadataProgress with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes checkCreateServiceProgress with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateServiceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateService', () => { + it('invokes updateService without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.UpdateServiceRequest(), + ); + request.service ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.UpdateServiceRequest', + ['service', 'name'], + ); + request.service.name = defaultValue1; + const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateService = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateService(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkQueryMetadataProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateService without error using callback', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.UpdateServiceRequest(), + ); + request.service ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.UpdateServiceRequest', + ['service', 'name'], + ); + request.service.name = defaultValue1; + const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateService = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateService( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1alpha.IService, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1alpha.IService, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('moveTableToDatabase', () => { - it('invokes moveTableToDatabase without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.MoveTableToDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.MoveTableToDatabaseRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.moveTableToDatabase = stubLongRunningCall(expectedResponse); - const [operation] = await client.moveTableToDatabase(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.moveTableToDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.moveTableToDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes moveTableToDatabase without error using callback', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.MoveTableToDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.MoveTableToDatabaseRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.moveTableToDatabase = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.moveTableToDatabase( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.moveTableToDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.moveTableToDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes moveTableToDatabase with call error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.MoveTableToDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.MoveTableToDatabaseRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.moveTableToDatabase = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.moveTableToDatabase(request), expectedError); - const actualRequest = (client.innerApiCalls.moveTableToDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.moveTableToDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes moveTableToDatabase with LRO error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.MoveTableToDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.MoveTableToDatabaseRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.moveTableToDatabase = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.moveTableToDatabase(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.moveTableToDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.moveTableToDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkMoveTableToDatabaseProgress without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkMoveTableToDatabaseProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkMoveTableToDatabaseProgress with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes updateService with call error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.UpdateServiceRequest(), + ); + request.service ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.UpdateServiceRequest', + ['service', 'name'], + ); + request.service.name = defaultValue1; + const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateService = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateService(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkMoveTableToDatabaseProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateService with LRO error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.UpdateServiceRequest(), + ); + request.service ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.UpdateServiceRequest', + ['service', 'name'], + ); + request.service.name = defaultValue1; + const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateService = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateService(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('alterMetadataResourceLocation', () => { - it('invokes alterMetadataResourceLocation without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.AlterMetadataResourceLocationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.AlterMetadataResourceLocationRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.alterMetadataResourceLocation = stubLongRunningCall(expectedResponse); - const [operation] = await client.alterMetadataResourceLocation(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.alterMetadataResourceLocation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.alterMetadataResourceLocation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes alterMetadataResourceLocation without error using callback', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.AlterMetadataResourceLocationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.AlterMetadataResourceLocationRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.alterMetadataResourceLocation = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.alterMetadataResourceLocation( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.alterMetadataResourceLocation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.alterMetadataResourceLocation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes alterMetadataResourceLocation with call error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.AlterMetadataResourceLocationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.AlterMetadataResourceLocationRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.alterMetadataResourceLocation = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.alterMetadataResourceLocation(request), expectedError); - const actualRequest = (client.innerApiCalls.alterMetadataResourceLocation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.alterMetadataResourceLocation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes alterMetadataResourceLocation with LRO error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.AlterMetadataResourceLocationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.AlterMetadataResourceLocationRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.alterMetadataResourceLocation = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.alterMetadataResourceLocation(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.alterMetadataResourceLocation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.alterMetadataResourceLocation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkAlterMetadataResourceLocationProgress without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkAlterMetadataResourceLocationProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAlterMetadataResourceLocationProgress with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes checkUpdateServiceProgress without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateServiceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkAlterMetadataResourceLocationProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpdateServiceProgress with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateServiceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteService', () => { + it('invokes deleteService without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.DeleteServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.DeleteServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteService = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteService(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listServices', () => { - it('invokes listServices without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ListServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Service()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Service()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Service()), - ]; - client.innerApiCalls.listServices = stubSimpleCall(expectedResponse); - const [response] = await client.listServices(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServices as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServices as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listServices without error using callback', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ListServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Service()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Service()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Service()), - ]; - client.innerApiCalls.listServices = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listServices( - request, - (err?: Error|null, result?: protos.google.cloud.metastore.v1alpha.IService[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServices as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServices as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listServices with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ListServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listServices = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listServices(request), expectedError); - const actualRequest = (client.innerApiCalls.listServices as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServices as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listServicesStream without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ListServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Service()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Service()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Service()), - ]; - client.descriptors.page.listServices.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listServicesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.metastore.v1alpha.Service[] = []; - stream.on('data', (response: protos.google.cloud.metastore.v1alpha.Service) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listServices.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServices, request)); - assert( - (client.descriptors.page.listServices.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listServicesStream with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ListServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listServices.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listServicesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.metastore.v1alpha.Service[] = []; - stream.on('data', (response: protos.google.cloud.metastore.v1alpha.Service) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listServices.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServices, request)); - assert( - (client.descriptors.page.listServices.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listServices without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ListServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Service()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Service()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Service()), - ]; - client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.metastore.v1alpha.IService[] = []; - const iterable = client.listServicesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes deleteService without error using callback', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.DeleteServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.DeleteServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteService = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteService( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listServices.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listServices.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listServices with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ListServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listServicesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.metastore.v1alpha.IService[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listServices.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listServices.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listMetadataImports', () => { - it('invokes listMetadataImports without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ListMetadataImportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ListMetadataImportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.MetadataImport()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.MetadataImport()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.MetadataImport()), - ]; - client.innerApiCalls.listMetadataImports = stubSimpleCall(expectedResponse); - const [response] = await client.listMetadataImports(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMetadataImports as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMetadataImports as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listMetadataImports without error using callback', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ListMetadataImportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ListMetadataImportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.MetadataImport()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.MetadataImport()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.MetadataImport()), - ]; - client.innerApiCalls.listMetadataImports = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listMetadataImports( - request, - (err?: Error|null, result?: protos.google.cloud.metastore.v1alpha.IMetadataImport[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMetadataImports as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMetadataImports as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listMetadataImports with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ListMetadataImportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ListMetadataImportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listMetadataImports = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listMetadataImports(request), expectedError); - const actualRequest = (client.innerApiCalls.listMetadataImports as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMetadataImports as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listMetadataImportsStream without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ListMetadataImportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ListMetadataImportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.MetadataImport()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.MetadataImport()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.MetadataImport()), - ]; - client.descriptors.page.listMetadataImports.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listMetadataImportsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.metastore.v1alpha.MetadataImport[] = []; - stream.on('data', (response: protos.google.cloud.metastore.v1alpha.MetadataImport) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listMetadataImports.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMetadataImports, request)); - assert( - (client.descriptors.page.listMetadataImports.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listMetadataImportsStream with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ListMetadataImportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ListMetadataImportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMetadataImports.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listMetadataImportsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.metastore.v1alpha.MetadataImport[] = []; - stream.on('data', (response: protos.google.cloud.metastore.v1alpha.MetadataImport) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listMetadataImports.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMetadataImports, request)); - assert( - (client.descriptors.page.listMetadataImports.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listMetadataImports without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ListMetadataImportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ListMetadataImportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.MetadataImport()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.MetadataImport()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.MetadataImport()), - ]; - client.descriptors.page.listMetadataImports.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.metastore.v1alpha.IMetadataImport[] = []; - const iterable = client.listMetadataImportsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteService with call error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.DeleteServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.DeleteServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteService = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteService(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteService with LRO error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.DeleteServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.DeleteServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteService = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteService(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteServiceProgress without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteServiceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteServiceProgress with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteServiceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createMetadataImport', () => { + it('invokes createMetadataImport without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.CreateMetadataImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.CreateMetadataImportRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createMetadataImport = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createMetadataImport(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createMetadataImport without error using callback', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.CreateMetadataImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.CreateMetadataImportRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createMetadataImport = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createMetadataImport( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1alpha.IMetadataImport, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listMetadataImports.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMetadataImports.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listMetadataImports with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ListMetadataImportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ListMetadataImportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMetadataImports.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listMetadataImportsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.metastore.v1alpha.IMetadataImport[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listMetadataImports.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMetadataImports.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listBackups', () => { - it('invokes listBackups without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Backup()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Backup()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Backup()), - ]; - client.innerApiCalls.listBackups = stubSimpleCall(expectedResponse); - const [response] = await client.listBackups(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listBackups without error using callback', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Backup()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Backup()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Backup()), - ]; - client.innerApiCalls.listBackups = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listBackups( - request, - (err?: Error|null, result?: protos.google.cloud.metastore.v1alpha.IBackup[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listBackups with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listBackups = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listBackups(request), expectedError); - const actualRequest = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listBackupsStream without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Backup()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Backup()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Backup()), - ]; - client.descriptors.page.listBackups.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listBackupsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.metastore.v1alpha.Backup[] = []; - stream.on('data', (response: protos.google.cloud.metastore.v1alpha.Backup) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listBackups.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listBackups, request)); - assert( - (client.descriptors.page.listBackups.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listBackupsStream with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listBackups.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listBackupsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.metastore.v1alpha.Backup[] = []; - stream.on('data', (response: protos.google.cloud.metastore.v1alpha.Backup) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listBackups.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listBackups, request)); - assert( - (client.descriptors.page.listBackups.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listBackups without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Backup()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Backup()), - generateSampleMessage(new protos.google.cloud.metastore.v1alpha.Backup()), - ]; - client.descriptors.page.listBackups.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.metastore.v1alpha.IBackup[] = []; - const iterable = client.listBackupsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1alpha.IMetadataImport, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createMetadataImport with call error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.CreateMetadataImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.CreateMetadataImportRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createMetadataImport = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createMetadataImport(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createMetadataImport with LRO error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.CreateMetadataImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.CreateMetadataImportRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createMetadataImport = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createMetadataImport(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateMetadataImportProgress without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateMetadataImportProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateMetadataImportProgress with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateMetadataImportProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateMetadataImport', () => { + it('invokes updateMetadataImport without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.UpdateMetadataImportRequest(), + ); + request.metadataImport ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.UpdateMetadataImportRequest', + ['metadataImport', 'name'], + ); + request.metadataImport.name = defaultValue1; + const expectedHeaderRequestParams = `metadata_import.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateMetadataImport = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateMetadataImport(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateMetadataImport without error using callback', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.UpdateMetadataImportRequest(), + ); + request.metadataImport ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.UpdateMetadataImportRequest', + ['metadataImport', 'name'], + ); + request.metadataImport.name = defaultValue1; + const expectedHeaderRequestParams = `metadata_import.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateMetadataImport = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateMetadataImport( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1alpha.IMetadataImport, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listBackups.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listBackups.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listBackups with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1alpha.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1alpha.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listBackups.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listBackupsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.metastore.v1alpha.IBackup[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listBackups.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listBackups.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1alpha.IMetadataImport, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateMetadataImport with call error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.UpdateMetadataImportRequest(), + ); + request.metadataImport ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.UpdateMetadataImportRequest', + ['metadataImport', 'name'], + ); + request.metadataImport.name = defaultValue1; + const expectedHeaderRequestParams = `metadata_import.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateMetadataImport = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateMetadataImport(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateMetadataImport with LRO error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.UpdateMetadataImportRequest(), + ); + request.metadataImport ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.UpdateMetadataImportRequest', + ['metadataImport', 'name'], + ); + request.metadataImport.name = defaultValue1; + const expectedHeaderRequestParams = `metadata_import.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateMetadataImport = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateMetadataImport(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateMetadataImportProgress without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateMetadataImportProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateMetadataImportProgress with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateMetadataImportProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('exportMetadata', () => { + it('invokes exportMetadata without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ExportMetadataRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ExportMetadataRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.exportMetadata = + stubLongRunningCall(expectedResponse); + const [operation] = await client.exportMetadata(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.exportMetadata as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportMetadata as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes exportMetadata without error using callback', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ExportMetadataRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ExportMetadataRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.exportMetadata = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.exportMetadata( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1alpha.IMetadataExport, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1alpha.IMetadataExport, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.exportMetadata as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportMetadata as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes exportMetadata with call error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ExportMetadataRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ExportMetadataRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.exportMetadata = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.exportMetadata(request), expectedError); + const actualRequest = ( + client.innerApiCalls.exportMetadata as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportMetadata as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes exportMetadata with LRO error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ExportMetadataRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ExportMetadataRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.exportMetadata = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.exportMetadata(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.exportMetadata as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportMetadata as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkExportMetadataProgress without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkExportMetadataProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkExportMetadataProgress with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkExportMetadataProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('restoreService', () => { + it('invokes restoreService without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.RestoreServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.RestoreServiceRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.restoreService = + stubLongRunningCall(expectedResponse); + const [operation] = await client.restoreService(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.restoreService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes restoreService without error using callback', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.RestoreServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.RestoreServiceRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.restoreService = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.restoreService( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1alpha.IRestore, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1alpha.IRestore, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.restoreService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('Path templates', () => { + it('invokes restoreService with call error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.RestoreServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.RestoreServiceRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.restoreService = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.restoreService(request), expectedError); + const actualRequest = ( + client.innerApiCalls.restoreService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('backup', async () => { - const fakePath = "/rendered/path/backup"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - backup: "backupValue", - }; - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.backupPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.backupPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('backupPath', () => { - const result = client.backupPath("projectValue", "locationValue", "serviceValue", "backupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.backupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes restoreService with LRO error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.RestoreServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.RestoreServiceRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.restoreService = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.restoreService(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.restoreService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromBackupName', () => { - const result = client.matchProjectFromBackupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkRestoreServiceProgress without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkRestoreServiceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('matchLocationFromBackupName', () => { - const result = client.matchLocationFromBackupName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkRestoreServiceProgress with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkRestoreServiceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createBackup', () => { + it('invokes createBackup without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.CreateBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.CreateBackupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createBackup = stubLongRunningCall(expectedResponse); + const [operation] = await client.createBackup(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchServiceFromBackupName', () => { - const result = client.matchServiceFromBackupName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes createBackup without error using callback', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.CreateBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.CreateBackupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createBackup = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createBackup( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1alpha.IBackup, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1alpha.IBackup, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchBackupFromBackupName', () => { - const result = client.matchBackupFromBackupName(fakePath); - assert.strictEqual(result, "backupValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes createBackup with call error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.CreateBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.CreateBackupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createBackup = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createBackup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('federation', async () => { - const fakePath = "/rendered/path/federation"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - federation: "federationValue", - }; - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.federationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.federationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('federationPath', () => { - const result = client.federationPath("projectValue", "locationValue", "federationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.federationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes createBackup with LRO error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.CreateBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.CreateBackupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createBackup = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createBackup(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromFederationName', () => { - const result = client.matchProjectFromFederationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.federationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkCreateBackupProgress without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateBackupProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('matchLocationFromFederationName', () => { - const result = client.matchLocationFromFederationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.federationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkCreateBackupProgress with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkCreateBackupProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteBackup', () => { + it('invokes deleteBackup without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.DeleteBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.DeleteBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteBackup = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteBackup(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchFederationFromFederationName', () => { - const result = client.matchFederationFromFederationName(fakePath); - assert.strictEqual(result, "federationValue"); - assert((client.pathTemplates.federationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes deleteBackup without error using callback', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.DeleteBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.DeleteBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteBackup = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteBackup( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('lake', async () => { - const fakePath = "/rendered/path/lake"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - lake: "lakeValue", - }; - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.lakePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.lakePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('lakePath', () => { - const result = client.lakePath("projectValue", "locationValue", "lakeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.lakePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes deleteBackup with call error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.DeleteBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.DeleteBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteBackup = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteBackup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromLakeName', () => { - const result = client.matchProjectFromLakeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.lakePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes deleteBackup with LRO error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.DeleteBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.DeleteBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteBackup = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteBackup(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromLakeName', () => { - const result = client.matchLocationFromLakeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.lakePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkDeleteBackupProgress without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteBackupProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('matchLakeFromLakeName', () => { - const result = client.matchLakeFromLakeName(fakePath); - assert.strictEqual(result, "lakeValue"); - assert((client.pathTemplates.lakePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes checkDeleteBackupProgress with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkDeleteBackupProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('queryMetadata', () => { + it('invokes queryMetadata without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.QueryMetadataRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.QueryMetadataRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.queryMetadata = + stubLongRunningCall(expectedResponse); + const [operation] = await client.queryMetadata(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.queryMetadata as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryMetadata as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes queryMetadata without error using callback', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.QueryMetadataRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.QueryMetadataRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.queryMetadata = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.queryMetadata( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1alpha.IQueryMetadataResponse, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1alpha.IQueryMetadataResponse, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.queryMetadata as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryMetadata as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes queryMetadata with call error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.QueryMetadataRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.QueryMetadataRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.queryMetadata = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.queryMetadata(request), expectedError); + const actualRequest = ( + client.innerApiCalls.queryMetadata as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryMetadata as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes queryMetadata with LRO error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.QueryMetadataRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.QueryMetadataRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.queryMetadata = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.queryMetadata(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.queryMetadata as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryMetadata as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('metadataImport', async () => { - const fakePath = "/rendered/path/metadataImport"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - metadata_import: "metadataImportValue", - }; - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.metadataImportPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.metadataImportPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('metadataImportPath', () => { - const result = client.metadataImportPath("projectValue", "locationValue", "serviceValue", "metadataImportValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.metadataImportPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes checkQueryMetadataProgress without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkQueryMetadataProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('matchProjectFromMetadataImportName', () => { - const result = client.matchProjectFromMetadataImportName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.metadataImportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkQueryMetadataProgress with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkQueryMetadataProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('moveTableToDatabase', () => { + it('invokes moveTableToDatabase without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.MoveTableToDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.MoveTableToDatabaseRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.moveTableToDatabase = + stubLongRunningCall(expectedResponse); + const [operation] = await client.moveTableToDatabase(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.moveTableToDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.moveTableToDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromMetadataImportName', () => { - const result = client.matchLocationFromMetadataImportName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.metadataImportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes moveTableToDatabase without error using callback', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.MoveTableToDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.MoveTableToDatabaseRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.moveTableToDatabase = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.moveTableToDatabase( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1alpha.IMoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1alpha.IMoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.moveTableToDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.moveTableToDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchServiceFromMetadataImportName', () => { - const result = client.matchServiceFromMetadataImportName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.metadataImportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes moveTableToDatabase with call error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.MoveTableToDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.MoveTableToDatabaseRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.moveTableToDatabase = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.moveTableToDatabase(request), expectedError); + const actualRequest = ( + client.innerApiCalls.moveTableToDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.moveTableToDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchMetadataImportFromMetadataImportName', () => { - const result = client.matchMetadataImportFromMetadataImportName(fakePath); - assert.strictEqual(result, "metadataImportValue"); - assert((client.pathTemplates.metadataImportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes moveTableToDatabase with LRO error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.MoveTableToDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.MoveTableToDatabaseRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.moveTableToDatabase = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.moveTableToDatabase(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.moveTableToDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.moveTableToDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('network', async () => { - const fakePath = "/rendered/path/network"; - const expectedParameters = { - project: "projectValue", - network: "networkValue", - }; - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.networkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.networkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('networkPath', () => { - const result = client.networkPath("projectValue", "networkValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.networkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes checkMoveTableToDatabaseProgress without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkMoveTableToDatabaseProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('matchProjectFromNetworkName', () => { - const result = client.matchProjectFromNetworkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.networkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkMoveTableToDatabaseProgress with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkMoveTableToDatabaseProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('alterMetadataResourceLocation', () => { + it('invokes alterMetadataResourceLocation without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.AlterMetadataResourceLocationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.AlterMetadataResourceLocationRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.alterMetadataResourceLocation = + stubLongRunningCall(expectedResponse); + const [operation] = await client.alterMetadataResourceLocation(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.alterMetadataResourceLocation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.alterMetadataResourceLocation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchNetworkFromNetworkName', () => { - const result = client.matchNetworkFromNetworkName(fakePath); - assert.strictEqual(result, "networkValue"); - assert((client.pathTemplates.networkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes alterMetadataResourceLocation without error using callback', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.AlterMetadataResourceLocationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.AlterMetadataResourceLocationRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.alterMetadataResourceLocation = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.alterMetadataResourceLocation( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1alpha.IAlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1alpha.IAlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1alpha.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.alterMetadataResourceLocation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.alterMetadataResourceLocation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes alterMetadataResourceLocation with call error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.AlterMetadataResourceLocationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.AlterMetadataResourceLocationRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.alterMetadataResourceLocation = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.alterMetadataResourceLocation(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.alterMetadataResourceLocation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.alterMetadataResourceLocation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes alterMetadataResourceLocation with LRO error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.AlterMetadataResourceLocationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.AlterMetadataResourceLocationRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.alterMetadataResourceLocation = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.alterMetadataResourceLocation(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.alterMetadataResourceLocation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.alterMetadataResourceLocation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('service', async () => { - const fakePath = "/rendered/path/service"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - }; - const client = new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.servicePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servicePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servicePath', () => { - const result = client.servicePath("projectValue", "locationValue", "serviceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servicePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes checkAlterMetadataResourceLocationProgress without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkAlterMetadataResourceLocationProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('matchProjectFromServiceName', () => { - const result = client.matchProjectFromServiceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkAlterMetadataResourceLocationProgress with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkAlterMetadataResourceLocationProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listServices', () => { + it('invokes listServices without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ListServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Service(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Service(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Service(), + ), + ]; + client.innerApiCalls.listServices = stubSimpleCall(expectedResponse); + const [response] = await client.listServices(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServices as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServices as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromServiceName', () => { - const result = client.matchLocationFromServiceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listServices without error using callback', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ListServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Service(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Service(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Service(), + ), + ]; + client.innerApiCalls.listServices = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listServices( + request, + ( + err?: Error | null, + result?: protos.google.cloud.metastore.v1alpha.IService[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServices as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServices as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchServiceFromServiceName', () => { - const result = client.matchServiceFromServiceName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes listServices with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ListServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listServices = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listServices(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listServices as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServices as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listServicesStream without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ListServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Service(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Service(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Service(), + ), + ]; + client.descriptors.page.listServices.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listServicesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.metastore.v1alpha.Service[] = []; + stream.on( + 'data', + (response: protos.google.cloud.metastore.v1alpha.Service) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listServices.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listServices, request), + ); + assert( + (client.descriptors.page.listServices.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + + it('invokes listServicesStream with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ListServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listServices.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listServicesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.metastore.v1alpha.Service[] = []; + stream.on( + 'data', + (response: protos.google.cloud.metastore.v1alpha.Service) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listServices.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listServices, request), + ); + assert( + (client.descriptors.page.listServices.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + + it('uses async iteration with listServices without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ListServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Service(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Service(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Service(), + ), + ]; + client.descriptors.page.listServices.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.metastore.v1alpha.IService[] = []; + const iterable = client.listServicesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listServices.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listServices.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + + it('uses async iteration with listServices with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ListServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listServices.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listServicesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.metastore.v1alpha.IService[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listServices.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listServices.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listMetadataImports', () => { + it('invokes listMetadataImports without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ListMetadataImportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ListMetadataImportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.MetadataImport(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.MetadataImport(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.MetadataImport(), + ), + ]; + client.innerApiCalls.listMetadataImports = + stubSimpleCall(expectedResponse); + const [response] = await client.listMetadataImports(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listMetadataImports as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMetadataImports as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listMetadataImports without error using callback', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ListMetadataImportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ListMetadataImportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.MetadataImport(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.MetadataImport(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.MetadataImport(), + ), + ]; + client.innerApiCalls.listMetadataImports = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listMetadataImports( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.metastore.v1alpha.IMetadataImport[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listMetadataImports as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMetadataImports as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listMetadataImports with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ListMetadataImportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ListMetadataImportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listMetadataImports = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listMetadataImports(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listMetadataImports as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMetadataImports as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listMetadataImportsStream without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ListMetadataImportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ListMetadataImportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.MetadataImport(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.MetadataImport(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.MetadataImport(), + ), + ]; + client.descriptors.page.listMetadataImports.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listMetadataImportsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.metastore.v1alpha.MetadataImport[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.metastore.v1alpha.MetadataImport) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listMetadataImports.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listMetadataImports, request), + ); + assert( + (client.descriptors.page.listMetadataImports.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + + it('invokes listMetadataImportsStream with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ListMetadataImportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ListMetadataImportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMetadataImports.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listMetadataImportsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.metastore.v1alpha.MetadataImport[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.metastore.v1alpha.MetadataImport) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listMetadataImports.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listMetadataImports, request), + ); + assert( + (client.descriptors.page.listMetadataImports.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + + it('uses async iteration with listMetadataImports without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ListMetadataImportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ListMetadataImportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.MetadataImport(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.MetadataImport(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.MetadataImport(), + ), + ]; + client.descriptors.page.listMetadataImports.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.metastore.v1alpha.IMetadataImport[] = + []; + const iterable = client.listMetadataImportsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listMetadataImports.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listMetadataImports.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + + it('uses async iteration with listMetadataImports with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ListMetadataImportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ListMetadataImportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMetadataImports.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listMetadataImportsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.metastore.v1alpha.IMetadataImport[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listMetadataImports.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listMetadataImports.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listBackups', () => { + it('invokes listBackups without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Backup(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Backup(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Backup(), + ), + ]; + client.innerApiCalls.listBackups = stubSimpleCall(expectedResponse); + const [response] = await client.listBackups(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listBackups without error using callback', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Backup(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Backup(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Backup(), + ), + ]; + client.innerApiCalls.listBackups = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listBackups( + request, + ( + err?: Error | null, + result?: protos.google.cloud.metastore.v1alpha.IBackup[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listBackups with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listBackups = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listBackups(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listBackupsStream without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Backup(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Backup(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Backup(), + ), + ]; + client.descriptors.page.listBackups.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listBackupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.metastore.v1alpha.Backup[] = []; + stream.on( + 'data', + (response: protos.google.cloud.metastore.v1alpha.Backup) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listBackups.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listBackups, request), + ); + assert( + (client.descriptors.page.listBackups.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + + it('invokes listBackupsStream with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listBackups.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listBackupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.metastore.v1alpha.Backup[] = []; + stream.on( + 'data', + (response: protos.google.cloud.metastore.v1alpha.Backup) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listBackups.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listBackups, request), + ); + assert( + (client.descriptors.page.listBackups.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + + it('uses async iteration with listBackups without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Backup(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Backup(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.Backup(), + ), + ]; + client.descriptors.page.listBackups.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.metastore.v1alpha.IBackup[] = []; + const iterable = client.listBackupsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listBackups.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listBackups.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + + it('uses async iteration with listBackups with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1alpha.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1alpha.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listBackups.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listBackupsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.metastore.v1alpha.IBackup[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listBackups.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listBackups.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getIamPolicy without error using callback', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); + }); + it('invokes getIamPolicy with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes setIamPolicy without error using callback', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); + }); + it('invokes setIamPolicy with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes testIamPermissions without error using callback', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); + }); + it('invokes testIamPermissions with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('backup', async () => { + const fakePath = '/rendered/path/backup'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service: 'serviceValue', + backup: 'backupValue', + }; + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.backupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.backupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('backupPath', () => { + const result = client.backupPath( + 'projectValue', + 'locationValue', + 'serviceValue', + 'backupValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.backupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromBackupName', () => { + const result = client.matchProjectFromBackupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromBackupName', () => { + const result = client.matchLocationFromBackupName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceFromBackupName', () => { + const result = client.matchServiceFromBackupName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchBackupFromBackupName', () => { + const result = client.matchBackupFromBackupName(fakePath); + assert.strictEqual(result, 'backupValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('federation', async () => { + const fakePath = '/rendered/path/federation'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + federation: 'federationValue', + }; + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.federationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.federationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('federationPath', () => { + const result = client.federationPath( + 'projectValue', + 'locationValue', + 'federationValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.federationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromFederationName', () => { + const result = client.matchProjectFromFederationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.federationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromFederationName', () => { + const result = client.matchLocationFromFederationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.federationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchFederationFromFederationName', () => { + const result = client.matchFederationFromFederationName(fakePath); + assert.strictEqual(result, 'federationValue'); + assert( + (client.pathTemplates.federationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('lake', async () => { + const fakePath = '/rendered/path/lake'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + lake: 'lakeValue', + }; + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.lakePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.lakePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('lakePath', () => { + const result = client.lakePath( + 'projectValue', + 'locationValue', + 'lakeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.lakePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLakeName', () => { + const result = client.matchProjectFromLakeName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.lakePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLakeName', () => { + const result = client.matchLocationFromLakeName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.lakePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLakeFromLakeName', () => { + const result = client.matchLakeFromLakeName(fakePath); + assert.strictEqual(result, 'lakeValue'); + assert( + (client.pathTemplates.lakePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('metadataImport', async () => { + const fakePath = '/rendered/path/metadataImport'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service: 'serviceValue', + metadata_import: 'metadataImportValue', + }; + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.metadataImportPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.metadataImportPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('metadataImportPath', () => { + const result = client.metadataImportPath( + 'projectValue', + 'locationValue', + 'serviceValue', + 'metadataImportValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.metadataImportPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMetadataImportName', () => { + const result = client.matchProjectFromMetadataImportName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.metadataImportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMetadataImportName', () => { + const result = client.matchLocationFromMetadataImportName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.metadataImportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceFromMetadataImportName', () => { + const result = client.matchServiceFromMetadataImportName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.metadataImportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMetadataImportFromMetadataImportName', () => { + const result = + client.matchMetadataImportFromMetadataImportName(fakePath); + assert.strictEqual(result, 'metadataImportValue'); + assert( + (client.pathTemplates.metadataImportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('network', async () => { + const fakePath = '/rendered/path/network'; + const expectedParameters = { + project: 'projectValue', + network: 'networkValue', + }; + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.networkPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.networkPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('networkPath', () => { + const result = client.networkPath('projectValue', 'networkValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.networkPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromNetworkName', () => { + const result = client.matchProjectFromNetworkName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.networkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchNetworkFromNetworkName', () => { + const result = client.matchNetworkFromNetworkName(fakePath); + assert.strictEqual(result, 'networkValue'); + assert( + (client.pathTemplates.networkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('service', async () => { + const fakePath = '/rendered/path/service'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service: 'serviceValue', + }; + const client = + new dataprocmetastoreModule.v1alpha.DataprocMetastoreClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.servicePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servicePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servicePath', () => { + const result = client.servicePath( + 'projectValue', + 'locationValue', + 'serviceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servicePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceName', () => { + const result = client.matchProjectFromServiceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromServiceName', () => { + const result = client.matchLocationFromServiceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceFromServiceName', () => { + const result = client.matchServiceFromServiceName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-metastore/test/gapic_dataproc_metastore_v1beta.ts b/packages/google-cloud-metastore/test/gapic_dataproc_metastore_v1beta.ts index 45fea3fad8bb..4eb0fdcdebe3 100644 --- a/packages/google-cloud-metastore/test/gapic_dataproc_metastore_v1beta.ts +++ b/packages/google-cloud-metastore/test/gapic_dataproc_metastore_v1beta.ts @@ -19,4334 +19,5817 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as dataprocmetastoreModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + IamProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1beta.DataprocMetastoreClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'metastore.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new dataprocmetastoreModule.v1beta.DataprocMetastoreClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'metastore.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = + new dataprocmetastoreModule.v1beta.DataprocMetastoreClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = dataprocmetastoreModule.v1beta.DataprocMetastoreClient.servicePath; - assert.strictEqual(servicePath, 'metastore.googleapis.com'); - assert(stub.called); - stub.restore(); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + dataprocmetastoreModule.v1beta.DataprocMetastoreClient.servicePath; + assert.strictEqual(servicePath, 'metastore.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + dataprocmetastoreModule.v1beta.DataprocMetastoreClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'metastore.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { universeDomain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'metastore.example.com'); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = dataprocmetastoreModule.v1beta.DataprocMetastoreClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'metastore.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'metastore.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { universe_domain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'metastore.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'metastore.example.com'); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new dataprocmetastoreModule.v1beta.DataprocMetastoreClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'metastore.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'metastore.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'metastore.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'metastore.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + it('has port', () => { + const port = dataprocmetastoreModule.v1beta.DataprocMetastoreClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has port', () => { - const port = dataprocmetastoreModule.v1beta.DataprocMetastoreClient.port; - assert(port); - assert(typeof port === 'number'); - }); + it('should create a client with no option', () => { + const client = + new dataprocmetastoreModule.v1beta.DataprocMetastoreClient(); + assert(client); + }); - it('should create a client with no option', () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient(); - assert(client); - }); + it('should create a client with gRPC fallback', () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + fallback: true, + }, + ); + assert(client); + }); - it('should create a client with gRPC fallback', () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - fallback: true, - }); - assert(client); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.dataprocMetastoreStub, undefined); + await client.initialize(); + assert(client.dataprocMetastoreStub); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.dataprocMetastoreStub, undefined); - await client.initialize(); - assert(client.dataprocMetastoreStub); + it('has close method for the initialized client', (done) => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.initialize().catch((err) => { + throw err; + }); + assert(client.dataprocMetastoreStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has close method for the initialized client', done => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.dataprocMetastoreStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the non-initialized client', (done) => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.dataprocMetastoreStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has close method for the non-initialized client', done => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.dataprocMetastoreStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getService', () => { + it('invokes getService without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.GetServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.GetServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Service(), + ); + client.innerApiCalls.getService = stubSimpleCall(expectedResponse); + const [response] = await client.getService(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); + it('invokes getService without error using callback', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.GetServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.GetServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Service(), + ); + client.innerApiCalls.getService = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getService( + request, + ( + err?: Error | null, + result?: protos.google.cloud.metastore.v1beta.IService | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getService', () => { - it('invokes getService without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.GetServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.GetServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.Service() - ); - client.innerApiCalls.getService = stubSimpleCall(expectedResponse); - const [response] = await client.getService(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getService with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.GetServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.GetServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getService = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getService(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getService without error using callback', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.GetServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.GetServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.Service() - ); - client.innerApiCalls.getService = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getService( - request, - (err?: Error|null, result?: protos.google.cloud.metastore.v1beta.IService|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getService with closed client', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.GetServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.GetServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getService(request), expectedError); + }); + }); + + describe('getMetadataImport', () => { + it('invokes getMetadataImport without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.GetMetadataImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.GetMetadataImportRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.MetadataImport(), + ); + client.innerApiCalls.getMetadataImport = stubSimpleCall(expectedResponse); + const [response] = await client.getMetadataImport(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getService with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.GetServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.GetServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getService = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getService(request), expectedError); - const actualRequest = (client.innerApiCalls.getService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getMetadataImport without error using callback', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.GetMetadataImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.GetMetadataImportRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.MetadataImport(), + ); + client.innerApiCalls.getMetadataImport = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getMetadataImport( + request, + ( + err?: Error | null, + result?: protos.google.cloud.metastore.v1beta.IMetadataImport | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getService with closed client', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.GetServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.GetServiceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getService(request), expectedError); - }); + it('invokes getMetadataImport with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.GetMetadataImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.GetMetadataImportRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getMetadataImport = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getMetadataImport(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getMetadataImport', () => { - it('invokes getMetadataImport without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.GetMetadataImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.GetMetadataImportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.MetadataImport() - ); - client.innerApiCalls.getMetadataImport = stubSimpleCall(expectedResponse); - const [response] = await client.getMetadataImport(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getMetadataImport with closed client', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.GetMetadataImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.GetMetadataImportRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getMetadataImport(request), expectedError); + }); + }); + + describe('getBackup', () => { + it('invokes getBackup without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.GetBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.GetBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Backup(), + ); + client.innerApiCalls.getBackup = stubSimpleCall(expectedResponse); + const [response] = await client.getBackup(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getMetadataImport without error using callback', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.GetMetadataImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.GetMetadataImportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.MetadataImport() - ); - client.innerApiCalls.getMetadataImport = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getMetadataImport( - request, - (err?: Error|null, result?: protos.google.cloud.metastore.v1beta.IMetadataImport|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getBackup without error using callback', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.GetBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.GetBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Backup(), + ); + client.innerApiCalls.getBackup = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getBackup( + request, + ( + err?: Error | null, + result?: protos.google.cloud.metastore.v1beta.IBackup | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getMetadataImport with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.GetMetadataImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.GetMetadataImportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getMetadataImport = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getMetadataImport(request), expectedError); - const actualRequest = (client.innerApiCalls.getMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getBackup with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.GetBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.GetBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getBackup = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getBackup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getMetadataImport with closed client', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.GetMetadataImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.GetMetadataImportRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getMetadataImport(request), expectedError); - }); + it('invokes getBackup with closed client', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.GetBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.GetBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getBackup(request), expectedError); + }); + }); + + describe('removeIamPolicy', () => { + it('invokes removeIamPolicy without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.RemoveIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.RemoveIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.RemoveIamPolicyResponse(), + ); + client.innerApiCalls.removeIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.removeIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getBackup', () => { - it('invokes getBackup without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.GetBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.Backup() - ); - client.innerApiCalls.getBackup = stubSimpleCall(expectedResponse); - const [response] = await client.getBackup(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes removeIamPolicy without error using callback', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.RemoveIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.RemoveIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.RemoveIamPolicyResponse(), + ); + client.innerApiCalls.removeIamPolicy = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeIamPolicy( + request, + ( + err?: Error | null, + result?: protos.google.cloud.metastore.v1beta.IRemoveIamPolicyResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getBackup without error using callback', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.GetBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.Backup() - ); - client.innerApiCalls.getBackup = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getBackup( - request, - (err?: Error|null, result?: protos.google.cloud.metastore.v1beta.IBackup|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes removeIamPolicy with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.RemoveIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.RemoveIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeIamPolicy = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.removeIamPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.removeIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getBackup with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.GetBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getBackup = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getBackup(request), expectedError); - const actualRequest = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes removeIamPolicy with closed client', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.RemoveIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.RemoveIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.removeIamPolicy(request), expectedError); + }); + }); + + describe('createService', () => { + it('invokes createService without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.CreateServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.CreateServiceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createService = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createService(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getBackup with closed client', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.GetBackupRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getBackup(request), expectedError); - }); + it('invokes createService without error using callback', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.CreateServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.CreateServiceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createService = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createService( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1beta.IService, + protos.google.cloud.metastore.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1beta.IService, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('removeIamPolicy', () => { - it('invokes removeIamPolicy without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.RemoveIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.RemoveIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.RemoveIamPolicyResponse() - ); - client.innerApiCalls.removeIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.removeIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.removeIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createService with call error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.CreateServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.CreateServiceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createService = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createService(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes removeIamPolicy without error using callback', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.RemoveIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.RemoveIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.RemoveIamPolicyResponse() - ); - client.innerApiCalls.removeIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeIamPolicy( - request, - (err?: Error|null, result?: protos.google.cloud.metastore.v1beta.IRemoveIamPolicyResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.removeIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createService with LRO error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.CreateServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.CreateServiceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createService = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createService(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes removeIamPolicy with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.RemoveIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.RemoveIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.removeIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.removeIamPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.removeIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateServiceProgress without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkCreateServiceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes removeIamPolicy with closed client', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.RemoveIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.RemoveIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.removeIamPolicy(request), expectedError); - }); + it('invokes checkCreateServiceProgress with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateServiceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateService', () => { + it('invokes updateService without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.UpdateServiceRequest(), + ); + request.service ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.UpdateServiceRequest', + ['service', 'name'], + ); + request.service.name = defaultValue1; + const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateService = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateService(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createService', () => { - it('invokes createService without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.CreateServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.CreateServiceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createService = stubLongRunningCall(expectedResponse); - const [operation] = await client.createService(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateService without error using callback', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.UpdateServiceRequest(), + ); + request.service ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.UpdateServiceRequest', + ['service', 'name'], + ); + request.service.name = defaultValue1; + const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateService = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateService( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1beta.IService, + protos.google.cloud.metastore.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1beta.IService, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createService without error using callback', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.CreateServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.CreateServiceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createService = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createService( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateService with call error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.UpdateServiceRequest(), + ); + request.service ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.UpdateServiceRequest', + ['service', 'name'], + ); + request.service.name = defaultValue1; + const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateService = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateService(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createService with call error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.CreateServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.CreateServiceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createService = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createService(request), expectedError); - const actualRequest = (client.innerApiCalls.createService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateService with LRO error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.UpdateServiceRequest(), + ); + request.service ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.UpdateServiceRequest', + ['service', 'name'], + ); + request.service.name = defaultValue1; + const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateService = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateService(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createService with LRO error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.CreateServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.CreateServiceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createService = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createService(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateServiceProgress without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkUpdateServiceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkCreateServiceProgress without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateServiceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateServiceProgress with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateServiceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteService', () => { + it('invokes deleteService without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.DeleteServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.DeleteServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteService = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteService(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateServiceProgress with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes deleteService without error using callback', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.DeleteServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.DeleteServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteService = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteService( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateServiceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteService with call error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.DeleteServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.DeleteServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteService = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteService(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateService', () => { - it('invokes updateService without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.UpdateServiceRequest() - ); - request.service ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.UpdateServiceRequest', ['service', 'name']); - request.service.name = defaultValue1; - const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateService = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateService(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteService with LRO error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.DeleteServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.DeleteServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteService = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteService(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateService without error using callback', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.UpdateServiceRequest() - ); - request.service ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.UpdateServiceRequest', ['service', 'name']); - request.service.name = defaultValue1; - const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateService = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateService( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteServiceProgress without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkDeleteServiceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateService with call error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.UpdateServiceRequest() - ); - request.service ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.UpdateServiceRequest', ['service', 'name']); - request.service.name = defaultValue1; - const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateService = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateService(request), expectedError); - const actualRequest = (client.innerApiCalls.updateService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteServiceProgress with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteServiceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createMetadataImport', () => { + it('invokes createMetadataImport without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.CreateMetadataImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.CreateMetadataImportRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createMetadataImport = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createMetadataImport(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateService with LRO error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.UpdateServiceRequest() - ); - request.service ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.UpdateServiceRequest', ['service', 'name']); - request.service.name = defaultValue1; - const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateService = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateService(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createMetadataImport without error using callback', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.CreateMetadataImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.CreateMetadataImportRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createMetadataImport = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createMetadataImport( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1beta.IMetadataImport, + protos.google.cloud.metastore.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1beta.IMetadataImport, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateServiceProgress without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateServiceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createMetadataImport with call error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.CreateMetadataImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.CreateMetadataImportRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createMetadataImport = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createMetadataImport(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateServiceProgress with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes createMetadataImport with LRO error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.CreateMetadataImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.CreateMetadataImportRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createMetadataImport = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createMetadataImport(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateServiceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateMetadataImportProgress without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkCreateMetadataImportProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('deleteService', () => { - it('invokes deleteService without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.DeleteServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.DeleteServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteService = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteService(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateMetadataImportProgress with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateMetadataImportProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateMetadataImport', () => { + it('invokes updateMetadataImport without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.UpdateMetadataImportRequest(), + ); + request.metadataImport ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.UpdateMetadataImportRequest', + ['metadataImport', 'name'], + ); + request.metadataImport.name = defaultValue1; + const expectedHeaderRequestParams = `metadata_import.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateMetadataImport = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateMetadataImport(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteService without error using callback', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.DeleteServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.DeleteServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteService = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteService( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateMetadataImport without error using callback', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.UpdateMetadataImportRequest(), + ); + request.metadataImport ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.UpdateMetadataImportRequest', + ['metadataImport', 'name'], + ); + request.metadataImport.name = defaultValue1; + const expectedHeaderRequestParams = `metadata_import.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateMetadataImport = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateMetadataImport( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1beta.IMetadataImport, + protos.google.cloud.metastore.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1beta.IMetadataImport, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteService with call error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.DeleteServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.DeleteServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteService = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteService(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateMetadataImport with call error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.UpdateMetadataImportRequest(), + ); + request.metadataImport ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.UpdateMetadataImportRequest', + ['metadataImport', 'name'], + ); + request.metadataImport.name = defaultValue1; + const expectedHeaderRequestParams = `metadata_import.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateMetadataImport = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateMetadataImport(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteService with LRO error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.DeleteServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.DeleteServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteService = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteService(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateMetadataImport with LRO error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.UpdateMetadataImportRequest(), + ); + request.metadataImport ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.UpdateMetadataImportRequest', + ['metadataImport', 'name'], + ); + request.metadataImport.name = defaultValue1; + const expectedHeaderRequestParams = `metadata_import.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateMetadataImport = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateMetadataImport(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateMetadataImport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMetadataImport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteServiceProgress without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteServiceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateMetadataImportProgress without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkUpdateMetadataImportProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteServiceProgress with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes checkUpdateMetadataImportProgress with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateMetadataImportProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('exportMetadata', () => { + it('invokes exportMetadata without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ExportMetadataRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ExportMetadataRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.exportMetadata = + stubLongRunningCall(expectedResponse); + const [operation] = await client.exportMetadata(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.exportMetadata as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportMetadata as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteServiceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes exportMetadata without error using callback', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ExportMetadataRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ExportMetadataRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.exportMetadata = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.exportMetadata( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1beta.IMetadataExport, + protos.google.cloud.metastore.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1beta.IMetadataExport, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.exportMetadata as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportMetadata as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createMetadataImport', () => { - it('invokes createMetadataImport without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.CreateMetadataImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.CreateMetadataImportRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createMetadataImport = stubLongRunningCall(expectedResponse); - const [operation] = await client.createMetadataImport(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes exportMetadata with call error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ExportMetadataRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ExportMetadataRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.exportMetadata = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.exportMetadata(request), expectedError); + const actualRequest = ( + client.innerApiCalls.exportMetadata as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportMetadata as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createMetadataImport without error using callback', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.CreateMetadataImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.CreateMetadataImportRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createMetadataImport = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createMetadataImport( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes exportMetadata with LRO error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ExportMetadataRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ExportMetadataRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.exportMetadata = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.exportMetadata(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.exportMetadata as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportMetadata as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createMetadataImport with call error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.CreateMetadataImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.CreateMetadataImportRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createMetadataImport = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createMetadataImport(request), expectedError); - const actualRequest = (client.innerApiCalls.createMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkExportMetadataProgress without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkExportMetadataProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createMetadataImport with LRO error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.CreateMetadataImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.CreateMetadataImportRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createMetadataImport = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createMetadataImport(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkExportMetadataProgress with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkExportMetadataProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('restoreService', () => { + it('invokes restoreService without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.RestoreServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.RestoreServiceRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.restoreService = + stubLongRunningCall(expectedResponse); + const [operation] = await client.restoreService(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.restoreService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateMetadataImportProgress without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateMetadataImportProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes restoreService without error using callback', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.RestoreServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.RestoreServiceRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.restoreService = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.restoreService( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1beta.IRestore, + protos.google.cloud.metastore.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1beta.IRestore, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.restoreService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateMetadataImportProgress with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes restoreService with call error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.RestoreServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.RestoreServiceRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.restoreService = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.restoreService(request), expectedError); + const actualRequest = ( + client.innerApiCalls.restoreService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateMetadataImportProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes restoreService with LRO error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.RestoreServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.RestoreServiceRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.restoreService = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.restoreService(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.restoreService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateMetadataImport', () => { - it('invokes updateMetadataImport without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.UpdateMetadataImportRequest() - ); - request.metadataImport ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.UpdateMetadataImportRequest', ['metadataImport', 'name']); - request.metadataImport.name = defaultValue1; - const expectedHeaderRequestParams = `metadata_import.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateMetadataImport = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateMetadataImport(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRestoreServiceProgress without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkRestoreServiceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateMetadataImport without error using callback', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.UpdateMetadataImportRequest() - ); - request.metadataImport ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.UpdateMetadataImportRequest', ['metadataImport', 'name']); - request.metadataImport.name = defaultValue1; - const expectedHeaderRequestParams = `metadata_import.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateMetadataImport = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateMetadataImport( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRestoreServiceProgress with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkRestoreServiceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createBackup', () => { + it('invokes createBackup without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.CreateBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.CreateBackupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createBackup = stubLongRunningCall(expectedResponse); + const [operation] = await client.createBackup(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateMetadataImport with call error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.UpdateMetadataImportRequest() - ); - request.metadataImport ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.UpdateMetadataImportRequest', ['metadataImport', 'name']); - request.metadataImport.name = defaultValue1; - const expectedHeaderRequestParams = `metadata_import.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateMetadataImport = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateMetadataImport(request), expectedError); - const actualRequest = (client.innerApiCalls.updateMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createBackup without error using callback', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.CreateBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.CreateBackupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createBackup = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createBackup( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1beta.IBackup, + protos.google.cloud.metastore.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1beta.IBackup, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateMetadataImport with LRO error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.UpdateMetadataImportRequest() - ); - request.metadataImport ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.UpdateMetadataImportRequest', ['metadataImport', 'name']); - request.metadataImport.name = defaultValue1; - const expectedHeaderRequestParams = `metadata_import.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateMetadataImport = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateMetadataImport(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateMetadataImport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMetadataImport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createBackup with call error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.CreateBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.CreateBackupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createBackup = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createBackup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateMetadataImportProgress without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateMetadataImportProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createBackup with LRO error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.CreateBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.CreateBackupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createBackup = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createBackup(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateMetadataImportProgress with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes checkCreateBackupProgress without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkCreateBackupProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateMetadataImportProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateBackupProgress with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkCreateBackupProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteBackup', () => { + it('invokes deleteBackup without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.DeleteBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.DeleteBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteBackup = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteBackup(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('exportMetadata', () => { - it('invokes exportMetadata without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ExportMetadataRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ExportMetadataRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.exportMetadata = stubLongRunningCall(expectedResponse); - const [operation] = await client.exportMetadata(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.exportMetadata as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportMetadata as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteBackup without error using callback', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.DeleteBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.DeleteBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteBackup = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteBackup( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes exportMetadata without error using callback', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ExportMetadataRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ExportMetadataRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.exportMetadata = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.exportMetadata( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.exportMetadata as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportMetadata as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteBackup with call error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.DeleteBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.DeleteBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteBackup = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteBackup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes exportMetadata with call error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ExportMetadataRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ExportMetadataRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.exportMetadata = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.exportMetadata(request), expectedError); - const actualRequest = (client.innerApiCalls.exportMetadata as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportMetadata as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteBackup with LRO error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.DeleteBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.DeleteBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteBackup = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteBackup(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes exportMetadata with LRO error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ExportMetadataRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ExportMetadataRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.exportMetadata = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.exportMetadata(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.exportMetadata as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportMetadata as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteBackupProgress without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkDeleteBackupProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkExportMetadataProgress without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkExportMetadataProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkDeleteBackupProgress with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkDeleteBackupProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('queryMetadata', () => { + it('invokes queryMetadata without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.QueryMetadataRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.QueryMetadataRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.queryMetadata = + stubLongRunningCall(expectedResponse); + const [operation] = await client.queryMetadata(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.queryMetadata as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryMetadata as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkExportMetadataProgress with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes queryMetadata without error using callback', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.QueryMetadataRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.QueryMetadataRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.queryMetadata = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.queryMetadata( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1beta.IQueryMetadataResponse, + protos.google.cloud.metastore.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1beta.IQueryMetadataResponse, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.queryMetadata as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryMetadata as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkExportMetadataProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes queryMetadata with call error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.QueryMetadataRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.QueryMetadataRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.queryMetadata = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.queryMetadata(request), expectedError); + const actualRequest = ( + client.innerApiCalls.queryMetadata as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryMetadata as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('restoreService', () => { - it('invokes restoreService without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.RestoreServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.RestoreServiceRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.restoreService = stubLongRunningCall(expectedResponse); - const [operation] = await client.restoreService(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.restoreService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes queryMetadata with LRO error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.QueryMetadataRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.QueryMetadataRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.queryMetadata = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.queryMetadata(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.queryMetadata as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryMetadata as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes restoreService without error using callback', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.RestoreServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.RestoreServiceRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.restoreService = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.restoreService( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.restoreService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkQueryMetadataProgress without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkQueryMetadataProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes restoreService with call error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.RestoreServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.RestoreServiceRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.restoreService = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.restoreService(request), expectedError); - const actualRequest = (client.innerApiCalls.restoreService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkQueryMetadataProgress with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkQueryMetadataProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('moveTableToDatabase', () => { + it('invokes moveTableToDatabase without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.MoveTableToDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.MoveTableToDatabaseRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.moveTableToDatabase = + stubLongRunningCall(expectedResponse); + const [operation] = await client.moveTableToDatabase(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.moveTableToDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.moveTableToDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes restoreService with LRO error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.RestoreServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.RestoreServiceRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.restoreService = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.restoreService(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.restoreService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes moveTableToDatabase without error using callback', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.MoveTableToDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.MoveTableToDatabaseRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.moveTableToDatabase = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.moveTableToDatabase( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1beta.IMoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1beta.IMoveTableToDatabaseResponse, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.moveTableToDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.moveTableToDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRestoreServiceProgress without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkRestoreServiceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes moveTableToDatabase with call error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.MoveTableToDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.MoveTableToDatabaseRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.moveTableToDatabase = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.moveTableToDatabase(request), expectedError); + const actualRequest = ( + client.innerApiCalls.moveTableToDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.moveTableToDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRestoreServiceProgress with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes moveTableToDatabase with LRO error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.MoveTableToDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.MoveTableToDatabaseRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.moveTableToDatabase = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.moveTableToDatabase(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.moveTableToDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.moveTableToDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRestoreServiceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkMoveTableToDatabaseProgress without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkMoveTableToDatabaseProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('createBackup', () => { - it('invokes createBackup without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.CreateBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.CreateBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createBackup = stubLongRunningCall(expectedResponse); - const [operation] = await client.createBackup(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createBackup without error using callback', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.CreateBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.CreateBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createBackup = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createBackup( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createBackup with call error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.CreateBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.CreateBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createBackup = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createBackup(request), expectedError); - const actualRequest = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createBackup with LRO error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.CreateBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.CreateBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createBackup = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createBackup(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateBackupProgress without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateBackupProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateBackupProgress with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateBackupProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkMoveTableToDatabaseProgress with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkMoveTableToDatabaseProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - - describe('deleteBackup', () => { - it('invokes deleteBackup without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteBackup = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteBackup(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteBackup without error using callback', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteBackup = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteBackup( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteBackup with call error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteBackup = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteBackup(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteBackup with LRO error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteBackup = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteBackup(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteBackupProgress without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteBackupProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteBackupProgress with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteBackupProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + }); + + describe('alterMetadataResourceLocation', () => { + it('invokes alterMetadataResourceLocation without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.AlterMetadataResourceLocationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.AlterMetadataResourceLocationRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.alterMetadataResourceLocation = + stubLongRunningCall(expectedResponse); + const [operation] = await client.alterMetadataResourceLocation(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.alterMetadataResourceLocation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.alterMetadataResourceLocation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('queryMetadata', () => { - it('invokes queryMetadata without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.QueryMetadataRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.QueryMetadataRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.queryMetadata = stubLongRunningCall(expectedResponse); - const [operation] = await client.queryMetadata(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.queryMetadata as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.queryMetadata as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes queryMetadata without error using callback', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.QueryMetadataRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.QueryMetadataRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.queryMetadata = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.queryMetadata( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.queryMetadata as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.queryMetadata as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes queryMetadata with call error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.QueryMetadataRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.QueryMetadataRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.queryMetadata = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.queryMetadata(request), expectedError); - const actualRequest = (client.innerApiCalls.queryMetadata as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.queryMetadata as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes queryMetadata with LRO error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.QueryMetadataRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.QueryMetadataRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.queryMetadata = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.queryMetadata(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.queryMetadata as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.queryMetadata as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkQueryMetadataProgress without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkQueryMetadataProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkQueryMetadataProgress with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkQueryMetadataProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes alterMetadataResourceLocation without error using callback', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.AlterMetadataResourceLocationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.AlterMetadataResourceLocationRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.alterMetadataResourceLocation = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.alterMetadataResourceLocation( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.metastore.v1beta.IAlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.metastore.v1beta.IAlterMetadataResourceLocationResponse, + protos.google.cloud.metastore.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.alterMetadataResourceLocation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.alterMetadataResourceLocation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('moveTableToDatabase', () => { - it('invokes moveTableToDatabase without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.MoveTableToDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.MoveTableToDatabaseRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.moveTableToDatabase = stubLongRunningCall(expectedResponse); - const [operation] = await client.moveTableToDatabase(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.moveTableToDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.moveTableToDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes moveTableToDatabase without error using callback', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.MoveTableToDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.MoveTableToDatabaseRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.moveTableToDatabase = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.moveTableToDatabase( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.moveTableToDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.moveTableToDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes moveTableToDatabase with call error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.MoveTableToDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.MoveTableToDatabaseRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.moveTableToDatabase = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.moveTableToDatabase(request), expectedError); - const actualRequest = (client.innerApiCalls.moveTableToDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.moveTableToDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes moveTableToDatabase with LRO error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.MoveTableToDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.MoveTableToDatabaseRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.moveTableToDatabase = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.moveTableToDatabase(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.moveTableToDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.moveTableToDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkMoveTableToDatabaseProgress without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkMoveTableToDatabaseProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkMoveTableToDatabaseProgress with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkMoveTableToDatabaseProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes alterMetadataResourceLocation with call error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.AlterMetadataResourceLocationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.AlterMetadataResourceLocationRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.alterMetadataResourceLocation = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.alterMetadataResourceLocation(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.alterMetadataResourceLocation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.alterMetadataResourceLocation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('alterMetadataResourceLocation', () => { - it('invokes alterMetadataResourceLocation without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.AlterMetadataResourceLocationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.AlterMetadataResourceLocationRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.alterMetadataResourceLocation = stubLongRunningCall(expectedResponse); - const [operation] = await client.alterMetadataResourceLocation(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.alterMetadataResourceLocation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.alterMetadataResourceLocation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes alterMetadataResourceLocation without error using callback', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.AlterMetadataResourceLocationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.AlterMetadataResourceLocationRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.alterMetadataResourceLocation = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.alterMetadataResourceLocation( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.alterMetadataResourceLocation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.alterMetadataResourceLocation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes alterMetadataResourceLocation with call error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.AlterMetadataResourceLocationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.AlterMetadataResourceLocationRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.alterMetadataResourceLocation = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.alterMetadataResourceLocation(request), expectedError); - const actualRequest = (client.innerApiCalls.alterMetadataResourceLocation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.alterMetadataResourceLocation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes alterMetadataResourceLocation with LRO error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.AlterMetadataResourceLocationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.AlterMetadataResourceLocationRequest', ['service']); - request.service = defaultValue1; - const expectedHeaderRequestParams = `service=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.alterMetadataResourceLocation = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.alterMetadataResourceLocation(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.alterMetadataResourceLocation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.alterMetadataResourceLocation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes alterMetadataResourceLocation with LRO error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.AlterMetadataResourceLocationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.AlterMetadataResourceLocationRequest', + ['service'], + ); + request.service = defaultValue1; + const expectedHeaderRequestParams = `service=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.alterMetadataResourceLocation = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.alterMetadataResourceLocation(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.alterMetadataResourceLocation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.alterMetadataResourceLocation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkAlterMetadataResourceLocationProgress without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkAlterMetadataResourceLocationProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkAlterMetadataResourceLocationProgress without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkAlterMetadataResourceLocationProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkAlterMetadataResourceLocationProgress with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes checkAlterMetadataResourceLocationProgress with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkAlterMetadataResourceLocationProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listServices', () => { + it('invokes listServices without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ListServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Service(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Service(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Service(), + ), + ]; + client.innerApiCalls.listServices = stubSimpleCall(expectedResponse); + const [response] = await client.listServices(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServices as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServices as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkAlterMetadataResourceLocationProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes listServices without error using callback', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ListServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Service(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Service(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Service(), + ), + ]; + client.innerApiCalls.listServices = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listServices( + request, + ( + err?: Error | null, + result?: protos.google.cloud.metastore.v1beta.IService[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServices as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServices as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listServices', () => { - it('invokes listServices without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ListServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Service()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Service()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Service()), - ]; - client.innerApiCalls.listServices = stubSimpleCall(expectedResponse); - const [response] = await client.listServices(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServices as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServices as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listServices with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ListServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listServices = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listServices(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listServices as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServices as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listServices without error using callback', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ListServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Service()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Service()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Service()), - ]; - client.innerApiCalls.listServices = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listServices( - request, - (err?: Error|null, result?: protos.google.cloud.metastore.v1beta.IService[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServices as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServices as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listServicesStream without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ListServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Service(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Service(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Service(), + ), + ]; + client.descriptors.page.listServices.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listServicesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.metastore.v1beta.Service[] = []; + stream.on( + 'data', + (response: protos.google.cloud.metastore.v1beta.Service) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listServices.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listServices, request), + ); + assert( + (client.descriptors.page.listServices.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listServices with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ListServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listServices = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listServices(request), expectedError); - const actualRequest = (client.innerApiCalls.listServices as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServices as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listServicesStream with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ListServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listServices.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listServicesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.metastore.v1beta.Service[] = []; + stream.on( + 'data', + (response: protos.google.cloud.metastore.v1beta.Service) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listServices.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listServices, request), + ); + assert( + (client.descriptors.page.listServices.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listServicesStream without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ListServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Service()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Service()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Service()), - ]; - client.descriptors.page.listServices.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listServicesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.metastore.v1beta.Service[] = []; - stream.on('data', (response: protos.google.cloud.metastore.v1beta.Service) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listServices.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServices, request)); - assert( - (client.descriptors.page.listServices.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listServices without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ListServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Service(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Service(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Service(), + ), + ]; + client.descriptors.page.listServices.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.metastore.v1beta.IService[] = []; + const iterable = client.listServicesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listServices.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listServices.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listServicesStream with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ListServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listServices.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listServicesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.metastore.v1beta.Service[] = []; - stream.on('data', (response: protos.google.cloud.metastore.v1beta.Service) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listServices.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServices, request)); - assert( - (client.descriptors.page.listServices.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listServices with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ListServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listServices.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listServicesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.metastore.v1beta.IService[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listServices.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listServices.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listMetadataImports', () => { + it('invokes listMetadataImports without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ListMetadataImportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ListMetadataImportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.MetadataImport(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.MetadataImport(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.MetadataImport(), + ), + ]; + client.innerApiCalls.listMetadataImports = + stubSimpleCall(expectedResponse); + const [response] = await client.listMetadataImports(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listMetadataImports as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMetadataImports as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listServices without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ListServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Service()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Service()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Service()), - ]; - client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.metastore.v1beta.IService[] = []; - const iterable = client.listServicesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listMetadataImports without error using callback', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ListMetadataImportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ListMetadataImportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.MetadataImport(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.MetadataImport(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.MetadataImport(), + ), + ]; + client.innerApiCalls.listMetadataImports = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listMetadataImports( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.metastore.v1beta.IMetadataImport[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listServices.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listServices.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listServices with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ListServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listServicesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.metastore.v1beta.IService[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listServices.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listServices.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listMetadataImports as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMetadataImports as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listMetadataImports', () => { - it('invokes listMetadataImports without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ListMetadataImportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ListMetadataImportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1beta.MetadataImport()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.MetadataImport()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.MetadataImport()), - ]; - client.innerApiCalls.listMetadataImports = stubSimpleCall(expectedResponse); - const [response] = await client.listMetadataImports(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMetadataImports as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMetadataImports as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listMetadataImports with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ListMetadataImportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ListMetadataImportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listMetadataImports = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listMetadataImports(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listMetadataImports as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMetadataImports as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listMetadataImports without error using callback', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ListMetadataImportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ListMetadataImportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1beta.MetadataImport()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.MetadataImport()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.MetadataImport()), - ]; - client.innerApiCalls.listMetadataImports = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listMetadataImports( - request, - (err?: Error|null, result?: protos.google.cloud.metastore.v1beta.IMetadataImport[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMetadataImports as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMetadataImports as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listMetadataImportsStream without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ListMetadataImportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ListMetadataImportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.MetadataImport(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.MetadataImport(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.MetadataImport(), + ), + ]; + client.descriptors.page.listMetadataImports.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listMetadataImportsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.metastore.v1beta.MetadataImport[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.metastore.v1beta.MetadataImport) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listMetadataImports.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listMetadataImports, request), + ); + assert( + (client.descriptors.page.listMetadataImports.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listMetadataImports with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ListMetadataImportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ListMetadataImportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listMetadataImports = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listMetadataImports(request), expectedError); - const actualRequest = (client.innerApiCalls.listMetadataImports as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMetadataImports as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listMetadataImportsStream with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ListMetadataImportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ListMetadataImportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMetadataImports.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listMetadataImportsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.metastore.v1beta.MetadataImport[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.metastore.v1beta.MetadataImport) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listMetadataImports.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listMetadataImports, request), + ); + assert( + (client.descriptors.page.listMetadataImports.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listMetadataImportsStream without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ListMetadataImportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ListMetadataImportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1beta.MetadataImport()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.MetadataImport()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.MetadataImport()), - ]; - client.descriptors.page.listMetadataImports.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listMetadataImportsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.metastore.v1beta.MetadataImport[] = []; - stream.on('data', (response: protos.google.cloud.metastore.v1beta.MetadataImport) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listMetadataImports.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMetadataImports, request)); - assert( - (client.descriptors.page.listMetadataImports.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listMetadataImports without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ListMetadataImportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ListMetadataImportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.MetadataImport(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.MetadataImport(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.MetadataImport(), + ), + ]; + client.descriptors.page.listMetadataImports.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.metastore.v1beta.IMetadataImport[] = + []; + const iterable = client.listMetadataImportsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listMetadataImports.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listMetadataImports.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listMetadataImportsStream with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ListMetadataImportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ListMetadataImportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMetadataImports.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listMetadataImportsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.metastore.v1beta.MetadataImport[] = []; - stream.on('data', (response: protos.google.cloud.metastore.v1beta.MetadataImport) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listMetadataImports.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMetadataImports, request)); - assert( - (client.descriptors.page.listMetadataImports.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listMetadataImports with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ListMetadataImportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ListMetadataImportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMetadataImports.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listMetadataImportsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.metastore.v1beta.IMetadataImport[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listMetadataImports.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listMetadataImports.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listBackups', () => { + it('invokes listBackups without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Backup(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Backup(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Backup(), + ), + ]; + client.innerApiCalls.listBackups = stubSimpleCall(expectedResponse); + const [response] = await client.listBackups(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listMetadataImports without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ListMetadataImportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ListMetadataImportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1beta.MetadataImport()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.MetadataImport()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.MetadataImport()), - ]; - client.descriptors.page.listMetadataImports.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.metastore.v1beta.IMetadataImport[] = []; - const iterable = client.listMetadataImportsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listBackups without error using callback', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Backup(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Backup(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Backup(), + ), + ]; + client.innerApiCalls.listBackups = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listBackups( + request, + ( + err?: Error | null, + result?: protos.google.cloud.metastore.v1beta.IBackup[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listMetadataImports.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMetadataImports.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listMetadataImports with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ListMetadataImportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ListMetadataImportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMetadataImports.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listMetadataImportsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.metastore.v1beta.IMetadataImport[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listMetadataImports.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMetadataImports.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listBackups', () => { - it('invokes listBackups without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Backup()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Backup()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Backup()), - ]; - client.innerApiCalls.listBackups = stubSimpleCall(expectedResponse); - const [response] = await client.listBackups(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listBackups without error using callback', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Backup()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Backup()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Backup()), - ]; - client.innerApiCalls.listBackups = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listBackups( - request, - (err?: Error|null, result?: protos.google.cloud.metastore.v1beta.IBackup[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listBackups with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listBackups = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listBackups(request), expectedError); - const actualRequest = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listBackups with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listBackups = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listBackups(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listBackupsStream without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Backup()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Backup()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Backup()), - ]; - client.descriptors.page.listBackups.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listBackupsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.metastore.v1beta.Backup[] = []; - stream.on('data', (response: protos.google.cloud.metastore.v1beta.Backup) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listBackups.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listBackups, request)); - assert( - (client.descriptors.page.listBackups.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listBackupsStream without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Backup(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Backup(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Backup(), + ), + ]; + client.descriptors.page.listBackups.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listBackupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.metastore.v1beta.Backup[] = []; + stream.on( + 'data', + (response: protos.google.cloud.metastore.v1beta.Backup) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listBackups.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listBackups, request), + ); + assert( + (client.descriptors.page.listBackups.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listBackupsStream with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listBackups.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listBackupsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.metastore.v1beta.Backup[] = []; - stream.on('data', (response: protos.google.cloud.metastore.v1beta.Backup) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listBackups.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listBackups, request)); - assert( - (client.descriptors.page.listBackups.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listBackupsStream with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listBackups.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listBackupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.metastore.v1beta.Backup[] = []; + stream.on( + 'data', + (response: protos.google.cloud.metastore.v1beta.Backup) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listBackups.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listBackups, request), + ); + assert( + (client.descriptors.page.listBackups.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listBackups without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Backup()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Backup()), - generateSampleMessage(new protos.google.cloud.metastore.v1beta.Backup()), - ]; - client.descriptors.page.listBackups.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.metastore.v1beta.IBackup[] = []; - const iterable = client.listBackupsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listBackups.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listBackups.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listBackups without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Backup(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Backup(), + ), + generateSampleMessage( + new protos.google.cloud.metastore.v1beta.Backup(), + ), + ]; + client.descriptors.page.listBackups.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.metastore.v1beta.IBackup[] = []; + const iterable = client.listBackupsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listBackups.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listBackups.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listBackups with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.metastore.v1beta.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.metastore.v1beta.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listBackups.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listBackupsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.metastore.v1beta.IBackup[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listBackups.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listBackups.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listBackups with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.metastore.v1beta.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.metastore.v1beta.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listBackups.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listBackupsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.metastore.v1beta.IBackup[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listBackups.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listBackups.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy without error using callback', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes setIamPolicy with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes testIamPermissions with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('backup', async () => { + const fakePath = '/rendered/path/backup'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service: 'serviceValue', + backup: 'backupValue', + }; + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.backupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.backupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('backupPath', () => { + const result = client.backupPath( + 'projectValue', + 'locationValue', + 'serviceValue', + 'backupValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.backupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromBackupName', () => { + const result = client.matchProjectFromBackupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromBackupName', () => { + const result = client.matchLocationFromBackupName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceFromBackupName', () => { + const result = client.matchServiceFromBackupName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchBackupFromBackupName', () => { + const result = client.matchBackupFromBackupName(fakePath); + assert.strictEqual(result, 'backupValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('backup', async () => { - const fakePath = "/rendered/path/backup"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - backup: "backupValue", - }; - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.backupPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.backupPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('backupPath', () => { - const result = client.backupPath("projectValue", "locationValue", "serviceValue", "backupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.backupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBackupName', () => { - const result = client.matchProjectFromBackupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBackupName', () => { - const result = client.matchLocationFromBackupName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromBackupName', () => { - const result = client.matchServiceFromBackupName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBackupFromBackupName', () => { - const result = client.matchBackupFromBackupName(fakePath); - assert.strictEqual(result, "backupValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('federation', async () => { - const fakePath = "/rendered/path/federation"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - federation: "federationValue", - }; - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.federationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.federationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('federationPath', () => { - const result = client.federationPath("projectValue", "locationValue", "federationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.federationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromFederationName', () => { - const result = client.matchProjectFromFederationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.federationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromFederationName', () => { - const result = client.matchLocationFromFederationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.federationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchFederationFromFederationName', () => { - const result = client.matchFederationFromFederationName(fakePath); - assert.strictEqual(result, "federationValue"); - assert((client.pathTemplates.federationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('lake', async () => { - const fakePath = "/rendered/path/lake"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - lake: "lakeValue", - }; - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.lakePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.lakePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('lakePath', () => { - const result = client.lakePath("projectValue", "locationValue", "lakeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.lakePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLakeName', () => { - const result = client.matchProjectFromLakeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.lakePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLakeName', () => { - const result = client.matchLocationFromLakeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.lakePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLakeFromLakeName', () => { - const result = client.matchLakeFromLakeName(fakePath); - assert.strictEqual(result, "lakeValue"); - assert((client.pathTemplates.lakePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('metadataImport', async () => { - const fakePath = "/rendered/path/metadataImport"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - metadata_import: "metadataImportValue", - }; - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.metadataImportPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.metadataImportPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('metadataImportPath', () => { - const result = client.metadataImportPath("projectValue", "locationValue", "serviceValue", "metadataImportValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.metadataImportPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMetadataImportName', () => { - const result = client.matchProjectFromMetadataImportName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.metadataImportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMetadataImportName', () => { - const result = client.matchLocationFromMetadataImportName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.metadataImportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromMetadataImportName', () => { - const result = client.matchServiceFromMetadataImportName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.metadataImportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMetadataImportFromMetadataImportName', () => { - const result = client.matchMetadataImportFromMetadataImportName(fakePath); - assert.strictEqual(result, "metadataImportValue"); - assert((client.pathTemplates.metadataImportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('network', async () => { - const fakePath = "/rendered/path/network"; - const expectedParameters = { - project: "projectValue", - network: "networkValue", - }; - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.networkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.networkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('networkPath', () => { - const result = client.networkPath("projectValue", "networkValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.networkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromNetworkName', () => { - const result = client.matchProjectFromNetworkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.networkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchNetworkFromNetworkName', () => { - const result = client.matchNetworkFromNetworkName(fakePath); - assert.strictEqual(result, "networkValue"); - assert((client.pathTemplates.networkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('federation', async () => { + const fakePath = '/rendered/path/federation'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + federation: 'federationValue', + }; + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.federationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.federationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('federationPath', () => { + const result = client.federationPath( + 'projectValue', + 'locationValue', + 'federationValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.federationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromFederationName', () => { + const result = client.matchProjectFromFederationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.federationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromFederationName', () => { + const result = client.matchLocationFromFederationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.federationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchFederationFromFederationName', () => { + const result = client.matchFederationFromFederationName(fakePath); + assert.strictEqual(result, 'federationValue'); + assert( + (client.pathTemplates.federationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('lake', async () => { + const fakePath = '/rendered/path/lake'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + lake: 'lakeValue', + }; + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.lakePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.lakePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('lakePath', () => { + const result = client.lakePath( + 'projectValue', + 'locationValue', + 'lakeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.lakePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLakeName', () => { + const result = client.matchProjectFromLakeName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.lakePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLakeName', () => { + const result = client.matchLocationFromLakeName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.lakePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLakeFromLakeName', () => { + const result = client.matchLakeFromLakeName(fakePath); + assert.strictEqual(result, 'lakeValue'); + assert( + (client.pathTemplates.lakePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('service', async () => { - const fakePath = "/rendered/path/service"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - }; - const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.servicePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servicePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servicePath', () => { - const result = client.servicePath("projectValue", "locationValue", "serviceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servicePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('metadataImport', async () => { + const fakePath = '/rendered/path/metadataImport'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service: 'serviceValue', + metadata_import: 'metadataImportValue', + }; + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.metadataImportPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.metadataImportPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('metadataImportPath', () => { + const result = client.metadataImportPath( + 'projectValue', + 'locationValue', + 'serviceValue', + 'metadataImportValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.metadataImportPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMetadataImportName', () => { + const result = client.matchProjectFromMetadataImportName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.metadataImportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMetadataImportName', () => { + const result = client.matchLocationFromMetadataImportName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.metadataImportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceFromMetadataImportName', () => { + const result = client.matchServiceFromMetadataImportName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.metadataImportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMetadataImportFromMetadataImportName', () => { + const result = + client.matchMetadataImportFromMetadataImportName(fakePath); + assert.strictEqual(result, 'metadataImportValue'); + assert( + (client.pathTemplates.metadataImportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromServiceName', () => { - const result = client.matchProjectFromServiceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('network', async () => { + const fakePath = '/rendered/path/network'; + const expectedParameters = { + project: 'projectValue', + network: 'networkValue', + }; + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.networkPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.networkPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('networkPath', () => { + const result = client.networkPath('projectValue', 'networkValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.networkPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromNetworkName', () => { + const result = client.matchProjectFromNetworkName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.networkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchNetworkFromNetworkName', () => { + const result = client.matchNetworkFromNetworkName(fakePath); + assert.strictEqual(result, 'networkValue'); + assert( + (client.pathTemplates.networkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchLocationFromServiceName', () => { - const result = client.matchLocationFromServiceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.projectPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchServiceFromServiceName', () => { - const result = client.matchServiceFromServiceName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('service', async () => { + const fakePath = '/rendered/path/service'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service: 'serviceValue', + }; + const client = new dataprocmetastoreModule.v1beta.DataprocMetastoreClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.servicePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servicePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servicePath', () => { + const result = client.servicePath( + 'projectValue', + 'locationValue', + 'serviceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servicePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceName', () => { + const result = client.matchProjectFromServiceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromServiceName', () => { + const result = client.matchLocationFromServiceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceFromServiceName', () => { + const result = client.matchServiceFromServiceName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-metastore/webpack.config.js b/packages/google-cloud-metastore/webpack.config.js index 196fa97f3c2c..6fc45cb3d307 100644 --- a/packages/google-cloud-metastore/webpack.config.js +++ b/packages/google-cloud-metastore/webpack.config.js @@ -1,4 +1,4 @@ -// Copyright 2026 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-migrationcenter/.eslintignore b/packages/google-cloud-migrationcenter/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-migrationcenter/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-migrationcenter/.eslintrc.json b/packages/google-cloud-migrationcenter/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-migrationcenter/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-migrationcenter/README.md b/packages/google-cloud-migrationcenter/README.md index 963e5f1f6e6d..3ded2371eb77 100644 --- a/packages/google-cloud-migrationcenter/README.md +++ b/packages/google-cloud-migrationcenter/README.md @@ -140,7 +140,7 @@ More Information: [Google Cloud Platform Launch Stages][launch_stages] ## Contributing -Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-migrationcenter/CONTRIBUTING.md). +Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/CONTRIBUTING.md). Please note that this `README.md` and a variety of configuration files in this repository (including `.nycrc` and `tsconfig.json`) @@ -150,7 +150,7 @@ are generated from a central template. Apache Version 2.0 -See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-migrationcenter/LICENSE) +See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/LICENSE) [shell_img]: https://gstatic.com/cloudssh/images/open-btn.png [projects]: https://console.cloud.google.com/project diff --git a/packages/google-cloud-migrationcenter/protos/protos.d.ts b/packages/google-cloud-migrationcenter/protos/protos.d.ts index f9fdeec8a913..56ad2de5ecd4 100644 --- a/packages/google-cloud-migrationcenter/protos/protos.d.ts +++ b/packages/google-cloud-migrationcenter/protos/protos.d.ts @@ -21341,6 +21341,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -21358,6 +21361,9 @@ export namespace google { /** CommonLanguageSettings destinations. */ public destinations: google.api.ClientLibraryDestination[]; + /** CommonLanguageSettings selectiveGapicGeneration. */ + public selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); + /** * Creates a new CommonLanguageSettings instance using the specified properties. * @param [properties] Properties to set @@ -22058,6 +22064,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -22072,6 +22081,9 @@ export namespace google { /** PythonSettings common. */ public common?: (google.api.ICommonLanguageSettings|null); + /** PythonSettings experimentalFeatures. */ + public experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); + /** * Creates a new PythonSettings instance using the specified properties. * @param [properties] Properties to set @@ -22150,6 +22162,118 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + namespace PythonSettings { + + /** Properties of an ExperimentalFeatures. */ + interface IExperimentalFeatures { + + /** ExperimentalFeatures restAsyncIoEnabled */ + restAsyncIoEnabled?: (boolean|null); + + /** ExperimentalFeatures protobufPythonicTypesEnabled */ + protobufPythonicTypesEnabled?: (boolean|null); + + /** ExperimentalFeatures unversionedPackageDisabled */ + unversionedPackageDisabled?: (boolean|null); + } + + /** Represents an ExperimentalFeatures. */ + class ExperimentalFeatures implements IExperimentalFeatures { + + /** + * Constructs a new ExperimentalFeatures. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.PythonSettings.IExperimentalFeatures); + + /** ExperimentalFeatures restAsyncIoEnabled. */ + public restAsyncIoEnabled: boolean; + + /** ExperimentalFeatures protobufPythonicTypesEnabled. */ + public protobufPythonicTypesEnabled: boolean; + + /** ExperimentalFeatures unversionedPackageDisabled. */ + public unversionedPackageDisabled: boolean; + + /** + * Creates a new ExperimentalFeatures instance using the specified properties. + * @param [properties] Properties to set + * @returns ExperimentalFeatures instance + */ + public static create(properties?: google.api.PythonSettings.IExperimentalFeatures): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Encodes the specified ExperimentalFeatures message. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @param message ExperimentalFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.PythonSettings.IExperimentalFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExperimentalFeatures message, length delimited. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @param message ExperimentalFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.PythonSettings.IExperimentalFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExperimentalFeatures + * @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.api.PythonSettings.ExperimentalFeatures; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExperimentalFeatures + * @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.api.PythonSettings.ExperimentalFeatures; + + /** + * Verifies an ExperimentalFeatures 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 an ExperimentalFeatures message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExperimentalFeatures + */ + public static fromObject(object: { [k: string]: any }): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Creates a plain object from an ExperimentalFeatures message. Also converts values to other types if specified. + * @param message ExperimentalFeatures + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.PythonSettings.ExperimentalFeatures, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExperimentalFeatures to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExperimentalFeatures + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + /** Properties of a NodeSettings. */ interface INodeSettings { @@ -22476,6 +22600,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -22490,6 +22617,9 @@ export namespace google { /** GoSettings common. */ public common?: (google.api.ICommonLanguageSettings|null); + /** GoSettings renamedServices. */ + public renamedServices: { [k: string]: string }; + /** * Creates a new GoSettings instance using the specified properties. * @param [properties] Properties to set @@ -22814,6 +22944,109 @@ export namespace google { PACKAGE_MANAGER = 20 } + /** Properties of a SelectiveGapicGeneration. */ + interface ISelectiveGapicGeneration { + + /** SelectiveGapicGeneration methods */ + methods?: (string[]|null); + + /** SelectiveGapicGeneration generateOmittedAsInternal */ + generateOmittedAsInternal?: (boolean|null); + } + + /** Represents a SelectiveGapicGeneration. */ + class SelectiveGapicGeneration implements ISelectiveGapicGeneration { + + /** + * Constructs a new SelectiveGapicGeneration. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.ISelectiveGapicGeneration); + + /** SelectiveGapicGeneration methods. */ + public methods: string[]; + + /** SelectiveGapicGeneration generateOmittedAsInternal. */ + public generateOmittedAsInternal: boolean; + + /** + * Creates a new SelectiveGapicGeneration instance using the specified properties. + * @param [properties] Properties to set + * @returns SelectiveGapicGeneration instance + */ + public static create(properties?: google.api.ISelectiveGapicGeneration): google.api.SelectiveGapicGeneration; + + /** + * Encodes the specified SelectiveGapicGeneration message. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @param message SelectiveGapicGeneration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.ISelectiveGapicGeneration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SelectiveGapicGeneration message, length delimited. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @param message SelectiveGapicGeneration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.ISelectiveGapicGeneration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SelectiveGapicGeneration + * @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.api.SelectiveGapicGeneration; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SelectiveGapicGeneration + * @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.api.SelectiveGapicGeneration; + + /** + * Verifies a SelectiveGapicGeneration 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 SelectiveGapicGeneration message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SelectiveGapicGeneration + */ + public static fromObject(object: { [k: string]: any }): google.api.SelectiveGapicGeneration; + + /** + * Creates a plain object from a SelectiveGapicGeneration message. Also converts values to other types if specified. + * @param message SelectiveGapicGeneration + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.SelectiveGapicGeneration, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SelectiveGapicGeneration to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SelectiveGapicGeneration + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** LaunchStage enum. */ enum LaunchStage { LAUNCH_STAGE_UNSPECIFIED = 0, @@ -23195,6 +23428,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -23225,6 +23459,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -23274,6 +23511,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -23408,6 +23648,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -23449,6 +23692,9 @@ export namespace google { /** DescriptorProto reservedName. */ public reservedName: string[]; + /** DescriptorProto visibility. */ + public visibility: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility); + /** * Creates a new DescriptorProto instance using the specified properties. * @param [properties] Properties to set @@ -24296,6 +24542,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -24322,6 +24571,9 @@ export namespace google { /** EnumDescriptorProto reservedName. */ public reservedName: string[]; + /** EnumDescriptorProto visibility. */ + public visibility: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility); + /** * Creates a new EnumDescriptorProto instance using the specified properties. * @param [properties] Properties to set @@ -25256,6 +25508,9 @@ export namespace google { /** FieldOptions features */ features?: (google.protobuf.IFeatureSet|null); + /** FieldOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** FieldOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); @@ -25311,6 +25566,9 @@ export namespace google { /** FieldOptions features. */ public features?: (google.protobuf.IFeatureSet|null); + /** FieldOptions featureSupport. */ + public featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** FieldOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; @@ -25531,6 +25789,121 @@ export namespace google { */ public static getTypeUrl(typeUrlPrefix?: string): string; } + + /** Properties of a FeatureSupport. */ + interface IFeatureSupport { + + /** FeatureSupport editionIntroduced */ + editionIntroduced?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSupport editionDeprecated */ + editionDeprecated?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSupport deprecationWarning */ + deprecationWarning?: (string|null); + + /** FeatureSupport editionRemoved */ + editionRemoved?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + } + + /** Represents a FeatureSupport. */ + class FeatureSupport implements IFeatureSupport { + + /** + * Constructs a new FeatureSupport. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.FieldOptions.IFeatureSupport); + + /** FeatureSupport editionIntroduced. */ + public editionIntroduced: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSupport editionDeprecated. */ + public editionDeprecated: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSupport deprecationWarning. */ + public deprecationWarning: string; + + /** FeatureSupport editionRemoved. */ + public editionRemoved: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** + * Creates a new FeatureSupport instance using the specified properties. + * @param [properties] Properties to set + * @returns FeatureSupport instance + */ + public static create(properties?: google.protobuf.FieldOptions.IFeatureSupport): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Encodes the specified FeatureSupport message. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @param message FeatureSupport message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.FieldOptions.IFeatureSupport, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FeatureSupport message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @param message FeatureSupport message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.FieldOptions.IFeatureSupport, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FeatureSupport + * @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.protobuf.FieldOptions.FeatureSupport; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FeatureSupport + * @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.protobuf.FieldOptions.FeatureSupport; + + /** + * Verifies a FeatureSupport 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 FeatureSupport message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FeatureSupport + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Creates a plain object from a FeatureSupport message. Also converts values to other types if specified. + * @param message FeatureSupport + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldOptions.FeatureSupport, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FeatureSupport to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FeatureSupport + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } } /** Properties of an OneofOptions. */ @@ -25769,6 +26142,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -25791,6 +26167,9 @@ export namespace google { /** EnumValueOptions debugRedact. */ public debugRedact: boolean; + /** EnumValueOptions featureSupport. */ + public featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; @@ -26383,6 +26762,12 @@ export namespace google { /** FeatureSet jsonFormat */ jsonFormat?: (google.protobuf.FeatureSet.JsonFormat|keyof typeof google.protobuf.FeatureSet.JsonFormat|null); + + /** FeatureSet enforceNamingStyle */ + enforceNamingStyle?: (google.protobuf.FeatureSet.EnforceNamingStyle|keyof typeof google.protobuf.FeatureSet.EnforceNamingStyle|null); + + /** FeatureSet defaultSymbolVisibility */ + defaultSymbolVisibility?: (google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|keyof typeof google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|null); } /** Represents a FeatureSet. */ @@ -26412,6 +26797,12 @@ export namespace google { /** FeatureSet jsonFormat. */ public jsonFormat: (google.protobuf.FeatureSet.JsonFormat|keyof typeof google.protobuf.FeatureSet.JsonFormat); + /** FeatureSet enforceNamingStyle. */ + public enforceNamingStyle: (google.protobuf.FeatureSet.EnforceNamingStyle|keyof typeof google.protobuf.FeatureSet.EnforceNamingStyle); + + /** FeatureSet defaultSymbolVisibility. */ + public defaultSymbolVisibility: (google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|keyof typeof google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility); + /** * Creates a new FeatureSet instance using the specified properties. * @param [properties] Properties to set @@ -26534,6 +26925,116 @@ export namespace google { ALLOW = 1, LEGACY_BEST_EFFORT = 2 } + + /** EnforceNamingStyle enum. */ + enum EnforceNamingStyle { + ENFORCE_NAMING_STYLE_UNKNOWN = 0, + STYLE2024 = 1, + STYLE_LEGACY = 2 + } + + /** Properties of a VisibilityFeature. */ + interface IVisibilityFeature { + } + + /** Represents a VisibilityFeature. */ + class VisibilityFeature implements IVisibilityFeature { + + /** + * Constructs a new VisibilityFeature. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.FeatureSet.IVisibilityFeature); + + /** + * Creates a new VisibilityFeature instance using the specified properties. + * @param [properties] Properties to set + * @returns VisibilityFeature instance + */ + public static create(properties?: google.protobuf.FeatureSet.IVisibilityFeature): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Encodes the specified VisibilityFeature message. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @param message VisibilityFeature message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.FeatureSet.IVisibilityFeature, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified VisibilityFeature message, length delimited. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @param message VisibilityFeature message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.FeatureSet.IVisibilityFeature, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns VisibilityFeature + * @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.protobuf.FeatureSet.VisibilityFeature; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns VisibilityFeature + * @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.protobuf.FeatureSet.VisibilityFeature; + + /** + * Verifies a VisibilityFeature 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 VisibilityFeature message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns VisibilityFeature + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Creates a plain object from a VisibilityFeature message. Also converts values to other types if specified. + * @param message VisibilityFeature + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FeatureSet.VisibilityFeature, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this VisibilityFeature to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for VisibilityFeature + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace VisibilityFeature { + + /** DefaultSymbolVisibility enum. */ + enum DefaultSymbolVisibility { + DEFAULT_SYMBOL_VISIBILITY_UNKNOWN = 0, + EXPORT_ALL = 1, + EXPORT_TOP_LEVEL = 2, + LOCAL_ALL = 3, + STRICT = 4 + } + } } /** Properties of a FeatureSetDefaults. */ @@ -26653,8 +27154,11 @@ export namespace google { /** FeatureSetEditionDefault edition */ edition?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); - /** FeatureSetEditionDefault features */ - features?: (google.protobuf.IFeatureSet|null); + /** FeatureSetEditionDefault overridableFeatures */ + overridableFeatures?: (google.protobuf.IFeatureSet|null); + + /** FeatureSetEditionDefault fixedFeatures */ + fixedFeatures?: (google.protobuf.IFeatureSet|null); } /** Represents a FeatureSetEditionDefault. */ @@ -26669,8 +27173,11 @@ export namespace google { /** FeatureSetEditionDefault edition. */ public edition: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); - /** FeatureSetEditionDefault features. */ - public features?: (google.protobuf.IFeatureSet|null); + /** FeatureSetEditionDefault overridableFeatures. */ + public overridableFeatures?: (google.protobuf.IFeatureSet|null); + + /** FeatureSetEditionDefault fixedFeatures. */ + public fixedFeatures?: (google.protobuf.IFeatureSet|null); /** * Creates a new FeatureSetEditionDefault instance using the specified properties. @@ -27203,6 +27710,13 @@ export namespace google { } } + /** SymbolVisibility enum. */ + enum SymbolVisibility { + VISIBILITY_UNSET = 0, + VISIBILITY_LOCAL = 1, + VISIBILITY_EXPORT = 2 + } + /** Properties of a Duration. */ interface IDuration { diff --git a/packages/google-cloud-migrationcenter/protos/protos.js b/packages/google-cloud-migrationcenter/protos/protos.js index 813bae524be6..4d47988fd943 100644 --- a/packages/google-cloud-migrationcenter/protos/protos.js +++ b/packages/google-cloud-migrationcenter/protos/protos.js @@ -53034,6 +53034,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -53068,6 +53069,14 @@ */ CommonLanguageSettings.prototype.destinations = $util.emptyArray; + /** + * CommonLanguageSettings selectiveGapicGeneration. + * @member {google.api.ISelectiveGapicGeneration|null|undefined} selectiveGapicGeneration + * @memberof google.api.CommonLanguageSettings + * @instance + */ + CommonLanguageSettings.prototype.selectiveGapicGeneration = null; + /** * Creates a new CommonLanguageSettings instance using the specified properties. * @function create @@ -53100,6 +53109,8 @@ writer.int32(message.destinations[i]); writer.ldelim(); } + if (message.selectiveGapicGeneration != null && Object.hasOwnProperty.call(message, "selectiveGapicGeneration")) + $root.google.api.SelectiveGapicGeneration.encode(message.selectiveGapicGeneration, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); return writer; }; @@ -53151,6 +53162,10 @@ message.destinations.push(reader.int32()); break; } + case 3: { + message.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -53202,6 +53217,11 @@ break; } } + if (message.selectiveGapicGeneration != null && message.hasOwnProperty("selectiveGapicGeneration")) { + var error = $root.google.api.SelectiveGapicGeneration.verify(message.selectiveGapicGeneration); + if (error) + return "selectiveGapicGeneration." + error; + } return null; }; @@ -53244,6 +53264,11 @@ break; } } + if (object.selectiveGapicGeneration != null) { + if (typeof object.selectiveGapicGeneration !== "object") + throw TypeError(".google.api.CommonLanguageSettings.selectiveGapicGeneration: object expected"); + message.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.fromObject(object.selectiveGapicGeneration); + } return message; }; @@ -53262,8 +53287,10 @@ var object = {}; if (options.arrays || options.defaults) object.destinations = []; - if (options.defaults) + if (options.defaults) { object.referenceDocsUri = ""; + object.selectiveGapicGeneration = null; + } if (message.referenceDocsUri != null && message.hasOwnProperty("referenceDocsUri")) object.referenceDocsUri = message.referenceDocsUri; if (message.destinations && message.destinations.length) { @@ -53271,6 +53298,8 @@ for (var j = 0; j < message.destinations.length; ++j) object.destinations[j] = options.enums === String ? $root.google.api.ClientLibraryDestination[message.destinations[j]] === undefined ? message.destinations[j] : $root.google.api.ClientLibraryDestination[message.destinations[j]] : message.destinations[j]; } + if (message.selectiveGapicGeneration != null && message.hasOwnProperty("selectiveGapicGeneration")) + object.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.toObject(message.selectiveGapicGeneration, options); return object; }; @@ -55093,6 +55122,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -55118,6 +55148,14 @@ */ PythonSettings.prototype.common = null; + /** + * PythonSettings experimentalFeatures. + * @member {google.api.PythonSettings.IExperimentalFeatures|null|undefined} experimentalFeatures + * @memberof google.api.PythonSettings + * @instance + */ + PythonSettings.prototype.experimentalFeatures = null; + /** * Creates a new PythonSettings instance using the specified properties. * @function create @@ -55144,6 +55182,8 @@ writer = $Writer.create(); if (message.common != null && Object.hasOwnProperty.call(message, "common")) $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.experimentalFeatures != null && Object.hasOwnProperty.call(message, "experimentalFeatures")) + $root.google.api.PythonSettings.ExperimentalFeatures.encode(message.experimentalFeatures, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; @@ -55184,6 +55224,10 @@ message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); break; } + case 2: { + message.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -55224,6 +55268,11 @@ if (error) return "common." + error; } + if (message.experimentalFeatures != null && message.hasOwnProperty("experimentalFeatures")) { + var error = $root.google.api.PythonSettings.ExperimentalFeatures.verify(message.experimentalFeatures); + if (error) + return "experimentalFeatures." + error; + } return null; }; @@ -55244,6 +55293,11 @@ throw TypeError(".google.api.PythonSettings.common: object expected"); message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); } + if (object.experimentalFeatures != null) { + if (typeof object.experimentalFeatures !== "object") + throw TypeError(".google.api.PythonSettings.experimentalFeatures: object expected"); + message.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.fromObject(object.experimentalFeatures); + } return message; }; @@ -55260,10 +55314,14 @@ if (!options) options = {}; var object = {}; - if (options.defaults) + if (options.defaults) { object.common = null; + object.experimentalFeatures = null; + } if (message.common != null && message.hasOwnProperty("common")) object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + if (message.experimentalFeatures != null && message.hasOwnProperty("experimentalFeatures")) + object.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.toObject(message.experimentalFeatures, options); return object; }; @@ -55293,6 +55351,258 @@ return typeUrlPrefix + "/google.api.PythonSettings"; }; + PythonSettings.ExperimentalFeatures = (function() { + + /** + * Properties of an ExperimentalFeatures. + * @memberof google.api.PythonSettings + * @interface IExperimentalFeatures + * @property {boolean|null} [restAsyncIoEnabled] ExperimentalFeatures restAsyncIoEnabled + * @property {boolean|null} [protobufPythonicTypesEnabled] ExperimentalFeatures protobufPythonicTypesEnabled + * @property {boolean|null} [unversionedPackageDisabled] ExperimentalFeatures unversionedPackageDisabled + */ + + /** + * Constructs a new ExperimentalFeatures. + * @memberof google.api.PythonSettings + * @classdesc Represents an ExperimentalFeatures. + * @implements IExperimentalFeatures + * @constructor + * @param {google.api.PythonSettings.IExperimentalFeatures=} [properties] Properties to set + */ + function ExperimentalFeatures(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]]; + } + + /** + * ExperimentalFeatures restAsyncIoEnabled. + * @member {boolean} restAsyncIoEnabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.restAsyncIoEnabled = false; + + /** + * ExperimentalFeatures protobufPythonicTypesEnabled. + * @member {boolean} protobufPythonicTypesEnabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.protobufPythonicTypesEnabled = false; + + /** + * ExperimentalFeatures unversionedPackageDisabled. + * @member {boolean} unversionedPackageDisabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.unversionedPackageDisabled = false; + + /** + * Creates a new ExperimentalFeatures instance using the specified properties. + * @function create + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures=} [properties] Properties to set + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures instance + */ + ExperimentalFeatures.create = function create(properties) { + return new ExperimentalFeatures(properties); + }; + + /** + * Encodes the specified ExperimentalFeatures message. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @function encode + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures} message ExperimentalFeatures message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExperimentalFeatures.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.restAsyncIoEnabled != null && Object.hasOwnProperty.call(message, "restAsyncIoEnabled")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.restAsyncIoEnabled); + if (message.protobufPythonicTypesEnabled != null && Object.hasOwnProperty.call(message, "protobufPythonicTypesEnabled")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.protobufPythonicTypesEnabled); + if (message.unversionedPackageDisabled != null && Object.hasOwnProperty.call(message, "unversionedPackageDisabled")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.unversionedPackageDisabled); + return writer; + }; + + /** + * Encodes the specified ExperimentalFeatures message, length delimited. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures} message ExperimentalFeatures message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExperimentalFeatures.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer. + * @function decode + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExperimentalFeatures.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.PythonSettings.ExperimentalFeatures(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.restAsyncIoEnabled = reader.bool(); + break; + } + case 2: { + message.protobufPythonicTypesEnabled = reader.bool(); + break; + } + case 3: { + message.unversionedPackageDisabled = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExperimentalFeatures.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExperimentalFeatures message. + * @function verify + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExperimentalFeatures.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.restAsyncIoEnabled != null && message.hasOwnProperty("restAsyncIoEnabled")) + if (typeof message.restAsyncIoEnabled !== "boolean") + return "restAsyncIoEnabled: boolean expected"; + if (message.protobufPythonicTypesEnabled != null && message.hasOwnProperty("protobufPythonicTypesEnabled")) + if (typeof message.protobufPythonicTypesEnabled !== "boolean") + return "protobufPythonicTypesEnabled: boolean expected"; + if (message.unversionedPackageDisabled != null && message.hasOwnProperty("unversionedPackageDisabled")) + if (typeof message.unversionedPackageDisabled !== "boolean") + return "unversionedPackageDisabled: boolean expected"; + return null; + }; + + /** + * Creates an ExperimentalFeatures message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {Object.} object Plain object + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + */ + ExperimentalFeatures.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.PythonSettings.ExperimentalFeatures) + return object; + var message = new $root.google.api.PythonSettings.ExperimentalFeatures(); + if (object.restAsyncIoEnabled != null) + message.restAsyncIoEnabled = Boolean(object.restAsyncIoEnabled); + if (object.protobufPythonicTypesEnabled != null) + message.protobufPythonicTypesEnabled = Boolean(object.protobufPythonicTypesEnabled); + if (object.unversionedPackageDisabled != null) + message.unversionedPackageDisabled = Boolean(object.unversionedPackageDisabled); + return message; + }; + + /** + * Creates a plain object from an ExperimentalFeatures message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.ExperimentalFeatures} message ExperimentalFeatures + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExperimentalFeatures.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.restAsyncIoEnabled = false; + object.protobufPythonicTypesEnabled = false; + object.unversionedPackageDisabled = false; + } + if (message.restAsyncIoEnabled != null && message.hasOwnProperty("restAsyncIoEnabled")) + object.restAsyncIoEnabled = message.restAsyncIoEnabled; + if (message.protobufPythonicTypesEnabled != null && message.hasOwnProperty("protobufPythonicTypesEnabled")) + object.protobufPythonicTypesEnabled = message.protobufPythonicTypesEnabled; + if (message.unversionedPackageDisabled != null && message.hasOwnProperty("unversionedPackageDisabled")) + object.unversionedPackageDisabled = message.unversionedPackageDisabled; + return object; + }; + + /** + * Converts this ExperimentalFeatures to JSON. + * @function toJSON + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + * @returns {Object.} JSON object + */ + ExperimentalFeatures.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExperimentalFeatures + * @function getTypeUrl + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExperimentalFeatures.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.PythonSettings.ExperimentalFeatures"; + }; + + return ExperimentalFeatures; + })(); + return PythonSettings; })(); @@ -56169,6 +56479,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -56180,6 +56491,7 @@ * @param {google.api.IGoSettings=} [properties] Properties to set */ function GoSettings(properties) { + this.renamedServices = {}; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -56194,6 +56506,14 @@ */ GoSettings.prototype.common = null; + /** + * GoSettings renamedServices. + * @member {Object.} renamedServices + * @memberof google.api.GoSettings + * @instance + */ + GoSettings.prototype.renamedServices = $util.emptyObject; + /** * Creates a new GoSettings instance using the specified properties. * @function create @@ -56220,6 +56540,9 @@ writer = $Writer.create(); if (message.common != null && Object.hasOwnProperty.call(message, "common")) $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.renamedServices != null && Object.hasOwnProperty.call(message, "renamedServices")) + for (var keys = Object.keys(message.renamedServices), i = 0; i < keys.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.renamedServices[keys[i]]).ldelim(); return writer; }; @@ -56250,7 +56573,7 @@ GoSettings.decode = function decode(reader, length, error) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.GoSettings(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.GoSettings(), key, value; while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) @@ -56260,6 +56583,29 @@ message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); break; } + case 2: { + if (message.renamedServices === $util.emptyObject) + message.renamedServices = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = ""; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = reader.string(); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.renamedServices[key] = value; + break; + } default: reader.skipType(tag & 7); break; @@ -56300,6 +56646,14 @@ if (error) return "common." + error; } + if (message.renamedServices != null && message.hasOwnProperty("renamedServices")) { + if (!$util.isObject(message.renamedServices)) + return "renamedServices: object expected"; + var key = Object.keys(message.renamedServices); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.renamedServices[key[i]])) + return "renamedServices: string{k:string} expected"; + } return null; }; @@ -56320,6 +56674,13 @@ throw TypeError(".google.api.GoSettings.common: object expected"); message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); } + if (object.renamedServices) { + if (typeof object.renamedServices !== "object") + throw TypeError(".google.api.GoSettings.renamedServices: object expected"); + message.renamedServices = {}; + for (var keys = Object.keys(object.renamedServices), i = 0; i < keys.length; ++i) + message.renamedServices[keys[i]] = String(object.renamedServices[keys[i]]); + } return message; }; @@ -56336,10 +56697,18 @@ if (!options) options = {}; var object = {}; + if (options.objects || options.defaults) + object.renamedServices = {}; if (options.defaults) object.common = null; if (message.common != null && message.hasOwnProperty("common")) object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + var keys2; + if (message.renamedServices && (keys2 = Object.keys(message.renamedServices)).length) { + object.renamedServices = {}; + for (var j = 0; j < keys2.length; ++j) + object.renamedServices[keys2[j]] = message.renamedServices[keys2[j]]; + } return object; }; @@ -56978,29 +57347,274 @@ return values; })(); - /** - * LaunchStage enum. - * @name google.api.LaunchStage - * @enum {number} - * @property {number} LAUNCH_STAGE_UNSPECIFIED=0 LAUNCH_STAGE_UNSPECIFIED value - * @property {number} UNIMPLEMENTED=6 UNIMPLEMENTED value - * @property {number} PRELAUNCH=7 PRELAUNCH value - * @property {number} EARLY_ACCESS=1 EARLY_ACCESS value - * @property {number} ALPHA=2 ALPHA value - * @property {number} BETA=3 BETA value - * @property {number} GA=4 GA value - * @property {number} DEPRECATED=5 DEPRECATED value - */ - api.LaunchStage = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "LAUNCH_STAGE_UNSPECIFIED"] = 0; - values[valuesById[6] = "UNIMPLEMENTED"] = 6; - values[valuesById[7] = "PRELAUNCH"] = 7; - values[valuesById[1] = "EARLY_ACCESS"] = 1; - values[valuesById[2] = "ALPHA"] = 2; - values[valuesById[3] = "BETA"] = 3; - values[valuesById[4] = "GA"] = 4; - values[valuesById[5] = "DEPRECATED"] = 5; + api.SelectiveGapicGeneration = (function() { + + /** + * Properties of a SelectiveGapicGeneration. + * @memberof google.api + * @interface ISelectiveGapicGeneration + * @property {Array.|null} [methods] SelectiveGapicGeneration methods + * @property {boolean|null} [generateOmittedAsInternal] SelectiveGapicGeneration generateOmittedAsInternal + */ + + /** + * Constructs a new SelectiveGapicGeneration. + * @memberof google.api + * @classdesc Represents a SelectiveGapicGeneration. + * @implements ISelectiveGapicGeneration + * @constructor + * @param {google.api.ISelectiveGapicGeneration=} [properties] Properties to set + */ + function SelectiveGapicGeneration(properties) { + this.methods = []; + 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]]; + } + + /** + * SelectiveGapicGeneration methods. + * @member {Array.} methods + * @memberof google.api.SelectiveGapicGeneration + * @instance + */ + SelectiveGapicGeneration.prototype.methods = $util.emptyArray; + + /** + * SelectiveGapicGeneration generateOmittedAsInternal. + * @member {boolean} generateOmittedAsInternal + * @memberof google.api.SelectiveGapicGeneration + * @instance + */ + SelectiveGapicGeneration.prototype.generateOmittedAsInternal = false; + + /** + * Creates a new SelectiveGapicGeneration instance using the specified properties. + * @function create + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration=} [properties] Properties to set + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration instance + */ + SelectiveGapicGeneration.create = function create(properties) { + return new SelectiveGapicGeneration(properties); + }; + + /** + * Encodes the specified SelectiveGapicGeneration message. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @function encode + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration} message SelectiveGapicGeneration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SelectiveGapicGeneration.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.methods != null && message.methods.length) + for (var i = 0; i < message.methods.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.methods[i]); + if (message.generateOmittedAsInternal != null && Object.hasOwnProperty.call(message, "generateOmittedAsInternal")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.generateOmittedAsInternal); + return writer; + }; + + /** + * Encodes the specified SelectiveGapicGeneration message, length delimited. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration} message SelectiveGapicGeneration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SelectiveGapicGeneration.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer. + * @function decode + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SelectiveGapicGeneration.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.SelectiveGapicGeneration(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + if (!(message.methods && message.methods.length)) + message.methods = []; + message.methods.push(reader.string()); + break; + } + case 2: { + message.generateOmittedAsInternal = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SelectiveGapicGeneration.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SelectiveGapicGeneration message. + * @function verify + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SelectiveGapicGeneration.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.methods != null && message.hasOwnProperty("methods")) { + if (!Array.isArray(message.methods)) + return "methods: array expected"; + for (var i = 0; i < message.methods.length; ++i) + if (!$util.isString(message.methods[i])) + return "methods: string[] expected"; + } + if (message.generateOmittedAsInternal != null && message.hasOwnProperty("generateOmittedAsInternal")) + if (typeof message.generateOmittedAsInternal !== "boolean") + return "generateOmittedAsInternal: boolean expected"; + return null; + }; + + /** + * Creates a SelectiveGapicGeneration message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {Object.} object Plain object + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + */ + SelectiveGapicGeneration.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.SelectiveGapicGeneration) + return object; + var message = new $root.google.api.SelectiveGapicGeneration(); + if (object.methods) { + if (!Array.isArray(object.methods)) + throw TypeError(".google.api.SelectiveGapicGeneration.methods: array expected"); + message.methods = []; + for (var i = 0; i < object.methods.length; ++i) + message.methods[i] = String(object.methods[i]); + } + if (object.generateOmittedAsInternal != null) + message.generateOmittedAsInternal = Boolean(object.generateOmittedAsInternal); + return message; + }; + + /** + * Creates a plain object from a SelectiveGapicGeneration message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.SelectiveGapicGeneration} message SelectiveGapicGeneration + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SelectiveGapicGeneration.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.methods = []; + if (options.defaults) + object.generateOmittedAsInternal = false; + if (message.methods && message.methods.length) { + object.methods = []; + for (var j = 0; j < message.methods.length; ++j) + object.methods[j] = message.methods[j]; + } + if (message.generateOmittedAsInternal != null && message.hasOwnProperty("generateOmittedAsInternal")) + object.generateOmittedAsInternal = message.generateOmittedAsInternal; + return object; + }; + + /** + * Converts this SelectiveGapicGeneration to JSON. + * @function toJSON + * @memberof google.api.SelectiveGapicGeneration + * @instance + * @returns {Object.} JSON object + */ + SelectiveGapicGeneration.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SelectiveGapicGeneration + * @function getTypeUrl + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SelectiveGapicGeneration.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.SelectiveGapicGeneration"; + }; + + return SelectiveGapicGeneration; + })(); + + /** + * LaunchStage enum. + * @name google.api.LaunchStage + * @enum {number} + * @property {number} LAUNCH_STAGE_UNSPECIFIED=0 LAUNCH_STAGE_UNSPECIFIED value + * @property {number} UNIMPLEMENTED=6 UNIMPLEMENTED value + * @property {number} PRELAUNCH=7 PRELAUNCH value + * @property {number} EARLY_ACCESS=1 EARLY_ACCESS value + * @property {number} ALPHA=2 ALPHA value + * @property {number} BETA=3 BETA value + * @property {number} GA=4 GA value + * @property {number} DEPRECATED=5 DEPRECATED value + */ + api.LaunchStage = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "LAUNCH_STAGE_UNSPECIFIED"] = 0; + values[valuesById[6] = "UNIMPLEMENTED"] = 6; + values[valuesById[7] = "PRELAUNCH"] = 7; + values[valuesById[1] = "EARLY_ACCESS"] = 1; + values[valuesById[2] = "ALPHA"] = 2; + values[valuesById[3] = "BETA"] = 3; + values[valuesById[4] = "GA"] = 4; + values[valuesById[5] = "DEPRECATED"] = 5; return values; })(); @@ -57963,6 +58577,7 @@ * @name google.protobuf.Edition * @enum {number} * @property {number} EDITION_UNKNOWN=0 EDITION_UNKNOWN value + * @property {number} EDITION_LEGACY=900 EDITION_LEGACY value * @property {number} EDITION_PROTO2=998 EDITION_PROTO2 value * @property {number} EDITION_PROTO3=999 EDITION_PROTO3 value * @property {number} EDITION_2023=1000 EDITION_2023 value @@ -57977,6 +58592,7 @@ protobuf.Edition = (function() { var valuesById = {}, values = Object.create(valuesById); values[valuesById[0] = "EDITION_UNKNOWN"] = 0; + values[valuesById[900] = "EDITION_LEGACY"] = 900; values[valuesById[998] = "EDITION_PROTO2"] = 998; values[valuesById[999] = "EDITION_PROTO3"] = 999; values[valuesById[1000] = "EDITION_2023"] = 1000; @@ -58001,6 +58617,7 @@ * @property {Array.|null} [dependency] FileDescriptorProto dependency * @property {Array.|null} [publicDependency] FileDescriptorProto publicDependency * @property {Array.|null} [weakDependency] FileDescriptorProto weakDependency + * @property {Array.|null} [optionDependency] FileDescriptorProto optionDependency * @property {Array.|null} [messageType] FileDescriptorProto messageType * @property {Array.|null} [enumType] FileDescriptorProto enumType * @property {Array.|null} [service] FileDescriptorProto service @@ -58023,6 +58640,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -58073,6 +58691,14 @@ */ FileDescriptorProto.prototype.weakDependency = $util.emptyArray; + /** + * FileDescriptorProto optionDependency. + * @member {Array.} optionDependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.optionDependency = $util.emptyArray; + /** * FileDescriptorProto messageType. * @member {Array.} messageType @@ -58194,6 +58820,9 @@ writer.uint32(/* id 12, wireType 2 =*/98).string(message.syntax); if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) writer.uint32(/* id 14, wireType 0 =*/112).int32(message.edition); + if (message.optionDependency != null && message.optionDependency.length) + for (var i = 0; i < message.optionDependency.length; ++i) + writer.uint32(/* id 15, wireType 2 =*/122).string(message.optionDependency[i]); return writer; }; @@ -58266,6 +58895,12 @@ message.weakDependency.push(reader.int32()); break; } + case 15: { + if (!(message.optionDependency && message.optionDependency.length)) + message.optionDependency = []; + message.optionDependency.push(reader.string()); + break; + } case 4: { if (!(message.messageType && message.messageType.length)) message.messageType = []; @@ -58368,6 +59003,13 @@ if (!$util.isInteger(message.weakDependency[i])) return "weakDependency: integer[] expected"; } + if (message.optionDependency != null && message.hasOwnProperty("optionDependency")) { + if (!Array.isArray(message.optionDependency)) + return "optionDependency: array expected"; + for (var i = 0; i < message.optionDependency.length; ++i) + if (!$util.isString(message.optionDependency[i])) + return "optionDependency: string[] expected"; + } if (message.messageType != null && message.hasOwnProperty("messageType")) { if (!Array.isArray(message.messageType)) return "messageType: array expected"; @@ -58422,6 +59064,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -58474,6 +59117,13 @@ for (var i = 0; i < object.weakDependency.length; ++i) message.weakDependency[i] = object.weakDependency[i] | 0; } + if (object.optionDependency) { + if (!Array.isArray(object.optionDependency)) + throw TypeError(".google.protobuf.FileDescriptorProto.optionDependency: array expected"); + message.optionDependency = []; + for (var i = 0; i < object.optionDependency.length; ++i) + message.optionDependency[i] = String(object.optionDependency[i]); + } if (object.messageType) { if (!Array.isArray(object.messageType)) throw TypeError(".google.protobuf.FileDescriptorProto.messageType: array expected"); @@ -58537,6 +59187,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -58602,6 +59256,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -58658,6 +59313,11 @@ object.syntax = message.syntax; if (message.edition != null && message.hasOwnProperty("edition")) object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.optionDependency && message.optionDependency.length) { + object.optionDependency = []; + for (var j = 0; j < message.optionDependency.length; ++j) + object.optionDependency[j] = message.optionDependency[j]; + } return object; }; @@ -58706,6 +59366,7 @@ * @property {google.protobuf.IMessageOptions|null} [options] DescriptorProto options * @property {Array.|null} [reservedRange] DescriptorProto reservedRange * @property {Array.|null} [reservedName] DescriptorProto reservedName + * @property {google.protobuf.SymbolVisibility|null} [visibility] DescriptorProto visibility */ /** @@ -58811,6 +59472,14 @@ */ DescriptorProto.prototype.reservedName = $util.emptyArray; + /** + * DescriptorProto visibility. + * @member {google.protobuf.SymbolVisibility} visibility + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.visibility = 0; + /** * Creates a new DescriptorProto instance using the specified properties. * @function create @@ -58863,6 +59532,8 @@ if (message.reservedName != null && message.reservedName.length) for (var i = 0; i < message.reservedName.length; ++i) writer.uint32(/* id 10, wireType 2 =*/82).string(message.reservedName[i]); + if (message.visibility != null && Object.hasOwnProperty.call(message, "visibility")) + writer.uint32(/* id 11, wireType 0 =*/88).int32(message.visibility); return writer; }; @@ -58955,6 +59626,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -59068,6 +59743,15 @@ if (!$util.isString(message.reservedName[i])) return "reservedName: string[] expected"; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + switch (message.visibility) { + default: + return "visibility: enum value expected"; + case 0: + case 1: + case 2: + break; + } return null; }; @@ -59167,6 +59851,26 @@ for (var i = 0; i < object.reservedName.length; ++i) message.reservedName[i] = String(object.reservedName[i]); } + switch (object.visibility) { + default: + if (typeof object.visibility === "number") { + message.visibility = object.visibility; + break; + } + break; + case "VISIBILITY_UNSET": + case 0: + message.visibility = 0; + break; + case "VISIBILITY_LOCAL": + case 1: + message.visibility = 1; + break; + case "VISIBILITY_EXPORT": + case 2: + message.visibility = 2; + break; + } return message; }; @@ -59196,6 +59900,7 @@ if (options.defaults) { object.name = ""; object.options = null; + object.visibility = options.enums === String ? "VISIBILITY_UNSET" : 0; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -59241,6 +59946,8 @@ for (var j = 0; j < message.reservedName.length; ++j) object.reservedName[j] = message.reservedName[j]; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + object.visibility = options.enums === String ? $root.google.protobuf.SymbolVisibility[message.visibility] === undefined ? message.visibility : $root.google.protobuf.SymbolVisibility[message.visibility] : message.visibility; return object; }; @@ -61285,6 +61992,7 @@ * @property {google.protobuf.IEnumOptions|null} [options] EnumDescriptorProto options * @property {Array.|null} [reservedRange] EnumDescriptorProto reservedRange * @property {Array.|null} [reservedName] EnumDescriptorProto reservedName + * @property {google.protobuf.SymbolVisibility|null} [visibility] EnumDescriptorProto visibility */ /** @@ -61345,6 +62053,14 @@ */ EnumDescriptorProto.prototype.reservedName = $util.emptyArray; + /** + * EnumDescriptorProto visibility. + * @member {google.protobuf.SymbolVisibility} visibility + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.visibility = 0; + /** * Creates a new EnumDescriptorProto instance using the specified properties. * @function create @@ -61382,6 +62098,8 @@ if (message.reservedName != null && message.reservedName.length) for (var i = 0; i < message.reservedName.length; ++i) writer.uint32(/* id 5, wireType 2 =*/42).string(message.reservedName[i]); + if (message.visibility != null && Object.hasOwnProperty.call(message, "visibility")) + writer.uint32(/* id 6, wireType 0 =*/48).int32(message.visibility); return writer; }; @@ -61444,6 +62162,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -61512,6 +62234,15 @@ if (!$util.isString(message.reservedName[i])) return "reservedName: string[] expected"; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + switch (message.visibility) { + default: + return "visibility: enum value expected"; + case 0: + case 1: + case 2: + break; + } return null; }; @@ -61561,6 +62292,26 @@ for (var i = 0; i < object.reservedName.length; ++i) message.reservedName[i] = String(object.reservedName[i]); } + switch (object.visibility) { + default: + if (typeof object.visibility === "number") { + message.visibility = object.visibility; + break; + } + break; + case "VISIBILITY_UNSET": + case 0: + message.visibility = 0; + break; + case "VISIBILITY_LOCAL": + case 1: + message.visibility = 1; + break; + case "VISIBILITY_EXPORT": + case 2: + message.visibility = 2; + break; + } return message; }; @@ -61585,6 +62336,7 @@ if (options.defaults) { object.name = ""; object.options = null; + object.visibility = options.enums === String ? "VISIBILITY_UNSET" : 0; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -61605,6 +62357,8 @@ for (var j = 0; j < message.reservedName.length; ++j) object.reservedName[j] = message.reservedName[j]; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + object.visibility = options.enums === String ? $root.google.protobuf.SymbolVisibility[message.visibility] === undefined ? message.visibility : $root.google.protobuf.SymbolVisibility[message.visibility] : message.visibility; return object; }; @@ -63923,6 +64677,7 @@ * @property {Array.|null} [targets] FieldOptions targets * @property {Array.|null} [editionDefaults] FieldOptions editionDefaults * @property {google.protobuf.IFeatureSet|null} [features] FieldOptions features + * @property {google.protobuf.FieldOptions.IFeatureSupport|null} [featureSupport] FieldOptions featureSupport * @property {Array.|null} [uninterpretedOption] FieldOptions uninterpretedOption * @property {Array.|null} [".google.api.fieldBehavior"] FieldOptions .google.api.fieldBehavior * @property {google.api.IResourceReference|null} [".google.api.resourceReference"] FieldOptions .google.api.resourceReference @@ -64043,6 +64798,14 @@ */ FieldOptions.prototype.features = null; + /** + * FieldOptions featureSupport. + * @member {google.protobuf.FieldOptions.IFeatureSupport|null|undefined} featureSupport + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.featureSupport = null; + /** * FieldOptions uninterpretedOption. * @member {Array.} uninterpretedOption @@ -64117,6 +64880,8 @@ $root.google.protobuf.FieldOptions.EditionDefault.encode(message.editionDefaults[i], writer.uint32(/* id 20, wireType 2 =*/162).fork()).ldelim(); if (message.features != null && Object.hasOwnProperty.call(message, "features")) $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 21, wireType 2 =*/170).fork()).ldelim(); + if (message.featureSupport != null && Object.hasOwnProperty.call(message, "featureSupport")) + $root.google.protobuf.FieldOptions.FeatureSupport.encode(message.featureSupport, writer.uint32(/* id 22, wireType 2 =*/178).fork()).ldelim(); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); @@ -64218,6 +64983,10 @@ message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); break; } + case 22: { + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.decode(reader, reader.uint32()); + break; + } case 999: { if (!(message.uninterpretedOption && message.uninterpretedOption.length)) message.uninterpretedOption = []; @@ -64353,6 +65122,11 @@ if (error) return "features." + error; } + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) { + var error = $root.google.protobuf.FieldOptions.FeatureSupport.verify(message.featureSupport); + if (error) + return "featureSupport." + error; + } if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { if (!Array.isArray(message.uninterpretedOption)) return "uninterpretedOption: array expected"; @@ -64541,6 +65315,11 @@ throw TypeError(".google.protobuf.FieldOptions.features: object expected"); message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); } + if (object.featureSupport != null) { + if (typeof object.featureSupport !== "object") + throw TypeError(".google.protobuf.FieldOptions.featureSupport: object expected"); + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.fromObject(object.featureSupport); + } if (object.uninterpretedOption) { if (!Array.isArray(object.uninterpretedOption)) throw TypeError(".google.protobuf.FieldOptions.uninterpretedOption: array expected"); @@ -64638,6 +65417,7 @@ object.debugRedact = false; object.retention = options.enums === String ? "RETENTION_UNKNOWN" : 0; object.features = null; + object.featureSupport = null; object[".google.api.resourceReference"] = null; } if (message.ctype != null && message.hasOwnProperty("ctype")) @@ -64670,6 +65450,8 @@ } if (message.features != null && message.hasOwnProperty("features")) object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) + object.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.toObject(message.featureSupport, options); if (message.uninterpretedOption && message.uninterpretedOption.length) { object.uninterpretedOption = []; for (var j = 0; j < message.uninterpretedOption.length; ++j) @@ -64942,6 +65724,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -64983,103 +65766,589 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; + case "EDITION_PROTO2": + case 998: + message.edition = 998; + break; + case "EDITION_PROTO3": + case 999: + message.edition = 999; + break; + case "EDITION_2023": + case 1000: + message.edition = 1000; + break; + case "EDITION_2024": + case 1001: + message.edition = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.edition = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.edition = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.edition = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.edition = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.edition = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.edition = 2147483647; + break; + } + if (object.value != null) + message.value = String(object.value); + return message; + }; + + /** + * Creates a plain object from an EditionDefault message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {google.protobuf.FieldOptions.EditionDefault} message EditionDefault + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EditionDefault.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.value = ""; + object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + } + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + if (message.edition != null && message.hasOwnProperty("edition")) + object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + return object; + }; + + /** + * Converts this EditionDefault to JSON. + * @function toJSON + * @memberof google.protobuf.FieldOptions.EditionDefault + * @instance + * @returns {Object.} JSON object + */ + EditionDefault.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for EditionDefault + * @function getTypeUrl + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + EditionDefault.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FieldOptions.EditionDefault"; + }; + + return EditionDefault; + })(); + + FieldOptions.FeatureSupport = (function() { + + /** + * Properties of a FeatureSupport. + * @memberof google.protobuf.FieldOptions + * @interface IFeatureSupport + * @property {google.protobuf.Edition|null} [editionIntroduced] FeatureSupport editionIntroduced + * @property {google.protobuf.Edition|null} [editionDeprecated] FeatureSupport editionDeprecated + * @property {string|null} [deprecationWarning] FeatureSupport deprecationWarning + * @property {google.protobuf.Edition|null} [editionRemoved] FeatureSupport editionRemoved + */ + + /** + * Constructs a new FeatureSupport. + * @memberof google.protobuf.FieldOptions + * @classdesc Represents a FeatureSupport. + * @implements IFeatureSupport + * @constructor + * @param {google.protobuf.FieldOptions.IFeatureSupport=} [properties] Properties to set + */ + function FeatureSupport(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]]; + } + + /** + * FeatureSupport editionIntroduced. + * @member {google.protobuf.Edition} editionIntroduced + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionIntroduced = 0; + + /** + * FeatureSupport editionDeprecated. + * @member {google.protobuf.Edition} editionDeprecated + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionDeprecated = 0; + + /** + * FeatureSupport deprecationWarning. + * @member {string} deprecationWarning + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.deprecationWarning = ""; + + /** + * FeatureSupport editionRemoved. + * @member {google.protobuf.Edition} editionRemoved + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionRemoved = 0; + + /** + * Creates a new FeatureSupport instance using the specified properties. + * @function create + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport=} [properties] Properties to set + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport instance + */ + FeatureSupport.create = function create(properties) { + return new FeatureSupport(properties); + }; + + /** + * Encodes the specified FeatureSupport message. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport} message FeatureSupport message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSupport.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.editionIntroduced != null && Object.hasOwnProperty.call(message, "editionIntroduced")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.editionIntroduced); + if (message.editionDeprecated != null && Object.hasOwnProperty.call(message, "editionDeprecated")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.editionDeprecated); + if (message.deprecationWarning != null && Object.hasOwnProperty.call(message, "deprecationWarning")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.deprecationWarning); + if (message.editionRemoved != null && Object.hasOwnProperty.call(message, "editionRemoved")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.editionRemoved); + return writer; + }; + + /** + * Encodes the specified FeatureSupport message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport} message FeatureSupport message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSupport.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSupport.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FieldOptions.FeatureSupport(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.editionIntroduced = reader.int32(); + break; + } + case 2: { + message.editionDeprecated = reader.int32(); + break; + } + case 3: { + message.deprecationWarning = reader.string(); + break; + } + case 4: { + message.editionRemoved = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSupport.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FeatureSupport message. + * @function verify + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FeatureSupport.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.editionIntroduced != null && message.hasOwnProperty("editionIntroduced")) + switch (message.editionIntroduced) { + default: + return "editionIntroduced: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + if (message.editionDeprecated != null && message.hasOwnProperty("editionDeprecated")) + switch (message.editionDeprecated) { + default: + return "editionDeprecated: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + if (message.deprecationWarning != null && message.hasOwnProperty("deprecationWarning")) + if (!$util.isString(message.deprecationWarning)) + return "deprecationWarning: string expected"; + if (message.editionRemoved != null && message.hasOwnProperty("editionRemoved")) + switch (message.editionRemoved) { + default: + return "editionRemoved: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + return null; + }; + + /** + * Creates a FeatureSupport message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + */ + FeatureSupport.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FieldOptions.FeatureSupport) + return object; + var message = new $root.google.protobuf.FieldOptions.FeatureSupport(); + switch (object.editionIntroduced) { + default: + if (typeof object.editionIntroduced === "number") { + message.editionIntroduced = object.editionIntroduced; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionIntroduced = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionIntroduced = 900; + break; + case "EDITION_PROTO2": + case 998: + message.editionIntroduced = 998; + break; + case "EDITION_PROTO3": + case 999: + message.editionIntroduced = 999; + break; + case "EDITION_2023": + case 1000: + message.editionIntroduced = 1000; + break; + case "EDITION_2024": + case 1001: + message.editionIntroduced = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.editionIntroduced = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.editionIntroduced = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.editionIntroduced = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.editionIntroduced = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.editionIntroduced = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.editionIntroduced = 2147483647; + break; + } + switch (object.editionDeprecated) { + default: + if (typeof object.editionDeprecated === "number") { + message.editionDeprecated = object.editionDeprecated; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionDeprecated = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionDeprecated = 900; + break; + case "EDITION_PROTO2": + case 998: + message.editionDeprecated = 998; + break; + case "EDITION_PROTO3": + case 999: + message.editionDeprecated = 999; + break; + case "EDITION_2023": + case 1000: + message.editionDeprecated = 1000; + break; + case "EDITION_2024": + case 1001: + message.editionDeprecated = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.editionDeprecated = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.editionDeprecated = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.editionDeprecated = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.editionDeprecated = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.editionDeprecated = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.editionDeprecated = 2147483647; + break; + } + if (object.deprecationWarning != null) + message.deprecationWarning = String(object.deprecationWarning); + switch (object.editionRemoved) { + default: + if (typeof object.editionRemoved === "number") { + message.editionRemoved = object.editionRemoved; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionRemoved = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionRemoved = 900; + break; case "EDITION_PROTO2": case 998: - message.edition = 998; + message.editionRemoved = 998; break; case "EDITION_PROTO3": case 999: - message.edition = 999; + message.editionRemoved = 999; break; case "EDITION_2023": case 1000: - message.edition = 1000; + message.editionRemoved = 1000; break; case "EDITION_2024": case 1001: - message.edition = 1001; + message.editionRemoved = 1001; break; case "EDITION_1_TEST_ONLY": case 1: - message.edition = 1; + message.editionRemoved = 1; break; case "EDITION_2_TEST_ONLY": case 2: - message.edition = 2; + message.editionRemoved = 2; break; case "EDITION_99997_TEST_ONLY": case 99997: - message.edition = 99997; + message.editionRemoved = 99997; break; case "EDITION_99998_TEST_ONLY": case 99998: - message.edition = 99998; + message.editionRemoved = 99998; break; case "EDITION_99999_TEST_ONLY": case 99999: - message.edition = 99999; + message.editionRemoved = 99999; break; case "EDITION_MAX": case 2147483647: - message.edition = 2147483647; + message.editionRemoved = 2147483647; break; } - if (object.value != null) - message.value = String(object.value); return message; }; /** - * Creates a plain object from an EditionDefault message. Also converts values to other types if specified. + * Creates a plain object from a FeatureSupport message. Also converts values to other types if specified. * @function toObject - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @static - * @param {google.protobuf.FieldOptions.EditionDefault} message EditionDefault + * @param {google.protobuf.FieldOptions.FeatureSupport} message FeatureSupport * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - EditionDefault.toObject = function toObject(message, options) { + FeatureSupport.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { - object.value = ""; - object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.editionIntroduced = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.editionDeprecated = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.deprecationWarning = ""; + object.editionRemoved = options.enums === String ? "EDITION_UNKNOWN" : 0; } - if (message.value != null && message.hasOwnProperty("value")) - object.value = message.value; - if (message.edition != null && message.hasOwnProperty("edition")) - object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.editionIntroduced != null && message.hasOwnProperty("editionIntroduced")) + object.editionIntroduced = options.enums === String ? $root.google.protobuf.Edition[message.editionIntroduced] === undefined ? message.editionIntroduced : $root.google.protobuf.Edition[message.editionIntroduced] : message.editionIntroduced; + if (message.editionDeprecated != null && message.hasOwnProperty("editionDeprecated")) + object.editionDeprecated = options.enums === String ? $root.google.protobuf.Edition[message.editionDeprecated] === undefined ? message.editionDeprecated : $root.google.protobuf.Edition[message.editionDeprecated] : message.editionDeprecated; + if (message.deprecationWarning != null && message.hasOwnProperty("deprecationWarning")) + object.deprecationWarning = message.deprecationWarning; + if (message.editionRemoved != null && message.hasOwnProperty("editionRemoved")) + object.editionRemoved = options.enums === String ? $root.google.protobuf.Edition[message.editionRemoved] === undefined ? message.editionRemoved : $root.google.protobuf.Edition[message.editionRemoved] : message.editionRemoved; return object; }; /** - * Converts this EditionDefault to JSON. + * Converts this FeatureSupport to JSON. * @function toJSON - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @instance * @returns {Object.} JSON object */ - EditionDefault.prototype.toJSON = function toJSON() { + FeatureSupport.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for EditionDefault + * Gets the default type url for FeatureSupport * @function getTypeUrl - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - EditionDefault.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + FeatureSupport.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.protobuf.FieldOptions.EditionDefault"; + return typeUrlPrefix + "/google.protobuf.FieldOptions.FeatureSupport"; }; - return EditionDefault; + return FeatureSupport; })(); return FieldOptions; @@ -65674,6 +66943,7 @@ * @property {boolean|null} [deprecated] EnumValueOptions deprecated * @property {google.protobuf.IFeatureSet|null} [features] EnumValueOptions features * @property {boolean|null} [debugRedact] EnumValueOptions debugRedact + * @property {google.protobuf.FieldOptions.IFeatureSupport|null} [featureSupport] EnumValueOptions featureSupport * @property {Array.|null} [uninterpretedOption] EnumValueOptions uninterpretedOption */ @@ -65717,6 +66987,14 @@ */ EnumValueOptions.prototype.debugRedact = false; + /** + * EnumValueOptions featureSupport. + * @member {google.protobuf.FieldOptions.IFeatureSupport|null|undefined} featureSupport + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.featureSupport = null; + /** * EnumValueOptions uninterpretedOption. * @member {Array.} uninterpretedOption @@ -65755,6 +67033,8 @@ $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.debugRedact != null && Object.hasOwnProperty.call(message, "debugRedact")) writer.uint32(/* id 3, wireType 0 =*/24).bool(message.debugRedact); + if (message.featureSupport != null && Object.hasOwnProperty.call(message, "featureSupport")) + $root.google.protobuf.FieldOptions.FeatureSupport.encode(message.featureSupport, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); @@ -65806,6 +67086,10 @@ message.debugRedact = reader.bool(); break; } + case 4: { + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.decode(reader, reader.uint32()); + break; + } case 999: { if (!(message.uninterpretedOption && message.uninterpretedOption.length)) message.uninterpretedOption = []; @@ -65858,6 +67142,11 @@ if (message.debugRedact != null && message.hasOwnProperty("debugRedact")) if (typeof message.debugRedact !== "boolean") return "debugRedact: boolean expected"; + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) { + var error = $root.google.protobuf.FieldOptions.FeatureSupport.verify(message.featureSupport); + if (error) + return "featureSupport." + error; + } if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { if (!Array.isArray(message.uninterpretedOption)) return "uninterpretedOption: array expected"; @@ -65891,6 +67180,11 @@ } if (object.debugRedact != null) message.debugRedact = Boolean(object.debugRedact); + if (object.featureSupport != null) { + if (typeof object.featureSupport !== "object") + throw TypeError(".google.protobuf.EnumValueOptions.featureSupport: object expected"); + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.fromObject(object.featureSupport); + } if (object.uninterpretedOption) { if (!Array.isArray(object.uninterpretedOption)) throw TypeError(".google.protobuf.EnumValueOptions.uninterpretedOption: array expected"); @@ -65923,6 +67217,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -65930,6 +67225,8 @@ object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); if (message.debugRedact != null && message.hasOwnProperty("debugRedact")) object.debugRedact = message.debugRedact; + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) + object.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.toObject(message.featureSupport, options); if (message.uninterpretedOption && message.uninterpretedOption.length) { object.uninterpretedOption = []; for (var j = 0; j < message.uninterpretedOption.length; ++j) @@ -67397,6 +68694,8 @@ * @property {google.protobuf.FeatureSet.Utf8Validation|null} [utf8Validation] FeatureSet utf8Validation * @property {google.protobuf.FeatureSet.MessageEncoding|null} [messageEncoding] FeatureSet messageEncoding * @property {google.protobuf.FeatureSet.JsonFormat|null} [jsonFormat] FeatureSet jsonFormat + * @property {google.protobuf.FeatureSet.EnforceNamingStyle|null} [enforceNamingStyle] FeatureSet enforceNamingStyle + * @property {google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|null} [defaultSymbolVisibility] FeatureSet defaultSymbolVisibility */ /** @@ -67462,6 +68761,22 @@ */ FeatureSet.prototype.jsonFormat = 0; + /** + * FeatureSet enforceNamingStyle. + * @member {google.protobuf.FeatureSet.EnforceNamingStyle} enforceNamingStyle + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.enforceNamingStyle = 0; + + /** + * FeatureSet defaultSymbolVisibility. + * @member {google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility} defaultSymbolVisibility + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.defaultSymbolVisibility = 0; + /** * Creates a new FeatureSet instance using the specified properties. * @function create @@ -67498,6 +68813,10 @@ writer.uint32(/* id 5, wireType 0 =*/40).int32(message.messageEncoding); if (message.jsonFormat != null && Object.hasOwnProperty.call(message, "jsonFormat")) writer.uint32(/* id 6, wireType 0 =*/48).int32(message.jsonFormat); + if (message.enforceNamingStyle != null && Object.hasOwnProperty.call(message, "enforceNamingStyle")) + writer.uint32(/* id 7, wireType 0 =*/56).int32(message.enforceNamingStyle); + if (message.defaultSymbolVisibility != null && Object.hasOwnProperty.call(message, "defaultSymbolVisibility")) + writer.uint32(/* id 8, wireType 0 =*/64).int32(message.defaultSymbolVisibility); return writer; }; @@ -67558,6 +68877,14 @@ message.jsonFormat = reader.int32(); break; } + case 7: { + message.enforceNamingStyle = reader.int32(); + break; + } + case 8: { + message.defaultSymbolVisibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -67648,6 +68975,26 @@ case 2: break; } + if (message.enforceNamingStyle != null && message.hasOwnProperty("enforceNamingStyle")) + switch (message.enforceNamingStyle) { + default: + return "enforceNamingStyle: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.defaultSymbolVisibility != null && message.hasOwnProperty("defaultSymbolVisibility")) + switch (message.defaultSymbolVisibility) { + default: + return "defaultSymbolVisibility: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } return null; }; @@ -67787,6 +69134,54 @@ message.jsonFormat = 2; break; } + switch (object.enforceNamingStyle) { + default: + if (typeof object.enforceNamingStyle === "number") { + message.enforceNamingStyle = object.enforceNamingStyle; + break; + } + break; + case "ENFORCE_NAMING_STYLE_UNKNOWN": + case 0: + message.enforceNamingStyle = 0; + break; + case "STYLE2024": + case 1: + message.enforceNamingStyle = 1; + break; + case "STYLE_LEGACY": + case 2: + message.enforceNamingStyle = 2; + break; + } + switch (object.defaultSymbolVisibility) { + default: + if (typeof object.defaultSymbolVisibility === "number") { + message.defaultSymbolVisibility = object.defaultSymbolVisibility; + break; + } + break; + case "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN": + case 0: + message.defaultSymbolVisibility = 0; + break; + case "EXPORT_ALL": + case 1: + message.defaultSymbolVisibility = 1; + break; + case "EXPORT_TOP_LEVEL": + case 2: + message.defaultSymbolVisibility = 2; + break; + case "LOCAL_ALL": + case 3: + message.defaultSymbolVisibility = 3; + break; + case "STRICT": + case 4: + message.defaultSymbolVisibility = 4; + break; + } return message; }; @@ -67810,6 +69205,8 @@ object.utf8Validation = options.enums === String ? "UTF8_VALIDATION_UNKNOWN" : 0; object.messageEncoding = options.enums === String ? "MESSAGE_ENCODING_UNKNOWN" : 0; object.jsonFormat = options.enums === String ? "JSON_FORMAT_UNKNOWN" : 0; + object.enforceNamingStyle = options.enums === String ? "ENFORCE_NAMING_STYLE_UNKNOWN" : 0; + object.defaultSymbolVisibility = options.enums === String ? "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN" : 0; } if (message.fieldPresence != null && message.hasOwnProperty("fieldPresence")) object.fieldPresence = options.enums === String ? $root.google.protobuf.FeatureSet.FieldPresence[message.fieldPresence] === undefined ? message.fieldPresence : $root.google.protobuf.FeatureSet.FieldPresence[message.fieldPresence] : message.fieldPresence; @@ -67823,6 +69220,10 @@ object.messageEncoding = options.enums === String ? $root.google.protobuf.FeatureSet.MessageEncoding[message.messageEncoding] === undefined ? message.messageEncoding : $root.google.protobuf.FeatureSet.MessageEncoding[message.messageEncoding] : message.messageEncoding; if (message.jsonFormat != null && message.hasOwnProperty("jsonFormat")) object.jsonFormat = options.enums === String ? $root.google.protobuf.FeatureSet.JsonFormat[message.jsonFormat] === undefined ? message.jsonFormat : $root.google.protobuf.FeatureSet.JsonFormat[message.jsonFormat] : message.jsonFormat; + if (message.enforceNamingStyle != null && message.hasOwnProperty("enforceNamingStyle")) + object.enforceNamingStyle = options.enums === String ? $root.google.protobuf.FeatureSet.EnforceNamingStyle[message.enforceNamingStyle] === undefined ? message.enforceNamingStyle : $root.google.protobuf.FeatureSet.EnforceNamingStyle[message.enforceNamingStyle] : message.enforceNamingStyle; + if (message.defaultSymbolVisibility != null && message.hasOwnProperty("defaultSymbolVisibility")) + object.defaultSymbolVisibility = options.enums === String ? $root.google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility[message.defaultSymbolVisibility] === undefined ? message.defaultSymbolVisibility : $root.google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility[message.defaultSymbolVisibility] : message.defaultSymbolVisibility; return object; }; @@ -67950,6 +69351,219 @@ return values; })(); + /** + * EnforceNamingStyle enum. + * @name google.protobuf.FeatureSet.EnforceNamingStyle + * @enum {number} + * @property {number} ENFORCE_NAMING_STYLE_UNKNOWN=0 ENFORCE_NAMING_STYLE_UNKNOWN value + * @property {number} STYLE2024=1 STYLE2024 value + * @property {number} STYLE_LEGACY=2 STYLE_LEGACY value + */ + FeatureSet.EnforceNamingStyle = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "ENFORCE_NAMING_STYLE_UNKNOWN"] = 0; + values[valuesById[1] = "STYLE2024"] = 1; + values[valuesById[2] = "STYLE_LEGACY"] = 2; + return values; + })(); + + FeatureSet.VisibilityFeature = (function() { + + /** + * Properties of a VisibilityFeature. + * @memberof google.protobuf.FeatureSet + * @interface IVisibilityFeature + */ + + /** + * Constructs a new VisibilityFeature. + * @memberof google.protobuf.FeatureSet + * @classdesc Represents a VisibilityFeature. + * @implements IVisibilityFeature + * @constructor + * @param {google.protobuf.FeatureSet.IVisibilityFeature=} [properties] Properties to set + */ + function VisibilityFeature(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]]; + } + + /** + * Creates a new VisibilityFeature instance using the specified properties. + * @function create + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature=} [properties] Properties to set + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature instance + */ + VisibilityFeature.create = function create(properties) { + return new VisibilityFeature(properties); + }; + + /** + * Encodes the specified VisibilityFeature message. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature} message VisibilityFeature message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VisibilityFeature.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified VisibilityFeature message, length delimited. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature} message VisibilityFeature message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VisibilityFeature.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VisibilityFeature.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FeatureSet.VisibilityFeature(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VisibilityFeature.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a VisibilityFeature message. + * @function verify + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + VisibilityFeature.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a VisibilityFeature message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + */ + VisibilityFeature.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FeatureSet.VisibilityFeature) + return object; + return new $root.google.protobuf.FeatureSet.VisibilityFeature(); + }; + + /** + * Creates a plain object from a VisibilityFeature message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.VisibilityFeature} message VisibilityFeature + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + VisibilityFeature.toObject = function toObject() { + return {}; + }; + + /** + * Converts this VisibilityFeature to JSON. + * @function toJSON + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @instance + * @returns {Object.} JSON object + */ + VisibilityFeature.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for VisibilityFeature + * @function getTypeUrl + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + VisibilityFeature.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FeatureSet.VisibilityFeature"; + }; + + /** + * DefaultSymbolVisibility enum. + * @name google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility + * @enum {number} + * @property {number} DEFAULT_SYMBOL_VISIBILITY_UNKNOWN=0 DEFAULT_SYMBOL_VISIBILITY_UNKNOWN value + * @property {number} EXPORT_ALL=1 EXPORT_ALL value + * @property {number} EXPORT_TOP_LEVEL=2 EXPORT_TOP_LEVEL value + * @property {number} LOCAL_ALL=3 LOCAL_ALL value + * @property {number} STRICT=4 STRICT value + */ + VisibilityFeature.DefaultSymbolVisibility = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN"] = 0; + values[valuesById[1] = "EXPORT_ALL"] = 1; + values[valuesById[2] = "EXPORT_TOP_LEVEL"] = 2; + values[valuesById[3] = "LOCAL_ALL"] = 3; + values[valuesById[4] = "STRICT"] = 4; + return values; + })(); + + return VisibilityFeature; + })(); + return FeatureSet; })(); @@ -68134,6 +69748,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -68151,6 +69766,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -68199,6 +69815,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -68251,6 +69871,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -68359,7 +69983,8 @@ * @memberof google.protobuf.FeatureSetDefaults * @interface IFeatureSetEditionDefault * @property {google.protobuf.Edition|null} [edition] FeatureSetEditionDefault edition - * @property {google.protobuf.IFeatureSet|null} [features] FeatureSetEditionDefault features + * @property {google.protobuf.IFeatureSet|null} [overridableFeatures] FeatureSetEditionDefault overridableFeatures + * @property {google.protobuf.IFeatureSet|null} [fixedFeatures] FeatureSetEditionDefault fixedFeatures */ /** @@ -68386,12 +70011,20 @@ FeatureSetEditionDefault.prototype.edition = 0; /** - * FeatureSetEditionDefault features. - * @member {google.protobuf.IFeatureSet|null|undefined} features + * FeatureSetEditionDefault overridableFeatures. + * @member {google.protobuf.IFeatureSet|null|undefined} overridableFeatures + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @instance + */ + FeatureSetEditionDefault.prototype.overridableFeatures = null; + + /** + * FeatureSetEditionDefault fixedFeatures. + * @member {google.protobuf.IFeatureSet|null|undefined} fixedFeatures * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault * @instance */ - FeatureSetEditionDefault.prototype.features = null; + FeatureSetEditionDefault.prototype.fixedFeatures = null; /** * Creates a new FeatureSetEditionDefault instance using the specified properties. @@ -68417,10 +70050,12 @@ FeatureSetEditionDefault.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.features != null && Object.hasOwnProperty.call(message, "features")) - $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) writer.uint32(/* id 3, wireType 0 =*/24).int32(message.edition); + if (message.overridableFeatures != null && Object.hasOwnProperty.call(message, "overridableFeatures")) + $root.google.protobuf.FeatureSet.encode(message.overridableFeatures, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.fixedFeatures != null && Object.hasOwnProperty.call(message, "fixedFeatures")) + $root.google.protobuf.FeatureSet.encode(message.fixedFeatures, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); return writer; }; @@ -68461,8 +70096,12 @@ message.edition = reader.int32(); break; } - case 2: { - message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + case 4: { + message.overridableFeatures = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + break; + } + case 5: { + message.fixedFeatures = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); break; } default: @@ -68505,6 +70144,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -68517,10 +70157,15 @@ case 2147483647: break; } - if (message.features != null && message.hasOwnProperty("features")) { - var error = $root.google.protobuf.FeatureSet.verify(message.features); + if (message.overridableFeatures != null && message.hasOwnProperty("overridableFeatures")) { + var error = $root.google.protobuf.FeatureSet.verify(message.overridableFeatures); + if (error) + return "overridableFeatures." + error; + } + if (message.fixedFeatures != null && message.hasOwnProperty("fixedFeatures")) { + var error = $root.google.protobuf.FeatureSet.verify(message.fixedFeatures); if (error) - return "features." + error; + return "fixedFeatures." + error; } return null; }; @@ -68548,6 +70193,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -68589,10 +70238,15 @@ message.edition = 2147483647; break; } - if (object.features != null) { - if (typeof object.features !== "object") - throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.features: object expected"); - message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); + if (object.overridableFeatures != null) { + if (typeof object.overridableFeatures !== "object") + throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.overridableFeatures: object expected"); + message.overridableFeatures = $root.google.protobuf.FeatureSet.fromObject(object.overridableFeatures); + } + if (object.fixedFeatures != null) { + if (typeof object.fixedFeatures !== "object") + throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.fixedFeatures: object expected"); + message.fixedFeatures = $root.google.protobuf.FeatureSet.fromObject(object.fixedFeatures); } return message; }; @@ -68611,13 +70265,16 @@ options = {}; var object = {}; if (options.defaults) { - object.features = null; object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.overridableFeatures = null; + object.fixedFeatures = null; } - if (message.features != null && message.hasOwnProperty("features")) - object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); if (message.edition != null && message.hasOwnProperty("edition")) object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.overridableFeatures != null && message.hasOwnProperty("overridableFeatures")) + object.overridableFeatures = $root.google.protobuf.FeatureSet.toObject(message.overridableFeatures, options); + if (message.fixedFeatures != null && message.hasOwnProperty("fixedFeatures")) + object.fixedFeatures = $root.google.protobuf.FeatureSet.toObject(message.fixedFeatures, options); return object; }; @@ -69832,6 +71489,22 @@ return GeneratedCodeInfo; })(); + /** + * SymbolVisibility enum. + * @name google.protobuf.SymbolVisibility + * @enum {number} + * @property {number} VISIBILITY_UNSET=0 VISIBILITY_UNSET value + * @property {number} VISIBILITY_LOCAL=1 VISIBILITY_LOCAL value + * @property {number} VISIBILITY_EXPORT=2 VISIBILITY_EXPORT value + */ + protobuf.SymbolVisibility = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "VISIBILITY_UNSET"] = 0; + values[valuesById[1] = "VISIBILITY_LOCAL"] = 1; + values[valuesById[2] = "VISIBILITY_EXPORT"] = 2; + return values; + })(); + protobuf.Duration = (function() { /** diff --git a/packages/google-cloud-migrationcenter/protos/protos.json b/packages/google-cloud-migrationcenter/protos/protos.json index fb7e6042369c..e91b6928dfcc 100644 --- a/packages/google-cloud-migrationcenter/protos/protos.json +++ b/packages/google-cloud-migrationcenter/protos/protos.json @@ -5221,8 +5221,7 @@ "java_multiple_files": true, "java_outer_classname": "ResourceProto", "java_package": "com.google.api", - "objc_class_prefix": "GAPI", - "cc_enable_arenas": true + "objc_class_prefix": "GAPI" }, "nested": { "http": { @@ -5346,6 +5345,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -5486,6 +5489,28 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "experimentalFeatures": { + "type": "ExperimentalFeatures", + "id": 2 + } + }, + "nested": { + "ExperimentalFeatures": { + "fields": { + "restAsyncIoEnabled": { + "type": "bool", + "id": 1 + }, + "protobufPythonicTypesEnabled": { + "type": "bool", + "id": 2 + }, + "unversionedPackageDisabled": { + "type": "bool", + "id": 3 + } + } } } }, @@ -5543,6 +5568,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -5604,6 +5634,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -5736,12 +5779,19 @@ "type": "FileDescriptorProto", "id": 1 } - } + }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ] }, "Edition": { "edition": "proto2", "values": { "EDITION_UNKNOWN": 0, + "EDITION_LEGACY": 900, "EDITION_PROTO2": 998, "EDITION_PROTO3": 999, "EDITION_2023": 1000, @@ -5780,6 +5830,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -5868,6 +5923,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -6093,6 +6152,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -6143,7 +6206,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -6307,6 +6377,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -6442,7 +6513,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -6470,6 +6542,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -6539,6 +6615,26 @@ "id": 2 } } + }, + "FeatureSupport": { + "fields": { + "editionIntroduced": { + "type": "Edition", + "id": 1 + }, + "editionDeprecated": { + "type": "Edition", + "id": 2 + }, + "deprecationWarning": { + "type": "string", + "id": 3 + }, + "editionRemoved": { + "type": "Edition", + "id": 4 + } + } } } }, @@ -6627,6 +6723,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -6769,6 +6869,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -6779,6 +6880,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -6789,6 +6891,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -6799,6 +6902,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -6809,7 +6913,8 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", - "edition_defaults.edition": "EDITION_PROTO2", + "feature_support.edition_introduced": "EDITION_2023", + "edition_defaults.edition": "EDITION_LEGACY", "edition_defaults.value": "LENGTH_PREFIXED" } }, @@ -6819,27 +6924,38 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "ALLOW" } + }, + "enforceNamingStyle": { + "type": "EnforceNamingStyle", + "id": 7, + "options": { + "retention": "RETENTION_SOURCE", + "targets": "TARGET_TYPE_METHOD", + "feature_support.edition_introduced": "EDITION_2024", + "edition_defaults.edition": "EDITION_2024", + "edition_defaults.value": "STYLE2024" + } + }, + "defaultSymbolVisibility": { + "type": "VisibilityFeature.DefaultSymbolVisibility", + "id": 8, + "options": { + "retention": "RETENTION_SOURCE", + "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2024", + "edition_defaults.edition": "EDITION_2024", + "edition_defaults.value": "EXPORT_TOP_LEVEL" + } } }, "extensions": [ [ 1000, - 1000 - ], - [ - 1001, - 1001 - ], - [ - 1002, - 1002 - ], - [ - 9990, - 9990 + 9994 ], [ 9995, @@ -6884,7 +7000,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -6899,6 +7021,33 @@ "ALLOW": 1, "LEGACY_BEST_EFFORT": 2 } + }, + "EnforceNamingStyle": { + "values": { + "ENFORCE_NAMING_STYLE_UNKNOWN": 0, + "STYLE2024": 1, + "STYLE_LEGACY": 2 + } + }, + "VisibilityFeature": { + "fields": {}, + "reserved": [ + [ + 1, + 536870911 + ] + ], + "nested": { + "DefaultSymbolVisibility": { + "values": { + "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN": 0, + "EXPORT_ALL": 1, + "EXPORT_TOP_LEVEL": 2, + "LOCAL_ALL": 3, + "STRICT": 4 + } + } + } } } }, @@ -6926,11 +7075,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -6943,6 +7107,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -7028,6 +7198,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Duration": { "fields": { "seconds": { @@ -7086,6 +7264,7 @@ "java_multiple_files": true, "java_outer_classname": "OperationsProto", "java_package": "com.google.longrunning", + "objc_class_prefix": "GLRUN", "php_namespace": "Google\\LongRunning" }, "nested": { diff --git a/packages/google-cloud-migrationcenter/samples/generated/v1/snippet_metadata_google.cloud.migrationcenter.v1.json b/packages/google-cloud-migrationcenter/samples/generated/v1/snippet_metadata_google.cloud.migrationcenter.v1.json index d28c91a30d66..75fc84ee26dd 100644 --- a/packages/google-cloud-migrationcenter/samples/generated/v1/snippet_metadata_google.cloud.migrationcenter.v1.json +++ b/packages/google-cloud-migrationcenter/samples/generated/v1/snippet_metadata_google.cloud.migrationcenter.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-migrationcenter", - "version": "2.2.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-migrationcenter/src/v1/index.ts b/packages/google-cloud-migrationcenter/src/v1/index.ts index 5e4b439bd35f..af3ec82a2d51 100644 --- a/packages/google-cloud-migrationcenter/src/v1/index.ts +++ b/packages/google-cloud-migrationcenter/src/v1/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {MigrationCenterClient} from './migration_center_client'; +export { MigrationCenterClient } from './migration_center_client'; diff --git a/packages/google-cloud-migrationcenter/src/v1/migration_center_client.ts b/packages/google-cloud-migrationcenter/src/v1/migration_center_client.ts index fd4b0b928d84..0a500c436f6b 100644 --- a/packages/google-cloud-migrationcenter/src/v1/migration_center_client.ts +++ b/packages/google-cloud-migrationcenter/src/v1/migration_center_client.ts @@ -18,11 +18,22 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -44,7 +55,7 @@ export class MigrationCenterClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('migrationcenter'); @@ -57,11 +68,11 @@ export class MigrationCenterClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - migrationCenterStub?: Promise<{[name: string]: Function}>; + migrationCenterStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of MigrationCenterClient. @@ -102,21 +113,42 @@ export class MigrationCenterClient { * const client = new MigrationCenterClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof MigrationCenterClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'migrationcenter.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -141,7 +173,7 @@ export class MigrationCenterClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -155,15 +187,11 @@ export class MigrationCenterClient { } this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -185,40 +213,40 @@ export class MigrationCenterClient { // Create useful helper objects for these. this.pathTemplates = { assetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/assets/{asset}' + 'projects/{project}/locations/{location}/assets/{asset}', ), errorFramePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/sources/{source}/errorFrames/{error_frame}' + 'projects/{project}/locations/{location}/sources/{source}/errorFrames/{error_frame}', ), groupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/groups/{group}' + 'projects/{project}/locations/{location}/groups/{group}', ), importDataFilePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/importJobs/{import_job}/importDataFiles/{import_data_file}' + 'projects/{project}/locations/{location}/importJobs/{import_job}/importDataFiles/{import_data_file}', ), importJobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/importJobs/{import_job}' + 'projects/{project}/locations/{location}/importJobs/{import_job}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), preferenceSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/preferenceSets/{preference_set}' + 'projects/{project}/locations/{location}/preferenceSets/{preference_set}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), reportPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/reportConfigs/{report_config}/reports/{report}' + 'projects/{project}/locations/{location}/reportConfigs/{report_config}/reports/{report}', ), reportConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/reportConfigs/{report_config}' + 'projects/{project}/locations/{location}/reportConfigs/{report_config}', ), settingsPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/settings' + 'projects/{project}/locations/{location}/settings', ), sourcePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/sources/{source}' + 'projects/{project}/locations/{location}/sources/{source}', ), }; @@ -226,24 +254,51 @@ export class MigrationCenterClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listAssets: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'assets'), - listImportJobs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'importJobs'), - listImportDataFiles: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'importDataFiles'), - listGroups: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'groups'), - listErrorFrames: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'errorFrames'), - listSources: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'sources'), - listPreferenceSets: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'preferenceSets'), - listReportConfigs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'reportConfigs'), - listReports: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'reports') + listAssets: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'assets', + ), + listImportJobs: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'importJobs', + ), + listImportDataFiles: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'importDataFiles', + ), + listGroups: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'groups', + ), + listErrorFrames: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'errorFrames', + ), + listSources: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'sources', + ), + listPreferenceSets: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'preferenceSets', + ), + listReportConfigs: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'reportConfigs', + ), + listReports: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'reports', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -252,205 +307,309 @@ export class MigrationCenterClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1/{name=projects/*}/locations', + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createImportJobResponse = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.ImportJob') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.ImportJob', + ) as gax.protobuf.Type; const createImportJobMetadata = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteImportJobResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteImportJobMetadata = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateImportJobResponse = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.ImportJob') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.ImportJob', + ) as gax.protobuf.Type; const updateImportJobMetadata = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.OperationMetadata', + ) as gax.protobuf.Type; const validateImportJobResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const validateImportJobMetadata = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.OperationMetadata', + ) as gax.protobuf.Type; const runImportJobResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const runImportJobMetadata = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.OperationMetadata', + ) as gax.protobuf.Type; const createImportDataFileResponse = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.ImportDataFile') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.ImportDataFile', + ) as gax.protobuf.Type; const createImportDataFileMetadata = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteImportDataFileResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteImportDataFileMetadata = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.OperationMetadata', + ) as gax.protobuf.Type; const createGroupResponse = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.Group') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.Group', + ) as gax.protobuf.Type; const createGroupMetadata = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateGroupResponse = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.Group') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.Group', + ) as gax.protobuf.Type; const updateGroupMetadata = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteGroupResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteGroupMetadata = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.OperationMetadata', + ) as gax.protobuf.Type; const addAssetsToGroupResponse = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.Group') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.Group', + ) as gax.protobuf.Type; const addAssetsToGroupMetadata = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.OperationMetadata', + ) as gax.protobuf.Type; const removeAssetsFromGroupResponse = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.Group') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.Group', + ) as gax.protobuf.Type; const removeAssetsFromGroupMetadata = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.OperationMetadata', + ) as gax.protobuf.Type; const createSourceResponse = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.Source') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.Source', + ) as gax.protobuf.Type; const createSourceMetadata = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateSourceResponse = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.Source') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.Source', + ) as gax.protobuf.Type; const updateSourceMetadata = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteSourceResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteSourceMetadata = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.OperationMetadata', + ) as gax.protobuf.Type; const createPreferenceSetResponse = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.PreferenceSet') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.PreferenceSet', + ) as gax.protobuf.Type; const createPreferenceSetMetadata = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.OperationMetadata', + ) as gax.protobuf.Type; const updatePreferenceSetResponse = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.PreferenceSet') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.PreferenceSet', + ) as gax.protobuf.Type; const updatePreferenceSetMetadata = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.OperationMetadata', + ) as gax.protobuf.Type; const deletePreferenceSetResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deletePreferenceSetMetadata = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateSettingsResponse = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.Settings') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.Settings', + ) as gax.protobuf.Type; const updateSettingsMetadata = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.OperationMetadata', + ) as gax.protobuf.Type; const createReportConfigResponse = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.ReportConfig') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.ReportConfig', + ) as gax.protobuf.Type; const createReportConfigMetadata = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteReportConfigResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteReportConfigMetadata = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.OperationMetadata', + ) as gax.protobuf.Type; const createReportResponse = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.Report') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.Report', + ) as gax.protobuf.Type; const createReportMetadata = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteReportResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteReportMetadata = protoFilesRoot.lookup( - '.google.cloud.migrationcenter.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.migrationcenter.v1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createImportJob: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createImportJobResponse.decode.bind(createImportJobResponse), - createImportJobMetadata.decode.bind(createImportJobMetadata)), + createImportJobMetadata.decode.bind(createImportJobMetadata), + ), deleteImportJob: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteImportJobResponse.decode.bind(deleteImportJobResponse), - deleteImportJobMetadata.decode.bind(deleteImportJobMetadata)), + deleteImportJobMetadata.decode.bind(deleteImportJobMetadata), + ), updateImportJob: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateImportJobResponse.decode.bind(updateImportJobResponse), - updateImportJobMetadata.decode.bind(updateImportJobMetadata)), + updateImportJobMetadata.decode.bind(updateImportJobMetadata), + ), validateImportJob: new this._gaxModule.LongrunningDescriptor( this.operationsClient, validateImportJobResponse.decode.bind(validateImportJobResponse), - validateImportJobMetadata.decode.bind(validateImportJobMetadata)), + validateImportJobMetadata.decode.bind(validateImportJobMetadata), + ), runImportJob: new this._gaxModule.LongrunningDescriptor( this.operationsClient, runImportJobResponse.decode.bind(runImportJobResponse), - runImportJobMetadata.decode.bind(runImportJobMetadata)), + runImportJobMetadata.decode.bind(runImportJobMetadata), + ), createImportDataFile: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createImportDataFileResponse.decode.bind(createImportDataFileResponse), - createImportDataFileMetadata.decode.bind(createImportDataFileMetadata)), + createImportDataFileMetadata.decode.bind(createImportDataFileMetadata), + ), deleteImportDataFile: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteImportDataFileResponse.decode.bind(deleteImportDataFileResponse), - deleteImportDataFileMetadata.decode.bind(deleteImportDataFileMetadata)), + deleteImportDataFileMetadata.decode.bind(deleteImportDataFileMetadata), + ), createGroup: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createGroupResponse.decode.bind(createGroupResponse), - createGroupMetadata.decode.bind(createGroupMetadata)), + createGroupMetadata.decode.bind(createGroupMetadata), + ), updateGroup: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateGroupResponse.decode.bind(updateGroupResponse), - updateGroupMetadata.decode.bind(updateGroupMetadata)), + updateGroupMetadata.decode.bind(updateGroupMetadata), + ), deleteGroup: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteGroupResponse.decode.bind(deleteGroupResponse), - deleteGroupMetadata.decode.bind(deleteGroupMetadata)), + deleteGroupMetadata.decode.bind(deleteGroupMetadata), + ), addAssetsToGroup: new this._gaxModule.LongrunningDescriptor( this.operationsClient, addAssetsToGroupResponse.decode.bind(addAssetsToGroupResponse), - addAssetsToGroupMetadata.decode.bind(addAssetsToGroupMetadata)), + addAssetsToGroupMetadata.decode.bind(addAssetsToGroupMetadata), + ), removeAssetsFromGroup: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - removeAssetsFromGroupResponse.decode.bind(removeAssetsFromGroupResponse), - removeAssetsFromGroupMetadata.decode.bind(removeAssetsFromGroupMetadata)), + removeAssetsFromGroupResponse.decode.bind( + removeAssetsFromGroupResponse, + ), + removeAssetsFromGroupMetadata.decode.bind( + removeAssetsFromGroupMetadata, + ), + ), createSource: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createSourceResponse.decode.bind(createSourceResponse), - createSourceMetadata.decode.bind(createSourceMetadata)), + createSourceMetadata.decode.bind(createSourceMetadata), + ), updateSource: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateSourceResponse.decode.bind(updateSourceResponse), - updateSourceMetadata.decode.bind(updateSourceMetadata)), + updateSourceMetadata.decode.bind(updateSourceMetadata), + ), deleteSource: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteSourceResponse.decode.bind(deleteSourceResponse), - deleteSourceMetadata.decode.bind(deleteSourceMetadata)), + deleteSourceMetadata.decode.bind(deleteSourceMetadata), + ), createPreferenceSet: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createPreferenceSetResponse.decode.bind(createPreferenceSetResponse), - createPreferenceSetMetadata.decode.bind(createPreferenceSetMetadata)), + createPreferenceSetMetadata.decode.bind(createPreferenceSetMetadata), + ), updatePreferenceSet: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updatePreferenceSetResponse.decode.bind(updatePreferenceSetResponse), - updatePreferenceSetMetadata.decode.bind(updatePreferenceSetMetadata)), + updatePreferenceSetMetadata.decode.bind(updatePreferenceSetMetadata), + ), deletePreferenceSet: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deletePreferenceSetResponse.decode.bind(deletePreferenceSetResponse), - deletePreferenceSetMetadata.decode.bind(deletePreferenceSetMetadata)), + deletePreferenceSetMetadata.decode.bind(deletePreferenceSetMetadata), + ), updateSettings: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateSettingsResponse.decode.bind(updateSettingsResponse), - updateSettingsMetadata.decode.bind(updateSettingsMetadata)), + updateSettingsMetadata.decode.bind(updateSettingsMetadata), + ), createReportConfig: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createReportConfigResponse.decode.bind(createReportConfigResponse), - createReportConfigMetadata.decode.bind(createReportConfigMetadata)), + createReportConfigMetadata.decode.bind(createReportConfigMetadata), + ), deleteReportConfig: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteReportConfigResponse.decode.bind(deleteReportConfigResponse), - deleteReportConfigMetadata.decode.bind(deleteReportConfigMetadata)), + deleteReportConfigMetadata.decode.bind(deleteReportConfigMetadata), + ), createReport: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createReportResponse.decode.bind(createReportResponse), - createReportMetadata.decode.bind(createReportMetadata)), + createReportMetadata.decode.bind(createReportMetadata), + ), deleteReport: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteReportResponse.decode.bind(deleteReportResponse), - deleteReportMetadata.decode.bind(deleteReportMetadata)) + deleteReportMetadata.decode.bind(deleteReportMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.migrationcenter.v1.MigrationCenter', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.migrationcenter.v1.MigrationCenter', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -481,28 +640,82 @@ export class MigrationCenterClient { // Put together the "service stub" for // google.cloud.migrationcenter.v1.MigrationCenter. this.migrationCenterStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.migrationcenter.v1.MigrationCenter') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.migrationcenter.v1.MigrationCenter', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.migrationcenter.v1.MigrationCenter, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const migrationCenterStubMethods = - ['listAssets', 'getAsset', 'updateAsset', 'batchUpdateAssets', 'deleteAsset', 'batchDeleteAssets', 'reportAssetFrames', 'aggregateAssetsValues', 'createImportJob', 'listImportJobs', 'getImportJob', 'deleteImportJob', 'updateImportJob', 'validateImportJob', 'runImportJob', 'getImportDataFile', 'listImportDataFiles', 'createImportDataFile', 'deleteImportDataFile', 'listGroups', 'getGroup', 'createGroup', 'updateGroup', 'deleteGroup', 'addAssetsToGroup', 'removeAssetsFromGroup', 'listErrorFrames', 'getErrorFrame', 'listSources', 'getSource', 'createSource', 'updateSource', 'deleteSource', 'listPreferenceSets', 'getPreferenceSet', 'createPreferenceSet', 'updatePreferenceSet', 'deletePreferenceSet', 'getSettings', 'updateSettings', 'createReportConfig', 'getReportConfig', 'listReportConfigs', 'deleteReportConfig', 'createReport', 'getReport', 'listReports', 'deleteReport']; + const migrationCenterStubMethods = [ + 'listAssets', + 'getAsset', + 'updateAsset', + 'batchUpdateAssets', + 'deleteAsset', + 'batchDeleteAssets', + 'reportAssetFrames', + 'aggregateAssetsValues', + 'createImportJob', + 'listImportJobs', + 'getImportJob', + 'deleteImportJob', + 'updateImportJob', + 'validateImportJob', + 'runImportJob', + 'getImportDataFile', + 'listImportDataFiles', + 'createImportDataFile', + 'deleteImportDataFile', + 'listGroups', + 'getGroup', + 'createGroup', + 'updateGroup', + 'deleteGroup', + 'addAssetsToGroup', + 'removeAssetsFromGroup', + 'listErrorFrames', + 'getErrorFrame', + 'listSources', + 'getSource', + 'createSource', + 'updateSource', + 'deleteSource', + 'listPreferenceSets', + 'getPreferenceSet', + 'createPreferenceSet', + 'updatePreferenceSet', + 'deletePreferenceSet', + 'getSettings', + 'updateSettings', + 'createReportConfig', + 'getReportConfig', + 'listReportConfigs', + 'deleteReportConfig', + 'createReport', + 'getReport', + 'listReports', + 'deleteReport', + ]; for (const methodName of migrationCenterStubMethods) { const callPromise = this.migrationCenterStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -512,7 +725,7 @@ export class MigrationCenterClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -527,8 +740,14 @@ export class MigrationCenterClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'migrationcenter.googleapis.com'; } @@ -539,8 +758,14 @@ export class MigrationCenterClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'migrationcenter.googleapis.com'; } @@ -571,9 +796,7 @@ export class MigrationCenterClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -582,8 +805,9 @@ export class MigrationCenterClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -594,4561 +818,6730 @@ export class MigrationCenterClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets the details of an asset. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource. - * @param {google.cloud.migrationcenter.v1.AssetView} request.view - * View of the assets. Defaults to BASIC. - * @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 {@link protos.google.cloud.migrationcenter.v1.Asset|Asset}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/migration_center.get_asset.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_GetAsset_async - */ + /** + * Gets the details of an asset. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource. + * @param {google.cloud.migrationcenter.v1.AssetView} request.view + * View of the assets. Defaults to BASIC. + * @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 {@link protos.google.cloud.migrationcenter.v1.Asset|Asset}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/migration_center.get_asset.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_GetAsset_async + */ getAsset( - request?: protos.google.cloud.migrationcenter.v1.IGetAssetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.migrationcenter.v1.IAsset, - protos.google.cloud.migrationcenter.v1.IGetAssetRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.IGetAssetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IAsset, + protos.google.cloud.migrationcenter.v1.IGetAssetRequest | undefined, + {} | undefined, + ] + >; getAsset( - request: protos.google.cloud.migrationcenter.v1.IGetAssetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.migrationcenter.v1.IAsset, - protos.google.cloud.migrationcenter.v1.IGetAssetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IGetAssetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.migrationcenter.v1.IAsset, + | protos.google.cloud.migrationcenter.v1.IGetAssetRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAsset( - request: protos.google.cloud.migrationcenter.v1.IGetAssetRequest, - callback: Callback< - protos.google.cloud.migrationcenter.v1.IAsset, - protos.google.cloud.migrationcenter.v1.IGetAssetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IGetAssetRequest, + callback: Callback< + protos.google.cloud.migrationcenter.v1.IAsset, + | protos.google.cloud.migrationcenter.v1.IGetAssetRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAsset( - request?: protos.google.cloud.migrationcenter.v1.IGetAssetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.migrationcenter.v1.IAsset, - protos.google.cloud.migrationcenter.v1.IGetAssetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.migrationcenter.v1.IGetAssetRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.migrationcenter.v1.IAsset, - protos.google.cloud.migrationcenter.v1.IGetAssetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.migrationcenter.v1.IAsset, - protos.google.cloud.migrationcenter.v1.IGetAssetRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.migrationcenter.v1.IGetAssetRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.migrationcenter.v1.IAsset, + | protos.google.cloud.migrationcenter.v1.IGetAssetRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IAsset, + protos.google.cloud.migrationcenter.v1.IGetAssetRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getAsset request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.migrationcenter.v1.IAsset, - protos.google.cloud.migrationcenter.v1.IGetAssetRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.migrationcenter.v1.IAsset, + | protos.google.cloud.migrationcenter.v1.IGetAssetRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getAsset response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getAsset(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.migrationcenter.v1.IAsset, - protos.google.cloud.migrationcenter.v1.IGetAssetRequest|undefined, - {}|undefined - ]) => { - this._log.info('getAsset response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getAsset(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.migrationcenter.v1.IAsset, + protos.google.cloud.migrationcenter.v1.IGetAssetRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getAsset response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Updates the parameters of an asset. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Field mask is used to specify the fields to be overwritten in the - * `Asset` resource by the update. - * The values specified in the `update_mask` field are relative to the - * resource, not the full request. - * A field will be overwritten if it is in the mask. - * A single * value in the mask lets you to overwrite all fields. - * @param {google.cloud.migrationcenter.v1.Asset} request.asset - * Required. The resource being updated. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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 {@link protos.google.cloud.migrationcenter.v1.Asset|Asset}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/migration_center.update_asset.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_UpdateAsset_async - */ + /** + * Updates the parameters of an asset. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Field mask is used to specify the fields to be overwritten in the + * `Asset` resource by the update. + * The values specified in the `update_mask` field are relative to the + * resource, not the full request. + * A field will be overwritten if it is in the mask. + * A single * value in the mask lets you to overwrite all fields. + * @param {google.cloud.migrationcenter.v1.Asset} request.asset + * Required. The resource being updated. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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 {@link protos.google.cloud.migrationcenter.v1.Asset|Asset}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/migration_center.update_asset.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_UpdateAsset_async + */ updateAsset( - request?: protos.google.cloud.migrationcenter.v1.IUpdateAssetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.migrationcenter.v1.IAsset, - protos.google.cloud.migrationcenter.v1.IUpdateAssetRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.IUpdateAssetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IAsset, + protos.google.cloud.migrationcenter.v1.IUpdateAssetRequest | undefined, + {} | undefined, + ] + >; updateAsset( - request: protos.google.cloud.migrationcenter.v1.IUpdateAssetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.migrationcenter.v1.IAsset, - protos.google.cloud.migrationcenter.v1.IUpdateAssetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IUpdateAssetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.migrationcenter.v1.IAsset, + | protos.google.cloud.migrationcenter.v1.IUpdateAssetRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateAsset( - request: protos.google.cloud.migrationcenter.v1.IUpdateAssetRequest, - callback: Callback< - protos.google.cloud.migrationcenter.v1.IAsset, - protos.google.cloud.migrationcenter.v1.IUpdateAssetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IUpdateAssetRequest, + callback: Callback< + protos.google.cloud.migrationcenter.v1.IAsset, + | protos.google.cloud.migrationcenter.v1.IUpdateAssetRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateAsset( - request?: protos.google.cloud.migrationcenter.v1.IUpdateAssetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.migrationcenter.v1.IAsset, - protos.google.cloud.migrationcenter.v1.IUpdateAssetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.migrationcenter.v1.IUpdateAssetRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.migrationcenter.v1.IAsset, - protos.google.cloud.migrationcenter.v1.IUpdateAssetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.migrationcenter.v1.IAsset, - protos.google.cloud.migrationcenter.v1.IUpdateAssetRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.migrationcenter.v1.IUpdateAssetRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.migrationcenter.v1.IAsset, + | protos.google.cloud.migrationcenter.v1.IUpdateAssetRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IAsset, + protos.google.cloud.migrationcenter.v1.IUpdateAssetRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'asset.name': request.asset!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'asset.name': request.asset!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateAsset request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.migrationcenter.v1.IAsset, - protos.google.cloud.migrationcenter.v1.IUpdateAssetRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.migrationcenter.v1.IAsset, + | protos.google.cloud.migrationcenter.v1.IUpdateAssetRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateAsset response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateAsset(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.migrationcenter.v1.IAsset, - protos.google.cloud.migrationcenter.v1.IUpdateAssetRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateAsset response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .updateAsset(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.migrationcenter.v1.IAsset, + ( + | protos.google.cloud.migrationcenter.v1.IUpdateAssetRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateAsset response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Updates the parameters of a list of assets. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for batch asset update. - * @param {number[]} request.requests - * Required. The request message specifying the resources to update. - * A maximum of 1000 assets can be modified in a batch. - * @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 {@link protos.google.cloud.migrationcenter.v1.BatchUpdateAssetsResponse|BatchUpdateAssetsResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/migration_center.batch_update_assets.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_BatchUpdateAssets_async - */ + /** + * Updates the parameters of a list of assets. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for batch asset update. + * @param {number[]} request.requests + * Required. The request message specifying the resources to update. + * A maximum of 1000 assets can be modified in a batch. + * @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 {@link protos.google.cloud.migrationcenter.v1.BatchUpdateAssetsResponse|BatchUpdateAssetsResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/migration_center.batch_update_assets.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_BatchUpdateAssets_async + */ batchUpdateAssets( - request?: protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsResponse, - protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsResponse, + ( + | protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsRequest + | undefined + ), + {} | undefined, + ] + >; batchUpdateAssets( - request: protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsResponse, - protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsResponse, + | protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsRequest + | null + | undefined, + {} | null | undefined + >, + ): void; batchUpdateAssets( - request: protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsRequest, - callback: Callback< - protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsResponse, - protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsRequest, + callback: Callback< + protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsResponse, + | protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsRequest + | null + | undefined, + {} | null | undefined + >, + ): void; batchUpdateAssets( - request?: protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsResponse, - protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsResponse, - protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsResponse, - protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsResponse, + | protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsResponse, + ( + | protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('batchUpdateAssets request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsResponse, - protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsResponse, + | protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('batchUpdateAssets response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.batchUpdateAssets(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsResponse, - protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsRequest|undefined, - {}|undefined - ]) => { - this._log.info('batchUpdateAssets response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .batchUpdateAssets(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsResponse, + ( + | protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('batchUpdateAssets response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Deletes an asset. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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 {@link protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/migration_center.delete_asset.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_DeleteAsset_async - */ + /** + * Deletes an asset. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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 {@link protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/migration_center.delete_asset.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_DeleteAsset_async + */ deleteAsset( - request?: protos.google.cloud.migrationcenter.v1.IDeleteAssetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.migrationcenter.v1.IDeleteAssetRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.IDeleteAssetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IDeleteAssetRequest | undefined, + {} | undefined, + ] + >; deleteAsset( - request: protos.google.cloud.migrationcenter.v1.IDeleteAssetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.migrationcenter.v1.IDeleteAssetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IDeleteAssetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.migrationcenter.v1.IDeleteAssetRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteAsset( - request: protos.google.cloud.migrationcenter.v1.IDeleteAssetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.migrationcenter.v1.IDeleteAssetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IDeleteAssetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.migrationcenter.v1.IDeleteAssetRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteAsset( - request?: protos.google.cloud.migrationcenter.v1.IDeleteAssetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.migrationcenter.v1.IDeleteAssetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.migrationcenter.v1.IDeleteAssetRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.migrationcenter.v1.IDeleteAssetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.migrationcenter.v1.IDeleteAssetRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.migrationcenter.v1.IDeleteAssetRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.migrationcenter.v1.IDeleteAssetRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IDeleteAssetRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('deleteAsset request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.migrationcenter.v1.IDeleteAssetRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.migrationcenter.v1.IDeleteAssetRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteAsset response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.deleteAsset(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.migrationcenter.v1.IDeleteAssetRequest|undefined, - {}|undefined - ]) => { - this._log.info('deleteAsset response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .deleteAsset(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.migrationcenter.v1.IDeleteAssetRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteAsset response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Deletes list of Assets. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for batch asset delete. - * @param {string[]} request.names - * Required. The IDs of the assets to delete. - * A maximum of 1000 assets can be deleted in a batch. - * Format: projects/{project}/locations/{location}/assets/{name}. - * @param {boolean} [request.allowMissing] - * Optional. When this value is set to `true` the request is a no-op for - * non-existing assets. See https://google.aip.dev/135#delete-if-existing for - * additional details. Default value is `false`. - * @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 {@link protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/migration_center.batch_delete_assets.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_BatchDeleteAssets_async - */ + /** + * Deletes list of Assets. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for batch asset delete. + * @param {string[]} request.names + * Required. The IDs of the assets to delete. + * A maximum of 1000 assets can be deleted in a batch. + * Format: projects/{project}/locations/{location}/assets/{name}. + * @param {boolean} [request.allowMissing] + * Optional. When this value is set to `true` the request is a no-op for + * non-existing assets. See https://google.aip.dev/135#delete-if-existing for + * additional details. Default value is `false`. + * @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 {@link protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/migration_center.batch_delete_assets.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_BatchDeleteAssets_async + */ batchDeleteAssets( - request?: protos.google.cloud.migrationcenter.v1.IBatchDeleteAssetsRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.migrationcenter.v1.IBatchDeleteAssetsRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.IBatchDeleteAssetsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.migrationcenter.v1.IBatchDeleteAssetsRequest + | undefined + ), + {} | undefined, + ] + >; batchDeleteAssets( - request: protos.google.cloud.migrationcenter.v1.IBatchDeleteAssetsRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.migrationcenter.v1.IBatchDeleteAssetsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IBatchDeleteAssetsRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.migrationcenter.v1.IBatchDeleteAssetsRequest + | null + | undefined, + {} | null | undefined + >, + ): void; batchDeleteAssets( - request: protos.google.cloud.migrationcenter.v1.IBatchDeleteAssetsRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.migrationcenter.v1.IBatchDeleteAssetsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IBatchDeleteAssetsRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.migrationcenter.v1.IBatchDeleteAssetsRequest + | null + | undefined, + {} | null | undefined + >, + ): void; batchDeleteAssets( - request?: protos.google.cloud.migrationcenter.v1.IBatchDeleteAssetsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.migrationcenter.v1.IBatchDeleteAssetsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.migrationcenter.v1.IBatchDeleteAssetsRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.migrationcenter.v1.IBatchDeleteAssetsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.migrationcenter.v1.IBatchDeleteAssetsRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.migrationcenter.v1.IBatchDeleteAssetsRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.migrationcenter.v1.IBatchDeleteAssetsRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.migrationcenter.v1.IBatchDeleteAssetsRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('batchDeleteAssets request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.migrationcenter.v1.IBatchDeleteAssetsRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.migrationcenter.v1.IBatchDeleteAssetsRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('batchDeleteAssets response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.batchDeleteAssets(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.migrationcenter.v1.IBatchDeleteAssetsRequest|undefined, - {}|undefined - ]) => { - this._log.info('batchDeleteAssets response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .batchDeleteAssets(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.migrationcenter.v1.IBatchDeleteAssetsRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('batchDeleteAssets response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Reports a set of frames. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent of the resource. - * @param {google.cloud.migrationcenter.v1.Frames} request.frames - * Collection of frames data. - * @param {string} request.source - * Required. Reference to a source. - * @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 {@link protos.google.cloud.migrationcenter.v1.ReportAssetFramesResponse|ReportAssetFramesResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/migration_center.report_asset_frames.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_ReportAssetFrames_async - */ + /** + * Reports a set of frames. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent of the resource. + * @param {google.cloud.migrationcenter.v1.Frames} request.frames + * Collection of frames data. + * @param {string} request.source + * Required. Reference to a source. + * @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 {@link protos.google.cloud.migrationcenter.v1.ReportAssetFramesResponse|ReportAssetFramesResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/migration_center.report_asset_frames.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_ReportAssetFrames_async + */ reportAssetFrames( - request?: protos.google.cloud.migrationcenter.v1.IReportAssetFramesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.migrationcenter.v1.IReportAssetFramesResponse, - protos.google.cloud.migrationcenter.v1.IReportAssetFramesRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.IReportAssetFramesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IReportAssetFramesResponse, + ( + | protos.google.cloud.migrationcenter.v1.IReportAssetFramesRequest + | undefined + ), + {} | undefined, + ] + >; reportAssetFrames( - request: protos.google.cloud.migrationcenter.v1.IReportAssetFramesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.migrationcenter.v1.IReportAssetFramesResponse, - protos.google.cloud.migrationcenter.v1.IReportAssetFramesRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IReportAssetFramesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.migrationcenter.v1.IReportAssetFramesResponse, + | protos.google.cloud.migrationcenter.v1.IReportAssetFramesRequest + | null + | undefined, + {} | null | undefined + >, + ): void; reportAssetFrames( - request: protos.google.cloud.migrationcenter.v1.IReportAssetFramesRequest, - callback: Callback< - protos.google.cloud.migrationcenter.v1.IReportAssetFramesResponse, - protos.google.cloud.migrationcenter.v1.IReportAssetFramesRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IReportAssetFramesRequest, + callback: Callback< + protos.google.cloud.migrationcenter.v1.IReportAssetFramesResponse, + | protos.google.cloud.migrationcenter.v1.IReportAssetFramesRequest + | null + | undefined, + {} | null | undefined + >, + ): void; reportAssetFrames( - request?: protos.google.cloud.migrationcenter.v1.IReportAssetFramesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.migrationcenter.v1.IReportAssetFramesResponse, - protos.google.cloud.migrationcenter.v1.IReportAssetFramesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.migrationcenter.v1.IReportAssetFramesRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.migrationcenter.v1.IReportAssetFramesResponse, - protos.google.cloud.migrationcenter.v1.IReportAssetFramesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.migrationcenter.v1.IReportAssetFramesResponse, - protos.google.cloud.migrationcenter.v1.IReportAssetFramesRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.migrationcenter.v1.IReportAssetFramesRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.migrationcenter.v1.IReportAssetFramesResponse, + | protos.google.cloud.migrationcenter.v1.IReportAssetFramesRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IReportAssetFramesResponse, + ( + | protos.google.cloud.migrationcenter.v1.IReportAssetFramesRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('reportAssetFrames request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.migrationcenter.v1.IReportAssetFramesResponse, - protos.google.cloud.migrationcenter.v1.IReportAssetFramesRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.migrationcenter.v1.IReportAssetFramesResponse, + | protos.google.cloud.migrationcenter.v1.IReportAssetFramesRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('reportAssetFrames response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.reportAssetFrames(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.migrationcenter.v1.IReportAssetFramesResponse, - protos.google.cloud.migrationcenter.v1.IReportAssetFramesRequest|undefined, - {}|undefined - ]) => { - this._log.info('reportAssetFrames response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .reportAssetFrames(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.migrationcenter.v1.IReportAssetFramesResponse, + ( + | protos.google.cloud.migrationcenter.v1.IReportAssetFramesRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('reportAssetFrames response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Aggregates the requested fields based on provided function. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for `AggregateAssetsValuesRequest`. - * @param {number[]} request.aggregations - * Array of aggregations to perform. - * Up to 25 aggregations can be defined. - * @param {string} request.filter - * The aggregation will be performed on assets that match the provided filter. - * @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 {@link protos.google.cloud.migrationcenter.v1.AggregateAssetsValuesResponse|AggregateAssetsValuesResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/migration_center.aggregate_assets_values.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_AggregateAssetsValues_async - */ + /** + * Aggregates the requested fields based on provided function. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for `AggregateAssetsValuesRequest`. + * @param {number[]} request.aggregations + * Array of aggregations to perform. + * Up to 25 aggregations can be defined. + * @param {string} request.filter + * The aggregation will be performed on assets that match the provided filter. + * @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 {@link protos.google.cloud.migrationcenter.v1.AggregateAssetsValuesResponse|AggregateAssetsValuesResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/migration_center.aggregate_assets_values.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_AggregateAssetsValues_async + */ aggregateAssetsValues( - request?: protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesResponse, - protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesResponse, + ( + | protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesRequest + | undefined + ), + {} | undefined, + ] + >; aggregateAssetsValues( - request: protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesResponse, - protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesResponse, + | protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesRequest + | null + | undefined, + {} | null | undefined + >, + ): void; aggregateAssetsValues( - request: protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesRequest, - callback: Callback< - protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesResponse, - protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesRequest, + callback: Callback< + protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesResponse, + | protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesRequest + | null + | undefined, + {} | null | undefined + >, + ): void; aggregateAssetsValues( - request?: protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesResponse, - protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesResponse, - protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesResponse, - protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesResponse, + | protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesResponse, + ( + | protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('aggregateAssetsValues request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesResponse, - protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesResponse, + | protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('aggregateAssetsValues response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.aggregateAssetsValues(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesResponse, - protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesRequest|undefined, - {}|undefined - ]) => { - this._log.info('aggregateAssetsValues response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .aggregateAssetsValues(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesResponse, + ( + | protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('aggregateAssetsValues response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets the details of an import job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource. - * @param {google.cloud.migrationcenter.v1.ImportJobView} [request.view] - * Optional. The level of details of the import job. - * Default value is FULL. - * @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 {@link protos.google.cloud.migrationcenter.v1.ImportJob|ImportJob}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/migration_center.get_import_job.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_GetImportJob_async - */ + /** + * Gets the details of an import job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource. + * @param {google.cloud.migrationcenter.v1.ImportJobView} [request.view] + * Optional. The level of details of the import job. + * Default value is FULL. + * @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 {@link protos.google.cloud.migrationcenter.v1.ImportJob|ImportJob}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/migration_center.get_import_job.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_GetImportJob_async + */ getImportJob( - request?: protos.google.cloud.migrationcenter.v1.IGetImportJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.migrationcenter.v1.IImportJob, - protos.google.cloud.migrationcenter.v1.IGetImportJobRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.IGetImportJobRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IImportJob, + protos.google.cloud.migrationcenter.v1.IGetImportJobRequest | undefined, + {} | undefined, + ] + >; getImportJob( - request: protos.google.cloud.migrationcenter.v1.IGetImportJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.migrationcenter.v1.IImportJob, - protos.google.cloud.migrationcenter.v1.IGetImportJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IGetImportJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.migrationcenter.v1.IImportJob, + | protos.google.cloud.migrationcenter.v1.IGetImportJobRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getImportJob( - request: protos.google.cloud.migrationcenter.v1.IGetImportJobRequest, - callback: Callback< - protos.google.cloud.migrationcenter.v1.IImportJob, - protos.google.cloud.migrationcenter.v1.IGetImportJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IGetImportJobRequest, + callback: Callback< + protos.google.cloud.migrationcenter.v1.IImportJob, + | protos.google.cloud.migrationcenter.v1.IGetImportJobRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getImportJob( - request?: protos.google.cloud.migrationcenter.v1.IGetImportJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.migrationcenter.v1.IImportJob, - protos.google.cloud.migrationcenter.v1.IGetImportJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.migrationcenter.v1.IGetImportJobRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.migrationcenter.v1.IImportJob, - protos.google.cloud.migrationcenter.v1.IGetImportJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.migrationcenter.v1.IImportJob, - protos.google.cloud.migrationcenter.v1.IGetImportJobRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.migrationcenter.v1.IGetImportJobRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.migrationcenter.v1.IImportJob, + | protos.google.cloud.migrationcenter.v1.IGetImportJobRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IImportJob, + protos.google.cloud.migrationcenter.v1.IGetImportJobRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getImportJob request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.migrationcenter.v1.IImportJob, - protos.google.cloud.migrationcenter.v1.IGetImportJobRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.migrationcenter.v1.IImportJob, + | protos.google.cloud.migrationcenter.v1.IGetImportJobRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getImportJob response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getImportJob(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.migrationcenter.v1.IImportJob, - protos.google.cloud.migrationcenter.v1.IGetImportJobRequest|undefined, - {}|undefined - ]) => { - this._log.info('getImportJob response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getImportJob(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.migrationcenter.v1.IImportJob, + ( + | protos.google.cloud.migrationcenter.v1.IGetImportJobRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getImportJob response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets an import data file. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the ImportDataFile. - * @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 {@link protos.google.cloud.migrationcenter.v1.ImportDataFile|ImportDataFile}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/migration_center.get_import_data_file.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_GetImportDataFile_async - */ + /** + * Gets an import data file. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the ImportDataFile. + * @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 {@link protos.google.cloud.migrationcenter.v1.ImportDataFile|ImportDataFile}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/migration_center.get_import_data_file.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_GetImportDataFile_async + */ getImportDataFile( - request?: protos.google.cloud.migrationcenter.v1.IGetImportDataFileRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.migrationcenter.v1.IImportDataFile, - protos.google.cloud.migrationcenter.v1.IGetImportDataFileRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.IGetImportDataFileRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IImportDataFile, + ( + | protos.google.cloud.migrationcenter.v1.IGetImportDataFileRequest + | undefined + ), + {} | undefined, + ] + >; getImportDataFile( - request: protos.google.cloud.migrationcenter.v1.IGetImportDataFileRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.migrationcenter.v1.IImportDataFile, - protos.google.cloud.migrationcenter.v1.IGetImportDataFileRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IGetImportDataFileRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.migrationcenter.v1.IImportDataFile, + | protos.google.cloud.migrationcenter.v1.IGetImportDataFileRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getImportDataFile( - request: protos.google.cloud.migrationcenter.v1.IGetImportDataFileRequest, - callback: Callback< - protos.google.cloud.migrationcenter.v1.IImportDataFile, - protos.google.cloud.migrationcenter.v1.IGetImportDataFileRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IGetImportDataFileRequest, + callback: Callback< + protos.google.cloud.migrationcenter.v1.IImportDataFile, + | protos.google.cloud.migrationcenter.v1.IGetImportDataFileRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getImportDataFile( - request?: protos.google.cloud.migrationcenter.v1.IGetImportDataFileRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.migrationcenter.v1.IImportDataFile, - protos.google.cloud.migrationcenter.v1.IGetImportDataFileRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.migrationcenter.v1.IGetImportDataFileRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.migrationcenter.v1.IImportDataFile, - protos.google.cloud.migrationcenter.v1.IGetImportDataFileRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.migrationcenter.v1.IImportDataFile, - protos.google.cloud.migrationcenter.v1.IGetImportDataFileRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.migrationcenter.v1.IGetImportDataFileRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.migrationcenter.v1.IImportDataFile, + | protos.google.cloud.migrationcenter.v1.IGetImportDataFileRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IImportDataFile, + ( + | protos.google.cloud.migrationcenter.v1.IGetImportDataFileRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getImportDataFile request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.migrationcenter.v1.IImportDataFile, - protos.google.cloud.migrationcenter.v1.IGetImportDataFileRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.migrationcenter.v1.IImportDataFile, + | protos.google.cloud.migrationcenter.v1.IGetImportDataFileRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getImportDataFile response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getImportDataFile(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.migrationcenter.v1.IImportDataFile, - protos.google.cloud.migrationcenter.v1.IGetImportDataFileRequest|undefined, - {}|undefined - ]) => { - this._log.info('getImportDataFile response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getImportDataFile(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.migrationcenter.v1.IImportDataFile, + ( + | protos.google.cloud.migrationcenter.v1.IGetImportDataFileRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getImportDataFile response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets the details of a group. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource. - * @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 {@link protos.google.cloud.migrationcenter.v1.Group|Group}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/migration_center.get_group.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_GetGroup_async - */ + /** + * Gets the details of a group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource. + * @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 {@link protos.google.cloud.migrationcenter.v1.Group|Group}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/migration_center.get_group.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_GetGroup_async + */ getGroup( - request?: protos.google.cloud.migrationcenter.v1.IGetGroupRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.migrationcenter.v1.IGroup, - protos.google.cloud.migrationcenter.v1.IGetGroupRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.IGetGroupRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IGetGroupRequest | undefined, + {} | undefined, + ] + >; getGroup( - request: protos.google.cloud.migrationcenter.v1.IGetGroupRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.migrationcenter.v1.IGroup, - protos.google.cloud.migrationcenter.v1.IGetGroupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IGetGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.migrationcenter.v1.IGroup, + | protos.google.cloud.migrationcenter.v1.IGetGroupRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getGroup( - request: protos.google.cloud.migrationcenter.v1.IGetGroupRequest, - callback: Callback< - protos.google.cloud.migrationcenter.v1.IGroup, - protos.google.cloud.migrationcenter.v1.IGetGroupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IGetGroupRequest, + callback: Callback< + protos.google.cloud.migrationcenter.v1.IGroup, + | protos.google.cloud.migrationcenter.v1.IGetGroupRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getGroup( - request?: protos.google.cloud.migrationcenter.v1.IGetGroupRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.migrationcenter.v1.IGroup, - protos.google.cloud.migrationcenter.v1.IGetGroupRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.migrationcenter.v1.IGetGroupRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.migrationcenter.v1.IGroup, - protos.google.cloud.migrationcenter.v1.IGetGroupRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.migrationcenter.v1.IGroup, - protos.google.cloud.migrationcenter.v1.IGetGroupRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.migrationcenter.v1.IGetGroupRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.migrationcenter.v1.IGroup, + | protos.google.cloud.migrationcenter.v1.IGetGroupRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IGetGroupRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getGroup request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.migrationcenter.v1.IGroup, - protos.google.cloud.migrationcenter.v1.IGetGroupRequest|null|undefined, - {}|null|undefined>|undefined = callback - ? (error, response, options, rawResponse) => { - this._log.info('getGroup response %j', response); + const wrappedCallback: + | Callback< + protos.google.cloud.migrationcenter.v1.IGroup, + | protos.google.cloud.migrationcenter.v1.IGetGroupRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getGroup response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getGroup(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.migrationcenter.v1.IGroup, - protos.google.cloud.migrationcenter.v1.IGetGroupRequest|undefined, - {}|undefined - ]) => { - this._log.info('getGroup response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getGroup(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IGetGroupRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getGroup response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets the details of an error frame. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the frame to retrieve. - * Format: - * projects/{project}/locations/{location}/sources/{source}/errorFrames/{error_frame} - * @param {google.cloud.migrationcenter.v1.ErrorFrameView} [request.view] - * Optional. An optional view mode to control the level of details for the - * frame. The default is a basic frame view. - * @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 {@link protos.google.cloud.migrationcenter.v1.ErrorFrame|ErrorFrame}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/migration_center.get_error_frame.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_GetErrorFrame_async - */ + /** + * Gets the details of an error frame. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the frame to retrieve. + * Format: + * projects/{project}/locations/{location}/sources/{source}/errorFrames/{error_frame} + * @param {google.cloud.migrationcenter.v1.ErrorFrameView} [request.view] + * Optional. An optional view mode to control the level of details for the + * frame. The default is a basic frame view. + * @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 {@link protos.google.cloud.migrationcenter.v1.ErrorFrame|ErrorFrame}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/migration_center.get_error_frame.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_GetErrorFrame_async + */ getErrorFrame( - request?: protos.google.cloud.migrationcenter.v1.IGetErrorFrameRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.migrationcenter.v1.IErrorFrame, - protos.google.cloud.migrationcenter.v1.IGetErrorFrameRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.IGetErrorFrameRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IErrorFrame, + protos.google.cloud.migrationcenter.v1.IGetErrorFrameRequest | undefined, + {} | undefined, + ] + >; getErrorFrame( - request: protos.google.cloud.migrationcenter.v1.IGetErrorFrameRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.migrationcenter.v1.IErrorFrame, - protos.google.cloud.migrationcenter.v1.IGetErrorFrameRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IGetErrorFrameRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.migrationcenter.v1.IErrorFrame, + | protos.google.cloud.migrationcenter.v1.IGetErrorFrameRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getErrorFrame( - request: protos.google.cloud.migrationcenter.v1.IGetErrorFrameRequest, - callback: Callback< - protos.google.cloud.migrationcenter.v1.IErrorFrame, - protos.google.cloud.migrationcenter.v1.IGetErrorFrameRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IGetErrorFrameRequest, + callback: Callback< + protos.google.cloud.migrationcenter.v1.IErrorFrame, + | protos.google.cloud.migrationcenter.v1.IGetErrorFrameRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getErrorFrame( - request?: protos.google.cloud.migrationcenter.v1.IGetErrorFrameRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.migrationcenter.v1.IErrorFrame, - protos.google.cloud.migrationcenter.v1.IGetErrorFrameRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.migrationcenter.v1.IGetErrorFrameRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.migrationcenter.v1.IErrorFrame, - protos.google.cloud.migrationcenter.v1.IGetErrorFrameRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.migrationcenter.v1.IErrorFrame, - protos.google.cloud.migrationcenter.v1.IGetErrorFrameRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.migrationcenter.v1.IGetErrorFrameRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.migrationcenter.v1.IErrorFrame, + | protos.google.cloud.migrationcenter.v1.IGetErrorFrameRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IErrorFrame, + protos.google.cloud.migrationcenter.v1.IGetErrorFrameRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getErrorFrame request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.migrationcenter.v1.IErrorFrame, - protos.google.cloud.migrationcenter.v1.IGetErrorFrameRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.migrationcenter.v1.IErrorFrame, + | protos.google.cloud.migrationcenter.v1.IGetErrorFrameRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getErrorFrame response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getErrorFrame(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.migrationcenter.v1.IErrorFrame, - protos.google.cloud.migrationcenter.v1.IGetErrorFrameRequest|undefined, - {}|undefined - ]) => { - this._log.info('getErrorFrame response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getErrorFrame(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.migrationcenter.v1.IErrorFrame, + ( + | protos.google.cloud.migrationcenter.v1.IGetErrorFrameRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getErrorFrame response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets the details of a source. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource. - * @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 {@link protos.google.cloud.migrationcenter.v1.Source|Source}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/migration_center.get_source.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_GetSource_async - */ + /** + * Gets the details of a source. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource. + * @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 {@link protos.google.cloud.migrationcenter.v1.Source|Source}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/migration_center.get_source.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_GetSource_async + */ getSource( - request?: protos.google.cloud.migrationcenter.v1.IGetSourceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.migrationcenter.v1.ISource, - protos.google.cloud.migrationcenter.v1.IGetSourceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.IGetSourceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.ISource, + protos.google.cloud.migrationcenter.v1.IGetSourceRequest | undefined, + {} | undefined, + ] + >; getSource( - request: protos.google.cloud.migrationcenter.v1.IGetSourceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.migrationcenter.v1.ISource, - protos.google.cloud.migrationcenter.v1.IGetSourceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IGetSourceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.migrationcenter.v1.ISource, + | protos.google.cloud.migrationcenter.v1.IGetSourceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getSource( - request: protos.google.cloud.migrationcenter.v1.IGetSourceRequest, - callback: Callback< - protos.google.cloud.migrationcenter.v1.ISource, - protos.google.cloud.migrationcenter.v1.IGetSourceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IGetSourceRequest, + callback: Callback< + protos.google.cloud.migrationcenter.v1.ISource, + | protos.google.cloud.migrationcenter.v1.IGetSourceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getSource( - request?: protos.google.cloud.migrationcenter.v1.IGetSourceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.migrationcenter.v1.ISource, - protos.google.cloud.migrationcenter.v1.IGetSourceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.migrationcenter.v1.IGetSourceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.migrationcenter.v1.ISource, - protos.google.cloud.migrationcenter.v1.IGetSourceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.migrationcenter.v1.ISource, - protos.google.cloud.migrationcenter.v1.IGetSourceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.migrationcenter.v1.IGetSourceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.migrationcenter.v1.ISource, + | protos.google.cloud.migrationcenter.v1.IGetSourceRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.ISource, + protos.google.cloud.migrationcenter.v1.IGetSourceRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getSource request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.migrationcenter.v1.ISource, - protos.google.cloud.migrationcenter.v1.IGetSourceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.migrationcenter.v1.ISource, + | protos.google.cloud.migrationcenter.v1.IGetSourceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getSource response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getSource(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.migrationcenter.v1.ISource, - protos.google.cloud.migrationcenter.v1.IGetSourceRequest|undefined, - {}|undefined - ]) => { - this._log.info('getSource response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getSource(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.migrationcenter.v1.ISource, + protos.google.cloud.migrationcenter.v1.IGetSourceRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getSource response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets the details of a preference set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource. - * @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 {@link protos.google.cloud.migrationcenter.v1.PreferenceSet|PreferenceSet}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/migration_center.get_preference_set.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_GetPreferenceSet_async - */ + /** + * Gets the details of a preference set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource. + * @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 {@link protos.google.cloud.migrationcenter.v1.PreferenceSet|PreferenceSet}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/migration_center.get_preference_set.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_GetPreferenceSet_async + */ getPreferenceSet( - request?: protos.google.cloud.migrationcenter.v1.IGetPreferenceSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.migrationcenter.v1.IPreferenceSet, - protos.google.cloud.migrationcenter.v1.IGetPreferenceSetRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.IGetPreferenceSetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IPreferenceSet, + ( + | protos.google.cloud.migrationcenter.v1.IGetPreferenceSetRequest + | undefined + ), + {} | undefined, + ] + >; getPreferenceSet( - request: protos.google.cloud.migrationcenter.v1.IGetPreferenceSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.migrationcenter.v1.IPreferenceSet, - protos.google.cloud.migrationcenter.v1.IGetPreferenceSetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IGetPreferenceSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.migrationcenter.v1.IPreferenceSet, + | protos.google.cloud.migrationcenter.v1.IGetPreferenceSetRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getPreferenceSet( - request: protos.google.cloud.migrationcenter.v1.IGetPreferenceSetRequest, - callback: Callback< - protos.google.cloud.migrationcenter.v1.IPreferenceSet, - protos.google.cloud.migrationcenter.v1.IGetPreferenceSetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IGetPreferenceSetRequest, + callback: Callback< + protos.google.cloud.migrationcenter.v1.IPreferenceSet, + | protos.google.cloud.migrationcenter.v1.IGetPreferenceSetRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getPreferenceSet( - request?: protos.google.cloud.migrationcenter.v1.IGetPreferenceSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.migrationcenter.v1.IPreferenceSet, - protos.google.cloud.migrationcenter.v1.IGetPreferenceSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.migrationcenter.v1.IGetPreferenceSetRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.migrationcenter.v1.IPreferenceSet, - protos.google.cloud.migrationcenter.v1.IGetPreferenceSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.migrationcenter.v1.IPreferenceSet, - protos.google.cloud.migrationcenter.v1.IGetPreferenceSetRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.migrationcenter.v1.IGetPreferenceSetRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.migrationcenter.v1.IPreferenceSet, + | protos.google.cloud.migrationcenter.v1.IGetPreferenceSetRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IPreferenceSet, + ( + | protos.google.cloud.migrationcenter.v1.IGetPreferenceSetRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getPreferenceSet request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.migrationcenter.v1.IPreferenceSet, - protos.google.cloud.migrationcenter.v1.IGetPreferenceSetRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.migrationcenter.v1.IPreferenceSet, + | protos.google.cloud.migrationcenter.v1.IGetPreferenceSetRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getPreferenceSet response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getPreferenceSet(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.migrationcenter.v1.IPreferenceSet, - protos.google.cloud.migrationcenter.v1.IGetPreferenceSetRequest|undefined, - {}|undefined - ]) => { - this._log.info('getPreferenceSet response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getPreferenceSet(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.migrationcenter.v1.IPreferenceSet, + ( + | protos.google.cloud.migrationcenter.v1.IGetPreferenceSetRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getPreferenceSet response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets the details of regional settings. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource. - * @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 {@link protos.google.cloud.migrationcenter.v1.Settings|Settings}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/migration_center.get_settings.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_GetSettings_async - */ + /** + * Gets the details of regional settings. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource. + * @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 {@link protos.google.cloud.migrationcenter.v1.Settings|Settings}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/migration_center.get_settings.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_GetSettings_async + */ getSettings( - request?: protos.google.cloud.migrationcenter.v1.IGetSettingsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.migrationcenter.v1.ISettings, - protos.google.cloud.migrationcenter.v1.IGetSettingsRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.IGetSettingsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.ISettings, + protos.google.cloud.migrationcenter.v1.IGetSettingsRequest | undefined, + {} | undefined, + ] + >; getSettings( - request: protos.google.cloud.migrationcenter.v1.IGetSettingsRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.migrationcenter.v1.ISettings, - protos.google.cloud.migrationcenter.v1.IGetSettingsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IGetSettingsRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.migrationcenter.v1.ISettings, + | protos.google.cloud.migrationcenter.v1.IGetSettingsRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getSettings( - request: protos.google.cloud.migrationcenter.v1.IGetSettingsRequest, - callback: Callback< - protos.google.cloud.migrationcenter.v1.ISettings, - protos.google.cloud.migrationcenter.v1.IGetSettingsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IGetSettingsRequest, + callback: Callback< + protos.google.cloud.migrationcenter.v1.ISettings, + | protos.google.cloud.migrationcenter.v1.IGetSettingsRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getSettings( - request?: protos.google.cloud.migrationcenter.v1.IGetSettingsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.migrationcenter.v1.ISettings, - protos.google.cloud.migrationcenter.v1.IGetSettingsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.migrationcenter.v1.IGetSettingsRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.migrationcenter.v1.ISettings, - protos.google.cloud.migrationcenter.v1.IGetSettingsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.migrationcenter.v1.ISettings, - protos.google.cloud.migrationcenter.v1.IGetSettingsRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.migrationcenter.v1.IGetSettingsRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.migrationcenter.v1.ISettings, + | protos.google.cloud.migrationcenter.v1.IGetSettingsRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.ISettings, + protos.google.cloud.migrationcenter.v1.IGetSettingsRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getSettings request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.migrationcenter.v1.ISettings, - protos.google.cloud.migrationcenter.v1.IGetSettingsRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.migrationcenter.v1.ISettings, + | protos.google.cloud.migrationcenter.v1.IGetSettingsRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getSettings response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getSettings(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.migrationcenter.v1.ISettings, - protos.google.cloud.migrationcenter.v1.IGetSettingsRequest|undefined, - {}|undefined - ]) => { - this._log.info('getSettings response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getSettings(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.migrationcenter.v1.ISettings, + ( + | protos.google.cloud.migrationcenter.v1.IGetSettingsRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getSettings response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single ReportConfig. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource. - * @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 {@link protos.google.cloud.migrationcenter.v1.ReportConfig|ReportConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/migration_center.get_report_config.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_GetReportConfig_async - */ + /** + * Gets details of a single ReportConfig. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource. + * @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 {@link protos.google.cloud.migrationcenter.v1.ReportConfig|ReportConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/migration_center.get_report_config.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_GetReportConfig_async + */ getReportConfig( - request?: protos.google.cloud.migrationcenter.v1.IGetReportConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.migrationcenter.v1.IReportConfig, - protos.google.cloud.migrationcenter.v1.IGetReportConfigRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.IGetReportConfigRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IReportConfig, + ( + | protos.google.cloud.migrationcenter.v1.IGetReportConfigRequest + | undefined + ), + {} | undefined, + ] + >; getReportConfig( - request: protos.google.cloud.migrationcenter.v1.IGetReportConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.migrationcenter.v1.IReportConfig, - protos.google.cloud.migrationcenter.v1.IGetReportConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IGetReportConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.migrationcenter.v1.IReportConfig, + | protos.google.cloud.migrationcenter.v1.IGetReportConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getReportConfig( - request: protos.google.cloud.migrationcenter.v1.IGetReportConfigRequest, - callback: Callback< - protos.google.cloud.migrationcenter.v1.IReportConfig, - protos.google.cloud.migrationcenter.v1.IGetReportConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IGetReportConfigRequest, + callback: Callback< + protos.google.cloud.migrationcenter.v1.IReportConfig, + | protos.google.cloud.migrationcenter.v1.IGetReportConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getReportConfig( - request?: protos.google.cloud.migrationcenter.v1.IGetReportConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.migrationcenter.v1.IReportConfig, - protos.google.cloud.migrationcenter.v1.IGetReportConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.migrationcenter.v1.IGetReportConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.migrationcenter.v1.IReportConfig, - protos.google.cloud.migrationcenter.v1.IGetReportConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.migrationcenter.v1.IReportConfig, - protos.google.cloud.migrationcenter.v1.IGetReportConfigRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.migrationcenter.v1.IGetReportConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.migrationcenter.v1.IReportConfig, + | protos.google.cloud.migrationcenter.v1.IGetReportConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IReportConfig, + ( + | protos.google.cloud.migrationcenter.v1.IGetReportConfigRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getReportConfig request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.migrationcenter.v1.IReportConfig, - protos.google.cloud.migrationcenter.v1.IGetReportConfigRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.migrationcenter.v1.IReportConfig, + | protos.google.cloud.migrationcenter.v1.IGetReportConfigRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getReportConfig response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getReportConfig(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.migrationcenter.v1.IReportConfig, - protos.google.cloud.migrationcenter.v1.IGetReportConfigRequest|undefined, - {}|undefined - ]) => { - this._log.info('getReportConfig response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getReportConfig(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.migrationcenter.v1.IReportConfig, + ( + | protos.google.cloud.migrationcenter.v1.IGetReportConfigRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getReportConfig response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single Report. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource. - * @param {google.cloud.migrationcenter.v1.ReportView} request.view - * Determines what information to retrieve for the Report. - * @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 {@link protos.google.cloud.migrationcenter.v1.Report|Report}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/migration_center.get_report.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_GetReport_async - */ - getReport( - request?: protos.google.cloud.migrationcenter.v1.IGetReportRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.migrationcenter.v1.IReport, - protos.google.cloud.migrationcenter.v1.IGetReportRequest|undefined, {}|undefined - ]>; + /** + * Gets details of a single Report. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource. + * @param {google.cloud.migrationcenter.v1.ReportView} request.view + * Determines what information to retrieve for the Report. + * @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 {@link protos.google.cloud.migrationcenter.v1.Report|Report}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/migration_center.get_report.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_GetReport_async + */ getReport( - request: protos.google.cloud.migrationcenter.v1.IGetReportRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.migrationcenter.v1.IReport, - protos.google.cloud.migrationcenter.v1.IGetReportRequest|null|undefined, - {}|null|undefined>): void; + request?: protos.google.cloud.migrationcenter.v1.IGetReportRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IReport, + protos.google.cloud.migrationcenter.v1.IGetReportRequest | undefined, + {} | undefined, + ] + >; getReport( - request: protos.google.cloud.migrationcenter.v1.IGetReportRequest, - callback: Callback< - protos.google.cloud.migrationcenter.v1.IReport, - protos.google.cloud.migrationcenter.v1.IGetReportRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IGetReportRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.migrationcenter.v1.IReport, + | protos.google.cloud.migrationcenter.v1.IGetReportRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getReport( - request?: protos.google.cloud.migrationcenter.v1.IGetReportRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.migrationcenter.v1.IReport, - protos.google.cloud.migrationcenter.v1.IGetReportRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request: protos.google.cloud.migrationcenter.v1.IGetReportRequest, + callback: Callback< + protos.google.cloud.migrationcenter.v1.IReport, + | protos.google.cloud.migrationcenter.v1.IGetReportRequest + | null + | undefined, + {} | null | undefined + >, + ): void; + getReport( + request?: protos.google.cloud.migrationcenter.v1.IGetReportRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.migrationcenter.v1.IReport, - protos.google.cloud.migrationcenter.v1.IGetReportRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.migrationcenter.v1.IReport, - protos.google.cloud.migrationcenter.v1.IGetReportRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.migrationcenter.v1.IGetReportRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.migrationcenter.v1.IReport, + | protos.google.cloud.migrationcenter.v1.IGetReportRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IReport, + protos.google.cloud.migrationcenter.v1.IGetReportRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getReport request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.migrationcenter.v1.IReport, - protos.google.cloud.migrationcenter.v1.IGetReportRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.migrationcenter.v1.IReport, + | protos.google.cloud.migrationcenter.v1.IGetReportRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getReport response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getReport(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.migrationcenter.v1.IReport, - protos.google.cloud.migrationcenter.v1.IGetReportRequest|undefined, - {}|undefined - ]) => { - this._log.info('getReport response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getReport(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.migrationcenter.v1.IReport, + protos.google.cloud.migrationcenter.v1.IGetReportRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getReport response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates an import job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Value for parent. - * @param {string} request.importJobId - * Required. ID of the import job. - * @param {google.cloud.migrationcenter.v1.ImportJob} request.importJob - * Required. The resource being created. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/migration_center.create_import_job.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_CreateImportJob_async - */ + /** + * Creates an import job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Value for parent. + * @param {string} request.importJobId + * Required. ID of the import job. + * @param {google.cloud.migrationcenter.v1.ImportJob} request.importJob + * Required. The resource being created. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/migration_center.create_import_job.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_CreateImportJob_async + */ createImportJob( - request?: protos.google.cloud.migrationcenter.v1.ICreateImportJobRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.ICreateImportJobRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.migrationcenter.v1.IImportJob, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createImportJob( - request: protos.google.cloud.migrationcenter.v1.ICreateImportJobRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.ICreateImportJobRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IImportJob, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createImportJob( - request: protos.google.cloud.migrationcenter.v1.ICreateImportJobRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.ICreateImportJobRequest, + callback: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IImportJob, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createImportJob( - request?: protos.google.cloud.migrationcenter.v1.ICreateImportJobRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.migrationcenter.v1.ICreateImportJobRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IImportJob, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IImportJob, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.migrationcenter.v1.IImportJob, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IImportJob, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createImportJob response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createImportJob request %j', request); - return this.innerApiCalls.createImportJob(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createImportJob response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createImportJob(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.migrationcenter.v1.IImportJob, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createImportJob response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createImportJob()`. - * @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/migration_center.create_import_job.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_CreateImportJob_async - */ - async checkCreateImportJobProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createImportJob()`. + * @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/migration_center.create_import_job.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_CreateImportJob_async + */ + async checkCreateImportJobProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.migrationcenter.v1.ImportJob, + protos.google.cloud.migrationcenter.v1.OperationMetadata + > + > { this._log.info('createImportJob long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createImportJob, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createImportJob, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.migrationcenter.v1.ImportJob, + protos.google.cloud.migrationcenter.v1.OperationMetadata + >; } -/** - * Deletes an import job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {boolean} [request.force] - * Optional. If set to `true`, any `ImportDataFiles` of this job will also be - * deleted If set to `false`, the request only works if the job has no data - * files. - * @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/migration_center.delete_import_job.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_DeleteImportJob_async - */ + /** + * Deletes an import job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {boolean} [request.force] + * Optional. If set to `true`, any `ImportDataFiles` of this job will also be + * deleted If set to `false`, the request only works if the job has no data + * files. + * @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/migration_center.delete_import_job.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_DeleteImportJob_async + */ deleteImportJob( - request?: protos.google.cloud.migrationcenter.v1.IDeleteImportJobRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.IDeleteImportJobRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteImportJob( - request: protos.google.cloud.migrationcenter.v1.IDeleteImportJobRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IDeleteImportJobRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteImportJob( - request: protos.google.cloud.migrationcenter.v1.IDeleteImportJobRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IDeleteImportJobRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteImportJob( - request?: protos.google.cloud.migrationcenter.v1.IDeleteImportJobRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.migrationcenter.v1.IDeleteImportJobRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteImportJob response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteImportJob request %j', request); - return this.innerApiCalls.deleteImportJob(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteImportJob response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteImportJob(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteImportJob response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteImportJob()`. - * @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/migration_center.delete_import_job.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_DeleteImportJob_async - */ - async checkDeleteImportJobProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteImportJob()`. + * @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/migration_center.delete_import_job.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_DeleteImportJob_async + */ + async checkDeleteImportJobProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.migrationcenter.v1.OperationMetadata + > + > { this._log.info('deleteImportJob long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteImportJob, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteImportJob, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.migrationcenter.v1.OperationMetadata + >; } -/** - * Updates an import job. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Field mask is used to specify the fields to be overwritten in the - * `Asset` resource by the update. - * The values specified in the `update_mask` field are relative to the - * resource, not the full request. - * A field will be overwritten if it is in the mask. - * A single * value in the mask lets you to overwrite all fields. - * @param {google.cloud.migrationcenter.v1.ImportJob} request.importJob - * Required. The resource being updated - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/migration_center.update_import_job.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_UpdateImportJob_async - */ + /** + * Updates an import job. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Field mask is used to specify the fields to be overwritten in the + * `Asset` resource by the update. + * The values specified in the `update_mask` field are relative to the + * resource, not the full request. + * A field will be overwritten if it is in the mask. + * A single * value in the mask lets you to overwrite all fields. + * @param {google.cloud.migrationcenter.v1.ImportJob} request.importJob + * Required. The resource being updated + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/migration_center.update_import_job.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_UpdateImportJob_async + */ updateImportJob( - request?: protos.google.cloud.migrationcenter.v1.IUpdateImportJobRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.IUpdateImportJobRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.migrationcenter.v1.IImportJob, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateImportJob( - request: protos.google.cloud.migrationcenter.v1.IUpdateImportJobRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IUpdateImportJobRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IImportJob, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateImportJob( - request: protos.google.cloud.migrationcenter.v1.IUpdateImportJobRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IUpdateImportJobRequest, + callback: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IImportJob, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateImportJob( - request?: protos.google.cloud.migrationcenter.v1.IUpdateImportJobRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.migrationcenter.v1.IUpdateImportJobRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IImportJob, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IImportJob, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.migrationcenter.v1.IImportJob, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'import_job.name': request.importJob!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'import_job.name': request.importJob!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IImportJob, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateImportJob response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateImportJob request %j', request); - return this.innerApiCalls.updateImportJob(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateImportJob response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateImportJob(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.migrationcenter.v1.IImportJob, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateImportJob response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateImportJob()`. - * @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/migration_center.update_import_job.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_UpdateImportJob_async - */ - async checkUpdateImportJobProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateImportJob()`. + * @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/migration_center.update_import_job.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_UpdateImportJob_async + */ + async checkUpdateImportJobProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.migrationcenter.v1.ImportJob, + protos.google.cloud.migrationcenter.v1.OperationMetadata + > + > { this._log.info('updateImportJob long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateImportJob, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateImportJob, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.migrationcenter.v1.ImportJob, + protos.google.cloud.migrationcenter.v1.OperationMetadata + >; } -/** - * Validates an import job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the import job to validate. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/migration_center.validate_import_job.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_ValidateImportJob_async - */ + /** + * Validates an import job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the import job to validate. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/migration_center.validate_import_job.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_ValidateImportJob_async + */ validateImportJob( - request?: protos.google.cloud.migrationcenter.v1.IValidateImportJobRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.IValidateImportJobRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; validateImportJob( - request: protos.google.cloud.migrationcenter.v1.IValidateImportJobRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IValidateImportJobRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; validateImportJob( - request: protos.google.cloud.migrationcenter.v1.IValidateImportJobRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IValidateImportJobRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; validateImportJob( - request?: protos.google.cloud.migrationcenter.v1.IValidateImportJobRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.migrationcenter.v1.IValidateImportJobRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('validateImportJob response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('validateImportJob request %j', request); - return this.innerApiCalls.validateImportJob(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('validateImportJob response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .validateImportJob(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('validateImportJob response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `validateImportJob()`. - * @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/migration_center.validate_import_job.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_ValidateImportJob_async - */ - async checkValidateImportJobProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `validateImportJob()`. + * @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/migration_center.validate_import_job.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_ValidateImportJob_async + */ + async checkValidateImportJobProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.migrationcenter.v1.OperationMetadata + > + > { this._log.info('validateImportJob long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.validateImportJob, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.validateImportJob, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.migrationcenter.v1.OperationMetadata + >; } -/** - * Runs an import job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the import job to run. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/migration_center.run_import_job.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_RunImportJob_async - */ + /** + * Runs an import job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the import job to run. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/migration_center.run_import_job.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_RunImportJob_async + */ runImportJob( - request?: protos.google.cloud.migrationcenter.v1.IRunImportJobRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.IRunImportJobRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; runImportJob( - request: protos.google.cloud.migrationcenter.v1.IRunImportJobRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IRunImportJobRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; runImportJob( - request: protos.google.cloud.migrationcenter.v1.IRunImportJobRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IRunImportJobRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; runImportJob( - request?: protos.google.cloud.migrationcenter.v1.IRunImportJobRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; + request?: protos.google.cloud.migrationcenter.v1.IRunImportJobRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('runImportJob response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('runImportJob request %j', request); - return this.innerApiCalls.runImportJob(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('runImportJob response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .runImportJob(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('runImportJob response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `runImportJob()`. - * @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/migration_center.run_import_job.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_RunImportJob_async - */ - async checkRunImportJobProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `runImportJob()`. + * @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/migration_center.run_import_job.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_RunImportJob_async + */ + async checkRunImportJobProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.migrationcenter.v1.OperationMetadata + > + > { this._log.info('runImportJob long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.runImportJob, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.runImportJob, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.migrationcenter.v1.OperationMetadata + >; } -/** - * Creates an import data file. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of the parent of the ImportDataFile. - * @param {string} request.importDataFileId - * Required. The ID of the new data file. - * @param {google.cloud.migrationcenter.v1.ImportDataFile} request.importDataFile - * Required. The resource being created. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/migration_center.create_import_data_file.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_CreateImportDataFile_async - */ + /** + * Creates an import data file. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of the parent of the ImportDataFile. + * @param {string} request.importDataFileId + * Required. The ID of the new data file. + * @param {google.cloud.migrationcenter.v1.ImportDataFile} request.importDataFile + * Required. The resource being created. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/migration_center.create_import_data_file.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_CreateImportDataFile_async + */ createImportDataFile( - request?: protos.google.cloud.migrationcenter.v1.ICreateImportDataFileRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.ICreateImportDataFileRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.migrationcenter.v1.IImportDataFile, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createImportDataFile( - request: protos.google.cloud.migrationcenter.v1.ICreateImportDataFileRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.ICreateImportDataFileRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IImportDataFile, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createImportDataFile( - request: protos.google.cloud.migrationcenter.v1.ICreateImportDataFileRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.ICreateImportDataFileRequest, + callback: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IImportDataFile, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createImportDataFile( - request?: protos.google.cloud.migrationcenter.v1.ICreateImportDataFileRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.migrationcenter.v1.ICreateImportDataFileRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IImportDataFile, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IImportDataFile, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.migrationcenter.v1.IImportDataFile, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IImportDataFile, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createImportDataFile response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createImportDataFile request %j', request); - return this.innerApiCalls.createImportDataFile(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createImportDataFile response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createImportDataFile(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.migrationcenter.v1.IImportDataFile, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createImportDataFile response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createImportDataFile()`. - * @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/migration_center.create_import_data_file.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_CreateImportDataFile_async - */ - async checkCreateImportDataFileProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createImportDataFile()`. + * @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/migration_center.create_import_data_file.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_CreateImportDataFile_async + */ + async checkCreateImportDataFileProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.migrationcenter.v1.ImportDataFile, + protos.google.cloud.migrationcenter.v1.OperationMetadata + > + > { this._log.info('createImportDataFile long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createImportDataFile, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createImportDataFile, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.migrationcenter.v1.ImportDataFile, + protos.google.cloud.migrationcenter.v1.OperationMetadata + >; } -/** - * Delete an import data file. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the ImportDataFile to delete. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/migration_center.delete_import_data_file.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_DeleteImportDataFile_async - */ + /** + * Delete an import data file. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the ImportDataFile to delete. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/migration_center.delete_import_data_file.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_DeleteImportDataFile_async + */ deleteImportDataFile( - request?: protos.google.cloud.migrationcenter.v1.IDeleteImportDataFileRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.IDeleteImportDataFileRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteImportDataFile( - request: protos.google.cloud.migrationcenter.v1.IDeleteImportDataFileRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IDeleteImportDataFileRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteImportDataFile( - request: protos.google.cloud.migrationcenter.v1.IDeleteImportDataFileRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IDeleteImportDataFileRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteImportDataFile( - request?: protos.google.cloud.migrationcenter.v1.IDeleteImportDataFileRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.migrationcenter.v1.IDeleteImportDataFileRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteImportDataFile response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteImportDataFile request %j', request); - return this.innerApiCalls.deleteImportDataFile(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteImportDataFile response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteImportDataFile(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteImportDataFile response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteImportDataFile()`. - * @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/migration_center.delete_import_data_file.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_DeleteImportDataFile_async - */ - async checkDeleteImportDataFileProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteImportDataFile()`. + * @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/migration_center.delete_import_data_file.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_DeleteImportDataFile_async + */ + async checkDeleteImportDataFileProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.migrationcenter.v1.OperationMetadata + > + > { this._log.info('deleteImportDataFile long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteImportDataFile, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteImportDataFile, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.migrationcenter.v1.OperationMetadata + >; } -/** - * Creates a new group in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Value for parent. - * @param {string} request.groupId - * Required. User specified ID for the group. It will become the last - * component of the group name. The ID must be unique within the project, must - * conform with RFC-1034, is restricted to lower-cased letters, and has a - * maximum length of 63 characters. The ID must match the regular expression: - * `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`. - * @param {google.cloud.migrationcenter.v1.Group} request.group - * Required. The group resource being created. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/migration_center.create_group.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_CreateGroup_async - */ + /** + * Creates a new group in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Value for parent. + * @param {string} request.groupId + * Required. User specified ID for the group. It will become the last + * component of the group name. The ID must be unique within the project, must + * conform with RFC-1034, is restricted to lower-cased letters, and has a + * maximum length of 63 characters. The ID must match the regular expression: + * `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`. + * @param {google.cloud.migrationcenter.v1.Group} request.group + * Required. The group resource being created. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/migration_center.create_group.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_CreateGroup_async + */ createGroup( - request?: protos.google.cloud.migrationcenter.v1.ICreateGroupRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.ICreateGroupRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createGroup( - request: protos.google.cloud.migrationcenter.v1.ICreateGroupRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.ICreateGroupRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createGroup( - request: protos.google.cloud.migrationcenter.v1.ICreateGroupRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.ICreateGroupRequest, + callback: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createGroup( - request?: protos.google.cloud.migrationcenter.v1.ICreateGroupRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.migrationcenter.v1.ICreateGroupRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createGroup response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createGroup request %j', request); - return this.innerApiCalls.createGroup(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createGroup response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createGroup(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createGroup response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createGroup()`. - * @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/migration_center.create_group.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_CreateGroup_async - */ - async checkCreateGroupProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createGroup()`. + * @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/migration_center.create_group.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_CreateGroup_async + */ + async checkCreateGroupProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.migrationcenter.v1.Group, + protos.google.cloud.migrationcenter.v1.OperationMetadata + > + > { this._log.info('createGroup long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createGroup, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createGroup, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.migrationcenter.v1.Group, + protos.google.cloud.migrationcenter.v1.OperationMetadata + >; } -/** - * Updates the parameters of a group. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Field mask is used to specify the fields to be overwritten in the - * `Group` resource by the update. - * The values specified in the `update_mask` are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. - * A single * value in the mask lets you to overwrite all fields. - * @param {google.cloud.migrationcenter.v1.Group} request.group - * Required. The group resource being updated. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/migration_center.update_group.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_UpdateGroup_async - */ + /** + * Updates the parameters of a group. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Field mask is used to specify the fields to be overwritten in the + * `Group` resource by the update. + * The values specified in the `update_mask` are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. + * A single * value in the mask lets you to overwrite all fields. + * @param {google.cloud.migrationcenter.v1.Group} request.group + * Required. The group resource being updated. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/migration_center.update_group.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_UpdateGroup_async + */ updateGroup( - request?: protos.google.cloud.migrationcenter.v1.IUpdateGroupRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.IUpdateGroupRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateGroup( - request: protos.google.cloud.migrationcenter.v1.IUpdateGroupRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IUpdateGroupRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateGroup( - request: protos.google.cloud.migrationcenter.v1.IUpdateGroupRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IUpdateGroupRequest, + callback: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateGroup( - request?: protos.google.cloud.migrationcenter.v1.IUpdateGroupRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.migrationcenter.v1.IUpdateGroupRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'group.name': request.group!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'group.name': request.group!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateGroup response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateGroup request %j', request); - return this.innerApiCalls.updateGroup(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateGroup response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateGroup(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateGroup response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateGroup()`. - * @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/migration_center.update_group.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_UpdateGroup_async - */ - async checkUpdateGroupProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateGroup()`. + * @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/migration_center.update_group.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_UpdateGroup_async + */ + async checkUpdateGroupProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.migrationcenter.v1.Group, + protos.google.cloud.migrationcenter.v1.OperationMetadata + > + > { this._log.info('updateGroup long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateGroup, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateGroup, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.migrationcenter.v1.Group, + protos.google.cloud.migrationcenter.v1.OperationMetadata + >; } -/** - * Deletes a group. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the group resource. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/migration_center.delete_group.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_DeleteGroup_async - */ + /** + * Deletes a group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the group resource. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/migration_center.delete_group.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_DeleteGroup_async + */ deleteGroup( - request?: protos.google.cloud.migrationcenter.v1.IDeleteGroupRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.IDeleteGroupRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteGroup( - request: protos.google.cloud.migrationcenter.v1.IDeleteGroupRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IDeleteGroupRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteGroup( - request: protos.google.cloud.migrationcenter.v1.IDeleteGroupRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IDeleteGroupRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteGroup( - request?: protos.google.cloud.migrationcenter.v1.IDeleteGroupRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.migrationcenter.v1.IDeleteGroupRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteGroup response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteGroup request %j', request); - return this.innerApiCalls.deleteGroup(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteGroup response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteGroup(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteGroup response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteGroup()`. - * @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/migration_center.delete_group.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_DeleteGroup_async - */ - async checkDeleteGroupProgress(name: string): Promise>{ - this._log.info('deleteGroup long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + /** + * Check the status of the long running operation returned by `deleteGroup()`. + * @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/migration_center.delete_group.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_DeleteGroup_async + */ + async checkDeleteGroupProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.migrationcenter.v1.OperationMetadata + > + > { + this._log.info('deleteGroup long-running'); + 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.deleteGroup, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteGroup, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.migrationcenter.v1.OperationMetadata + >; } -/** - * Adds assets to a group. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.group - * Required. Group reference. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {google.cloud.migrationcenter.v1.AssetList} request.assets - * Required. List of assets to be added. - * The maximum number of assets that can be added in a single request is - * 1000. - * @param {boolean} [request.allowExisting] - * Optional. When this value is set to `false` and one of the given assets is - * already an existing member of the group, the operation fails with an - * `Already Exists` error. When set to `true` this situation is silently - * ignored by the server. - * - * Default value is `false`. - * @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/migration_center.add_assets_to_group.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_AddAssetsToGroup_async - */ + /** + * Adds assets to a group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.group + * Required. Group reference. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {google.cloud.migrationcenter.v1.AssetList} request.assets + * Required. List of assets to be added. + * The maximum number of assets that can be added in a single request is + * 1000. + * @param {boolean} [request.allowExisting] + * Optional. When this value is set to `false` and one of the given assets is + * already an existing member of the group, the operation fails with an + * `Already Exists` error. When set to `true` this situation is silently + * ignored by the server. + * + * Default value is `false`. + * @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/migration_center.add_assets_to_group.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_AddAssetsToGroup_async + */ addAssetsToGroup( - request?: protos.google.cloud.migrationcenter.v1.IAddAssetsToGroupRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.IAddAssetsToGroupRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; addAssetsToGroup( - request: protos.google.cloud.migrationcenter.v1.IAddAssetsToGroupRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IAddAssetsToGroupRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; addAssetsToGroup( - request: protos.google.cloud.migrationcenter.v1.IAddAssetsToGroupRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IAddAssetsToGroupRequest, + callback: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; addAssetsToGroup( - request?: protos.google.cloud.migrationcenter.v1.IAddAssetsToGroupRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.migrationcenter.v1.IAddAssetsToGroupRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'group': request.group ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + group: request.group ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('addAssetsToGroup response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('addAssetsToGroup request %j', request); - return this.innerApiCalls.addAssetsToGroup(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('addAssetsToGroup response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .addAssetsToGroup(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('addAssetsToGroup response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `addAssetsToGroup()`. - * @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/migration_center.add_assets_to_group.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_AddAssetsToGroup_async - */ - async checkAddAssetsToGroupProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `addAssetsToGroup()`. + * @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/migration_center.add_assets_to_group.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_AddAssetsToGroup_async + */ + async checkAddAssetsToGroupProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.migrationcenter.v1.Group, + protos.google.cloud.migrationcenter.v1.OperationMetadata + > + > { this._log.info('addAssetsToGroup long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.addAssetsToGroup, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.addAssetsToGroup, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.migrationcenter.v1.Group, + protos.google.cloud.migrationcenter.v1.OperationMetadata + >; } -/** - * Removes assets from a group. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.group - * Required. Group reference. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {google.cloud.migrationcenter.v1.AssetList} request.assets - * Required. List of assets to be removed. - * The maximum number of assets that can be removed in a single request is - * 1000. - * @param {boolean} [request.allowMissing] - * Optional. When this value is set to `false` and one of the given assets is - * not an existing member of the group, the operation fails with a `Not Found` - * error. When set to `true` this situation is silently ignored by the server. - * - * Default value is `false`. - * @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/migration_center.remove_assets_from_group.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_RemoveAssetsFromGroup_async - */ + /** + * Removes assets from a group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.group + * Required. Group reference. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {google.cloud.migrationcenter.v1.AssetList} request.assets + * Required. List of assets to be removed. + * The maximum number of assets that can be removed in a single request is + * 1000. + * @param {boolean} [request.allowMissing] + * Optional. When this value is set to `false` and one of the given assets is + * not an existing member of the group, the operation fails with a `Not Found` + * error. When set to `true` this situation is silently ignored by the server. + * + * Default value is `false`. + * @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/migration_center.remove_assets_from_group.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_RemoveAssetsFromGroup_async + */ removeAssetsFromGroup( - request?: protos.google.cloud.migrationcenter.v1.IRemoveAssetsFromGroupRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.IRemoveAssetsFromGroupRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; removeAssetsFromGroup( - request: protos.google.cloud.migrationcenter.v1.IRemoveAssetsFromGroupRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IRemoveAssetsFromGroupRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; removeAssetsFromGroup( - request: protos.google.cloud.migrationcenter.v1.IRemoveAssetsFromGroupRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IRemoveAssetsFromGroupRequest, + callback: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; removeAssetsFromGroup( - request?: protos.google.cloud.migrationcenter.v1.IRemoveAssetsFromGroupRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.migrationcenter.v1.IRemoveAssetsFromGroupRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'group': request.group ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + group: request.group ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('removeAssetsFromGroup response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('removeAssetsFromGroup request %j', request); - return this.innerApiCalls.removeAssetsFromGroup(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('removeAssetsFromGroup response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .removeAssetsFromGroup(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('removeAssetsFromGroup response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `removeAssetsFromGroup()`. - * @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/migration_center.remove_assets_from_group.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_RemoveAssetsFromGroup_async - */ - async checkRemoveAssetsFromGroupProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `removeAssetsFromGroup()`. + * @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/migration_center.remove_assets_from_group.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_RemoveAssetsFromGroup_async + */ + async checkRemoveAssetsFromGroupProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.migrationcenter.v1.Group, + protos.google.cloud.migrationcenter.v1.OperationMetadata + > + > { this._log.info('removeAssetsFromGroup long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.removeAssetsFromGroup, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.removeAssetsFromGroup, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.migrationcenter.v1.Group, + protos.google.cloud.migrationcenter.v1.OperationMetadata + >; } -/** - * Creates a new source in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Value for parent. - * @param {string} request.sourceId - * Required. User specified ID for the source. It will become the last - * component of the source name. The ID must be unique within the project, - * must conform with RFC-1034, is restricted to lower-cased letters, and has a - * maximum length of 63 characters. The ID must match the regular expression: - * `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`. - * @param {google.cloud.migrationcenter.v1.Source} request.source - * Required. The resource being created. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/migration_center.create_source.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_CreateSource_async - */ + /** + * Creates a new source in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Value for parent. + * @param {string} request.sourceId + * Required. User specified ID for the source. It will become the last + * component of the source name. The ID must be unique within the project, + * must conform with RFC-1034, is restricted to lower-cased letters, and has a + * maximum length of 63 characters. The ID must match the regular expression: + * `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`. + * @param {google.cloud.migrationcenter.v1.Source} request.source + * Required. The resource being created. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/migration_center.create_source.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_CreateSource_async + */ createSource( - request?: protos.google.cloud.migrationcenter.v1.ICreateSourceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.ICreateSourceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.migrationcenter.v1.ISource, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createSource( - request: protos.google.cloud.migrationcenter.v1.ICreateSourceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.ICreateSourceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.ISource, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createSource( - request: protos.google.cloud.migrationcenter.v1.ICreateSourceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.ICreateSourceRequest, + callback: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.ISource, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createSource( - request?: protos.google.cloud.migrationcenter.v1.ICreateSourceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.migrationcenter.v1.ICreateSourceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.ISource, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.ISource, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.migrationcenter.v1.ISource, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.ISource, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createSource response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createSource request %j', request); - return this.innerApiCalls.createSource(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createSource response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createSource(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.migrationcenter.v1.ISource, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createSource response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createSource()`. - * @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/migration_center.create_source.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_CreateSource_async - */ - async checkCreateSourceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createSource()`. + * @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/migration_center.create_source.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_CreateSource_async + */ + async checkCreateSourceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.migrationcenter.v1.Source, + protos.google.cloud.migrationcenter.v1.OperationMetadata + > + > { this._log.info('createSource long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createSource, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createSource, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.migrationcenter.v1.Source, + protos.google.cloud.migrationcenter.v1.OperationMetadata + >; } -/** - * Updates the parameters of a source. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Field mask is used to specify the fields to be overwritten in the - * `Source` resource by the update. - * The values specified in the `update_mask` field are relative to the - * resource, not the full request. - * A field will be overwritten if it is in the mask. - * A single * value in the mask lets you to overwrite all fields. - * @param {google.cloud.migrationcenter.v1.Source} request.source - * Required. The resource being updated - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/migration_center.update_source.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_UpdateSource_async - */ + /** + * Updates the parameters of a source. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Field mask is used to specify the fields to be overwritten in the + * `Source` resource by the update. + * The values specified in the `update_mask` field are relative to the + * resource, not the full request. + * A field will be overwritten if it is in the mask. + * A single * value in the mask lets you to overwrite all fields. + * @param {google.cloud.migrationcenter.v1.Source} request.source + * Required. The resource being updated + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/migration_center.update_source.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_UpdateSource_async + */ updateSource( - request?: protos.google.cloud.migrationcenter.v1.IUpdateSourceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.IUpdateSourceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.migrationcenter.v1.ISource, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateSource( - request: protos.google.cloud.migrationcenter.v1.IUpdateSourceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IUpdateSourceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.ISource, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateSource( - request: protos.google.cloud.migrationcenter.v1.IUpdateSourceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IUpdateSourceRequest, + callback: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.ISource, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateSource( - request?: protos.google.cloud.migrationcenter.v1.IUpdateSourceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.migrationcenter.v1.IUpdateSourceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.ISource, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.ISource, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.migrationcenter.v1.ISource, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'source.name': request.source!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'source.name': request.source!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.ISource, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateSource response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateSource request %j', request); - return this.innerApiCalls.updateSource(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateSource response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateSource(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.migrationcenter.v1.ISource, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateSource response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateSource()`. - * @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/migration_center.update_source.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_UpdateSource_async - */ - async checkUpdateSourceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateSource()`. + * @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/migration_center.update_source.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_UpdateSource_async + */ + async checkUpdateSourceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.migrationcenter.v1.Source, + protos.google.cloud.migrationcenter.v1.OperationMetadata + > + > { this._log.info('updateSource long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateSource, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateSource, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.migrationcenter.v1.Source, + protos.google.cloud.migrationcenter.v1.OperationMetadata + >; } -/** - * Deletes a source. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/migration_center.delete_source.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_DeleteSource_async - */ + /** + * Deletes a source. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/migration_center.delete_source.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_DeleteSource_async + */ deleteSource( - request?: protos.google.cloud.migrationcenter.v1.IDeleteSourceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.IDeleteSourceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteSource( - request: protos.google.cloud.migrationcenter.v1.IDeleteSourceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IDeleteSourceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteSource( - request: protos.google.cloud.migrationcenter.v1.IDeleteSourceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IDeleteSourceRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteSource( - request?: protos.google.cloud.migrationcenter.v1.IDeleteSourceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.migrationcenter.v1.IDeleteSourceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteSource response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteSource request %j', request); - return this.innerApiCalls.deleteSource(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteSource response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteSource(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteSource response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteSource()`. - * @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/migration_center.delete_source.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_DeleteSource_async - */ - async checkDeleteSourceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteSource()`. + * @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/migration_center.delete_source.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_DeleteSource_async + */ + async checkDeleteSourceProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.migrationcenter.v1.OperationMetadata + > + > { this._log.info('deleteSource long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteSource, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteSource, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.migrationcenter.v1.OperationMetadata + >; } -/** - * Creates a new preference set in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Value for parent. - * @param {string} request.preferenceSetId - * Required. User specified ID for the preference set. It will become the last - * component of the preference set name. The ID must be unique within the - * project, must conform with RFC-1034, is restricted to lower-cased letters, - * and has a maximum length of 63 characters. The ID must match the regular - * expression - * `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`. - * @param {google.cloud.migrationcenter.v1.PreferenceSet} request.preferenceSet - * Required. The preference set resource being created. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/migration_center.create_preference_set.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_CreatePreferenceSet_async - */ + /** + * Creates a new preference set in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Value for parent. + * @param {string} request.preferenceSetId + * Required. User specified ID for the preference set. It will become the last + * component of the preference set name. The ID must be unique within the + * project, must conform with RFC-1034, is restricted to lower-cased letters, + * and has a maximum length of 63 characters. The ID must match the regular + * expression + * `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`. + * @param {google.cloud.migrationcenter.v1.PreferenceSet} request.preferenceSet + * Required. The preference set resource being created. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/migration_center.create_preference_set.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_CreatePreferenceSet_async + */ createPreferenceSet( - request?: protos.google.cloud.migrationcenter.v1.ICreatePreferenceSetRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.ICreatePreferenceSetRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.migrationcenter.v1.IPreferenceSet, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createPreferenceSet( - request: protos.google.cloud.migrationcenter.v1.ICreatePreferenceSetRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.ICreatePreferenceSetRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IPreferenceSet, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createPreferenceSet( - request: protos.google.cloud.migrationcenter.v1.ICreatePreferenceSetRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.ICreatePreferenceSetRequest, + callback: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IPreferenceSet, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createPreferenceSet( - request?: protos.google.cloud.migrationcenter.v1.ICreatePreferenceSetRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.migrationcenter.v1.ICreatePreferenceSetRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IPreferenceSet, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IPreferenceSet, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.migrationcenter.v1.IPreferenceSet, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IPreferenceSet, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createPreferenceSet response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createPreferenceSet request %j', request); - return this.innerApiCalls.createPreferenceSet(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createPreferenceSet response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createPreferenceSet(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.migrationcenter.v1.IPreferenceSet, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createPreferenceSet response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createPreferenceSet()`. - * @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/migration_center.create_preference_set.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_CreatePreferenceSet_async - */ - async checkCreatePreferenceSetProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createPreferenceSet()`. + * @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/migration_center.create_preference_set.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_CreatePreferenceSet_async + */ + async checkCreatePreferenceSetProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.migrationcenter.v1.PreferenceSet, + protos.google.cloud.migrationcenter.v1.OperationMetadata + > + > { this._log.info('createPreferenceSet long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createPreferenceSet, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createPreferenceSet, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.migrationcenter.v1.PreferenceSet, + protos.google.cloud.migrationcenter.v1.OperationMetadata + >; } -/** - * Updates the parameters of a preference set. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Field mask is used to specify the fields to be overwritten in the - * `PreferenceSet` resource by the update. - * The values specified in the `update_mask` field are relative to the - * resource, not the full request. - * A field will be overwritten if it is in the mask. - * A single * value in the mask lets you to overwrite all fields. - * @param {google.cloud.migrationcenter.v1.PreferenceSet} request.preferenceSet - * Required. The preference set resource being updated. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/migration_center.update_preference_set.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_UpdatePreferenceSet_async - */ + /** + * Updates the parameters of a preference set. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Field mask is used to specify the fields to be overwritten in the + * `PreferenceSet` resource by the update. + * The values specified in the `update_mask` field are relative to the + * resource, not the full request. + * A field will be overwritten if it is in the mask. + * A single * value in the mask lets you to overwrite all fields. + * @param {google.cloud.migrationcenter.v1.PreferenceSet} request.preferenceSet + * Required. The preference set resource being updated. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/migration_center.update_preference_set.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_UpdatePreferenceSet_async + */ updatePreferenceSet( - request?: protos.google.cloud.migrationcenter.v1.IUpdatePreferenceSetRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.IUpdatePreferenceSetRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.migrationcenter.v1.IPreferenceSet, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updatePreferenceSet( - request: protos.google.cloud.migrationcenter.v1.IUpdatePreferenceSetRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IUpdatePreferenceSetRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IPreferenceSet, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updatePreferenceSet( - request: protos.google.cloud.migrationcenter.v1.IUpdatePreferenceSetRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IUpdatePreferenceSetRequest, + callback: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IPreferenceSet, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updatePreferenceSet( - request?: protos.google.cloud.migrationcenter.v1.IUpdatePreferenceSetRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.migrationcenter.v1.IUpdatePreferenceSetRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IPreferenceSet, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IPreferenceSet, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.migrationcenter.v1.IPreferenceSet, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'preference_set.name': request.preferenceSet!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'preference_set.name': request.preferenceSet!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IPreferenceSet, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updatePreferenceSet response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updatePreferenceSet request %j', request); - return this.innerApiCalls.updatePreferenceSet(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updatePreferenceSet response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updatePreferenceSet(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.migrationcenter.v1.IPreferenceSet, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updatePreferenceSet response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updatePreferenceSet()`. - * @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/migration_center.update_preference_set.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_UpdatePreferenceSet_async - */ - async checkUpdatePreferenceSetProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updatePreferenceSet()`. + * @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/migration_center.update_preference_set.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_UpdatePreferenceSet_async + */ + async checkUpdatePreferenceSetProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.migrationcenter.v1.PreferenceSet, + protos.google.cloud.migrationcenter.v1.OperationMetadata + > + > { this._log.info('updatePreferenceSet long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updatePreferenceSet, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updatePreferenceSet, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.migrationcenter.v1.PreferenceSet, + protos.google.cloud.migrationcenter.v1.OperationMetadata + >; } -/** - * Deletes a preference set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the group resource. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/migration_center.delete_preference_set.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_DeletePreferenceSet_async - */ + /** + * Deletes a preference set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the group resource. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/migration_center.delete_preference_set.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_DeletePreferenceSet_async + */ deletePreferenceSet( - request?: protos.google.cloud.migrationcenter.v1.IDeletePreferenceSetRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.IDeletePreferenceSetRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deletePreferenceSet( - request: protos.google.cloud.migrationcenter.v1.IDeletePreferenceSetRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IDeletePreferenceSetRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deletePreferenceSet( - request: protos.google.cloud.migrationcenter.v1.IDeletePreferenceSetRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IDeletePreferenceSetRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deletePreferenceSet( - request?: protos.google.cloud.migrationcenter.v1.IDeletePreferenceSetRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.migrationcenter.v1.IDeletePreferenceSetRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deletePreferenceSet response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deletePreferenceSet request %j', request); - return this.innerApiCalls.deletePreferenceSet(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deletePreferenceSet response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deletePreferenceSet(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deletePreferenceSet response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deletePreferenceSet()`. - * @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/migration_center.delete_preference_set.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_DeletePreferenceSet_async - */ - async checkDeletePreferenceSetProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deletePreferenceSet()`. + * @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/migration_center.delete_preference_set.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_DeletePreferenceSet_async + */ + async checkDeletePreferenceSetProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.migrationcenter.v1.OperationMetadata + > + > { this._log.info('deletePreferenceSet long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deletePreferenceSet, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deletePreferenceSet, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.migrationcenter.v1.OperationMetadata + >; } -/** - * Updates the regional-level project settings. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Field mask is used to specify the fields to be overwritten in the - * `Settings` resource by the update. - * The values specified in the `update_mask` field are relative to the - * resource, not the full request. - * A field will be overwritten if it is in the mask. - * A single * value in the mask lets you to overwrite all fields. - * @param {google.cloud.migrationcenter.v1.Settings} request.settings - * Required. The project settings resource being updated. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/migration_center.update_settings.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_UpdateSettings_async - */ + /** + * Updates the regional-level project settings. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Field mask is used to specify the fields to be overwritten in the + * `Settings` resource by the update. + * The values specified in the `update_mask` field are relative to the + * resource, not the full request. + * A field will be overwritten if it is in the mask. + * A single * value in the mask lets you to overwrite all fields. + * @param {google.cloud.migrationcenter.v1.Settings} request.settings + * Required. The project settings resource being updated. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/migration_center.update_settings.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_UpdateSettings_async + */ updateSettings( - request?: protos.google.cloud.migrationcenter.v1.IUpdateSettingsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.IUpdateSettingsRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.migrationcenter.v1.ISettings, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateSettings( - request: protos.google.cloud.migrationcenter.v1.IUpdateSettingsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IUpdateSettingsRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.ISettings, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateSettings( - request: protos.google.cloud.migrationcenter.v1.IUpdateSettingsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IUpdateSettingsRequest, + callback: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.ISettings, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateSettings( - request?: protos.google.cloud.migrationcenter.v1.IUpdateSettingsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.migrationcenter.v1.IUpdateSettingsRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.ISettings, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.ISettings, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.migrationcenter.v1.ISettings, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'settings.name': request.settings!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'settings.name': request.settings!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.ISettings, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateSettings response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateSettings request %j', request); - return this.innerApiCalls.updateSettings(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateSettings response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateSettings(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.migrationcenter.v1.ISettings, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateSettings response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateSettings()`. - * @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/migration_center.update_settings.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_UpdateSettings_async - */ - async checkUpdateSettingsProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateSettings()`. + * @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/migration_center.update_settings.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_UpdateSettings_async + */ + async checkUpdateSettingsProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.migrationcenter.v1.Settings, + protos.google.cloud.migrationcenter.v1.OperationMetadata + > + > { this._log.info('updateSettings long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateSettings, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateSettings, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.migrationcenter.v1.Settings, + protos.google.cloud.migrationcenter.v1.OperationMetadata + >; } -/** - * Creates a report configuration. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Value for parent. - * @param {string} request.reportConfigId - * Required. User specified ID for the report config. It will become the last - * component of the report config name. The ID must be unique within the - * project, must conform with RFC-1034, is restricted to lower-cased letters, - * and has a maximum length of 63 characters. The ID must match the regular - * expression: [a-z]([a-z0-9-]{0,61}[a-z0-9])?. - * @param {google.cloud.migrationcenter.v1.ReportConfig} request.reportConfig - * Required. The report config set resource being created. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/migration_center.create_report_config.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_CreateReportConfig_async - */ + /** + * Creates a report configuration. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Value for parent. + * @param {string} request.reportConfigId + * Required. User specified ID for the report config. It will become the last + * component of the report config name. The ID must be unique within the + * project, must conform with RFC-1034, is restricted to lower-cased letters, + * and has a maximum length of 63 characters. The ID must match the regular + * expression: [a-z]([a-z0-9-]{0,61}[a-z0-9])?. + * @param {google.cloud.migrationcenter.v1.ReportConfig} request.reportConfig + * Required. The report config set resource being created. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/migration_center.create_report_config.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_CreateReportConfig_async + */ createReportConfig( - request?: protos.google.cloud.migrationcenter.v1.ICreateReportConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.ICreateReportConfigRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.migrationcenter.v1.IReportConfig, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createReportConfig( - request: protos.google.cloud.migrationcenter.v1.ICreateReportConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.ICreateReportConfigRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IReportConfig, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createReportConfig( - request: protos.google.cloud.migrationcenter.v1.ICreateReportConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.ICreateReportConfigRequest, + callback: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IReportConfig, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createReportConfig( - request?: protos.google.cloud.migrationcenter.v1.ICreateReportConfigRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.migrationcenter.v1.ICreateReportConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IReportConfig, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IReportConfig, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.migrationcenter.v1.IReportConfig, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IReportConfig, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createReportConfig response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createReportConfig request %j', request); - return this.innerApiCalls.createReportConfig(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createReportConfig response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createReportConfig(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.migrationcenter.v1.IReportConfig, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createReportConfig response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createReportConfig()`. - * @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/migration_center.create_report_config.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_CreateReportConfig_async - */ - async checkCreateReportConfigProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createReportConfig()`. + * @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/migration_center.create_report_config.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_CreateReportConfig_async + */ + async checkCreateReportConfigProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.migrationcenter.v1.ReportConfig, + protos.google.cloud.migrationcenter.v1.OperationMetadata + > + > { this._log.info('createReportConfig long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createReportConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createReportConfig, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.migrationcenter.v1.ReportConfig, + protos.google.cloud.migrationcenter.v1.OperationMetadata + >; } -/** - * Deletes a ReportConfig. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {boolean} [request.force] - * Optional. If set to `true`, any child `Reports` of this entity will also be - * deleted. If set to `false`, the request only works if the resource has no - * children. - * @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/migration_center.delete_report_config.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_DeleteReportConfig_async - */ + /** + * Deletes a ReportConfig. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {boolean} [request.force] + * Optional. If set to `true`, any child `Reports` of this entity will also be + * deleted. If set to `false`, the request only works if the resource has no + * children. + * @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/migration_center.delete_report_config.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_DeleteReportConfig_async + */ deleteReportConfig( - request?: protos.google.cloud.migrationcenter.v1.IDeleteReportConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.IDeleteReportConfigRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteReportConfig( - request: protos.google.cloud.migrationcenter.v1.IDeleteReportConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IDeleteReportConfigRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteReportConfig( - request: protos.google.cloud.migrationcenter.v1.IDeleteReportConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IDeleteReportConfigRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteReportConfig( - request?: protos.google.cloud.migrationcenter.v1.IDeleteReportConfigRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.migrationcenter.v1.IDeleteReportConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteReportConfig response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteReportConfig request %j', request); - return this.innerApiCalls.deleteReportConfig(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteReportConfig response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteReportConfig(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteReportConfig response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteReportConfig()`. - * @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/migration_center.delete_report_config.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_DeleteReportConfig_async - */ - async checkDeleteReportConfigProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteReportConfig()`. + * @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/migration_center.delete_report_config.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_DeleteReportConfig_async + */ + async checkDeleteReportConfigProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.migrationcenter.v1.OperationMetadata + > + > { this._log.info('deleteReportConfig long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteReportConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteReportConfig, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.migrationcenter.v1.OperationMetadata + >; } -/** - * Creates a report. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Value for parent. - * @param {string} request.reportId - * Required. User specified id for the report. It will become the last - * component of the report name. The id must be unique within the project, - * must conform with RFC-1034, is restricted to lower-cased letters, and has a - * maximum length of 63 characters. The id must match the regular expression: - * [a-z]([a-z0-9-]{0,61}[a-z0-9])?. - * @param {google.cloud.migrationcenter.v1.Report} request.report - * Required. The report resource being created. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/migration_center.create_report.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_CreateReport_async - */ + /** + * Creates a report. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Value for parent. + * @param {string} request.reportId + * Required. User specified id for the report. It will become the last + * component of the report name. The id must be unique within the project, + * must conform with RFC-1034, is restricted to lower-cased letters, and has a + * maximum length of 63 characters. The id must match the regular expression: + * [a-z]([a-z0-9-]{0,61}[a-z0-9])?. + * @param {google.cloud.migrationcenter.v1.Report} request.report + * Required. The report resource being created. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/migration_center.create_report.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_CreateReport_async + */ createReport( - request?: protos.google.cloud.migrationcenter.v1.ICreateReportRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.ICreateReportRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.migrationcenter.v1.IReport, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createReport( - request: protos.google.cloud.migrationcenter.v1.ICreateReportRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.ICreateReportRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IReport, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createReport( - request: protos.google.cloud.migrationcenter.v1.ICreateReportRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.ICreateReportRequest, + callback: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IReport, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createReport( - request?: protos.google.cloud.migrationcenter.v1.ICreateReportRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.migrationcenter.v1.ICreateReportRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IReport, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IReport, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.migrationcenter.v1.IReport, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.migrationcenter.v1.IReport, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createReport response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createReport request %j', request); - return this.innerApiCalls.createReport(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createReport response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createReport(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.migrationcenter.v1.IReport, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createReport response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createReport()`. - * @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/migration_center.create_report.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_CreateReport_async - */ - async checkCreateReportProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createReport()`. + * @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/migration_center.create_report.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_CreateReport_async + */ + async checkCreateReportProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.migrationcenter.v1.Report, + protos.google.cloud.migrationcenter.v1.OperationMetadata + > + > { this._log.info('createReport long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createReport, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createReport, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.migrationcenter.v1.Report, + protos.google.cloud.migrationcenter.v1.OperationMetadata + >; } -/** - * Deletes a Report. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/migration_center.delete_report.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_DeleteReport_async - */ + /** + * Deletes a Report. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/migration_center.delete_report.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_DeleteReport_async + */ deleteReport( - request?: protos.google.cloud.migrationcenter.v1.IDeleteReportRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.migrationcenter.v1.IDeleteReportRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteReport( - request: protos.google.cloud.migrationcenter.v1.IDeleteReportRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IDeleteReportRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteReport( - request: protos.google.cloud.migrationcenter.v1.IDeleteReportRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.migrationcenter.v1.IDeleteReportRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteReport( - request?: protos.google.cloud.migrationcenter.v1.IDeleteReportRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.migrationcenter.v1.IDeleteReportRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteReport response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteReport request %j', request); - return this.innerApiCalls.deleteReport(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteReport response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteReport(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteReport response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteReport()`. - * @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/migration_center.delete_report.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_DeleteReport_async - */ - async checkDeleteReportProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteReport()`. + * @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/migration_center.delete_report.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_DeleteReport_async + */ + async checkDeleteReportProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.migrationcenter.v1.OperationMetadata + > + > { this._log.info('deleteReport long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteReport, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists all the assets in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for `ListAssetsRequest`. - * @param {number} request.pageSize - * Requested page size. Server may return fewer items than requested. - * If unspecified, server will pick an appropriate default. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. - * @param {string} request.filter - * Filtering results. - * @param {string} request.orderBy - * Field to sort by. See https://google.aip.dev/132#ordering for more details. - * @param {google.cloud.migrationcenter.v1.AssetView} request.view - * View of the assets. Defaults to BASIC. - * @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 Array of {@link protos.google.cloud.migrationcenter.v1.Asset|Asset}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listAssetsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteReport, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.migrationcenter.v1.OperationMetadata + >; + } + /** + * Lists all the assets in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for `ListAssetsRequest`. + * @param {number} request.pageSize + * Requested page size. Server may return fewer items than requested. + * If unspecified, server will pick an appropriate default. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. + * @param {string} request.filter + * Filtering results. + * @param {string} request.orderBy + * Field to sort by. See https://google.aip.dev/132#ordering for more details. + * @param {google.cloud.migrationcenter.v1.AssetView} request.view + * View of the assets. Defaults to BASIC. + * @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 Array of {@link protos.google.cloud.migrationcenter.v1.Asset|Asset}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listAssetsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listAssets( - request?: protos.google.cloud.migrationcenter.v1.IListAssetsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.migrationcenter.v1.IAsset[], - protos.google.cloud.migrationcenter.v1.IListAssetsRequest|null, - protos.google.cloud.migrationcenter.v1.IListAssetsResponse - ]>; + request?: protos.google.cloud.migrationcenter.v1.IListAssetsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IAsset[], + protos.google.cloud.migrationcenter.v1.IListAssetsRequest | null, + protos.google.cloud.migrationcenter.v1.IListAssetsResponse, + ] + >; listAssets( - request: protos.google.cloud.migrationcenter.v1.IListAssetsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListAssetsRequest, - protos.google.cloud.migrationcenter.v1.IListAssetsResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IAsset>): void; + request: protos.google.cloud.migrationcenter.v1.IListAssetsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListAssetsRequest, + | protos.google.cloud.migrationcenter.v1.IListAssetsResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IAsset + >, + ): void; listAssets( - request: protos.google.cloud.migrationcenter.v1.IListAssetsRequest, - callback: PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListAssetsRequest, - protos.google.cloud.migrationcenter.v1.IListAssetsResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IAsset>): void; + request: protos.google.cloud.migrationcenter.v1.IListAssetsRequest, + callback: PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListAssetsRequest, + | protos.google.cloud.migrationcenter.v1.IListAssetsResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IAsset + >, + ): void; listAssets( - request?: protos.google.cloud.migrationcenter.v1.IListAssetsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListAssetsRequest, - protos.google.cloud.migrationcenter.v1.IListAssetsResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IAsset>, - callback?: PaginationCallback< + request?: protos.google.cloud.migrationcenter.v1.IListAssetsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.migrationcenter.v1.IListAssetsRequest, - protos.google.cloud.migrationcenter.v1.IListAssetsResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IAsset>): - Promise<[ - protos.google.cloud.migrationcenter.v1.IAsset[], - protos.google.cloud.migrationcenter.v1.IListAssetsRequest|null, - protos.google.cloud.migrationcenter.v1.IListAssetsResponse - ]>|void { + | protos.google.cloud.migrationcenter.v1.IListAssetsResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IAsset + >, + callback?: PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListAssetsRequest, + | protos.google.cloud.migrationcenter.v1.IListAssetsResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IAsset + >, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IAsset[], + protos.google.cloud.migrationcenter.v1.IListAssetsRequest | null, + protos.google.cloud.migrationcenter.v1.IListAssetsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListAssetsRequest, - protos.google.cloud.migrationcenter.v1.IListAssetsResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IAsset>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListAssetsRequest, + | protos.google.cloud.migrationcenter.v1.IListAssetsResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IAsset + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listAssets values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -5157,211 +7550,240 @@ export class MigrationCenterClient { this._log.info('listAssets request %j', request); return this.innerApiCalls .listAssets(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.migrationcenter.v1.IAsset[], - protos.google.cloud.migrationcenter.v1.IListAssetsRequest|null, - protos.google.cloud.migrationcenter.v1.IListAssetsResponse - ]) => { - this._log.info('listAssets values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.migrationcenter.v1.IAsset[], + protos.google.cloud.migrationcenter.v1.IListAssetsRequest | null, + protos.google.cloud.migrationcenter.v1.IListAssetsResponse, + ]) => { + this._log.info('listAssets values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listAssets`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for `ListAssetsRequest`. - * @param {number} request.pageSize - * Requested page size. Server may return fewer items than requested. - * If unspecified, server will pick an appropriate default. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. - * @param {string} request.filter - * Filtering results. - * @param {string} request.orderBy - * Field to sort by. See https://google.aip.dev/132#ordering for more details. - * @param {google.cloud.migrationcenter.v1.AssetView} request.view - * View of the assets. Defaults to BASIC. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.migrationcenter.v1.Asset|Asset} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listAssetsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listAssets`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for `ListAssetsRequest`. + * @param {number} request.pageSize + * Requested page size. Server may return fewer items than requested. + * If unspecified, server will pick an appropriate default. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. + * @param {string} request.filter + * Filtering results. + * @param {string} request.orderBy + * Field to sort by. See https://google.aip.dev/132#ordering for more details. + * @param {google.cloud.migrationcenter.v1.AssetView} request.view + * View of the assets. Defaults to BASIC. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.migrationcenter.v1.Asset|Asset} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listAssetsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listAssetsStream( - request?: protos.google.cloud.migrationcenter.v1.IListAssetsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.migrationcenter.v1.IListAssetsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listAssets']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listAssets stream %j', request); return this.descriptors.page.listAssets.createStream( this.innerApiCalls.listAssets as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listAssets`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for `ListAssetsRequest`. - * @param {number} request.pageSize - * Requested page size. Server may return fewer items than requested. - * If unspecified, server will pick an appropriate default. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. - * @param {string} request.filter - * Filtering results. - * @param {string} request.orderBy - * Field to sort by. See https://google.aip.dev/132#ordering for more details. - * @param {google.cloud.migrationcenter.v1.AssetView} request.view - * View of the assets. Defaults to BASIC. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.migrationcenter.v1.Asset|Asset}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/migration_center.list_assets.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_ListAssets_async - */ + /** + * Equivalent to `listAssets`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for `ListAssetsRequest`. + * @param {number} request.pageSize + * Requested page size. Server may return fewer items than requested. + * If unspecified, server will pick an appropriate default. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. + * @param {string} request.filter + * Filtering results. + * @param {string} request.orderBy + * Field to sort by. See https://google.aip.dev/132#ordering for more details. + * @param {google.cloud.migrationcenter.v1.AssetView} request.view + * View of the assets. Defaults to BASIC. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.migrationcenter.v1.Asset|Asset}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/migration_center.list_assets.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_ListAssets_async + */ listAssetsAsync( - request?: protos.google.cloud.migrationcenter.v1.IListAssetsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.migrationcenter.v1.IListAssetsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listAssets']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listAssets iterate %j', request); return this.descriptors.page.listAssets.asyncIterate( this.innerApiCalls['listAssets'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists all import jobs. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for `ListImportJobsRequest`. - * @param {number} request.pageSize - * Requested page size. Server may return fewer items than requested. - * If unspecified, server will pick an appropriate default. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. - * @param {string} request.filter - * Filtering results. - * @param {string} request.orderBy - * Field to sort by. See https://google.aip.dev/132#ordering for more details. - * @param {google.cloud.migrationcenter.v1.ImportJobView} [request.view] - * Optional. The level of details of each import job. - * Default value is BASIC. - * @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 Array of {@link protos.google.cloud.migrationcenter.v1.ImportJob|ImportJob}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listImportJobsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists all import jobs. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for `ListImportJobsRequest`. + * @param {number} request.pageSize + * Requested page size. Server may return fewer items than requested. + * If unspecified, server will pick an appropriate default. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. + * @param {string} request.filter + * Filtering results. + * @param {string} request.orderBy + * Field to sort by. See https://google.aip.dev/132#ordering for more details. + * @param {google.cloud.migrationcenter.v1.ImportJobView} [request.view] + * Optional. The level of details of each import job. + * Default value is BASIC. + * @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 Array of {@link protos.google.cloud.migrationcenter.v1.ImportJob|ImportJob}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listImportJobsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listImportJobs( - request?: protos.google.cloud.migrationcenter.v1.IListImportJobsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.migrationcenter.v1.IImportJob[], - protos.google.cloud.migrationcenter.v1.IListImportJobsRequest|null, - protos.google.cloud.migrationcenter.v1.IListImportJobsResponse - ]>; + request?: protos.google.cloud.migrationcenter.v1.IListImportJobsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IImportJob[], + protos.google.cloud.migrationcenter.v1.IListImportJobsRequest | null, + protos.google.cloud.migrationcenter.v1.IListImportJobsResponse, + ] + >; listImportJobs( - request: protos.google.cloud.migrationcenter.v1.IListImportJobsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListImportJobsRequest, - protos.google.cloud.migrationcenter.v1.IListImportJobsResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IImportJob>): void; + request: protos.google.cloud.migrationcenter.v1.IListImportJobsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListImportJobsRequest, + | protos.google.cloud.migrationcenter.v1.IListImportJobsResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IImportJob + >, + ): void; listImportJobs( - request: protos.google.cloud.migrationcenter.v1.IListImportJobsRequest, - callback: PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListImportJobsRequest, - protos.google.cloud.migrationcenter.v1.IListImportJobsResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IImportJob>): void; + request: protos.google.cloud.migrationcenter.v1.IListImportJobsRequest, + callback: PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListImportJobsRequest, + | protos.google.cloud.migrationcenter.v1.IListImportJobsResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IImportJob + >, + ): void; listImportJobs( - request?: protos.google.cloud.migrationcenter.v1.IListImportJobsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListImportJobsRequest, - protos.google.cloud.migrationcenter.v1.IListImportJobsResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IImportJob>, - callback?: PaginationCallback< + request?: protos.google.cloud.migrationcenter.v1.IListImportJobsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.migrationcenter.v1.IListImportJobsRequest, - protos.google.cloud.migrationcenter.v1.IListImportJobsResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IImportJob>): - Promise<[ - protos.google.cloud.migrationcenter.v1.IImportJob[], - protos.google.cloud.migrationcenter.v1.IListImportJobsRequest|null, - protos.google.cloud.migrationcenter.v1.IListImportJobsResponse - ]>|void { + | protos.google.cloud.migrationcenter.v1.IListImportJobsResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IImportJob + >, + callback?: PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListImportJobsRequest, + | protos.google.cloud.migrationcenter.v1.IListImportJobsResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IImportJob + >, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IImportJob[], + protos.google.cloud.migrationcenter.v1.IListImportJobsRequest | null, + protos.google.cloud.migrationcenter.v1.IListImportJobsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListImportJobsRequest, - protos.google.cloud.migrationcenter.v1.IListImportJobsResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IImportJob>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListImportJobsRequest, + | protos.google.cloud.migrationcenter.v1.IListImportJobsResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IImportJob + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listImportJobs values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -5370,216 +7792,245 @@ export class MigrationCenterClient { this._log.info('listImportJobs request %j', request); return this.innerApiCalls .listImportJobs(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.migrationcenter.v1.IImportJob[], - protos.google.cloud.migrationcenter.v1.IListImportJobsRequest|null, - protos.google.cloud.migrationcenter.v1.IListImportJobsResponse - ]) => { - this._log.info('listImportJobs values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.migrationcenter.v1.IImportJob[], + protos.google.cloud.migrationcenter.v1.IListImportJobsRequest | null, + protos.google.cloud.migrationcenter.v1.IListImportJobsResponse, + ]) => { + this._log.info('listImportJobs values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listImportJobs`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for `ListImportJobsRequest`. - * @param {number} request.pageSize - * Requested page size. Server may return fewer items than requested. - * If unspecified, server will pick an appropriate default. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. - * @param {string} request.filter - * Filtering results. - * @param {string} request.orderBy - * Field to sort by. See https://google.aip.dev/132#ordering for more details. - * @param {google.cloud.migrationcenter.v1.ImportJobView} [request.view] - * Optional. The level of details of each import job. - * Default value is BASIC. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.migrationcenter.v1.ImportJob|ImportJob} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listImportJobsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listImportJobs`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for `ListImportJobsRequest`. + * @param {number} request.pageSize + * Requested page size. Server may return fewer items than requested. + * If unspecified, server will pick an appropriate default. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. + * @param {string} request.filter + * Filtering results. + * @param {string} request.orderBy + * Field to sort by. See https://google.aip.dev/132#ordering for more details. + * @param {google.cloud.migrationcenter.v1.ImportJobView} [request.view] + * Optional. The level of details of each import job. + * Default value is BASIC. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.migrationcenter.v1.ImportJob|ImportJob} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listImportJobsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listImportJobsStream( - request?: protos.google.cloud.migrationcenter.v1.IListImportJobsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.migrationcenter.v1.IListImportJobsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listImportJobs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listImportJobs stream %j', request); return this.descriptors.page.listImportJobs.createStream( this.innerApiCalls.listImportJobs as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listImportJobs`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for `ListImportJobsRequest`. - * @param {number} request.pageSize - * Requested page size. Server may return fewer items than requested. - * If unspecified, server will pick an appropriate default. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. - * @param {string} request.filter - * Filtering results. - * @param {string} request.orderBy - * Field to sort by. See https://google.aip.dev/132#ordering for more details. - * @param {google.cloud.migrationcenter.v1.ImportJobView} [request.view] - * Optional. The level of details of each import job. - * Default value is BASIC. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.migrationcenter.v1.ImportJob|ImportJob}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/migration_center.list_import_jobs.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_ListImportJobs_async - */ + /** + * Equivalent to `listImportJobs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for `ListImportJobsRequest`. + * @param {number} request.pageSize + * Requested page size. Server may return fewer items than requested. + * If unspecified, server will pick an appropriate default. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. + * @param {string} request.filter + * Filtering results. + * @param {string} request.orderBy + * Field to sort by. See https://google.aip.dev/132#ordering for more details. + * @param {google.cloud.migrationcenter.v1.ImportJobView} [request.view] + * Optional. The level of details of each import job. + * Default value is BASIC. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.migrationcenter.v1.ImportJob|ImportJob}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/migration_center.list_import_jobs.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_ListImportJobs_async + */ listImportJobsAsync( - request?: protos.google.cloud.migrationcenter.v1.IListImportJobsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.migrationcenter.v1.IListImportJobsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listImportJobs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listImportJobs iterate %j', request); return this.descriptors.page.listImportJobs.asyncIterate( this.innerApiCalls['listImportJobs'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * List import data files. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of the parent of the `ImportDataFiles` resource. - * @param {number} request.pageSize - * The maximum number of data files to return. The service may return - * fewer than this value. If unspecified, at most 500 data files will be - * returned. The maximum value is 1000; values above 1000 will be coerced to - * 1000. - * @param {string} request.pageToken - * A page token, received from a previous `ListImportDataFiles` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListImportDataFiles` - * must match the call that provided the page token. - * @param {string} request.filter - * Filtering results. - * @param {string} request.orderBy - * Field to sort by. See https://google.aip.dev/132#ordering for more details. - * @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 Array of {@link protos.google.cloud.migrationcenter.v1.ImportDataFile|ImportDataFile}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listImportDataFilesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * List import data files. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of the parent of the `ImportDataFiles` resource. + * @param {number} request.pageSize + * The maximum number of data files to return. The service may return + * fewer than this value. If unspecified, at most 500 data files will be + * returned. The maximum value is 1000; values above 1000 will be coerced to + * 1000. + * @param {string} request.pageToken + * A page token, received from a previous `ListImportDataFiles` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListImportDataFiles` + * must match the call that provided the page token. + * @param {string} request.filter + * Filtering results. + * @param {string} request.orderBy + * Field to sort by. See https://google.aip.dev/132#ordering for more details. + * @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 Array of {@link protos.google.cloud.migrationcenter.v1.ImportDataFile|ImportDataFile}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listImportDataFilesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listImportDataFiles( - request?: protos.google.cloud.migrationcenter.v1.IListImportDataFilesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.migrationcenter.v1.IImportDataFile[], - protos.google.cloud.migrationcenter.v1.IListImportDataFilesRequest|null, - protos.google.cloud.migrationcenter.v1.IListImportDataFilesResponse - ]>; + request?: protos.google.cloud.migrationcenter.v1.IListImportDataFilesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IImportDataFile[], + protos.google.cloud.migrationcenter.v1.IListImportDataFilesRequest | null, + protos.google.cloud.migrationcenter.v1.IListImportDataFilesResponse, + ] + >; listImportDataFiles( - request: protos.google.cloud.migrationcenter.v1.IListImportDataFilesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListImportDataFilesRequest, - protos.google.cloud.migrationcenter.v1.IListImportDataFilesResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IImportDataFile>): void; + request: protos.google.cloud.migrationcenter.v1.IListImportDataFilesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListImportDataFilesRequest, + | protos.google.cloud.migrationcenter.v1.IListImportDataFilesResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IImportDataFile + >, + ): void; listImportDataFiles( - request: protos.google.cloud.migrationcenter.v1.IListImportDataFilesRequest, - callback: PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListImportDataFilesRequest, - protos.google.cloud.migrationcenter.v1.IListImportDataFilesResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IImportDataFile>): void; + request: protos.google.cloud.migrationcenter.v1.IListImportDataFilesRequest, + callback: PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListImportDataFilesRequest, + | protos.google.cloud.migrationcenter.v1.IListImportDataFilesResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IImportDataFile + >, + ): void; listImportDataFiles( - request?: protos.google.cloud.migrationcenter.v1.IListImportDataFilesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListImportDataFilesRequest, - protos.google.cloud.migrationcenter.v1.IListImportDataFilesResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IImportDataFile>, - callback?: PaginationCallback< + request?: protos.google.cloud.migrationcenter.v1.IListImportDataFilesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.migrationcenter.v1.IListImportDataFilesRequest, - protos.google.cloud.migrationcenter.v1.IListImportDataFilesResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IImportDataFile>): - Promise<[ - protos.google.cloud.migrationcenter.v1.IImportDataFile[], - protos.google.cloud.migrationcenter.v1.IListImportDataFilesRequest|null, - protos.google.cloud.migrationcenter.v1.IListImportDataFilesResponse - ]>|void { + | protos.google.cloud.migrationcenter.v1.IListImportDataFilesResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IImportDataFile + >, + callback?: PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListImportDataFilesRequest, + | protos.google.cloud.migrationcenter.v1.IListImportDataFilesResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IImportDataFile + >, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IImportDataFile[], + protos.google.cloud.migrationcenter.v1.IListImportDataFilesRequest | null, + protos.google.cloud.migrationcenter.v1.IListImportDataFilesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListImportDataFilesRequest, - protos.google.cloud.migrationcenter.v1.IListImportDataFilesResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IImportDataFile>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListImportDataFilesRequest, + | protos.google.cloud.migrationcenter.v1.IListImportDataFilesResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IImportDataFile + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listImportDataFiles values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -5588,216 +8039,245 @@ export class MigrationCenterClient { this._log.info('listImportDataFiles request %j', request); return this.innerApiCalls .listImportDataFiles(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.migrationcenter.v1.IImportDataFile[], - protos.google.cloud.migrationcenter.v1.IListImportDataFilesRequest|null, - protos.google.cloud.migrationcenter.v1.IListImportDataFilesResponse - ]) => { - this._log.info('listImportDataFiles values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.migrationcenter.v1.IImportDataFile[], + protos.google.cloud.migrationcenter.v1.IListImportDataFilesRequest | null, + protos.google.cloud.migrationcenter.v1.IListImportDataFilesResponse, + ]) => { + this._log.info('listImportDataFiles values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listImportDataFiles`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of the parent of the `ImportDataFiles` resource. - * @param {number} request.pageSize - * The maximum number of data files to return. The service may return - * fewer than this value. If unspecified, at most 500 data files will be - * returned. The maximum value is 1000; values above 1000 will be coerced to - * 1000. - * @param {string} request.pageToken - * A page token, received from a previous `ListImportDataFiles` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListImportDataFiles` - * must match the call that provided the page token. - * @param {string} request.filter - * Filtering results. - * @param {string} request.orderBy - * Field to sort by. See https://google.aip.dev/132#ordering for more details. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.migrationcenter.v1.ImportDataFile|ImportDataFile} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listImportDataFilesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listImportDataFiles`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of the parent of the `ImportDataFiles` resource. + * @param {number} request.pageSize + * The maximum number of data files to return. The service may return + * fewer than this value. If unspecified, at most 500 data files will be + * returned. The maximum value is 1000; values above 1000 will be coerced to + * 1000. + * @param {string} request.pageToken + * A page token, received from a previous `ListImportDataFiles` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListImportDataFiles` + * must match the call that provided the page token. + * @param {string} request.filter + * Filtering results. + * @param {string} request.orderBy + * Field to sort by. See https://google.aip.dev/132#ordering for more details. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.migrationcenter.v1.ImportDataFile|ImportDataFile} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listImportDataFilesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listImportDataFilesStream( - request?: protos.google.cloud.migrationcenter.v1.IListImportDataFilesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.migrationcenter.v1.IListImportDataFilesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listImportDataFiles']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listImportDataFiles stream %j', request); return this.descriptors.page.listImportDataFiles.createStream( this.innerApiCalls.listImportDataFiles as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listImportDataFiles`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of the parent of the `ImportDataFiles` resource. - * @param {number} request.pageSize - * The maximum number of data files to return. The service may return - * fewer than this value. If unspecified, at most 500 data files will be - * returned. The maximum value is 1000; values above 1000 will be coerced to - * 1000. - * @param {string} request.pageToken - * A page token, received from a previous `ListImportDataFiles` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListImportDataFiles` - * must match the call that provided the page token. - * @param {string} request.filter - * Filtering results. - * @param {string} request.orderBy - * Field to sort by. See https://google.aip.dev/132#ordering for more details. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.migrationcenter.v1.ImportDataFile|ImportDataFile}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/migration_center.list_import_data_files.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_ListImportDataFiles_async - */ + /** + * Equivalent to `listImportDataFiles`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of the parent of the `ImportDataFiles` resource. + * @param {number} request.pageSize + * The maximum number of data files to return. The service may return + * fewer than this value. If unspecified, at most 500 data files will be + * returned. The maximum value is 1000; values above 1000 will be coerced to + * 1000. + * @param {string} request.pageToken + * A page token, received from a previous `ListImportDataFiles` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListImportDataFiles` + * must match the call that provided the page token. + * @param {string} request.filter + * Filtering results. + * @param {string} request.orderBy + * Field to sort by. See https://google.aip.dev/132#ordering for more details. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.migrationcenter.v1.ImportDataFile|ImportDataFile}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/migration_center.list_import_data_files.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_ListImportDataFiles_async + */ listImportDataFilesAsync( - request?: protos.google.cloud.migrationcenter.v1.IListImportDataFilesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.migrationcenter.v1.IListImportDataFilesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listImportDataFiles']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listImportDataFiles iterate %j', request); return this.descriptors.page.listImportDataFiles.asyncIterate( this.innerApiCalls['listImportDataFiles'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists all groups in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for `ListGroupsRequest`. - * @param {number} request.pageSize - * Requested page size. Server may return fewer items than requested. - * If unspecified, server will pick an appropriate default. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. - * @param {string} request.filter - * Filtering results. - * @param {string} request.orderBy - * Field to sort by. See https://google.aip.dev/132#ordering for more details. - * @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 Array of {@link protos.google.cloud.migrationcenter.v1.Group|Group}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listGroupsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists all groups in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for `ListGroupsRequest`. + * @param {number} request.pageSize + * Requested page size. Server may return fewer items than requested. + * If unspecified, server will pick an appropriate default. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. + * @param {string} request.filter + * Filtering results. + * @param {string} request.orderBy + * Field to sort by. See https://google.aip.dev/132#ordering for more details. + * @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 Array of {@link protos.google.cloud.migrationcenter.v1.Group|Group}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listGroupsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listGroups( - request?: protos.google.cloud.migrationcenter.v1.IListGroupsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.migrationcenter.v1.IGroup[], - protos.google.cloud.migrationcenter.v1.IListGroupsRequest|null, - protos.google.cloud.migrationcenter.v1.IListGroupsResponse - ]>; + request?: protos.google.cloud.migrationcenter.v1.IListGroupsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IGroup[], + protos.google.cloud.migrationcenter.v1.IListGroupsRequest | null, + protos.google.cloud.migrationcenter.v1.IListGroupsResponse, + ] + >; listGroups( - request: protos.google.cloud.migrationcenter.v1.IListGroupsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListGroupsRequest, - protos.google.cloud.migrationcenter.v1.IListGroupsResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IGroup>): void; + request: protos.google.cloud.migrationcenter.v1.IListGroupsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListGroupsRequest, + | protos.google.cloud.migrationcenter.v1.IListGroupsResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IGroup + >, + ): void; listGroups( - request: protos.google.cloud.migrationcenter.v1.IListGroupsRequest, - callback: PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListGroupsRequest, - protos.google.cloud.migrationcenter.v1.IListGroupsResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IGroup>): void; + request: protos.google.cloud.migrationcenter.v1.IListGroupsRequest, + callback: PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListGroupsRequest, + | protos.google.cloud.migrationcenter.v1.IListGroupsResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IGroup + >, + ): void; listGroups( - request?: protos.google.cloud.migrationcenter.v1.IListGroupsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListGroupsRequest, - protos.google.cloud.migrationcenter.v1.IListGroupsResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IGroup>, - callback?: PaginationCallback< + request?: protos.google.cloud.migrationcenter.v1.IListGroupsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.migrationcenter.v1.IListGroupsRequest, - protos.google.cloud.migrationcenter.v1.IListGroupsResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IGroup>): - Promise<[ - protos.google.cloud.migrationcenter.v1.IGroup[], - protos.google.cloud.migrationcenter.v1.IListGroupsRequest|null, - protos.google.cloud.migrationcenter.v1.IListGroupsResponse - ]>|void { + | protos.google.cloud.migrationcenter.v1.IListGroupsResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IGroup + >, + callback?: PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListGroupsRequest, + | protos.google.cloud.migrationcenter.v1.IListGroupsResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IGroup + >, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IGroup[], + protos.google.cloud.migrationcenter.v1.IListGroupsRequest | null, + protos.google.cloud.migrationcenter.v1.IListGroupsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListGroupsRequest, - protos.google.cloud.migrationcenter.v1.IListGroupsResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IGroup>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListGroupsRequest, + | protos.google.cloud.migrationcenter.v1.IListGroupsResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IGroup + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listGroups values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -5806,203 +8286,232 @@ export class MigrationCenterClient { this._log.info('listGroups request %j', request); return this.innerApiCalls .listGroups(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.migrationcenter.v1.IGroup[], - protos.google.cloud.migrationcenter.v1.IListGroupsRequest|null, - protos.google.cloud.migrationcenter.v1.IListGroupsResponse - ]) => { - this._log.info('listGroups values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.migrationcenter.v1.IGroup[], + protos.google.cloud.migrationcenter.v1.IListGroupsRequest | null, + protos.google.cloud.migrationcenter.v1.IListGroupsResponse, + ]) => { + this._log.info('listGroups values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listGroups`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for `ListGroupsRequest`. - * @param {number} request.pageSize - * Requested page size. Server may return fewer items than requested. - * If unspecified, server will pick an appropriate default. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. - * @param {string} request.filter - * Filtering results. - * @param {string} request.orderBy - * Field to sort by. See https://google.aip.dev/132#ordering for more details. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.migrationcenter.v1.Group|Group} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listGroupsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listGroups`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for `ListGroupsRequest`. + * @param {number} request.pageSize + * Requested page size. Server may return fewer items than requested. + * If unspecified, server will pick an appropriate default. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. + * @param {string} request.filter + * Filtering results. + * @param {string} request.orderBy + * Field to sort by. See https://google.aip.dev/132#ordering for more details. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.migrationcenter.v1.Group|Group} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listGroupsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listGroupsStream( - request?: protos.google.cloud.migrationcenter.v1.IListGroupsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.migrationcenter.v1.IListGroupsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listGroups']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listGroups stream %j', request); return this.descriptors.page.listGroups.createStream( this.innerApiCalls.listGroups as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listGroups`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for `ListGroupsRequest`. - * @param {number} request.pageSize - * Requested page size. Server may return fewer items than requested. - * If unspecified, server will pick an appropriate default. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. - * @param {string} request.filter - * Filtering results. - * @param {string} request.orderBy - * Field to sort by. See https://google.aip.dev/132#ordering for more details. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.migrationcenter.v1.Group|Group}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/migration_center.list_groups.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_ListGroups_async - */ + /** + * Equivalent to `listGroups`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for `ListGroupsRequest`. + * @param {number} request.pageSize + * Requested page size. Server may return fewer items than requested. + * If unspecified, server will pick an appropriate default. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. + * @param {string} request.filter + * Filtering results. + * @param {string} request.orderBy + * Field to sort by. See https://google.aip.dev/132#ordering for more details. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.migrationcenter.v1.Group|Group}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/migration_center.list_groups.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_ListGroups_async + */ listGroupsAsync( - request?: protos.google.cloud.migrationcenter.v1.IListGroupsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.migrationcenter.v1.IListGroupsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listGroups']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listGroups iterate %j', request); return this.descriptors.page.listGroups.asyncIterate( this.innerApiCalls['listGroups'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists all error frames in a given source and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value (the source) for `ListErrorFramesRequest`. - * @param {number} request.pageSize - * Requested page size. Server may return fewer items than requested. - * If unspecified, server will pick an appropriate default. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. - * @param {google.cloud.migrationcenter.v1.ErrorFrameView} [request.view] - * Optional. An optional view mode to control the level of details of each - * error frame. The default is a BASIC frame view. - * @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 Array of {@link protos.google.cloud.migrationcenter.v1.ErrorFrame|ErrorFrame}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listErrorFramesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists all error frames in a given source and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value (the source) for `ListErrorFramesRequest`. + * @param {number} request.pageSize + * Requested page size. Server may return fewer items than requested. + * If unspecified, server will pick an appropriate default. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. + * @param {google.cloud.migrationcenter.v1.ErrorFrameView} [request.view] + * Optional. An optional view mode to control the level of details of each + * error frame. The default is a BASIC frame view. + * @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 Array of {@link protos.google.cloud.migrationcenter.v1.ErrorFrame|ErrorFrame}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listErrorFramesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listErrorFrames( - request?: protos.google.cloud.migrationcenter.v1.IListErrorFramesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.migrationcenter.v1.IErrorFrame[], - protos.google.cloud.migrationcenter.v1.IListErrorFramesRequest|null, - protos.google.cloud.migrationcenter.v1.IListErrorFramesResponse - ]>; + request?: protos.google.cloud.migrationcenter.v1.IListErrorFramesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IErrorFrame[], + protos.google.cloud.migrationcenter.v1.IListErrorFramesRequest | null, + protos.google.cloud.migrationcenter.v1.IListErrorFramesResponse, + ] + >; listErrorFrames( - request: protos.google.cloud.migrationcenter.v1.IListErrorFramesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListErrorFramesRequest, - protos.google.cloud.migrationcenter.v1.IListErrorFramesResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IErrorFrame>): void; + request: protos.google.cloud.migrationcenter.v1.IListErrorFramesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListErrorFramesRequest, + | protos.google.cloud.migrationcenter.v1.IListErrorFramesResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IErrorFrame + >, + ): void; listErrorFrames( - request: protos.google.cloud.migrationcenter.v1.IListErrorFramesRequest, - callback: PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListErrorFramesRequest, - protos.google.cloud.migrationcenter.v1.IListErrorFramesResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IErrorFrame>): void; + request: protos.google.cloud.migrationcenter.v1.IListErrorFramesRequest, + callback: PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListErrorFramesRequest, + | protos.google.cloud.migrationcenter.v1.IListErrorFramesResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IErrorFrame + >, + ): void; listErrorFrames( - request?: protos.google.cloud.migrationcenter.v1.IListErrorFramesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListErrorFramesRequest, - protos.google.cloud.migrationcenter.v1.IListErrorFramesResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IErrorFrame>, - callback?: PaginationCallback< + request?: protos.google.cloud.migrationcenter.v1.IListErrorFramesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.migrationcenter.v1.IListErrorFramesRequest, - protos.google.cloud.migrationcenter.v1.IListErrorFramesResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IErrorFrame>): - Promise<[ - protos.google.cloud.migrationcenter.v1.IErrorFrame[], - protos.google.cloud.migrationcenter.v1.IListErrorFramesRequest|null, - protos.google.cloud.migrationcenter.v1.IListErrorFramesResponse - ]>|void { + | protos.google.cloud.migrationcenter.v1.IListErrorFramesResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IErrorFrame + >, + callback?: PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListErrorFramesRequest, + | protos.google.cloud.migrationcenter.v1.IListErrorFramesResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IErrorFrame + >, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IErrorFrame[], + protos.google.cloud.migrationcenter.v1.IListErrorFramesRequest | null, + protos.google.cloud.migrationcenter.v1.IListErrorFramesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListErrorFramesRequest, - protos.google.cloud.migrationcenter.v1.IListErrorFramesResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IErrorFrame>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListErrorFramesRequest, + | protos.google.cloud.migrationcenter.v1.IListErrorFramesResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IErrorFrame + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listErrorFrames values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -6011,202 +8520,231 @@ export class MigrationCenterClient { this._log.info('listErrorFrames request %j', request); return this.innerApiCalls .listErrorFrames(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.migrationcenter.v1.IErrorFrame[], - protos.google.cloud.migrationcenter.v1.IListErrorFramesRequest|null, - protos.google.cloud.migrationcenter.v1.IListErrorFramesResponse - ]) => { - this._log.info('listErrorFrames values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.migrationcenter.v1.IErrorFrame[], + protos.google.cloud.migrationcenter.v1.IListErrorFramesRequest | null, + protos.google.cloud.migrationcenter.v1.IListErrorFramesResponse, + ]) => { + this._log.info('listErrorFrames values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listErrorFrames`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value (the source) for `ListErrorFramesRequest`. - * @param {number} request.pageSize - * Requested page size. Server may return fewer items than requested. - * If unspecified, server will pick an appropriate default. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. - * @param {google.cloud.migrationcenter.v1.ErrorFrameView} [request.view] - * Optional. An optional view mode to control the level of details of each - * error frame. The default is a BASIC frame view. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.migrationcenter.v1.ErrorFrame|ErrorFrame} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listErrorFramesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listErrorFrames`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value (the source) for `ListErrorFramesRequest`. + * @param {number} request.pageSize + * Requested page size. Server may return fewer items than requested. + * If unspecified, server will pick an appropriate default. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. + * @param {google.cloud.migrationcenter.v1.ErrorFrameView} [request.view] + * Optional. An optional view mode to control the level of details of each + * error frame. The default is a BASIC frame view. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.migrationcenter.v1.ErrorFrame|ErrorFrame} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listErrorFramesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listErrorFramesStream( - request?: protos.google.cloud.migrationcenter.v1.IListErrorFramesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.migrationcenter.v1.IListErrorFramesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listErrorFrames']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listErrorFrames stream %j', request); return this.descriptors.page.listErrorFrames.createStream( this.innerApiCalls.listErrorFrames as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listErrorFrames`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value (the source) for `ListErrorFramesRequest`. - * @param {number} request.pageSize - * Requested page size. Server may return fewer items than requested. - * If unspecified, server will pick an appropriate default. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. - * @param {google.cloud.migrationcenter.v1.ErrorFrameView} [request.view] - * Optional. An optional view mode to control the level of details of each - * error frame. The default is a BASIC frame view. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.migrationcenter.v1.ErrorFrame|ErrorFrame}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/migration_center.list_error_frames.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_ListErrorFrames_async - */ + /** + * Equivalent to `listErrorFrames`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value (the source) for `ListErrorFramesRequest`. + * @param {number} request.pageSize + * Requested page size. Server may return fewer items than requested. + * If unspecified, server will pick an appropriate default. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. + * @param {google.cloud.migrationcenter.v1.ErrorFrameView} [request.view] + * Optional. An optional view mode to control the level of details of each + * error frame. The default is a BASIC frame view. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.migrationcenter.v1.ErrorFrame|ErrorFrame}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/migration_center.list_error_frames.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_ListErrorFrames_async + */ listErrorFramesAsync( - request?: protos.google.cloud.migrationcenter.v1.IListErrorFramesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.migrationcenter.v1.IListErrorFramesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listErrorFrames']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listErrorFrames iterate %j', request); return this.descriptors.page.listErrorFrames.asyncIterate( this.innerApiCalls['listErrorFrames'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists all the sources in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for `ListSourcesRequest`. - * @param {number} request.pageSize - * Requested page size. The server may return fewer items than requested. - * If unspecified, the server will pick an appropriate default value. - * @param {string} request.pageToken - * A token identifying a page of results that the server should return. - * @param {string} request.filter - * Filtering results. - * @param {string} request.orderBy - * Field to sort by. See https://google.aip.dev/132#ordering for more details. - * @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 Array of {@link protos.google.cloud.migrationcenter.v1.Source|Source}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listSourcesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists all the sources in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for `ListSourcesRequest`. + * @param {number} request.pageSize + * Requested page size. The server may return fewer items than requested. + * If unspecified, the server will pick an appropriate default value. + * @param {string} request.pageToken + * A token identifying a page of results that the server should return. + * @param {string} request.filter + * Filtering results. + * @param {string} request.orderBy + * Field to sort by. See https://google.aip.dev/132#ordering for more details. + * @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 Array of {@link protos.google.cloud.migrationcenter.v1.Source|Source}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listSourcesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listSources( - request?: protos.google.cloud.migrationcenter.v1.IListSourcesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.migrationcenter.v1.ISource[], - protos.google.cloud.migrationcenter.v1.IListSourcesRequest|null, - protos.google.cloud.migrationcenter.v1.IListSourcesResponse - ]>; + request?: protos.google.cloud.migrationcenter.v1.IListSourcesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.ISource[], + protos.google.cloud.migrationcenter.v1.IListSourcesRequest | null, + protos.google.cloud.migrationcenter.v1.IListSourcesResponse, + ] + >; listSources( - request: protos.google.cloud.migrationcenter.v1.IListSourcesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListSourcesRequest, - protos.google.cloud.migrationcenter.v1.IListSourcesResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.ISource>): void; + request: protos.google.cloud.migrationcenter.v1.IListSourcesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListSourcesRequest, + | protos.google.cloud.migrationcenter.v1.IListSourcesResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.ISource + >, + ): void; listSources( - request: protos.google.cloud.migrationcenter.v1.IListSourcesRequest, - callback: PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListSourcesRequest, - protos.google.cloud.migrationcenter.v1.IListSourcesResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.ISource>): void; + request: protos.google.cloud.migrationcenter.v1.IListSourcesRequest, + callback: PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListSourcesRequest, + | protos.google.cloud.migrationcenter.v1.IListSourcesResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.ISource + >, + ): void; listSources( - request?: protos.google.cloud.migrationcenter.v1.IListSourcesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListSourcesRequest, - protos.google.cloud.migrationcenter.v1.IListSourcesResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.ISource>, - callback?: PaginationCallback< + request?: protos.google.cloud.migrationcenter.v1.IListSourcesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.migrationcenter.v1.IListSourcesRequest, - protos.google.cloud.migrationcenter.v1.IListSourcesResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.ISource>): - Promise<[ - protos.google.cloud.migrationcenter.v1.ISource[], - protos.google.cloud.migrationcenter.v1.IListSourcesRequest|null, - protos.google.cloud.migrationcenter.v1.IListSourcesResponse - ]>|void { + | protos.google.cloud.migrationcenter.v1.IListSourcesResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.ISource + >, + callback?: PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListSourcesRequest, + | protos.google.cloud.migrationcenter.v1.IListSourcesResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.ISource + >, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.ISource[], + protos.google.cloud.migrationcenter.v1.IListSourcesRequest | null, + protos.google.cloud.migrationcenter.v1.IListSourcesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListSourcesRequest, - protos.google.cloud.migrationcenter.v1.IListSourcesResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.ISource>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListSourcesRequest, + | protos.google.cloud.migrationcenter.v1.IListSourcesResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.ISource + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listSources values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -6215,203 +8753,232 @@ export class MigrationCenterClient { this._log.info('listSources request %j', request); return this.innerApiCalls .listSources(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.migrationcenter.v1.ISource[], - protos.google.cloud.migrationcenter.v1.IListSourcesRequest|null, - protos.google.cloud.migrationcenter.v1.IListSourcesResponse - ]) => { - this._log.info('listSources values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.migrationcenter.v1.ISource[], + protos.google.cloud.migrationcenter.v1.IListSourcesRequest | null, + protos.google.cloud.migrationcenter.v1.IListSourcesResponse, + ]) => { + this._log.info('listSources values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listSources`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for `ListSourcesRequest`. - * @param {number} request.pageSize - * Requested page size. The server may return fewer items than requested. - * If unspecified, the server will pick an appropriate default value. - * @param {string} request.pageToken - * A token identifying a page of results that the server should return. - * @param {string} request.filter - * Filtering results. - * @param {string} request.orderBy - * Field to sort by. See https://google.aip.dev/132#ordering for more details. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.migrationcenter.v1.Source|Source} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listSourcesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listSources`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for `ListSourcesRequest`. + * @param {number} request.pageSize + * Requested page size. The server may return fewer items than requested. + * If unspecified, the server will pick an appropriate default value. + * @param {string} request.pageToken + * A token identifying a page of results that the server should return. + * @param {string} request.filter + * Filtering results. + * @param {string} request.orderBy + * Field to sort by. See https://google.aip.dev/132#ordering for more details. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.migrationcenter.v1.Source|Source} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listSourcesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listSourcesStream( - request?: protos.google.cloud.migrationcenter.v1.IListSourcesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.migrationcenter.v1.IListSourcesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listSources']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listSources stream %j', request); return this.descriptors.page.listSources.createStream( this.innerApiCalls.listSources as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listSources`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for `ListSourcesRequest`. - * @param {number} request.pageSize - * Requested page size. The server may return fewer items than requested. - * If unspecified, the server will pick an appropriate default value. - * @param {string} request.pageToken - * A token identifying a page of results that the server should return. - * @param {string} request.filter - * Filtering results. - * @param {string} request.orderBy - * Field to sort by. See https://google.aip.dev/132#ordering for more details. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.migrationcenter.v1.Source|Source}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/migration_center.list_sources.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_ListSources_async - */ + /** + * Equivalent to `listSources`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for `ListSourcesRequest`. + * @param {number} request.pageSize + * Requested page size. The server may return fewer items than requested. + * If unspecified, the server will pick an appropriate default value. + * @param {string} request.pageToken + * A token identifying a page of results that the server should return. + * @param {string} request.filter + * Filtering results. + * @param {string} request.orderBy + * Field to sort by. See https://google.aip.dev/132#ordering for more details. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.migrationcenter.v1.Source|Source}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/migration_center.list_sources.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_ListSources_async + */ listSourcesAsync( - request?: protos.google.cloud.migrationcenter.v1.IListSourcesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.migrationcenter.v1.IListSourcesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listSources']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listSources iterate %j', request); return this.descriptors.page.listSources.asyncIterate( this.innerApiCalls['listSources'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists all the preference sets in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for `ListPreferenceSetsRequest`. - * @param {number} request.pageSize - * Requested page size. Server may return fewer items than requested. - * If unspecified, at most 500 preference sets will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. - * @param {string} request.orderBy - * Field to sort by. See https://google.aip.dev/132#ordering for more details. - * @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 Array of {@link protos.google.cloud.migrationcenter.v1.PreferenceSet|PreferenceSet}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listPreferenceSetsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists all the preference sets in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for `ListPreferenceSetsRequest`. + * @param {number} request.pageSize + * Requested page size. Server may return fewer items than requested. + * If unspecified, at most 500 preference sets will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. + * @param {string} request.orderBy + * Field to sort by. See https://google.aip.dev/132#ordering for more details. + * @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 Array of {@link protos.google.cloud.migrationcenter.v1.PreferenceSet|PreferenceSet}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listPreferenceSetsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listPreferenceSets( - request?: protos.google.cloud.migrationcenter.v1.IListPreferenceSetsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.migrationcenter.v1.IPreferenceSet[], - protos.google.cloud.migrationcenter.v1.IListPreferenceSetsRequest|null, - protos.google.cloud.migrationcenter.v1.IListPreferenceSetsResponse - ]>; + request?: protos.google.cloud.migrationcenter.v1.IListPreferenceSetsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IPreferenceSet[], + protos.google.cloud.migrationcenter.v1.IListPreferenceSetsRequest | null, + protos.google.cloud.migrationcenter.v1.IListPreferenceSetsResponse, + ] + >; listPreferenceSets( - request: protos.google.cloud.migrationcenter.v1.IListPreferenceSetsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListPreferenceSetsRequest, - protos.google.cloud.migrationcenter.v1.IListPreferenceSetsResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IPreferenceSet>): void; + request: protos.google.cloud.migrationcenter.v1.IListPreferenceSetsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListPreferenceSetsRequest, + | protos.google.cloud.migrationcenter.v1.IListPreferenceSetsResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IPreferenceSet + >, + ): void; listPreferenceSets( - request: protos.google.cloud.migrationcenter.v1.IListPreferenceSetsRequest, - callback: PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListPreferenceSetsRequest, - protos.google.cloud.migrationcenter.v1.IListPreferenceSetsResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IPreferenceSet>): void; + request: protos.google.cloud.migrationcenter.v1.IListPreferenceSetsRequest, + callback: PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListPreferenceSetsRequest, + | protos.google.cloud.migrationcenter.v1.IListPreferenceSetsResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IPreferenceSet + >, + ): void; listPreferenceSets( - request?: protos.google.cloud.migrationcenter.v1.IListPreferenceSetsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListPreferenceSetsRequest, - protos.google.cloud.migrationcenter.v1.IListPreferenceSetsResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IPreferenceSet>, - callback?: PaginationCallback< + request?: protos.google.cloud.migrationcenter.v1.IListPreferenceSetsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.migrationcenter.v1.IListPreferenceSetsRequest, - protos.google.cloud.migrationcenter.v1.IListPreferenceSetsResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IPreferenceSet>): - Promise<[ - protos.google.cloud.migrationcenter.v1.IPreferenceSet[], - protos.google.cloud.migrationcenter.v1.IListPreferenceSetsRequest|null, - protos.google.cloud.migrationcenter.v1.IListPreferenceSetsResponse - ]>|void { + | protos.google.cloud.migrationcenter.v1.IListPreferenceSetsResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IPreferenceSet + >, + callback?: PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListPreferenceSetsRequest, + | protos.google.cloud.migrationcenter.v1.IListPreferenceSetsResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IPreferenceSet + >, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IPreferenceSet[], + protos.google.cloud.migrationcenter.v1.IListPreferenceSetsRequest | null, + protos.google.cloud.migrationcenter.v1.IListPreferenceSetsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListPreferenceSetsRequest, - protos.google.cloud.migrationcenter.v1.IListPreferenceSetsResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IPreferenceSet>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListPreferenceSetsRequest, + | protos.google.cloud.migrationcenter.v1.IListPreferenceSetsResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IPreferenceSet + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listPreferenceSets values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -6420,202 +8987,231 @@ export class MigrationCenterClient { this._log.info('listPreferenceSets request %j', request); return this.innerApiCalls .listPreferenceSets(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.migrationcenter.v1.IPreferenceSet[], - protos.google.cloud.migrationcenter.v1.IListPreferenceSetsRequest|null, - protos.google.cloud.migrationcenter.v1.IListPreferenceSetsResponse - ]) => { - this._log.info('listPreferenceSets values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.migrationcenter.v1.IPreferenceSet[], + protos.google.cloud.migrationcenter.v1.IListPreferenceSetsRequest | null, + protos.google.cloud.migrationcenter.v1.IListPreferenceSetsResponse, + ]) => { + this._log.info('listPreferenceSets values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listPreferenceSets`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for `ListPreferenceSetsRequest`. - * @param {number} request.pageSize - * Requested page size. Server may return fewer items than requested. - * If unspecified, at most 500 preference sets will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. - * @param {string} request.orderBy - * Field to sort by. See https://google.aip.dev/132#ordering for more details. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.migrationcenter.v1.PreferenceSet|PreferenceSet} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listPreferenceSetsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listPreferenceSets`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for `ListPreferenceSetsRequest`. + * @param {number} request.pageSize + * Requested page size. Server may return fewer items than requested. + * If unspecified, at most 500 preference sets will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. + * @param {string} request.orderBy + * Field to sort by. See https://google.aip.dev/132#ordering for more details. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.migrationcenter.v1.PreferenceSet|PreferenceSet} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listPreferenceSetsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listPreferenceSetsStream( - request?: protos.google.cloud.migrationcenter.v1.IListPreferenceSetsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.migrationcenter.v1.IListPreferenceSetsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listPreferenceSets']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listPreferenceSets stream %j', request); return this.descriptors.page.listPreferenceSets.createStream( this.innerApiCalls.listPreferenceSets as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listPreferenceSets`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for `ListPreferenceSetsRequest`. - * @param {number} request.pageSize - * Requested page size. Server may return fewer items than requested. - * If unspecified, at most 500 preference sets will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. - * @param {string} request.orderBy - * Field to sort by. See https://google.aip.dev/132#ordering for more details. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.migrationcenter.v1.PreferenceSet|PreferenceSet}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/migration_center.list_preference_sets.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_ListPreferenceSets_async - */ + /** + * Equivalent to `listPreferenceSets`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for `ListPreferenceSetsRequest`. + * @param {number} request.pageSize + * Requested page size. Server may return fewer items than requested. + * If unspecified, at most 500 preference sets will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. + * @param {string} request.orderBy + * Field to sort by. See https://google.aip.dev/132#ordering for more details. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.migrationcenter.v1.PreferenceSet|PreferenceSet}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/migration_center.list_preference_sets.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_ListPreferenceSets_async + */ listPreferenceSetsAsync( - request?: protos.google.cloud.migrationcenter.v1.IListPreferenceSetsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.migrationcenter.v1.IListPreferenceSetsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listPreferenceSets']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listPreferenceSets iterate %j', request); return this.descriptors.page.listPreferenceSets.asyncIterate( this.innerApiCalls['listPreferenceSets'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists ReportConfigs in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for `ListReportConfigsRequest`. - * @param {number} request.pageSize - * Requested page size. Server may return fewer items than requested. - * If unspecified, server will pick an appropriate default. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. - * @param {string} request.filter - * Filtering results. - * @param {string} request.orderBy - * Field to sort by. See https://google.aip.dev/132#ordering for more details. - * @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 Array of {@link protos.google.cloud.migrationcenter.v1.ReportConfig|ReportConfig}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listReportConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists ReportConfigs in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for `ListReportConfigsRequest`. + * @param {number} request.pageSize + * Requested page size. Server may return fewer items than requested. + * If unspecified, server will pick an appropriate default. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. + * @param {string} request.filter + * Filtering results. + * @param {string} request.orderBy + * Field to sort by. See https://google.aip.dev/132#ordering for more details. + * @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 Array of {@link protos.google.cloud.migrationcenter.v1.ReportConfig|ReportConfig}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listReportConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listReportConfigs( - request?: protos.google.cloud.migrationcenter.v1.IListReportConfigsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.migrationcenter.v1.IReportConfig[], - protos.google.cloud.migrationcenter.v1.IListReportConfigsRequest|null, - protos.google.cloud.migrationcenter.v1.IListReportConfigsResponse - ]>; + request?: protos.google.cloud.migrationcenter.v1.IListReportConfigsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IReportConfig[], + protos.google.cloud.migrationcenter.v1.IListReportConfigsRequest | null, + protos.google.cloud.migrationcenter.v1.IListReportConfigsResponse, + ] + >; listReportConfigs( - request: protos.google.cloud.migrationcenter.v1.IListReportConfigsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListReportConfigsRequest, - protos.google.cloud.migrationcenter.v1.IListReportConfigsResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IReportConfig>): void; + request: protos.google.cloud.migrationcenter.v1.IListReportConfigsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListReportConfigsRequest, + | protos.google.cloud.migrationcenter.v1.IListReportConfigsResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IReportConfig + >, + ): void; listReportConfigs( - request: protos.google.cloud.migrationcenter.v1.IListReportConfigsRequest, - callback: PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListReportConfigsRequest, - protos.google.cloud.migrationcenter.v1.IListReportConfigsResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IReportConfig>): void; + request: protos.google.cloud.migrationcenter.v1.IListReportConfigsRequest, + callback: PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListReportConfigsRequest, + | protos.google.cloud.migrationcenter.v1.IListReportConfigsResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IReportConfig + >, + ): void; listReportConfigs( - request?: protos.google.cloud.migrationcenter.v1.IListReportConfigsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListReportConfigsRequest, - protos.google.cloud.migrationcenter.v1.IListReportConfigsResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IReportConfig>, - callback?: PaginationCallback< + request?: protos.google.cloud.migrationcenter.v1.IListReportConfigsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.migrationcenter.v1.IListReportConfigsRequest, - protos.google.cloud.migrationcenter.v1.IListReportConfigsResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IReportConfig>): - Promise<[ - protos.google.cloud.migrationcenter.v1.IReportConfig[], - protos.google.cloud.migrationcenter.v1.IListReportConfigsRequest|null, - protos.google.cloud.migrationcenter.v1.IListReportConfigsResponse - ]>|void { + | protos.google.cloud.migrationcenter.v1.IListReportConfigsResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IReportConfig + >, + callback?: PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListReportConfigsRequest, + | protos.google.cloud.migrationcenter.v1.IListReportConfigsResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IReportConfig + >, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IReportConfig[], + protos.google.cloud.migrationcenter.v1.IListReportConfigsRequest | null, + protos.google.cloud.migrationcenter.v1.IListReportConfigsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListReportConfigsRequest, - protos.google.cloud.migrationcenter.v1.IListReportConfigsResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IReportConfig>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListReportConfigsRequest, + | protos.google.cloud.migrationcenter.v1.IListReportConfigsResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IReportConfig + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listReportConfigs values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -6624,206 +9220,235 @@ export class MigrationCenterClient { this._log.info('listReportConfigs request %j', request); return this.innerApiCalls .listReportConfigs(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.migrationcenter.v1.IReportConfig[], - protos.google.cloud.migrationcenter.v1.IListReportConfigsRequest|null, - protos.google.cloud.migrationcenter.v1.IListReportConfigsResponse - ]) => { - this._log.info('listReportConfigs values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.migrationcenter.v1.IReportConfig[], + protos.google.cloud.migrationcenter.v1.IListReportConfigsRequest | null, + protos.google.cloud.migrationcenter.v1.IListReportConfigsResponse, + ]) => { + this._log.info('listReportConfigs values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listReportConfigs`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for `ListReportConfigsRequest`. - * @param {number} request.pageSize - * Requested page size. Server may return fewer items than requested. - * If unspecified, server will pick an appropriate default. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. - * @param {string} request.filter - * Filtering results. - * @param {string} request.orderBy - * Field to sort by. See https://google.aip.dev/132#ordering for more details. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.migrationcenter.v1.ReportConfig|ReportConfig} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listReportConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listReportConfigs`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for `ListReportConfigsRequest`. + * @param {number} request.pageSize + * Requested page size. Server may return fewer items than requested. + * If unspecified, server will pick an appropriate default. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. + * @param {string} request.filter + * Filtering results. + * @param {string} request.orderBy + * Field to sort by. See https://google.aip.dev/132#ordering for more details. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.migrationcenter.v1.ReportConfig|ReportConfig} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listReportConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listReportConfigsStream( - request?: protos.google.cloud.migrationcenter.v1.IListReportConfigsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.migrationcenter.v1.IListReportConfigsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listReportConfigs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listReportConfigs stream %j', request); return this.descriptors.page.listReportConfigs.createStream( this.innerApiCalls.listReportConfigs as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listReportConfigs`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for `ListReportConfigsRequest`. - * @param {number} request.pageSize - * Requested page size. Server may return fewer items than requested. - * If unspecified, server will pick an appropriate default. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. - * @param {string} request.filter - * Filtering results. - * @param {string} request.orderBy - * Field to sort by. See https://google.aip.dev/132#ordering for more details. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.migrationcenter.v1.ReportConfig|ReportConfig}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/migration_center.list_report_configs.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_ListReportConfigs_async - */ + /** + * Equivalent to `listReportConfigs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for `ListReportConfigsRequest`. + * @param {number} request.pageSize + * Requested page size. Server may return fewer items than requested. + * If unspecified, server will pick an appropriate default. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. + * @param {string} request.filter + * Filtering results. + * @param {string} request.orderBy + * Field to sort by. See https://google.aip.dev/132#ordering for more details. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.migrationcenter.v1.ReportConfig|ReportConfig}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/migration_center.list_report_configs.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_ListReportConfigs_async + */ listReportConfigsAsync( - request?: protos.google.cloud.migrationcenter.v1.IListReportConfigsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.migrationcenter.v1.IListReportConfigsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listReportConfigs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listReportConfigs iterate %j', request); return this.descriptors.page.listReportConfigs.asyncIterate( this.innerApiCalls['listReportConfigs'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists Reports in a given ReportConfig. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for `ListReportsRequest`. - * @param {number} request.pageSize - * Requested page size. The server may return fewer items than requested. - * If unspecified, the server will pick an appropriate default value. - * @param {string} request.pageToken - * A token identifying a page of results that the server should return. - * @param {string} request.filter - * Filtering results. - * @param {string} request.orderBy - * Field to sort by. See https://google.aip.dev/132#ordering for more details. - * @param {google.cloud.migrationcenter.v1.ReportView} request.view - * Determines what information to retrieve for each Report. - * @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 Array of {@link protos.google.cloud.migrationcenter.v1.Report|Report}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listReportsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists Reports in a given ReportConfig. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for `ListReportsRequest`. + * @param {number} request.pageSize + * Requested page size. The server may return fewer items than requested. + * If unspecified, the server will pick an appropriate default value. + * @param {string} request.pageToken + * A token identifying a page of results that the server should return. + * @param {string} request.filter + * Filtering results. + * @param {string} request.orderBy + * Field to sort by. See https://google.aip.dev/132#ordering for more details. + * @param {google.cloud.migrationcenter.v1.ReportView} request.view + * Determines what information to retrieve for each Report. + * @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 Array of {@link protos.google.cloud.migrationcenter.v1.Report|Report}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listReportsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listReports( - request?: protos.google.cloud.migrationcenter.v1.IListReportsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.migrationcenter.v1.IReport[], - protos.google.cloud.migrationcenter.v1.IListReportsRequest|null, - protos.google.cloud.migrationcenter.v1.IListReportsResponse - ]>; + request?: protos.google.cloud.migrationcenter.v1.IListReportsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IReport[], + protos.google.cloud.migrationcenter.v1.IListReportsRequest | null, + protos.google.cloud.migrationcenter.v1.IListReportsResponse, + ] + >; listReports( - request: protos.google.cloud.migrationcenter.v1.IListReportsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListReportsRequest, - protos.google.cloud.migrationcenter.v1.IListReportsResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IReport>): void; + request: protos.google.cloud.migrationcenter.v1.IListReportsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListReportsRequest, + | protos.google.cloud.migrationcenter.v1.IListReportsResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IReport + >, + ): void; listReports( - request: protos.google.cloud.migrationcenter.v1.IListReportsRequest, - callback: PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListReportsRequest, - protos.google.cloud.migrationcenter.v1.IListReportsResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IReport>): void; + request: protos.google.cloud.migrationcenter.v1.IListReportsRequest, + callback: PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListReportsRequest, + | protos.google.cloud.migrationcenter.v1.IListReportsResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IReport + >, + ): void; listReports( - request?: protos.google.cloud.migrationcenter.v1.IListReportsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListReportsRequest, - protos.google.cloud.migrationcenter.v1.IListReportsResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IReport>, - callback?: PaginationCallback< + request?: protos.google.cloud.migrationcenter.v1.IListReportsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.migrationcenter.v1.IListReportsRequest, - protos.google.cloud.migrationcenter.v1.IListReportsResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IReport>): - Promise<[ - protos.google.cloud.migrationcenter.v1.IReport[], - protos.google.cloud.migrationcenter.v1.IListReportsRequest|null, - protos.google.cloud.migrationcenter.v1.IListReportsResponse - ]>|void { + | protos.google.cloud.migrationcenter.v1.IListReportsResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IReport + >, + callback?: PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListReportsRequest, + | protos.google.cloud.migrationcenter.v1.IListReportsResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IReport + >, + ): Promise< + [ + protos.google.cloud.migrationcenter.v1.IReport[], + protos.google.cloud.migrationcenter.v1.IListReportsRequest | null, + protos.google.cloud.migrationcenter.v1.IListReportsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.migrationcenter.v1.IListReportsRequest, - protos.google.cloud.migrationcenter.v1.IListReportsResponse|null|undefined, - protos.google.cloud.migrationcenter.v1.IReport>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.migrationcenter.v1.IListReportsRequest, + | protos.google.cloud.migrationcenter.v1.IListReportsResponse + | null + | undefined, + protos.google.cloud.migrationcenter.v1.IReport + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listReports values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -6832,123 +9457,128 @@ export class MigrationCenterClient { this._log.info('listReports request %j', request); return this.innerApiCalls .listReports(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.migrationcenter.v1.IReport[], - protos.google.cloud.migrationcenter.v1.IListReportsRequest|null, - protos.google.cloud.migrationcenter.v1.IListReportsResponse - ]) => { - this._log.info('listReports values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.migrationcenter.v1.IReport[], + protos.google.cloud.migrationcenter.v1.IListReportsRequest | null, + protos.google.cloud.migrationcenter.v1.IListReportsResponse, + ]) => { + this._log.info('listReports values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listReports`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for `ListReportsRequest`. - * @param {number} request.pageSize - * Requested page size. The server may return fewer items than requested. - * If unspecified, the server will pick an appropriate default value. - * @param {string} request.pageToken - * A token identifying a page of results that the server should return. - * @param {string} request.filter - * Filtering results. - * @param {string} request.orderBy - * Field to sort by. See https://google.aip.dev/132#ordering for more details. - * @param {google.cloud.migrationcenter.v1.ReportView} request.view - * Determines what information to retrieve for each Report. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.migrationcenter.v1.Report|Report} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listReportsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listReports`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for `ListReportsRequest`. + * @param {number} request.pageSize + * Requested page size. The server may return fewer items than requested. + * If unspecified, the server will pick an appropriate default value. + * @param {string} request.pageToken + * A token identifying a page of results that the server should return. + * @param {string} request.filter + * Filtering results. + * @param {string} request.orderBy + * Field to sort by. See https://google.aip.dev/132#ordering for more details. + * @param {google.cloud.migrationcenter.v1.ReportView} request.view + * Determines what information to retrieve for each Report. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.migrationcenter.v1.Report|Report} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listReportsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listReportsStream( - request?: protos.google.cloud.migrationcenter.v1.IListReportsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.migrationcenter.v1.IListReportsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listReports']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listReports stream %j', request); return this.descriptors.page.listReports.createStream( this.innerApiCalls.listReports as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listReports`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for `ListReportsRequest`. - * @param {number} request.pageSize - * Requested page size. The server may return fewer items than requested. - * If unspecified, the server will pick an appropriate default value. - * @param {string} request.pageToken - * A token identifying a page of results that the server should return. - * @param {string} request.filter - * Filtering results. - * @param {string} request.orderBy - * Field to sort by. See https://google.aip.dev/132#ordering for more details. - * @param {google.cloud.migrationcenter.v1.ReportView} request.view - * Determines what information to retrieve for each Report. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.migrationcenter.v1.Report|Report}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/migration_center.list_reports.js - * region_tag:migrationcenter_v1_generated_MigrationCenter_ListReports_async - */ + /** + * Equivalent to `listReports`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for `ListReportsRequest`. + * @param {number} request.pageSize + * Requested page size. The server may return fewer items than requested. + * If unspecified, the server will pick an appropriate default value. + * @param {string} request.pageToken + * A token identifying a page of results that the server should return. + * @param {string} request.filter + * Filtering results. + * @param {string} request.orderBy + * Field to sort by. See https://google.aip.dev/132#ordering for more details. + * @param {google.cloud.migrationcenter.v1.ReportView} request.view + * Determines what information to retrieve for each Report. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.migrationcenter.v1.Report|Report}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/migration_center.list_reports.js + * region_tag:migrationcenter_v1_generated_MigrationCenter_ListReports_async + */ listReportsAsync( - request?: protos.google.cloud.migrationcenter.v1.IListReportsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.migrationcenter.v1.IListReportsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listReports']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listReports iterate %j', request); return this.descriptors.page.listReports.asyncIterate( this.innerApiCalls['listReports'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** + + /** * Gets information about a location. * * @param {Object} request @@ -6983,12 +9613,11 @@ export class MigrationCenterClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -7021,12 +9650,12 @@ export class MigrationCenterClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -7069,22 +9698,22 @@ export class MigrationCenterClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -7119,15 +9748,15 @@ export class MigrationCenterClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - 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 ?? '', - }); + 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 ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -7161,7 +9790,7 @@ export class MigrationCenterClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -7174,25 +9803,24 @@ export class MigrationCenterClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -7231,22 +9859,22 @@ export class MigrationCenterClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -7262,7 +9890,7 @@ export class MigrationCenterClient { * @param {string} asset * @returns {string} Resource name string. */ - assetPath(project:string,location:string,asset:string) { + assetPath(project: string, location: string, asset: string) { return this.pathTemplates.assetPathTemplate.render({ project: project, location: location, @@ -7312,7 +9940,12 @@ export class MigrationCenterClient { * @param {string} error_frame * @returns {string} Resource name string. */ - errorFramePath(project:string,location:string,source:string,errorFrame:string) { + errorFramePath( + project: string, + location: string, + source: string, + errorFrame: string, + ) { return this.pathTemplates.errorFramePathTemplate.render({ project: project, location: location, @@ -7329,7 +9962,8 @@ export class MigrationCenterClient { * @returns {string} A string representing the project. */ matchProjectFromErrorFrameName(errorFrameName: string) { - return this.pathTemplates.errorFramePathTemplate.match(errorFrameName).project; + return this.pathTemplates.errorFramePathTemplate.match(errorFrameName) + .project; } /** @@ -7340,7 +9974,8 @@ export class MigrationCenterClient { * @returns {string} A string representing the location. */ matchLocationFromErrorFrameName(errorFrameName: string) { - return this.pathTemplates.errorFramePathTemplate.match(errorFrameName).location; + return this.pathTemplates.errorFramePathTemplate.match(errorFrameName) + .location; } /** @@ -7351,7 +9986,8 @@ export class MigrationCenterClient { * @returns {string} A string representing the source. */ matchSourceFromErrorFrameName(errorFrameName: string) { - return this.pathTemplates.errorFramePathTemplate.match(errorFrameName).source; + return this.pathTemplates.errorFramePathTemplate.match(errorFrameName) + .source; } /** @@ -7362,7 +9998,8 @@ export class MigrationCenterClient { * @returns {string} A string representing the error_frame. */ matchErrorFrameFromErrorFrameName(errorFrameName: string) { - return this.pathTemplates.errorFramePathTemplate.match(errorFrameName).error_frame; + return this.pathTemplates.errorFramePathTemplate.match(errorFrameName) + .error_frame; } /** @@ -7373,7 +10010,7 @@ export class MigrationCenterClient { * @param {string} group * @returns {string} Resource name string. */ - groupPath(project:string,location:string,group:string) { + groupPath(project: string, location: string, group: string) { return this.pathTemplates.groupPathTemplate.render({ project: project, location: location, @@ -7423,7 +10060,12 @@ export class MigrationCenterClient { * @param {string} import_data_file * @returns {string} Resource name string. */ - importDataFilePath(project:string,location:string,importJob:string,importDataFile:string) { + importDataFilePath( + project: string, + location: string, + importJob: string, + importDataFile: string, + ) { return this.pathTemplates.importDataFilePathTemplate.render({ project: project, location: location, @@ -7440,7 +10082,9 @@ export class MigrationCenterClient { * @returns {string} A string representing the project. */ matchProjectFromImportDataFileName(importDataFileName: string) { - return this.pathTemplates.importDataFilePathTemplate.match(importDataFileName).project; + return this.pathTemplates.importDataFilePathTemplate.match( + importDataFileName, + ).project; } /** @@ -7451,7 +10095,9 @@ export class MigrationCenterClient { * @returns {string} A string representing the location. */ matchLocationFromImportDataFileName(importDataFileName: string) { - return this.pathTemplates.importDataFilePathTemplate.match(importDataFileName).location; + return this.pathTemplates.importDataFilePathTemplate.match( + importDataFileName, + ).location; } /** @@ -7462,7 +10108,9 @@ export class MigrationCenterClient { * @returns {string} A string representing the import_job. */ matchImportJobFromImportDataFileName(importDataFileName: string) { - return this.pathTemplates.importDataFilePathTemplate.match(importDataFileName).import_job; + return this.pathTemplates.importDataFilePathTemplate.match( + importDataFileName, + ).import_job; } /** @@ -7473,7 +10121,9 @@ export class MigrationCenterClient { * @returns {string} A string representing the import_data_file. */ matchImportDataFileFromImportDataFileName(importDataFileName: string) { - return this.pathTemplates.importDataFilePathTemplate.match(importDataFileName).import_data_file; + return this.pathTemplates.importDataFilePathTemplate.match( + importDataFileName, + ).import_data_file; } /** @@ -7484,7 +10134,7 @@ export class MigrationCenterClient { * @param {string} import_job * @returns {string} Resource name string. */ - importJobPath(project:string,location:string,importJob:string) { + importJobPath(project: string, location: string, importJob: string) { return this.pathTemplates.importJobPathTemplate.render({ project: project, location: location, @@ -7500,7 +10150,8 @@ export class MigrationCenterClient { * @returns {string} A string representing the project. */ matchProjectFromImportJobName(importJobName: string) { - return this.pathTemplates.importJobPathTemplate.match(importJobName).project; + return this.pathTemplates.importJobPathTemplate.match(importJobName) + .project; } /** @@ -7511,7 +10162,8 @@ export class MigrationCenterClient { * @returns {string} A string representing the location. */ matchLocationFromImportJobName(importJobName: string) { - return this.pathTemplates.importJobPathTemplate.match(importJobName).location; + return this.pathTemplates.importJobPathTemplate.match(importJobName) + .location; } /** @@ -7522,7 +10174,8 @@ export class MigrationCenterClient { * @returns {string} A string representing the import_job. */ matchImportJobFromImportJobName(importJobName: string) { - return this.pathTemplates.importJobPathTemplate.match(importJobName).import_job; + return this.pathTemplates.importJobPathTemplate.match(importJobName) + .import_job; } /** @@ -7532,7 +10185,7 @@ export class MigrationCenterClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -7569,7 +10222,7 @@ export class MigrationCenterClient { * @param {string} preference_set * @returns {string} Resource name string. */ - preferenceSetPath(project:string,location:string,preferenceSet:string) { + preferenceSetPath(project: string, location: string, preferenceSet: string) { return this.pathTemplates.preferenceSetPathTemplate.render({ project: project, location: location, @@ -7585,7 +10238,8 @@ export class MigrationCenterClient { * @returns {string} A string representing the project. */ matchProjectFromPreferenceSetName(preferenceSetName: string) { - return this.pathTemplates.preferenceSetPathTemplate.match(preferenceSetName).project; + return this.pathTemplates.preferenceSetPathTemplate.match(preferenceSetName) + .project; } /** @@ -7596,7 +10250,8 @@ export class MigrationCenterClient { * @returns {string} A string representing the location. */ matchLocationFromPreferenceSetName(preferenceSetName: string) { - return this.pathTemplates.preferenceSetPathTemplate.match(preferenceSetName).location; + return this.pathTemplates.preferenceSetPathTemplate.match(preferenceSetName) + .location; } /** @@ -7607,7 +10262,8 @@ export class MigrationCenterClient { * @returns {string} A string representing the preference_set. */ matchPreferenceSetFromPreferenceSetName(preferenceSetName: string) { - return this.pathTemplates.preferenceSetPathTemplate.match(preferenceSetName).preference_set; + return this.pathTemplates.preferenceSetPathTemplate.match(preferenceSetName) + .preference_set; } /** @@ -7616,7 +10272,7 @@ export class MigrationCenterClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -7642,7 +10298,12 @@ export class MigrationCenterClient { * @param {string} report * @returns {string} Resource name string. */ - reportPath(project:string,location:string,reportConfig:string,report:string) { + reportPath( + project: string, + location: string, + reportConfig: string, + report: string, + ) { return this.pathTemplates.reportPathTemplate.render({ project: project, location: location, @@ -7681,7 +10342,8 @@ export class MigrationCenterClient { * @returns {string} A string representing the report_config. */ matchReportConfigFromReportName(reportName: string) { - return this.pathTemplates.reportPathTemplate.match(reportName).report_config; + return this.pathTemplates.reportPathTemplate.match(reportName) + .report_config; } /** @@ -7703,7 +10365,7 @@ export class MigrationCenterClient { * @param {string} report_config * @returns {string} Resource name string. */ - reportConfigPath(project:string,location:string,reportConfig:string) { + reportConfigPath(project: string, location: string, reportConfig: string) { return this.pathTemplates.reportConfigPathTemplate.render({ project: project, location: location, @@ -7719,7 +10381,8 @@ export class MigrationCenterClient { * @returns {string} A string representing the project. */ matchProjectFromReportConfigName(reportConfigName: string) { - return this.pathTemplates.reportConfigPathTemplate.match(reportConfigName).project; + return this.pathTemplates.reportConfigPathTemplate.match(reportConfigName) + .project; } /** @@ -7730,7 +10393,8 @@ export class MigrationCenterClient { * @returns {string} A string representing the location. */ matchLocationFromReportConfigName(reportConfigName: string) { - return this.pathTemplates.reportConfigPathTemplate.match(reportConfigName).location; + return this.pathTemplates.reportConfigPathTemplate.match(reportConfigName) + .location; } /** @@ -7741,7 +10405,8 @@ export class MigrationCenterClient { * @returns {string} A string representing the report_config. */ matchReportConfigFromReportConfigName(reportConfigName: string) { - return this.pathTemplates.reportConfigPathTemplate.match(reportConfigName).report_config; + return this.pathTemplates.reportConfigPathTemplate.match(reportConfigName) + .report_config; } /** @@ -7751,7 +10416,7 @@ export class MigrationCenterClient { * @param {string} location * @returns {string} Resource name string. */ - settingsPath(project:string,location:string) { + settingsPath(project: string, location: string) { return this.pathTemplates.settingsPathTemplate.render({ project: project, location: location, @@ -7788,7 +10453,7 @@ export class MigrationCenterClient { * @param {string} source * @returns {string} Resource name string. */ - sourcePath(project:string,location:string,source:string) { + sourcePath(project: string, location: string, source: string) { return this.pathTemplates.sourcePathTemplate.render({ project: project, location: location, @@ -7837,14 +10502,16 @@ export class MigrationCenterClient { */ close(): Promise { if (this.migrationCenterStub && !this._terminated) { - return this.migrationCenterStub.then(stub => { + return this.migrationCenterStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.locationsClient.close().catch(err => {throw err}); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-migrationcenter/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-migrationcenter/system-test/fixtures/sample/src/index.ts index b65b9989223a..d185f8804363 100644 --- a/packages/google-cloud-migrationcenter/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-migrationcenter/system-test/fixtures/sample/src/index.ts @@ -16,7 +16,7 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {MigrationCenterClient} from '@google-cloud/migrationcenter'; +import { MigrationCenterClient } from '@google-cloud/migrationcenter'; // check that the client class type name can be used function doStuffWithMigrationCenterClient(client: MigrationCenterClient) { diff --git a/packages/google-cloud-migrationcenter/system-test/install.ts b/packages/google-cloud-migrationcenter/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-migrationcenter/system-test/install.ts +++ b/packages/google-cloud-migrationcenter/system-test/install.ts @@ -16,34 +16,36 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {packNTest} from 'pack-n-play'; -import {readFileSync} from 'fs'; -import {describe, it} from 'mocha'; +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; +import { describe, it } from 'mocha'; describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { + it('TypeScript code', async function () { this.timeout(300000); const options = { packageDir: process.cwd(), sample: { description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } + ts: readFileSync( + './system-test/fixtures/sample/src/index.ts', + ).toString(), + }, }; await packNTest(options); }); - it('JavaScript code', async function() { + it('JavaScript code', async function () { this.timeout(300000); const options = { packageDir: process.cwd(), sample: { description: 'JavaScript user can use the library', - cjs: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } + cjs: readFileSync( + './system-test/fixtures/sample/src/index.js', + ).toString(), + }, }; await packNTest(options); }); - }); diff --git a/packages/google-cloud-migrationcenter/test/gapic_migration_center_v1.ts b/packages/google-cloud-migrationcenter/test/gapic_migration_center_v1.ts index bacc83e3c9e0..0d52f3c864e8 100644 --- a/packages/google-cloud-migrationcenter/test/gapic_migration_center_v1.ts +++ b/packages/google-cloud-migrationcenter/test/gapic_migration_center_v1.ts @@ -19,8726 +19,11135 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as migrationcenterModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1.MigrationCenterClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new migrationcenterModule.v1.MigrationCenterClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'migrationcenter.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new migrationcenterModule.v1.MigrationCenterClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'migrationcenter.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new migrationcenterModule.v1.MigrationCenterClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new migrationcenterModule.v1.MigrationCenterClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = migrationcenterModule.v1.MigrationCenterClient.servicePath; - assert.strictEqual(servicePath, 'migrationcenter.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = migrationcenterModule.v1.MigrationCenterClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'migrationcenter.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'migrationcenter.example.com'); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + migrationcenterModule.v1.MigrationCenterClient.servicePath; + assert.strictEqual(servicePath, 'migrationcenter.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + migrationcenterModule.v1.MigrationCenterClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'migrationcenter.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'migrationcenter.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'migrationcenter.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'migrationcenter.example.com'); + }); - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new migrationcenterModule.v1.MigrationCenterClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'migrationcenter.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new migrationcenterModule.v1.MigrationCenterClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'migrationcenter.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new migrationcenterModule.v1.MigrationCenterClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new migrationcenterModule.v1.MigrationCenterClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'migrationcenter.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new migrationcenterModule.v1.MigrationCenterClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'migrationcenter.configured.example.com', + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new migrationcenterModule.v1.MigrationCenterClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has port', () => { - const port = migrationcenterModule.v1.MigrationCenterClient.port; - assert(port); - assert(typeof port === 'number'); - }); + it('has port', () => { + const port = migrationcenterModule.v1.MigrationCenterClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('should create a client with no option', () => { - const client = new migrationcenterModule.v1.MigrationCenterClient(); - assert(client); - }); + it('should create a client with no option', () => { + const client = new migrationcenterModule.v1.MigrationCenterClient(); + assert(client); + }); - it('should create a client with gRPC fallback', () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - fallback: true, - }); - assert(client); - }); + it('should create a client with gRPC fallback', () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + fallback: true, + }); + assert(client); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.migrationCenterStub, undefined); - await client.initialize(); - assert(client.migrationCenterStub); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.migrationCenterStub, undefined); + await client.initialize(); + assert(client.migrationCenterStub); + }); - it('has close method for the initialized client', done => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.migrationCenterStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the initialized client', (done) => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.migrationCenterStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has close method for the non-initialized client', done => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.migrationCenterStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the non-initialized client', (done) => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.migrationCenterStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getAsset', () => { + it('invokes getAsset without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetAssetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetAssetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Asset(), + ); + client.innerApiCalls.getAsset = stubSimpleCall(expectedResponse); + const [response] = await client.getAsset(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getAsset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAsset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getAsset', () => { - it('invokes getAsset without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetAssetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetAssetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.Asset() - ); - client.innerApiCalls.getAsset = stubSimpleCall(expectedResponse); - const [response] = await client.getAsset(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getAsset as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAsset as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getAsset without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetAssetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetAssetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Asset(), + ); + client.innerApiCalls.getAsset = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getAsset( + request, + ( + err?: Error | null, + result?: protos.google.cloud.migrationcenter.v1.IAsset | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getAsset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAsset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getAsset without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetAssetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetAssetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.Asset() - ); - client.innerApiCalls.getAsset = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getAsset( - request, - (err?: Error|null, result?: protos.google.cloud.migrationcenter.v1.IAsset|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getAsset as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAsset as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getAsset with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetAssetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetAssetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getAsset = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getAsset(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getAsset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAsset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getAsset with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetAssetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetAssetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getAsset = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getAsset(request), expectedError); - const actualRequest = (client.innerApiCalls.getAsset as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAsset as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getAsset with closed client', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetAssetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetAssetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getAsset(request), expectedError); + }); + }); + + describe('updateAsset', () => { + it('invokes updateAsset without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.UpdateAssetRequest(), + ); + request.asset ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.UpdateAssetRequest', + ['asset', 'name'], + ); + request.asset.name = defaultValue1; + const expectedHeaderRequestParams = `asset.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Asset(), + ); + client.innerApiCalls.updateAsset = stubSimpleCall(expectedResponse); + const [response] = await client.updateAsset(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateAsset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateAsset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getAsset with closed client', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetAssetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetAssetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getAsset(request), expectedError); - }); + it('invokes updateAsset without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.UpdateAssetRequest(), + ); + request.asset ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.UpdateAssetRequest', + ['asset', 'name'], + ); + request.asset.name = defaultValue1; + const expectedHeaderRequestParams = `asset.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Asset(), + ); + client.innerApiCalls.updateAsset = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateAsset( + request, + ( + err?: Error | null, + result?: protos.google.cloud.migrationcenter.v1.IAsset | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateAsset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateAsset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateAsset', () => { - it('invokes updateAsset without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.UpdateAssetRequest() - ); - request.asset ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.UpdateAssetRequest', ['asset', 'name']); - request.asset.name = defaultValue1; - const expectedHeaderRequestParams = `asset.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.Asset() - ); - client.innerApiCalls.updateAsset = stubSimpleCall(expectedResponse); - const [response] = await client.updateAsset(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateAsset as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAsset as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateAsset with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.UpdateAssetRequest(), + ); + request.asset ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.UpdateAssetRequest', + ['asset', 'name'], + ); + request.asset.name = defaultValue1; + const expectedHeaderRequestParams = `asset.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateAsset = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateAsset(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateAsset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateAsset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateAsset without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.UpdateAssetRequest() - ); - request.asset ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.UpdateAssetRequest', ['asset', 'name']); - request.asset.name = defaultValue1; - const expectedHeaderRequestParams = `asset.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.Asset() - ); - client.innerApiCalls.updateAsset = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateAsset( - request, - (err?: Error|null, result?: protos.google.cloud.migrationcenter.v1.IAsset|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateAsset as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAsset as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateAsset with closed client', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.UpdateAssetRequest(), + ); + request.asset ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.UpdateAssetRequest', + ['asset', 'name'], + ); + request.asset.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateAsset(request), expectedError); + }); + }); + + describe('batchUpdateAssets', () => { + it('invokes batchUpdateAssets without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.BatchUpdateAssetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.BatchUpdateAssetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.BatchUpdateAssetsResponse(), + ); + client.innerApiCalls.batchUpdateAssets = stubSimpleCall(expectedResponse); + const [response] = await client.batchUpdateAssets(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.batchUpdateAssets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchUpdateAssets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateAsset with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.UpdateAssetRequest() - ); - request.asset ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.UpdateAssetRequest', ['asset', 'name']); - request.asset.name = defaultValue1; - const expectedHeaderRequestParams = `asset.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateAsset = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateAsset(request), expectedError); - const actualRequest = (client.innerApiCalls.updateAsset as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAsset as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes batchUpdateAssets without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.BatchUpdateAssetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.BatchUpdateAssetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.BatchUpdateAssetsResponse(), + ); + client.innerApiCalls.batchUpdateAssets = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchUpdateAssets( + request, + ( + err?: Error | null, + result?: protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.batchUpdateAssets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchUpdateAssets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateAsset with closed client', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.UpdateAssetRequest() - ); - request.asset ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.UpdateAssetRequest', ['asset', 'name']); - request.asset.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateAsset(request), expectedError); - }); + it('invokes batchUpdateAssets with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.BatchUpdateAssetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.BatchUpdateAssetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchUpdateAssets = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.batchUpdateAssets(request), expectedError); + const actualRequest = ( + client.innerApiCalls.batchUpdateAssets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchUpdateAssets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('batchUpdateAssets', () => { - it('invokes batchUpdateAssets without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.BatchUpdateAssetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.BatchUpdateAssetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.BatchUpdateAssetsResponse() - ); - client.innerApiCalls.batchUpdateAssets = stubSimpleCall(expectedResponse); - const [response] = await client.batchUpdateAssets(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchUpdateAssets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchUpdateAssets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes batchUpdateAssets with closed client', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.BatchUpdateAssetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.BatchUpdateAssetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.batchUpdateAssets(request), expectedError); + }); + }); + + describe('deleteAsset', () => { + it('invokes deleteAsset without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeleteAssetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeleteAssetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteAsset = stubSimpleCall(expectedResponse); + const [response] = await client.deleteAsset(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteAsset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteAsset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes batchUpdateAssets without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.BatchUpdateAssetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.BatchUpdateAssetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.BatchUpdateAssetsResponse() - ); - client.innerApiCalls.batchUpdateAssets = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchUpdateAssets( - request, - (err?: Error|null, result?: protos.google.cloud.migrationcenter.v1.IBatchUpdateAssetsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchUpdateAssets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchUpdateAssets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteAsset without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeleteAssetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeleteAssetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteAsset = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteAsset( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteAsset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteAsset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes batchUpdateAssets with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.BatchUpdateAssetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.BatchUpdateAssetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchUpdateAssets = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchUpdateAssets(request), expectedError); - const actualRequest = (client.innerApiCalls.batchUpdateAssets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchUpdateAssets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteAsset with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeleteAssetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeleteAssetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteAsset = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteAsset(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteAsset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteAsset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes batchUpdateAssets with closed client', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.BatchUpdateAssetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.BatchUpdateAssetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.batchUpdateAssets(request), expectedError); - }); + it('invokes deleteAsset with closed client', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeleteAssetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeleteAssetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deleteAsset(request), expectedError); + }); + }); + + describe('batchDeleteAssets', () => { + it('invokes batchDeleteAssets without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.BatchDeleteAssetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.BatchDeleteAssetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.batchDeleteAssets = stubSimpleCall(expectedResponse); + const [response] = await client.batchDeleteAssets(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.batchDeleteAssets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchDeleteAssets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteAsset', () => { - it('invokes deleteAsset without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeleteAssetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeleteAssetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteAsset = stubSimpleCall(expectedResponse); - const [response] = await client.deleteAsset(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteAsset as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteAsset as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes batchDeleteAssets without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.BatchDeleteAssetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.BatchDeleteAssetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.batchDeleteAssets = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchDeleteAssets( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.batchDeleteAssets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchDeleteAssets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteAsset without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeleteAssetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeleteAssetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteAsset = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteAsset( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteAsset as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteAsset as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes batchDeleteAssets with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.BatchDeleteAssetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.BatchDeleteAssetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchDeleteAssets = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.batchDeleteAssets(request), expectedError); + const actualRequest = ( + client.innerApiCalls.batchDeleteAssets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchDeleteAssets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteAsset with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeleteAssetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeleteAssetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteAsset = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteAsset(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteAsset as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteAsset as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes batchDeleteAssets with closed client', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.BatchDeleteAssetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.BatchDeleteAssetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.batchDeleteAssets(request), expectedError); + }); + }); + + describe('reportAssetFrames', () => { + it('invokes reportAssetFrames without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ReportAssetFramesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ReportAssetFramesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ReportAssetFramesResponse(), + ); + client.innerApiCalls.reportAssetFrames = stubSimpleCall(expectedResponse); + const [response] = await client.reportAssetFrames(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.reportAssetFrames as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reportAssetFrames as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteAsset with closed client', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeleteAssetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeleteAssetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteAsset(request), expectedError); - }); + it('invokes reportAssetFrames without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ReportAssetFramesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ReportAssetFramesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ReportAssetFramesResponse(), + ); + client.innerApiCalls.reportAssetFrames = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.reportAssetFrames( + request, + ( + err?: Error | null, + result?: protos.google.cloud.migrationcenter.v1.IReportAssetFramesResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.reportAssetFrames as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reportAssetFrames as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('batchDeleteAssets', () => { - it('invokes batchDeleteAssets without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.BatchDeleteAssetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.BatchDeleteAssetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.batchDeleteAssets = stubSimpleCall(expectedResponse); - const [response] = await client.batchDeleteAssets(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchDeleteAssets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchDeleteAssets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes reportAssetFrames with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ReportAssetFramesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ReportAssetFramesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.reportAssetFrames = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.reportAssetFrames(request), expectedError); + const actualRequest = ( + client.innerApiCalls.reportAssetFrames as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reportAssetFrames as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes batchDeleteAssets without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.BatchDeleteAssetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.BatchDeleteAssetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.batchDeleteAssets = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchDeleteAssets( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchDeleteAssets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchDeleteAssets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes reportAssetFrames with closed client', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ReportAssetFramesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ReportAssetFramesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.reportAssetFrames(request), expectedError); + }); + }); + + describe('aggregateAssetsValues', () => { + it('invokes aggregateAssetsValues without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.AggregateAssetsValuesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.AggregateAssetsValuesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.AggregateAssetsValuesResponse(), + ); + client.innerApiCalls.aggregateAssetsValues = + stubSimpleCall(expectedResponse); + const [response] = await client.aggregateAssetsValues(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.aggregateAssetsValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.aggregateAssetsValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes batchDeleteAssets with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.BatchDeleteAssetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.BatchDeleteAssetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchDeleteAssets = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchDeleteAssets(request), expectedError); - const actualRequest = (client.innerApiCalls.batchDeleteAssets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchDeleteAssets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes aggregateAssetsValues without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.AggregateAssetsValuesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.AggregateAssetsValuesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.AggregateAssetsValuesResponse(), + ); + client.innerApiCalls.aggregateAssetsValues = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.aggregateAssetsValues( + request, + ( + err?: Error | null, + result?: protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.aggregateAssetsValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.aggregateAssetsValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes batchDeleteAssets with closed client', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.BatchDeleteAssetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.BatchDeleteAssetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.batchDeleteAssets(request), expectedError); - }); + it('invokes aggregateAssetsValues with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.AggregateAssetsValuesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.AggregateAssetsValuesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.aggregateAssetsValues = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.aggregateAssetsValues(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.aggregateAssetsValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.aggregateAssetsValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('reportAssetFrames', () => { - it('invokes reportAssetFrames without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ReportAssetFramesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ReportAssetFramesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ReportAssetFramesResponse() - ); - client.innerApiCalls.reportAssetFrames = stubSimpleCall(expectedResponse); - const [response] = await client.reportAssetFrames(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.reportAssetFrames as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reportAssetFrames as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes aggregateAssetsValues with closed client', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.AggregateAssetsValuesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.AggregateAssetsValuesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.aggregateAssetsValues(request), + expectedError, + ); + }); + }); + + describe('getImportJob', () => { + it('invokes getImportJob without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetImportJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetImportJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ImportJob(), + ); + client.innerApiCalls.getImportJob = stubSimpleCall(expectedResponse); + const [response] = await client.getImportJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getImportJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getImportJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes reportAssetFrames without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ReportAssetFramesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ReportAssetFramesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ReportAssetFramesResponse() - ); - client.innerApiCalls.reportAssetFrames = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.reportAssetFrames( - request, - (err?: Error|null, result?: protos.google.cloud.migrationcenter.v1.IReportAssetFramesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.reportAssetFrames as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reportAssetFrames as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getImportJob without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetImportJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetImportJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ImportJob(), + ); + client.innerApiCalls.getImportJob = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getImportJob( + request, + ( + err?: Error | null, + result?: protos.google.cloud.migrationcenter.v1.IImportJob | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getImportJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getImportJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes reportAssetFrames with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ReportAssetFramesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ReportAssetFramesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.reportAssetFrames = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.reportAssetFrames(request), expectedError); - const actualRequest = (client.innerApiCalls.reportAssetFrames as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reportAssetFrames as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getImportJob with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetImportJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetImportJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getImportJob = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getImportJob(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getImportJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getImportJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes reportAssetFrames with closed client', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ReportAssetFramesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ReportAssetFramesRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.reportAssetFrames(request), expectedError); - }); + it('invokes getImportJob with closed client', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetImportJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetImportJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getImportJob(request), expectedError); + }); + }); + + describe('getImportDataFile', () => { + it('invokes getImportDataFile without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetImportDataFileRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetImportDataFileRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ImportDataFile(), + ); + client.innerApiCalls.getImportDataFile = stubSimpleCall(expectedResponse); + const [response] = await client.getImportDataFile(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getImportDataFile as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getImportDataFile as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('aggregateAssetsValues', () => { - it('invokes aggregateAssetsValues without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.AggregateAssetsValuesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.AggregateAssetsValuesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.AggregateAssetsValuesResponse() - ); - client.innerApiCalls.aggregateAssetsValues = stubSimpleCall(expectedResponse); - const [response] = await client.aggregateAssetsValues(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.aggregateAssetsValues as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.aggregateAssetsValues as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getImportDataFile without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetImportDataFileRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetImportDataFileRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ImportDataFile(), + ); + client.innerApiCalls.getImportDataFile = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getImportDataFile( + request, + ( + err?: Error | null, + result?: protos.google.cloud.migrationcenter.v1.IImportDataFile | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getImportDataFile as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getImportDataFile as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes aggregateAssetsValues without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.AggregateAssetsValuesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.AggregateAssetsValuesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.AggregateAssetsValuesResponse() - ); - client.innerApiCalls.aggregateAssetsValues = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.aggregateAssetsValues( - request, - (err?: Error|null, result?: protos.google.cloud.migrationcenter.v1.IAggregateAssetsValuesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.aggregateAssetsValues as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.aggregateAssetsValues as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getImportDataFile with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetImportDataFileRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetImportDataFileRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getImportDataFile = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getImportDataFile(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getImportDataFile as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getImportDataFile as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes aggregateAssetsValues with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.AggregateAssetsValuesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.AggregateAssetsValuesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.aggregateAssetsValues = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.aggregateAssetsValues(request), expectedError); - const actualRequest = (client.innerApiCalls.aggregateAssetsValues as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.aggregateAssetsValues as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getImportDataFile with closed client', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetImportDataFileRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetImportDataFileRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getImportDataFile(request), expectedError); + }); + }); + + describe('getGroup', () => { + it('invokes getGroup without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Group(), + ); + client.innerApiCalls.getGroup = stubSimpleCall(expectedResponse); + const [response] = await client.getGroup(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes aggregateAssetsValues with closed client', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.AggregateAssetsValuesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.AggregateAssetsValuesRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.aggregateAssetsValues(request), expectedError); - }); + it('invokes getGroup without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Group(), + ); + client.innerApiCalls.getGroup = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getGroup( + request, + ( + err?: Error | null, + result?: protos.google.cloud.migrationcenter.v1.IGroup | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getImportJob', () => { - it('invokes getImportJob without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetImportJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetImportJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ImportJob() - ); - client.innerApiCalls.getImportJob = stubSimpleCall(expectedResponse); - const [response] = await client.getImportJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getImportJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getImportJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getGroup with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getGroup = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getGroup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getImportJob without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetImportJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetImportJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ImportJob() - ); - client.innerApiCalls.getImportJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getImportJob( - request, - (err?: Error|null, result?: protos.google.cloud.migrationcenter.v1.IImportJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getImportJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getImportJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getGroup with closed client', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getGroup(request), expectedError); + }); + }); + + describe('getErrorFrame', () => { + it('invokes getErrorFrame without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetErrorFrameRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetErrorFrameRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ErrorFrame(), + ); + client.innerApiCalls.getErrorFrame = stubSimpleCall(expectedResponse); + const [response] = await client.getErrorFrame(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getErrorFrame as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getErrorFrame as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getImportJob with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetImportJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetImportJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getImportJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getImportJob(request), expectedError); - const actualRequest = (client.innerApiCalls.getImportJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getImportJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getErrorFrame without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetErrorFrameRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetErrorFrameRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ErrorFrame(), + ); + client.innerApiCalls.getErrorFrame = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getErrorFrame( + request, + ( + err?: Error | null, + result?: protos.google.cloud.migrationcenter.v1.IErrorFrame | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getErrorFrame as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getErrorFrame as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getImportJob with closed client', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetImportJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetImportJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getImportJob(request), expectedError); - }); + it('invokes getErrorFrame with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetErrorFrameRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetErrorFrameRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getErrorFrame = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getErrorFrame(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getErrorFrame as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getErrorFrame as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getImportDataFile', () => { - it('invokes getImportDataFile without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetImportDataFileRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetImportDataFileRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ImportDataFile() - ); - client.innerApiCalls.getImportDataFile = stubSimpleCall(expectedResponse); - const [response] = await client.getImportDataFile(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getImportDataFile as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getImportDataFile as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getErrorFrame with closed client', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetErrorFrameRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetErrorFrameRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getErrorFrame(request), expectedError); + }); + }); + + describe('getSource', () => { + it('invokes getSource without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetSourceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetSourceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Source(), + ); + client.innerApiCalls.getSource = stubSimpleCall(expectedResponse); + const [response] = await client.getSource(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getSource as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSource as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getImportDataFile without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetImportDataFileRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetImportDataFileRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ImportDataFile() - ); - client.innerApiCalls.getImportDataFile = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getImportDataFile( - request, - (err?: Error|null, result?: protos.google.cloud.migrationcenter.v1.IImportDataFile|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getImportDataFile as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getImportDataFile as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getSource without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetSourceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetSourceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Source(), + ); + client.innerApiCalls.getSource = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getSource( + request, + ( + err?: Error | null, + result?: protos.google.cloud.migrationcenter.v1.ISource | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getSource as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSource as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getImportDataFile with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetImportDataFileRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetImportDataFileRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getImportDataFile = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getImportDataFile(request), expectedError); - const actualRequest = (client.innerApiCalls.getImportDataFile as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getImportDataFile as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getSource with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetSourceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetSourceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getSource = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getSource(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getSource as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSource as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getImportDataFile with closed client', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetImportDataFileRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetImportDataFileRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getImportDataFile(request), expectedError); - }); + it('invokes getSource with closed client', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetSourceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetSourceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getSource(request), expectedError); + }); + }); + + describe('getPreferenceSet', () => { + it('invokes getPreferenceSet without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetPreferenceSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetPreferenceSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.PreferenceSet(), + ); + client.innerApiCalls.getPreferenceSet = stubSimpleCall(expectedResponse); + const [response] = await client.getPreferenceSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getPreferenceSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPreferenceSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getGroup', () => { - it('invokes getGroup without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetGroupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.Group() - ); - client.innerApiCalls.getGroup = stubSimpleCall(expectedResponse); - const [response] = await client.getGroup(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getPreferenceSet without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetPreferenceSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetPreferenceSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.PreferenceSet(), + ); + client.innerApiCalls.getPreferenceSet = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getPreferenceSet( + request, + ( + err?: Error | null, + result?: protos.google.cloud.migrationcenter.v1.IPreferenceSet | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getPreferenceSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPreferenceSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getGroup without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetGroupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.Group() - ); - client.innerApiCalls.getGroup = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getGroup( - request, - (err?: Error|null, result?: protos.google.cloud.migrationcenter.v1.IGroup|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getPreferenceSet with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetPreferenceSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetPreferenceSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getPreferenceSet = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getPreferenceSet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getPreferenceSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPreferenceSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getGroup with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetGroupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getGroup = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getGroup(request), expectedError); - const actualRequest = (client.innerApiCalls.getGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getPreferenceSet with closed client', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetPreferenceSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetPreferenceSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getPreferenceSet(request), expectedError); + }); + }); + + describe('getSettings', () => { + it('invokes getSettings without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetSettingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetSettingsRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Settings(), + ); + client.innerApiCalls.getSettings = stubSimpleCall(expectedResponse); + const [response] = await client.getSettings(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getSettings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSettings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getGroup with closed client', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetGroupRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getGroup(request), expectedError); - }); + it('invokes getSettings without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetSettingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetSettingsRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Settings(), + ); + client.innerApiCalls.getSettings = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getSettings( + request, + ( + err?: Error | null, + result?: protos.google.cloud.migrationcenter.v1.ISettings | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getSettings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSettings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getErrorFrame', () => { - it('invokes getErrorFrame without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetErrorFrameRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetErrorFrameRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ErrorFrame() - ); - client.innerApiCalls.getErrorFrame = stubSimpleCall(expectedResponse); - const [response] = await client.getErrorFrame(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getErrorFrame as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getErrorFrame as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getSettings with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetSettingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetSettingsRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getSettings = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getSettings(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getSettings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSettings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getErrorFrame without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetErrorFrameRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetErrorFrameRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ErrorFrame() - ); - client.innerApiCalls.getErrorFrame = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getErrorFrame( - request, - (err?: Error|null, result?: protos.google.cloud.migrationcenter.v1.IErrorFrame|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getErrorFrame as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getErrorFrame as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getSettings with closed client', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetSettingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetSettingsRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getSettings(request), expectedError); + }); + }); + + describe('getReportConfig', () => { + it('invokes getReportConfig without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetReportConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetReportConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ReportConfig(), + ); + client.innerApiCalls.getReportConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getReportConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getReportConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getReportConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getErrorFrame with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetErrorFrameRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetErrorFrameRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getErrorFrame = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getErrorFrame(request), expectedError); - const actualRequest = (client.innerApiCalls.getErrorFrame as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getErrorFrame as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getReportConfig without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetReportConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetReportConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ReportConfig(), + ); + client.innerApiCalls.getReportConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getReportConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.migrationcenter.v1.IReportConfig | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getReportConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getReportConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getErrorFrame with closed client', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetErrorFrameRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetErrorFrameRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getErrorFrame(request), expectedError); - }); + it('invokes getReportConfig with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetReportConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetReportConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getReportConfig = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getReportConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getReportConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getReportConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getSource', () => { - it('invokes getSource without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetSourceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetSourceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.Source() - ); - client.innerApiCalls.getSource = stubSimpleCall(expectedResponse); - const [response] = await client.getSource(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSource as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSource as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getReportConfig with closed client', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetReportConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetReportConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getReportConfig(request), expectedError); + }); + }); + + describe('getReport', () => { + it('invokes getReport without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetReportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetReportRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Report(), + ); + client.innerApiCalls.getReport = stubSimpleCall(expectedResponse); + const [response] = await client.getReport(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getReport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getReport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getSource without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetSourceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetSourceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.Source() - ); - client.innerApiCalls.getSource = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getSource( - request, - (err?: Error|null, result?: protos.google.cloud.migrationcenter.v1.ISource|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSource as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSource as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getReport without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetReportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetReportRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Report(), + ); + client.innerApiCalls.getReport = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getReport( + request, + ( + err?: Error | null, + result?: protos.google.cloud.migrationcenter.v1.IReport | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getReport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getReport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getSource with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetSourceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetSourceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getSource = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getSource(request), expectedError); - const actualRequest = (client.innerApiCalls.getSource as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSource as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getReport with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetReportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetReportRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getReport = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getReport(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getReport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getReport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getSource with closed client', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetSourceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetSourceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getSource(request), expectedError); - }); + it('invokes getReport with closed client', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.GetReportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.GetReportRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getReport(request), expectedError); + }); + }); + + describe('createImportJob', () => { + it('invokes createImportJob without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.CreateImportJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.CreateImportJobRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createImportJob = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createImportJob(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createImportJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createImportJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getPreferenceSet', () => { - it('invokes getPreferenceSet without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetPreferenceSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetPreferenceSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.PreferenceSet() - ); - client.innerApiCalls.getPreferenceSet = stubSimpleCall(expectedResponse); - const [response] = await client.getPreferenceSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getPreferenceSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPreferenceSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createImportJob without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.CreateImportJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.CreateImportJobRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createImportJob = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createImportJob( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.migrationcenter.v1.IImportJob, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.migrationcenter.v1.IImportJob, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createImportJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createImportJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getPreferenceSet without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetPreferenceSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetPreferenceSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.PreferenceSet() - ); - client.innerApiCalls.getPreferenceSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getPreferenceSet( - request, - (err?: Error|null, result?: protos.google.cloud.migrationcenter.v1.IPreferenceSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getPreferenceSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPreferenceSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createImportJob with call error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.CreateImportJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.CreateImportJobRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createImportJob = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createImportJob(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createImportJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createImportJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getPreferenceSet with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetPreferenceSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetPreferenceSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getPreferenceSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getPreferenceSet(request), expectedError); - const actualRequest = (client.innerApiCalls.getPreferenceSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPreferenceSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createImportJob with LRO error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.CreateImportJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.CreateImportJobRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createImportJob = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createImportJob(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createImportJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createImportJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getPreferenceSet with closed client', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetPreferenceSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetPreferenceSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getPreferenceSet(request), expectedError); - }); + it('invokes checkCreateImportJobProgress without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateImportJobProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('getSettings', () => { - it('invokes getSettings without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetSettingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetSettingsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.Settings() - ); - client.innerApiCalls.getSettings = stubSimpleCall(expectedResponse); - const [response] = await client.getSettings(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSettings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSettings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateImportJobProgress with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateImportJobProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteImportJob', () => { + it('invokes deleteImportJob without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeleteImportJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeleteImportJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteImportJob = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteImportJob(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteImportJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteImportJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getSettings without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetSettingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetSettingsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.Settings() - ); - client.innerApiCalls.getSettings = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getSettings( - request, - (err?: Error|null, result?: protos.google.cloud.migrationcenter.v1.ISettings|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSettings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSettings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteImportJob without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeleteImportJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeleteImportJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteImportJob = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteImportJob( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteImportJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteImportJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getSettings with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetSettingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetSettingsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getSettings = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getSettings(request), expectedError); - const actualRequest = (client.innerApiCalls.getSettings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSettings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteImportJob with call error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeleteImportJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeleteImportJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteImportJob = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteImportJob(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteImportJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteImportJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getSettings with closed client', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetSettingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetSettingsRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getSettings(request), expectedError); - }); + it('invokes deleteImportJob with LRO error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeleteImportJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeleteImportJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteImportJob = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteImportJob(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteImportJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteImportJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getReportConfig', () => { - it('invokes getReportConfig without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetReportConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetReportConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ReportConfig() - ); - client.innerApiCalls.getReportConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getReportConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getReportConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getReportConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteImportJobProgress without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteImportJobProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes getReportConfig without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetReportConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetReportConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ReportConfig() - ); - client.innerApiCalls.getReportConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getReportConfig( - request, - (err?: Error|null, result?: protos.google.cloud.migrationcenter.v1.IReportConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getReportConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getReportConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteImportJobProgress with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteImportJobProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateImportJob', () => { + it('invokes updateImportJob without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.UpdateImportJobRequest(), + ); + request.importJob ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.UpdateImportJobRequest', + ['importJob', 'name'], + ); + request.importJob.name = defaultValue1; + const expectedHeaderRequestParams = `import_job.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateImportJob = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateImportJob(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateImportJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateImportJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getReportConfig with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetReportConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetReportConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getReportConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getReportConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.getReportConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getReportConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateImportJob without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.UpdateImportJobRequest(), + ); + request.importJob ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.UpdateImportJobRequest', + ['importJob', 'name'], + ); + request.importJob.name = defaultValue1; + const expectedHeaderRequestParams = `import_job.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateImportJob = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateImportJob( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.migrationcenter.v1.IImportJob, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.migrationcenter.v1.IImportJob, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateImportJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateImportJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getReportConfig with closed client', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetReportConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetReportConfigRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getReportConfig(request), expectedError); - }); + it('invokes updateImportJob with call error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.UpdateImportJobRequest(), + ); + request.importJob ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.UpdateImportJobRequest', + ['importJob', 'name'], + ); + request.importJob.name = defaultValue1; + const expectedHeaderRequestParams = `import_job.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateImportJob = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateImportJob(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateImportJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateImportJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getReport', () => { - it('invokes getReport without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetReportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetReportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.Report() - ); - client.innerApiCalls.getReport = stubSimpleCall(expectedResponse); - const [response] = await client.getReport(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getReport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getReport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateImportJob with LRO error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.UpdateImportJobRequest(), + ); + request.importJob ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.UpdateImportJobRequest', + ['importJob', 'name'], + ); + request.importJob.name = defaultValue1; + const expectedHeaderRequestParams = `import_job.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateImportJob = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateImportJob(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateImportJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateImportJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getReport without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetReportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetReportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.Report() - ); - client.innerApiCalls.getReport = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getReport( - request, - (err?: Error|null, result?: protos.google.cloud.migrationcenter.v1.IReport|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getReport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getReport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateImportJobProgress without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateImportJobProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes getReport with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetReportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetReportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getReport = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getReport(request), expectedError); - const actualRequest = (client.innerApiCalls.getReport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getReport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateImportJobProgress with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateImportJobProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('validateImportJob', () => { + it('invokes validateImportJob without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ValidateImportJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ValidateImportJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.validateImportJob = + stubLongRunningCall(expectedResponse); + const [operation] = await client.validateImportJob(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.validateImportJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.validateImportJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getReport with closed client', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.GetReportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.GetReportRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getReport(request), expectedError); - }); + it('invokes validateImportJob without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ValidateImportJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ValidateImportJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.validateImportJob = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.validateImportJob( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.validateImportJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.validateImportJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createImportJob', () => { - it('invokes createImportJob without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.CreateImportJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.CreateImportJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createImportJob = stubLongRunningCall(expectedResponse); - const [operation] = await client.createImportJob(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createImportJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createImportJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes validateImportJob with call error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ValidateImportJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ValidateImportJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.validateImportJob = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.validateImportJob(request), expectedError); + const actualRequest = ( + client.innerApiCalls.validateImportJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.validateImportJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createImportJob without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.CreateImportJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.CreateImportJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createImportJob = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createImportJob( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createImportJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createImportJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes validateImportJob with LRO error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ValidateImportJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ValidateImportJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.validateImportJob = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.validateImportJob(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.validateImportJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.validateImportJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createImportJob with call error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.CreateImportJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.CreateImportJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createImportJob = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createImportJob(request), expectedError); - const actualRequest = (client.innerApiCalls.createImportJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createImportJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkValidateImportJobProgress without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkValidateImportJobProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createImportJob with LRO error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.CreateImportJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.CreateImportJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createImportJob = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createImportJob(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createImportJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createImportJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkValidateImportJobProgress with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkValidateImportJobProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('runImportJob', () => { + it('invokes runImportJob without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.RunImportJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.RunImportJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.runImportJob = stubLongRunningCall(expectedResponse); + const [operation] = await client.runImportJob(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.runImportJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.runImportJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateImportJobProgress without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateImportJobProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes runImportJob without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.RunImportJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.RunImportJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.runImportJob = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.runImportJob( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.runImportJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.runImportJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateImportJobProgress with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateImportJobProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes runImportJob with call error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.RunImportJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.RunImportJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.runImportJob = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.runImportJob(request), expectedError); + const actualRequest = ( + client.innerApiCalls.runImportJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.runImportJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteImportJob', () => { - it('invokes deleteImportJob without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeleteImportJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeleteImportJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteImportJob = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteImportJob(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteImportJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteImportJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes runImportJob with LRO error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.RunImportJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.RunImportJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.runImportJob = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.runImportJob(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.runImportJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.runImportJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteImportJob without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeleteImportJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeleteImportJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteImportJob = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteImportJob( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteImportJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteImportJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRunImportJobProgress without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkRunImportJobProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteImportJob with call error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeleteImportJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeleteImportJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteImportJob = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteImportJob(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteImportJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteImportJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRunImportJobProgress with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkRunImportJobProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createImportDataFile', () => { + it('invokes createImportDataFile without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.CreateImportDataFileRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.CreateImportDataFileRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createImportDataFile = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createImportDataFile(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createImportDataFile as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createImportDataFile as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteImportJob with LRO error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeleteImportJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeleteImportJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteImportJob = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteImportJob(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteImportJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteImportJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createImportDataFile without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.CreateImportDataFileRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.CreateImportDataFileRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createImportDataFile = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createImportDataFile( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.migrationcenter.v1.IImportDataFile, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.migrationcenter.v1.IImportDataFile, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createImportDataFile as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createImportDataFile as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteImportJobProgress without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteImportJobProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createImportDataFile with call error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.CreateImportDataFileRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.CreateImportDataFileRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createImportDataFile = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createImportDataFile(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createImportDataFile as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createImportDataFile as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteImportJobProgress with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteImportJobProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createImportDataFile with LRO error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.CreateImportDataFileRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.CreateImportDataFileRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createImportDataFile = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createImportDataFile(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createImportDataFile as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createImportDataFile as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateImportJob', () => { - it('invokes updateImportJob without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.UpdateImportJobRequest() - ); - request.importJob ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.UpdateImportJobRequest', ['importJob', 'name']); - request.importJob.name = defaultValue1; - const expectedHeaderRequestParams = `import_job.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateImportJob = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateImportJob(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateImportJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateImportJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateImportDataFileProgress without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateImportDataFileProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateImportJob without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.UpdateImportJobRequest() - ); - request.importJob ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.UpdateImportJobRequest', ['importJob', 'name']); - request.importJob.name = defaultValue1; - const expectedHeaderRequestParams = `import_job.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateImportJob = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateImportJob( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateImportJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateImportJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateImportDataFileProgress with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateImportDataFileProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteImportDataFile', () => { + it('invokes deleteImportDataFile without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeleteImportDataFileRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeleteImportDataFileRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteImportDataFile = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteImportDataFile(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteImportDataFile as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteImportDataFile as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateImportJob with call error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.UpdateImportJobRequest() - ); - request.importJob ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.UpdateImportJobRequest', ['importJob', 'name']); - request.importJob.name = defaultValue1; - const expectedHeaderRequestParams = `import_job.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateImportJob = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateImportJob(request), expectedError); - const actualRequest = (client.innerApiCalls.updateImportJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateImportJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteImportDataFile without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeleteImportDataFileRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeleteImportDataFileRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteImportDataFile = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteImportDataFile( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteImportDataFile as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteImportDataFile as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateImportJob with LRO error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.UpdateImportJobRequest() - ); - request.importJob ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.UpdateImportJobRequest', ['importJob', 'name']); - request.importJob.name = defaultValue1; - const expectedHeaderRequestParams = `import_job.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateImportJob = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateImportJob(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateImportJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateImportJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteImportDataFile with call error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeleteImportDataFileRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeleteImportDataFileRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteImportDataFile = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteImportDataFile(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteImportDataFile as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteImportDataFile as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateImportJobProgress without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateImportJobProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteImportDataFile with LRO error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeleteImportDataFileRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeleteImportDataFileRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteImportDataFile = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteImportDataFile(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteImportDataFile as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteImportDataFile as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateImportJobProgress with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateImportJobProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteImportDataFileProgress without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteImportDataFileProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('validateImportJob', () => { - it('invokes validateImportJob without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ValidateImportJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ValidateImportJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.validateImportJob = stubLongRunningCall(expectedResponse); - const [operation] = await client.validateImportJob(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.validateImportJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.validateImportJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteImportDataFileProgress with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteImportDataFileProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createGroup', () => { + it('invokes createGroup without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.CreateGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.CreateGroupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createGroup = stubLongRunningCall(expectedResponse); + const [operation] = await client.createGroup(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes validateImportJob without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ValidateImportJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ValidateImportJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.validateImportJob = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.validateImportJob( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.validateImportJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.validateImportJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createGroup without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.CreateGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.CreateGroupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createGroup = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createGroup( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes validateImportJob with call error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ValidateImportJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ValidateImportJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.validateImportJob = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.validateImportJob(request), expectedError); - const actualRequest = (client.innerApiCalls.validateImportJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.validateImportJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createGroup with call error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.CreateGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.CreateGroupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createGroup = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createGroup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes validateImportJob with LRO error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ValidateImportJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ValidateImportJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.validateImportJob = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.validateImportJob(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.validateImportJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.validateImportJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createGroup with LRO error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.CreateGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.CreateGroupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createGroup = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createGroup(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkValidateImportJobProgress without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkValidateImportJobProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkCreateGroupProgress without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateGroupProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkValidateImportJobProgress with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkValidateImportJobProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateGroupProgress with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkCreateGroupProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateGroup', () => { + it('invokes updateGroup without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.UpdateGroupRequest(), + ); + request.group ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.UpdateGroupRequest', + ['group', 'name'], + ); + request.group.name = defaultValue1; + const expectedHeaderRequestParams = `group.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateGroup = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateGroup(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('runImportJob', () => { - it('invokes runImportJob without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.RunImportJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.RunImportJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.runImportJob = stubLongRunningCall(expectedResponse); - const [operation] = await client.runImportJob(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.runImportJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runImportJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateGroup without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.UpdateGroupRequest(), + ); + request.group ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.UpdateGroupRequest', + ['group', 'name'], + ); + request.group.name = defaultValue1; + const expectedHeaderRequestParams = `group.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateGroup = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateGroup( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes runImportJob without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.RunImportJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.RunImportJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.runImportJob = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.runImportJob( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.runImportJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runImportJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateGroup with call error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.UpdateGroupRequest(), + ); + request.group ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.UpdateGroupRequest', + ['group', 'name'], + ); + request.group.name = defaultValue1; + const expectedHeaderRequestParams = `group.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateGroup = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateGroup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes runImportJob with call error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.RunImportJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.RunImportJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.runImportJob = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.runImportJob(request), expectedError); - const actualRequest = (client.innerApiCalls.runImportJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runImportJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateGroup with LRO error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.UpdateGroupRequest(), + ); + request.group ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.UpdateGroupRequest', + ['group', 'name'], + ); + request.group.name = defaultValue1; + const expectedHeaderRequestParams = `group.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateGroup = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateGroup(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes runImportJob with LRO error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.RunImportJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.RunImportJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.runImportJob = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.runImportJob(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.runImportJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runImportJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateGroupProgress without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateGroupProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkRunImportJobProgress without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkRunImportJobProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateGroupProgress with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkUpdateGroupProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteGroup', () => { + it('invokes deleteGroup without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeleteGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeleteGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteGroup = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteGroup(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRunImportJobProgress with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRunImportJobProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteGroup without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeleteGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeleteGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteGroup = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteGroup( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createImportDataFile', () => { - it('invokes createImportDataFile without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.CreateImportDataFileRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.CreateImportDataFileRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createImportDataFile = stubLongRunningCall(expectedResponse); - const [operation] = await client.createImportDataFile(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createImportDataFile as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createImportDataFile as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteGroup with call error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeleteGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeleteGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteGroup = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteGroup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createImportDataFile without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.CreateImportDataFileRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.CreateImportDataFileRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createImportDataFile = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createImportDataFile( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createImportDataFile as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createImportDataFile as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteGroup with LRO error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeleteGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeleteGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteGroup = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteGroup(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createImportDataFile with call error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.CreateImportDataFileRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.CreateImportDataFileRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createImportDataFile = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createImportDataFile(request), expectedError); - const actualRequest = (client.innerApiCalls.createImportDataFile as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createImportDataFile as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createImportDataFile with LRO error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.CreateImportDataFileRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.CreateImportDataFileRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createImportDataFile = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createImportDataFile(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createImportDataFile as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createImportDataFile as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateImportDataFileProgress without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateImportDataFileProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateImportDataFileProgress with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateImportDataFileProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteGroupProgress without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteGroupProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('deleteImportDataFile', () => { - it('invokes deleteImportDataFile without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeleteImportDataFileRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeleteImportDataFileRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteImportDataFile = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteImportDataFile(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteImportDataFile as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteImportDataFile as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteImportDataFile without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeleteImportDataFileRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeleteImportDataFileRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteImportDataFile = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteImportDataFile( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteImportDataFile as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteImportDataFile as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteImportDataFile with call error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeleteImportDataFileRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeleteImportDataFileRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteImportDataFile = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteImportDataFile(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteImportDataFile as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteImportDataFile as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteImportDataFile with LRO error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeleteImportDataFileRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeleteImportDataFileRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteImportDataFile = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteImportDataFile(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteImportDataFile as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteImportDataFile as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteImportDataFileProgress without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteImportDataFileProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteImportDataFileProgress with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteImportDataFileProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteGroupProgress with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkDeleteGroupProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - - describe('createGroup', () => { - it('invokes createGroup without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.CreateGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.CreateGroupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createGroup = stubLongRunningCall(expectedResponse); - const [operation] = await client.createGroup(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createGroup without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.CreateGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.CreateGroupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createGroup = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createGroup( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createGroup with call error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.CreateGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.CreateGroupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createGroup = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createGroup(request), expectedError); - const actualRequest = (client.innerApiCalls.createGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createGroup with LRO error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.CreateGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.CreateGroupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createGroup = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createGroup(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateGroupProgress without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateGroupProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateGroupProgress with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateGroupProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + }); + + describe('addAssetsToGroup', () => { + it('invokes addAssetsToGroup without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.AddAssetsToGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.AddAssetsToGroupRequest', + ['group'], + ); + request.group = defaultValue1; + const expectedHeaderRequestParams = `group=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.addAssetsToGroup = + stubLongRunningCall(expectedResponse); + const [operation] = await client.addAssetsToGroup(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addAssetsToGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addAssetsToGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateGroup', () => { - it('invokes updateGroup without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.UpdateGroupRequest() - ); - request.group ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.UpdateGroupRequest', ['group', 'name']); - request.group.name = defaultValue1; - const expectedHeaderRequestParams = `group.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateGroup = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateGroup(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateGroup without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.UpdateGroupRequest() - ); - request.group ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.UpdateGroupRequest', ['group', 'name']); - request.group.name = defaultValue1; - const expectedHeaderRequestParams = `group.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateGroup = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateGroup( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateGroup with call error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.UpdateGroupRequest() - ); - request.group ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.UpdateGroupRequest', ['group', 'name']); - request.group.name = defaultValue1; - const expectedHeaderRequestParams = `group.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateGroup = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateGroup(request), expectedError); - const actualRequest = (client.innerApiCalls.updateGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateGroup with LRO error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.UpdateGroupRequest() - ); - request.group ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.UpdateGroupRequest', ['group', 'name']); - request.group.name = defaultValue1; - const expectedHeaderRequestParams = `group.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateGroup = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateGroup(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateGroupProgress without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateGroupProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateGroupProgress with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateGroupProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes addAssetsToGroup without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.AddAssetsToGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.AddAssetsToGroupRequest', + ['group'], + ); + request.group = defaultValue1; + const expectedHeaderRequestParams = `group=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.addAssetsToGroup = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addAssetsToGroup( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addAssetsToGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addAssetsToGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteGroup', () => { - it('invokes deleteGroup without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeleteGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeleteGroupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteGroup = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteGroup(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteGroup without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeleteGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeleteGroupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteGroup = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteGroup( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteGroup with call error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeleteGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeleteGroupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteGroup = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteGroup(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteGroup with LRO error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeleteGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeleteGroupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteGroup = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteGroup(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteGroupProgress without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteGroupProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteGroupProgress with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteGroupProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes addAssetsToGroup with call error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.AddAssetsToGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.AddAssetsToGroupRequest', + ['group'], + ); + request.group = defaultValue1; + const expectedHeaderRequestParams = `group=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addAssetsToGroup = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.addAssetsToGroup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.addAssetsToGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addAssetsToGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('addAssetsToGroup', () => { - it('invokes addAssetsToGroup without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.AddAssetsToGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.AddAssetsToGroupRequest', ['group']); - request.group = defaultValue1; - const expectedHeaderRequestParams = `group=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.addAssetsToGroup = stubLongRunningCall(expectedResponse); - const [operation] = await client.addAssetsToGroup(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addAssetsToGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addAssetsToGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addAssetsToGroup without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.AddAssetsToGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.AddAssetsToGroupRequest', ['group']); - request.group = defaultValue1; - const expectedHeaderRequestParams = `group=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.addAssetsToGroup = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addAssetsToGroup( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addAssetsToGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addAssetsToGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addAssetsToGroup with call error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.AddAssetsToGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.AddAssetsToGroupRequest', ['group']); - request.group = defaultValue1; - const expectedHeaderRequestParams = `group=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.addAssetsToGroup = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.addAssetsToGroup(request), expectedError); - const actualRequest = (client.innerApiCalls.addAssetsToGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addAssetsToGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addAssetsToGroup with LRO error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.AddAssetsToGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.AddAssetsToGroupRequest', ['group']); - request.group = defaultValue1; - const expectedHeaderRequestParams = `group=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.addAssetsToGroup = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.addAssetsToGroup(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.addAssetsToGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addAssetsToGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkAddAssetsToGroupProgress without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkAddAssetsToGroupProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAddAssetsToGroupProgress with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkAddAssetsToGroupProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes addAssetsToGroup with LRO error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.AddAssetsToGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.AddAssetsToGroupRequest', + ['group'], + ); + request.group = defaultValue1; + const expectedHeaderRequestParams = `group=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addAssetsToGroup = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.addAssetsToGroup(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.addAssetsToGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addAssetsToGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('removeAssetsFromGroup', () => { - it('invokes removeAssetsFromGroup without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.RemoveAssetsFromGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.RemoveAssetsFromGroupRequest', ['group']); - request.group = defaultValue1; - const expectedHeaderRequestParams = `group=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.removeAssetsFromGroup = stubLongRunningCall(expectedResponse); - const [operation] = await client.removeAssetsFromGroup(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.removeAssetsFromGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeAssetsFromGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes removeAssetsFromGroup without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.RemoveAssetsFromGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.RemoveAssetsFromGroupRequest', ['group']); - request.group = defaultValue1; - const expectedHeaderRequestParams = `group=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.removeAssetsFromGroup = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeAssetsFromGroup( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.removeAssetsFromGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeAssetsFromGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes removeAssetsFromGroup with call error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.RemoveAssetsFromGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.RemoveAssetsFromGroupRequest', ['group']); - request.group = defaultValue1; - const expectedHeaderRequestParams = `group=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.removeAssetsFromGroup = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.removeAssetsFromGroup(request), expectedError); - const actualRequest = (client.innerApiCalls.removeAssetsFromGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeAssetsFromGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes removeAssetsFromGroup with LRO error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.RemoveAssetsFromGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.RemoveAssetsFromGroupRequest', ['group']); - request.group = defaultValue1; - const expectedHeaderRequestParams = `group=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.removeAssetsFromGroup = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.removeAssetsFromGroup(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.removeAssetsFromGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeAssetsFromGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkRemoveAssetsFromGroupProgress without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkRemoveAssetsFromGroupProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRemoveAssetsFromGroupProgress with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRemoveAssetsFromGroupProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkAddAssetsToGroupProgress without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkAddAssetsToGroupProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('createSource', () => { - it('invokes createSource without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.CreateSourceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.CreateSourceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createSource = stubLongRunningCall(expectedResponse); - const [operation] = await client.createSource(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createSource as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSource as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createSource without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.CreateSourceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.CreateSourceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createSource = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createSource( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createSource as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSource as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createSource with call error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.CreateSourceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.CreateSourceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createSource = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createSource(request), expectedError); - const actualRequest = (client.innerApiCalls.createSource as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSource as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createSource with LRO error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.CreateSourceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.CreateSourceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createSource = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createSource(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createSource as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSource as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateSourceProgress without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateSourceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkAddAssetsToGroupProgress with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkAddAssetsToGroupProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('removeAssetsFromGroup', () => { + it('invokes removeAssetsFromGroup without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.RemoveAssetsFromGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.RemoveAssetsFromGroupRequest', + ['group'], + ); + request.group = defaultValue1; + const expectedHeaderRequestParams = `group=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.removeAssetsFromGroup = + stubLongRunningCall(expectedResponse); + const [operation] = await client.removeAssetsFromGroup(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeAssetsFromGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeAssetsFromGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateSourceProgress with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateSourceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes removeAssetsFromGroup without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.RemoveAssetsFromGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.RemoveAssetsFromGroupRequest', + ['group'], + ); + request.group = defaultValue1; + const expectedHeaderRequestParams = `group=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.removeAssetsFromGroup = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeAssetsFromGroup( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.migrationcenter.v1.IGroup, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeAssetsFromGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeAssetsFromGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateSource', () => { - it('invokes updateSource without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.UpdateSourceRequest() - ); - request.source ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.UpdateSourceRequest', ['source', 'name']); - request.source.name = defaultValue1; - const expectedHeaderRequestParams = `source.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateSource = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateSource(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateSource as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSource as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes removeAssetsFromGroup with call error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.RemoveAssetsFromGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.RemoveAssetsFromGroupRequest', + ['group'], + ); + request.group = defaultValue1; + const expectedHeaderRequestParams = `group=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeAssetsFromGroup = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.removeAssetsFromGroup(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.removeAssetsFromGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeAssetsFromGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateSource without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.UpdateSourceRequest() - ); - request.source ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.UpdateSourceRequest', ['source', 'name']); - request.source.name = defaultValue1; - const expectedHeaderRequestParams = `source.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateSource = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateSource( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateSource as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSource as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes removeAssetsFromGroup with LRO error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.RemoveAssetsFromGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.RemoveAssetsFromGroupRequest', + ['group'], + ); + request.group = defaultValue1; + const expectedHeaderRequestParams = `group=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeAssetsFromGroup = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.removeAssetsFromGroup(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.removeAssetsFromGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeAssetsFromGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateSource with call error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.UpdateSourceRequest() - ); - request.source ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.UpdateSourceRequest', ['source', 'name']); - request.source.name = defaultValue1; - const expectedHeaderRequestParams = `source.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateSource = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateSource(request), expectedError); - const actualRequest = (client.innerApiCalls.updateSource as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSource as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRemoveAssetsFromGroupProgress without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkRemoveAssetsFromGroupProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateSource with LRO error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.UpdateSourceRequest() - ); - request.source ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.UpdateSourceRequest', ['source', 'name']); - request.source.name = defaultValue1; - const expectedHeaderRequestParams = `source.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateSource = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateSource(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateSource as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSource as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRemoveAssetsFromGroupProgress with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkRemoveAssetsFromGroupProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createSource', () => { + it('invokes createSource without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.CreateSourceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.CreateSourceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createSource = stubLongRunningCall(expectedResponse); + const [operation] = await client.createSource(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createSource as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSource as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateSourceProgress without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateSourceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createSource without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.CreateSourceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.CreateSourceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createSource = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createSource( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.migrationcenter.v1.ISource, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.migrationcenter.v1.ISource, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createSource as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSource as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateSourceProgress with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateSourceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createSource with call error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.CreateSourceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.CreateSourceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createSource = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createSource(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createSource as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSource as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteSource', () => { - it('invokes deleteSource without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeleteSourceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeleteSourceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteSource = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteSource(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteSource as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSource as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createSource with LRO error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.CreateSourceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.CreateSourceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createSource = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createSource(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createSource as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSource as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteSource without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeleteSourceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeleteSourceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteSource = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteSource( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteSource as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSource as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateSourceProgress without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateSourceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteSource with call error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeleteSourceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeleteSourceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteSource = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteSource(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteSource as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSource as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateSourceProgress with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkCreateSourceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateSource', () => { + it('invokes updateSource without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.UpdateSourceRequest(), + ); + request.source ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.UpdateSourceRequest', + ['source', 'name'], + ); + request.source.name = defaultValue1; + const expectedHeaderRequestParams = `source.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateSource = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateSource(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateSource as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSource as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteSource with LRO error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeleteSourceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeleteSourceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteSource = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteSource(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteSource as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSource as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateSource without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.UpdateSourceRequest(), + ); + request.source ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.UpdateSourceRequest', + ['source', 'name'], + ); + request.source.name = defaultValue1; + const expectedHeaderRequestParams = `source.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateSource = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateSource( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.migrationcenter.v1.ISource, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.migrationcenter.v1.ISource, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateSource as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSource as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteSourceProgress without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteSourceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateSource with call error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.UpdateSourceRequest(), + ); + request.source ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.UpdateSourceRequest', + ['source', 'name'], + ); + request.source.name = defaultValue1; + const expectedHeaderRequestParams = `source.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateSource = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateSource(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateSource as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSource as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteSourceProgress with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteSourceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateSource with LRO error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.UpdateSourceRequest(), + ); + request.source ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.UpdateSourceRequest', + ['source', 'name'], + ); + request.source.name = defaultValue1; + const expectedHeaderRequestParams = `source.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateSource = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateSource(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateSource as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSource as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createPreferenceSet', () => { - it('invokes createPreferenceSet without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.CreatePreferenceSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.CreatePreferenceSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createPreferenceSet = stubLongRunningCall(expectedResponse); - const [operation] = await client.createPreferenceSet(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createPreferenceSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPreferenceSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateSourceProgress without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateSourceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createPreferenceSet without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.CreatePreferenceSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.CreatePreferenceSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createPreferenceSet = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createPreferenceSet( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createPreferenceSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPreferenceSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateSourceProgress with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkUpdateSourceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteSource', () => { + it('invokes deleteSource without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeleteSourceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeleteSourceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteSource = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteSource(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteSource as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSource as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createPreferenceSet with call error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.CreatePreferenceSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.CreatePreferenceSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createPreferenceSet = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createPreferenceSet(request), expectedError); - const actualRequest = (client.innerApiCalls.createPreferenceSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPreferenceSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteSource without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeleteSourceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeleteSourceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteSource = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteSource( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteSource as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSource as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createPreferenceSet with LRO error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.CreatePreferenceSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.CreatePreferenceSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createPreferenceSet = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createPreferenceSet(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createPreferenceSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPreferenceSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteSource with call error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeleteSourceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeleteSourceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteSource = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteSource(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteSource as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSource as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreatePreferenceSetProgress without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreatePreferenceSetProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteSource with LRO error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeleteSourceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeleteSourceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteSource = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteSource(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteSource as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSource as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreatePreferenceSetProgress with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreatePreferenceSetProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteSourceProgress without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteSourceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('updatePreferenceSet', () => { - it('invokes updatePreferenceSet without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.UpdatePreferenceSetRequest() - ); - request.preferenceSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.UpdatePreferenceSetRequest', ['preferenceSet', 'name']); - request.preferenceSet.name = defaultValue1; - const expectedHeaderRequestParams = `preference_set.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updatePreferenceSet = stubLongRunningCall(expectedResponse); - const [operation] = await client.updatePreferenceSet(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updatePreferenceSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updatePreferenceSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteSourceProgress with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkDeleteSourceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createPreferenceSet', () => { + it('invokes createPreferenceSet without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.CreatePreferenceSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.CreatePreferenceSetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createPreferenceSet = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createPreferenceSet(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createPreferenceSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPreferenceSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updatePreferenceSet without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.UpdatePreferenceSetRequest() - ); - request.preferenceSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.UpdatePreferenceSetRequest', ['preferenceSet', 'name']); - request.preferenceSet.name = defaultValue1; - const expectedHeaderRequestParams = `preference_set.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updatePreferenceSet = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updatePreferenceSet( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updatePreferenceSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updatePreferenceSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createPreferenceSet without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.CreatePreferenceSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.CreatePreferenceSetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createPreferenceSet = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createPreferenceSet( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.migrationcenter.v1.IPreferenceSet, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.migrationcenter.v1.IPreferenceSet, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createPreferenceSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPreferenceSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updatePreferenceSet with call error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.UpdatePreferenceSetRequest() - ); - request.preferenceSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.UpdatePreferenceSetRequest', ['preferenceSet', 'name']); - request.preferenceSet.name = defaultValue1; - const expectedHeaderRequestParams = `preference_set.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updatePreferenceSet = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updatePreferenceSet(request), expectedError); - const actualRequest = (client.innerApiCalls.updatePreferenceSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updatePreferenceSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createPreferenceSet with call error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.CreatePreferenceSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.CreatePreferenceSetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createPreferenceSet = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createPreferenceSet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createPreferenceSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPreferenceSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updatePreferenceSet with LRO error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.UpdatePreferenceSetRequest() - ); - request.preferenceSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.UpdatePreferenceSetRequest', ['preferenceSet', 'name']); - request.preferenceSet.name = defaultValue1; - const expectedHeaderRequestParams = `preference_set.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updatePreferenceSet = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updatePreferenceSet(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updatePreferenceSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updatePreferenceSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createPreferenceSet with LRO error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.CreatePreferenceSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.CreatePreferenceSetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createPreferenceSet = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createPreferenceSet(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createPreferenceSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPreferenceSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdatePreferenceSetProgress without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdatePreferenceSetProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkCreatePreferenceSetProgress without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreatePreferenceSetProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkUpdatePreferenceSetProgress with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdatePreferenceSetProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreatePreferenceSetProgress with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreatePreferenceSetProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updatePreferenceSet', () => { + it('invokes updatePreferenceSet without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.UpdatePreferenceSetRequest(), + ); + request.preferenceSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.UpdatePreferenceSetRequest', + ['preferenceSet', 'name'], + ); + request.preferenceSet.name = defaultValue1; + const expectedHeaderRequestParams = `preference_set.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updatePreferenceSet = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updatePreferenceSet(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updatePreferenceSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updatePreferenceSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deletePreferenceSet', () => { - it('invokes deletePreferenceSet without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeletePreferenceSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeletePreferenceSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deletePreferenceSet = stubLongRunningCall(expectedResponse); - const [operation] = await client.deletePreferenceSet(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deletePreferenceSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePreferenceSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updatePreferenceSet without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.UpdatePreferenceSetRequest(), + ); + request.preferenceSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.UpdatePreferenceSetRequest', + ['preferenceSet', 'name'], + ); + request.preferenceSet.name = defaultValue1; + const expectedHeaderRequestParams = `preference_set.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updatePreferenceSet = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updatePreferenceSet( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.migrationcenter.v1.IPreferenceSet, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.migrationcenter.v1.IPreferenceSet, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updatePreferenceSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updatePreferenceSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deletePreferenceSet without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeletePreferenceSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeletePreferenceSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deletePreferenceSet = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deletePreferenceSet( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deletePreferenceSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePreferenceSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updatePreferenceSet with call error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.UpdatePreferenceSetRequest(), + ); + request.preferenceSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.UpdatePreferenceSetRequest', + ['preferenceSet', 'name'], + ); + request.preferenceSet.name = defaultValue1; + const expectedHeaderRequestParams = `preference_set.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updatePreferenceSet = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updatePreferenceSet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updatePreferenceSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updatePreferenceSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deletePreferenceSet with call error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeletePreferenceSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeletePreferenceSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deletePreferenceSet = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deletePreferenceSet(request), expectedError); - const actualRequest = (client.innerApiCalls.deletePreferenceSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePreferenceSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updatePreferenceSet with LRO error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.UpdatePreferenceSetRequest(), + ); + request.preferenceSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.UpdatePreferenceSetRequest', + ['preferenceSet', 'name'], + ); + request.preferenceSet.name = defaultValue1; + const expectedHeaderRequestParams = `preference_set.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updatePreferenceSet = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updatePreferenceSet(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updatePreferenceSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updatePreferenceSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deletePreferenceSet with LRO error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeletePreferenceSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeletePreferenceSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deletePreferenceSet = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deletePreferenceSet(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deletePreferenceSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePreferenceSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdatePreferenceSetProgress without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdatePreferenceSetProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeletePreferenceSetProgress without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeletePreferenceSetProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdatePreferenceSetProgress with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdatePreferenceSetProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deletePreferenceSet', () => { + it('invokes deletePreferenceSet without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeletePreferenceSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeletePreferenceSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deletePreferenceSet = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deletePreferenceSet(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deletePreferenceSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePreferenceSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeletePreferenceSetProgress with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeletePreferenceSetProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deletePreferenceSet without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeletePreferenceSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeletePreferenceSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deletePreferenceSet = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deletePreferenceSet( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deletePreferenceSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePreferenceSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateSettings', () => { - it('invokes updateSettings without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.UpdateSettingsRequest() - ); - request.settings ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.UpdateSettingsRequest', ['settings', 'name']); - request.settings.name = defaultValue1; - const expectedHeaderRequestParams = `settings.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateSettings = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateSettings(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateSettings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSettings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deletePreferenceSet with call error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeletePreferenceSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeletePreferenceSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deletePreferenceSet = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deletePreferenceSet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deletePreferenceSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePreferenceSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateSettings without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.UpdateSettingsRequest() - ); - request.settings ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.UpdateSettingsRequest', ['settings', 'name']); - request.settings.name = defaultValue1; - const expectedHeaderRequestParams = `settings.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateSettings = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateSettings( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateSettings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSettings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deletePreferenceSet with LRO error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeletePreferenceSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeletePreferenceSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deletePreferenceSet = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deletePreferenceSet(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deletePreferenceSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePreferenceSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateSettings with call error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.UpdateSettingsRequest() - ); - request.settings ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.UpdateSettingsRequest', ['settings', 'name']); - request.settings.name = defaultValue1; - const expectedHeaderRequestParams = `settings.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateSettings = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateSettings(request), expectedError); - const actualRequest = (client.innerApiCalls.updateSettings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSettings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeletePreferenceSetProgress without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeletePreferenceSetProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateSettings with LRO error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.UpdateSettingsRequest() - ); - request.settings ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.UpdateSettingsRequest', ['settings', 'name']); - request.settings.name = defaultValue1; - const expectedHeaderRequestParams = `settings.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateSettings = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateSettings(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateSettings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSettings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeletePreferenceSetProgress with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeletePreferenceSetProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateSettings', () => { + it('invokes updateSettings without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.UpdateSettingsRequest(), + ); + request.settings ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.UpdateSettingsRequest', + ['settings', 'name'], + ); + request.settings.name = defaultValue1; + const expectedHeaderRequestParams = `settings.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateSettings = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateSettings(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateSettings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSettings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateSettingsProgress without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateSettingsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateSettings without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.UpdateSettingsRequest(), + ); + request.settings ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.UpdateSettingsRequest', + ['settings', 'name'], + ); + request.settings.name = defaultValue1; + const expectedHeaderRequestParams = `settings.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateSettings = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateSettings( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.migrationcenter.v1.ISettings, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.migrationcenter.v1.ISettings, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateSettings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSettings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateSettingsProgress with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateSettingsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateSettings with call error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.UpdateSettingsRequest(), + ); + request.settings ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.UpdateSettingsRequest', + ['settings', 'name'], + ); + request.settings.name = defaultValue1; + const expectedHeaderRequestParams = `settings.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateSettings = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateSettings(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateSettings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSettings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createReportConfig', () => { - it('invokes createReportConfig without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.CreateReportConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.CreateReportConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createReportConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.createReportConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createReportConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createReportConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateSettings with LRO error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.UpdateSettingsRequest(), + ); + request.settings ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.UpdateSettingsRequest', + ['settings', 'name'], + ); + request.settings.name = defaultValue1; + const expectedHeaderRequestParams = `settings.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateSettings = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateSettings(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateSettings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSettings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createReportConfig without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.CreateReportConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.CreateReportConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createReportConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createReportConfig( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createReportConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createReportConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateSettingsProgress without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateSettingsProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createReportConfig with call error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.CreateReportConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.CreateReportConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createReportConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createReportConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.createReportConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createReportConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateSettingsProgress with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateSettingsProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createReportConfig', () => { + it('invokes createReportConfig without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.CreateReportConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.CreateReportConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createReportConfig = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createReportConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createReportConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createReportConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createReportConfig with LRO error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.CreateReportConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.CreateReportConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createReportConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createReportConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createReportConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createReportConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createReportConfig without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.CreateReportConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.CreateReportConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createReportConfig = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createReportConfig( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.migrationcenter.v1.IReportConfig, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.migrationcenter.v1.IReportConfig, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createReportConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createReportConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateReportConfigProgress without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateReportConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createReportConfig with call error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.CreateReportConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.CreateReportConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createReportConfig = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createReportConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createReportConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createReportConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateReportConfigProgress with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateReportConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createReportConfig with LRO error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.CreateReportConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.CreateReportConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createReportConfig = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createReportConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createReportConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createReportConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteReportConfig', () => { - it('invokes deleteReportConfig without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeleteReportConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeleteReportConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteReportConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteReportConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteReportConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteReportConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateReportConfigProgress without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateReportConfigProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteReportConfig without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeleteReportConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeleteReportConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteReportConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteReportConfig( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteReportConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteReportConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateReportConfigProgress with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateReportConfigProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteReportConfig', () => { + it('invokes deleteReportConfig without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeleteReportConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeleteReportConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteReportConfig = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteReportConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteReportConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteReportConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteReportConfig with call error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeleteReportConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeleteReportConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteReportConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteReportConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteReportConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteReportConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteReportConfig without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeleteReportConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeleteReportConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteReportConfig = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteReportConfig( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteReportConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteReportConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteReportConfig with LRO error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeleteReportConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeleteReportConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteReportConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteReportConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteReportConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteReportConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteReportConfig with call error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeleteReportConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeleteReportConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteReportConfig = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteReportConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteReportConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteReportConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteReportConfigProgress without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteReportConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteReportConfig with LRO error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeleteReportConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeleteReportConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteReportConfig = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteReportConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteReportConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteReportConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteReportConfigProgress with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteReportConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteReportConfigProgress without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteReportConfigProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('createReport', () => { - it('invokes createReport without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.CreateReportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.CreateReportRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createReport = stubLongRunningCall(expectedResponse); - const [operation] = await client.createReport(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createReport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createReport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteReportConfigProgress with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteReportConfigProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createReport', () => { + it('invokes createReport without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.CreateReportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.CreateReportRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createReport = stubLongRunningCall(expectedResponse); + const [operation] = await client.createReport(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createReport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createReport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createReport without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.CreateReportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.CreateReportRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createReport = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createReport( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createReport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createReport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createReport without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.CreateReportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.CreateReportRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createReport = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createReport( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.migrationcenter.v1.IReport, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.migrationcenter.v1.IReport, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createReport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createReport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createReport with call error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.CreateReportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.CreateReportRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createReport = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createReport(request), expectedError); - const actualRequest = (client.innerApiCalls.createReport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createReport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createReport with call error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.CreateReportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.CreateReportRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createReport = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createReport(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createReport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createReport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createReport with LRO error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.CreateReportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.CreateReportRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createReport = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createReport(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createReport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createReport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createReport with LRO error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.CreateReportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.CreateReportRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createReport = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createReport(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createReport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createReport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateReportProgress without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateReportProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkCreateReportProgress without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateReportProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkCreateReportProgress with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateReportProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateReportProgress with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkCreateReportProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteReport', () => { + it('invokes deleteReport without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeleteReportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeleteReportRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteReport = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteReport(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteReport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteReport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteReport', () => { - it('invokes deleteReport without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeleteReportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeleteReportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteReport = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteReport(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteReport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteReport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteReport without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeleteReportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeleteReportRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteReport = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteReport( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.migrationcenter.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteReport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteReport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteReport without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeleteReportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeleteReportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteReport = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteReport( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteReport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteReport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteReport with call error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeleteReportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeleteReportRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteReport = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteReport(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteReport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteReport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteReport with call error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeleteReportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeleteReportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteReport = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteReport(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteReport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteReport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteReport with LRO error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.DeleteReportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.DeleteReportRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteReport = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteReport(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteReport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteReport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteReport with LRO error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.DeleteReportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.DeleteReportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteReport = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteReport(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteReport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteReport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteReportProgress without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteReportProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteReportProgress without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteReportProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkDeleteReportProgress with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkDeleteReportProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listAssets', () => { + it('invokes listAssets without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListAssetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListAssetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Asset(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Asset(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Asset(), + ), + ]; + client.innerApiCalls.listAssets = stubSimpleCall(expectedResponse); + const [response] = await client.listAssets(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listAssets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAssets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteReportProgress with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteReportProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes listAssets without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListAssetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListAssetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Asset(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Asset(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Asset(), + ), + ]; + client.innerApiCalls.listAssets = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listAssets( + request, + ( + err?: Error | null, + result?: protos.google.cloud.migrationcenter.v1.IAsset[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listAssets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAssets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listAssets', () => { - it('invokes listAssets without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListAssetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListAssetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Asset()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Asset()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Asset()), - ]; - client.innerApiCalls.listAssets = stubSimpleCall(expectedResponse); - const [response] = await client.listAssets(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listAssets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAssets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listAssets with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListAssetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListAssetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listAssets = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listAssets(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listAssets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAssets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listAssets without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListAssetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListAssetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Asset()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Asset()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Asset()), - ]; - client.innerApiCalls.listAssets = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listAssets( - request, - (err?: Error|null, result?: protos.google.cloud.migrationcenter.v1.IAsset[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listAssets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAssets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listAssetsStream without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListAssetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListAssetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Asset(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Asset(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Asset(), + ), + ]; + client.descriptors.page.listAssets.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listAssetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.migrationcenter.v1.Asset[] = []; + stream.on( + 'data', + (response: protos.google.cloud.migrationcenter.v1.Asset) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listAssets.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listAssets, request), + ); + assert( + (client.descriptors.page.listAssets.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listAssets with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListAssetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListAssetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listAssets = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listAssets(request), expectedError); - const actualRequest = (client.innerApiCalls.listAssets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAssets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listAssetsStream with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListAssetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListAssetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listAssets.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listAssetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.migrationcenter.v1.Asset[] = []; + stream.on( + 'data', + (response: protos.google.cloud.migrationcenter.v1.Asset) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listAssets.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listAssets, request), + ); + assert( + (client.descriptors.page.listAssets.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listAssetsStream without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListAssetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListAssetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Asset()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Asset()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Asset()), - ]; - client.descriptors.page.listAssets.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listAssetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.migrationcenter.v1.Asset[] = []; - stream.on('data', (response: protos.google.cloud.migrationcenter.v1.Asset) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listAssets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAssets, request)); - assert( - (client.descriptors.page.listAssets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listAssets without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListAssetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListAssetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Asset(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Asset(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Asset(), + ), + ]; + client.descriptors.page.listAssets.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.migrationcenter.v1.IAsset[] = []; + const iterable = client.listAssetsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listAssets.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listAssets.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listAssetsStream with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListAssetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListAssetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listAssets.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listAssetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.migrationcenter.v1.Asset[] = []; - stream.on('data', (response: protos.google.cloud.migrationcenter.v1.Asset) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listAssets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAssets, request)); - assert( - (client.descriptors.page.listAssets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listAssets with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListAssetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListAssetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listAssets.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listAssetsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.migrationcenter.v1.IAsset[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listAssets.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listAssets.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listImportJobs', () => { + it('invokes listImportJobs without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListImportJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListImportJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ImportJob(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ImportJob(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ImportJob(), + ), + ]; + client.innerApiCalls.listImportJobs = stubSimpleCall(expectedResponse); + const [response] = await client.listImportJobs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listImportJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listImportJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listAssets without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListAssetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListAssetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Asset()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Asset()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Asset()), - ]; - client.descriptors.page.listAssets.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.migrationcenter.v1.IAsset[] = []; - const iterable = client.listAssetsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listImportJobs without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListImportJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListImportJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ImportJob(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ImportJob(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ImportJob(), + ), + ]; + client.innerApiCalls.listImportJobs = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listImportJobs( + request, + ( + err?: Error | null, + result?: protos.google.cloud.migrationcenter.v1.IImportJob[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listAssets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listAssets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listAssets with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListAssetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListAssetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listAssets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listAssetsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.migrationcenter.v1.IAsset[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listAssets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listAssets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listImportJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listImportJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listImportJobs', () => { - it('invokes listImportJobs without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListImportJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListImportJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ImportJob()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ImportJob()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ImportJob()), - ]; - client.innerApiCalls.listImportJobs = stubSimpleCall(expectedResponse); - const [response] = await client.listImportJobs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listImportJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listImportJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listImportJobs with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListImportJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListImportJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listImportJobs = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listImportJobs(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listImportJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listImportJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listImportJobs without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListImportJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListImportJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ImportJob()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ImportJob()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ImportJob()), - ]; - client.innerApiCalls.listImportJobs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listImportJobs( - request, - (err?: Error|null, result?: protos.google.cloud.migrationcenter.v1.IImportJob[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listImportJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listImportJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listImportJobsStream without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListImportJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListImportJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ImportJob(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ImportJob(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ImportJob(), + ), + ]; + client.descriptors.page.listImportJobs.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listImportJobsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.migrationcenter.v1.ImportJob[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.migrationcenter.v1.ImportJob) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listImportJobs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listImportJobs, request), + ); + assert( + (client.descriptors.page.listImportJobs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listImportJobs with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListImportJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListImportJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listImportJobs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listImportJobs(request), expectedError); - const actualRequest = (client.innerApiCalls.listImportJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listImportJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listImportJobsStream with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListImportJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListImportJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listImportJobs.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listImportJobsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.migrationcenter.v1.ImportJob[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.migrationcenter.v1.ImportJob) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listImportJobs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listImportJobs, request), + ); + assert( + (client.descriptors.page.listImportJobs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listImportJobsStream without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListImportJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListImportJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ImportJob()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ImportJob()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ImportJob()), - ]; - client.descriptors.page.listImportJobs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listImportJobsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.migrationcenter.v1.ImportJob[] = []; - stream.on('data', (response: protos.google.cloud.migrationcenter.v1.ImportJob) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listImportJobs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listImportJobs, request)); - assert( - (client.descriptors.page.listImportJobs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listImportJobs without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListImportJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListImportJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ImportJob(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ImportJob(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ImportJob(), + ), + ]; + client.descriptors.page.listImportJobs.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.migrationcenter.v1.IImportJob[] = []; + const iterable = client.listImportJobsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listImportJobs.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listImportJobs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listImportJobsStream with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListImportJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListImportJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listImportJobs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listImportJobsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.migrationcenter.v1.ImportJob[] = []; - stream.on('data', (response: protos.google.cloud.migrationcenter.v1.ImportJob) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listImportJobs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listImportJobs, request)); - assert( - (client.descriptors.page.listImportJobs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listImportJobs with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListImportJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListImportJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listImportJobs.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listImportJobsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.migrationcenter.v1.IImportJob[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listImportJobs.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listImportJobs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listImportDataFiles', () => { + it('invokes listImportDataFiles without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListImportDataFilesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListImportDataFilesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ImportDataFile(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ImportDataFile(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ImportDataFile(), + ), + ]; + client.innerApiCalls.listImportDataFiles = + stubSimpleCall(expectedResponse); + const [response] = await client.listImportDataFiles(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listImportDataFiles as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listImportDataFiles as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listImportJobs without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListImportJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListImportJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ImportJob()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ImportJob()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ImportJob()), - ]; - client.descriptors.page.listImportJobs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.migrationcenter.v1.IImportJob[] = []; - const iterable = client.listImportJobsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listImportDataFiles without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListImportDataFilesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListImportDataFilesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ImportDataFile(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ImportDataFile(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ImportDataFile(), + ), + ]; + client.innerApiCalls.listImportDataFiles = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listImportDataFiles( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.migrationcenter.v1.IImportDataFile[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listImportJobs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listImportJobs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listImportJobs with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListImportJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListImportJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listImportJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listImportJobsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.migrationcenter.v1.IImportJob[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listImportJobs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listImportJobs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listImportDataFiles as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listImportDataFiles as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listImportDataFiles', () => { - it('invokes listImportDataFiles without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListImportDataFilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListImportDataFilesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ImportDataFile()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ImportDataFile()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ImportDataFile()), - ]; - client.innerApiCalls.listImportDataFiles = stubSimpleCall(expectedResponse); - const [response] = await client.listImportDataFiles(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listImportDataFiles as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listImportDataFiles as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listImportDataFiles with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListImportDataFilesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListImportDataFilesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listImportDataFiles = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listImportDataFiles(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listImportDataFiles as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listImportDataFiles as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listImportDataFiles without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListImportDataFilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListImportDataFilesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ImportDataFile()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ImportDataFile()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ImportDataFile()), - ]; - client.innerApiCalls.listImportDataFiles = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listImportDataFiles( - request, - (err?: Error|null, result?: protos.google.cloud.migrationcenter.v1.IImportDataFile[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listImportDataFiles as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listImportDataFiles as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listImportDataFilesStream without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListImportDataFilesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListImportDataFilesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ImportDataFile(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ImportDataFile(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ImportDataFile(), + ), + ]; + client.descriptors.page.listImportDataFiles.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listImportDataFilesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.migrationcenter.v1.ImportDataFile[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.migrationcenter.v1.ImportDataFile) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listImportDataFiles.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listImportDataFiles, request), + ); + assert( + (client.descriptors.page.listImportDataFiles.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listImportDataFiles with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListImportDataFilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListImportDataFilesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listImportDataFiles = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listImportDataFiles(request), expectedError); - const actualRequest = (client.innerApiCalls.listImportDataFiles as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listImportDataFiles as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listImportDataFilesStream with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListImportDataFilesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListImportDataFilesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listImportDataFiles.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listImportDataFilesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.migrationcenter.v1.ImportDataFile[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.migrationcenter.v1.ImportDataFile) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listImportDataFiles.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listImportDataFiles, request), + ); + assert( + (client.descriptors.page.listImportDataFiles.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listImportDataFilesStream without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListImportDataFilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListImportDataFilesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ImportDataFile()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ImportDataFile()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ImportDataFile()), - ]; - client.descriptors.page.listImportDataFiles.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listImportDataFilesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.migrationcenter.v1.ImportDataFile[] = []; - stream.on('data', (response: protos.google.cloud.migrationcenter.v1.ImportDataFile) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listImportDataFiles.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listImportDataFiles, request)); - assert( - (client.descriptors.page.listImportDataFiles.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listImportDataFiles without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListImportDataFilesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListImportDataFilesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ImportDataFile(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ImportDataFile(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ImportDataFile(), + ), + ]; + client.descriptors.page.listImportDataFiles.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.migrationcenter.v1.IImportDataFile[] = + []; + const iterable = client.listImportDataFilesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listImportDataFiles.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listImportDataFiles.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listImportDataFilesStream with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListImportDataFilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListImportDataFilesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listImportDataFiles.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listImportDataFilesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.migrationcenter.v1.ImportDataFile[] = []; - stream.on('data', (response: protos.google.cloud.migrationcenter.v1.ImportDataFile) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listImportDataFiles.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listImportDataFiles, request)); - assert( - (client.descriptors.page.listImportDataFiles.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listImportDataFiles with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListImportDataFilesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListImportDataFilesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listImportDataFiles.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listImportDataFilesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.migrationcenter.v1.IImportDataFile[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listImportDataFiles.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listImportDataFiles.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listGroups', () => { + it('invokes listGroups without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Group(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Group(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Group(), + ), + ]; + client.innerApiCalls.listGroups = stubSimpleCall(expectedResponse); + const [response] = await client.listGroups(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listGroups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listGroups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listImportDataFiles without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListImportDataFilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListImportDataFilesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ImportDataFile()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ImportDataFile()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ImportDataFile()), - ]; - client.descriptors.page.listImportDataFiles.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.migrationcenter.v1.IImportDataFile[] = []; - const iterable = client.listImportDataFilesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listGroups without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Group(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Group(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Group(), + ), + ]; + client.innerApiCalls.listGroups = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listGroups( + request, + ( + err?: Error | null, + result?: protos.google.cloud.migrationcenter.v1.IGroup[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listImportDataFiles.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listImportDataFiles.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listImportDataFiles with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListImportDataFilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListImportDataFilesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listImportDataFiles.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listImportDataFilesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.migrationcenter.v1.IImportDataFile[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listImportDataFiles.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listImportDataFiles.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listGroups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listGroups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listGroups', () => { - it('invokes listGroups without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Group()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Group()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Group()), - ]; - client.innerApiCalls.listGroups = stubSimpleCall(expectedResponse); - const [response] = await client.listGroups(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listGroups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listGroups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listGroups with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listGroups = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listGroups(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listGroups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listGroups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listGroups without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Group()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Group()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Group()), - ]; - client.innerApiCalls.listGroups = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listGroups( - request, - (err?: Error|null, result?: protos.google.cloud.migrationcenter.v1.IGroup[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listGroups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listGroups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listGroupsStream without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Group(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Group(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Group(), + ), + ]; + client.descriptors.page.listGroups.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listGroupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.migrationcenter.v1.Group[] = []; + stream.on( + 'data', + (response: protos.google.cloud.migrationcenter.v1.Group) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listGroups.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listGroups, request), + ); + assert( + (client.descriptors.page.listGroups.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listGroups with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listGroups = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listGroups(request), expectedError); - const actualRequest = (client.innerApiCalls.listGroups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listGroups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listGroupsStream with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listGroups.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listGroupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.migrationcenter.v1.Group[] = []; + stream.on( + 'data', + (response: protos.google.cloud.migrationcenter.v1.Group) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listGroups.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listGroups, request), + ); + assert( + (client.descriptors.page.listGroups.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listGroupsStream without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Group()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Group()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Group()), - ]; - client.descriptors.page.listGroups.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listGroupsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.migrationcenter.v1.Group[] = []; - stream.on('data', (response: protos.google.cloud.migrationcenter.v1.Group) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listGroups.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listGroups, request)); - assert( - (client.descriptors.page.listGroups.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listGroups without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Group(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Group(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Group(), + ), + ]; + client.descriptors.page.listGroups.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.migrationcenter.v1.IGroup[] = []; + const iterable = client.listGroupsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listGroups.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listGroups.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listGroupsStream with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listGroups.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listGroupsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.migrationcenter.v1.Group[] = []; - stream.on('data', (response: protos.google.cloud.migrationcenter.v1.Group) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listGroups.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listGroups, request)); - assert( - (client.descriptors.page.listGroups.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listGroups with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listGroups.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listGroupsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.migrationcenter.v1.IGroup[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listGroups.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listGroups.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listErrorFrames', () => { + it('invokes listErrorFrames without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListErrorFramesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListErrorFramesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ErrorFrame(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ErrorFrame(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ErrorFrame(), + ), + ]; + client.innerApiCalls.listErrorFrames = stubSimpleCall(expectedResponse); + const [response] = await client.listErrorFrames(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listErrorFrames as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listErrorFrames as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listGroups without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Group()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Group()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Group()), - ]; - client.descriptors.page.listGroups.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.migrationcenter.v1.IGroup[] = []; - const iterable = client.listGroupsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listErrorFrames without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListErrorFramesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListErrorFramesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ErrorFrame(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ErrorFrame(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ErrorFrame(), + ), + ]; + client.innerApiCalls.listErrorFrames = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listErrorFrames( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.migrationcenter.v1.IErrorFrame[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listGroups.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listGroups.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listGroups with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listGroups.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listGroupsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.migrationcenter.v1.IGroup[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listGroups.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listGroups.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listErrorFrames as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listErrorFrames as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listErrorFrames', () => { - it('invokes listErrorFrames without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListErrorFramesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListErrorFramesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ErrorFrame()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ErrorFrame()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ErrorFrame()), - ]; - client.innerApiCalls.listErrorFrames = stubSimpleCall(expectedResponse); - const [response] = await client.listErrorFrames(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listErrorFrames as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listErrorFrames as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listErrorFrames with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListErrorFramesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListErrorFramesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listErrorFrames = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listErrorFrames(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listErrorFrames as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listErrorFrames as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listErrorFrames without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListErrorFramesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListErrorFramesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ErrorFrame()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ErrorFrame()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ErrorFrame()), - ]; - client.innerApiCalls.listErrorFrames = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listErrorFrames( - request, - (err?: Error|null, result?: protos.google.cloud.migrationcenter.v1.IErrorFrame[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listErrorFrames as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listErrorFrames as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listErrorFramesStream without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListErrorFramesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListErrorFramesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ErrorFrame(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ErrorFrame(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ErrorFrame(), + ), + ]; + client.descriptors.page.listErrorFrames.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listErrorFramesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.migrationcenter.v1.ErrorFrame[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.migrationcenter.v1.ErrorFrame) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listErrorFrames.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listErrorFrames, request), + ); + assert( + (client.descriptors.page.listErrorFrames.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listErrorFrames with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListErrorFramesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListErrorFramesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listErrorFrames = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listErrorFrames(request), expectedError); - const actualRequest = (client.innerApiCalls.listErrorFrames as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listErrorFrames as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listErrorFramesStream with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListErrorFramesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListErrorFramesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listErrorFrames.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listErrorFramesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.migrationcenter.v1.ErrorFrame[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.migrationcenter.v1.ErrorFrame) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listErrorFrames.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listErrorFrames, request), + ); + assert( + (client.descriptors.page.listErrorFrames.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listErrorFramesStream without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListErrorFramesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListErrorFramesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ErrorFrame()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ErrorFrame()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ErrorFrame()), - ]; - client.descriptors.page.listErrorFrames.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listErrorFramesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.migrationcenter.v1.ErrorFrame[] = []; - stream.on('data', (response: protos.google.cloud.migrationcenter.v1.ErrorFrame) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listErrorFrames.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listErrorFrames, request)); - assert( - (client.descriptors.page.listErrorFrames.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listErrorFrames without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListErrorFramesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListErrorFramesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ErrorFrame(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ErrorFrame(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ErrorFrame(), + ), + ]; + client.descriptors.page.listErrorFrames.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.migrationcenter.v1.IErrorFrame[] = + []; + const iterable = client.listErrorFramesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listErrorFrames.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listErrorFrames.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listErrorFramesStream with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListErrorFramesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListErrorFramesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listErrorFrames.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listErrorFramesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.migrationcenter.v1.ErrorFrame[] = []; - stream.on('data', (response: protos.google.cloud.migrationcenter.v1.ErrorFrame) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listErrorFrames.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listErrorFrames, request)); - assert( - (client.descriptors.page.listErrorFrames.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listErrorFrames with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListErrorFramesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListErrorFramesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listErrorFrames.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listErrorFramesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.migrationcenter.v1.IErrorFrame[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listErrorFrames.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listErrorFrames.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listSources', () => { + it('invokes listSources without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListSourcesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListSourcesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Source(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Source(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Source(), + ), + ]; + client.innerApiCalls.listSources = stubSimpleCall(expectedResponse); + const [response] = await client.listSources(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listSources as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSources as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listErrorFrames without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListErrorFramesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListErrorFramesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ErrorFrame()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ErrorFrame()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ErrorFrame()), - ]; - client.descriptors.page.listErrorFrames.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.migrationcenter.v1.IErrorFrame[] = []; - const iterable = client.listErrorFramesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listSources without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListSourcesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListSourcesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Source(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Source(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Source(), + ), + ]; + client.innerApiCalls.listSources = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listSources( + request, + ( + err?: Error | null, + result?: protos.google.cloud.migrationcenter.v1.ISource[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listErrorFrames.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listErrorFrames.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listErrorFrames with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListErrorFramesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListErrorFramesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listErrorFrames.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listErrorFramesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.migrationcenter.v1.IErrorFrame[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listErrorFrames.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listErrorFrames.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listSources as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSources as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listSources', () => { - it('invokes listSources without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListSourcesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListSourcesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Source()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Source()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Source()), - ]; - client.innerApiCalls.listSources = stubSimpleCall(expectedResponse); - const [response] = await client.listSources(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSources as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSources as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listSources with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListSourcesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListSourcesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listSources = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listSources(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listSources as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSources as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listSources without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListSourcesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListSourcesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Source()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Source()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Source()), - ]; - client.innerApiCalls.listSources = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listSources( - request, - (err?: Error|null, result?: protos.google.cloud.migrationcenter.v1.ISource[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSources as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSources as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listSourcesStream without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListSourcesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListSourcesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Source(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Source(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Source(), + ), + ]; + client.descriptors.page.listSources.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listSourcesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.migrationcenter.v1.Source[] = []; + stream.on( + 'data', + (response: protos.google.cloud.migrationcenter.v1.Source) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listSources.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listSources, request), + ); + assert( + (client.descriptors.page.listSources.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listSources with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListSourcesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListSourcesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listSources = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listSources(request), expectedError); - const actualRequest = (client.innerApiCalls.listSources as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSources as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listSourcesStream with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListSourcesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListSourcesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSources.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listSourcesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.migrationcenter.v1.Source[] = []; + stream.on( + 'data', + (response: protos.google.cloud.migrationcenter.v1.Source) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listSources.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listSources, request), + ); + assert( + (client.descriptors.page.listSources.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listSourcesStream without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListSourcesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListSourcesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Source()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Source()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Source()), - ]; - client.descriptors.page.listSources.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listSourcesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.migrationcenter.v1.Source[] = []; - stream.on('data', (response: protos.google.cloud.migrationcenter.v1.Source) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listSources.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSources, request)); - assert( - (client.descriptors.page.listSources.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listSources without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListSourcesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListSourcesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Source(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Source(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Source(), + ), + ]; + client.descriptors.page.listSources.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.migrationcenter.v1.ISource[] = []; + const iterable = client.listSourcesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listSources.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listSources.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listSourcesStream with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListSourcesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListSourcesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listSources.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listSourcesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.migrationcenter.v1.Source[] = []; - stream.on('data', (response: protos.google.cloud.migrationcenter.v1.Source) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listSources.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSources, request)); - assert( - (client.descriptors.page.listSources.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listSources with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListSourcesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListSourcesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSources.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listSourcesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.migrationcenter.v1.ISource[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listSources.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listSources.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listPreferenceSets', () => { + it('invokes listPreferenceSets without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListPreferenceSetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListPreferenceSetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.PreferenceSet(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.PreferenceSet(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.PreferenceSet(), + ), + ]; + client.innerApiCalls.listPreferenceSets = + stubSimpleCall(expectedResponse); + const [response] = await client.listPreferenceSets(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listPreferenceSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPreferenceSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listSources without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListSourcesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListSourcesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Source()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Source()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Source()), - ]; - client.descriptors.page.listSources.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.migrationcenter.v1.ISource[] = []; - const iterable = client.listSourcesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listPreferenceSets without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListPreferenceSetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListPreferenceSetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.PreferenceSet(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.PreferenceSet(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.PreferenceSet(), + ), + ]; + client.innerApiCalls.listPreferenceSets = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listPreferenceSets( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.migrationcenter.v1.IPreferenceSet[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listSources.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSources.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listSources with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListSourcesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListSourcesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listSources.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listSourcesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.migrationcenter.v1.ISource[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listSources.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSources.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listPreferenceSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPreferenceSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listPreferenceSets', () => { - it('invokes listPreferenceSets without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListPreferenceSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListPreferenceSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.PreferenceSet()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.PreferenceSet()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.PreferenceSet()), - ]; - client.innerApiCalls.listPreferenceSets = stubSimpleCall(expectedResponse); - const [response] = await client.listPreferenceSets(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPreferenceSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPreferenceSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listPreferenceSets with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListPreferenceSetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListPreferenceSetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listPreferenceSets = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listPreferenceSets(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listPreferenceSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPreferenceSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listPreferenceSets without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListPreferenceSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListPreferenceSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.PreferenceSet()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.PreferenceSet()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.PreferenceSet()), - ]; - client.innerApiCalls.listPreferenceSets = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listPreferenceSets( - request, - (err?: Error|null, result?: protos.google.cloud.migrationcenter.v1.IPreferenceSet[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPreferenceSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPreferenceSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listPreferenceSetsStream without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListPreferenceSetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListPreferenceSetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.PreferenceSet(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.PreferenceSet(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.PreferenceSet(), + ), + ]; + client.descriptors.page.listPreferenceSets.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listPreferenceSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.migrationcenter.v1.PreferenceSet[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.migrationcenter.v1.PreferenceSet) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listPreferenceSets.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listPreferenceSets, request), + ); + assert( + (client.descriptors.page.listPreferenceSets.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listPreferenceSets with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListPreferenceSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListPreferenceSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listPreferenceSets = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listPreferenceSets(request), expectedError); - const actualRequest = (client.innerApiCalls.listPreferenceSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPreferenceSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listPreferenceSetsStream with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListPreferenceSetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListPreferenceSetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPreferenceSets.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listPreferenceSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.migrationcenter.v1.PreferenceSet[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.migrationcenter.v1.PreferenceSet) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listPreferenceSets.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listPreferenceSets, request), + ); + assert( + (client.descriptors.page.listPreferenceSets.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listPreferenceSetsStream without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListPreferenceSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListPreferenceSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.PreferenceSet()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.PreferenceSet()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.PreferenceSet()), - ]; - client.descriptors.page.listPreferenceSets.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listPreferenceSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.migrationcenter.v1.PreferenceSet[] = []; - stream.on('data', (response: protos.google.cloud.migrationcenter.v1.PreferenceSet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listPreferenceSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPreferenceSets, request)); - assert( - (client.descriptors.page.listPreferenceSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listPreferenceSets without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListPreferenceSetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListPreferenceSetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.PreferenceSet(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.PreferenceSet(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.PreferenceSet(), + ), + ]; + client.descriptors.page.listPreferenceSets.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.migrationcenter.v1.IPreferenceSet[] = + []; + const iterable = client.listPreferenceSetsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listPreferenceSets.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listPreferenceSets.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listPreferenceSetsStream with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListPreferenceSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListPreferenceSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listPreferenceSets.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listPreferenceSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.migrationcenter.v1.PreferenceSet[] = []; - stream.on('data', (response: protos.google.cloud.migrationcenter.v1.PreferenceSet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listPreferenceSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPreferenceSets, request)); - assert( - (client.descriptors.page.listPreferenceSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listPreferenceSets with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListPreferenceSetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListPreferenceSetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPreferenceSets.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listPreferenceSetsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.migrationcenter.v1.IPreferenceSet[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listPreferenceSets.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listPreferenceSets.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listReportConfigs', () => { + it('invokes listReportConfigs without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListReportConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListReportConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ReportConfig(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ReportConfig(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ReportConfig(), + ), + ]; + client.innerApiCalls.listReportConfigs = stubSimpleCall(expectedResponse); + const [response] = await client.listReportConfigs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listReportConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listReportConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listPreferenceSets without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListPreferenceSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListPreferenceSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.PreferenceSet()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.PreferenceSet()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.PreferenceSet()), - ]; - client.descriptors.page.listPreferenceSets.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.migrationcenter.v1.IPreferenceSet[] = []; - const iterable = client.listPreferenceSetsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listReportConfigs without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListReportConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListReportConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ReportConfig(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ReportConfig(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ReportConfig(), + ), + ]; + client.innerApiCalls.listReportConfigs = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listReportConfigs( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.migrationcenter.v1.IReportConfig[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listPreferenceSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPreferenceSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listPreferenceSets with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListPreferenceSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListPreferenceSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listPreferenceSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listPreferenceSetsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.migrationcenter.v1.IPreferenceSet[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listPreferenceSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPreferenceSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listReportConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listReportConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listReportConfigs', () => { - it('invokes listReportConfigs without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListReportConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListReportConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ReportConfig()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ReportConfig()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ReportConfig()), - ]; - client.innerApiCalls.listReportConfigs = stubSimpleCall(expectedResponse); - const [response] = await client.listReportConfigs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listReportConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listReportConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listReportConfigs with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListReportConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListReportConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listReportConfigs = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listReportConfigs(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listReportConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listReportConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listReportConfigs without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListReportConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListReportConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ReportConfig()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ReportConfig()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ReportConfig()), - ]; - client.innerApiCalls.listReportConfigs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listReportConfigs( - request, - (err?: Error|null, result?: protos.google.cloud.migrationcenter.v1.IReportConfig[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listReportConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listReportConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listReportConfigsStream without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListReportConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListReportConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ReportConfig(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ReportConfig(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ReportConfig(), + ), + ]; + client.descriptors.page.listReportConfigs.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listReportConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.migrationcenter.v1.ReportConfig[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.migrationcenter.v1.ReportConfig) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listReportConfigs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listReportConfigs, request), + ); + assert( + (client.descriptors.page.listReportConfigs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listReportConfigs with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListReportConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListReportConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listReportConfigs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listReportConfigs(request), expectedError); - const actualRequest = (client.innerApiCalls.listReportConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listReportConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listReportConfigsStream with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListReportConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListReportConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listReportConfigs.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listReportConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.migrationcenter.v1.ReportConfig[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.migrationcenter.v1.ReportConfig) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listReportConfigs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listReportConfigs, request), + ); + assert( + (client.descriptors.page.listReportConfigs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listReportConfigsStream without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListReportConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListReportConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ReportConfig()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ReportConfig()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ReportConfig()), - ]; - client.descriptors.page.listReportConfigs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listReportConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.migrationcenter.v1.ReportConfig[] = []; - stream.on('data', (response: protos.google.cloud.migrationcenter.v1.ReportConfig) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listReportConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReportConfigs, request)); - assert( - (client.descriptors.page.listReportConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listReportConfigs without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListReportConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListReportConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ReportConfig(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ReportConfig(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ReportConfig(), + ), + ]; + client.descriptors.page.listReportConfigs.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.migrationcenter.v1.IReportConfig[] = + []; + const iterable = client.listReportConfigsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listReportConfigs.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listReportConfigs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listReportConfigsStream with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListReportConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListReportConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listReportConfigs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listReportConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.migrationcenter.v1.ReportConfig[] = []; - stream.on('data', (response: protos.google.cloud.migrationcenter.v1.ReportConfig) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listReportConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReportConfigs, request)); - assert( - (client.descriptors.page.listReportConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listReportConfigs with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListReportConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListReportConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listReportConfigs.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listReportConfigsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.migrationcenter.v1.IReportConfig[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listReportConfigs.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listReportConfigs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listReports', () => { + it('invokes listReports without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListReportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListReportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Report(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Report(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Report(), + ), + ]; + client.innerApiCalls.listReports = stubSimpleCall(expectedResponse); + const [response] = await client.listReports(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listReports as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listReports as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listReportConfigs without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListReportConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListReportConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ReportConfig()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ReportConfig()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.ReportConfig()), - ]; - client.descriptors.page.listReportConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.migrationcenter.v1.IReportConfig[] = []; - const iterable = client.listReportConfigsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listReports without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListReportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListReportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Report(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Report(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Report(), + ), + ]; + client.innerApiCalls.listReports = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listReports( + request, + ( + err?: Error | null, + result?: protos.google.cloud.migrationcenter.v1.IReport[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listReportConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listReportConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listReportConfigs with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListReportConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListReportConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listReportConfigs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listReportConfigsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.migrationcenter.v1.IReportConfig[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listReportConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listReportConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listReports as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listReports as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listReports', () => { - it('invokes listReports without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Report()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Report()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Report()), - ]; - client.innerApiCalls.listReports = stubSimpleCall(expectedResponse); - const [response] = await client.listReports(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listReports as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listReports as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listReports without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Report()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Report()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Report()), - ]; - client.innerApiCalls.listReports = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listReports( - request, - (err?: Error|null, result?: protos.google.cloud.migrationcenter.v1.IReport[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listReports as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listReports as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listReports with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listReports = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listReports(request), expectedError); - const actualRequest = (client.innerApiCalls.listReports as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listReports as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listReports with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListReportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListReportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listReports = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listReports(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listReports as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listReports as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listReportsStream without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Report()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Report()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Report()), - ]; - client.descriptors.page.listReports.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listReportsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.migrationcenter.v1.Report[] = []; - stream.on('data', (response: protos.google.cloud.migrationcenter.v1.Report) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listReports.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReports, request)); - assert( - (client.descriptors.page.listReports.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listReportsStream without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListReportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListReportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Report(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Report(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Report(), + ), + ]; + client.descriptors.page.listReports.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listReportsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.migrationcenter.v1.Report[] = []; + stream.on( + 'data', + (response: protos.google.cloud.migrationcenter.v1.Report) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listReports.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listReports, request), + ); + assert( + (client.descriptors.page.listReports.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listReportsStream with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listReports.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listReportsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.migrationcenter.v1.Report[] = []; - stream.on('data', (response: protos.google.cloud.migrationcenter.v1.Report) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listReports.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReports, request)); - assert( - (client.descriptors.page.listReports.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listReportsStream with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListReportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListReportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listReports.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listReportsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.migrationcenter.v1.Report[] = []; + stream.on( + 'data', + (response: protos.google.cloud.migrationcenter.v1.Report) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listReports.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listReports, request), + ); + assert( + (client.descriptors.page.listReports.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listReports without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Report()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Report()), - generateSampleMessage(new protos.google.cloud.migrationcenter.v1.Report()), - ]; - client.descriptors.page.listReports.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.migrationcenter.v1.IReport[] = []; - const iterable = client.listReportsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listReports.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listReports.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listReports without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListReportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListReportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Report(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Report(), + ), + generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.Report(), + ), + ]; + client.descriptors.page.listReports.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.migrationcenter.v1.IReport[] = []; + const iterable = client.listReportsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listReports.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listReports.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listReports with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.migrationcenter.v1.ListReportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.migrationcenter.v1.ListReportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listReports.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listReportsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.migrationcenter.v1.IReport[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listReports.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listReports.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listReports with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.migrationcenter.v1.ListReportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.migrationcenter.v1.ListReportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listReports.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listReportsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.migrationcenter.v1.IReport[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listReports.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listReports.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes getLocation without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes getLocation with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('uses async iteration with listLocations with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('asset', async () => { + const fakePath = '/rendered/path/asset'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + asset: 'assetValue', + }; + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.assetPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.assetPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('assetPath', () => { + const result = client.assetPath( + 'projectValue', + 'locationValue', + 'assetValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.assetPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromAssetName', () => { + const result = client.matchProjectFromAssetName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.assetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromAssetName', () => { + const result = client.matchLocationFromAssetName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.assetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAssetFromAssetName', () => { + const result = client.matchAssetFromAssetName(fakePath); + assert.strictEqual(result, 'assetValue'); + assert( + (client.pathTemplates.assetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('asset', async () => { - const fakePath = "/rendered/path/asset"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - asset: "assetValue", - }; - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.assetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.assetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('assetPath', () => { - const result = client.assetPath("projectValue", "locationValue", "assetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.assetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAssetName', () => { - const result = client.matchProjectFromAssetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.assetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAssetName', () => { - const result = client.matchLocationFromAssetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.assetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAssetFromAssetName', () => { - const result = client.matchAssetFromAssetName(fakePath); - assert.strictEqual(result, "assetValue"); - assert((client.pathTemplates.assetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('errorFrame', async () => { - const fakePath = "/rendered/path/errorFrame"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - source: "sourceValue", - error_frame: "errorFrameValue", - }; - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.errorFramePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.errorFramePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('errorFramePath', () => { - const result = client.errorFramePath("projectValue", "locationValue", "sourceValue", "errorFrameValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.errorFramePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromErrorFrameName', () => { - const result = client.matchProjectFromErrorFrameName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.errorFramePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromErrorFrameName', () => { - const result = client.matchLocationFromErrorFrameName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.errorFramePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSourceFromErrorFrameName', () => { - const result = client.matchSourceFromErrorFrameName(fakePath); - assert.strictEqual(result, "sourceValue"); - assert((client.pathTemplates.errorFramePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchErrorFrameFromErrorFrameName', () => { - const result = client.matchErrorFrameFromErrorFrameName(fakePath); - assert.strictEqual(result, "errorFrameValue"); - assert((client.pathTemplates.errorFramePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('errorFrame', async () => { + const fakePath = '/rendered/path/errorFrame'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + source: 'sourceValue', + error_frame: 'errorFrameValue', + }; + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.errorFramePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.errorFramePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('errorFramePath', () => { + const result = client.errorFramePath( + 'projectValue', + 'locationValue', + 'sourceValue', + 'errorFrameValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.errorFramePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromErrorFrameName', () => { + const result = client.matchProjectFromErrorFrameName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.errorFramePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromErrorFrameName', () => { + const result = client.matchLocationFromErrorFrameName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.errorFramePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchSourceFromErrorFrameName', () => { + const result = client.matchSourceFromErrorFrameName(fakePath); + assert.strictEqual(result, 'sourceValue'); + assert( + (client.pathTemplates.errorFramePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchErrorFrameFromErrorFrameName', () => { + const result = client.matchErrorFrameFromErrorFrameName(fakePath); + assert.strictEqual(result, 'errorFrameValue'); + assert( + (client.pathTemplates.errorFramePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('group', async () => { - const fakePath = "/rendered/path/group"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - group: "groupValue", - }; - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.groupPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.groupPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('groupPath', () => { - const result = client.groupPath("projectValue", "locationValue", "groupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.groupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromGroupName', () => { - const result = client.matchProjectFromGroupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.groupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromGroupName', () => { - const result = client.matchLocationFromGroupName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.groupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchGroupFromGroupName', () => { - const result = client.matchGroupFromGroupName(fakePath); - assert.strictEqual(result, "groupValue"); - assert((client.pathTemplates.groupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('group', async () => { + const fakePath = '/rendered/path/group'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + group: 'groupValue', + }; + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.groupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.groupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('groupPath', () => { + const result = client.groupPath( + 'projectValue', + 'locationValue', + 'groupValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.groupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromGroupName', () => { + const result = client.matchProjectFromGroupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.groupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromGroupName', () => { + const result = client.matchLocationFromGroupName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.groupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchGroupFromGroupName', () => { + const result = client.matchGroupFromGroupName(fakePath); + assert.strictEqual(result, 'groupValue'); + assert( + (client.pathTemplates.groupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('importDataFile', async () => { - const fakePath = "/rendered/path/importDataFile"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - import_job: "importJobValue", - import_data_file: "importDataFileValue", - }; - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.importDataFilePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.importDataFilePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('importDataFilePath', () => { - const result = client.importDataFilePath("projectValue", "locationValue", "importJobValue", "importDataFileValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.importDataFilePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromImportDataFileName', () => { - const result = client.matchProjectFromImportDataFileName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.importDataFilePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromImportDataFileName', () => { - const result = client.matchLocationFromImportDataFileName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.importDataFilePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchImportJobFromImportDataFileName', () => { - const result = client.matchImportJobFromImportDataFileName(fakePath); - assert.strictEqual(result, "importJobValue"); - assert((client.pathTemplates.importDataFilePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchImportDataFileFromImportDataFileName', () => { - const result = client.matchImportDataFileFromImportDataFileName(fakePath); - assert.strictEqual(result, "importDataFileValue"); - assert((client.pathTemplates.importDataFilePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('importDataFile', async () => { + const fakePath = '/rendered/path/importDataFile'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + import_job: 'importJobValue', + import_data_file: 'importDataFileValue', + }; + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.importDataFilePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.importDataFilePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('importDataFilePath', () => { + const result = client.importDataFilePath( + 'projectValue', + 'locationValue', + 'importJobValue', + 'importDataFileValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.importDataFilePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromImportDataFileName', () => { + const result = client.matchProjectFromImportDataFileName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.importDataFilePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromImportDataFileName', () => { + const result = client.matchLocationFromImportDataFileName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.importDataFilePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchImportJobFromImportDataFileName', () => { + const result = client.matchImportJobFromImportDataFileName(fakePath); + assert.strictEqual(result, 'importJobValue'); + assert( + (client.pathTemplates.importDataFilePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchImportDataFileFromImportDataFileName', () => { + const result = + client.matchImportDataFileFromImportDataFileName(fakePath); + assert.strictEqual(result, 'importDataFileValue'); + assert( + (client.pathTemplates.importDataFilePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('importJob', async () => { - const fakePath = "/rendered/path/importJob"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - import_job: "importJobValue", - }; - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.importJobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.importJobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('importJobPath', () => { - const result = client.importJobPath("projectValue", "locationValue", "importJobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.importJobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromImportJobName', () => { - const result = client.matchProjectFromImportJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.importJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromImportJobName', () => { - const result = client.matchLocationFromImportJobName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.importJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchImportJobFromImportJobName', () => { - const result = client.matchImportJobFromImportJobName(fakePath); - assert.strictEqual(result, "importJobValue"); - assert((client.pathTemplates.importJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('importJob', async () => { + const fakePath = '/rendered/path/importJob'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + import_job: 'importJobValue', + }; + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.importJobPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.importJobPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('importJobPath', () => { + const result = client.importJobPath( + 'projectValue', + 'locationValue', + 'importJobValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.importJobPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromImportJobName', () => { + const result = client.matchProjectFromImportJobName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.importJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromImportJobName', () => { + const result = client.matchLocationFromImportJobName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.importJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchImportJobFromImportJobName', () => { + const result = client.matchImportJobFromImportJobName(fakePath); + assert.strictEqual(result, 'importJobValue'); + assert( + (client.pathTemplates.importJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('preferenceSet', async () => { - const fakePath = "/rendered/path/preferenceSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - preference_set: "preferenceSetValue", - }; - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.preferenceSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.preferenceSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('preferenceSetPath', () => { - const result = client.preferenceSetPath("projectValue", "locationValue", "preferenceSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.preferenceSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromPreferenceSetName', () => { - const result = client.matchProjectFromPreferenceSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.preferenceSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromPreferenceSetName', () => { - const result = client.matchLocationFromPreferenceSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.preferenceSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchPreferenceSetFromPreferenceSetName', () => { - const result = client.matchPreferenceSetFromPreferenceSetName(fakePath); - assert.strictEqual(result, "preferenceSetValue"); - assert((client.pathTemplates.preferenceSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('preferenceSet', async () => { + const fakePath = '/rendered/path/preferenceSet'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + preference_set: 'preferenceSetValue', + }; + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.preferenceSetPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.preferenceSetPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('preferenceSetPath', () => { + const result = client.preferenceSetPath( + 'projectValue', + 'locationValue', + 'preferenceSetValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.preferenceSetPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromPreferenceSetName', () => { + const result = client.matchProjectFromPreferenceSetName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.preferenceSetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromPreferenceSetName', () => { + const result = client.matchLocationFromPreferenceSetName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.preferenceSetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchPreferenceSetFromPreferenceSetName', () => { + const result = client.matchPreferenceSetFromPreferenceSetName(fakePath); + assert.strictEqual(result, 'preferenceSetValue'); + assert( + (client.pathTemplates.preferenceSetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('report', async () => { - const fakePath = "/rendered/path/report"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - report_config: "reportConfigValue", - report: "reportValue", - }; - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.reportPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.reportPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('reportPath', () => { - const result = client.reportPath("projectValue", "locationValue", "reportConfigValue", "reportValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.reportPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromReportName', () => { - const result = client.matchProjectFromReportName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.reportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromReportName', () => { - const result = client.matchLocationFromReportName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.reportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReportConfigFromReportName', () => { - const result = client.matchReportConfigFromReportName(fakePath); - assert.strictEqual(result, "reportConfigValue"); - assert((client.pathTemplates.reportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReportFromReportName', () => { - const result = client.matchReportFromReportName(fakePath); - assert.strictEqual(result, "reportValue"); - assert((client.pathTemplates.reportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('report', async () => { + const fakePath = '/rendered/path/report'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + report_config: 'reportConfigValue', + report: 'reportValue', + }; + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.reportPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.reportPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('reportPath', () => { + const result = client.reportPath( + 'projectValue', + 'locationValue', + 'reportConfigValue', + 'reportValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.reportPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromReportName', () => { + const result = client.matchProjectFromReportName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.reportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromReportName', () => { + const result = client.matchLocationFromReportName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.reportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchReportConfigFromReportName', () => { + const result = client.matchReportConfigFromReportName(fakePath); + assert.strictEqual(result, 'reportConfigValue'); + assert( + (client.pathTemplates.reportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchReportFromReportName', () => { + const result = client.matchReportFromReportName(fakePath); + assert.strictEqual(result, 'reportValue'); + assert( + (client.pathTemplates.reportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('reportConfig', async () => { - const fakePath = "/rendered/path/reportConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - report_config: "reportConfigValue", - }; - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.reportConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.reportConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('reportConfigPath', () => { - const result = client.reportConfigPath("projectValue", "locationValue", "reportConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.reportConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromReportConfigName', () => { - const result = client.matchProjectFromReportConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.reportConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromReportConfigName', () => { - const result = client.matchLocationFromReportConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.reportConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReportConfigFromReportConfigName', () => { - const result = client.matchReportConfigFromReportConfigName(fakePath); - assert.strictEqual(result, "reportConfigValue"); - assert((client.pathTemplates.reportConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('reportConfig', async () => { + const fakePath = '/rendered/path/reportConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + report_config: 'reportConfigValue', + }; + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.reportConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.reportConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('reportConfigPath', () => { + const result = client.reportConfigPath( + 'projectValue', + 'locationValue', + 'reportConfigValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.reportConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromReportConfigName', () => { + const result = client.matchProjectFromReportConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.reportConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromReportConfigName', () => { + const result = client.matchLocationFromReportConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.reportConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchReportConfigFromReportConfigName', () => { + const result = client.matchReportConfigFromReportConfigName(fakePath); + assert.strictEqual(result, 'reportConfigValue'); + assert( + (client.pathTemplates.reportConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('settings', async () => { - const fakePath = "/rendered/path/settings"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.settingsPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.settingsPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('settingsPath', () => { - const result = client.settingsPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.settingsPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromSettingsName', () => { - const result = client.matchProjectFromSettingsName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.settingsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromSettingsName', () => { - const result = client.matchLocationFromSettingsName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.settingsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('settings', async () => { + const fakePath = '/rendered/path/settings'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.settingsPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.settingsPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('settingsPath', () => { + const result = client.settingsPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.settingsPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromSettingsName', () => { + const result = client.matchProjectFromSettingsName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.settingsPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromSettingsName', () => { + const result = client.matchLocationFromSettingsName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.settingsPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('source', async () => { - const fakePath = "/rendered/path/source"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - source: "sourceValue", - }; - const client = new migrationcenterModule.v1.MigrationCenterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.sourcePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.sourcePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('sourcePath', () => { - const result = client.sourcePath("projectValue", "locationValue", "sourceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.sourcePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromSourceName', () => { - const result = client.matchProjectFromSourceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.sourcePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromSourceName', () => { - const result = client.matchLocationFromSourceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.sourcePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSourceFromSourceName', () => { - const result = client.matchSourceFromSourceName(fakePath); - assert.strictEqual(result, "sourceValue"); - assert((client.pathTemplates.sourcePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('source', async () => { + const fakePath = '/rendered/path/source'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + source: 'sourceValue', + }; + const client = new migrationcenterModule.v1.MigrationCenterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.sourcePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.sourcePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('sourcePath', () => { + const result = client.sourcePath( + 'projectValue', + 'locationValue', + 'sourceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.sourcePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromSourceName', () => { + const result = client.matchProjectFromSourceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.sourcePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromSourceName', () => { + const result = client.matchLocationFromSourceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.sourcePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchSourceFromSourceName', () => { + const result = client.matchSourceFromSourceName(fakePath); + assert.strictEqual(result, 'sourceValue'); + assert( + (client.pathTemplates.sourcePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-migrationcenter/webpack.config.js b/packages/google-cloud-migrationcenter/webpack.config.js index 8ca7559162b2..f1e62781a308 100644 --- a/packages/google-cloud-migrationcenter/webpack.config.js +++ b/packages/google-cloud-migrationcenter/webpack.config.js @@ -1,4 +1,4 @@ -// Copyright 2026 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-modelarmor/.eslintignore b/packages/google-cloud-modelarmor/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-modelarmor/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-modelarmor/.eslintrc.json b/packages/google-cloud-modelarmor/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-modelarmor/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-modelarmor/README.md b/packages/google-cloud-modelarmor/README.md index c765b6bd9ede..3a231a92bce1 100644 --- a/packages/google-cloud-modelarmor/README.md +++ b/packages/google-cloud-modelarmor/README.md @@ -112,7 +112,7 @@ More Information: [Google Cloud Platform Launch Stages][launch_stages] ## Contributing -Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-modelarmor/CONTRIBUTING.md). +Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/CONTRIBUTING.md). Please note that this `README.md` and a variety of configuration files in this repository (including `.nycrc` and `tsconfig.json`) @@ -122,7 +122,7 @@ are generated from a central template. Apache Version 2.0 -See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-modelarmor/LICENSE) +See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/LICENSE) [shell_img]: https://gstatic.com/cloudssh/images/open-btn.png [projects]: https://console.cloud.google.com/project diff --git a/packages/google-cloud-modelarmor/protos/protos.d.ts b/packages/google-cloud-modelarmor/protos/protos.d.ts index 657ed010dc33..ca3e90dabc80 100644 --- a/packages/google-cloud-modelarmor/protos/protos.d.ts +++ b/packages/google-cloud-modelarmor/protos/protos.d.ts @@ -11855,6 +11855,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -11872,6 +11875,9 @@ export namespace google { /** CommonLanguageSettings destinations. */ public destinations: google.api.ClientLibraryDestination[]; + /** CommonLanguageSettings selectiveGapicGeneration. */ + public selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); + /** * Creates a new CommonLanguageSettings instance using the specified properties. * @param [properties] Properties to set @@ -12572,6 +12578,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -12586,6 +12595,9 @@ export namespace google { /** PythonSettings common. */ public common?: (google.api.ICommonLanguageSettings|null); + /** PythonSettings experimentalFeatures. */ + public experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); + /** * Creates a new PythonSettings instance using the specified properties. * @param [properties] Properties to set @@ -12664,6 +12676,118 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + namespace PythonSettings { + + /** Properties of an ExperimentalFeatures. */ + interface IExperimentalFeatures { + + /** ExperimentalFeatures restAsyncIoEnabled */ + restAsyncIoEnabled?: (boolean|null); + + /** ExperimentalFeatures protobufPythonicTypesEnabled */ + protobufPythonicTypesEnabled?: (boolean|null); + + /** ExperimentalFeatures unversionedPackageDisabled */ + unversionedPackageDisabled?: (boolean|null); + } + + /** Represents an ExperimentalFeatures. */ + class ExperimentalFeatures implements IExperimentalFeatures { + + /** + * Constructs a new ExperimentalFeatures. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.PythonSettings.IExperimentalFeatures); + + /** ExperimentalFeatures restAsyncIoEnabled. */ + public restAsyncIoEnabled: boolean; + + /** ExperimentalFeatures protobufPythonicTypesEnabled. */ + public protobufPythonicTypesEnabled: boolean; + + /** ExperimentalFeatures unversionedPackageDisabled. */ + public unversionedPackageDisabled: boolean; + + /** + * Creates a new ExperimentalFeatures instance using the specified properties. + * @param [properties] Properties to set + * @returns ExperimentalFeatures instance + */ + public static create(properties?: google.api.PythonSettings.IExperimentalFeatures): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Encodes the specified ExperimentalFeatures message. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @param message ExperimentalFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.PythonSettings.IExperimentalFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExperimentalFeatures message, length delimited. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @param message ExperimentalFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.PythonSettings.IExperimentalFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExperimentalFeatures + * @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.api.PythonSettings.ExperimentalFeatures; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExperimentalFeatures + * @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.api.PythonSettings.ExperimentalFeatures; + + /** + * Verifies an ExperimentalFeatures 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 an ExperimentalFeatures message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExperimentalFeatures + */ + public static fromObject(object: { [k: string]: any }): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Creates a plain object from an ExperimentalFeatures message. Also converts values to other types if specified. + * @param message ExperimentalFeatures + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.PythonSettings.ExperimentalFeatures, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExperimentalFeatures to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExperimentalFeatures + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + /** Properties of a NodeSettings. */ interface INodeSettings { @@ -12990,6 +13114,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -13004,6 +13131,9 @@ export namespace google { /** GoSettings common. */ public common?: (google.api.ICommonLanguageSettings|null); + /** GoSettings renamedServices. */ + public renamedServices: { [k: string]: string }; + /** * Creates a new GoSettings instance using the specified properties. * @param [properties] Properties to set @@ -13328,6 +13458,109 @@ export namespace google { PACKAGE_MANAGER = 20 } + /** Properties of a SelectiveGapicGeneration. */ + interface ISelectiveGapicGeneration { + + /** SelectiveGapicGeneration methods */ + methods?: (string[]|null); + + /** SelectiveGapicGeneration generateOmittedAsInternal */ + generateOmittedAsInternal?: (boolean|null); + } + + /** Represents a SelectiveGapicGeneration. */ + class SelectiveGapicGeneration implements ISelectiveGapicGeneration { + + /** + * Constructs a new SelectiveGapicGeneration. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.ISelectiveGapicGeneration); + + /** SelectiveGapicGeneration methods. */ + public methods: string[]; + + /** SelectiveGapicGeneration generateOmittedAsInternal. */ + public generateOmittedAsInternal: boolean; + + /** + * Creates a new SelectiveGapicGeneration instance using the specified properties. + * @param [properties] Properties to set + * @returns SelectiveGapicGeneration instance + */ + public static create(properties?: google.api.ISelectiveGapicGeneration): google.api.SelectiveGapicGeneration; + + /** + * Encodes the specified SelectiveGapicGeneration message. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @param message SelectiveGapicGeneration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.ISelectiveGapicGeneration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SelectiveGapicGeneration message, length delimited. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @param message SelectiveGapicGeneration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.ISelectiveGapicGeneration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SelectiveGapicGeneration + * @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.api.SelectiveGapicGeneration; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SelectiveGapicGeneration + * @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.api.SelectiveGapicGeneration; + + /** + * Verifies a SelectiveGapicGeneration 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 SelectiveGapicGeneration message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SelectiveGapicGeneration + */ + public static fromObject(object: { [k: string]: any }): google.api.SelectiveGapicGeneration; + + /** + * Creates a plain object from a SelectiveGapicGeneration message. Also converts values to other types if specified. + * @param message SelectiveGapicGeneration + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.SelectiveGapicGeneration, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SelectiveGapicGeneration to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SelectiveGapicGeneration + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** LaunchStage enum. */ enum LaunchStage { LAUNCH_STAGE_UNSPECIFIED = 0, @@ -13358,6 +13591,9 @@ export namespace google { /** FieldInfo format */ format?: (google.api.FieldInfo.Format|keyof typeof google.api.FieldInfo.Format|null); + + /** FieldInfo referencedTypes */ + referencedTypes?: (google.api.ITypeReference[]|null); } /** Represents a FieldInfo. */ @@ -13372,6 +13608,9 @@ export namespace google { /** FieldInfo format. */ public format: (google.api.FieldInfo.Format|keyof typeof google.api.FieldInfo.Format); + /** FieldInfo referencedTypes. */ + public referencedTypes: google.api.ITypeReference[]; + /** * Creates a new FieldInfo instance using the specified properties. * @param [properties] Properties to set @@ -13462,6 +13701,103 @@ export namespace google { } } + /** Properties of a TypeReference. */ + interface ITypeReference { + + /** TypeReference typeName */ + typeName?: (string|null); + } + + /** Represents a TypeReference. */ + class TypeReference implements ITypeReference { + + /** + * Constructs a new TypeReference. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.ITypeReference); + + /** TypeReference typeName. */ + public typeName: string; + + /** + * Creates a new TypeReference instance using the specified properties. + * @param [properties] Properties to set + * @returns TypeReference instance + */ + public static create(properties?: google.api.ITypeReference): google.api.TypeReference; + + /** + * Encodes the specified TypeReference message. Does not implicitly {@link google.api.TypeReference.verify|verify} messages. + * @param message TypeReference message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.ITypeReference, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified TypeReference message, length delimited. Does not implicitly {@link google.api.TypeReference.verify|verify} messages. + * @param message TypeReference message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.ITypeReference, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TypeReference message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns TypeReference + * @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.api.TypeReference; + + /** + * Decodes a TypeReference message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns TypeReference + * @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.api.TypeReference; + + /** + * Verifies a TypeReference 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 TypeReference message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TypeReference + */ + public static fromObject(object: { [k: string]: any }): google.api.TypeReference; + + /** + * Creates a plain object from a TypeReference message. Also converts values to other types if specified. + * @param message TypeReference + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.TypeReference, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TypeReference to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for TypeReference + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** Properties of a ResourceDescriptor. */ interface IResourceDescriptor { @@ -13818,6 +14154,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -13848,6 +14185,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -13897,6 +14237,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -14031,6 +14374,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -14072,6 +14418,9 @@ export namespace google { /** DescriptorProto reservedName. */ public reservedName: string[]; + /** DescriptorProto visibility. */ + public visibility: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility); + /** * Creates a new DescriptorProto instance using the specified properties. * @param [properties] Properties to set @@ -14919,6 +15268,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -14945,6 +15297,9 @@ export namespace google { /** EnumDescriptorProto reservedName. */ public reservedName: string[]; + /** EnumDescriptorProto visibility. */ + public visibility: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility); + /** * Creates a new EnumDescriptorProto instance using the specified properties. * @param [properties] Properties to set @@ -15879,6 +16234,9 @@ export namespace google { /** FieldOptions features */ features?: (google.protobuf.IFeatureSet|null); + /** FieldOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** FieldOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); @@ -15937,6 +16295,9 @@ export namespace google { /** FieldOptions features. */ public features?: (google.protobuf.IFeatureSet|null); + /** FieldOptions featureSupport. */ + public featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** FieldOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; @@ -16157,6 +16518,121 @@ export namespace google { */ public static getTypeUrl(typeUrlPrefix?: string): string; } + + /** Properties of a FeatureSupport. */ + interface IFeatureSupport { + + /** FeatureSupport editionIntroduced */ + editionIntroduced?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSupport editionDeprecated */ + editionDeprecated?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSupport deprecationWarning */ + deprecationWarning?: (string|null); + + /** FeatureSupport editionRemoved */ + editionRemoved?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + } + + /** Represents a FeatureSupport. */ + class FeatureSupport implements IFeatureSupport { + + /** + * Constructs a new FeatureSupport. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.FieldOptions.IFeatureSupport); + + /** FeatureSupport editionIntroduced. */ + public editionIntroduced: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSupport editionDeprecated. */ + public editionDeprecated: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSupport deprecationWarning. */ + public deprecationWarning: string; + + /** FeatureSupport editionRemoved. */ + public editionRemoved: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** + * Creates a new FeatureSupport instance using the specified properties. + * @param [properties] Properties to set + * @returns FeatureSupport instance + */ + public static create(properties?: google.protobuf.FieldOptions.IFeatureSupport): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Encodes the specified FeatureSupport message. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @param message FeatureSupport message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.FieldOptions.IFeatureSupport, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FeatureSupport message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @param message FeatureSupport message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.FieldOptions.IFeatureSupport, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FeatureSupport + * @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.protobuf.FieldOptions.FeatureSupport; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FeatureSupport + * @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.protobuf.FieldOptions.FeatureSupport; + + /** + * Verifies a FeatureSupport 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 FeatureSupport message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FeatureSupport + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Creates a plain object from a FeatureSupport message. Also converts values to other types if specified. + * @param message FeatureSupport + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldOptions.FeatureSupport, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FeatureSupport to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FeatureSupport + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } } /** Properties of an OneofOptions. */ @@ -16395,6 +16871,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -16417,6 +16896,9 @@ export namespace google { /** EnumValueOptions debugRedact. */ public debugRedact: boolean; + /** EnumValueOptions featureSupport. */ + public featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; @@ -17006,6 +17488,12 @@ export namespace google { /** FeatureSet jsonFormat */ jsonFormat?: (google.protobuf.FeatureSet.JsonFormat|keyof typeof google.protobuf.FeatureSet.JsonFormat|null); + + /** FeatureSet enforceNamingStyle */ + enforceNamingStyle?: (google.protobuf.FeatureSet.EnforceNamingStyle|keyof typeof google.protobuf.FeatureSet.EnforceNamingStyle|null); + + /** FeatureSet defaultSymbolVisibility */ + defaultSymbolVisibility?: (google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|keyof typeof google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|null); } /** Represents a FeatureSet. */ @@ -17035,6 +17523,12 @@ export namespace google { /** FeatureSet jsonFormat. */ public jsonFormat: (google.protobuf.FeatureSet.JsonFormat|keyof typeof google.protobuf.FeatureSet.JsonFormat); + /** FeatureSet enforceNamingStyle. */ + public enforceNamingStyle: (google.protobuf.FeatureSet.EnforceNamingStyle|keyof typeof google.protobuf.FeatureSet.EnforceNamingStyle); + + /** FeatureSet defaultSymbolVisibility. */ + public defaultSymbolVisibility: (google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|keyof typeof google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility); + /** * Creates a new FeatureSet instance using the specified properties. * @param [properties] Properties to set @@ -17157,6 +17651,116 @@ export namespace google { ALLOW = 1, LEGACY_BEST_EFFORT = 2 } + + /** EnforceNamingStyle enum. */ + enum EnforceNamingStyle { + ENFORCE_NAMING_STYLE_UNKNOWN = 0, + STYLE2024 = 1, + STYLE_LEGACY = 2 + } + + /** Properties of a VisibilityFeature. */ + interface IVisibilityFeature { + } + + /** Represents a VisibilityFeature. */ + class VisibilityFeature implements IVisibilityFeature { + + /** + * Constructs a new VisibilityFeature. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.FeatureSet.IVisibilityFeature); + + /** + * Creates a new VisibilityFeature instance using the specified properties. + * @param [properties] Properties to set + * @returns VisibilityFeature instance + */ + public static create(properties?: google.protobuf.FeatureSet.IVisibilityFeature): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Encodes the specified VisibilityFeature message. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @param message VisibilityFeature message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.FeatureSet.IVisibilityFeature, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified VisibilityFeature message, length delimited. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @param message VisibilityFeature message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.FeatureSet.IVisibilityFeature, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns VisibilityFeature + * @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.protobuf.FeatureSet.VisibilityFeature; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns VisibilityFeature + * @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.protobuf.FeatureSet.VisibilityFeature; + + /** + * Verifies a VisibilityFeature 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 VisibilityFeature message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns VisibilityFeature + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Creates a plain object from a VisibilityFeature message. Also converts values to other types if specified. + * @param message VisibilityFeature + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FeatureSet.VisibilityFeature, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this VisibilityFeature to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for VisibilityFeature + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace VisibilityFeature { + + /** DefaultSymbolVisibility enum. */ + enum DefaultSymbolVisibility { + DEFAULT_SYMBOL_VISIBILITY_UNKNOWN = 0, + EXPORT_ALL = 1, + EXPORT_TOP_LEVEL = 2, + LOCAL_ALL = 3, + STRICT = 4 + } + } } /** Properties of a FeatureSetDefaults. */ @@ -17276,8 +17880,11 @@ export namespace google { /** FeatureSetEditionDefault edition */ edition?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); - /** FeatureSetEditionDefault features */ - features?: (google.protobuf.IFeatureSet|null); + /** FeatureSetEditionDefault overridableFeatures */ + overridableFeatures?: (google.protobuf.IFeatureSet|null); + + /** FeatureSetEditionDefault fixedFeatures */ + fixedFeatures?: (google.protobuf.IFeatureSet|null); } /** Represents a FeatureSetEditionDefault. */ @@ -17292,8 +17899,11 @@ export namespace google { /** FeatureSetEditionDefault edition. */ public edition: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); - /** FeatureSetEditionDefault features. */ - public features?: (google.protobuf.IFeatureSet|null); + /** FeatureSetEditionDefault overridableFeatures. */ + public overridableFeatures?: (google.protobuf.IFeatureSet|null); + + /** FeatureSetEditionDefault fixedFeatures. */ + public fixedFeatures?: (google.protobuf.IFeatureSet|null); /** * Creates a new FeatureSetEditionDefault instance using the specified properties. @@ -17826,6 +18436,13 @@ export namespace google { } } + /** SymbolVisibility enum. */ + enum SymbolVisibility { + VISIBILITY_UNSET = 0, + VISIBILITY_LOCAL = 1, + VISIBILITY_EXPORT = 2 + } + /** Properties of a Duration. */ interface IDuration { diff --git a/packages/google-cloud-modelarmor/protos/protos.js b/packages/google-cloud-modelarmor/protos/protos.js index cd9fa3966f5b..bb4f88946666 100644 --- a/packages/google-cloud-modelarmor/protos/protos.js +++ b/packages/google-cloud-modelarmor/protos/protos.js @@ -30783,6 +30783,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -30817,6 +30818,14 @@ */ CommonLanguageSettings.prototype.destinations = $util.emptyArray; + /** + * CommonLanguageSettings selectiveGapicGeneration. + * @member {google.api.ISelectiveGapicGeneration|null|undefined} selectiveGapicGeneration + * @memberof google.api.CommonLanguageSettings + * @instance + */ + CommonLanguageSettings.prototype.selectiveGapicGeneration = null; + /** * Creates a new CommonLanguageSettings instance using the specified properties. * @function create @@ -30849,6 +30858,8 @@ writer.int32(message.destinations[i]); writer.ldelim(); } + if (message.selectiveGapicGeneration != null && Object.hasOwnProperty.call(message, "selectiveGapicGeneration")) + $root.google.api.SelectiveGapicGeneration.encode(message.selectiveGapicGeneration, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); return writer; }; @@ -30900,6 +30911,10 @@ message.destinations.push(reader.int32()); break; } + case 3: { + message.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -30951,6 +30966,11 @@ break; } } + if (message.selectiveGapicGeneration != null && message.hasOwnProperty("selectiveGapicGeneration")) { + var error = $root.google.api.SelectiveGapicGeneration.verify(message.selectiveGapicGeneration); + if (error) + return "selectiveGapicGeneration." + error; + } return null; }; @@ -30993,6 +31013,11 @@ break; } } + if (object.selectiveGapicGeneration != null) { + if (typeof object.selectiveGapicGeneration !== "object") + throw TypeError(".google.api.CommonLanguageSettings.selectiveGapicGeneration: object expected"); + message.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.fromObject(object.selectiveGapicGeneration); + } return message; }; @@ -31011,8 +31036,10 @@ var object = {}; if (options.arrays || options.defaults) object.destinations = []; - if (options.defaults) + if (options.defaults) { object.referenceDocsUri = ""; + object.selectiveGapicGeneration = null; + } if (message.referenceDocsUri != null && message.hasOwnProperty("referenceDocsUri")) object.referenceDocsUri = message.referenceDocsUri; if (message.destinations && message.destinations.length) { @@ -31020,6 +31047,8 @@ for (var j = 0; j < message.destinations.length; ++j) object.destinations[j] = options.enums === String ? $root.google.api.ClientLibraryDestination[message.destinations[j]] === undefined ? message.destinations[j] : $root.google.api.ClientLibraryDestination[message.destinations[j]] : message.destinations[j]; } + if (message.selectiveGapicGeneration != null && message.hasOwnProperty("selectiveGapicGeneration")) + object.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.toObject(message.selectiveGapicGeneration, options); return object; }; @@ -32842,6 +32871,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -32867,6 +32897,14 @@ */ PythonSettings.prototype.common = null; + /** + * PythonSettings experimentalFeatures. + * @member {google.api.PythonSettings.IExperimentalFeatures|null|undefined} experimentalFeatures + * @memberof google.api.PythonSettings + * @instance + */ + PythonSettings.prototype.experimentalFeatures = null; + /** * Creates a new PythonSettings instance using the specified properties. * @function create @@ -32893,6 +32931,8 @@ writer = $Writer.create(); if (message.common != null && Object.hasOwnProperty.call(message, "common")) $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.experimentalFeatures != null && Object.hasOwnProperty.call(message, "experimentalFeatures")) + $root.google.api.PythonSettings.ExperimentalFeatures.encode(message.experimentalFeatures, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; @@ -32933,6 +32973,10 @@ message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); break; } + case 2: { + message.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -32973,6 +33017,11 @@ if (error) return "common." + error; } + if (message.experimentalFeatures != null && message.hasOwnProperty("experimentalFeatures")) { + var error = $root.google.api.PythonSettings.ExperimentalFeatures.verify(message.experimentalFeatures); + if (error) + return "experimentalFeatures." + error; + } return null; }; @@ -32993,6 +33042,11 @@ throw TypeError(".google.api.PythonSettings.common: object expected"); message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); } + if (object.experimentalFeatures != null) { + if (typeof object.experimentalFeatures !== "object") + throw TypeError(".google.api.PythonSettings.experimentalFeatures: object expected"); + message.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.fromObject(object.experimentalFeatures); + } return message; }; @@ -33009,10 +33063,14 @@ if (!options) options = {}; var object = {}; - if (options.defaults) + if (options.defaults) { object.common = null; + object.experimentalFeatures = null; + } if (message.common != null && message.hasOwnProperty("common")) object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + if (message.experimentalFeatures != null && message.hasOwnProperty("experimentalFeatures")) + object.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.toObject(message.experimentalFeatures, options); return object; }; @@ -33042,6 +33100,258 @@ return typeUrlPrefix + "/google.api.PythonSettings"; }; + PythonSettings.ExperimentalFeatures = (function() { + + /** + * Properties of an ExperimentalFeatures. + * @memberof google.api.PythonSettings + * @interface IExperimentalFeatures + * @property {boolean|null} [restAsyncIoEnabled] ExperimentalFeatures restAsyncIoEnabled + * @property {boolean|null} [protobufPythonicTypesEnabled] ExperimentalFeatures protobufPythonicTypesEnabled + * @property {boolean|null} [unversionedPackageDisabled] ExperimentalFeatures unversionedPackageDisabled + */ + + /** + * Constructs a new ExperimentalFeatures. + * @memberof google.api.PythonSettings + * @classdesc Represents an ExperimentalFeatures. + * @implements IExperimentalFeatures + * @constructor + * @param {google.api.PythonSettings.IExperimentalFeatures=} [properties] Properties to set + */ + function ExperimentalFeatures(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]]; + } + + /** + * ExperimentalFeatures restAsyncIoEnabled. + * @member {boolean} restAsyncIoEnabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.restAsyncIoEnabled = false; + + /** + * ExperimentalFeatures protobufPythonicTypesEnabled. + * @member {boolean} protobufPythonicTypesEnabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.protobufPythonicTypesEnabled = false; + + /** + * ExperimentalFeatures unversionedPackageDisabled. + * @member {boolean} unversionedPackageDisabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.unversionedPackageDisabled = false; + + /** + * Creates a new ExperimentalFeatures instance using the specified properties. + * @function create + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures=} [properties] Properties to set + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures instance + */ + ExperimentalFeatures.create = function create(properties) { + return new ExperimentalFeatures(properties); + }; + + /** + * Encodes the specified ExperimentalFeatures message. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @function encode + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures} message ExperimentalFeatures message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExperimentalFeatures.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.restAsyncIoEnabled != null && Object.hasOwnProperty.call(message, "restAsyncIoEnabled")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.restAsyncIoEnabled); + if (message.protobufPythonicTypesEnabled != null && Object.hasOwnProperty.call(message, "protobufPythonicTypesEnabled")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.protobufPythonicTypesEnabled); + if (message.unversionedPackageDisabled != null && Object.hasOwnProperty.call(message, "unversionedPackageDisabled")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.unversionedPackageDisabled); + return writer; + }; + + /** + * Encodes the specified ExperimentalFeatures message, length delimited. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures} message ExperimentalFeatures message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExperimentalFeatures.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer. + * @function decode + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExperimentalFeatures.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.PythonSettings.ExperimentalFeatures(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.restAsyncIoEnabled = reader.bool(); + break; + } + case 2: { + message.protobufPythonicTypesEnabled = reader.bool(); + break; + } + case 3: { + message.unversionedPackageDisabled = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExperimentalFeatures.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExperimentalFeatures message. + * @function verify + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExperimentalFeatures.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.restAsyncIoEnabled != null && message.hasOwnProperty("restAsyncIoEnabled")) + if (typeof message.restAsyncIoEnabled !== "boolean") + return "restAsyncIoEnabled: boolean expected"; + if (message.protobufPythonicTypesEnabled != null && message.hasOwnProperty("protobufPythonicTypesEnabled")) + if (typeof message.protobufPythonicTypesEnabled !== "boolean") + return "protobufPythonicTypesEnabled: boolean expected"; + if (message.unversionedPackageDisabled != null && message.hasOwnProperty("unversionedPackageDisabled")) + if (typeof message.unversionedPackageDisabled !== "boolean") + return "unversionedPackageDisabled: boolean expected"; + return null; + }; + + /** + * Creates an ExperimentalFeatures message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {Object.} object Plain object + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + */ + ExperimentalFeatures.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.PythonSettings.ExperimentalFeatures) + return object; + var message = new $root.google.api.PythonSettings.ExperimentalFeatures(); + if (object.restAsyncIoEnabled != null) + message.restAsyncIoEnabled = Boolean(object.restAsyncIoEnabled); + if (object.protobufPythonicTypesEnabled != null) + message.protobufPythonicTypesEnabled = Boolean(object.protobufPythonicTypesEnabled); + if (object.unversionedPackageDisabled != null) + message.unversionedPackageDisabled = Boolean(object.unversionedPackageDisabled); + return message; + }; + + /** + * Creates a plain object from an ExperimentalFeatures message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.ExperimentalFeatures} message ExperimentalFeatures + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExperimentalFeatures.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.restAsyncIoEnabled = false; + object.protobufPythonicTypesEnabled = false; + object.unversionedPackageDisabled = false; + } + if (message.restAsyncIoEnabled != null && message.hasOwnProperty("restAsyncIoEnabled")) + object.restAsyncIoEnabled = message.restAsyncIoEnabled; + if (message.protobufPythonicTypesEnabled != null && message.hasOwnProperty("protobufPythonicTypesEnabled")) + object.protobufPythonicTypesEnabled = message.protobufPythonicTypesEnabled; + if (message.unversionedPackageDisabled != null && message.hasOwnProperty("unversionedPackageDisabled")) + object.unversionedPackageDisabled = message.unversionedPackageDisabled; + return object; + }; + + /** + * Converts this ExperimentalFeatures to JSON. + * @function toJSON + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + * @returns {Object.} JSON object + */ + ExperimentalFeatures.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExperimentalFeatures + * @function getTypeUrl + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExperimentalFeatures.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.PythonSettings.ExperimentalFeatures"; + }; + + return ExperimentalFeatures; + })(); + return PythonSettings; })(); @@ -33918,6 +34228,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -33929,6 +34240,7 @@ * @param {google.api.IGoSettings=} [properties] Properties to set */ function GoSettings(properties) { + this.renamedServices = {}; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -33943,6 +34255,14 @@ */ GoSettings.prototype.common = null; + /** + * GoSettings renamedServices. + * @member {Object.} renamedServices + * @memberof google.api.GoSettings + * @instance + */ + GoSettings.prototype.renamedServices = $util.emptyObject; + /** * Creates a new GoSettings instance using the specified properties. * @function create @@ -33969,6 +34289,9 @@ writer = $Writer.create(); if (message.common != null && Object.hasOwnProperty.call(message, "common")) $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.renamedServices != null && Object.hasOwnProperty.call(message, "renamedServices")) + for (var keys = Object.keys(message.renamedServices), i = 0; i < keys.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.renamedServices[keys[i]]).ldelim(); return writer; }; @@ -33999,7 +34322,7 @@ GoSettings.decode = function decode(reader, length, error) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.GoSettings(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.GoSettings(), key, value; while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) @@ -34009,6 +34332,29 @@ message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); break; } + case 2: { + if (message.renamedServices === $util.emptyObject) + message.renamedServices = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = ""; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = reader.string(); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.renamedServices[key] = value; + break; + } default: reader.skipType(tag & 7); break; @@ -34049,6 +34395,14 @@ if (error) return "common." + error; } + if (message.renamedServices != null && message.hasOwnProperty("renamedServices")) { + if (!$util.isObject(message.renamedServices)) + return "renamedServices: object expected"; + var key = Object.keys(message.renamedServices); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.renamedServices[key[i]])) + return "renamedServices: string{k:string} expected"; + } return null; }; @@ -34069,6 +34423,13 @@ throw TypeError(".google.api.GoSettings.common: object expected"); message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); } + if (object.renamedServices) { + if (typeof object.renamedServices !== "object") + throw TypeError(".google.api.GoSettings.renamedServices: object expected"); + message.renamedServices = {}; + for (var keys = Object.keys(object.renamedServices), i = 0; i < keys.length; ++i) + message.renamedServices[keys[i]] = String(object.renamedServices[keys[i]]); + } return message; }; @@ -34085,10 +34446,18 @@ if (!options) options = {}; var object = {}; + if (options.objects || options.defaults) + object.renamedServices = {}; if (options.defaults) object.common = null; if (message.common != null && message.hasOwnProperty("common")) object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + var keys2; + if (message.renamedServices && (keys2 = Object.keys(message.renamedServices)).length) { + object.renamedServices = {}; + for (var j = 0; j < keys2.length; ++j) + object.renamedServices[keys2[j]] = message.renamedServices[keys2[j]]; + } return object; }; @@ -34727,30 +35096,275 @@ return values; })(); - /** - * LaunchStage enum. - * @name google.api.LaunchStage - * @enum {number} - * @property {number} LAUNCH_STAGE_UNSPECIFIED=0 LAUNCH_STAGE_UNSPECIFIED value - * @property {number} UNIMPLEMENTED=6 UNIMPLEMENTED value - * @property {number} PRELAUNCH=7 PRELAUNCH value - * @property {number} EARLY_ACCESS=1 EARLY_ACCESS value - * @property {number} ALPHA=2 ALPHA value - * @property {number} BETA=3 BETA value - * @property {number} GA=4 GA value - * @property {number} DEPRECATED=5 DEPRECATED value - */ - api.LaunchStage = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "LAUNCH_STAGE_UNSPECIFIED"] = 0; - values[valuesById[6] = "UNIMPLEMENTED"] = 6; - values[valuesById[7] = "PRELAUNCH"] = 7; - values[valuesById[1] = "EARLY_ACCESS"] = 1; - values[valuesById[2] = "ALPHA"] = 2; - values[valuesById[3] = "BETA"] = 3; - values[valuesById[4] = "GA"] = 4; - values[valuesById[5] = "DEPRECATED"] = 5; - return values; + api.SelectiveGapicGeneration = (function() { + + /** + * Properties of a SelectiveGapicGeneration. + * @memberof google.api + * @interface ISelectiveGapicGeneration + * @property {Array.|null} [methods] SelectiveGapicGeneration methods + * @property {boolean|null} [generateOmittedAsInternal] SelectiveGapicGeneration generateOmittedAsInternal + */ + + /** + * Constructs a new SelectiveGapicGeneration. + * @memberof google.api + * @classdesc Represents a SelectiveGapicGeneration. + * @implements ISelectiveGapicGeneration + * @constructor + * @param {google.api.ISelectiveGapicGeneration=} [properties] Properties to set + */ + function SelectiveGapicGeneration(properties) { + this.methods = []; + 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]]; + } + + /** + * SelectiveGapicGeneration methods. + * @member {Array.} methods + * @memberof google.api.SelectiveGapicGeneration + * @instance + */ + SelectiveGapicGeneration.prototype.methods = $util.emptyArray; + + /** + * SelectiveGapicGeneration generateOmittedAsInternal. + * @member {boolean} generateOmittedAsInternal + * @memberof google.api.SelectiveGapicGeneration + * @instance + */ + SelectiveGapicGeneration.prototype.generateOmittedAsInternal = false; + + /** + * Creates a new SelectiveGapicGeneration instance using the specified properties. + * @function create + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration=} [properties] Properties to set + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration instance + */ + SelectiveGapicGeneration.create = function create(properties) { + return new SelectiveGapicGeneration(properties); + }; + + /** + * Encodes the specified SelectiveGapicGeneration message. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @function encode + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration} message SelectiveGapicGeneration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SelectiveGapicGeneration.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.methods != null && message.methods.length) + for (var i = 0; i < message.methods.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.methods[i]); + if (message.generateOmittedAsInternal != null && Object.hasOwnProperty.call(message, "generateOmittedAsInternal")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.generateOmittedAsInternal); + return writer; + }; + + /** + * Encodes the specified SelectiveGapicGeneration message, length delimited. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration} message SelectiveGapicGeneration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SelectiveGapicGeneration.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer. + * @function decode + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SelectiveGapicGeneration.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.SelectiveGapicGeneration(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + if (!(message.methods && message.methods.length)) + message.methods = []; + message.methods.push(reader.string()); + break; + } + case 2: { + message.generateOmittedAsInternal = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SelectiveGapicGeneration.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SelectiveGapicGeneration message. + * @function verify + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SelectiveGapicGeneration.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.methods != null && message.hasOwnProperty("methods")) { + if (!Array.isArray(message.methods)) + return "methods: array expected"; + for (var i = 0; i < message.methods.length; ++i) + if (!$util.isString(message.methods[i])) + return "methods: string[] expected"; + } + if (message.generateOmittedAsInternal != null && message.hasOwnProperty("generateOmittedAsInternal")) + if (typeof message.generateOmittedAsInternal !== "boolean") + return "generateOmittedAsInternal: boolean expected"; + return null; + }; + + /** + * Creates a SelectiveGapicGeneration message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {Object.} object Plain object + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + */ + SelectiveGapicGeneration.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.SelectiveGapicGeneration) + return object; + var message = new $root.google.api.SelectiveGapicGeneration(); + if (object.methods) { + if (!Array.isArray(object.methods)) + throw TypeError(".google.api.SelectiveGapicGeneration.methods: array expected"); + message.methods = []; + for (var i = 0; i < object.methods.length; ++i) + message.methods[i] = String(object.methods[i]); + } + if (object.generateOmittedAsInternal != null) + message.generateOmittedAsInternal = Boolean(object.generateOmittedAsInternal); + return message; + }; + + /** + * Creates a plain object from a SelectiveGapicGeneration message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.SelectiveGapicGeneration} message SelectiveGapicGeneration + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SelectiveGapicGeneration.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.methods = []; + if (options.defaults) + object.generateOmittedAsInternal = false; + if (message.methods && message.methods.length) { + object.methods = []; + for (var j = 0; j < message.methods.length; ++j) + object.methods[j] = message.methods[j]; + } + if (message.generateOmittedAsInternal != null && message.hasOwnProperty("generateOmittedAsInternal")) + object.generateOmittedAsInternal = message.generateOmittedAsInternal; + return object; + }; + + /** + * Converts this SelectiveGapicGeneration to JSON. + * @function toJSON + * @memberof google.api.SelectiveGapicGeneration + * @instance + * @returns {Object.} JSON object + */ + SelectiveGapicGeneration.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SelectiveGapicGeneration + * @function getTypeUrl + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SelectiveGapicGeneration.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.SelectiveGapicGeneration"; + }; + + return SelectiveGapicGeneration; + })(); + + /** + * LaunchStage enum. + * @name google.api.LaunchStage + * @enum {number} + * @property {number} LAUNCH_STAGE_UNSPECIFIED=0 LAUNCH_STAGE_UNSPECIFIED value + * @property {number} UNIMPLEMENTED=6 UNIMPLEMENTED value + * @property {number} PRELAUNCH=7 PRELAUNCH value + * @property {number} EARLY_ACCESS=1 EARLY_ACCESS value + * @property {number} ALPHA=2 ALPHA value + * @property {number} BETA=3 BETA value + * @property {number} GA=4 GA value + * @property {number} DEPRECATED=5 DEPRECATED value + */ + api.LaunchStage = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "LAUNCH_STAGE_UNSPECIFIED"] = 0; + values[valuesById[6] = "UNIMPLEMENTED"] = 6; + values[valuesById[7] = "PRELAUNCH"] = 7; + values[valuesById[1] = "EARLY_ACCESS"] = 1; + values[valuesById[2] = "ALPHA"] = 2; + values[valuesById[3] = "BETA"] = 3; + values[valuesById[4] = "GA"] = 4; + values[valuesById[5] = "DEPRECATED"] = 5; + return values; })(); /** @@ -34788,6 +35402,7 @@ * @memberof google.api * @interface IFieldInfo * @property {google.api.FieldInfo.Format|null} [format] FieldInfo format + * @property {Array.|null} [referencedTypes] FieldInfo referencedTypes */ /** @@ -34799,6 +35414,7 @@ * @param {google.api.IFieldInfo=} [properties] Properties to set */ function FieldInfo(properties) { + this.referencedTypes = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -34813,6 +35429,14 @@ */ FieldInfo.prototype.format = 0; + /** + * FieldInfo referencedTypes. + * @member {Array.} referencedTypes + * @memberof google.api.FieldInfo + * @instance + */ + FieldInfo.prototype.referencedTypes = $util.emptyArray; + /** * Creates a new FieldInfo instance using the specified properties. * @function create @@ -34839,6 +35463,9 @@ writer = $Writer.create(); if (message.format != null && Object.hasOwnProperty.call(message, "format")) writer.uint32(/* id 1, wireType 0 =*/8).int32(message.format); + if (message.referencedTypes != null && message.referencedTypes.length) + for (var i = 0; i < message.referencedTypes.length; ++i) + $root.google.api.TypeReference.encode(message.referencedTypes[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; @@ -34879,6 +35506,12 @@ message.format = reader.int32(); break; } + case 2: { + if (!(message.referencedTypes && message.referencedTypes.length)) + message.referencedTypes = []; + message.referencedTypes.push($root.google.api.TypeReference.decode(reader, reader.uint32())); + break; + } default: reader.skipType(tag & 7); break; @@ -34925,6 +35558,15 @@ case 4: break; } + if (message.referencedTypes != null && message.hasOwnProperty("referencedTypes")) { + if (!Array.isArray(message.referencedTypes)) + return "referencedTypes: array expected"; + for (var i = 0; i < message.referencedTypes.length; ++i) { + var error = $root.google.api.TypeReference.verify(message.referencedTypes[i]); + if (error) + return "referencedTypes." + error; + } + } return null; }; @@ -34968,6 +35610,16 @@ message.format = 4; break; } + if (object.referencedTypes) { + if (!Array.isArray(object.referencedTypes)) + throw TypeError(".google.api.FieldInfo.referencedTypes: array expected"); + message.referencedTypes = []; + for (var i = 0; i < object.referencedTypes.length; ++i) { + if (typeof object.referencedTypes[i] !== "object") + throw TypeError(".google.api.FieldInfo.referencedTypes: object expected"); + message.referencedTypes[i] = $root.google.api.TypeReference.fromObject(object.referencedTypes[i]); + } + } return message; }; @@ -34984,10 +35636,17 @@ if (!options) options = {}; var object = {}; + if (options.arrays || options.defaults) + object.referencedTypes = []; if (options.defaults) object.format = options.enums === String ? "FORMAT_UNSPECIFIED" : 0; if (message.format != null && message.hasOwnProperty("format")) object.format = options.enums === String ? $root.google.api.FieldInfo.Format[message.format] === undefined ? message.format : $root.google.api.FieldInfo.Format[message.format] : message.format; + if (message.referencedTypes && message.referencedTypes.length) { + object.referencedTypes = []; + for (var j = 0; j < message.referencedTypes.length; ++j) + object.referencedTypes[j] = $root.google.api.TypeReference.toObject(message.referencedTypes[j], options); + } return object; }; @@ -35040,32 +35699,24 @@ return FieldInfo; })(); - api.ResourceDescriptor = (function() { + api.TypeReference = (function() { /** - * Properties of a ResourceDescriptor. + * Properties of a TypeReference. * @memberof google.api - * @interface IResourceDescriptor - * @property {string|null} [type] ResourceDescriptor type - * @property {Array.|null} [pattern] ResourceDescriptor pattern - * @property {string|null} [nameField] ResourceDescriptor nameField - * @property {google.api.ResourceDescriptor.History|null} [history] ResourceDescriptor history - * @property {string|null} [plural] ResourceDescriptor plural - * @property {string|null} [singular] ResourceDescriptor singular - * @property {Array.|null} [style] ResourceDescriptor style + * @interface ITypeReference + * @property {string|null} [typeName] TypeReference typeName */ /** - * Constructs a new ResourceDescriptor. + * Constructs a new TypeReference. * @memberof google.api - * @classdesc Represents a ResourceDescriptor. - * @implements IResourceDescriptor + * @classdesc Represents a TypeReference. + * @implements ITypeReference * @constructor - * @param {google.api.IResourceDescriptor=} [properties] Properties to set + * @param {google.api.ITypeReference=} [properties] Properties to set */ - function ResourceDescriptor(properties) { - this.pattern = []; - this.style = []; + function TypeReference(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -35073,50 +35724,263 @@ } /** - * ResourceDescriptor type. - * @member {string} type - * @memberof google.api.ResourceDescriptor + * TypeReference typeName. + * @member {string} typeName + * @memberof google.api.TypeReference * @instance */ - ResourceDescriptor.prototype.type = ""; + TypeReference.prototype.typeName = ""; /** - * ResourceDescriptor pattern. - * @member {Array.} pattern - * @memberof google.api.ResourceDescriptor - * @instance + * Creates a new TypeReference instance using the specified properties. + * @function create + * @memberof google.api.TypeReference + * @static + * @param {google.api.ITypeReference=} [properties] Properties to set + * @returns {google.api.TypeReference} TypeReference instance */ - ResourceDescriptor.prototype.pattern = $util.emptyArray; + TypeReference.create = function create(properties) { + return new TypeReference(properties); + }; /** - * ResourceDescriptor nameField. - * @member {string} nameField - * @memberof google.api.ResourceDescriptor - * @instance + * Encodes the specified TypeReference message. Does not implicitly {@link google.api.TypeReference.verify|verify} messages. + * @function encode + * @memberof google.api.TypeReference + * @static + * @param {google.api.ITypeReference} message TypeReference message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer */ - ResourceDescriptor.prototype.nameField = ""; + TypeReference.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.typeName != null && Object.hasOwnProperty.call(message, "typeName")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.typeName); + return writer; + }; /** - * ResourceDescriptor history. - * @member {google.api.ResourceDescriptor.History} history - * @memberof google.api.ResourceDescriptor - * @instance + * Encodes the specified TypeReference message, length delimited. Does not implicitly {@link google.api.TypeReference.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.TypeReference + * @static + * @param {google.api.ITypeReference} message TypeReference message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer */ - ResourceDescriptor.prototype.history = 0; + TypeReference.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; /** - * ResourceDescriptor plural. - * @member {string} plural - * @memberof google.api.ResourceDescriptor - * @instance + * Decodes a TypeReference message from the specified reader or buffer. + * @function decode + * @memberof google.api.TypeReference + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.TypeReference} TypeReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - ResourceDescriptor.prototype.plural = ""; - - /** - * ResourceDescriptor singular. - * @member {string} singular - * @memberof google.api.ResourceDescriptor - * @instance + TypeReference.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.TypeReference(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.typeName = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a TypeReference message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.TypeReference + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.TypeReference} TypeReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TypeReference.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TypeReference message. + * @function verify + * @memberof google.api.TypeReference + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TypeReference.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.typeName != null && message.hasOwnProperty("typeName")) + if (!$util.isString(message.typeName)) + return "typeName: string expected"; + return null; + }; + + /** + * Creates a TypeReference message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.TypeReference + * @static + * @param {Object.} object Plain object + * @returns {google.api.TypeReference} TypeReference + */ + TypeReference.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.TypeReference) + return object; + var message = new $root.google.api.TypeReference(); + if (object.typeName != null) + message.typeName = String(object.typeName); + return message; + }; + + /** + * Creates a plain object from a TypeReference message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.TypeReference + * @static + * @param {google.api.TypeReference} message TypeReference + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TypeReference.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.typeName = ""; + if (message.typeName != null && message.hasOwnProperty("typeName")) + object.typeName = message.typeName; + return object; + }; + + /** + * Converts this TypeReference to JSON. + * @function toJSON + * @memberof google.api.TypeReference + * @instance + * @returns {Object.} JSON object + */ + TypeReference.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for TypeReference + * @function getTypeUrl + * @memberof google.api.TypeReference + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + TypeReference.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.TypeReference"; + }; + + return TypeReference; + })(); + + api.ResourceDescriptor = (function() { + + /** + * Properties of a ResourceDescriptor. + * @memberof google.api + * @interface IResourceDescriptor + * @property {string|null} [type] ResourceDescriptor type + * @property {Array.|null} [pattern] ResourceDescriptor pattern + * @property {string|null} [nameField] ResourceDescriptor nameField + * @property {google.api.ResourceDescriptor.History|null} [history] ResourceDescriptor history + * @property {string|null} [plural] ResourceDescriptor plural + * @property {string|null} [singular] ResourceDescriptor singular + * @property {Array.|null} [style] ResourceDescriptor style + */ + + /** + * Constructs a new ResourceDescriptor. + * @memberof google.api + * @classdesc Represents a ResourceDescriptor. + * @implements IResourceDescriptor + * @constructor + * @param {google.api.IResourceDescriptor=} [properties] Properties to set + */ + function ResourceDescriptor(properties) { + this.pattern = []; + this.style = []; + 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]]; + } + + /** + * ResourceDescriptor type. + * @member {string} type + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.type = ""; + + /** + * ResourceDescriptor pattern. + * @member {Array.} pattern + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.pattern = $util.emptyArray; + + /** + * ResourceDescriptor nameField. + * @member {string} nameField + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.nameField = ""; + + /** + * ResourceDescriptor history. + * @member {google.api.ResourceDescriptor.History} history + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.history = 0; + + /** + * ResourceDescriptor plural. + * @member {string} plural + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.plural = ""; + + /** + * ResourceDescriptor singular. + * @member {string} singular + * @memberof google.api.ResourceDescriptor + * @instance */ ResourceDescriptor.prototype.singular = ""; @@ -35971,6 +36835,7 @@ * @name google.protobuf.Edition * @enum {number} * @property {number} EDITION_UNKNOWN=0 EDITION_UNKNOWN value + * @property {number} EDITION_LEGACY=900 EDITION_LEGACY value * @property {number} EDITION_PROTO2=998 EDITION_PROTO2 value * @property {number} EDITION_PROTO3=999 EDITION_PROTO3 value * @property {number} EDITION_2023=1000 EDITION_2023 value @@ -35985,6 +36850,7 @@ protobuf.Edition = (function() { var valuesById = {}, values = Object.create(valuesById); values[valuesById[0] = "EDITION_UNKNOWN"] = 0; + values[valuesById[900] = "EDITION_LEGACY"] = 900; values[valuesById[998] = "EDITION_PROTO2"] = 998; values[valuesById[999] = "EDITION_PROTO3"] = 999; values[valuesById[1000] = "EDITION_2023"] = 1000; @@ -36009,6 +36875,7 @@ * @property {Array.|null} [dependency] FileDescriptorProto dependency * @property {Array.|null} [publicDependency] FileDescriptorProto publicDependency * @property {Array.|null} [weakDependency] FileDescriptorProto weakDependency + * @property {Array.|null} [optionDependency] FileDescriptorProto optionDependency * @property {Array.|null} [messageType] FileDescriptorProto messageType * @property {Array.|null} [enumType] FileDescriptorProto enumType * @property {Array.|null} [service] FileDescriptorProto service @@ -36031,6 +36898,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -36081,6 +36949,14 @@ */ FileDescriptorProto.prototype.weakDependency = $util.emptyArray; + /** + * FileDescriptorProto optionDependency. + * @member {Array.} optionDependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.optionDependency = $util.emptyArray; + /** * FileDescriptorProto messageType. * @member {Array.} messageType @@ -36202,6 +37078,9 @@ writer.uint32(/* id 12, wireType 2 =*/98).string(message.syntax); if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) writer.uint32(/* id 14, wireType 0 =*/112).int32(message.edition); + if (message.optionDependency != null && message.optionDependency.length) + for (var i = 0; i < message.optionDependency.length; ++i) + writer.uint32(/* id 15, wireType 2 =*/122).string(message.optionDependency[i]); return writer; }; @@ -36274,6 +37153,12 @@ message.weakDependency.push(reader.int32()); break; } + case 15: { + if (!(message.optionDependency && message.optionDependency.length)) + message.optionDependency = []; + message.optionDependency.push(reader.string()); + break; + } case 4: { if (!(message.messageType && message.messageType.length)) message.messageType = []; @@ -36376,6 +37261,13 @@ if (!$util.isInteger(message.weakDependency[i])) return "weakDependency: integer[] expected"; } + if (message.optionDependency != null && message.hasOwnProperty("optionDependency")) { + if (!Array.isArray(message.optionDependency)) + return "optionDependency: array expected"; + for (var i = 0; i < message.optionDependency.length; ++i) + if (!$util.isString(message.optionDependency[i])) + return "optionDependency: string[] expected"; + } if (message.messageType != null && message.hasOwnProperty("messageType")) { if (!Array.isArray(message.messageType)) return "messageType: array expected"; @@ -36430,6 +37322,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -36482,6 +37375,13 @@ for (var i = 0; i < object.weakDependency.length; ++i) message.weakDependency[i] = object.weakDependency[i] | 0; } + if (object.optionDependency) { + if (!Array.isArray(object.optionDependency)) + throw TypeError(".google.protobuf.FileDescriptorProto.optionDependency: array expected"); + message.optionDependency = []; + for (var i = 0; i < object.optionDependency.length; ++i) + message.optionDependency[i] = String(object.optionDependency[i]); + } if (object.messageType) { if (!Array.isArray(object.messageType)) throw TypeError(".google.protobuf.FileDescriptorProto.messageType: array expected"); @@ -36545,6 +37445,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -36610,6 +37514,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -36666,6 +37571,11 @@ object.syntax = message.syntax; if (message.edition != null && message.hasOwnProperty("edition")) object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.optionDependency && message.optionDependency.length) { + object.optionDependency = []; + for (var j = 0; j < message.optionDependency.length; ++j) + object.optionDependency[j] = message.optionDependency[j]; + } return object; }; @@ -36714,6 +37624,7 @@ * @property {google.protobuf.IMessageOptions|null} [options] DescriptorProto options * @property {Array.|null} [reservedRange] DescriptorProto reservedRange * @property {Array.|null} [reservedName] DescriptorProto reservedName + * @property {google.protobuf.SymbolVisibility|null} [visibility] DescriptorProto visibility */ /** @@ -36819,6 +37730,14 @@ */ DescriptorProto.prototype.reservedName = $util.emptyArray; + /** + * DescriptorProto visibility. + * @member {google.protobuf.SymbolVisibility} visibility + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.visibility = 0; + /** * Creates a new DescriptorProto instance using the specified properties. * @function create @@ -36871,6 +37790,8 @@ if (message.reservedName != null && message.reservedName.length) for (var i = 0; i < message.reservedName.length; ++i) writer.uint32(/* id 10, wireType 2 =*/82).string(message.reservedName[i]); + if (message.visibility != null && Object.hasOwnProperty.call(message, "visibility")) + writer.uint32(/* id 11, wireType 0 =*/88).int32(message.visibility); return writer; }; @@ -36963,6 +37884,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -37076,6 +38001,15 @@ if (!$util.isString(message.reservedName[i])) return "reservedName: string[] expected"; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + switch (message.visibility) { + default: + return "visibility: enum value expected"; + case 0: + case 1: + case 2: + break; + } return null; }; @@ -37175,6 +38109,26 @@ for (var i = 0; i < object.reservedName.length; ++i) message.reservedName[i] = String(object.reservedName[i]); } + switch (object.visibility) { + default: + if (typeof object.visibility === "number") { + message.visibility = object.visibility; + break; + } + break; + case "VISIBILITY_UNSET": + case 0: + message.visibility = 0; + break; + case "VISIBILITY_LOCAL": + case 1: + message.visibility = 1; + break; + case "VISIBILITY_EXPORT": + case 2: + message.visibility = 2; + break; + } return message; }; @@ -37204,6 +38158,7 @@ if (options.defaults) { object.name = ""; object.options = null; + object.visibility = options.enums === String ? "VISIBILITY_UNSET" : 0; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -37249,6 +38204,8 @@ for (var j = 0; j < message.reservedName.length; ++j) object.reservedName[j] = message.reservedName[j]; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + object.visibility = options.enums === String ? $root.google.protobuf.SymbolVisibility[message.visibility] === undefined ? message.visibility : $root.google.protobuf.SymbolVisibility[message.visibility] : message.visibility; return object; }; @@ -39293,6 +40250,7 @@ * @property {google.protobuf.IEnumOptions|null} [options] EnumDescriptorProto options * @property {Array.|null} [reservedRange] EnumDescriptorProto reservedRange * @property {Array.|null} [reservedName] EnumDescriptorProto reservedName + * @property {google.protobuf.SymbolVisibility|null} [visibility] EnumDescriptorProto visibility */ /** @@ -39353,6 +40311,14 @@ */ EnumDescriptorProto.prototype.reservedName = $util.emptyArray; + /** + * EnumDescriptorProto visibility. + * @member {google.protobuf.SymbolVisibility} visibility + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.visibility = 0; + /** * Creates a new EnumDescriptorProto instance using the specified properties. * @function create @@ -39390,6 +40356,8 @@ if (message.reservedName != null && message.reservedName.length) for (var i = 0; i < message.reservedName.length; ++i) writer.uint32(/* id 5, wireType 2 =*/42).string(message.reservedName[i]); + if (message.visibility != null && Object.hasOwnProperty.call(message, "visibility")) + writer.uint32(/* id 6, wireType 0 =*/48).int32(message.visibility); return writer; }; @@ -39452,6 +40420,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -39520,6 +40492,15 @@ if (!$util.isString(message.reservedName[i])) return "reservedName: string[] expected"; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + switch (message.visibility) { + default: + return "visibility: enum value expected"; + case 0: + case 1: + case 2: + break; + } return null; }; @@ -39569,6 +40550,26 @@ for (var i = 0; i < object.reservedName.length; ++i) message.reservedName[i] = String(object.reservedName[i]); } + switch (object.visibility) { + default: + if (typeof object.visibility === "number") { + message.visibility = object.visibility; + break; + } + break; + case "VISIBILITY_UNSET": + case 0: + message.visibility = 0; + break; + case "VISIBILITY_LOCAL": + case 1: + message.visibility = 1; + break; + case "VISIBILITY_EXPORT": + case 2: + message.visibility = 2; + break; + } return message; }; @@ -39593,6 +40594,7 @@ if (options.defaults) { object.name = ""; object.options = null; + object.visibility = options.enums === String ? "VISIBILITY_UNSET" : 0; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -39613,6 +40615,8 @@ for (var j = 0; j < message.reservedName.length; ++j) object.reservedName[j] = message.reservedName[j]; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + object.visibility = options.enums === String ? $root.google.protobuf.SymbolVisibility[message.visibility] === undefined ? message.visibility : $root.google.protobuf.SymbolVisibility[message.visibility] : message.visibility; return object; }; @@ -41931,6 +42935,7 @@ * @property {Array.|null} [targets] FieldOptions targets * @property {Array.|null} [editionDefaults] FieldOptions editionDefaults * @property {google.protobuf.IFeatureSet|null} [features] FieldOptions features + * @property {google.protobuf.FieldOptions.IFeatureSupport|null} [featureSupport] FieldOptions featureSupport * @property {Array.|null} [uninterpretedOption] FieldOptions uninterpretedOption * @property {Array.|null} [".google.api.fieldBehavior"] FieldOptions .google.api.fieldBehavior * @property {google.api.IFieldInfo|null} [".google.api.fieldInfo"] FieldOptions .google.api.fieldInfo @@ -42052,6 +43057,14 @@ */ FieldOptions.prototype.features = null; + /** + * FieldOptions featureSupport. + * @member {google.protobuf.FieldOptions.IFeatureSupport|null|undefined} featureSupport + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.featureSupport = null; + /** * FieldOptions uninterpretedOption. * @member {Array.} uninterpretedOption @@ -42134,6 +43147,8 @@ $root.google.protobuf.FieldOptions.EditionDefault.encode(message.editionDefaults[i], writer.uint32(/* id 20, wireType 2 =*/162).fork()).ldelim(); if (message.features != null && Object.hasOwnProperty.call(message, "features")) $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 21, wireType 2 =*/170).fork()).ldelim(); + if (message.featureSupport != null && Object.hasOwnProperty.call(message, "featureSupport")) + $root.google.protobuf.FieldOptions.FeatureSupport.encode(message.featureSupport, writer.uint32(/* id 22, wireType 2 =*/178).fork()).ldelim(); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); @@ -42237,6 +43252,10 @@ message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); break; } + case 22: { + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.decode(reader, reader.uint32()); + break; + } case 999: { if (!(message.uninterpretedOption && message.uninterpretedOption.length)) message.uninterpretedOption = []; @@ -42376,6 +43395,11 @@ if (error) return "features." + error; } + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) { + var error = $root.google.protobuf.FieldOptions.FeatureSupport.verify(message.featureSupport); + if (error) + return "featureSupport." + error; + } if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { if (!Array.isArray(message.uninterpretedOption)) return "uninterpretedOption: array expected"; @@ -42569,6 +43593,11 @@ throw TypeError(".google.protobuf.FieldOptions.features: object expected"); message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); } + if (object.featureSupport != null) { + if (typeof object.featureSupport !== "object") + throw TypeError(".google.protobuf.FieldOptions.featureSupport: object expected"); + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.fromObject(object.featureSupport); + } if (object.uninterpretedOption) { if (!Array.isArray(object.uninterpretedOption)) throw TypeError(".google.protobuf.FieldOptions.uninterpretedOption: array expected"); @@ -42671,6 +43700,7 @@ object.debugRedact = false; object.retention = options.enums === String ? "RETENTION_UNKNOWN" : 0; object.features = null; + object.featureSupport = null; object[".google.api.resourceReference"] = null; object[".google.api.fieldInfo"] = null; } @@ -42704,6 +43734,8 @@ } if (message.features != null && message.hasOwnProperty("features")) object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) + object.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.toObject(message.featureSupport, options); if (message.uninterpretedOption && message.uninterpretedOption.length) { object.uninterpretedOption = []; for (var j = 0; j < message.uninterpretedOption.length; ++j) @@ -42978,6 +44010,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -43019,103 +44052,589 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; break; case "EDITION_PROTO3": case 999: - message.edition = 999; + message.edition = 999; + break; + case "EDITION_2023": + case 1000: + message.edition = 1000; + break; + case "EDITION_2024": + case 1001: + message.edition = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.edition = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.edition = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.edition = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.edition = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.edition = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.edition = 2147483647; + break; + } + if (object.value != null) + message.value = String(object.value); + return message; + }; + + /** + * Creates a plain object from an EditionDefault message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {google.protobuf.FieldOptions.EditionDefault} message EditionDefault + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EditionDefault.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.value = ""; + object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + } + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + if (message.edition != null && message.hasOwnProperty("edition")) + object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + return object; + }; + + /** + * Converts this EditionDefault to JSON. + * @function toJSON + * @memberof google.protobuf.FieldOptions.EditionDefault + * @instance + * @returns {Object.} JSON object + */ + EditionDefault.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for EditionDefault + * @function getTypeUrl + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + EditionDefault.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FieldOptions.EditionDefault"; + }; + + return EditionDefault; + })(); + + FieldOptions.FeatureSupport = (function() { + + /** + * Properties of a FeatureSupport. + * @memberof google.protobuf.FieldOptions + * @interface IFeatureSupport + * @property {google.protobuf.Edition|null} [editionIntroduced] FeatureSupport editionIntroduced + * @property {google.protobuf.Edition|null} [editionDeprecated] FeatureSupport editionDeprecated + * @property {string|null} [deprecationWarning] FeatureSupport deprecationWarning + * @property {google.protobuf.Edition|null} [editionRemoved] FeatureSupport editionRemoved + */ + + /** + * Constructs a new FeatureSupport. + * @memberof google.protobuf.FieldOptions + * @classdesc Represents a FeatureSupport. + * @implements IFeatureSupport + * @constructor + * @param {google.protobuf.FieldOptions.IFeatureSupport=} [properties] Properties to set + */ + function FeatureSupport(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]]; + } + + /** + * FeatureSupport editionIntroduced. + * @member {google.protobuf.Edition} editionIntroduced + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionIntroduced = 0; + + /** + * FeatureSupport editionDeprecated. + * @member {google.protobuf.Edition} editionDeprecated + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionDeprecated = 0; + + /** + * FeatureSupport deprecationWarning. + * @member {string} deprecationWarning + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.deprecationWarning = ""; + + /** + * FeatureSupport editionRemoved. + * @member {google.protobuf.Edition} editionRemoved + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionRemoved = 0; + + /** + * Creates a new FeatureSupport instance using the specified properties. + * @function create + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport=} [properties] Properties to set + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport instance + */ + FeatureSupport.create = function create(properties) { + return new FeatureSupport(properties); + }; + + /** + * Encodes the specified FeatureSupport message. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport} message FeatureSupport message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSupport.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.editionIntroduced != null && Object.hasOwnProperty.call(message, "editionIntroduced")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.editionIntroduced); + if (message.editionDeprecated != null && Object.hasOwnProperty.call(message, "editionDeprecated")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.editionDeprecated); + if (message.deprecationWarning != null && Object.hasOwnProperty.call(message, "deprecationWarning")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.deprecationWarning); + if (message.editionRemoved != null && Object.hasOwnProperty.call(message, "editionRemoved")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.editionRemoved); + return writer; + }; + + /** + * Encodes the specified FeatureSupport message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport} message FeatureSupport message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSupport.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSupport.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FieldOptions.FeatureSupport(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.editionIntroduced = reader.int32(); + break; + } + case 2: { + message.editionDeprecated = reader.int32(); + break; + } + case 3: { + message.deprecationWarning = reader.string(); + break; + } + case 4: { + message.editionRemoved = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSupport.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FeatureSupport message. + * @function verify + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FeatureSupport.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.editionIntroduced != null && message.hasOwnProperty("editionIntroduced")) + switch (message.editionIntroduced) { + default: + return "editionIntroduced: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + if (message.editionDeprecated != null && message.hasOwnProperty("editionDeprecated")) + switch (message.editionDeprecated) { + default: + return "editionDeprecated: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + if (message.deprecationWarning != null && message.hasOwnProperty("deprecationWarning")) + if (!$util.isString(message.deprecationWarning)) + return "deprecationWarning: string expected"; + if (message.editionRemoved != null && message.hasOwnProperty("editionRemoved")) + switch (message.editionRemoved) { + default: + return "editionRemoved: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + return null; + }; + + /** + * Creates a FeatureSupport message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + */ + FeatureSupport.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FieldOptions.FeatureSupport) + return object; + var message = new $root.google.protobuf.FieldOptions.FeatureSupport(); + switch (object.editionIntroduced) { + default: + if (typeof object.editionIntroduced === "number") { + message.editionIntroduced = object.editionIntroduced; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionIntroduced = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionIntroduced = 900; + break; + case "EDITION_PROTO2": + case 998: + message.editionIntroduced = 998; + break; + case "EDITION_PROTO3": + case 999: + message.editionIntroduced = 999; + break; + case "EDITION_2023": + case 1000: + message.editionIntroduced = 1000; + break; + case "EDITION_2024": + case 1001: + message.editionIntroduced = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.editionIntroduced = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.editionIntroduced = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.editionIntroduced = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.editionIntroduced = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.editionIntroduced = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.editionIntroduced = 2147483647; + break; + } + switch (object.editionDeprecated) { + default: + if (typeof object.editionDeprecated === "number") { + message.editionDeprecated = object.editionDeprecated; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionDeprecated = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionDeprecated = 900; + break; + case "EDITION_PROTO2": + case 998: + message.editionDeprecated = 998; + break; + case "EDITION_PROTO3": + case 999: + message.editionDeprecated = 999; + break; + case "EDITION_2023": + case 1000: + message.editionDeprecated = 1000; + break; + case "EDITION_2024": + case 1001: + message.editionDeprecated = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.editionDeprecated = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.editionDeprecated = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.editionDeprecated = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.editionDeprecated = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.editionDeprecated = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.editionDeprecated = 2147483647; + break; + } + if (object.deprecationWarning != null) + message.deprecationWarning = String(object.deprecationWarning); + switch (object.editionRemoved) { + default: + if (typeof object.editionRemoved === "number") { + message.editionRemoved = object.editionRemoved; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionRemoved = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionRemoved = 900; + break; + case "EDITION_PROTO2": + case 998: + message.editionRemoved = 998; + break; + case "EDITION_PROTO3": + case 999: + message.editionRemoved = 999; break; case "EDITION_2023": case 1000: - message.edition = 1000; + message.editionRemoved = 1000; break; case "EDITION_2024": case 1001: - message.edition = 1001; + message.editionRemoved = 1001; break; case "EDITION_1_TEST_ONLY": case 1: - message.edition = 1; + message.editionRemoved = 1; break; case "EDITION_2_TEST_ONLY": case 2: - message.edition = 2; + message.editionRemoved = 2; break; case "EDITION_99997_TEST_ONLY": case 99997: - message.edition = 99997; + message.editionRemoved = 99997; break; case "EDITION_99998_TEST_ONLY": case 99998: - message.edition = 99998; + message.editionRemoved = 99998; break; case "EDITION_99999_TEST_ONLY": case 99999: - message.edition = 99999; + message.editionRemoved = 99999; break; case "EDITION_MAX": case 2147483647: - message.edition = 2147483647; + message.editionRemoved = 2147483647; break; } - if (object.value != null) - message.value = String(object.value); return message; }; /** - * Creates a plain object from an EditionDefault message. Also converts values to other types if specified. + * Creates a plain object from a FeatureSupport message. Also converts values to other types if specified. * @function toObject - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @static - * @param {google.protobuf.FieldOptions.EditionDefault} message EditionDefault + * @param {google.protobuf.FieldOptions.FeatureSupport} message FeatureSupport * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - EditionDefault.toObject = function toObject(message, options) { + FeatureSupport.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { - object.value = ""; - object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; - } - if (message.value != null && message.hasOwnProperty("value")) - object.value = message.value; - if (message.edition != null && message.hasOwnProperty("edition")) - object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + object.editionIntroduced = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.editionDeprecated = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.deprecationWarning = ""; + object.editionRemoved = options.enums === String ? "EDITION_UNKNOWN" : 0; + } + if (message.editionIntroduced != null && message.hasOwnProperty("editionIntroduced")) + object.editionIntroduced = options.enums === String ? $root.google.protobuf.Edition[message.editionIntroduced] === undefined ? message.editionIntroduced : $root.google.protobuf.Edition[message.editionIntroduced] : message.editionIntroduced; + if (message.editionDeprecated != null && message.hasOwnProperty("editionDeprecated")) + object.editionDeprecated = options.enums === String ? $root.google.protobuf.Edition[message.editionDeprecated] === undefined ? message.editionDeprecated : $root.google.protobuf.Edition[message.editionDeprecated] : message.editionDeprecated; + if (message.deprecationWarning != null && message.hasOwnProperty("deprecationWarning")) + object.deprecationWarning = message.deprecationWarning; + if (message.editionRemoved != null && message.hasOwnProperty("editionRemoved")) + object.editionRemoved = options.enums === String ? $root.google.protobuf.Edition[message.editionRemoved] === undefined ? message.editionRemoved : $root.google.protobuf.Edition[message.editionRemoved] : message.editionRemoved; return object; }; /** - * Converts this EditionDefault to JSON. + * Converts this FeatureSupport to JSON. * @function toJSON - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @instance * @returns {Object.} JSON object */ - EditionDefault.prototype.toJSON = function toJSON() { + FeatureSupport.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for EditionDefault + * Gets the default type url for FeatureSupport * @function getTypeUrl - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - EditionDefault.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + FeatureSupport.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.protobuf.FieldOptions.EditionDefault"; + return typeUrlPrefix + "/google.protobuf.FieldOptions.FeatureSupport"; }; - return EditionDefault; + return FeatureSupport; })(); return FieldOptions; @@ -43710,6 +45229,7 @@ * @property {boolean|null} [deprecated] EnumValueOptions deprecated * @property {google.protobuf.IFeatureSet|null} [features] EnumValueOptions features * @property {boolean|null} [debugRedact] EnumValueOptions debugRedact + * @property {google.protobuf.FieldOptions.IFeatureSupport|null} [featureSupport] EnumValueOptions featureSupport * @property {Array.|null} [uninterpretedOption] EnumValueOptions uninterpretedOption */ @@ -43753,6 +45273,14 @@ */ EnumValueOptions.prototype.debugRedact = false; + /** + * EnumValueOptions featureSupport. + * @member {google.protobuf.FieldOptions.IFeatureSupport|null|undefined} featureSupport + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.featureSupport = null; + /** * EnumValueOptions uninterpretedOption. * @member {Array.} uninterpretedOption @@ -43791,6 +45319,8 @@ $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.debugRedact != null && Object.hasOwnProperty.call(message, "debugRedact")) writer.uint32(/* id 3, wireType 0 =*/24).bool(message.debugRedact); + if (message.featureSupport != null && Object.hasOwnProperty.call(message, "featureSupport")) + $root.google.protobuf.FieldOptions.FeatureSupport.encode(message.featureSupport, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); @@ -43842,6 +45372,10 @@ message.debugRedact = reader.bool(); break; } + case 4: { + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.decode(reader, reader.uint32()); + break; + } case 999: { if (!(message.uninterpretedOption && message.uninterpretedOption.length)) message.uninterpretedOption = []; @@ -43894,6 +45428,11 @@ if (message.debugRedact != null && message.hasOwnProperty("debugRedact")) if (typeof message.debugRedact !== "boolean") return "debugRedact: boolean expected"; + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) { + var error = $root.google.protobuf.FieldOptions.FeatureSupport.verify(message.featureSupport); + if (error) + return "featureSupport." + error; + } if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { if (!Array.isArray(message.uninterpretedOption)) return "uninterpretedOption: array expected"; @@ -43927,6 +45466,11 @@ } if (object.debugRedact != null) message.debugRedact = Boolean(object.debugRedact); + if (object.featureSupport != null) { + if (typeof object.featureSupport !== "object") + throw TypeError(".google.protobuf.EnumValueOptions.featureSupport: object expected"); + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.fromObject(object.featureSupport); + } if (object.uninterpretedOption) { if (!Array.isArray(object.uninterpretedOption)) throw TypeError(".google.protobuf.EnumValueOptions.uninterpretedOption: array expected"); @@ -43959,6 +45503,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -43966,6 +45511,8 @@ object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); if (message.debugRedact != null && message.hasOwnProperty("debugRedact")) object.debugRedact = message.debugRedact; + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) + object.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.toObject(message.featureSupport, options); if (message.uninterpretedOption && message.uninterpretedOption.length) { object.uninterpretedOption = []; for (var j = 0; j < message.uninterpretedOption.length; ++j) @@ -45405,6 +46952,8 @@ * @property {google.protobuf.FeatureSet.Utf8Validation|null} [utf8Validation] FeatureSet utf8Validation * @property {google.protobuf.FeatureSet.MessageEncoding|null} [messageEncoding] FeatureSet messageEncoding * @property {google.protobuf.FeatureSet.JsonFormat|null} [jsonFormat] FeatureSet jsonFormat + * @property {google.protobuf.FeatureSet.EnforceNamingStyle|null} [enforceNamingStyle] FeatureSet enforceNamingStyle + * @property {google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|null} [defaultSymbolVisibility] FeatureSet defaultSymbolVisibility */ /** @@ -45470,6 +47019,22 @@ */ FeatureSet.prototype.jsonFormat = 0; + /** + * FeatureSet enforceNamingStyle. + * @member {google.protobuf.FeatureSet.EnforceNamingStyle} enforceNamingStyle + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.enforceNamingStyle = 0; + + /** + * FeatureSet defaultSymbolVisibility. + * @member {google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility} defaultSymbolVisibility + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.defaultSymbolVisibility = 0; + /** * Creates a new FeatureSet instance using the specified properties. * @function create @@ -45506,6 +47071,10 @@ writer.uint32(/* id 5, wireType 0 =*/40).int32(message.messageEncoding); if (message.jsonFormat != null && Object.hasOwnProperty.call(message, "jsonFormat")) writer.uint32(/* id 6, wireType 0 =*/48).int32(message.jsonFormat); + if (message.enforceNamingStyle != null && Object.hasOwnProperty.call(message, "enforceNamingStyle")) + writer.uint32(/* id 7, wireType 0 =*/56).int32(message.enforceNamingStyle); + if (message.defaultSymbolVisibility != null && Object.hasOwnProperty.call(message, "defaultSymbolVisibility")) + writer.uint32(/* id 8, wireType 0 =*/64).int32(message.defaultSymbolVisibility); return writer; }; @@ -45566,6 +47135,14 @@ message.jsonFormat = reader.int32(); break; } + case 7: { + message.enforceNamingStyle = reader.int32(); + break; + } + case 8: { + message.defaultSymbolVisibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -45656,6 +47233,26 @@ case 2: break; } + if (message.enforceNamingStyle != null && message.hasOwnProperty("enforceNamingStyle")) + switch (message.enforceNamingStyle) { + default: + return "enforceNamingStyle: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.defaultSymbolVisibility != null && message.hasOwnProperty("defaultSymbolVisibility")) + switch (message.defaultSymbolVisibility) { + default: + return "defaultSymbolVisibility: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } return null; }; @@ -45795,6 +47392,54 @@ message.jsonFormat = 2; break; } + switch (object.enforceNamingStyle) { + default: + if (typeof object.enforceNamingStyle === "number") { + message.enforceNamingStyle = object.enforceNamingStyle; + break; + } + break; + case "ENFORCE_NAMING_STYLE_UNKNOWN": + case 0: + message.enforceNamingStyle = 0; + break; + case "STYLE2024": + case 1: + message.enforceNamingStyle = 1; + break; + case "STYLE_LEGACY": + case 2: + message.enforceNamingStyle = 2; + break; + } + switch (object.defaultSymbolVisibility) { + default: + if (typeof object.defaultSymbolVisibility === "number") { + message.defaultSymbolVisibility = object.defaultSymbolVisibility; + break; + } + break; + case "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN": + case 0: + message.defaultSymbolVisibility = 0; + break; + case "EXPORT_ALL": + case 1: + message.defaultSymbolVisibility = 1; + break; + case "EXPORT_TOP_LEVEL": + case 2: + message.defaultSymbolVisibility = 2; + break; + case "LOCAL_ALL": + case 3: + message.defaultSymbolVisibility = 3; + break; + case "STRICT": + case 4: + message.defaultSymbolVisibility = 4; + break; + } return message; }; @@ -45818,6 +47463,8 @@ object.utf8Validation = options.enums === String ? "UTF8_VALIDATION_UNKNOWN" : 0; object.messageEncoding = options.enums === String ? "MESSAGE_ENCODING_UNKNOWN" : 0; object.jsonFormat = options.enums === String ? "JSON_FORMAT_UNKNOWN" : 0; + object.enforceNamingStyle = options.enums === String ? "ENFORCE_NAMING_STYLE_UNKNOWN" : 0; + object.defaultSymbolVisibility = options.enums === String ? "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN" : 0; } if (message.fieldPresence != null && message.hasOwnProperty("fieldPresence")) object.fieldPresence = options.enums === String ? $root.google.protobuf.FeatureSet.FieldPresence[message.fieldPresence] === undefined ? message.fieldPresence : $root.google.protobuf.FeatureSet.FieldPresence[message.fieldPresence] : message.fieldPresence; @@ -45831,6 +47478,10 @@ object.messageEncoding = options.enums === String ? $root.google.protobuf.FeatureSet.MessageEncoding[message.messageEncoding] === undefined ? message.messageEncoding : $root.google.protobuf.FeatureSet.MessageEncoding[message.messageEncoding] : message.messageEncoding; if (message.jsonFormat != null && message.hasOwnProperty("jsonFormat")) object.jsonFormat = options.enums === String ? $root.google.protobuf.FeatureSet.JsonFormat[message.jsonFormat] === undefined ? message.jsonFormat : $root.google.protobuf.FeatureSet.JsonFormat[message.jsonFormat] : message.jsonFormat; + if (message.enforceNamingStyle != null && message.hasOwnProperty("enforceNamingStyle")) + object.enforceNamingStyle = options.enums === String ? $root.google.protobuf.FeatureSet.EnforceNamingStyle[message.enforceNamingStyle] === undefined ? message.enforceNamingStyle : $root.google.protobuf.FeatureSet.EnforceNamingStyle[message.enforceNamingStyle] : message.enforceNamingStyle; + if (message.defaultSymbolVisibility != null && message.hasOwnProperty("defaultSymbolVisibility")) + object.defaultSymbolVisibility = options.enums === String ? $root.google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility[message.defaultSymbolVisibility] === undefined ? message.defaultSymbolVisibility : $root.google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility[message.defaultSymbolVisibility] : message.defaultSymbolVisibility; return object; }; @@ -45958,6 +47609,219 @@ return values; })(); + /** + * EnforceNamingStyle enum. + * @name google.protobuf.FeatureSet.EnforceNamingStyle + * @enum {number} + * @property {number} ENFORCE_NAMING_STYLE_UNKNOWN=0 ENFORCE_NAMING_STYLE_UNKNOWN value + * @property {number} STYLE2024=1 STYLE2024 value + * @property {number} STYLE_LEGACY=2 STYLE_LEGACY value + */ + FeatureSet.EnforceNamingStyle = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "ENFORCE_NAMING_STYLE_UNKNOWN"] = 0; + values[valuesById[1] = "STYLE2024"] = 1; + values[valuesById[2] = "STYLE_LEGACY"] = 2; + return values; + })(); + + FeatureSet.VisibilityFeature = (function() { + + /** + * Properties of a VisibilityFeature. + * @memberof google.protobuf.FeatureSet + * @interface IVisibilityFeature + */ + + /** + * Constructs a new VisibilityFeature. + * @memberof google.protobuf.FeatureSet + * @classdesc Represents a VisibilityFeature. + * @implements IVisibilityFeature + * @constructor + * @param {google.protobuf.FeatureSet.IVisibilityFeature=} [properties] Properties to set + */ + function VisibilityFeature(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]]; + } + + /** + * Creates a new VisibilityFeature instance using the specified properties. + * @function create + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature=} [properties] Properties to set + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature instance + */ + VisibilityFeature.create = function create(properties) { + return new VisibilityFeature(properties); + }; + + /** + * Encodes the specified VisibilityFeature message. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature} message VisibilityFeature message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VisibilityFeature.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified VisibilityFeature message, length delimited. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature} message VisibilityFeature message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VisibilityFeature.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VisibilityFeature.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FeatureSet.VisibilityFeature(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VisibilityFeature.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a VisibilityFeature message. + * @function verify + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + VisibilityFeature.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a VisibilityFeature message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + */ + VisibilityFeature.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FeatureSet.VisibilityFeature) + return object; + return new $root.google.protobuf.FeatureSet.VisibilityFeature(); + }; + + /** + * Creates a plain object from a VisibilityFeature message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.VisibilityFeature} message VisibilityFeature + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + VisibilityFeature.toObject = function toObject() { + return {}; + }; + + /** + * Converts this VisibilityFeature to JSON. + * @function toJSON + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @instance + * @returns {Object.} JSON object + */ + VisibilityFeature.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for VisibilityFeature + * @function getTypeUrl + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + VisibilityFeature.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FeatureSet.VisibilityFeature"; + }; + + /** + * DefaultSymbolVisibility enum. + * @name google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility + * @enum {number} + * @property {number} DEFAULT_SYMBOL_VISIBILITY_UNKNOWN=0 DEFAULT_SYMBOL_VISIBILITY_UNKNOWN value + * @property {number} EXPORT_ALL=1 EXPORT_ALL value + * @property {number} EXPORT_TOP_LEVEL=2 EXPORT_TOP_LEVEL value + * @property {number} LOCAL_ALL=3 LOCAL_ALL value + * @property {number} STRICT=4 STRICT value + */ + VisibilityFeature.DefaultSymbolVisibility = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN"] = 0; + values[valuesById[1] = "EXPORT_ALL"] = 1; + values[valuesById[2] = "EXPORT_TOP_LEVEL"] = 2; + values[valuesById[3] = "LOCAL_ALL"] = 3; + values[valuesById[4] = "STRICT"] = 4; + return values; + })(); + + return VisibilityFeature; + })(); + return FeatureSet; })(); @@ -46142,6 +48006,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -46159,6 +48024,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -46207,6 +48073,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -46259,6 +48129,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -46367,7 +48241,8 @@ * @memberof google.protobuf.FeatureSetDefaults * @interface IFeatureSetEditionDefault * @property {google.protobuf.Edition|null} [edition] FeatureSetEditionDefault edition - * @property {google.protobuf.IFeatureSet|null} [features] FeatureSetEditionDefault features + * @property {google.protobuf.IFeatureSet|null} [overridableFeatures] FeatureSetEditionDefault overridableFeatures + * @property {google.protobuf.IFeatureSet|null} [fixedFeatures] FeatureSetEditionDefault fixedFeatures */ /** @@ -46394,12 +48269,20 @@ FeatureSetEditionDefault.prototype.edition = 0; /** - * FeatureSetEditionDefault features. - * @member {google.protobuf.IFeatureSet|null|undefined} features + * FeatureSetEditionDefault overridableFeatures. + * @member {google.protobuf.IFeatureSet|null|undefined} overridableFeatures + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @instance + */ + FeatureSetEditionDefault.prototype.overridableFeatures = null; + + /** + * FeatureSetEditionDefault fixedFeatures. + * @member {google.protobuf.IFeatureSet|null|undefined} fixedFeatures * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault * @instance */ - FeatureSetEditionDefault.prototype.features = null; + FeatureSetEditionDefault.prototype.fixedFeatures = null; /** * Creates a new FeatureSetEditionDefault instance using the specified properties. @@ -46425,10 +48308,12 @@ FeatureSetEditionDefault.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.features != null && Object.hasOwnProperty.call(message, "features")) - $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) writer.uint32(/* id 3, wireType 0 =*/24).int32(message.edition); + if (message.overridableFeatures != null && Object.hasOwnProperty.call(message, "overridableFeatures")) + $root.google.protobuf.FeatureSet.encode(message.overridableFeatures, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.fixedFeatures != null && Object.hasOwnProperty.call(message, "fixedFeatures")) + $root.google.protobuf.FeatureSet.encode(message.fixedFeatures, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); return writer; }; @@ -46469,8 +48354,12 @@ message.edition = reader.int32(); break; } - case 2: { - message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + case 4: { + message.overridableFeatures = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + break; + } + case 5: { + message.fixedFeatures = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); break; } default: @@ -46513,6 +48402,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -46525,10 +48415,15 @@ case 2147483647: break; } - if (message.features != null && message.hasOwnProperty("features")) { - var error = $root.google.protobuf.FeatureSet.verify(message.features); + if (message.overridableFeatures != null && message.hasOwnProperty("overridableFeatures")) { + var error = $root.google.protobuf.FeatureSet.verify(message.overridableFeatures); + if (error) + return "overridableFeatures." + error; + } + if (message.fixedFeatures != null && message.hasOwnProperty("fixedFeatures")) { + var error = $root.google.protobuf.FeatureSet.verify(message.fixedFeatures); if (error) - return "features." + error; + return "fixedFeatures." + error; } return null; }; @@ -46556,6 +48451,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -46597,10 +48496,15 @@ message.edition = 2147483647; break; } - if (object.features != null) { - if (typeof object.features !== "object") - throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.features: object expected"); - message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); + if (object.overridableFeatures != null) { + if (typeof object.overridableFeatures !== "object") + throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.overridableFeatures: object expected"); + message.overridableFeatures = $root.google.protobuf.FeatureSet.fromObject(object.overridableFeatures); + } + if (object.fixedFeatures != null) { + if (typeof object.fixedFeatures !== "object") + throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.fixedFeatures: object expected"); + message.fixedFeatures = $root.google.protobuf.FeatureSet.fromObject(object.fixedFeatures); } return message; }; @@ -46619,13 +48523,16 @@ options = {}; var object = {}; if (options.defaults) { - object.features = null; object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.overridableFeatures = null; + object.fixedFeatures = null; } - if (message.features != null && message.hasOwnProperty("features")) - object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); if (message.edition != null && message.hasOwnProperty("edition")) object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.overridableFeatures != null && message.hasOwnProperty("overridableFeatures")) + object.overridableFeatures = $root.google.protobuf.FeatureSet.toObject(message.overridableFeatures, options); + if (message.fixedFeatures != null && message.hasOwnProperty("fixedFeatures")) + object.fixedFeatures = $root.google.protobuf.FeatureSet.toObject(message.fixedFeatures, options); return object; }; @@ -47840,6 +49747,22 @@ return GeneratedCodeInfo; })(); + /** + * SymbolVisibility enum. + * @name google.protobuf.SymbolVisibility + * @enum {number} + * @property {number} VISIBILITY_UNSET=0 VISIBILITY_UNSET value + * @property {number} VISIBILITY_LOCAL=1 VISIBILITY_LOCAL value + * @property {number} VISIBILITY_EXPORT=2 VISIBILITY_EXPORT value + */ + protobuf.SymbolVisibility = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "VISIBILITY_UNSET"] = 0; + values[valuesById[1] = "VISIBILITY_LOCAL"] = 1; + values[valuesById[2] = "VISIBILITY_EXPORT"] = 2; + return values; + })(); + protobuf.Duration = (function() { /** diff --git a/packages/google-cloud-modelarmor/protos/protos.json b/packages/google-cloud-modelarmor/protos/protos.json index a00caed237a5..19d5a16d6da9 100644 --- a/packages/google-cloud-modelarmor/protos/protos.json +++ b/packages/google-cloud-modelarmor/protos/protos.json @@ -3200,8 +3200,7 @@ "java_multiple_files": true, "java_outer_classname": "ResourceProto", "java_package": "com.google.api", - "objc_class_prefix": "GAPI", - "cc_enable_arenas": true + "objc_class_prefix": "GAPI" }, "nested": { "http": { @@ -3325,6 +3324,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -3465,6 +3468,28 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "experimentalFeatures": { + "type": "ExperimentalFeatures", + "id": 2 + } + }, + "nested": { + "ExperimentalFeatures": { + "fields": { + "restAsyncIoEnabled": { + "type": "bool", + "id": 1 + }, + "protobufPythonicTypesEnabled": { + "type": "bool", + "id": 2 + }, + "unversionedPackageDisabled": { + "type": "bool", + "id": 3 + } + } } } }, @@ -3522,6 +3547,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -3583,6 +3613,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -3627,6 +3670,11 @@ "format": { "type": "Format", "id": 1 + }, + "referencedTypes": { + "rule": "repeated", + "type": "TypeReference", + "id": 2 } }, "nested": { @@ -3641,6 +3689,14 @@ } } }, + "TypeReference": { + "fields": { + "typeName": { + "type": "string", + "id": 1 + } + } + }, "resourceReference": { "type": "google.api.ResourceReference", "id": 1055, @@ -3739,12 +3795,19 @@ "type": "FileDescriptorProto", "id": 1 } - } + }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ] }, "Edition": { "edition": "proto2", "values": { "EDITION_UNKNOWN": 0, + "EDITION_LEGACY": 900, "EDITION_PROTO2": 998, "EDITION_PROTO3": 999, "EDITION_2023": 1000, @@ -3783,6 +3846,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -3871,6 +3939,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -4096,6 +4168,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -4146,7 +4222,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -4310,6 +4393,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -4445,7 +4529,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -4473,6 +4558,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -4542,6 +4631,26 @@ "id": 2 } } + }, + "FeatureSupport": { + "fields": { + "editionIntroduced": { + "type": "Edition", + "id": 1 + }, + "editionDeprecated": { + "type": "Edition", + "id": 2 + }, + "deprecationWarning": { + "type": "string", + "id": 3 + }, + "editionRemoved": { + "type": "Edition", + "id": 4 + } + } } } }, @@ -4630,6 +4739,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -4772,6 +4885,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -4782,6 +4896,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -4792,6 +4907,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -4802,6 +4918,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -4812,7 +4929,8 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", - "edition_defaults.edition": "EDITION_PROTO2", + "feature_support.edition_introduced": "EDITION_2023", + "edition_defaults.edition": "EDITION_LEGACY", "edition_defaults.value": "LENGTH_PREFIXED" } }, @@ -4822,27 +4940,38 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "ALLOW" } + }, + "enforceNamingStyle": { + "type": "EnforceNamingStyle", + "id": 7, + "options": { + "retention": "RETENTION_SOURCE", + "targets": "TARGET_TYPE_METHOD", + "feature_support.edition_introduced": "EDITION_2024", + "edition_defaults.edition": "EDITION_2024", + "edition_defaults.value": "STYLE2024" + } + }, + "defaultSymbolVisibility": { + "type": "VisibilityFeature.DefaultSymbolVisibility", + "id": 8, + "options": { + "retention": "RETENTION_SOURCE", + "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2024", + "edition_defaults.edition": "EDITION_2024", + "edition_defaults.value": "EXPORT_TOP_LEVEL" + } } }, "extensions": [ [ 1000, - 1000 - ], - [ - 1001, - 1001 - ], - [ - 1002, - 1002 - ], - [ - 9990, - 9990 + 9994 ], [ 9995, @@ -4887,7 +5016,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -4902,6 +5037,33 @@ "ALLOW": 1, "LEGACY_BEST_EFFORT": 2 } + }, + "EnforceNamingStyle": { + "values": { + "ENFORCE_NAMING_STYLE_UNKNOWN": 0, + "STYLE2024": 1, + "STYLE_LEGACY": 2 + } + }, + "VisibilityFeature": { + "fields": {}, + "reserved": [ + [ + 1, + 536870911 + ] + ], + "nested": { + "DefaultSymbolVisibility": { + "values": { + "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN": 0, + "EXPORT_ALL": 1, + "EXPORT_TOP_LEVEL": 2, + "LOCAL_ALL": 3, + "STRICT": 4 + } + } + } } } }, @@ -4929,11 +5091,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -4946,6 +5123,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -5031,6 +5214,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Duration": { "fields": { "seconds": { diff --git a/packages/google-cloud-modelarmor/samples/generated/v1/snippet_metadata_google.cloud.modelarmor.v1.json b/packages/google-cloud-modelarmor/samples/generated/v1/snippet_metadata_google.cloud.modelarmor.v1.json index f420f827ea4a..a4aa9add53fc 100644 --- a/packages/google-cloud-modelarmor/samples/generated/v1/snippet_metadata_google.cloud.modelarmor.v1.json +++ b/packages/google-cloud-modelarmor/samples/generated/v1/snippet_metadata_google.cloud.modelarmor.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-modelarmor", - "version": "0.4.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-modelarmor/samples/generated/v1beta/snippet_metadata_google.cloud.modelarmor.v1beta.json b/packages/google-cloud-modelarmor/samples/generated/v1beta/snippet_metadata_google.cloud.modelarmor.v1beta.json index 6e6478a1e274..ebea3de18755 100644 --- a/packages/google-cloud-modelarmor/samples/generated/v1beta/snippet_metadata_google.cloud.modelarmor.v1beta.json +++ b/packages/google-cloud-modelarmor/samples/generated/v1beta/snippet_metadata_google.cloud.modelarmor.v1beta.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-modelarmor", - "version": "0.4.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-modelarmor/src/v1/index.ts b/packages/google-cloud-modelarmor/src/v1/index.ts index d9f2b339caec..367fb8b87540 100644 --- a/packages/google-cloud-modelarmor/src/v1/index.ts +++ b/packages/google-cloud-modelarmor/src/v1/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {ModelArmorClient} from './model_armor_client'; +export { ModelArmorClient } from './model_armor_client'; diff --git a/packages/google-cloud-modelarmor/src/v1/model_armor_client.ts b/packages/google-cloud-modelarmor/src/v1/model_armor_client.ts index 299e30674b38..cbee05f98849 100644 --- a/packages/google-cloud-modelarmor/src/v1/model_armor_client.ts +++ b/packages/google-cloud-modelarmor/src/v1/model_armor_client.ts @@ -18,11 +18,20 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + PaginationCallback, + GaxCall, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -44,7 +53,7 @@ export class ModelArmorClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('modelarmor'); @@ -57,10 +66,10 @@ export class ModelArmorClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - modelArmorStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + modelArmorStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of ModelArmorClient. @@ -101,21 +110,42 @@ export class ModelArmorClient { * const client = new ModelArmorClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof ModelArmorClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'modelarmor.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -140,7 +170,7 @@ export class ModelArmorClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -154,15 +184,11 @@ export class ModelArmorClient { } this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -184,22 +210,23 @@ export class ModelArmorClient { // Create useful helper objects for these. this.pathTemplates = { folderLocationFloorSettingPathTemplate: new this._gaxModule.PathTemplate( - 'folders/{folder}/locations/{location}/floorSetting' + 'folders/{folder}/locations/{location}/floorSetting', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - organizationLocationFloorSettingPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/locations/{location}/floorSetting' + 'projects/{project}/locations/{location}', ), + organizationLocationFloorSettingPathTemplate: + new this._gaxModule.PathTemplate( + 'organizations/{organization}/locations/{location}/floorSetting', + ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), projectLocationFloorSettingPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/floorSetting' + 'projects/{project}/locations/{location}/floorSetting', ), templatePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/templates/{template}' + 'projects/{project}/locations/{location}/templates/{template}', ), }; @@ -207,14 +234,20 @@ export class ModelArmorClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listTemplates: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'templates') + listTemplates: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'templates', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.modelarmor.v1.ModelArmor', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.modelarmor.v1.ModelArmor', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -245,37 +278,50 @@ export class ModelArmorClient { // Put together the "service stub" for // google.cloud.modelarmor.v1.ModelArmor. this.modelArmorStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.modelarmor.v1.ModelArmor') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.modelarmor.v1.ModelArmor', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.modelarmor.v1.ModelArmor, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const modelArmorStubMethods = - ['listTemplates', 'getTemplate', 'createTemplate', 'updateTemplate', 'deleteTemplate', 'getFloorSetting', 'updateFloorSetting', 'sanitizeUserPrompt', 'sanitizeModelResponse']; + const modelArmorStubMethods = [ + 'listTemplates', + 'getTemplate', + 'createTemplate', + 'updateTemplate', + 'deleteTemplate', + 'getFloorSetting', + 'updateFloorSetting', + 'sanitizeUserPrompt', + 'sanitizeModelResponse', + ]; for (const methodName of modelArmorStubMethods) { const callPromise = this.modelArmorStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); - const descriptor = - this.descriptors.page[methodName] || - undefined; + const descriptor = this.descriptors.page[methodName] || undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -290,8 +336,14 @@ export class ModelArmorClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'modelarmor.googleapis.com'; } @@ -302,8 +354,14 @@ export class ModelArmorClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'modelarmor.googleapis.com'; } @@ -334,9 +392,7 @@ export class ModelArmorClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -345,8 +401,9 @@ export class ModelArmorClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -357,918 +414,1272 @@ export class ModelArmorClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets details of a single Template. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource - * @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 {@link protos.google.cloud.modelarmor.v1.Template|Template}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/model_armor.get_template.js - * region_tag:modelarmor_v1_generated_ModelArmor_GetTemplate_async - */ + /** + * Gets details of a single Template. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource + * @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 {@link protos.google.cloud.modelarmor.v1.Template|Template}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/model_armor.get_template.js + * region_tag:modelarmor_v1_generated_ModelArmor_GetTemplate_async + */ getTemplate( - request?: protos.google.cloud.modelarmor.v1.IGetTemplateRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.modelarmor.v1.ITemplate, - protos.google.cloud.modelarmor.v1.IGetTemplateRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.modelarmor.v1.IGetTemplateRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.modelarmor.v1.ITemplate, + protos.google.cloud.modelarmor.v1.IGetTemplateRequest | undefined, + {} | undefined, + ] + >; getTemplate( - request: protos.google.cloud.modelarmor.v1.IGetTemplateRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.modelarmor.v1.ITemplate, - protos.google.cloud.modelarmor.v1.IGetTemplateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1.IGetTemplateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.modelarmor.v1.ITemplate, + protos.google.cloud.modelarmor.v1.IGetTemplateRequest | null | undefined, + {} | null | undefined + >, + ): void; getTemplate( - request: protos.google.cloud.modelarmor.v1.IGetTemplateRequest, - callback: Callback< - protos.google.cloud.modelarmor.v1.ITemplate, - protos.google.cloud.modelarmor.v1.IGetTemplateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1.IGetTemplateRequest, + callback: Callback< + protos.google.cloud.modelarmor.v1.ITemplate, + protos.google.cloud.modelarmor.v1.IGetTemplateRequest | null | undefined, + {} | null | undefined + >, + ): void; getTemplate( - request?: protos.google.cloud.modelarmor.v1.IGetTemplateRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.modelarmor.v1.ITemplate, - protos.google.cloud.modelarmor.v1.IGetTemplateRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.modelarmor.v1.IGetTemplateRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.modelarmor.v1.ITemplate, - protos.google.cloud.modelarmor.v1.IGetTemplateRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.modelarmor.v1.ITemplate, - protos.google.cloud.modelarmor.v1.IGetTemplateRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.modelarmor.v1.IGetTemplateRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.modelarmor.v1.ITemplate, + protos.google.cloud.modelarmor.v1.IGetTemplateRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.modelarmor.v1.ITemplate, + protos.google.cloud.modelarmor.v1.IGetTemplateRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getTemplate request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.modelarmor.v1.ITemplate, - protos.google.cloud.modelarmor.v1.IGetTemplateRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.modelarmor.v1.ITemplate, + | protos.google.cloud.modelarmor.v1.IGetTemplateRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getTemplate response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getTemplate(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.modelarmor.v1.ITemplate, - protos.google.cloud.modelarmor.v1.IGetTemplateRequest|undefined, - {}|undefined - ]) => { - this._log.info('getTemplate response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getTemplate(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.modelarmor.v1.ITemplate, + protos.google.cloud.modelarmor.v1.IGetTemplateRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getTemplate response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a new Template in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Value for parent. - * @param {string} request.templateId - * Required. Id of the requesting object - * If auto-generating Id server-side, remove this field and - * template_id from the method_signature of Create RPC - * @param {google.cloud.modelarmor.v1.Template} request.template - * Required. The resource being created - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server stores the - * request ID for 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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 {@link protos.google.cloud.modelarmor.v1.Template|Template}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/model_armor.create_template.js - * region_tag:modelarmor_v1_generated_ModelArmor_CreateTemplate_async - */ + /** + * Creates a new Template in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Value for parent. + * @param {string} request.templateId + * Required. Id of the requesting object + * If auto-generating Id server-side, remove this field and + * template_id from the method_signature of Create RPC + * @param {google.cloud.modelarmor.v1.Template} request.template + * Required. The resource being created + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server stores the + * request ID for 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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 {@link protos.google.cloud.modelarmor.v1.Template|Template}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/model_armor.create_template.js + * region_tag:modelarmor_v1_generated_ModelArmor_CreateTemplate_async + */ createTemplate( - request?: protos.google.cloud.modelarmor.v1.ICreateTemplateRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.modelarmor.v1.ITemplate, - protos.google.cloud.modelarmor.v1.ICreateTemplateRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.modelarmor.v1.ICreateTemplateRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.modelarmor.v1.ITemplate, + protos.google.cloud.modelarmor.v1.ICreateTemplateRequest | undefined, + {} | undefined, + ] + >; createTemplate( - request: protos.google.cloud.modelarmor.v1.ICreateTemplateRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.modelarmor.v1.ITemplate, - protos.google.cloud.modelarmor.v1.ICreateTemplateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1.ICreateTemplateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.modelarmor.v1.ITemplate, + | protos.google.cloud.modelarmor.v1.ICreateTemplateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createTemplate( - request: protos.google.cloud.modelarmor.v1.ICreateTemplateRequest, - callback: Callback< - protos.google.cloud.modelarmor.v1.ITemplate, - protos.google.cloud.modelarmor.v1.ICreateTemplateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1.ICreateTemplateRequest, + callback: Callback< + protos.google.cloud.modelarmor.v1.ITemplate, + | protos.google.cloud.modelarmor.v1.ICreateTemplateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createTemplate( - request?: protos.google.cloud.modelarmor.v1.ICreateTemplateRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.modelarmor.v1.ITemplate, - protos.google.cloud.modelarmor.v1.ICreateTemplateRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.modelarmor.v1.ICreateTemplateRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.modelarmor.v1.ITemplate, - protos.google.cloud.modelarmor.v1.ICreateTemplateRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.modelarmor.v1.ITemplate, - protos.google.cloud.modelarmor.v1.ICreateTemplateRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.modelarmor.v1.ICreateTemplateRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.modelarmor.v1.ITemplate, + | protos.google.cloud.modelarmor.v1.ICreateTemplateRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.modelarmor.v1.ITemplate, + protos.google.cloud.modelarmor.v1.ICreateTemplateRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('createTemplate request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.modelarmor.v1.ITemplate, - protos.google.cloud.modelarmor.v1.ICreateTemplateRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.modelarmor.v1.ITemplate, + | protos.google.cloud.modelarmor.v1.ICreateTemplateRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createTemplate response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createTemplate(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.modelarmor.v1.ITemplate, - protos.google.cloud.modelarmor.v1.ICreateTemplateRequest|undefined, - {}|undefined - ]) => { - this._log.info('createTemplate response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .createTemplate(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.modelarmor.v1.ITemplate, + protos.google.cloud.modelarmor.v1.ICreateTemplateRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createTemplate response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Updates the parameters of a single Template. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Field mask is used to specify the fields to be overwritten in the - * Template resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - * @param {google.cloud.modelarmor.v1.Template} request.template - * Required. The resource being updated - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server stores the - * request ID for 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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 {@link protos.google.cloud.modelarmor.v1.Template|Template}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/model_armor.update_template.js - * region_tag:modelarmor_v1_generated_ModelArmor_UpdateTemplate_async - */ + /** + * Updates the parameters of a single Template. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Field mask is used to specify the fields to be overwritten in the + * Template resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @param {google.cloud.modelarmor.v1.Template} request.template + * Required. The resource being updated + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server stores the + * request ID for 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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 {@link protos.google.cloud.modelarmor.v1.Template|Template}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/model_armor.update_template.js + * region_tag:modelarmor_v1_generated_ModelArmor_UpdateTemplate_async + */ updateTemplate( - request?: protos.google.cloud.modelarmor.v1.IUpdateTemplateRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.modelarmor.v1.ITemplate, - protos.google.cloud.modelarmor.v1.IUpdateTemplateRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.modelarmor.v1.IUpdateTemplateRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.modelarmor.v1.ITemplate, + protos.google.cloud.modelarmor.v1.IUpdateTemplateRequest | undefined, + {} | undefined, + ] + >; updateTemplate( - request: protos.google.cloud.modelarmor.v1.IUpdateTemplateRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.modelarmor.v1.ITemplate, - protos.google.cloud.modelarmor.v1.IUpdateTemplateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1.IUpdateTemplateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.modelarmor.v1.ITemplate, + | protos.google.cloud.modelarmor.v1.IUpdateTemplateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateTemplate( - request: protos.google.cloud.modelarmor.v1.IUpdateTemplateRequest, - callback: Callback< - protos.google.cloud.modelarmor.v1.ITemplate, - protos.google.cloud.modelarmor.v1.IUpdateTemplateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1.IUpdateTemplateRequest, + callback: Callback< + protos.google.cloud.modelarmor.v1.ITemplate, + | protos.google.cloud.modelarmor.v1.IUpdateTemplateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateTemplate( - request?: protos.google.cloud.modelarmor.v1.IUpdateTemplateRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.modelarmor.v1.ITemplate, - protos.google.cloud.modelarmor.v1.IUpdateTemplateRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.modelarmor.v1.IUpdateTemplateRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.modelarmor.v1.ITemplate, - protos.google.cloud.modelarmor.v1.IUpdateTemplateRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.modelarmor.v1.ITemplate, - protos.google.cloud.modelarmor.v1.IUpdateTemplateRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.modelarmor.v1.IUpdateTemplateRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.modelarmor.v1.ITemplate, + | protos.google.cloud.modelarmor.v1.IUpdateTemplateRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.modelarmor.v1.ITemplate, + protos.google.cloud.modelarmor.v1.IUpdateTemplateRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'template.name': request.template!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'template.name': request.template!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateTemplate request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.modelarmor.v1.ITemplate, - protos.google.cloud.modelarmor.v1.IUpdateTemplateRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.modelarmor.v1.ITemplate, + | protos.google.cloud.modelarmor.v1.IUpdateTemplateRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateTemplate response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateTemplate(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.modelarmor.v1.ITemplate, - protos.google.cloud.modelarmor.v1.IUpdateTemplateRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateTemplate response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .updateTemplate(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.modelarmor.v1.ITemplate, + protos.google.cloud.modelarmor.v1.IUpdateTemplateRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updateTemplate response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Deletes a single Template. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server stores the - * request ID for 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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 {@link protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/model_armor.delete_template.js - * region_tag:modelarmor_v1_generated_ModelArmor_DeleteTemplate_async - */ + /** + * Deletes a single Template. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server stores the + * request ID for 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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 {@link protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/model_armor.delete_template.js + * region_tag:modelarmor_v1_generated_ModelArmor_DeleteTemplate_async + */ deleteTemplate( - request?: protos.google.cloud.modelarmor.v1.IDeleteTemplateRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.modelarmor.v1.IDeleteTemplateRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.modelarmor.v1.IDeleteTemplateRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.modelarmor.v1.IDeleteTemplateRequest | undefined, + {} | undefined, + ] + >; deleteTemplate( - request: protos.google.cloud.modelarmor.v1.IDeleteTemplateRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.modelarmor.v1.IDeleteTemplateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1.IDeleteTemplateRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.modelarmor.v1.IDeleteTemplateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteTemplate( - request: protos.google.cloud.modelarmor.v1.IDeleteTemplateRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.modelarmor.v1.IDeleteTemplateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1.IDeleteTemplateRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.modelarmor.v1.IDeleteTemplateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteTemplate( - request?: protos.google.cloud.modelarmor.v1.IDeleteTemplateRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.modelarmor.v1.IDeleteTemplateRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.modelarmor.v1.IDeleteTemplateRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.modelarmor.v1.IDeleteTemplateRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.modelarmor.v1.IDeleteTemplateRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.modelarmor.v1.IDeleteTemplateRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.modelarmor.v1.IDeleteTemplateRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.modelarmor.v1.IDeleteTemplateRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('deleteTemplate request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.modelarmor.v1.IDeleteTemplateRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.modelarmor.v1.IDeleteTemplateRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteTemplate response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.deleteTemplate(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.modelarmor.v1.IDeleteTemplateRequest|undefined, - {}|undefined - ]) => { - this._log.info('deleteTemplate response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .deleteTemplate(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + protos.google.cloud.modelarmor.v1.IDeleteTemplateRequest | undefined, + {} | undefined, + ]) => { + this._log.info('deleteTemplate response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single floor setting of a project - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the floor setting to get, example - * projects/123/floorsetting. - * @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 {@link protos.google.cloud.modelarmor.v1.FloorSetting|FloorSetting}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/model_armor.get_floor_setting.js - * region_tag:modelarmor_v1_generated_ModelArmor_GetFloorSetting_async - */ + /** + * Gets details of a single floor setting of a project + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the floor setting to get, example + * projects/123/floorsetting. + * @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 {@link protos.google.cloud.modelarmor.v1.FloorSetting|FloorSetting}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/model_armor.get_floor_setting.js + * region_tag:modelarmor_v1_generated_ModelArmor_GetFloorSetting_async + */ getFloorSetting( - request?: protos.google.cloud.modelarmor.v1.IGetFloorSettingRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.modelarmor.v1.IFloorSetting, - protos.google.cloud.modelarmor.v1.IGetFloorSettingRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.modelarmor.v1.IGetFloorSettingRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.modelarmor.v1.IFloorSetting, + protos.google.cloud.modelarmor.v1.IGetFloorSettingRequest | undefined, + {} | undefined, + ] + >; getFloorSetting( - request: protos.google.cloud.modelarmor.v1.IGetFloorSettingRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.modelarmor.v1.IFloorSetting, - protos.google.cloud.modelarmor.v1.IGetFloorSettingRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1.IGetFloorSettingRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.modelarmor.v1.IFloorSetting, + | protos.google.cloud.modelarmor.v1.IGetFloorSettingRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getFloorSetting( - request: protos.google.cloud.modelarmor.v1.IGetFloorSettingRequest, - callback: Callback< - protos.google.cloud.modelarmor.v1.IFloorSetting, - protos.google.cloud.modelarmor.v1.IGetFloorSettingRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1.IGetFloorSettingRequest, + callback: Callback< + protos.google.cloud.modelarmor.v1.IFloorSetting, + | protos.google.cloud.modelarmor.v1.IGetFloorSettingRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getFloorSetting( - request?: protos.google.cloud.modelarmor.v1.IGetFloorSettingRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.modelarmor.v1.IFloorSetting, - protos.google.cloud.modelarmor.v1.IGetFloorSettingRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.modelarmor.v1.IGetFloorSettingRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.modelarmor.v1.IFloorSetting, - protos.google.cloud.modelarmor.v1.IGetFloorSettingRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.modelarmor.v1.IFloorSetting, - protos.google.cloud.modelarmor.v1.IGetFloorSettingRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.modelarmor.v1.IGetFloorSettingRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.modelarmor.v1.IFloorSetting, + | protos.google.cloud.modelarmor.v1.IGetFloorSettingRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.modelarmor.v1.IFloorSetting, + protos.google.cloud.modelarmor.v1.IGetFloorSettingRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getFloorSetting request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.modelarmor.v1.IFloorSetting, - protos.google.cloud.modelarmor.v1.IGetFloorSettingRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.modelarmor.v1.IFloorSetting, + | protos.google.cloud.modelarmor.v1.IGetFloorSettingRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getFloorSetting response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getFloorSetting(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.modelarmor.v1.IFloorSetting, - protos.google.cloud.modelarmor.v1.IGetFloorSettingRequest|undefined, - {}|undefined - ]) => { - this._log.info('getFloorSetting response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getFloorSetting(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.modelarmor.v1.IFloorSetting, + protos.google.cloud.modelarmor.v1.IGetFloorSettingRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getFloorSetting response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Updates the parameters of a single floor setting of a project - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.modelarmor.v1.FloorSetting} request.floorSetting - * Required. The floor setting being updated. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask is used to specify the fields to be overwritten in the - * FloorSetting resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - * @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 {@link protos.google.cloud.modelarmor.v1.FloorSetting|FloorSetting}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/model_armor.update_floor_setting.js - * region_tag:modelarmor_v1_generated_ModelArmor_UpdateFloorSetting_async - */ + /** + * Updates the parameters of a single floor setting of a project + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.modelarmor.v1.FloorSetting} request.floorSetting + * Required. The floor setting being updated. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask is used to specify the fields to be overwritten in the + * FloorSetting resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @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 {@link protos.google.cloud.modelarmor.v1.FloorSetting|FloorSetting}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/model_armor.update_floor_setting.js + * region_tag:modelarmor_v1_generated_ModelArmor_UpdateFloorSetting_async + */ updateFloorSetting( - request?: protos.google.cloud.modelarmor.v1.IUpdateFloorSettingRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.modelarmor.v1.IFloorSetting, - protos.google.cloud.modelarmor.v1.IUpdateFloorSettingRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.modelarmor.v1.IUpdateFloorSettingRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.modelarmor.v1.IFloorSetting, + protos.google.cloud.modelarmor.v1.IUpdateFloorSettingRequest | undefined, + {} | undefined, + ] + >; updateFloorSetting( - request: protos.google.cloud.modelarmor.v1.IUpdateFloorSettingRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.modelarmor.v1.IFloorSetting, - protos.google.cloud.modelarmor.v1.IUpdateFloorSettingRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1.IUpdateFloorSettingRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.modelarmor.v1.IFloorSetting, + | protos.google.cloud.modelarmor.v1.IUpdateFloorSettingRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateFloorSetting( - request: protos.google.cloud.modelarmor.v1.IUpdateFloorSettingRequest, - callback: Callback< - protos.google.cloud.modelarmor.v1.IFloorSetting, - protos.google.cloud.modelarmor.v1.IUpdateFloorSettingRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1.IUpdateFloorSettingRequest, + callback: Callback< + protos.google.cloud.modelarmor.v1.IFloorSetting, + | protos.google.cloud.modelarmor.v1.IUpdateFloorSettingRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateFloorSetting( - request?: protos.google.cloud.modelarmor.v1.IUpdateFloorSettingRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.modelarmor.v1.IFloorSetting, - protos.google.cloud.modelarmor.v1.IUpdateFloorSettingRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.modelarmor.v1.IUpdateFloorSettingRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.modelarmor.v1.IFloorSetting, - protos.google.cloud.modelarmor.v1.IUpdateFloorSettingRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.modelarmor.v1.IFloorSetting, - protos.google.cloud.modelarmor.v1.IUpdateFloorSettingRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.modelarmor.v1.IUpdateFloorSettingRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.modelarmor.v1.IFloorSetting, + | protos.google.cloud.modelarmor.v1.IUpdateFloorSettingRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.modelarmor.v1.IFloorSetting, + protos.google.cloud.modelarmor.v1.IUpdateFloorSettingRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'floor_setting.name': request.floorSetting!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'floor_setting.name': request.floorSetting!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateFloorSetting request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.modelarmor.v1.IFloorSetting, - protos.google.cloud.modelarmor.v1.IUpdateFloorSettingRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.modelarmor.v1.IFloorSetting, + | protos.google.cloud.modelarmor.v1.IUpdateFloorSettingRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateFloorSetting response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateFloorSetting(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.modelarmor.v1.IFloorSetting, - protos.google.cloud.modelarmor.v1.IUpdateFloorSettingRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateFloorSetting response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .updateFloorSetting(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.modelarmor.v1.IFloorSetting, + ( + | protos.google.cloud.modelarmor.v1.IUpdateFloorSettingRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateFloorSetting response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Sanitizes User Prompt. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Represents resource name of template - * e.g. name=projects/sample-project/locations/us-central1/templates/templ01 - * @param {google.cloud.modelarmor.v1.DataItem} request.userPromptData - * Required. User prompt data to sanitize. - * @param {google.cloud.modelarmor.v1.MultiLanguageDetectionMetadata} [request.multiLanguageDetectionMetadata] - * Optional. Metadata related to Multi Language Detection. - * @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 {@link protos.google.cloud.modelarmor.v1.SanitizeUserPromptResponse|SanitizeUserPromptResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/model_armor.sanitize_user_prompt.js - * region_tag:modelarmor_v1_generated_ModelArmor_SanitizeUserPrompt_async - */ + /** + * Sanitizes User Prompt. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Represents resource name of template + * e.g. name=projects/sample-project/locations/us-central1/templates/templ01 + * @param {google.cloud.modelarmor.v1.DataItem} request.userPromptData + * Required. User prompt data to sanitize. + * @param {google.cloud.modelarmor.v1.MultiLanguageDetectionMetadata} [request.multiLanguageDetectionMetadata] + * Optional. Metadata related to Multi Language Detection. + * @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 {@link protos.google.cloud.modelarmor.v1.SanitizeUserPromptResponse|SanitizeUserPromptResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/model_armor.sanitize_user_prompt.js + * region_tag:modelarmor_v1_generated_ModelArmor_SanitizeUserPrompt_async + */ sanitizeUserPrompt( - request?: protos.google.cloud.modelarmor.v1.ISanitizeUserPromptRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.modelarmor.v1.ISanitizeUserPromptResponse, - protos.google.cloud.modelarmor.v1.ISanitizeUserPromptRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.modelarmor.v1.ISanitizeUserPromptRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.modelarmor.v1.ISanitizeUserPromptResponse, + protos.google.cloud.modelarmor.v1.ISanitizeUserPromptRequest | undefined, + {} | undefined, + ] + >; sanitizeUserPrompt( - request: protos.google.cloud.modelarmor.v1.ISanitizeUserPromptRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.modelarmor.v1.ISanitizeUserPromptResponse, - protos.google.cloud.modelarmor.v1.ISanitizeUserPromptRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1.ISanitizeUserPromptRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.modelarmor.v1.ISanitizeUserPromptResponse, + | protos.google.cloud.modelarmor.v1.ISanitizeUserPromptRequest + | null + | undefined, + {} | null | undefined + >, + ): void; sanitizeUserPrompt( - request: protos.google.cloud.modelarmor.v1.ISanitizeUserPromptRequest, - callback: Callback< - protos.google.cloud.modelarmor.v1.ISanitizeUserPromptResponse, - protos.google.cloud.modelarmor.v1.ISanitizeUserPromptRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1.ISanitizeUserPromptRequest, + callback: Callback< + protos.google.cloud.modelarmor.v1.ISanitizeUserPromptResponse, + | protos.google.cloud.modelarmor.v1.ISanitizeUserPromptRequest + | null + | undefined, + {} | null | undefined + >, + ): void; sanitizeUserPrompt( - request?: protos.google.cloud.modelarmor.v1.ISanitizeUserPromptRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.modelarmor.v1.ISanitizeUserPromptResponse, - protos.google.cloud.modelarmor.v1.ISanitizeUserPromptRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.modelarmor.v1.ISanitizeUserPromptRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.modelarmor.v1.ISanitizeUserPromptResponse, - protos.google.cloud.modelarmor.v1.ISanitizeUserPromptRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.modelarmor.v1.ISanitizeUserPromptResponse, - protos.google.cloud.modelarmor.v1.ISanitizeUserPromptRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.modelarmor.v1.ISanitizeUserPromptRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.modelarmor.v1.ISanitizeUserPromptResponse, + | protos.google.cloud.modelarmor.v1.ISanitizeUserPromptRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.modelarmor.v1.ISanitizeUserPromptResponse, + protos.google.cloud.modelarmor.v1.ISanitizeUserPromptRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('sanitizeUserPrompt request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.modelarmor.v1.ISanitizeUserPromptResponse, - protos.google.cloud.modelarmor.v1.ISanitizeUserPromptRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.modelarmor.v1.ISanitizeUserPromptResponse, + | protos.google.cloud.modelarmor.v1.ISanitizeUserPromptRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('sanitizeUserPrompt response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.sanitizeUserPrompt(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.modelarmor.v1.ISanitizeUserPromptResponse, - protos.google.cloud.modelarmor.v1.ISanitizeUserPromptRequest|undefined, - {}|undefined - ]) => { - this._log.info('sanitizeUserPrompt response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .sanitizeUserPrompt(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.modelarmor.v1.ISanitizeUserPromptResponse, + ( + | protos.google.cloud.modelarmor.v1.ISanitizeUserPromptRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('sanitizeUserPrompt response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Sanitizes Model Response. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Represents resource name of template - * e.g. name=projects/sample-project/locations/us-central1/templates/templ01 - * @param {google.cloud.modelarmor.v1.DataItem} request.modelResponseData - * Required. Model response data to sanitize. - * @param {string} [request.userPrompt] - * Optional. User Prompt associated with Model response. - * @param {google.cloud.modelarmor.v1.MultiLanguageDetectionMetadata} [request.multiLanguageDetectionMetadata] - * Optional. Metadata related for multi language detection. - * @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 {@link protos.google.cloud.modelarmor.v1.SanitizeModelResponseResponse|SanitizeModelResponseResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/model_armor.sanitize_model_response.js - * region_tag:modelarmor_v1_generated_ModelArmor_SanitizeModelResponse_async - */ + /** + * Sanitizes Model Response. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Represents resource name of template + * e.g. name=projects/sample-project/locations/us-central1/templates/templ01 + * @param {google.cloud.modelarmor.v1.DataItem} request.modelResponseData + * Required. Model response data to sanitize. + * @param {string} [request.userPrompt] + * Optional. User Prompt associated with Model response. + * @param {google.cloud.modelarmor.v1.MultiLanguageDetectionMetadata} [request.multiLanguageDetectionMetadata] + * Optional. Metadata related for multi language detection. + * @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 {@link protos.google.cloud.modelarmor.v1.SanitizeModelResponseResponse|SanitizeModelResponseResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/model_armor.sanitize_model_response.js + * region_tag:modelarmor_v1_generated_ModelArmor_SanitizeModelResponse_async + */ sanitizeModelResponse( - request?: protos.google.cloud.modelarmor.v1.ISanitizeModelResponseRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.modelarmor.v1.ISanitizeModelResponseResponse, - protos.google.cloud.modelarmor.v1.ISanitizeModelResponseRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.modelarmor.v1.ISanitizeModelResponseRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.modelarmor.v1.ISanitizeModelResponseResponse, + ( + | protos.google.cloud.modelarmor.v1.ISanitizeModelResponseRequest + | undefined + ), + {} | undefined, + ] + >; sanitizeModelResponse( - request: protos.google.cloud.modelarmor.v1.ISanitizeModelResponseRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.modelarmor.v1.ISanitizeModelResponseResponse, - protos.google.cloud.modelarmor.v1.ISanitizeModelResponseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1.ISanitizeModelResponseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.modelarmor.v1.ISanitizeModelResponseResponse, + | protos.google.cloud.modelarmor.v1.ISanitizeModelResponseRequest + | null + | undefined, + {} | null | undefined + >, + ): void; sanitizeModelResponse( - request: protos.google.cloud.modelarmor.v1.ISanitizeModelResponseRequest, - callback: Callback< - protos.google.cloud.modelarmor.v1.ISanitizeModelResponseResponse, - protos.google.cloud.modelarmor.v1.ISanitizeModelResponseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1.ISanitizeModelResponseRequest, + callback: Callback< + protos.google.cloud.modelarmor.v1.ISanitizeModelResponseResponse, + | protos.google.cloud.modelarmor.v1.ISanitizeModelResponseRequest + | null + | undefined, + {} | null | undefined + >, + ): void; sanitizeModelResponse( - request?: protos.google.cloud.modelarmor.v1.ISanitizeModelResponseRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.modelarmor.v1.ISanitizeModelResponseResponse, - protos.google.cloud.modelarmor.v1.ISanitizeModelResponseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.modelarmor.v1.ISanitizeModelResponseRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.modelarmor.v1.ISanitizeModelResponseResponse, - protos.google.cloud.modelarmor.v1.ISanitizeModelResponseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.modelarmor.v1.ISanitizeModelResponseResponse, - protos.google.cloud.modelarmor.v1.ISanitizeModelResponseRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.modelarmor.v1.ISanitizeModelResponseRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.modelarmor.v1.ISanitizeModelResponseResponse, + | protos.google.cloud.modelarmor.v1.ISanitizeModelResponseRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.modelarmor.v1.ISanitizeModelResponseResponse, + ( + | protos.google.cloud.modelarmor.v1.ISanitizeModelResponseRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('sanitizeModelResponse request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.modelarmor.v1.ISanitizeModelResponseResponse, - protos.google.cloud.modelarmor.v1.ISanitizeModelResponseRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.modelarmor.v1.ISanitizeModelResponseResponse, + | protos.google.cloud.modelarmor.v1.ISanitizeModelResponseRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('sanitizeModelResponse response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.sanitizeModelResponse(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.modelarmor.v1.ISanitizeModelResponseResponse, - protos.google.cloud.modelarmor.v1.ISanitizeModelResponseRequest|undefined, - {}|undefined - ]) => { - this._log.info('sanitizeModelResponse response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .sanitizeModelResponse(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.modelarmor.v1.ISanitizeModelResponseResponse, + ( + | protos.google.cloud.modelarmor.v1.ISanitizeModelResponseRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('sanitizeModelResponse response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } - /** - * Lists Templates in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListTemplatesRequest - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Filtering results - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results - * @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 Array of {@link protos.google.cloud.modelarmor.v1.Template|Template}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listTemplatesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists Templates in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListTemplatesRequest + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Filtering results + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results + * @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 Array of {@link protos.google.cloud.modelarmor.v1.Template|Template}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listTemplatesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listTemplates( - request?: protos.google.cloud.modelarmor.v1.IListTemplatesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.modelarmor.v1.ITemplate[], - protos.google.cloud.modelarmor.v1.IListTemplatesRequest|null, - protos.google.cloud.modelarmor.v1.IListTemplatesResponse - ]>; + request?: protos.google.cloud.modelarmor.v1.IListTemplatesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.modelarmor.v1.ITemplate[], + protos.google.cloud.modelarmor.v1.IListTemplatesRequest | null, + protos.google.cloud.modelarmor.v1.IListTemplatesResponse, + ] + >; listTemplates( - request: protos.google.cloud.modelarmor.v1.IListTemplatesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.modelarmor.v1.IListTemplatesRequest, - protos.google.cloud.modelarmor.v1.IListTemplatesResponse|null|undefined, - protos.google.cloud.modelarmor.v1.ITemplate>): void; + request: protos.google.cloud.modelarmor.v1.IListTemplatesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.modelarmor.v1.IListTemplatesRequest, + | protos.google.cloud.modelarmor.v1.IListTemplatesResponse + | null + | undefined, + protos.google.cloud.modelarmor.v1.ITemplate + >, + ): void; listTemplates( - request: protos.google.cloud.modelarmor.v1.IListTemplatesRequest, - callback: PaginationCallback< - protos.google.cloud.modelarmor.v1.IListTemplatesRequest, - protos.google.cloud.modelarmor.v1.IListTemplatesResponse|null|undefined, - protos.google.cloud.modelarmor.v1.ITemplate>): void; + request: protos.google.cloud.modelarmor.v1.IListTemplatesRequest, + callback: PaginationCallback< + protos.google.cloud.modelarmor.v1.IListTemplatesRequest, + | protos.google.cloud.modelarmor.v1.IListTemplatesResponse + | null + | undefined, + protos.google.cloud.modelarmor.v1.ITemplate + >, + ): void; listTemplates( - request?: protos.google.cloud.modelarmor.v1.IListTemplatesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.modelarmor.v1.IListTemplatesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.modelarmor.v1.IListTemplatesRequest, - protos.google.cloud.modelarmor.v1.IListTemplatesResponse|null|undefined, - protos.google.cloud.modelarmor.v1.ITemplate>, - callback?: PaginationCallback< - protos.google.cloud.modelarmor.v1.IListTemplatesRequest, - protos.google.cloud.modelarmor.v1.IListTemplatesResponse|null|undefined, - protos.google.cloud.modelarmor.v1.ITemplate>): - Promise<[ - protos.google.cloud.modelarmor.v1.ITemplate[], - protos.google.cloud.modelarmor.v1.IListTemplatesRequest|null, - protos.google.cloud.modelarmor.v1.IListTemplatesResponse - ]>|void { + | protos.google.cloud.modelarmor.v1.IListTemplatesResponse + | null + | undefined, + protos.google.cloud.modelarmor.v1.ITemplate + >, + callback?: PaginationCallback< + protos.google.cloud.modelarmor.v1.IListTemplatesRequest, + | protos.google.cloud.modelarmor.v1.IListTemplatesResponse + | null + | undefined, + protos.google.cloud.modelarmor.v1.ITemplate + >, + ): Promise< + [ + protos.google.cloud.modelarmor.v1.ITemplate[], + protos.google.cloud.modelarmor.v1.IListTemplatesRequest | null, + protos.google.cloud.modelarmor.v1.IListTemplatesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.modelarmor.v1.IListTemplatesRequest, - protos.google.cloud.modelarmor.v1.IListTemplatesResponse|null|undefined, - protos.google.cloud.modelarmor.v1.ITemplate>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.modelarmor.v1.IListTemplatesRequest, + | protos.google.cloud.modelarmor.v1.IListTemplatesResponse + | null + | undefined, + protos.google.cloud.modelarmor.v1.ITemplate + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listTemplates values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1277,119 +1688,124 @@ export class ModelArmorClient { this._log.info('listTemplates request %j', request); return this.innerApiCalls .listTemplates(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.modelarmor.v1.ITemplate[], - protos.google.cloud.modelarmor.v1.IListTemplatesRequest|null, - protos.google.cloud.modelarmor.v1.IListTemplatesResponse - ]) => { - this._log.info('listTemplates values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.modelarmor.v1.ITemplate[], + protos.google.cloud.modelarmor.v1.IListTemplatesRequest | null, + protos.google.cloud.modelarmor.v1.IListTemplatesResponse, + ]) => { + this._log.info('listTemplates values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listTemplates`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListTemplatesRequest - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Filtering results - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.modelarmor.v1.Template|Template} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listTemplatesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listTemplates`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListTemplatesRequest + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Filtering results + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.modelarmor.v1.Template|Template} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listTemplatesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listTemplatesStream( - request?: protos.google.cloud.modelarmor.v1.IListTemplatesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.modelarmor.v1.IListTemplatesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listTemplates']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listTemplates stream %j', request); return this.descriptors.page.listTemplates.createStream( this.innerApiCalls.listTemplates as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listTemplates`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListTemplatesRequest - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Filtering results - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.modelarmor.v1.Template|Template}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/model_armor.list_templates.js - * region_tag:modelarmor_v1_generated_ModelArmor_ListTemplates_async - */ + /** + * Equivalent to `listTemplates`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListTemplatesRequest + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Filtering results + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.modelarmor.v1.Template|Template}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/model_armor.list_templates.js + * region_tag:modelarmor_v1_generated_ModelArmor_ListTemplates_async + */ listTemplatesAsync( - request?: protos.google.cloud.modelarmor.v1.IListTemplatesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.modelarmor.v1.IListTemplatesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listTemplates']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listTemplates iterate %j', request); return this.descriptors.page.listTemplates.asyncIterate( this.innerApiCalls['listTemplates'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** + + /** * Gets information about a location. * * @param {Object} request @@ -1424,12 +1840,11 @@ export class ModelArmorClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -1462,7 +1877,7 @@ export class ModelArmorClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -1478,7 +1893,7 @@ export class ModelArmorClient { * @param {string} location * @returns {string} Resource name string. */ - folderLocationFloorSettingPath(folder:string,location:string) { + folderLocationFloorSettingPath(folder: string, location: string) { return this.pathTemplates.folderLocationFloorSettingPathTemplate.render({ folder: folder, location: location, @@ -1492,8 +1907,12 @@ export class ModelArmorClient { * A fully-qualified path representing folder_location_floorSetting resource. * @returns {string} A string representing the folder. */ - matchFolderFromFolderLocationFloorSettingName(folderLocationFloorSettingName: string) { - return this.pathTemplates.folderLocationFloorSettingPathTemplate.match(folderLocationFloorSettingName).folder; + matchFolderFromFolderLocationFloorSettingName( + folderLocationFloorSettingName: string, + ) { + return this.pathTemplates.folderLocationFloorSettingPathTemplate.match( + folderLocationFloorSettingName, + ).folder; } /** @@ -1503,8 +1922,12 @@ export class ModelArmorClient { * A fully-qualified path representing folder_location_floorSetting resource. * @returns {string} A string representing the location. */ - matchLocationFromFolderLocationFloorSettingName(folderLocationFloorSettingName: string) { - return this.pathTemplates.folderLocationFloorSettingPathTemplate.match(folderLocationFloorSettingName).location; + matchLocationFromFolderLocationFloorSettingName( + folderLocationFloorSettingName: string, + ) { + return this.pathTemplates.folderLocationFloorSettingPathTemplate.match( + folderLocationFloorSettingName, + ).location; } /** @@ -1514,7 +1937,7 @@ export class ModelArmorClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -1550,11 +1973,13 @@ export class ModelArmorClient { * @param {string} location * @returns {string} Resource name string. */ - organizationLocationFloorSettingPath(organization:string,location:string) { - return this.pathTemplates.organizationLocationFloorSettingPathTemplate.render({ - organization: organization, - location: location, - }); + organizationLocationFloorSettingPath(organization: string, location: string) { + return this.pathTemplates.organizationLocationFloorSettingPathTemplate.render( + { + organization: organization, + location: location, + }, + ); } /** @@ -1564,8 +1989,12 @@ export class ModelArmorClient { * A fully-qualified path representing organization_location_floorSetting resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationLocationFloorSettingName(organizationLocationFloorSettingName: string) { - return this.pathTemplates.organizationLocationFloorSettingPathTemplate.match(organizationLocationFloorSettingName).organization; + matchOrganizationFromOrganizationLocationFloorSettingName( + organizationLocationFloorSettingName: string, + ) { + return this.pathTemplates.organizationLocationFloorSettingPathTemplate.match( + organizationLocationFloorSettingName, + ).organization; } /** @@ -1575,8 +2004,12 @@ export class ModelArmorClient { * A fully-qualified path representing organization_location_floorSetting resource. * @returns {string} A string representing the location. */ - matchLocationFromOrganizationLocationFloorSettingName(organizationLocationFloorSettingName: string) { - return this.pathTemplates.organizationLocationFloorSettingPathTemplate.match(organizationLocationFloorSettingName).location; + matchLocationFromOrganizationLocationFloorSettingName( + organizationLocationFloorSettingName: string, + ) { + return this.pathTemplates.organizationLocationFloorSettingPathTemplate.match( + organizationLocationFloorSettingName, + ).location; } /** @@ -1585,7 +2018,7 @@ export class ModelArmorClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -1609,7 +2042,7 @@ export class ModelArmorClient { * @param {string} location * @returns {string} Resource name string. */ - projectLocationFloorSettingPath(project:string,location:string) { + projectLocationFloorSettingPath(project: string, location: string) { return this.pathTemplates.projectLocationFloorSettingPathTemplate.render({ project: project, location: location, @@ -1623,8 +2056,12 @@ export class ModelArmorClient { * A fully-qualified path representing project_location_floorSetting resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectLocationFloorSettingName(projectLocationFloorSettingName: string) { - return this.pathTemplates.projectLocationFloorSettingPathTemplate.match(projectLocationFloorSettingName).project; + matchProjectFromProjectLocationFloorSettingName( + projectLocationFloorSettingName: string, + ) { + return this.pathTemplates.projectLocationFloorSettingPathTemplate.match( + projectLocationFloorSettingName, + ).project; } /** @@ -1634,8 +2071,12 @@ export class ModelArmorClient { * A fully-qualified path representing project_location_floorSetting resource. * @returns {string} A string representing the location. */ - matchLocationFromProjectLocationFloorSettingName(projectLocationFloorSettingName: string) { - return this.pathTemplates.projectLocationFloorSettingPathTemplate.match(projectLocationFloorSettingName).location; + matchLocationFromProjectLocationFloorSettingName( + projectLocationFloorSettingName: string, + ) { + return this.pathTemplates.projectLocationFloorSettingPathTemplate.match( + projectLocationFloorSettingName, + ).location; } /** @@ -1646,7 +2087,7 @@ export class ModelArmorClient { * @param {string} template * @returns {string} Resource name string. */ - templatePath(project:string,location:string,template:string) { + templatePath(project: string, location: string, template: string) { return this.pathTemplates.templatePathTemplate.render({ project: project, location: location, @@ -1695,13 +2136,15 @@ export class ModelArmorClient { */ close(): Promise { if (this.modelArmorStub && !this._terminated) { - return this.modelArmorStub.then(stub => { + return this.modelArmorStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.locationsClient.close().catch(err => {throw err}); + this.locationsClient.close().catch((err) => { + throw err; + }); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-modelarmor/src/v1beta/index.ts b/packages/google-cloud-modelarmor/src/v1beta/index.ts index d9f2b339caec..367fb8b87540 100644 --- a/packages/google-cloud-modelarmor/src/v1beta/index.ts +++ b/packages/google-cloud-modelarmor/src/v1beta/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {ModelArmorClient} from './model_armor_client'; +export { ModelArmorClient } from './model_armor_client'; diff --git a/packages/google-cloud-modelarmor/src/v1beta/model_armor_client.ts b/packages/google-cloud-modelarmor/src/v1beta/model_armor_client.ts index 98d48ac8361c..2f7107f448c7 100644 --- a/packages/google-cloud-modelarmor/src/v1beta/model_armor_client.ts +++ b/packages/google-cloud-modelarmor/src/v1beta/model_armor_client.ts @@ -18,11 +18,20 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform, PassThrough} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + PaginationCallback, + GaxCall, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform, PassThrough } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -44,7 +53,7 @@ export class ModelArmorClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('modelarmor'); @@ -57,10 +66,10 @@ export class ModelArmorClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - modelArmorStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + modelArmorStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of ModelArmorClient. @@ -101,21 +110,42 @@ export class ModelArmorClient { * const client = new ModelArmorClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof ModelArmorClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'modelarmor.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -140,7 +170,7 @@ export class ModelArmorClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -154,15 +184,11 @@ export class ModelArmorClient { } this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -184,22 +210,23 @@ export class ModelArmorClient { // Create useful helper objects for these. this.pathTemplates = { folderLocationFloorSettingPathTemplate: new this._gaxModule.PathTemplate( - 'folders/{folder}/locations/{location}/floorSetting' + 'folders/{folder}/locations/{location}/floorSetting', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - organizationLocationFloorSettingPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/locations/{location}/floorSetting' + 'projects/{project}/locations/{location}', ), + organizationLocationFloorSettingPathTemplate: + new this._gaxModule.PathTemplate( + 'organizations/{organization}/locations/{location}/floorSetting', + ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), projectLocationFloorSettingPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/floorSetting' + 'projects/{project}/locations/{location}/floorSetting', ), templatePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/templates/{template}' + 'projects/{project}/locations/{location}/templates/{template}', ), }; @@ -207,21 +234,35 @@ export class ModelArmorClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listTemplates: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'templates') + listTemplates: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'templates', + ), }; // Some of the methods on this service provide streaming responses. // Provide descriptors for these. this.descriptors.stream = { - streamSanitizeUserPrompt: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, !!opts.fallback, !!opts.gaxServerStreamingRetries), - streamSanitizeModelResponse: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, !!opts.fallback, !!opts.gaxServerStreamingRetries) + streamSanitizeUserPrompt: new this._gaxModule.StreamDescriptor( + this._gaxModule.StreamType.BIDI_STREAMING, + !!opts.fallback, + !!opts.gaxServerStreamingRetries, + ), + streamSanitizeModelResponse: new this._gaxModule.StreamDescriptor( + this._gaxModule.StreamType.BIDI_STREAMING, + !!opts.fallback, + !!opts.gaxServerStreamingRetries, + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.modelarmor.v1beta.ModelArmor', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.modelarmor.v1beta.ModelArmor', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -252,35 +293,57 @@ export class ModelArmorClient { // Put together the "service stub" for // google.cloud.modelarmor.v1beta.ModelArmor. this.modelArmorStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.modelarmor.v1beta.ModelArmor') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.modelarmor.v1beta.ModelArmor', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.modelarmor.v1beta.ModelArmor, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const modelArmorStubMethods = - ['listTemplates', 'getTemplate', 'createTemplate', 'updateTemplate', 'deleteTemplate', 'getFloorSetting', 'updateFloorSetting', 'sanitizeUserPrompt', 'sanitizeModelResponse', 'streamSanitizeUserPrompt', 'streamSanitizeModelResponse']; + const modelArmorStubMethods = [ + 'listTemplates', + 'getTemplate', + 'createTemplate', + 'updateTemplate', + 'deleteTemplate', + 'getFloorSetting', + 'updateFloorSetting', + 'sanitizeUserPrompt', + 'sanitizeModelResponse', + 'streamSanitizeUserPrompt', + 'streamSanitizeModelResponse', + ]; for (const methodName of modelArmorStubMethods) { const callPromise = this.modelArmorStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - if (methodName in this.descriptors.stream) { - const stream = new PassThrough({objectMode: true}); - setImmediate(() => { - stream.emit('error', new this._gaxModule.GoogleError('The client has already been closed.')); - }); - return stream; + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + if (methodName in this.descriptors.stream) { + const stream = new PassThrough({ objectMode: true }); + setImmediate(() => { + stream.emit( + 'error', + new this._gaxModule.GoogleError( + 'The client has already been closed.', + ), + ); + }); + return stream; + } + return Promise.reject('The client has already been closed.'); } - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -290,7 +353,7 @@ export class ModelArmorClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -305,8 +368,14 @@ export class ModelArmorClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'modelarmor.googleapis.com'; } @@ -317,8 +386,14 @@ export class ModelArmorClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'modelarmor.googleapis.com'; } @@ -349,9 +424,7 @@ export class ModelArmorClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -360,8 +433,9 @@ export class ModelArmorClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -372,966 +446,1350 @@ export class ModelArmorClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets details of a single Template. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource - * @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 {@link protos.google.cloud.modelarmor.v1beta.Template|Template}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/model_armor.get_template.js - * region_tag:modelarmor_v1beta_generated_ModelArmor_GetTemplate_async - */ + /** + * Gets details of a single Template. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource + * @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 {@link protos.google.cloud.modelarmor.v1beta.Template|Template}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/model_armor.get_template.js + * region_tag:modelarmor_v1beta_generated_ModelArmor_GetTemplate_async + */ getTemplate( - request?: protos.google.cloud.modelarmor.v1beta.IGetTemplateRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.modelarmor.v1beta.ITemplate, - protos.google.cloud.modelarmor.v1beta.IGetTemplateRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.modelarmor.v1beta.IGetTemplateRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.modelarmor.v1beta.ITemplate, + protos.google.cloud.modelarmor.v1beta.IGetTemplateRequest | undefined, + {} | undefined, + ] + >; getTemplate( - request: protos.google.cloud.modelarmor.v1beta.IGetTemplateRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.modelarmor.v1beta.ITemplate, - protos.google.cloud.modelarmor.v1beta.IGetTemplateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1beta.IGetTemplateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.modelarmor.v1beta.ITemplate, + | protos.google.cloud.modelarmor.v1beta.IGetTemplateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getTemplate( - request: protos.google.cloud.modelarmor.v1beta.IGetTemplateRequest, - callback: Callback< - protos.google.cloud.modelarmor.v1beta.ITemplate, - protos.google.cloud.modelarmor.v1beta.IGetTemplateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1beta.IGetTemplateRequest, + callback: Callback< + protos.google.cloud.modelarmor.v1beta.ITemplate, + | protos.google.cloud.modelarmor.v1beta.IGetTemplateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getTemplate( - request?: protos.google.cloud.modelarmor.v1beta.IGetTemplateRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.modelarmor.v1beta.ITemplate, - protos.google.cloud.modelarmor.v1beta.IGetTemplateRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.modelarmor.v1beta.IGetTemplateRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.modelarmor.v1beta.ITemplate, - protos.google.cloud.modelarmor.v1beta.IGetTemplateRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.modelarmor.v1beta.ITemplate, - protos.google.cloud.modelarmor.v1beta.IGetTemplateRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.modelarmor.v1beta.IGetTemplateRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.modelarmor.v1beta.ITemplate, + | protos.google.cloud.modelarmor.v1beta.IGetTemplateRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.modelarmor.v1beta.ITemplate, + protos.google.cloud.modelarmor.v1beta.IGetTemplateRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getTemplate request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.modelarmor.v1beta.ITemplate, - protos.google.cloud.modelarmor.v1beta.IGetTemplateRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.modelarmor.v1beta.ITemplate, + | protos.google.cloud.modelarmor.v1beta.IGetTemplateRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getTemplate response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getTemplate(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.modelarmor.v1beta.ITemplate, - protos.google.cloud.modelarmor.v1beta.IGetTemplateRequest|undefined, - {}|undefined - ]) => { - this._log.info('getTemplate response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getTemplate(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.modelarmor.v1beta.ITemplate, + protos.google.cloud.modelarmor.v1beta.IGetTemplateRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getTemplate response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a new Template in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Value for parent. - * @param {string} request.templateId - * Required. Id of the requesting object - * If auto-generating Id server-side, remove this field and - * template_id from the method_signature of Create RPC - * @param {google.cloud.modelarmor.v1beta.Template} request.template - * Required. The resource being created - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server stores the - * request ID for 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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 {@link protos.google.cloud.modelarmor.v1beta.Template|Template}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/model_armor.create_template.js - * region_tag:modelarmor_v1beta_generated_ModelArmor_CreateTemplate_async - */ + /** + * Creates a new Template in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Value for parent. + * @param {string} request.templateId + * Required. Id of the requesting object + * If auto-generating Id server-side, remove this field and + * template_id from the method_signature of Create RPC + * @param {google.cloud.modelarmor.v1beta.Template} request.template + * Required. The resource being created + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server stores the + * request ID for 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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 {@link protos.google.cloud.modelarmor.v1beta.Template|Template}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/model_armor.create_template.js + * region_tag:modelarmor_v1beta_generated_ModelArmor_CreateTemplate_async + */ createTemplate( - request?: protos.google.cloud.modelarmor.v1beta.ICreateTemplateRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.modelarmor.v1beta.ITemplate, - protos.google.cloud.modelarmor.v1beta.ICreateTemplateRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.modelarmor.v1beta.ICreateTemplateRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.modelarmor.v1beta.ITemplate, + protos.google.cloud.modelarmor.v1beta.ICreateTemplateRequest | undefined, + {} | undefined, + ] + >; createTemplate( - request: protos.google.cloud.modelarmor.v1beta.ICreateTemplateRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.modelarmor.v1beta.ITemplate, - protos.google.cloud.modelarmor.v1beta.ICreateTemplateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1beta.ICreateTemplateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.modelarmor.v1beta.ITemplate, + | protos.google.cloud.modelarmor.v1beta.ICreateTemplateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createTemplate( - request: protos.google.cloud.modelarmor.v1beta.ICreateTemplateRequest, - callback: Callback< - protos.google.cloud.modelarmor.v1beta.ITemplate, - protos.google.cloud.modelarmor.v1beta.ICreateTemplateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1beta.ICreateTemplateRequest, + callback: Callback< + protos.google.cloud.modelarmor.v1beta.ITemplate, + | protos.google.cloud.modelarmor.v1beta.ICreateTemplateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createTemplate( - request?: protos.google.cloud.modelarmor.v1beta.ICreateTemplateRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.modelarmor.v1beta.ITemplate, - protos.google.cloud.modelarmor.v1beta.ICreateTemplateRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.modelarmor.v1beta.ICreateTemplateRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.modelarmor.v1beta.ITemplate, - protos.google.cloud.modelarmor.v1beta.ICreateTemplateRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.modelarmor.v1beta.ITemplate, - protos.google.cloud.modelarmor.v1beta.ICreateTemplateRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.modelarmor.v1beta.ICreateTemplateRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.modelarmor.v1beta.ITemplate, + | protos.google.cloud.modelarmor.v1beta.ICreateTemplateRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.modelarmor.v1beta.ITemplate, + protos.google.cloud.modelarmor.v1beta.ICreateTemplateRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('createTemplate request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.modelarmor.v1beta.ITemplate, - protos.google.cloud.modelarmor.v1beta.ICreateTemplateRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.modelarmor.v1beta.ITemplate, + | protos.google.cloud.modelarmor.v1beta.ICreateTemplateRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createTemplate response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createTemplate(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.modelarmor.v1beta.ITemplate, - protos.google.cloud.modelarmor.v1beta.ICreateTemplateRequest|undefined, - {}|undefined - ]) => { - this._log.info('createTemplate response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .createTemplate(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.modelarmor.v1beta.ITemplate, + ( + | protos.google.cloud.modelarmor.v1beta.ICreateTemplateRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createTemplate response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Updates the parameters of a single Template. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Field mask is used to specify the fields to be overwritten in the - * Template resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - * @param {google.cloud.modelarmor.v1beta.Template} request.template - * Required. The resource being updated - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server stores the - * request ID for 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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 {@link protos.google.cloud.modelarmor.v1beta.Template|Template}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/model_armor.update_template.js - * region_tag:modelarmor_v1beta_generated_ModelArmor_UpdateTemplate_async - */ + /** + * Updates the parameters of a single Template. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Field mask is used to specify the fields to be overwritten in the + * Template resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @param {google.cloud.modelarmor.v1beta.Template} request.template + * Required. The resource being updated + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server stores the + * request ID for 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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 {@link protos.google.cloud.modelarmor.v1beta.Template|Template}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/model_armor.update_template.js + * region_tag:modelarmor_v1beta_generated_ModelArmor_UpdateTemplate_async + */ updateTemplate( - request?: protos.google.cloud.modelarmor.v1beta.IUpdateTemplateRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.modelarmor.v1beta.ITemplate, - protos.google.cloud.modelarmor.v1beta.IUpdateTemplateRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.modelarmor.v1beta.IUpdateTemplateRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.modelarmor.v1beta.ITemplate, + protos.google.cloud.modelarmor.v1beta.IUpdateTemplateRequest | undefined, + {} | undefined, + ] + >; updateTemplate( - request: protos.google.cloud.modelarmor.v1beta.IUpdateTemplateRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.modelarmor.v1beta.ITemplate, - protos.google.cloud.modelarmor.v1beta.IUpdateTemplateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1beta.IUpdateTemplateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.modelarmor.v1beta.ITemplate, + | protos.google.cloud.modelarmor.v1beta.IUpdateTemplateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateTemplate( - request: protos.google.cloud.modelarmor.v1beta.IUpdateTemplateRequest, - callback: Callback< - protos.google.cloud.modelarmor.v1beta.ITemplate, - protos.google.cloud.modelarmor.v1beta.IUpdateTemplateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1beta.IUpdateTemplateRequest, + callback: Callback< + protos.google.cloud.modelarmor.v1beta.ITemplate, + | protos.google.cloud.modelarmor.v1beta.IUpdateTemplateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateTemplate( - request?: protos.google.cloud.modelarmor.v1beta.IUpdateTemplateRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.modelarmor.v1beta.ITemplate, - protos.google.cloud.modelarmor.v1beta.IUpdateTemplateRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.modelarmor.v1beta.IUpdateTemplateRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.modelarmor.v1beta.ITemplate, - protos.google.cloud.modelarmor.v1beta.IUpdateTemplateRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.modelarmor.v1beta.ITemplate, - protos.google.cloud.modelarmor.v1beta.IUpdateTemplateRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.modelarmor.v1beta.IUpdateTemplateRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.modelarmor.v1beta.ITemplate, + | protos.google.cloud.modelarmor.v1beta.IUpdateTemplateRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.modelarmor.v1beta.ITemplate, + protos.google.cloud.modelarmor.v1beta.IUpdateTemplateRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'template.name': request.template!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'template.name': request.template!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateTemplate request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.modelarmor.v1beta.ITemplate, - protos.google.cloud.modelarmor.v1beta.IUpdateTemplateRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.modelarmor.v1beta.ITemplate, + | protos.google.cloud.modelarmor.v1beta.IUpdateTemplateRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateTemplate response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateTemplate(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.modelarmor.v1beta.ITemplate, - protos.google.cloud.modelarmor.v1beta.IUpdateTemplateRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateTemplate response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .updateTemplate(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.modelarmor.v1beta.ITemplate, + ( + | protos.google.cloud.modelarmor.v1beta.IUpdateTemplateRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateTemplate response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Deletes a single Template. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server stores the - * request ID for 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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 {@link protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/model_armor.delete_template.js - * region_tag:modelarmor_v1beta_generated_ModelArmor_DeleteTemplate_async - */ + /** + * Deletes a single Template. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server stores the + * request ID for 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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 {@link protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/model_armor.delete_template.js + * region_tag:modelarmor_v1beta_generated_ModelArmor_DeleteTemplate_async + */ deleteTemplate( - request?: protos.google.cloud.modelarmor.v1beta.IDeleteTemplateRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.modelarmor.v1beta.IDeleteTemplateRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.modelarmor.v1beta.IDeleteTemplateRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.modelarmor.v1beta.IDeleteTemplateRequest | undefined, + {} | undefined, + ] + >; deleteTemplate( - request: protos.google.cloud.modelarmor.v1beta.IDeleteTemplateRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.modelarmor.v1beta.IDeleteTemplateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1beta.IDeleteTemplateRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.modelarmor.v1beta.IDeleteTemplateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteTemplate( - request: protos.google.cloud.modelarmor.v1beta.IDeleteTemplateRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.modelarmor.v1beta.IDeleteTemplateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1beta.IDeleteTemplateRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.modelarmor.v1beta.IDeleteTemplateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteTemplate( - request?: protos.google.cloud.modelarmor.v1beta.IDeleteTemplateRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.modelarmor.v1beta.IDeleteTemplateRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.modelarmor.v1beta.IDeleteTemplateRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.modelarmor.v1beta.IDeleteTemplateRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.modelarmor.v1beta.IDeleteTemplateRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.modelarmor.v1beta.IDeleteTemplateRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.modelarmor.v1beta.IDeleteTemplateRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.modelarmor.v1beta.IDeleteTemplateRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('deleteTemplate request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.modelarmor.v1beta.IDeleteTemplateRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.modelarmor.v1beta.IDeleteTemplateRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteTemplate response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.deleteTemplate(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.modelarmor.v1beta.IDeleteTemplateRequest|undefined, - {}|undefined - ]) => { - this._log.info('deleteTemplate response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .deleteTemplate(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.modelarmor.v1beta.IDeleteTemplateRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteTemplate response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single floor setting of a project - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the floor setting to get, example - * projects/123/floorsetting. - * @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 {@link protos.google.cloud.modelarmor.v1beta.FloorSetting|FloorSetting}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/model_armor.get_floor_setting.js - * region_tag:modelarmor_v1beta_generated_ModelArmor_GetFloorSetting_async - */ + /** + * Gets details of a single floor setting of a project + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the floor setting to get, example + * projects/123/floorsetting. + * @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 {@link protos.google.cloud.modelarmor.v1beta.FloorSetting|FloorSetting}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/model_armor.get_floor_setting.js + * region_tag:modelarmor_v1beta_generated_ModelArmor_GetFloorSetting_async + */ getFloorSetting( - request?: protos.google.cloud.modelarmor.v1beta.IGetFloorSettingRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.modelarmor.v1beta.IFloorSetting, - protos.google.cloud.modelarmor.v1beta.IGetFloorSettingRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.modelarmor.v1beta.IGetFloorSettingRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.modelarmor.v1beta.IFloorSetting, + protos.google.cloud.modelarmor.v1beta.IGetFloorSettingRequest | undefined, + {} | undefined, + ] + >; getFloorSetting( - request: protos.google.cloud.modelarmor.v1beta.IGetFloorSettingRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.modelarmor.v1beta.IFloorSetting, - protos.google.cloud.modelarmor.v1beta.IGetFloorSettingRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1beta.IGetFloorSettingRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.modelarmor.v1beta.IFloorSetting, + | protos.google.cloud.modelarmor.v1beta.IGetFloorSettingRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getFloorSetting( - request: protos.google.cloud.modelarmor.v1beta.IGetFloorSettingRequest, - callback: Callback< - protos.google.cloud.modelarmor.v1beta.IFloorSetting, - protos.google.cloud.modelarmor.v1beta.IGetFloorSettingRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1beta.IGetFloorSettingRequest, + callback: Callback< + protos.google.cloud.modelarmor.v1beta.IFloorSetting, + | protos.google.cloud.modelarmor.v1beta.IGetFloorSettingRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getFloorSetting( - request?: protos.google.cloud.modelarmor.v1beta.IGetFloorSettingRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.modelarmor.v1beta.IFloorSetting, - protos.google.cloud.modelarmor.v1beta.IGetFloorSettingRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.modelarmor.v1beta.IGetFloorSettingRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.modelarmor.v1beta.IFloorSetting, - protos.google.cloud.modelarmor.v1beta.IGetFloorSettingRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.modelarmor.v1beta.IFloorSetting, - protos.google.cloud.modelarmor.v1beta.IGetFloorSettingRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.modelarmor.v1beta.IGetFloorSettingRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.modelarmor.v1beta.IFloorSetting, + | protos.google.cloud.modelarmor.v1beta.IGetFloorSettingRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.modelarmor.v1beta.IFloorSetting, + protos.google.cloud.modelarmor.v1beta.IGetFloorSettingRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getFloorSetting request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.modelarmor.v1beta.IFloorSetting, - protos.google.cloud.modelarmor.v1beta.IGetFloorSettingRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.modelarmor.v1beta.IFloorSetting, + | protos.google.cloud.modelarmor.v1beta.IGetFloorSettingRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getFloorSetting response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getFloorSetting(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.modelarmor.v1beta.IFloorSetting, - protos.google.cloud.modelarmor.v1beta.IGetFloorSettingRequest|undefined, - {}|undefined - ]) => { - this._log.info('getFloorSetting response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getFloorSetting(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.modelarmor.v1beta.IFloorSetting, + ( + | protos.google.cloud.modelarmor.v1beta.IGetFloorSettingRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getFloorSetting response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Updates the parameters of a single floor setting of a project - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.modelarmor.v1beta.FloorSetting} request.floorSetting - * Required. The floor setting being updated. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask is used to specify the fields to be overwritten in the - * FloorSetting resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - * @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 {@link protos.google.cloud.modelarmor.v1beta.FloorSetting|FloorSetting}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/model_armor.update_floor_setting.js - * region_tag:modelarmor_v1beta_generated_ModelArmor_UpdateFloorSetting_async - */ + /** + * Updates the parameters of a single floor setting of a project + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.modelarmor.v1beta.FloorSetting} request.floorSetting + * Required. The floor setting being updated. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask is used to specify the fields to be overwritten in the + * FloorSetting resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @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 {@link protos.google.cloud.modelarmor.v1beta.FloorSetting|FloorSetting}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/model_armor.update_floor_setting.js + * region_tag:modelarmor_v1beta_generated_ModelArmor_UpdateFloorSetting_async + */ updateFloorSetting( - request?: protos.google.cloud.modelarmor.v1beta.IUpdateFloorSettingRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.modelarmor.v1beta.IFloorSetting, - protos.google.cloud.modelarmor.v1beta.IUpdateFloorSettingRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.modelarmor.v1beta.IUpdateFloorSettingRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.modelarmor.v1beta.IFloorSetting, + ( + | protos.google.cloud.modelarmor.v1beta.IUpdateFloorSettingRequest + | undefined + ), + {} | undefined, + ] + >; updateFloorSetting( - request: protos.google.cloud.modelarmor.v1beta.IUpdateFloorSettingRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.modelarmor.v1beta.IFloorSetting, - protos.google.cloud.modelarmor.v1beta.IUpdateFloorSettingRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1beta.IUpdateFloorSettingRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.modelarmor.v1beta.IFloorSetting, + | protos.google.cloud.modelarmor.v1beta.IUpdateFloorSettingRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateFloorSetting( - request: protos.google.cloud.modelarmor.v1beta.IUpdateFloorSettingRequest, - callback: Callback< - protos.google.cloud.modelarmor.v1beta.IFloorSetting, - protos.google.cloud.modelarmor.v1beta.IUpdateFloorSettingRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1beta.IUpdateFloorSettingRequest, + callback: Callback< + protos.google.cloud.modelarmor.v1beta.IFloorSetting, + | protos.google.cloud.modelarmor.v1beta.IUpdateFloorSettingRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateFloorSetting( - request?: protos.google.cloud.modelarmor.v1beta.IUpdateFloorSettingRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.modelarmor.v1beta.IFloorSetting, - protos.google.cloud.modelarmor.v1beta.IUpdateFloorSettingRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.modelarmor.v1beta.IUpdateFloorSettingRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.modelarmor.v1beta.IFloorSetting, - protos.google.cloud.modelarmor.v1beta.IUpdateFloorSettingRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.modelarmor.v1beta.IFloorSetting, - protos.google.cloud.modelarmor.v1beta.IUpdateFloorSettingRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.modelarmor.v1beta.IUpdateFloorSettingRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.modelarmor.v1beta.IFloorSetting, + | protos.google.cloud.modelarmor.v1beta.IUpdateFloorSettingRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.modelarmor.v1beta.IFloorSetting, + ( + | protos.google.cloud.modelarmor.v1beta.IUpdateFloorSettingRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'floor_setting.name': request.floorSetting!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'floor_setting.name': request.floorSetting!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateFloorSetting request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.modelarmor.v1beta.IFloorSetting, - protos.google.cloud.modelarmor.v1beta.IUpdateFloorSettingRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.modelarmor.v1beta.IFloorSetting, + | protos.google.cloud.modelarmor.v1beta.IUpdateFloorSettingRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateFloorSetting response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateFloorSetting(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.modelarmor.v1beta.IFloorSetting, - protos.google.cloud.modelarmor.v1beta.IUpdateFloorSettingRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateFloorSetting response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .updateFloorSetting(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.modelarmor.v1beta.IFloorSetting, + ( + | protos.google.cloud.modelarmor.v1beta.IUpdateFloorSettingRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateFloorSetting response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Sanitizes User Prompt. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Represents resource name of template - * e.g. name=projects/sample-project/locations/us-central1/templates/templ01 - * @param {google.cloud.modelarmor.v1beta.DataItem} request.userPromptData - * Required. User prompt data to sanitize. - * @param {google.cloud.modelarmor.v1beta.MultiLanguageDetectionMetadata} [request.multiLanguageDetectionMetadata] - * Optional. Metadata related to Multi Language Detection. - * @param {google.cloud.modelarmor.v1beta.StreamingMode} [request.streamingMode] - * Optional. Streaming Mode for StreamSanitize* API. - * @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 {@link protos.google.cloud.modelarmor.v1beta.SanitizeUserPromptResponse|SanitizeUserPromptResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/model_armor.sanitize_user_prompt.js - * region_tag:modelarmor_v1beta_generated_ModelArmor_SanitizeUserPrompt_async - */ + /** + * Sanitizes User Prompt. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Represents resource name of template + * e.g. name=projects/sample-project/locations/us-central1/templates/templ01 + * @param {google.cloud.modelarmor.v1beta.DataItem} request.userPromptData + * Required. User prompt data to sanitize. + * @param {google.cloud.modelarmor.v1beta.MultiLanguageDetectionMetadata} [request.multiLanguageDetectionMetadata] + * Optional. Metadata related to Multi Language Detection. + * @param {google.cloud.modelarmor.v1beta.StreamingMode} [request.streamingMode] + * Optional. Streaming Mode for StreamSanitize* API. + * @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 {@link protos.google.cloud.modelarmor.v1beta.SanitizeUserPromptResponse|SanitizeUserPromptResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/model_armor.sanitize_user_prompt.js + * region_tag:modelarmor_v1beta_generated_ModelArmor_SanitizeUserPrompt_async + */ sanitizeUserPrompt( - request?: protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptResponse, - protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptResponse, + ( + | protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptRequest + | undefined + ), + {} | undefined, + ] + >; sanitizeUserPrompt( - request: protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptResponse, - protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptResponse, + | protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptRequest + | null + | undefined, + {} | null | undefined + >, + ): void; sanitizeUserPrompt( - request: protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptRequest, - callback: Callback< - protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptResponse, - protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptRequest, + callback: Callback< + protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptResponse, + | protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptRequest + | null + | undefined, + {} | null | undefined + >, + ): void; sanitizeUserPrompt( - request?: protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptResponse, - protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptResponse, - protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptResponse, - protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptResponse, + | protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptResponse, + ( + | protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('sanitizeUserPrompt request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptResponse, - protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptResponse, + | protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('sanitizeUserPrompt response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.sanitizeUserPrompt(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptResponse, - protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptRequest|undefined, - {}|undefined - ]) => { - this._log.info('sanitizeUserPrompt response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .sanitizeUserPrompt(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptResponse, + ( + | protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('sanitizeUserPrompt response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Sanitizes Model Response. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Represents resource name of template - * e.g. name=projects/sample-project/locations/us-central1/templates/templ01 - * @param {google.cloud.modelarmor.v1beta.DataItem} request.modelResponseData - * Required. Model response data to sanitize. - * @param {string} [request.userPrompt] - * Optional. User Prompt associated with Model response. - * @param {google.cloud.modelarmor.v1beta.MultiLanguageDetectionMetadata} [request.multiLanguageDetectionMetadata] - * Optional. Metadata related for multi language detection. - * @param {google.cloud.modelarmor.v1beta.StreamingMode} [request.streamingMode] - * Optional. Streaming Mode for StreamSanitize* API. - * @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 {@link protos.google.cloud.modelarmor.v1beta.SanitizeModelResponseResponse|SanitizeModelResponseResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/model_armor.sanitize_model_response.js - * region_tag:modelarmor_v1beta_generated_ModelArmor_SanitizeModelResponse_async - */ + /** + * Sanitizes Model Response. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Represents resource name of template + * e.g. name=projects/sample-project/locations/us-central1/templates/templ01 + * @param {google.cloud.modelarmor.v1beta.DataItem} request.modelResponseData + * Required. Model response data to sanitize. + * @param {string} [request.userPrompt] + * Optional. User Prompt associated with Model response. + * @param {google.cloud.modelarmor.v1beta.MultiLanguageDetectionMetadata} [request.multiLanguageDetectionMetadata] + * Optional. Metadata related for multi language detection. + * @param {google.cloud.modelarmor.v1beta.StreamingMode} [request.streamingMode] + * Optional. Streaming Mode for StreamSanitize* API. + * @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 {@link protos.google.cloud.modelarmor.v1beta.SanitizeModelResponseResponse|SanitizeModelResponseResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/model_armor.sanitize_model_response.js + * region_tag:modelarmor_v1beta_generated_ModelArmor_SanitizeModelResponse_async + */ sanitizeModelResponse( - request?: protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseResponse, - protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseResponse, + ( + | protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseRequest + | undefined + ), + {} | undefined, + ] + >; sanitizeModelResponse( - request: protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseResponse, - protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseResponse, + | protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseRequest + | null + | undefined, + {} | null | undefined + >, + ): void; sanitizeModelResponse( - request: protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseRequest, - callback: Callback< - protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseResponse, - protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseRequest, + callback: Callback< + protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseResponse, + | protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseRequest + | null + | undefined, + {} | null | undefined + >, + ): void; sanitizeModelResponse( - request?: protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseResponse, - protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseResponse, - protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseResponse, - protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseResponse, + | protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseResponse, + ( + | protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('sanitizeModelResponse request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseResponse, - protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseResponse, + | protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('sanitizeModelResponse response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.sanitizeModelResponse(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseResponse, - protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseRequest|undefined, - {}|undefined - ]) => { - this._log.info('sanitizeModelResponse response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .sanitizeModelResponse(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseResponse, + ( + | protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('sanitizeModelResponse response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Streaming version of Sanitize User Prompt. - * - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which is both readable and writable. It accepts objects - * representing {@link protos.google.cloud.modelarmor.v1beta.SanitizeUserPromptRequest|SanitizeUserPromptRequest} for write() method, and - * will emit objects representing {@link protos.google.cloud.modelarmor.v1beta.SanitizeUserPromptResponse|SanitizeUserPromptResponse} on 'data' event asynchronously. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/model_armor.stream_sanitize_user_prompt.js - * region_tag:modelarmor_v1beta_generated_ModelArmor_StreamSanitizeUserPrompt_async - */ - streamSanitizeUserPrompt( - options?: CallOptions): - gax.CancellableStream { - this.initialize().catch(err => {throw err}); + /** + * Streaming version of Sanitize User Prompt. + * + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which is both readable and writable. It accepts objects + * representing {@link protos.google.cloud.modelarmor.v1beta.SanitizeUserPromptRequest|SanitizeUserPromptRequest} for write() method, and + * will emit objects representing {@link protos.google.cloud.modelarmor.v1beta.SanitizeUserPromptResponse|SanitizeUserPromptResponse} on 'data' event asynchronously. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/model_armor.stream_sanitize_user_prompt.js + * region_tag:modelarmor_v1beta_generated_ModelArmor_StreamSanitizeUserPrompt_async + */ + streamSanitizeUserPrompt(options?: CallOptions): gax.CancellableStream { + this.initialize().catch((err) => { + throw err; + }); this._log.info('streamSanitizeUserPrompt stream %j', options); return this.innerApiCalls.streamSanitizeUserPrompt(null, options); } -/** - * Streaming version of Sanitizes Model Response. - * - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which is both readable and writable. It accepts objects - * representing {@link protos.google.cloud.modelarmor.v1beta.SanitizeModelResponseRequest|SanitizeModelResponseRequest} for write() method, and - * will emit objects representing {@link protos.google.cloud.modelarmor.v1beta.SanitizeModelResponseResponse|SanitizeModelResponseResponse} on 'data' event asynchronously. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/model_armor.stream_sanitize_model_response.js - * region_tag:modelarmor_v1beta_generated_ModelArmor_StreamSanitizeModelResponse_async - */ - streamSanitizeModelResponse( - options?: CallOptions): - gax.CancellableStream { - this.initialize().catch(err => {throw err}); + /** + * Streaming version of Sanitizes Model Response. + * + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which is both readable and writable. It accepts objects + * representing {@link protos.google.cloud.modelarmor.v1beta.SanitizeModelResponseRequest|SanitizeModelResponseRequest} for write() method, and + * will emit objects representing {@link protos.google.cloud.modelarmor.v1beta.SanitizeModelResponseResponse|SanitizeModelResponseResponse} on 'data' event asynchronously. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/model_armor.stream_sanitize_model_response.js + * region_tag:modelarmor_v1beta_generated_ModelArmor_StreamSanitizeModelResponse_async + */ + streamSanitizeModelResponse(options?: CallOptions): gax.CancellableStream { + this.initialize().catch((err) => { + throw err; + }); this._log.info('streamSanitizeModelResponse stream %j', options); return this.innerApiCalls.streamSanitizeModelResponse(null, options); } - /** - * Lists Templates in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListTemplatesRequest - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Filtering results - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results - * @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 Array of {@link protos.google.cloud.modelarmor.v1beta.Template|Template}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listTemplatesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists Templates in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListTemplatesRequest + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Filtering results + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results + * @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 Array of {@link protos.google.cloud.modelarmor.v1beta.Template|Template}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listTemplatesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listTemplates( - request?: protos.google.cloud.modelarmor.v1beta.IListTemplatesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.modelarmor.v1beta.ITemplate[], - protos.google.cloud.modelarmor.v1beta.IListTemplatesRequest|null, - protos.google.cloud.modelarmor.v1beta.IListTemplatesResponse - ]>; + request?: protos.google.cloud.modelarmor.v1beta.IListTemplatesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.modelarmor.v1beta.ITemplate[], + protos.google.cloud.modelarmor.v1beta.IListTemplatesRequest | null, + protos.google.cloud.modelarmor.v1beta.IListTemplatesResponse, + ] + >; listTemplates( - request: protos.google.cloud.modelarmor.v1beta.IListTemplatesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.modelarmor.v1beta.IListTemplatesRequest, - protos.google.cloud.modelarmor.v1beta.IListTemplatesResponse|null|undefined, - protos.google.cloud.modelarmor.v1beta.ITemplate>): void; + request: protos.google.cloud.modelarmor.v1beta.IListTemplatesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.modelarmor.v1beta.IListTemplatesRequest, + | protos.google.cloud.modelarmor.v1beta.IListTemplatesResponse + | null + | undefined, + protos.google.cloud.modelarmor.v1beta.ITemplate + >, + ): void; listTemplates( - request: protos.google.cloud.modelarmor.v1beta.IListTemplatesRequest, - callback: PaginationCallback< - protos.google.cloud.modelarmor.v1beta.IListTemplatesRequest, - protos.google.cloud.modelarmor.v1beta.IListTemplatesResponse|null|undefined, - protos.google.cloud.modelarmor.v1beta.ITemplate>): void; + request: protos.google.cloud.modelarmor.v1beta.IListTemplatesRequest, + callback: PaginationCallback< + protos.google.cloud.modelarmor.v1beta.IListTemplatesRequest, + | protos.google.cloud.modelarmor.v1beta.IListTemplatesResponse + | null + | undefined, + protos.google.cloud.modelarmor.v1beta.ITemplate + >, + ): void; listTemplates( - request?: protos.google.cloud.modelarmor.v1beta.IListTemplatesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.modelarmor.v1beta.IListTemplatesRequest, - protos.google.cloud.modelarmor.v1beta.IListTemplatesResponse|null|undefined, - protos.google.cloud.modelarmor.v1beta.ITemplate>, - callback?: PaginationCallback< + request?: protos.google.cloud.modelarmor.v1beta.IListTemplatesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.modelarmor.v1beta.IListTemplatesRequest, - protos.google.cloud.modelarmor.v1beta.IListTemplatesResponse|null|undefined, - protos.google.cloud.modelarmor.v1beta.ITemplate>): - Promise<[ - protos.google.cloud.modelarmor.v1beta.ITemplate[], - protos.google.cloud.modelarmor.v1beta.IListTemplatesRequest|null, - protos.google.cloud.modelarmor.v1beta.IListTemplatesResponse - ]>|void { + | protos.google.cloud.modelarmor.v1beta.IListTemplatesResponse + | null + | undefined, + protos.google.cloud.modelarmor.v1beta.ITemplate + >, + callback?: PaginationCallback< + protos.google.cloud.modelarmor.v1beta.IListTemplatesRequest, + | protos.google.cloud.modelarmor.v1beta.IListTemplatesResponse + | null + | undefined, + protos.google.cloud.modelarmor.v1beta.ITemplate + >, + ): Promise< + [ + protos.google.cloud.modelarmor.v1beta.ITemplate[], + protos.google.cloud.modelarmor.v1beta.IListTemplatesRequest | null, + protos.google.cloud.modelarmor.v1beta.IListTemplatesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.modelarmor.v1beta.IListTemplatesRequest, - protos.google.cloud.modelarmor.v1beta.IListTemplatesResponse|null|undefined, - protos.google.cloud.modelarmor.v1beta.ITemplate>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.modelarmor.v1beta.IListTemplatesRequest, + | protos.google.cloud.modelarmor.v1beta.IListTemplatesResponse + | null + | undefined, + protos.google.cloud.modelarmor.v1beta.ITemplate + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listTemplates values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1340,119 +1798,124 @@ export class ModelArmorClient { this._log.info('listTemplates request %j', request); return this.innerApiCalls .listTemplates(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.modelarmor.v1beta.ITemplate[], - protos.google.cloud.modelarmor.v1beta.IListTemplatesRequest|null, - protos.google.cloud.modelarmor.v1beta.IListTemplatesResponse - ]) => { - this._log.info('listTemplates values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.modelarmor.v1beta.ITemplate[], + protos.google.cloud.modelarmor.v1beta.IListTemplatesRequest | null, + protos.google.cloud.modelarmor.v1beta.IListTemplatesResponse, + ]) => { + this._log.info('listTemplates values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listTemplates`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListTemplatesRequest - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Filtering results - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.modelarmor.v1beta.Template|Template} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listTemplatesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listTemplates`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListTemplatesRequest + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Filtering results + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.modelarmor.v1beta.Template|Template} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listTemplatesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listTemplatesStream( - request?: protos.google.cloud.modelarmor.v1beta.IListTemplatesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.modelarmor.v1beta.IListTemplatesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listTemplates']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listTemplates stream %j', request); return this.descriptors.page.listTemplates.createStream( this.innerApiCalls.listTemplates as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listTemplates`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListTemplatesRequest - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Filtering results - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.modelarmor.v1beta.Template|Template}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/model_armor.list_templates.js - * region_tag:modelarmor_v1beta_generated_ModelArmor_ListTemplates_async - */ + /** + * Equivalent to `listTemplates`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListTemplatesRequest + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Filtering results + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.modelarmor.v1beta.Template|Template}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/model_armor.list_templates.js + * region_tag:modelarmor_v1beta_generated_ModelArmor_ListTemplates_async + */ listTemplatesAsync( - request?: protos.google.cloud.modelarmor.v1beta.IListTemplatesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.modelarmor.v1beta.IListTemplatesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listTemplates']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listTemplates iterate %j', request); return this.descriptors.page.listTemplates.asyncIterate( this.innerApiCalls['listTemplates'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** + + /** * Gets information about a location. * * @param {Object} request @@ -1487,12 +1950,11 @@ export class ModelArmorClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -1525,7 +1987,7 @@ export class ModelArmorClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -1541,7 +2003,7 @@ export class ModelArmorClient { * @param {string} location * @returns {string} Resource name string. */ - folderLocationFloorSettingPath(folder:string,location:string) { + folderLocationFloorSettingPath(folder: string, location: string) { return this.pathTemplates.folderLocationFloorSettingPathTemplate.render({ folder: folder, location: location, @@ -1555,8 +2017,12 @@ export class ModelArmorClient { * A fully-qualified path representing folder_location_floorSetting resource. * @returns {string} A string representing the folder. */ - matchFolderFromFolderLocationFloorSettingName(folderLocationFloorSettingName: string) { - return this.pathTemplates.folderLocationFloorSettingPathTemplate.match(folderLocationFloorSettingName).folder; + matchFolderFromFolderLocationFloorSettingName( + folderLocationFloorSettingName: string, + ) { + return this.pathTemplates.folderLocationFloorSettingPathTemplate.match( + folderLocationFloorSettingName, + ).folder; } /** @@ -1566,8 +2032,12 @@ export class ModelArmorClient { * A fully-qualified path representing folder_location_floorSetting resource. * @returns {string} A string representing the location. */ - matchLocationFromFolderLocationFloorSettingName(folderLocationFloorSettingName: string) { - return this.pathTemplates.folderLocationFloorSettingPathTemplate.match(folderLocationFloorSettingName).location; + matchLocationFromFolderLocationFloorSettingName( + folderLocationFloorSettingName: string, + ) { + return this.pathTemplates.folderLocationFloorSettingPathTemplate.match( + folderLocationFloorSettingName, + ).location; } /** @@ -1577,7 +2047,7 @@ export class ModelArmorClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -1613,11 +2083,13 @@ export class ModelArmorClient { * @param {string} location * @returns {string} Resource name string. */ - organizationLocationFloorSettingPath(organization:string,location:string) { - return this.pathTemplates.organizationLocationFloorSettingPathTemplate.render({ - organization: organization, - location: location, - }); + organizationLocationFloorSettingPath(organization: string, location: string) { + return this.pathTemplates.organizationLocationFloorSettingPathTemplate.render( + { + organization: organization, + location: location, + }, + ); } /** @@ -1627,8 +2099,12 @@ export class ModelArmorClient { * A fully-qualified path representing organization_location_floorSetting resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationLocationFloorSettingName(organizationLocationFloorSettingName: string) { - return this.pathTemplates.organizationLocationFloorSettingPathTemplate.match(organizationLocationFloorSettingName).organization; + matchOrganizationFromOrganizationLocationFloorSettingName( + organizationLocationFloorSettingName: string, + ) { + return this.pathTemplates.organizationLocationFloorSettingPathTemplate.match( + organizationLocationFloorSettingName, + ).organization; } /** @@ -1638,8 +2114,12 @@ export class ModelArmorClient { * A fully-qualified path representing organization_location_floorSetting resource. * @returns {string} A string representing the location. */ - matchLocationFromOrganizationLocationFloorSettingName(organizationLocationFloorSettingName: string) { - return this.pathTemplates.organizationLocationFloorSettingPathTemplate.match(organizationLocationFloorSettingName).location; + matchLocationFromOrganizationLocationFloorSettingName( + organizationLocationFloorSettingName: string, + ) { + return this.pathTemplates.organizationLocationFloorSettingPathTemplate.match( + organizationLocationFloorSettingName, + ).location; } /** @@ -1648,7 +2128,7 @@ export class ModelArmorClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -1672,7 +2152,7 @@ export class ModelArmorClient { * @param {string} location * @returns {string} Resource name string. */ - projectLocationFloorSettingPath(project:string,location:string) { + projectLocationFloorSettingPath(project: string, location: string) { return this.pathTemplates.projectLocationFloorSettingPathTemplate.render({ project: project, location: location, @@ -1686,8 +2166,12 @@ export class ModelArmorClient { * A fully-qualified path representing project_location_floorSetting resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectLocationFloorSettingName(projectLocationFloorSettingName: string) { - return this.pathTemplates.projectLocationFloorSettingPathTemplate.match(projectLocationFloorSettingName).project; + matchProjectFromProjectLocationFloorSettingName( + projectLocationFloorSettingName: string, + ) { + return this.pathTemplates.projectLocationFloorSettingPathTemplate.match( + projectLocationFloorSettingName, + ).project; } /** @@ -1697,8 +2181,12 @@ export class ModelArmorClient { * A fully-qualified path representing project_location_floorSetting resource. * @returns {string} A string representing the location. */ - matchLocationFromProjectLocationFloorSettingName(projectLocationFloorSettingName: string) { - return this.pathTemplates.projectLocationFloorSettingPathTemplate.match(projectLocationFloorSettingName).location; + matchLocationFromProjectLocationFloorSettingName( + projectLocationFloorSettingName: string, + ) { + return this.pathTemplates.projectLocationFloorSettingPathTemplate.match( + projectLocationFloorSettingName, + ).location; } /** @@ -1709,7 +2197,7 @@ export class ModelArmorClient { * @param {string} template * @returns {string} Resource name string. */ - templatePath(project:string,location:string,template:string) { + templatePath(project: string, location: string, template: string) { return this.pathTemplates.templatePathTemplate.render({ project: project, location: location, @@ -1758,13 +2246,15 @@ export class ModelArmorClient { */ close(): Promise { if (this.modelArmorStub && !this._terminated) { - return this.modelArmorStub.then(stub => { + return this.modelArmorStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.locationsClient.close().catch(err => {throw err}); + this.locationsClient.close().catch((err) => { + throw err; + }); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-modelarmor/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-modelarmor/system-test/fixtures/sample/src/index.ts index db6249209557..1093673611e0 100644 --- a/packages/google-cloud-modelarmor/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-modelarmor/system-test/fixtures/sample/src/index.ts @@ -16,7 +16,7 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {ModelArmorClient} from '@google-cloud/modelarmor'; +import { ModelArmorClient } from '@google-cloud/modelarmor'; // check that the client class type name can be used function doStuffWithModelArmorClient(client: ModelArmorClient) { diff --git a/packages/google-cloud-modelarmor/system-test/install.ts b/packages/google-cloud-modelarmor/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-modelarmor/system-test/install.ts +++ b/packages/google-cloud-modelarmor/system-test/install.ts @@ -16,34 +16,36 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {packNTest} from 'pack-n-play'; -import {readFileSync} from 'fs'; -import {describe, it} from 'mocha'; +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; +import { describe, it } from 'mocha'; describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { + it('TypeScript code', async function () { this.timeout(300000); const options = { packageDir: process.cwd(), sample: { description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } + ts: readFileSync( + './system-test/fixtures/sample/src/index.ts', + ).toString(), + }, }; await packNTest(options); }); - it('JavaScript code', async function() { + it('JavaScript code', async function () { this.timeout(300000); const options = { packageDir: process.cwd(), sample: { description: 'JavaScript user can use the library', - cjs: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } + cjs: readFileSync( + './system-test/fixtures/sample/src/index.js', + ).toString(), + }, }; await packNTest(options); }); - }); diff --git a/packages/google-cloud-modelarmor/test/gapic_model_armor_v1.ts b/packages/google-cloud-modelarmor/test/gapic_model_armor_v1.ts index 0208442ea202..b3e0a98c70f9 100644 --- a/packages/google-cloud-modelarmor/test/gapic_model_armor_v1.ts +++ b/packages/google-cloud-modelarmor/test/gapic_model_armor_v1.ts @@ -19,1757 +19,2214 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as modelarmorModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LocationProtos} from 'google-gax'; +import { protobuf, LocationProtos } from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1.ModelArmorClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new modelarmorModule.v1.ModelArmorClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'modelarmor.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new modelarmorModule.v1.ModelArmorClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = modelarmorModule.v1.ModelArmorClient.servicePath; - assert.strictEqual(servicePath, 'modelarmor.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = modelarmorModule.v1.ModelArmorClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'modelarmor.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new modelarmorModule.v1.ModelArmorClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'modelarmor.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new modelarmorModule.v1.ModelArmorClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'modelarmor.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new modelarmorModule.v1.ModelArmorClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'modelarmor.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new modelarmorModule.v1.ModelArmorClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'modelarmor.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new modelarmorModule.v1.ModelArmorClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = modelarmorModule.v1.ModelArmorClient.port; - assert(port); - assert(typeof port === 'number'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new modelarmorModule.v1.ModelArmorClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'modelarmor.googleapis.com'); + }); - it('should create a client with no option', () => { - const client = new modelarmorModule.v1.ModelArmorClient(); - assert(client); - }); + it('has universeDomain', () => { + const client = new modelarmorModule.v1.ModelArmorClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - fallback: true, - }); - assert(client); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = modelarmorModule.v1.ModelArmorClient.servicePath; + assert.strictEqual(servicePath, 'modelarmor.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = modelarmorModule.v1.ModelArmorClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'modelarmor.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'modelarmor.example.com'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.modelArmorStub, undefined); - await client.initialize(); - assert(client.modelArmorStub); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'modelarmor.example.com'); + }); - it('has close method for the initialized client', done => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.modelArmorStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new modelarmorModule.v1.ModelArmorClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'modelarmor.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('has close method for the non-initialized client', done => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.modelArmorStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new modelarmorModule.v1.ModelArmorClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'modelarmor.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new modelarmorModule.v1.ModelArmorClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); + it('has port', () => { + const port = modelarmorModule.v1.ModelArmorClient.port; + assert(port); + assert(typeof port === 'number'); }); - describe('getTemplate', () => { - it('invokes getTemplate without error', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.GetTemplateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.GetTemplateRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.Template() - ); - client.innerApiCalls.getTemplate = stubSimpleCall(expectedResponse); - const [response] = await client.getTemplate(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTemplate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTemplate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('should create a client with no option', () => { + const client = new modelarmorModule.v1.ModelArmorClient(); + assert(client); + }); - it('invokes getTemplate without error using callback', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.GetTemplateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.GetTemplateRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.Template() - ); - client.innerApiCalls.getTemplate = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getTemplate( - request, - (err?: Error|null, result?: protos.google.cloud.modelarmor.v1.ITemplate|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTemplate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTemplate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('should create a client with gRPC fallback', () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + fallback: true, + }); + assert(client); + }); - it('invokes getTemplate with error', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.GetTemplateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.GetTemplateRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getTemplate = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getTemplate(request), expectedError); - const actualRequest = (client.innerApiCalls.getTemplate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTemplate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.modelArmorStub, undefined); + await client.initialize(); + assert(client.modelArmorStub); + }); - it('invokes getTemplate with closed client', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.GetTemplateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.GetTemplateRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getTemplate(request), expectedError); + it('has close method for the initialized client', (done) => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.modelArmorStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('createTemplate', () => { - it('invokes createTemplate without error', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.CreateTemplateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.CreateTemplateRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.Template() - ); - client.innerApiCalls.createTemplate = stubSimpleCall(expectedResponse); - const [response] = await client.createTemplate(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createTemplate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTemplate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the non-initialized client', (done) => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.modelArmorStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes createTemplate without error using callback', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.CreateTemplateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.CreateTemplateRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.Template() - ); - client.innerApiCalls.createTemplate = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createTemplate( - request, - (err?: Error|null, result?: protos.google.cloud.modelarmor.v1.ITemplate|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createTemplate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTemplate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('invokes createTemplate with error', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.CreateTemplateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.CreateTemplateRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createTemplate = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createTemplate(request), expectedError); - const actualRequest = (client.innerApiCalls.createTemplate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTemplate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getTemplate', () => { + it('invokes getTemplate without error', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.GetTemplateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.GetTemplateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.Template(), + ); + client.innerApiCalls.getTemplate = stubSimpleCall(expectedResponse); + const [response] = await client.getTemplate(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getTemplate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTemplate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createTemplate with closed client', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.CreateTemplateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.CreateTemplateRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createTemplate(request), expectedError); - }); + it('invokes getTemplate without error using callback', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.GetTemplateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.GetTemplateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.Template(), + ); + client.innerApiCalls.getTemplate = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getTemplate( + request, + ( + err?: Error | null, + result?: protos.google.cloud.modelarmor.v1.ITemplate | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getTemplate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTemplate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateTemplate', () => { - it('invokes updateTemplate without error', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.UpdateTemplateRequest() - ); - request.template ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.UpdateTemplateRequest', ['template', 'name']); - request.template.name = defaultValue1; - const expectedHeaderRequestParams = `template.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.Template() - ); - client.innerApiCalls.updateTemplate = stubSimpleCall(expectedResponse); - const [response] = await client.updateTemplate(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateTemplate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTemplate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getTemplate with error', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.GetTemplateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.GetTemplateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getTemplate = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getTemplate(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getTemplate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTemplate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateTemplate without error using callback', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.UpdateTemplateRequest() - ); - request.template ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.UpdateTemplateRequest', ['template', 'name']); - request.template.name = defaultValue1; - const expectedHeaderRequestParams = `template.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.Template() - ); - client.innerApiCalls.updateTemplate = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateTemplate( - request, - (err?: Error|null, result?: protos.google.cloud.modelarmor.v1.ITemplate|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateTemplate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTemplate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getTemplate with closed client', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.GetTemplateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.GetTemplateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getTemplate(request), expectedError); + }); + }); + + describe('createTemplate', () => { + it('invokes createTemplate without error', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.CreateTemplateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.CreateTemplateRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.Template(), + ); + client.innerApiCalls.createTemplate = stubSimpleCall(expectedResponse); + const [response] = await client.createTemplate(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createTemplate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTemplate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateTemplate with error', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.UpdateTemplateRequest() - ); - request.template ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.UpdateTemplateRequest', ['template', 'name']); - request.template.name = defaultValue1; - const expectedHeaderRequestParams = `template.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateTemplate = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateTemplate(request), expectedError); - const actualRequest = (client.innerApiCalls.updateTemplate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTemplate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createTemplate without error using callback', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.CreateTemplateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.CreateTemplateRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.Template(), + ); + client.innerApiCalls.createTemplate = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createTemplate( + request, + ( + err?: Error | null, + result?: protos.google.cloud.modelarmor.v1.ITemplate | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createTemplate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTemplate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateTemplate with closed client', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.UpdateTemplateRequest() - ); - request.template ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.UpdateTemplateRequest', ['template', 'name']); - request.template.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateTemplate(request), expectedError); - }); + it('invokes createTemplate with error', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.CreateTemplateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.CreateTemplateRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createTemplate = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createTemplate(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createTemplate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTemplate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteTemplate', () => { - it('invokes deleteTemplate without error', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.DeleteTemplateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.DeleteTemplateRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteTemplate = stubSimpleCall(expectedResponse); - const [response] = await client.deleteTemplate(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteTemplate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTemplate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createTemplate with closed client', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.CreateTemplateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.CreateTemplateRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createTemplate(request), expectedError); + }); + }); + + describe('updateTemplate', () => { + it('invokes updateTemplate without error', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.UpdateTemplateRequest(), + ); + request.template ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.UpdateTemplateRequest', + ['template', 'name'], + ); + request.template.name = defaultValue1; + const expectedHeaderRequestParams = `template.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.Template(), + ); + client.innerApiCalls.updateTemplate = stubSimpleCall(expectedResponse); + const [response] = await client.updateTemplate(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateTemplate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTemplate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTemplate without error using callback', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.DeleteTemplateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.DeleteTemplateRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteTemplate = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteTemplate( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteTemplate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTemplate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateTemplate without error using callback', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.UpdateTemplateRequest(), + ); + request.template ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.UpdateTemplateRequest', + ['template', 'name'], + ); + request.template.name = defaultValue1; + const expectedHeaderRequestParams = `template.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.Template(), + ); + client.innerApiCalls.updateTemplate = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateTemplate( + request, + ( + err?: Error | null, + result?: protos.google.cloud.modelarmor.v1.ITemplate | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateTemplate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTemplate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTemplate with error', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.DeleteTemplateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.DeleteTemplateRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteTemplate = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteTemplate(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteTemplate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTemplate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateTemplate with error', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.UpdateTemplateRequest(), + ); + request.template ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.UpdateTemplateRequest', + ['template', 'name'], + ); + request.template.name = defaultValue1; + const expectedHeaderRequestParams = `template.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateTemplate = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateTemplate(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateTemplate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTemplate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTemplate with closed client', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.DeleteTemplateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.DeleteTemplateRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteTemplate(request), expectedError); - }); + it('invokes updateTemplate with closed client', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.UpdateTemplateRequest(), + ); + request.template ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.UpdateTemplateRequest', + ['template', 'name'], + ); + request.template.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateTemplate(request), expectedError); + }); + }); + + describe('deleteTemplate', () => { + it('invokes deleteTemplate without error', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.DeleteTemplateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.DeleteTemplateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteTemplate = stubSimpleCall(expectedResponse); + const [response] = await client.deleteTemplate(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteTemplate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTemplate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getFloorSetting', () => { - it('invokes getFloorSetting without error', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.GetFloorSettingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.GetFloorSettingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.FloorSetting() - ); - client.innerApiCalls.getFloorSetting = stubSimpleCall(expectedResponse); - const [response] = await client.getFloorSetting(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getFloorSetting as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getFloorSetting as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteTemplate without error using callback', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.DeleteTemplateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.DeleteTemplateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteTemplate = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteTemplate( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteTemplate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTemplate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getFloorSetting without error using callback', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.GetFloorSettingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.GetFloorSettingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.FloorSetting() - ); - client.innerApiCalls.getFloorSetting = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getFloorSetting( - request, - (err?: Error|null, result?: protos.google.cloud.modelarmor.v1.IFloorSetting|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getFloorSetting as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getFloorSetting as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteTemplate with error', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.DeleteTemplateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.DeleteTemplateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteTemplate = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteTemplate(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteTemplate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTemplate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getFloorSetting with error', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.GetFloorSettingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.GetFloorSettingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getFloorSetting = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getFloorSetting(request), expectedError); - const actualRequest = (client.innerApiCalls.getFloorSetting as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getFloorSetting as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteTemplate with closed client', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.DeleteTemplateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.DeleteTemplateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deleteTemplate(request), expectedError); + }); + }); + + describe('getFloorSetting', () => { + it('invokes getFloorSetting without error', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.GetFloorSettingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.GetFloorSettingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.FloorSetting(), + ); + client.innerApiCalls.getFloorSetting = stubSimpleCall(expectedResponse); + const [response] = await client.getFloorSetting(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getFloorSetting as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFloorSetting as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getFloorSetting with closed client', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.GetFloorSettingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.GetFloorSettingRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getFloorSetting(request), expectedError); - }); + it('invokes getFloorSetting without error using callback', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.GetFloorSettingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.GetFloorSettingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.FloorSetting(), + ); + client.innerApiCalls.getFloorSetting = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getFloorSetting( + request, + ( + err?: Error | null, + result?: protos.google.cloud.modelarmor.v1.IFloorSetting | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getFloorSetting as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFloorSetting as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateFloorSetting', () => { - it('invokes updateFloorSetting without error', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.UpdateFloorSettingRequest() - ); - request.floorSetting ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.UpdateFloorSettingRequest', ['floorSetting', 'name']); - request.floorSetting.name = defaultValue1; - const expectedHeaderRequestParams = `floor_setting.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.FloorSetting() - ); - client.innerApiCalls.updateFloorSetting = stubSimpleCall(expectedResponse); - const [response] = await client.updateFloorSetting(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateFloorSetting as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFloorSetting as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getFloorSetting with error', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.GetFloorSettingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.GetFloorSettingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getFloorSetting = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getFloorSetting(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getFloorSetting as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFloorSetting as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateFloorSetting without error using callback', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.UpdateFloorSettingRequest() - ); - request.floorSetting ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.UpdateFloorSettingRequest', ['floorSetting', 'name']); - request.floorSetting.name = defaultValue1; - const expectedHeaderRequestParams = `floor_setting.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.FloorSetting() - ); - client.innerApiCalls.updateFloorSetting = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateFloorSetting( - request, - (err?: Error|null, result?: protos.google.cloud.modelarmor.v1.IFloorSetting|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateFloorSetting as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFloorSetting as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getFloorSetting with closed client', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.GetFloorSettingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.GetFloorSettingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getFloorSetting(request), expectedError); + }); + }); + + describe('updateFloorSetting', () => { + it('invokes updateFloorSetting without error', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.UpdateFloorSettingRequest(), + ); + request.floorSetting ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.UpdateFloorSettingRequest', + ['floorSetting', 'name'], + ); + request.floorSetting.name = defaultValue1; + const expectedHeaderRequestParams = `floor_setting.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.FloorSetting(), + ); + client.innerApiCalls.updateFloorSetting = + stubSimpleCall(expectedResponse); + const [response] = await client.updateFloorSetting(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateFloorSetting as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFloorSetting as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateFloorSetting with error', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.UpdateFloorSettingRequest() - ); - request.floorSetting ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.UpdateFloorSettingRequest', ['floorSetting', 'name']); - request.floorSetting.name = defaultValue1; - const expectedHeaderRequestParams = `floor_setting.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateFloorSetting = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateFloorSetting(request), expectedError); - const actualRequest = (client.innerApiCalls.updateFloorSetting as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFloorSetting as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateFloorSetting without error using callback', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.UpdateFloorSettingRequest(), + ); + request.floorSetting ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.UpdateFloorSettingRequest', + ['floorSetting', 'name'], + ); + request.floorSetting.name = defaultValue1; + const expectedHeaderRequestParams = `floor_setting.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.FloorSetting(), + ); + client.innerApiCalls.updateFloorSetting = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateFloorSetting( + request, + ( + err?: Error | null, + result?: protos.google.cloud.modelarmor.v1.IFloorSetting | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateFloorSetting as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFloorSetting as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateFloorSetting with closed client', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.UpdateFloorSettingRequest() - ); - request.floorSetting ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.UpdateFloorSettingRequest', ['floorSetting', 'name']); - request.floorSetting.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateFloorSetting(request), expectedError); - }); + it('invokes updateFloorSetting with error', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.UpdateFloorSettingRequest(), + ); + request.floorSetting ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.UpdateFloorSettingRequest', + ['floorSetting', 'name'], + ); + request.floorSetting.name = defaultValue1; + const expectedHeaderRequestParams = `floor_setting.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateFloorSetting = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateFloorSetting(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateFloorSetting as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFloorSetting as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('sanitizeUserPrompt', () => { - it('invokes sanitizeUserPrompt without error', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.SanitizeUserPromptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.SanitizeUserPromptRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.SanitizeUserPromptResponse() - ); - client.innerApiCalls.sanitizeUserPrompt = stubSimpleCall(expectedResponse); - const [response] = await client.sanitizeUserPrompt(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.sanitizeUserPrompt as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.sanitizeUserPrompt as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateFloorSetting with closed client', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.UpdateFloorSettingRequest(), + ); + request.floorSetting ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.UpdateFloorSettingRequest', + ['floorSetting', 'name'], + ); + request.floorSetting.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateFloorSetting(request), expectedError); + }); + }); + + describe('sanitizeUserPrompt', () => { + it('invokes sanitizeUserPrompt without error', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.SanitizeUserPromptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.SanitizeUserPromptRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.SanitizeUserPromptResponse(), + ); + client.innerApiCalls.sanitizeUserPrompt = + stubSimpleCall(expectedResponse); + const [response] = await client.sanitizeUserPrompt(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.sanitizeUserPrompt as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.sanitizeUserPrompt as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes sanitizeUserPrompt without error using callback', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.SanitizeUserPromptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.SanitizeUserPromptRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.SanitizeUserPromptResponse() - ); - client.innerApiCalls.sanitizeUserPrompt = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.sanitizeUserPrompt( - request, - (err?: Error|null, result?: protos.google.cloud.modelarmor.v1.ISanitizeUserPromptResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.sanitizeUserPrompt as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.sanitizeUserPrompt as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes sanitizeUserPrompt without error using callback', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.SanitizeUserPromptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.SanitizeUserPromptRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.SanitizeUserPromptResponse(), + ); + client.innerApiCalls.sanitizeUserPrompt = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.sanitizeUserPrompt( + request, + ( + err?: Error | null, + result?: protos.google.cloud.modelarmor.v1.ISanitizeUserPromptResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.sanitizeUserPrompt as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.sanitizeUserPrompt as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes sanitizeUserPrompt with error', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.SanitizeUserPromptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.SanitizeUserPromptRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.sanitizeUserPrompt = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.sanitizeUserPrompt(request), expectedError); - const actualRequest = (client.innerApiCalls.sanitizeUserPrompt as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.sanitizeUserPrompt as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes sanitizeUserPrompt with error', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.SanitizeUserPromptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.SanitizeUserPromptRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.sanitizeUserPrompt = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.sanitizeUserPrompt(request), expectedError); + const actualRequest = ( + client.innerApiCalls.sanitizeUserPrompt as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.sanitizeUserPrompt as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes sanitizeUserPrompt with closed client', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.SanitizeUserPromptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.SanitizeUserPromptRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.sanitizeUserPrompt(request), expectedError); - }); + it('invokes sanitizeUserPrompt with closed client', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.SanitizeUserPromptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.SanitizeUserPromptRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.sanitizeUserPrompt(request), expectedError); + }); + }); + + describe('sanitizeModelResponse', () => { + it('invokes sanitizeModelResponse without error', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.SanitizeModelResponseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.SanitizeModelResponseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.SanitizeModelResponseResponse(), + ); + client.innerApiCalls.sanitizeModelResponse = + stubSimpleCall(expectedResponse); + const [response] = await client.sanitizeModelResponse(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.sanitizeModelResponse as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.sanitizeModelResponse as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('sanitizeModelResponse', () => { - it('invokes sanitizeModelResponse without error', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.SanitizeModelResponseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.SanitizeModelResponseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.SanitizeModelResponseResponse() - ); - client.innerApiCalls.sanitizeModelResponse = stubSimpleCall(expectedResponse); - const [response] = await client.sanitizeModelResponse(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.sanitizeModelResponse as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.sanitizeModelResponse as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes sanitizeModelResponse without error using callback', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.SanitizeModelResponseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.SanitizeModelResponseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.SanitizeModelResponseResponse(), + ); + client.innerApiCalls.sanitizeModelResponse = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.sanitizeModelResponse( + request, + ( + err?: Error | null, + result?: protos.google.cloud.modelarmor.v1.ISanitizeModelResponseResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.sanitizeModelResponse as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.sanitizeModelResponse as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes sanitizeModelResponse without error using callback', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.SanitizeModelResponseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.SanitizeModelResponseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.SanitizeModelResponseResponse() - ); - client.innerApiCalls.sanitizeModelResponse = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.sanitizeModelResponse( - request, - (err?: Error|null, result?: protos.google.cloud.modelarmor.v1.ISanitizeModelResponseResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.sanitizeModelResponse as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.sanitizeModelResponse as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes sanitizeModelResponse with error', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.SanitizeModelResponseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.SanitizeModelResponseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.sanitizeModelResponse = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.sanitizeModelResponse(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.sanitizeModelResponse as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.sanitizeModelResponse as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes sanitizeModelResponse with error', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.SanitizeModelResponseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.SanitizeModelResponseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.sanitizeModelResponse = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.sanitizeModelResponse(request), expectedError); - const actualRequest = (client.innerApiCalls.sanitizeModelResponse as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.sanitizeModelResponse as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes sanitizeModelResponse with closed client', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.SanitizeModelResponseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.SanitizeModelResponseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.sanitizeModelResponse(request), + expectedError, + ); + }); + }); + + describe('listTemplates', () => { + it('invokes listTemplates without error', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.ListTemplatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.ListTemplatesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.modelarmor.v1.Template()), + generateSampleMessage(new protos.google.cloud.modelarmor.v1.Template()), + generateSampleMessage(new protos.google.cloud.modelarmor.v1.Template()), + ]; + client.innerApiCalls.listTemplates = stubSimpleCall(expectedResponse); + const [response] = await client.listTemplates(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listTemplates as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTemplates as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes sanitizeModelResponse with closed client', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.SanitizeModelResponseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.SanitizeModelResponseRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.sanitizeModelResponse(request), expectedError); - }); + it('invokes listTemplates without error using callback', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.ListTemplatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.ListTemplatesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.modelarmor.v1.Template()), + generateSampleMessage(new protos.google.cloud.modelarmor.v1.Template()), + generateSampleMessage(new protos.google.cloud.modelarmor.v1.Template()), + ]; + client.innerApiCalls.listTemplates = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listTemplates( + request, + ( + err?: Error | null, + result?: protos.google.cloud.modelarmor.v1.ITemplate[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listTemplates as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTemplates as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listTemplates', () => { - it('invokes listTemplates without error', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.ListTemplatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.ListTemplatesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.modelarmor.v1.Template()), - generateSampleMessage(new protos.google.cloud.modelarmor.v1.Template()), - generateSampleMessage(new protos.google.cloud.modelarmor.v1.Template()), - ]; - client.innerApiCalls.listTemplates = stubSimpleCall(expectedResponse); - const [response] = await client.listTemplates(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTemplates as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTemplates as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listTemplates with error', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.ListTemplatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.ListTemplatesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listTemplates = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listTemplates(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listTemplates as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTemplates as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listTemplates without error using callback', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.ListTemplatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.ListTemplatesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.modelarmor.v1.Template()), - generateSampleMessage(new protos.google.cloud.modelarmor.v1.Template()), - generateSampleMessage(new protos.google.cloud.modelarmor.v1.Template()), - ]; - client.innerApiCalls.listTemplates = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listTemplates( - request, - (err?: Error|null, result?: protos.google.cloud.modelarmor.v1.ITemplate[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTemplates as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTemplates as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listTemplatesStream without error', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.ListTemplatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.ListTemplatesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.modelarmor.v1.Template()), + generateSampleMessage(new protos.google.cloud.modelarmor.v1.Template()), + generateSampleMessage(new protos.google.cloud.modelarmor.v1.Template()), + ]; + client.descriptors.page.listTemplates.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listTemplatesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.modelarmor.v1.Template[] = []; + stream.on( + 'data', + (response: protos.google.cloud.modelarmor.v1.Template) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listTemplates with error', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.ListTemplatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.ListTemplatesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listTemplates = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listTemplates(request), expectedError); - const actualRequest = (client.innerApiCalls.listTemplates as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTemplates as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + stream.on('error', (err: Error) => { + reject(err); }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listTemplates.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listTemplates, request), + ); + assert( + (client.descriptors.page.listTemplates.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listTemplatesStream without error', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.ListTemplatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.ListTemplatesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.modelarmor.v1.Template()), - generateSampleMessage(new protos.google.cloud.modelarmor.v1.Template()), - generateSampleMessage(new protos.google.cloud.modelarmor.v1.Template()), - ]; - client.descriptors.page.listTemplates.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listTemplatesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.modelarmor.v1.Template[] = []; - stream.on('data', (response: protos.google.cloud.modelarmor.v1.Template) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listTemplates.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTemplates, request)); - assert( - (client.descriptors.page.listTemplates.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('invokes listTemplatesStream with error', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.ListTemplatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.ListTemplatesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTemplates.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listTemplatesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.modelarmor.v1.Template[] = []; + stream.on( + 'data', + (response: protos.google.cloud.modelarmor.v1.Template) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listTemplatesStream with error', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.ListTemplatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.ListTemplatesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listTemplates.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listTemplatesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.modelarmor.v1.Template[] = []; - stream.on('data', (response: protos.google.cloud.modelarmor.v1.Template) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listTemplates.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTemplates, request)); - assert( - (client.descriptors.page.listTemplates.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + stream.on('error', (err: Error) => { + reject(err); }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listTemplates.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listTemplates, request), + ); + assert( + (client.descriptors.page.listTemplates.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listTemplates without error', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.ListTemplatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.ListTemplatesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.modelarmor.v1.Template()), - generateSampleMessage(new protos.google.cloud.modelarmor.v1.Template()), - generateSampleMessage(new protos.google.cloud.modelarmor.v1.Template()), - ]; - client.descriptors.page.listTemplates.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.modelarmor.v1.ITemplate[] = []; - const iterable = client.listTemplatesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listTemplates.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTemplates.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listTemplates without error', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.ListTemplatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.ListTemplatesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.modelarmor.v1.Template()), + generateSampleMessage(new protos.google.cloud.modelarmor.v1.Template()), + generateSampleMessage(new protos.google.cloud.modelarmor.v1.Template()), + ]; + client.descriptors.page.listTemplates.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.modelarmor.v1.ITemplate[] = []; + const iterable = client.listTemplatesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listTemplates.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listTemplates.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listTemplates with error', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1.ListTemplatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1.ListTemplatesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listTemplates.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listTemplatesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.modelarmor.v1.ITemplate[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listTemplates.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTemplates.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listTemplates with error', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1.ListTemplatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1.ListTemplatesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTemplates.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listTemplatesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.modelarmor.v1.ITemplate[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listTemplates.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listTemplates.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes getLocation without error using callback', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('Path templates', () => { + describe('folderLocationFloorSetting', async () => { + const fakePath = '/rendered/path/folderLocationFloorSetting'; + const expectedParameters = { + folder: 'folderValue', + location: 'locationValue', + }; + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.folderLocationFloorSettingPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderLocationFloorSettingPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderLocationFloorSettingPath', () => { + const result = client.folderLocationFloorSettingPath( + 'folderValue', + 'locationValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.folderLocationFloorSettingPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchFolderFromFolderLocationFloorSettingName', () => { + const result = + client.matchFolderFromFolderLocationFloorSettingName(fakePath); + assert.strictEqual(result, 'folderValue'); + assert( + ( + client.pathTemplates.folderLocationFloorSettingPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromFolderLocationFloorSettingName', () => { + const result = + client.matchLocationFromFolderLocationFloorSettingName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.folderLocationFloorSettingPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('folderLocationFloorSetting', async () => { - const fakePath = "/rendered/path/folderLocationFloorSetting"; - const expectedParameters = { - folder: "folderValue", - location: "locationValue", - }; - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.folderLocationFloorSettingPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.folderLocationFloorSettingPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('folderLocationFloorSettingPath', () => { - const result = client.folderLocationFloorSettingPath("folderValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.folderLocationFloorSettingPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchFolderFromFolderLocationFloorSettingName', () => { - const result = client.matchFolderFromFolderLocationFloorSettingName(fakePath); - assert.strictEqual(result, "folderValue"); - assert((client.pathTemplates.folderLocationFloorSettingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromFolderLocationFloorSettingName', () => { - const result = client.matchLocationFromFolderLocationFloorSettingName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.folderLocationFloorSettingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('organizationLocationFloorSetting', async () => { - const fakePath = "/rendered/path/organizationLocationFloorSetting"; - const expectedParameters = { - organization: "organizationValue", - location: "locationValue", - }; - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationLocationFloorSettingPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationLocationFloorSettingPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationLocationFloorSettingPath', () => { - const result = client.organizationLocationFloorSettingPath("organizationValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationLocationFloorSettingPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationLocationFloorSettingName', () => { - const result = client.matchOrganizationFromOrganizationLocationFloorSettingName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationLocationFloorSettingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromOrganizationLocationFloorSettingName', () => { - const result = client.matchLocationFromOrganizationLocationFloorSettingName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.organizationLocationFloorSettingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationLocationFloorSetting', async () => { + const fakePath = '/rendered/path/organizationLocationFloorSetting'; + const expectedParameters = { + organization: 'organizationValue', + location: 'locationValue', + }; + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationLocationFloorSettingPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationLocationFloorSettingPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationLocationFloorSettingPath', () => { + const result = client.organizationLocationFloorSettingPath( + 'organizationValue', + 'locationValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationLocationFloorSettingPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationLocationFloorSettingName', () => { + const result = + client.matchOrganizationFromOrganizationLocationFloorSettingName( + fakePath, + ); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationLocationFloorSettingPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromOrganizationLocationFloorSettingName', () => { + const result = + client.matchLocationFromOrganizationLocationFloorSettingName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.organizationLocationFloorSettingPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectLocationFloorSetting', async () => { - const fakePath = "/rendered/path/projectLocationFloorSetting"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectLocationFloorSettingPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationFloorSettingPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationFloorSettingPath', () => { - const result = client.projectLocationFloorSettingPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationFloorSettingPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationFloorSettingName', () => { - const result = client.matchProjectFromProjectLocationFloorSettingName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationFloorSettingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationFloorSettingName', () => { - const result = client.matchLocationFromProjectLocationFloorSettingName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationFloorSettingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectLocationFloorSetting', async () => { + const fakePath = '/rendered/path/projectLocationFloorSetting'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectLocationFloorSettingPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationFloorSettingPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectLocationFloorSettingPath', () => { + const result = client.projectLocationFloorSettingPath( + 'projectValue', + 'locationValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectLocationFloorSettingPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectLocationFloorSettingName', () => { + const result = + client.matchProjectFromProjectLocationFloorSettingName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectLocationFloorSettingPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromProjectLocationFloorSettingName', () => { + const result = + client.matchLocationFromProjectLocationFloorSettingName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.projectLocationFloorSettingPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('template', async () => { - const fakePath = "/rendered/path/template"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - template: "templateValue", - }; - const client = new modelarmorModule.v1.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.templatePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.templatePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('templatePath', () => { - const result = client.templatePath("projectValue", "locationValue", "templateValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.templatePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTemplateName', () => { - const result = client.matchProjectFromTemplateName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.templatePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromTemplateName', () => { - const result = client.matchLocationFromTemplateName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.templatePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTemplateFromTemplateName', () => { - const result = client.matchTemplateFromTemplateName(fakePath); - assert.strictEqual(result, "templateValue"); - assert((client.pathTemplates.templatePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('template', async () => { + const fakePath = '/rendered/path/template'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + template: 'templateValue', + }; + const client = new modelarmorModule.v1.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.templatePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.templatePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('templatePath', () => { + const result = client.templatePath( + 'projectValue', + 'locationValue', + 'templateValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.templatePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromTemplateName', () => { + const result = client.matchProjectFromTemplateName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.templatePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromTemplateName', () => { + const result = client.matchLocationFromTemplateName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.templatePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTemplateFromTemplateName', () => { + const result = client.matchTemplateFromTemplateName(fakePath); + assert.strictEqual(result, 'templateValue'); + assert( + (client.pathTemplates.templatePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-modelarmor/test/gapic_model_armor_v1beta.ts b/packages/google-cloud-modelarmor/test/gapic_model_armor_v1beta.ts index ac5943005662..2bc5a01fa606 100644 --- a/packages/google-cloud-modelarmor/test/gapic_model_armor_v1beta.ts +++ b/packages/google-cloud-modelarmor/test/gapic_model_armor_v1beta.ts @@ -19,1894 +19,2434 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as modelarmorModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LocationProtos} from 'google-gax'; +import { protobuf, LocationProtos } from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubBidiStreamingCall(response?: ResponseType, error?: Error) { - const transformStub = error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - return sinon.stub().returns(mockStream); +function stubBidiStreamingCall( + response?: ResponseType, + error?: Error, +) { + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + return sinon.stub().returns(mockStream); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1beta.ModelArmorClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new modelarmorModule.v1beta.ModelArmorClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'modelarmor.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new modelarmorModule.v1beta.ModelArmorClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = modelarmorModule.v1beta.ModelArmorClient.servicePath; - assert.strictEqual(servicePath, 'modelarmor.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = modelarmorModule.v1beta.ModelArmorClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'modelarmor.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'modelarmor.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'modelarmor.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new modelarmorModule.v1beta.ModelArmorClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'modelarmor.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new modelarmorModule.v1beta.ModelArmorClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'modelarmor.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new modelarmorModule.v1beta.ModelArmorClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = modelarmorModule.v1beta.ModelArmorClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new modelarmorModule.v1beta.ModelArmorClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.modelArmorStub, undefined); - await client.initialize(); - assert(client.modelArmorStub); - }); - - it('has close method for the initialized client', done => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.modelArmorStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has close method for the non-initialized client', done => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.modelArmorStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new modelarmorModule.v1beta.ModelArmorClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'modelarmor.googleapis.com'); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); + it('has universeDomain', () => { + const client = new modelarmorModule.v1beta.ModelArmorClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); }); - describe('getTemplate', () => { - it('invokes getTemplate without error', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.GetTemplateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.GetTemplateRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.Template() - ); - client.innerApiCalls.getTemplate = stubSimpleCall(expectedResponse); - const [response] = await client.getTemplate(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTemplate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTemplate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + modelarmorModule.v1beta.ModelArmorClient.servicePath; + assert.strictEqual(servicePath, 'modelarmor.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + modelarmorModule.v1beta.ModelArmorClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'modelarmor.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'modelarmor.example.com'); + }); - it('invokes getTemplate without error using callback', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.GetTemplateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.GetTemplateRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.Template() - ); - client.innerApiCalls.getTemplate = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getTemplate( - request, - (err?: Error|null, result?: protos.google.cloud.modelarmor.v1beta.ITemplate|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTemplate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTemplate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'modelarmor.example.com'); + }); - it('invokes getTemplate with error', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.GetTemplateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.GetTemplateRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getTemplate = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getTemplate(request), expectedError); - const actualRequest = (client.innerApiCalls.getTemplate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTemplate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new modelarmorModule.v1beta.ModelArmorClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'modelarmor.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new modelarmorModule.v1beta.ModelArmorClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'modelarmor.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new modelarmorModule.v1beta.ModelArmorClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('invokes getTemplate with closed client', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.GetTemplateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.GetTemplateRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getTemplate(request), expectedError); - }); + it('has port', () => { + const port = modelarmorModule.v1beta.ModelArmorClient.port; + assert(port); + assert(typeof port === 'number'); }); - describe('createTemplate', () => { - it('invokes createTemplate without error', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.CreateTemplateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.CreateTemplateRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.Template() - ); - client.innerApiCalls.createTemplate = stubSimpleCall(expectedResponse); - const [response] = await client.createTemplate(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createTemplate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTemplate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('should create a client with no option', () => { + const client = new modelarmorModule.v1beta.ModelArmorClient(); + assert(client); + }); - it('invokes createTemplate without error using callback', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.CreateTemplateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.CreateTemplateRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.Template() - ); - client.innerApiCalls.createTemplate = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createTemplate( - request, - (err?: Error|null, result?: protos.google.cloud.modelarmor.v1beta.ITemplate|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createTemplate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTemplate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('should create a client with gRPC fallback', () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + fallback: true, + }); + assert(client); + }); - it('invokes createTemplate with error', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.CreateTemplateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.CreateTemplateRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createTemplate = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createTemplate(request), expectedError); - const actualRequest = (client.innerApiCalls.createTemplate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTemplate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.modelArmorStub, undefined); + await client.initialize(); + assert(client.modelArmorStub); + }); - it('invokes createTemplate with closed client', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.CreateTemplateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.CreateTemplateRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createTemplate(request), expectedError); + it('has close method for the initialized client', (done) => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.modelArmorStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('updateTemplate', () => { - it('invokes updateTemplate without error', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.UpdateTemplateRequest() - ); - request.template ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.UpdateTemplateRequest', ['template', 'name']); - request.template.name = defaultValue1; - const expectedHeaderRequestParams = `template.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.Template() - ); - client.innerApiCalls.updateTemplate = stubSimpleCall(expectedResponse); - const [response] = await client.updateTemplate(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateTemplate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTemplate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the non-initialized client', (done) => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.modelArmorStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes updateTemplate without error using callback', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.UpdateTemplateRequest() - ); - request.template ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.UpdateTemplateRequest', ['template', 'name']); - request.template.name = defaultValue1; - const expectedHeaderRequestParams = `template.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.Template() - ); - client.innerApiCalls.updateTemplate = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateTemplate( - request, - (err?: Error|null, result?: protos.google.cloud.modelarmor.v1beta.ITemplate|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateTemplate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTemplate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('invokes updateTemplate with error', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.UpdateTemplateRequest() - ); - request.template ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.UpdateTemplateRequest', ['template', 'name']); - request.template.name = defaultValue1; - const expectedHeaderRequestParams = `template.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateTemplate = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateTemplate(request), expectedError); - const actualRequest = (client.innerApiCalls.updateTemplate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTemplate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getTemplate', () => { + it('invokes getTemplate without error', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.GetTemplateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.GetTemplateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.Template(), + ); + client.innerApiCalls.getTemplate = stubSimpleCall(expectedResponse); + const [response] = await client.getTemplate(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getTemplate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTemplate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateTemplate with closed client', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.UpdateTemplateRequest() - ); - request.template ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.UpdateTemplateRequest', ['template', 'name']); - request.template.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateTemplate(request), expectedError); - }); + it('invokes getTemplate without error using callback', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.GetTemplateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.GetTemplateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.Template(), + ); + client.innerApiCalls.getTemplate = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getTemplate( + request, + ( + err?: Error | null, + result?: protos.google.cloud.modelarmor.v1beta.ITemplate | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getTemplate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTemplate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteTemplate', () => { - it('invokes deleteTemplate without error', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.DeleteTemplateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.DeleteTemplateRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteTemplate = stubSimpleCall(expectedResponse); - const [response] = await client.deleteTemplate(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteTemplate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTemplate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getTemplate with error', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.GetTemplateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.GetTemplateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getTemplate = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getTemplate(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getTemplate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTemplate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTemplate without error using callback', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.DeleteTemplateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.DeleteTemplateRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteTemplate = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteTemplate( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteTemplate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTemplate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getTemplate with closed client', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.GetTemplateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.GetTemplateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getTemplate(request), expectedError); + }); + }); + + describe('createTemplate', () => { + it('invokes createTemplate without error', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.CreateTemplateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.CreateTemplateRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.Template(), + ); + client.innerApiCalls.createTemplate = stubSimpleCall(expectedResponse); + const [response] = await client.createTemplate(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createTemplate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTemplate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTemplate with error', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.DeleteTemplateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.DeleteTemplateRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteTemplate = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteTemplate(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteTemplate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTemplate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createTemplate without error using callback', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.CreateTemplateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.CreateTemplateRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.Template(), + ); + client.innerApiCalls.createTemplate = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createTemplate( + request, + ( + err?: Error | null, + result?: protos.google.cloud.modelarmor.v1beta.ITemplate | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createTemplate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTemplate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTemplate with closed client', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.DeleteTemplateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.DeleteTemplateRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteTemplate(request), expectedError); - }); + it('invokes createTemplate with error', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.CreateTemplateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.CreateTemplateRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createTemplate = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createTemplate(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createTemplate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTemplate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getFloorSetting', () => { - it('invokes getFloorSetting without error', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.GetFloorSettingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.GetFloorSettingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.FloorSetting() - ); - client.innerApiCalls.getFloorSetting = stubSimpleCall(expectedResponse); - const [response] = await client.getFloorSetting(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getFloorSetting as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getFloorSetting as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createTemplate with closed client', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.CreateTemplateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.CreateTemplateRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createTemplate(request), expectedError); + }); + }); + + describe('updateTemplate', () => { + it('invokes updateTemplate without error', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.UpdateTemplateRequest(), + ); + request.template ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.UpdateTemplateRequest', + ['template', 'name'], + ); + request.template.name = defaultValue1; + const expectedHeaderRequestParams = `template.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.Template(), + ); + client.innerApiCalls.updateTemplate = stubSimpleCall(expectedResponse); + const [response] = await client.updateTemplate(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateTemplate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTemplate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getFloorSetting without error using callback', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.GetFloorSettingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.GetFloorSettingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.FloorSetting() - ); - client.innerApiCalls.getFloorSetting = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getFloorSetting( - request, - (err?: Error|null, result?: protos.google.cloud.modelarmor.v1beta.IFloorSetting|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getFloorSetting as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getFloorSetting as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateTemplate without error using callback', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.UpdateTemplateRequest(), + ); + request.template ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.UpdateTemplateRequest', + ['template', 'name'], + ); + request.template.name = defaultValue1; + const expectedHeaderRequestParams = `template.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.Template(), + ); + client.innerApiCalls.updateTemplate = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateTemplate( + request, + ( + err?: Error | null, + result?: protos.google.cloud.modelarmor.v1beta.ITemplate | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateTemplate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTemplate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getFloorSetting with error', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.GetFloorSettingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.GetFloorSettingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getFloorSetting = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getFloorSetting(request), expectedError); - const actualRequest = (client.innerApiCalls.getFloorSetting as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getFloorSetting as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateTemplate with error', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.UpdateTemplateRequest(), + ); + request.template ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.UpdateTemplateRequest', + ['template', 'name'], + ); + request.template.name = defaultValue1; + const expectedHeaderRequestParams = `template.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateTemplate = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateTemplate(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateTemplate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTemplate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getFloorSetting with closed client', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.GetFloorSettingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.GetFloorSettingRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getFloorSetting(request), expectedError); - }); + it('invokes updateTemplate with closed client', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.UpdateTemplateRequest(), + ); + request.template ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.UpdateTemplateRequest', + ['template', 'name'], + ); + request.template.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateTemplate(request), expectedError); + }); + }); + + describe('deleteTemplate', () => { + it('invokes deleteTemplate without error', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.DeleteTemplateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.DeleteTemplateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteTemplate = stubSimpleCall(expectedResponse); + const [response] = await client.deleteTemplate(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteTemplate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTemplate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateFloorSetting', () => { - it('invokes updateFloorSetting without error', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.UpdateFloorSettingRequest() - ); - request.floorSetting ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.UpdateFloorSettingRequest', ['floorSetting', 'name']); - request.floorSetting.name = defaultValue1; - const expectedHeaderRequestParams = `floor_setting.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.FloorSetting() - ); - client.innerApiCalls.updateFloorSetting = stubSimpleCall(expectedResponse); - const [response] = await client.updateFloorSetting(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateFloorSetting as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFloorSetting as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteTemplate without error using callback', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.DeleteTemplateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.DeleteTemplateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteTemplate = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteTemplate( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteTemplate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTemplate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateFloorSetting without error using callback', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.UpdateFloorSettingRequest() - ); - request.floorSetting ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.UpdateFloorSettingRequest', ['floorSetting', 'name']); - request.floorSetting.name = defaultValue1; - const expectedHeaderRequestParams = `floor_setting.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.FloorSetting() - ); - client.innerApiCalls.updateFloorSetting = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateFloorSetting( - request, - (err?: Error|null, result?: protos.google.cloud.modelarmor.v1beta.IFloorSetting|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateFloorSetting as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFloorSetting as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteTemplate with error', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.DeleteTemplateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.DeleteTemplateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteTemplate = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteTemplate(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteTemplate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTemplate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateFloorSetting with error', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.UpdateFloorSettingRequest() - ); - request.floorSetting ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.UpdateFloorSettingRequest', ['floorSetting', 'name']); - request.floorSetting.name = defaultValue1; - const expectedHeaderRequestParams = `floor_setting.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateFloorSetting = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateFloorSetting(request), expectedError); - const actualRequest = (client.innerApiCalls.updateFloorSetting as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFloorSetting as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteTemplate with closed client', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.DeleteTemplateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.DeleteTemplateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deleteTemplate(request), expectedError); + }); + }); + + describe('getFloorSetting', () => { + it('invokes getFloorSetting without error', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.GetFloorSettingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.GetFloorSettingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.FloorSetting(), + ); + client.innerApiCalls.getFloorSetting = stubSimpleCall(expectedResponse); + const [response] = await client.getFloorSetting(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getFloorSetting as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFloorSetting as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateFloorSetting with closed client', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.UpdateFloorSettingRequest() - ); - request.floorSetting ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.UpdateFloorSettingRequest', ['floorSetting', 'name']); - request.floorSetting.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateFloorSetting(request), expectedError); - }); + it('invokes getFloorSetting without error using callback', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.GetFloorSettingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.GetFloorSettingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.FloorSetting(), + ); + client.innerApiCalls.getFloorSetting = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getFloorSetting( + request, + ( + err?: Error | null, + result?: protos.google.cloud.modelarmor.v1beta.IFloorSetting | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getFloorSetting as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFloorSetting as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('sanitizeUserPrompt', () => { - it('invokes sanitizeUserPrompt without error', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.SanitizeUserPromptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.SanitizeUserPromptRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.SanitizeUserPromptResponse() - ); - client.innerApiCalls.sanitizeUserPrompt = stubSimpleCall(expectedResponse); - const [response] = await client.sanitizeUserPrompt(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.sanitizeUserPrompt as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.sanitizeUserPrompt as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getFloorSetting with error', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.GetFloorSettingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.GetFloorSettingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getFloorSetting = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getFloorSetting(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getFloorSetting as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFloorSetting as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes sanitizeUserPrompt without error using callback', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.SanitizeUserPromptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.SanitizeUserPromptRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.SanitizeUserPromptResponse() - ); - client.innerApiCalls.sanitizeUserPrompt = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.sanitizeUserPrompt( - request, - (err?: Error|null, result?: protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.sanitizeUserPrompt as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.sanitizeUserPrompt as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getFloorSetting with closed client', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.GetFloorSettingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.GetFloorSettingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getFloorSetting(request), expectedError); + }); + }); + + describe('updateFloorSetting', () => { + it('invokes updateFloorSetting without error', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.UpdateFloorSettingRequest(), + ); + request.floorSetting ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.UpdateFloorSettingRequest', + ['floorSetting', 'name'], + ); + request.floorSetting.name = defaultValue1; + const expectedHeaderRequestParams = `floor_setting.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.FloorSetting(), + ); + client.innerApiCalls.updateFloorSetting = + stubSimpleCall(expectedResponse); + const [response] = await client.updateFloorSetting(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateFloorSetting as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFloorSetting as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes sanitizeUserPrompt with error', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.SanitizeUserPromptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.SanitizeUserPromptRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.sanitizeUserPrompt = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.sanitizeUserPrompt(request), expectedError); - const actualRequest = (client.innerApiCalls.sanitizeUserPrompt as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.sanitizeUserPrompt as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateFloorSetting without error using callback', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.UpdateFloorSettingRequest(), + ); + request.floorSetting ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.UpdateFloorSettingRequest', + ['floorSetting', 'name'], + ); + request.floorSetting.name = defaultValue1; + const expectedHeaderRequestParams = `floor_setting.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.FloorSetting(), + ); + client.innerApiCalls.updateFloorSetting = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateFloorSetting( + request, + ( + err?: Error | null, + result?: protos.google.cloud.modelarmor.v1beta.IFloorSetting | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateFloorSetting as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFloorSetting as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes sanitizeUserPrompt with closed client', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.SanitizeUserPromptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.SanitizeUserPromptRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.sanitizeUserPrompt(request), expectedError); - }); + it('invokes updateFloorSetting with error', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.UpdateFloorSettingRequest(), + ); + request.floorSetting ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.UpdateFloorSettingRequest', + ['floorSetting', 'name'], + ); + request.floorSetting.name = defaultValue1; + const expectedHeaderRequestParams = `floor_setting.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateFloorSetting = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateFloorSetting(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateFloorSetting as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFloorSetting as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('sanitizeModelResponse', () => { - it('invokes sanitizeModelResponse without error', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.SanitizeModelResponseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.SanitizeModelResponseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.SanitizeModelResponseResponse() - ); - client.innerApiCalls.sanitizeModelResponse = stubSimpleCall(expectedResponse); - const [response] = await client.sanitizeModelResponse(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.sanitizeModelResponse as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.sanitizeModelResponse as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateFloorSetting with closed client', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.UpdateFloorSettingRequest(), + ); + request.floorSetting ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.UpdateFloorSettingRequest', + ['floorSetting', 'name'], + ); + request.floorSetting.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateFloorSetting(request), expectedError); + }); + }); + + describe('sanitizeUserPrompt', () => { + it('invokes sanitizeUserPrompt without error', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.SanitizeUserPromptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.SanitizeUserPromptRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.SanitizeUserPromptResponse(), + ); + client.innerApiCalls.sanitizeUserPrompt = + stubSimpleCall(expectedResponse); + const [response] = await client.sanitizeUserPrompt(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.sanitizeUserPrompt as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.sanitizeUserPrompt as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes sanitizeModelResponse without error using callback', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.SanitizeModelResponseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.SanitizeModelResponseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.SanitizeModelResponseResponse() - ); - client.innerApiCalls.sanitizeModelResponse = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.sanitizeModelResponse( - request, - (err?: Error|null, result?: protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.sanitizeModelResponse as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.sanitizeModelResponse as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes sanitizeUserPrompt without error using callback', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.SanitizeUserPromptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.SanitizeUserPromptRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.SanitizeUserPromptResponse(), + ); + client.innerApiCalls.sanitizeUserPrompt = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.sanitizeUserPrompt( + request, + ( + err?: Error | null, + result?: protos.google.cloud.modelarmor.v1beta.ISanitizeUserPromptResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.sanitizeUserPrompt as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.sanitizeUserPrompt as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes sanitizeModelResponse with error', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.SanitizeModelResponseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.SanitizeModelResponseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.sanitizeModelResponse = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.sanitizeModelResponse(request), expectedError); - const actualRequest = (client.innerApiCalls.sanitizeModelResponse as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.sanitizeModelResponse as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes sanitizeUserPrompt with error', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.SanitizeUserPromptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.SanitizeUserPromptRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.sanitizeUserPrompt = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.sanitizeUserPrompt(request), expectedError); + const actualRequest = ( + client.innerApiCalls.sanitizeUserPrompt as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.sanitizeUserPrompt as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes sanitizeModelResponse with closed client', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.SanitizeModelResponseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.SanitizeModelResponseRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.sanitizeModelResponse(request), expectedError); - }); + it('invokes sanitizeUserPrompt with closed client', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.SanitizeUserPromptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.SanitizeUserPromptRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.sanitizeUserPrompt(request), expectedError); + }); + }); + + describe('sanitizeModelResponse', () => { + it('invokes sanitizeModelResponse without error', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.SanitizeModelResponseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.SanitizeModelResponseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.SanitizeModelResponseResponse(), + ); + client.innerApiCalls.sanitizeModelResponse = + stubSimpleCall(expectedResponse); + const [response] = await client.sanitizeModelResponse(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.sanitizeModelResponse as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.sanitizeModelResponse as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('streamSanitizeUserPrompt', () => { - it('invokes streamSanitizeUserPrompt without error', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.SanitizeUserPromptRequest() - ); - - const expectedResponse = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.SanitizeUserPromptResponse() - ); - client.innerApiCalls.streamSanitizeUserPrompt = stubBidiStreamingCall(expectedResponse); - const stream = client.streamSanitizeUserPrompt(); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.cloud.modelarmor.v1beta.SanitizeUserPromptResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - stream.write(request); - stream.end(); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.streamSanitizeUserPrompt as SinonStub) - .getCall(0).calledWith(null)); - assert.deepStrictEqual(((stream as unknown as PassThrough) - ._transform as SinonStub).getCall(0).args[0], request); - }); + it('invokes sanitizeModelResponse without error using callback', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.SanitizeModelResponseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.SanitizeModelResponseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.SanitizeModelResponseResponse(), + ); + client.innerApiCalls.sanitizeModelResponse = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.sanitizeModelResponse( + request, + ( + err?: Error | null, + result?: protos.google.cloud.modelarmor.v1beta.ISanitizeModelResponseResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.sanitizeModelResponse as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.sanitizeModelResponse as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes streamSanitizeUserPrompt with error', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.SanitizeUserPromptRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.streamSanitizeUserPrompt = stubBidiStreamingCall(undefined, expectedError); - const stream = client.streamSanitizeUserPrompt(); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.cloud.modelarmor.v1beta.SanitizeUserPromptResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - stream.write(request); - stream.end(); - }); - await assert.rejects(promise, expectedError); - assert((client.innerApiCalls.streamSanitizeUserPrompt as SinonStub) - .getCall(0).calledWith(null)); - assert.deepStrictEqual(((stream as unknown as PassThrough) - ._transform as SinonStub).getCall(0).args[0], request); - }); + it('invokes sanitizeModelResponse with error', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.SanitizeModelResponseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.SanitizeModelResponseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.sanitizeModelResponse = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.sanitizeModelResponse(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.sanitizeModelResponse as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.sanitizeModelResponse as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('streamSanitizeModelResponse', () => { - it('invokes streamSanitizeModelResponse without error', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.SanitizeModelResponseRequest() - ); - - const expectedResponse = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.SanitizeModelResponseResponse() - ); - client.innerApiCalls.streamSanitizeModelResponse = stubBidiStreamingCall(expectedResponse); - const stream = client.streamSanitizeModelResponse(); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.cloud.modelarmor.v1beta.SanitizeModelResponseResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - stream.write(request); - stream.end(); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.streamSanitizeModelResponse as SinonStub) - .getCall(0).calledWith(null)); - assert.deepStrictEqual(((stream as unknown as PassThrough) - ._transform as SinonStub).getCall(0).args[0], request); - }); + it('invokes sanitizeModelResponse with closed client', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.SanitizeModelResponseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.SanitizeModelResponseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.sanitizeModelResponse(request), + expectedError, + ); + }); + }); + + describe('streamSanitizeUserPrompt', () => { + it('invokes streamSanitizeUserPrompt without error', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.SanitizeUserPromptRequest(), + ); + + const expectedResponse = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.SanitizeUserPromptResponse(), + ); + client.innerApiCalls.streamSanitizeUserPrompt = + stubBidiStreamingCall(expectedResponse); + const stream = client.streamSanitizeUserPrompt(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + ( + response: protos.google.cloud.modelarmor.v1beta.SanitizeUserPromptResponse, + ) => { + resolve(response); + }, + ); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.streamSanitizeUserPrompt as SinonStub) + .getCall(0) + .calledWith(null), + ); + assert.deepStrictEqual( + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], + request, + ); + }); - it('invokes streamSanitizeModelResponse with error', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.SanitizeModelResponseRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.streamSanitizeModelResponse = stubBidiStreamingCall(undefined, expectedError); - const stream = client.streamSanitizeModelResponse(); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.cloud.modelarmor.v1beta.SanitizeModelResponseResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - stream.write(request); - stream.end(); - }); - await assert.rejects(promise, expectedError); - assert((client.innerApiCalls.streamSanitizeModelResponse as SinonStub) - .getCall(0).calledWith(null)); - assert.deepStrictEqual(((stream as unknown as PassThrough) - ._transform as SinonStub).getCall(0).args[0], request); - }); + it('invokes streamSanitizeUserPrompt with error', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.SanitizeUserPromptRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.streamSanitizeUserPrompt = stubBidiStreamingCall( + undefined, + expectedError, + ); + const stream = client.streamSanitizeUserPrompt(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + ( + response: protos.google.cloud.modelarmor.v1beta.SanitizeUserPromptResponse, + ) => { + resolve(response); + }, + ); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + await assert.rejects(promise, expectedError); + assert( + (client.innerApiCalls.streamSanitizeUserPrompt as SinonStub) + .getCall(0) + .calledWith(null), + ); + assert.deepStrictEqual( + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], + request, + ); + }); + }); + + describe('streamSanitizeModelResponse', () => { + it('invokes streamSanitizeModelResponse without error', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.SanitizeModelResponseRequest(), + ); + + const expectedResponse = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.SanitizeModelResponseResponse(), + ); + client.innerApiCalls.streamSanitizeModelResponse = + stubBidiStreamingCall(expectedResponse); + const stream = client.streamSanitizeModelResponse(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + ( + response: protos.google.cloud.modelarmor.v1beta.SanitizeModelResponseResponse, + ) => { + resolve(response); + }, + ); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.streamSanitizeModelResponse as SinonStub) + .getCall(0) + .calledWith(null), + ); + assert.deepStrictEqual( + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], + request, + ); }); - describe('listTemplates', () => { - it('invokes listTemplates without error', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.ListTemplatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.ListTemplatesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.modelarmor.v1beta.Template()), - generateSampleMessage(new protos.google.cloud.modelarmor.v1beta.Template()), - generateSampleMessage(new protos.google.cloud.modelarmor.v1beta.Template()), - ]; - client.innerApiCalls.listTemplates = stubSimpleCall(expectedResponse); - const [response] = await client.listTemplates(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTemplates as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTemplates as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes streamSanitizeModelResponse with error', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.SanitizeModelResponseRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.streamSanitizeModelResponse = stubBidiStreamingCall( + undefined, + expectedError, + ); + const stream = client.streamSanitizeModelResponse(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + ( + response: protos.google.cloud.modelarmor.v1beta.SanitizeModelResponseResponse, + ) => { + resolve(response); + }, + ); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + await assert.rejects(promise, expectedError); + assert( + (client.innerApiCalls.streamSanitizeModelResponse as SinonStub) + .getCall(0) + .calledWith(null), + ); + assert.deepStrictEqual( + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], + request, + ); + }); + }); + + describe('listTemplates', () => { + it('invokes listTemplates without error', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.ListTemplatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.ListTemplatesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.Template(), + ), + generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.Template(), + ), + generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.Template(), + ), + ]; + client.innerApiCalls.listTemplates = stubSimpleCall(expectedResponse); + const [response] = await client.listTemplates(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listTemplates as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTemplates as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listTemplates without error using callback', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.ListTemplatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.ListTemplatesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.modelarmor.v1beta.Template()), - generateSampleMessage(new protos.google.cloud.modelarmor.v1beta.Template()), - generateSampleMessage(new protos.google.cloud.modelarmor.v1beta.Template()), - ]; - client.innerApiCalls.listTemplates = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listTemplates( - request, - (err?: Error|null, result?: protos.google.cloud.modelarmor.v1beta.ITemplate[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTemplates as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTemplates as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listTemplates without error using callback', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.ListTemplatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.ListTemplatesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.Template(), + ), + generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.Template(), + ), + generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.Template(), + ), + ]; + client.innerApiCalls.listTemplates = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listTemplates( + request, + ( + err?: Error | null, + result?: protos.google.cloud.modelarmor.v1beta.ITemplate[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listTemplates as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTemplates as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listTemplates with error', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.ListTemplatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.ListTemplatesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listTemplates = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listTemplates(request), expectedError); - const actualRequest = (client.innerApiCalls.listTemplates as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTemplates as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listTemplates with error', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.ListTemplatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.ListTemplatesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listTemplates = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listTemplates(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listTemplates as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTemplates as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listTemplatesStream without error', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.ListTemplatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.ListTemplatesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.modelarmor.v1beta.Template()), - generateSampleMessage(new protos.google.cloud.modelarmor.v1beta.Template()), - generateSampleMessage(new protos.google.cloud.modelarmor.v1beta.Template()), - ]; - client.descriptors.page.listTemplates.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listTemplatesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.modelarmor.v1beta.Template[] = []; - stream.on('data', (response: protos.google.cloud.modelarmor.v1beta.Template) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listTemplates.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTemplates, request)); - assert( - (client.descriptors.page.listTemplates.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listTemplatesStream without error', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.ListTemplatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.ListTemplatesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.Template(), + ), + generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.Template(), + ), + generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.Template(), + ), + ]; + client.descriptors.page.listTemplates.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listTemplatesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.modelarmor.v1beta.Template[] = []; + stream.on( + 'data', + (response: protos.google.cloud.modelarmor.v1beta.Template) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listTemplates.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listTemplates, request), + ); + assert( + (client.descriptors.page.listTemplates.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listTemplatesStream with error', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.ListTemplatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.ListTemplatesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listTemplates.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listTemplatesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.modelarmor.v1beta.Template[] = []; - stream.on('data', (response: protos.google.cloud.modelarmor.v1beta.Template) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listTemplates.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTemplates, request)); - assert( - (client.descriptors.page.listTemplates.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listTemplatesStream with error', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.ListTemplatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.ListTemplatesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTemplates.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listTemplatesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.modelarmor.v1beta.Template[] = []; + stream.on( + 'data', + (response: protos.google.cloud.modelarmor.v1beta.Template) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listTemplates.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listTemplates, request), + ); + assert( + (client.descriptors.page.listTemplates.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listTemplates without error', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.ListTemplatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.ListTemplatesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.modelarmor.v1beta.Template()), - generateSampleMessage(new protos.google.cloud.modelarmor.v1beta.Template()), - generateSampleMessage(new protos.google.cloud.modelarmor.v1beta.Template()), - ]; - client.descriptors.page.listTemplates.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.modelarmor.v1beta.ITemplate[] = []; - const iterable = client.listTemplatesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listTemplates.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTemplates.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listTemplates without error', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.ListTemplatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.ListTemplatesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.Template(), + ), + generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.Template(), + ), + generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.Template(), + ), + ]; + client.descriptors.page.listTemplates.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.modelarmor.v1beta.ITemplate[] = []; + const iterable = client.listTemplatesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listTemplates.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listTemplates.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listTemplates with error', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.modelarmor.v1beta.ListTemplatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.modelarmor.v1beta.ListTemplatesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listTemplates.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listTemplatesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.modelarmor.v1beta.ITemplate[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listTemplates.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTemplates.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listTemplates with error', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.modelarmor.v1beta.ListTemplatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.modelarmor.v1beta.ListTemplatesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTemplates.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listTemplatesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.modelarmor.v1beta.ITemplate[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listTemplates.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listTemplates.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes getLocation without error using callback', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('Path templates', () => { + describe('folderLocationFloorSetting', async () => { + const fakePath = '/rendered/path/folderLocationFloorSetting'; + const expectedParameters = { + folder: 'folderValue', + location: 'locationValue', + }; + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.folderLocationFloorSettingPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderLocationFloorSettingPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderLocationFloorSettingPath', () => { + const result = client.folderLocationFloorSettingPath( + 'folderValue', + 'locationValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.folderLocationFloorSettingPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchFolderFromFolderLocationFloorSettingName', () => { + const result = + client.matchFolderFromFolderLocationFloorSettingName(fakePath); + assert.strictEqual(result, 'folderValue'); + assert( + ( + client.pathTemplates.folderLocationFloorSettingPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromFolderLocationFloorSettingName', () => { + const result = + client.matchLocationFromFolderLocationFloorSettingName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.folderLocationFloorSettingPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('folderLocationFloorSetting', async () => { - const fakePath = "/rendered/path/folderLocationFloorSetting"; - const expectedParameters = { - folder: "folderValue", - location: "locationValue", - }; - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.folderLocationFloorSettingPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.folderLocationFloorSettingPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('folderLocationFloorSettingPath', () => { - const result = client.folderLocationFloorSettingPath("folderValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.folderLocationFloorSettingPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchFolderFromFolderLocationFloorSettingName', () => { - const result = client.matchFolderFromFolderLocationFloorSettingName(fakePath); - assert.strictEqual(result, "folderValue"); - assert((client.pathTemplates.folderLocationFloorSettingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromFolderLocationFloorSettingName', () => { - const result = client.matchLocationFromFolderLocationFloorSettingName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.folderLocationFloorSettingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('organizationLocationFloorSetting', async () => { - const fakePath = "/rendered/path/organizationLocationFloorSetting"; - const expectedParameters = { - organization: "organizationValue", - location: "locationValue", - }; - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationLocationFloorSettingPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationLocationFloorSettingPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationLocationFloorSettingPath', () => { - const result = client.organizationLocationFloorSettingPath("organizationValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationLocationFloorSettingPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationLocationFloorSettingName', () => { - const result = client.matchOrganizationFromOrganizationLocationFloorSettingName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationLocationFloorSettingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromOrganizationLocationFloorSettingName', () => { - const result = client.matchLocationFromOrganizationLocationFloorSettingName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.organizationLocationFloorSettingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationLocationFloorSetting', async () => { + const fakePath = '/rendered/path/organizationLocationFloorSetting'; + const expectedParameters = { + organization: 'organizationValue', + location: 'locationValue', + }; + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationLocationFloorSettingPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationLocationFloorSettingPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationLocationFloorSettingPath', () => { + const result = client.organizationLocationFloorSettingPath( + 'organizationValue', + 'locationValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationLocationFloorSettingPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationLocationFloorSettingName', () => { + const result = + client.matchOrganizationFromOrganizationLocationFloorSettingName( + fakePath, + ); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationLocationFloorSettingPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromOrganizationLocationFloorSettingName', () => { + const result = + client.matchLocationFromOrganizationLocationFloorSettingName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.organizationLocationFloorSettingPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectLocationFloorSetting', async () => { - const fakePath = "/rendered/path/projectLocationFloorSetting"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectLocationFloorSettingPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationFloorSettingPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationFloorSettingPath', () => { - const result = client.projectLocationFloorSettingPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationFloorSettingPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationFloorSettingName', () => { - const result = client.matchProjectFromProjectLocationFloorSettingName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationFloorSettingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationFloorSettingName', () => { - const result = client.matchLocationFromProjectLocationFloorSettingName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationFloorSettingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectLocationFloorSetting', async () => { + const fakePath = '/rendered/path/projectLocationFloorSetting'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectLocationFloorSettingPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationFloorSettingPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectLocationFloorSettingPath', () => { + const result = client.projectLocationFloorSettingPath( + 'projectValue', + 'locationValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectLocationFloorSettingPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectLocationFloorSettingName', () => { + const result = + client.matchProjectFromProjectLocationFloorSettingName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectLocationFloorSettingPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromProjectLocationFloorSettingName', () => { + const result = + client.matchLocationFromProjectLocationFloorSettingName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.projectLocationFloorSettingPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('template', async () => { - const fakePath = "/rendered/path/template"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - template: "templateValue", - }; - const client = new modelarmorModule.v1beta.ModelArmorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.templatePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.templatePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('templatePath', () => { - const result = client.templatePath("projectValue", "locationValue", "templateValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.templatePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTemplateName', () => { - const result = client.matchProjectFromTemplateName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.templatePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromTemplateName', () => { - const result = client.matchLocationFromTemplateName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.templatePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTemplateFromTemplateName', () => { - const result = client.matchTemplateFromTemplateName(fakePath); - assert.strictEqual(result, "templateValue"); - assert((client.pathTemplates.templatePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('template', async () => { + const fakePath = '/rendered/path/template'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + template: 'templateValue', + }; + const client = new modelarmorModule.v1beta.ModelArmorClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.templatePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.templatePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('templatePath', () => { + const result = client.templatePath( + 'projectValue', + 'locationValue', + 'templateValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.templatePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromTemplateName', () => { + const result = client.matchProjectFromTemplateName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.templatePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromTemplateName', () => { + const result = client.matchLocationFromTemplateName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.templatePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTemplateFromTemplateName', () => { + const result = client.matchTemplateFromTemplateName(fakePath); + assert.strictEqual(result, 'templateValue'); + assert( + (client.pathTemplates.templatePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-modelarmor/webpack.config.js b/packages/google-cloud-modelarmor/webpack.config.js index 3a98be91fa38..aff4865dc9d5 100644 --- a/packages/google-cloud-modelarmor/webpack.config.js +++ b/packages/google-cloud-modelarmor/webpack.config.js @@ -1,4 +1,4 @@ -// Copyright 2026 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-netapp/.eslintignore b/packages/google-cloud-netapp/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-netapp/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-netapp/.eslintrc.json b/packages/google-cloud-netapp/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-netapp/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-netapp/README.md b/packages/google-cloud-netapp/README.md index f4c7d90f98b7..5094ba82ab94 100644 --- a/packages/google-cloud-netapp/README.md +++ b/packages/google-cloud-netapp/README.md @@ -163,7 +163,7 @@ More Information: [Google Cloud Platform Launch Stages][launch_stages] ## Contributing -Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-netapp/CONTRIBUTING.md). +Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/CONTRIBUTING.md). Please note that this `README.md` and a variety of configuration files in this repository (including `.nycrc` and `tsconfig.json`) @@ -173,7 +173,7 @@ are generated from a central template. Apache Version 2.0 -See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-netapp/LICENSE) +See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/LICENSE) [shell_img]: https://gstatic.com/cloudssh/images/open-btn.png [projects]: https://console.cloud.google.com/project diff --git a/packages/google-cloud-netapp/protos/protos.d.ts b/packages/google-cloud-netapp/protos/protos.d.ts index 01639c5941b2..a9c2eba95a53 100644 --- a/packages/google-cloud-netapp/protos/protos.d.ts +++ b/packages/google-cloud-netapp/protos/protos.d.ts @@ -16975,6 +16975,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -16992,6 +16995,9 @@ export namespace google { /** CommonLanguageSettings destinations. */ public destinations: google.api.ClientLibraryDestination[]; + /** CommonLanguageSettings selectiveGapicGeneration. */ + public selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); + /** * Creates a new CommonLanguageSettings instance using the specified properties. * @param [properties] Properties to set @@ -17692,6 +17698,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -17706,6 +17715,9 @@ export namespace google { /** PythonSettings common. */ public common?: (google.api.ICommonLanguageSettings|null); + /** PythonSettings experimentalFeatures. */ + public experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); + /** * Creates a new PythonSettings instance using the specified properties. * @param [properties] Properties to set @@ -17784,6 +17796,118 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + namespace PythonSettings { + + /** Properties of an ExperimentalFeatures. */ + interface IExperimentalFeatures { + + /** ExperimentalFeatures restAsyncIoEnabled */ + restAsyncIoEnabled?: (boolean|null); + + /** ExperimentalFeatures protobufPythonicTypesEnabled */ + protobufPythonicTypesEnabled?: (boolean|null); + + /** ExperimentalFeatures unversionedPackageDisabled */ + unversionedPackageDisabled?: (boolean|null); + } + + /** Represents an ExperimentalFeatures. */ + class ExperimentalFeatures implements IExperimentalFeatures { + + /** + * Constructs a new ExperimentalFeatures. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.PythonSettings.IExperimentalFeatures); + + /** ExperimentalFeatures restAsyncIoEnabled. */ + public restAsyncIoEnabled: boolean; + + /** ExperimentalFeatures protobufPythonicTypesEnabled. */ + public protobufPythonicTypesEnabled: boolean; + + /** ExperimentalFeatures unversionedPackageDisabled. */ + public unversionedPackageDisabled: boolean; + + /** + * Creates a new ExperimentalFeatures instance using the specified properties. + * @param [properties] Properties to set + * @returns ExperimentalFeatures instance + */ + public static create(properties?: google.api.PythonSettings.IExperimentalFeatures): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Encodes the specified ExperimentalFeatures message. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @param message ExperimentalFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.PythonSettings.IExperimentalFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExperimentalFeatures message, length delimited. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @param message ExperimentalFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.PythonSettings.IExperimentalFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExperimentalFeatures + * @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.api.PythonSettings.ExperimentalFeatures; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExperimentalFeatures + * @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.api.PythonSettings.ExperimentalFeatures; + + /** + * Verifies an ExperimentalFeatures 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 an ExperimentalFeatures message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExperimentalFeatures + */ + public static fromObject(object: { [k: string]: any }): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Creates a plain object from an ExperimentalFeatures message. Also converts values to other types if specified. + * @param message ExperimentalFeatures + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.PythonSettings.ExperimentalFeatures, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExperimentalFeatures to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExperimentalFeatures + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + /** Properties of a NodeSettings. */ interface INodeSettings { @@ -18110,6 +18234,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -18124,6 +18251,9 @@ export namespace google { /** GoSettings common. */ public common?: (google.api.ICommonLanguageSettings|null); + /** GoSettings renamedServices. */ + public renamedServices: { [k: string]: string }; + /** * Creates a new GoSettings instance using the specified properties. * @param [properties] Properties to set @@ -18448,6 +18578,109 @@ export namespace google { PACKAGE_MANAGER = 20 } + /** Properties of a SelectiveGapicGeneration. */ + interface ISelectiveGapicGeneration { + + /** SelectiveGapicGeneration methods */ + methods?: (string[]|null); + + /** SelectiveGapicGeneration generateOmittedAsInternal */ + generateOmittedAsInternal?: (boolean|null); + } + + /** Represents a SelectiveGapicGeneration. */ + class SelectiveGapicGeneration implements ISelectiveGapicGeneration { + + /** + * Constructs a new SelectiveGapicGeneration. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.ISelectiveGapicGeneration); + + /** SelectiveGapicGeneration methods. */ + public methods: string[]; + + /** SelectiveGapicGeneration generateOmittedAsInternal. */ + public generateOmittedAsInternal: boolean; + + /** + * Creates a new SelectiveGapicGeneration instance using the specified properties. + * @param [properties] Properties to set + * @returns SelectiveGapicGeneration instance + */ + public static create(properties?: google.api.ISelectiveGapicGeneration): google.api.SelectiveGapicGeneration; + + /** + * Encodes the specified SelectiveGapicGeneration message. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @param message SelectiveGapicGeneration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.ISelectiveGapicGeneration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SelectiveGapicGeneration message, length delimited. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @param message SelectiveGapicGeneration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.ISelectiveGapicGeneration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SelectiveGapicGeneration + * @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.api.SelectiveGapicGeneration; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SelectiveGapicGeneration + * @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.api.SelectiveGapicGeneration; + + /** + * Verifies a SelectiveGapicGeneration 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 SelectiveGapicGeneration message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SelectiveGapicGeneration + */ + public static fromObject(object: { [k: string]: any }): google.api.SelectiveGapicGeneration; + + /** + * Creates a plain object from a SelectiveGapicGeneration message. Also converts values to other types if specified. + * @param message SelectiveGapicGeneration + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.SelectiveGapicGeneration, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SelectiveGapicGeneration to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SelectiveGapicGeneration + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** LaunchStage enum. */ enum LaunchStage { LAUNCH_STAGE_UNSPECIFIED = 0, @@ -18465,6 +18698,9 @@ export namespace google { /** FieldInfo format */ format?: (google.api.FieldInfo.Format|keyof typeof google.api.FieldInfo.Format|null); + + /** FieldInfo referencedTypes */ + referencedTypes?: (google.api.ITypeReference[]|null); } /** Represents a FieldInfo. */ @@ -18479,6 +18715,9 @@ export namespace google { /** FieldInfo format. */ public format: (google.api.FieldInfo.Format|keyof typeof google.api.FieldInfo.Format); + /** FieldInfo referencedTypes. */ + public referencedTypes: google.api.ITypeReference[]; + /** * Creates a new FieldInfo instance using the specified properties. * @param [properties] Properties to set @@ -18568,6 +18807,103 @@ export namespace google { IPV4_OR_IPV6 = 4 } } + + /** Properties of a TypeReference. */ + interface ITypeReference { + + /** TypeReference typeName */ + typeName?: (string|null); + } + + /** Represents a TypeReference. */ + class TypeReference implements ITypeReference { + + /** + * Constructs a new TypeReference. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.ITypeReference); + + /** TypeReference typeName. */ + public typeName: string; + + /** + * Creates a new TypeReference instance using the specified properties. + * @param [properties] Properties to set + * @returns TypeReference instance + */ + public static create(properties?: google.api.ITypeReference): google.api.TypeReference; + + /** + * Encodes the specified TypeReference message. Does not implicitly {@link google.api.TypeReference.verify|verify} messages. + * @param message TypeReference message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.ITypeReference, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified TypeReference message, length delimited. Does not implicitly {@link google.api.TypeReference.verify|verify} messages. + * @param message TypeReference message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.ITypeReference, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TypeReference message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns TypeReference + * @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.api.TypeReference; + + /** + * Decodes a TypeReference message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns TypeReference + * @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.api.TypeReference; + + /** + * Verifies a TypeReference 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 TypeReference message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TypeReference + */ + public static fromObject(object: { [k: string]: any }): google.api.TypeReference; + + /** + * Creates a plain object from a TypeReference message. Also converts values to other types if specified. + * @param message TypeReference + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.TypeReference, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TypeReference to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for TypeReference + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } } /** Namespace protobuf. */ @@ -18673,6 +19009,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -18703,6 +19040,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -18752,6 +19092,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -18886,6 +19229,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -18927,6 +19273,9 @@ export namespace google { /** DescriptorProto reservedName. */ public reservedName: string[]; + /** DescriptorProto visibility. */ + public visibility: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility); + /** * Creates a new DescriptorProto instance using the specified properties. * @param [properties] Properties to set @@ -19774,6 +20123,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -19800,6 +20152,9 @@ export namespace google { /** EnumDescriptorProto reservedName. */ public reservedName: string[]; + /** EnumDescriptorProto visibility. */ + public visibility: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility); + /** * Creates a new EnumDescriptorProto instance using the specified properties. * @param [properties] Properties to set @@ -20734,6 +21089,9 @@ export namespace google { /** FieldOptions features */ features?: (google.protobuf.IFeatureSet|null); + /** FieldOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** FieldOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); @@ -20792,6 +21150,9 @@ export namespace google { /** FieldOptions features. */ public features?: (google.protobuf.IFeatureSet|null); + /** FieldOptions featureSupport. */ + public featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** FieldOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; @@ -21012,6 +21373,121 @@ export namespace google { */ public static getTypeUrl(typeUrlPrefix?: string): string; } + + /** Properties of a FeatureSupport. */ + interface IFeatureSupport { + + /** FeatureSupport editionIntroduced */ + editionIntroduced?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSupport editionDeprecated */ + editionDeprecated?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSupport deprecationWarning */ + deprecationWarning?: (string|null); + + /** FeatureSupport editionRemoved */ + editionRemoved?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + } + + /** Represents a FeatureSupport. */ + class FeatureSupport implements IFeatureSupport { + + /** + * Constructs a new FeatureSupport. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.FieldOptions.IFeatureSupport); + + /** FeatureSupport editionIntroduced. */ + public editionIntroduced: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSupport editionDeprecated. */ + public editionDeprecated: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSupport deprecationWarning. */ + public deprecationWarning: string; + + /** FeatureSupport editionRemoved. */ + public editionRemoved: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** + * Creates a new FeatureSupport instance using the specified properties. + * @param [properties] Properties to set + * @returns FeatureSupport instance + */ + public static create(properties?: google.protobuf.FieldOptions.IFeatureSupport): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Encodes the specified FeatureSupport message. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @param message FeatureSupport message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.FieldOptions.IFeatureSupport, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FeatureSupport message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @param message FeatureSupport message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.FieldOptions.IFeatureSupport, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FeatureSupport + * @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.protobuf.FieldOptions.FeatureSupport; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FeatureSupport + * @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.protobuf.FieldOptions.FeatureSupport; + + /** + * Verifies a FeatureSupport 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 FeatureSupport message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FeatureSupport + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Creates a plain object from a FeatureSupport message. Also converts values to other types if specified. + * @param message FeatureSupport + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldOptions.FeatureSupport, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FeatureSupport to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FeatureSupport + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } } /** Properties of an OneofOptions. */ @@ -21250,6 +21726,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -21272,6 +21751,9 @@ export namespace google { /** EnumValueOptions debugRedact. */ public debugRedact: boolean; + /** EnumValueOptions featureSupport. */ + public featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; @@ -21864,6 +22346,12 @@ export namespace google { /** FeatureSet jsonFormat */ jsonFormat?: (google.protobuf.FeatureSet.JsonFormat|keyof typeof google.protobuf.FeatureSet.JsonFormat|null); + + /** FeatureSet enforceNamingStyle */ + enforceNamingStyle?: (google.protobuf.FeatureSet.EnforceNamingStyle|keyof typeof google.protobuf.FeatureSet.EnforceNamingStyle|null); + + /** FeatureSet defaultSymbolVisibility */ + defaultSymbolVisibility?: (google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|keyof typeof google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|null); } /** Represents a FeatureSet. */ @@ -21893,6 +22381,12 @@ export namespace google { /** FeatureSet jsonFormat. */ public jsonFormat: (google.protobuf.FeatureSet.JsonFormat|keyof typeof google.protobuf.FeatureSet.JsonFormat); + /** FeatureSet enforceNamingStyle. */ + public enforceNamingStyle: (google.protobuf.FeatureSet.EnforceNamingStyle|keyof typeof google.protobuf.FeatureSet.EnforceNamingStyle); + + /** FeatureSet defaultSymbolVisibility. */ + public defaultSymbolVisibility: (google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|keyof typeof google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility); + /** * Creates a new FeatureSet instance using the specified properties. * @param [properties] Properties to set @@ -22015,6 +22509,116 @@ export namespace google { ALLOW = 1, LEGACY_BEST_EFFORT = 2 } + + /** EnforceNamingStyle enum. */ + enum EnforceNamingStyle { + ENFORCE_NAMING_STYLE_UNKNOWN = 0, + STYLE2024 = 1, + STYLE_LEGACY = 2 + } + + /** Properties of a VisibilityFeature. */ + interface IVisibilityFeature { + } + + /** Represents a VisibilityFeature. */ + class VisibilityFeature implements IVisibilityFeature { + + /** + * Constructs a new VisibilityFeature. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.FeatureSet.IVisibilityFeature); + + /** + * Creates a new VisibilityFeature instance using the specified properties. + * @param [properties] Properties to set + * @returns VisibilityFeature instance + */ + public static create(properties?: google.protobuf.FeatureSet.IVisibilityFeature): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Encodes the specified VisibilityFeature message. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @param message VisibilityFeature message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.FeatureSet.IVisibilityFeature, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified VisibilityFeature message, length delimited. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @param message VisibilityFeature message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.FeatureSet.IVisibilityFeature, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns VisibilityFeature + * @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.protobuf.FeatureSet.VisibilityFeature; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns VisibilityFeature + * @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.protobuf.FeatureSet.VisibilityFeature; + + /** + * Verifies a VisibilityFeature 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 VisibilityFeature message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns VisibilityFeature + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Creates a plain object from a VisibilityFeature message. Also converts values to other types if specified. + * @param message VisibilityFeature + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FeatureSet.VisibilityFeature, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this VisibilityFeature to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for VisibilityFeature + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace VisibilityFeature { + + /** DefaultSymbolVisibility enum. */ + enum DefaultSymbolVisibility { + DEFAULT_SYMBOL_VISIBILITY_UNKNOWN = 0, + EXPORT_ALL = 1, + EXPORT_TOP_LEVEL = 2, + LOCAL_ALL = 3, + STRICT = 4 + } + } } /** Properties of a FeatureSetDefaults. */ @@ -22134,8 +22738,11 @@ export namespace google { /** FeatureSetEditionDefault edition */ edition?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); - /** FeatureSetEditionDefault features */ - features?: (google.protobuf.IFeatureSet|null); + /** FeatureSetEditionDefault overridableFeatures */ + overridableFeatures?: (google.protobuf.IFeatureSet|null); + + /** FeatureSetEditionDefault fixedFeatures */ + fixedFeatures?: (google.protobuf.IFeatureSet|null); } /** Represents a FeatureSetEditionDefault. */ @@ -22150,8 +22757,11 @@ export namespace google { /** FeatureSetEditionDefault edition. */ public edition: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); - /** FeatureSetEditionDefault features. */ - public features?: (google.protobuf.IFeatureSet|null); + /** FeatureSetEditionDefault overridableFeatures. */ + public overridableFeatures?: (google.protobuf.IFeatureSet|null); + + /** FeatureSetEditionDefault fixedFeatures. */ + public fixedFeatures?: (google.protobuf.IFeatureSet|null); /** * Creates a new FeatureSetEditionDefault instance using the specified properties. @@ -22684,6 +23294,13 @@ export namespace google { } } + /** SymbolVisibility enum. */ + enum SymbolVisibility { + VISIBILITY_UNSET = 0, + VISIBILITY_LOCAL = 1, + VISIBILITY_EXPORT = 2 + } + /** Properties of a FieldMask. */ interface IFieldMask { diff --git a/packages/google-cloud-netapp/protos/protos.js b/packages/google-cloud-netapp/protos/protos.js index ad8f2ad492a7..a9467c67e8f2 100644 --- a/packages/google-cloud-netapp/protos/protos.js +++ b/packages/google-cloud-netapp/protos/protos.js @@ -43702,6 +43702,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -43736,6 +43737,14 @@ */ CommonLanguageSettings.prototype.destinations = $util.emptyArray; + /** + * CommonLanguageSettings selectiveGapicGeneration. + * @member {google.api.ISelectiveGapicGeneration|null|undefined} selectiveGapicGeneration + * @memberof google.api.CommonLanguageSettings + * @instance + */ + CommonLanguageSettings.prototype.selectiveGapicGeneration = null; + /** * Creates a new CommonLanguageSettings instance using the specified properties. * @function create @@ -43768,6 +43777,8 @@ writer.int32(message.destinations[i]); writer.ldelim(); } + if (message.selectiveGapicGeneration != null && Object.hasOwnProperty.call(message, "selectiveGapicGeneration")) + $root.google.api.SelectiveGapicGeneration.encode(message.selectiveGapicGeneration, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); return writer; }; @@ -43819,6 +43830,10 @@ message.destinations.push(reader.int32()); break; } + case 3: { + message.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -43870,6 +43885,11 @@ break; } } + if (message.selectiveGapicGeneration != null && message.hasOwnProperty("selectiveGapicGeneration")) { + var error = $root.google.api.SelectiveGapicGeneration.verify(message.selectiveGapicGeneration); + if (error) + return "selectiveGapicGeneration." + error; + } return null; }; @@ -43912,6 +43932,11 @@ break; } } + if (object.selectiveGapicGeneration != null) { + if (typeof object.selectiveGapicGeneration !== "object") + throw TypeError(".google.api.CommonLanguageSettings.selectiveGapicGeneration: object expected"); + message.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.fromObject(object.selectiveGapicGeneration); + } return message; }; @@ -43930,8 +43955,10 @@ var object = {}; if (options.arrays || options.defaults) object.destinations = []; - if (options.defaults) + if (options.defaults) { object.referenceDocsUri = ""; + object.selectiveGapicGeneration = null; + } if (message.referenceDocsUri != null && message.hasOwnProperty("referenceDocsUri")) object.referenceDocsUri = message.referenceDocsUri; if (message.destinations && message.destinations.length) { @@ -43939,6 +43966,8 @@ for (var j = 0; j < message.destinations.length; ++j) object.destinations[j] = options.enums === String ? $root.google.api.ClientLibraryDestination[message.destinations[j]] === undefined ? message.destinations[j] : $root.google.api.ClientLibraryDestination[message.destinations[j]] : message.destinations[j]; } + if (message.selectiveGapicGeneration != null && message.hasOwnProperty("selectiveGapicGeneration")) + object.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.toObject(message.selectiveGapicGeneration, options); return object; }; @@ -45761,6 +45790,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -45786,6 +45816,14 @@ */ PythonSettings.prototype.common = null; + /** + * PythonSettings experimentalFeatures. + * @member {google.api.PythonSettings.IExperimentalFeatures|null|undefined} experimentalFeatures + * @memberof google.api.PythonSettings + * @instance + */ + PythonSettings.prototype.experimentalFeatures = null; + /** * Creates a new PythonSettings instance using the specified properties. * @function create @@ -45812,6 +45850,8 @@ writer = $Writer.create(); if (message.common != null && Object.hasOwnProperty.call(message, "common")) $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.experimentalFeatures != null && Object.hasOwnProperty.call(message, "experimentalFeatures")) + $root.google.api.PythonSettings.ExperimentalFeatures.encode(message.experimentalFeatures, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; @@ -45852,6 +45892,10 @@ message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); break; } + case 2: { + message.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -45892,6 +45936,11 @@ if (error) return "common." + error; } + if (message.experimentalFeatures != null && message.hasOwnProperty("experimentalFeatures")) { + var error = $root.google.api.PythonSettings.ExperimentalFeatures.verify(message.experimentalFeatures); + if (error) + return "experimentalFeatures." + error; + } return null; }; @@ -45912,6 +45961,11 @@ throw TypeError(".google.api.PythonSettings.common: object expected"); message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); } + if (object.experimentalFeatures != null) { + if (typeof object.experimentalFeatures !== "object") + throw TypeError(".google.api.PythonSettings.experimentalFeatures: object expected"); + message.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.fromObject(object.experimentalFeatures); + } return message; }; @@ -45928,10 +45982,14 @@ if (!options) options = {}; var object = {}; - if (options.defaults) + if (options.defaults) { object.common = null; + object.experimentalFeatures = null; + } if (message.common != null && message.hasOwnProperty("common")) object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + if (message.experimentalFeatures != null && message.hasOwnProperty("experimentalFeatures")) + object.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.toObject(message.experimentalFeatures, options); return object; }; @@ -45961,6 +46019,258 @@ return typeUrlPrefix + "/google.api.PythonSettings"; }; + PythonSettings.ExperimentalFeatures = (function() { + + /** + * Properties of an ExperimentalFeatures. + * @memberof google.api.PythonSettings + * @interface IExperimentalFeatures + * @property {boolean|null} [restAsyncIoEnabled] ExperimentalFeatures restAsyncIoEnabled + * @property {boolean|null} [protobufPythonicTypesEnabled] ExperimentalFeatures protobufPythonicTypesEnabled + * @property {boolean|null} [unversionedPackageDisabled] ExperimentalFeatures unversionedPackageDisabled + */ + + /** + * Constructs a new ExperimentalFeatures. + * @memberof google.api.PythonSettings + * @classdesc Represents an ExperimentalFeatures. + * @implements IExperimentalFeatures + * @constructor + * @param {google.api.PythonSettings.IExperimentalFeatures=} [properties] Properties to set + */ + function ExperimentalFeatures(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]]; + } + + /** + * ExperimentalFeatures restAsyncIoEnabled. + * @member {boolean} restAsyncIoEnabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.restAsyncIoEnabled = false; + + /** + * ExperimentalFeatures protobufPythonicTypesEnabled. + * @member {boolean} protobufPythonicTypesEnabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.protobufPythonicTypesEnabled = false; + + /** + * ExperimentalFeatures unversionedPackageDisabled. + * @member {boolean} unversionedPackageDisabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.unversionedPackageDisabled = false; + + /** + * Creates a new ExperimentalFeatures instance using the specified properties. + * @function create + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures=} [properties] Properties to set + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures instance + */ + ExperimentalFeatures.create = function create(properties) { + return new ExperimentalFeatures(properties); + }; + + /** + * Encodes the specified ExperimentalFeatures message. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @function encode + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures} message ExperimentalFeatures message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExperimentalFeatures.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.restAsyncIoEnabled != null && Object.hasOwnProperty.call(message, "restAsyncIoEnabled")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.restAsyncIoEnabled); + if (message.protobufPythonicTypesEnabled != null && Object.hasOwnProperty.call(message, "protobufPythonicTypesEnabled")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.protobufPythonicTypesEnabled); + if (message.unversionedPackageDisabled != null && Object.hasOwnProperty.call(message, "unversionedPackageDisabled")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.unversionedPackageDisabled); + return writer; + }; + + /** + * Encodes the specified ExperimentalFeatures message, length delimited. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures} message ExperimentalFeatures message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExperimentalFeatures.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer. + * @function decode + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExperimentalFeatures.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.PythonSettings.ExperimentalFeatures(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.restAsyncIoEnabled = reader.bool(); + break; + } + case 2: { + message.protobufPythonicTypesEnabled = reader.bool(); + break; + } + case 3: { + message.unversionedPackageDisabled = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExperimentalFeatures.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExperimentalFeatures message. + * @function verify + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExperimentalFeatures.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.restAsyncIoEnabled != null && message.hasOwnProperty("restAsyncIoEnabled")) + if (typeof message.restAsyncIoEnabled !== "boolean") + return "restAsyncIoEnabled: boolean expected"; + if (message.protobufPythonicTypesEnabled != null && message.hasOwnProperty("protobufPythonicTypesEnabled")) + if (typeof message.protobufPythonicTypesEnabled !== "boolean") + return "protobufPythonicTypesEnabled: boolean expected"; + if (message.unversionedPackageDisabled != null && message.hasOwnProperty("unversionedPackageDisabled")) + if (typeof message.unversionedPackageDisabled !== "boolean") + return "unversionedPackageDisabled: boolean expected"; + return null; + }; + + /** + * Creates an ExperimentalFeatures message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {Object.} object Plain object + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + */ + ExperimentalFeatures.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.PythonSettings.ExperimentalFeatures) + return object; + var message = new $root.google.api.PythonSettings.ExperimentalFeatures(); + if (object.restAsyncIoEnabled != null) + message.restAsyncIoEnabled = Boolean(object.restAsyncIoEnabled); + if (object.protobufPythonicTypesEnabled != null) + message.protobufPythonicTypesEnabled = Boolean(object.protobufPythonicTypesEnabled); + if (object.unversionedPackageDisabled != null) + message.unversionedPackageDisabled = Boolean(object.unversionedPackageDisabled); + return message; + }; + + /** + * Creates a plain object from an ExperimentalFeatures message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.ExperimentalFeatures} message ExperimentalFeatures + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExperimentalFeatures.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.restAsyncIoEnabled = false; + object.protobufPythonicTypesEnabled = false; + object.unversionedPackageDisabled = false; + } + if (message.restAsyncIoEnabled != null && message.hasOwnProperty("restAsyncIoEnabled")) + object.restAsyncIoEnabled = message.restAsyncIoEnabled; + if (message.protobufPythonicTypesEnabled != null && message.hasOwnProperty("protobufPythonicTypesEnabled")) + object.protobufPythonicTypesEnabled = message.protobufPythonicTypesEnabled; + if (message.unversionedPackageDisabled != null && message.hasOwnProperty("unversionedPackageDisabled")) + object.unversionedPackageDisabled = message.unversionedPackageDisabled; + return object; + }; + + /** + * Converts this ExperimentalFeatures to JSON. + * @function toJSON + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + * @returns {Object.} JSON object + */ + ExperimentalFeatures.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExperimentalFeatures + * @function getTypeUrl + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExperimentalFeatures.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.PythonSettings.ExperimentalFeatures"; + }; + + return ExperimentalFeatures; + })(); + return PythonSettings; })(); @@ -46837,6 +47147,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -46848,6 +47159,7 @@ * @param {google.api.IGoSettings=} [properties] Properties to set */ function GoSettings(properties) { + this.renamedServices = {}; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -46862,6 +47174,14 @@ */ GoSettings.prototype.common = null; + /** + * GoSettings renamedServices. + * @member {Object.} renamedServices + * @memberof google.api.GoSettings + * @instance + */ + GoSettings.prototype.renamedServices = $util.emptyObject; + /** * Creates a new GoSettings instance using the specified properties. * @function create @@ -46888,6 +47208,9 @@ writer = $Writer.create(); if (message.common != null && Object.hasOwnProperty.call(message, "common")) $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.renamedServices != null && Object.hasOwnProperty.call(message, "renamedServices")) + for (var keys = Object.keys(message.renamedServices), i = 0; i < keys.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.renamedServices[keys[i]]).ldelim(); return writer; }; @@ -46918,7 +47241,7 @@ GoSettings.decode = function decode(reader, length, error) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.GoSettings(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.GoSettings(), key, value; while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) @@ -46928,6 +47251,29 @@ message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); break; } + case 2: { + if (message.renamedServices === $util.emptyObject) + message.renamedServices = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = ""; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = reader.string(); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.renamedServices[key] = value; + break; + } default: reader.skipType(tag & 7); break; @@ -46968,6 +47314,14 @@ if (error) return "common." + error; } + if (message.renamedServices != null && message.hasOwnProperty("renamedServices")) { + if (!$util.isObject(message.renamedServices)) + return "renamedServices: object expected"; + var key = Object.keys(message.renamedServices); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.renamedServices[key[i]])) + return "renamedServices: string{k:string} expected"; + } return null; }; @@ -46988,6 +47342,13 @@ throw TypeError(".google.api.GoSettings.common: object expected"); message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); } + if (object.renamedServices) { + if (typeof object.renamedServices !== "object") + throw TypeError(".google.api.GoSettings.renamedServices: object expected"); + message.renamedServices = {}; + for (var keys = Object.keys(object.renamedServices), i = 0; i < keys.length; ++i) + message.renamedServices[keys[i]] = String(object.renamedServices[keys[i]]); + } return message; }; @@ -47004,10 +47365,18 @@ if (!options) options = {}; var object = {}; + if (options.objects || options.defaults) + object.renamedServices = {}; if (options.defaults) object.common = null; if (message.common != null && message.hasOwnProperty("common")) object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + var keys2; + if (message.renamedServices && (keys2 = Object.keys(message.renamedServices)).length) { + object.renamedServices = {}; + for (var j = 0; j < keys2.length; ++j) + object.renamedServices[keys2[j]] = message.renamedServices[keys2[j]]; + } return object; }; @@ -47646,29 +48015,274 @@ return values; })(); - /** - * LaunchStage enum. - * @name google.api.LaunchStage - * @enum {number} - * @property {number} LAUNCH_STAGE_UNSPECIFIED=0 LAUNCH_STAGE_UNSPECIFIED value - * @property {number} UNIMPLEMENTED=6 UNIMPLEMENTED value - * @property {number} PRELAUNCH=7 PRELAUNCH value - * @property {number} EARLY_ACCESS=1 EARLY_ACCESS value - * @property {number} ALPHA=2 ALPHA value - * @property {number} BETA=3 BETA value - * @property {number} GA=4 GA value - * @property {number} DEPRECATED=5 DEPRECATED value - */ - api.LaunchStage = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "LAUNCH_STAGE_UNSPECIFIED"] = 0; - values[valuesById[6] = "UNIMPLEMENTED"] = 6; - values[valuesById[7] = "PRELAUNCH"] = 7; - values[valuesById[1] = "EARLY_ACCESS"] = 1; - values[valuesById[2] = "ALPHA"] = 2; - values[valuesById[3] = "BETA"] = 3; - values[valuesById[4] = "GA"] = 4; - values[valuesById[5] = "DEPRECATED"] = 5; + api.SelectiveGapicGeneration = (function() { + + /** + * Properties of a SelectiveGapicGeneration. + * @memberof google.api + * @interface ISelectiveGapicGeneration + * @property {Array.|null} [methods] SelectiveGapicGeneration methods + * @property {boolean|null} [generateOmittedAsInternal] SelectiveGapicGeneration generateOmittedAsInternal + */ + + /** + * Constructs a new SelectiveGapicGeneration. + * @memberof google.api + * @classdesc Represents a SelectiveGapicGeneration. + * @implements ISelectiveGapicGeneration + * @constructor + * @param {google.api.ISelectiveGapicGeneration=} [properties] Properties to set + */ + function SelectiveGapicGeneration(properties) { + this.methods = []; + 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]]; + } + + /** + * SelectiveGapicGeneration methods. + * @member {Array.} methods + * @memberof google.api.SelectiveGapicGeneration + * @instance + */ + SelectiveGapicGeneration.prototype.methods = $util.emptyArray; + + /** + * SelectiveGapicGeneration generateOmittedAsInternal. + * @member {boolean} generateOmittedAsInternal + * @memberof google.api.SelectiveGapicGeneration + * @instance + */ + SelectiveGapicGeneration.prototype.generateOmittedAsInternal = false; + + /** + * Creates a new SelectiveGapicGeneration instance using the specified properties. + * @function create + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration=} [properties] Properties to set + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration instance + */ + SelectiveGapicGeneration.create = function create(properties) { + return new SelectiveGapicGeneration(properties); + }; + + /** + * Encodes the specified SelectiveGapicGeneration message. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @function encode + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration} message SelectiveGapicGeneration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SelectiveGapicGeneration.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.methods != null && message.methods.length) + for (var i = 0; i < message.methods.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.methods[i]); + if (message.generateOmittedAsInternal != null && Object.hasOwnProperty.call(message, "generateOmittedAsInternal")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.generateOmittedAsInternal); + return writer; + }; + + /** + * Encodes the specified SelectiveGapicGeneration message, length delimited. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration} message SelectiveGapicGeneration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SelectiveGapicGeneration.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer. + * @function decode + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SelectiveGapicGeneration.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.SelectiveGapicGeneration(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + if (!(message.methods && message.methods.length)) + message.methods = []; + message.methods.push(reader.string()); + break; + } + case 2: { + message.generateOmittedAsInternal = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SelectiveGapicGeneration.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SelectiveGapicGeneration message. + * @function verify + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SelectiveGapicGeneration.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.methods != null && message.hasOwnProperty("methods")) { + if (!Array.isArray(message.methods)) + return "methods: array expected"; + for (var i = 0; i < message.methods.length; ++i) + if (!$util.isString(message.methods[i])) + return "methods: string[] expected"; + } + if (message.generateOmittedAsInternal != null && message.hasOwnProperty("generateOmittedAsInternal")) + if (typeof message.generateOmittedAsInternal !== "boolean") + return "generateOmittedAsInternal: boolean expected"; + return null; + }; + + /** + * Creates a SelectiveGapicGeneration message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {Object.} object Plain object + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + */ + SelectiveGapicGeneration.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.SelectiveGapicGeneration) + return object; + var message = new $root.google.api.SelectiveGapicGeneration(); + if (object.methods) { + if (!Array.isArray(object.methods)) + throw TypeError(".google.api.SelectiveGapicGeneration.methods: array expected"); + message.methods = []; + for (var i = 0; i < object.methods.length; ++i) + message.methods[i] = String(object.methods[i]); + } + if (object.generateOmittedAsInternal != null) + message.generateOmittedAsInternal = Boolean(object.generateOmittedAsInternal); + return message; + }; + + /** + * Creates a plain object from a SelectiveGapicGeneration message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.SelectiveGapicGeneration} message SelectiveGapicGeneration + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SelectiveGapicGeneration.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.methods = []; + if (options.defaults) + object.generateOmittedAsInternal = false; + if (message.methods && message.methods.length) { + object.methods = []; + for (var j = 0; j < message.methods.length; ++j) + object.methods[j] = message.methods[j]; + } + if (message.generateOmittedAsInternal != null && message.hasOwnProperty("generateOmittedAsInternal")) + object.generateOmittedAsInternal = message.generateOmittedAsInternal; + return object; + }; + + /** + * Converts this SelectiveGapicGeneration to JSON. + * @function toJSON + * @memberof google.api.SelectiveGapicGeneration + * @instance + * @returns {Object.} JSON object + */ + SelectiveGapicGeneration.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SelectiveGapicGeneration + * @function getTypeUrl + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SelectiveGapicGeneration.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.SelectiveGapicGeneration"; + }; + + return SelectiveGapicGeneration; + })(); + + /** + * LaunchStage enum. + * @name google.api.LaunchStage + * @enum {number} + * @property {number} LAUNCH_STAGE_UNSPECIFIED=0 LAUNCH_STAGE_UNSPECIFIED value + * @property {number} UNIMPLEMENTED=6 UNIMPLEMENTED value + * @property {number} PRELAUNCH=7 PRELAUNCH value + * @property {number} EARLY_ACCESS=1 EARLY_ACCESS value + * @property {number} ALPHA=2 ALPHA value + * @property {number} BETA=3 BETA value + * @property {number} GA=4 GA value + * @property {number} DEPRECATED=5 DEPRECATED value + */ + api.LaunchStage = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "LAUNCH_STAGE_UNSPECIFIED"] = 0; + values[valuesById[6] = "UNIMPLEMENTED"] = 6; + values[valuesById[7] = "PRELAUNCH"] = 7; + values[valuesById[1] = "EARLY_ACCESS"] = 1; + values[valuesById[2] = "ALPHA"] = 2; + values[valuesById[3] = "BETA"] = 3; + values[valuesById[4] = "GA"] = 4; + values[valuesById[5] = "DEPRECATED"] = 5; return values; })(); @@ -47679,6 +48293,7 @@ * @memberof google.api * @interface IFieldInfo * @property {google.api.FieldInfo.Format|null} [format] FieldInfo format + * @property {Array.|null} [referencedTypes] FieldInfo referencedTypes */ /** @@ -47690,6 +48305,7 @@ * @param {google.api.IFieldInfo=} [properties] Properties to set */ function FieldInfo(properties) { + this.referencedTypes = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -47704,6 +48320,14 @@ */ FieldInfo.prototype.format = 0; + /** + * FieldInfo referencedTypes. + * @member {Array.} referencedTypes + * @memberof google.api.FieldInfo + * @instance + */ + FieldInfo.prototype.referencedTypes = $util.emptyArray; + /** * Creates a new FieldInfo instance using the specified properties. * @function create @@ -47730,6 +48354,9 @@ writer = $Writer.create(); if (message.format != null && Object.hasOwnProperty.call(message, "format")) writer.uint32(/* id 1, wireType 0 =*/8).int32(message.format); + if (message.referencedTypes != null && message.referencedTypes.length) + for (var i = 0; i < message.referencedTypes.length; ++i) + $root.google.api.TypeReference.encode(message.referencedTypes[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; @@ -47770,6 +48397,12 @@ message.format = reader.int32(); break; } + case 2: { + if (!(message.referencedTypes && message.referencedTypes.length)) + message.referencedTypes = []; + message.referencedTypes.push($root.google.api.TypeReference.decode(reader, reader.uint32())); + break; + } default: reader.skipType(tag & 7); break; @@ -47816,6 +48449,15 @@ case 4: break; } + if (message.referencedTypes != null && message.hasOwnProperty("referencedTypes")) { + if (!Array.isArray(message.referencedTypes)) + return "referencedTypes: array expected"; + for (var i = 0; i < message.referencedTypes.length; ++i) { + var error = $root.google.api.TypeReference.verify(message.referencedTypes[i]); + if (error) + return "referencedTypes." + error; + } + } return null; }; @@ -47859,6 +48501,16 @@ message.format = 4; break; } + if (object.referencedTypes) { + if (!Array.isArray(object.referencedTypes)) + throw TypeError(".google.api.FieldInfo.referencedTypes: array expected"); + message.referencedTypes = []; + for (var i = 0; i < object.referencedTypes.length; ++i) { + if (typeof object.referencedTypes[i] !== "object") + throw TypeError(".google.api.FieldInfo.referencedTypes: object expected"); + message.referencedTypes[i] = $root.google.api.TypeReference.fromObject(object.referencedTypes[i]); + } + } return message; }; @@ -47875,10 +48527,17 @@ if (!options) options = {}; var object = {}; + if (options.arrays || options.defaults) + object.referencedTypes = []; if (options.defaults) object.format = options.enums === String ? "FORMAT_UNSPECIFIED" : 0; if (message.format != null && message.hasOwnProperty("format")) object.format = options.enums === String ? $root.google.api.FieldInfo.Format[message.format] === undefined ? message.format : $root.google.api.FieldInfo.Format[message.format] : message.format; + if (message.referencedTypes && message.referencedTypes.length) { + object.referencedTypes = []; + for (var j = 0; j < message.referencedTypes.length; ++j) + object.referencedTypes[j] = $root.google.api.TypeReference.toObject(message.referencedTypes[j], options); + } return object; }; @@ -47931,37 +48590,24 @@ return FieldInfo; })(); - return api; - })(); - - google.protobuf = (function() { - - /** - * Namespace protobuf. - * @memberof google - * @namespace - */ - var protobuf = {}; - - protobuf.FileDescriptorSet = (function() { + api.TypeReference = (function() { /** - * Properties of a FileDescriptorSet. - * @memberof google.protobuf - * @interface IFileDescriptorSet - * @property {Array.|null} [file] FileDescriptorSet file + * Properties of a TypeReference. + * @memberof google.api + * @interface ITypeReference + * @property {string|null} [typeName] TypeReference typeName */ /** - * Constructs a new FileDescriptorSet. - * @memberof google.protobuf - * @classdesc Represents a FileDescriptorSet. - * @implements IFileDescriptorSet + * Constructs a new TypeReference. + * @memberof google.api + * @classdesc Represents a TypeReference. + * @implements ITypeReference * @constructor - * @param {google.protobuf.IFileDescriptorSet=} [properties] Properties to set + * @param {google.api.ITypeReference=} [properties] Properties to set */ - function FileDescriptorSet(properties) { - this.file = []; + function TypeReference(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -47969,80 +48615,77 @@ } /** - * FileDescriptorSet file. - * @member {Array.} file - * @memberof google.protobuf.FileDescriptorSet + * TypeReference typeName. + * @member {string} typeName + * @memberof google.api.TypeReference * @instance */ - FileDescriptorSet.prototype.file = $util.emptyArray; + TypeReference.prototype.typeName = ""; /** - * Creates a new FileDescriptorSet instance using the specified properties. + * Creates a new TypeReference instance using the specified properties. * @function create - * @memberof google.protobuf.FileDescriptorSet + * @memberof google.api.TypeReference * @static - * @param {google.protobuf.IFileDescriptorSet=} [properties] Properties to set - * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet instance + * @param {google.api.ITypeReference=} [properties] Properties to set + * @returns {google.api.TypeReference} TypeReference instance */ - FileDescriptorSet.create = function create(properties) { - return new FileDescriptorSet(properties); + TypeReference.create = function create(properties) { + return new TypeReference(properties); }; /** - * Encodes the specified FileDescriptorSet message. Does not implicitly {@link google.protobuf.FileDescriptorSet.verify|verify} messages. + * Encodes the specified TypeReference message. Does not implicitly {@link google.api.TypeReference.verify|verify} messages. * @function encode - * @memberof google.protobuf.FileDescriptorSet + * @memberof google.api.TypeReference * @static - * @param {google.protobuf.IFileDescriptorSet} message FileDescriptorSet message or plain object to encode + * @param {google.api.ITypeReference} message TypeReference message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - FileDescriptorSet.encode = function encode(message, writer) { + TypeReference.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.file != null && message.file.length) - for (var i = 0; i < message.file.length; ++i) - $root.google.protobuf.FileDescriptorProto.encode(message.file[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.typeName != null && Object.hasOwnProperty.call(message, "typeName")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.typeName); return writer; }; /** - * Encodes the specified FileDescriptorSet message, length delimited. Does not implicitly {@link google.protobuf.FileDescriptorSet.verify|verify} messages. + * Encodes the specified TypeReference message, length delimited. Does not implicitly {@link google.api.TypeReference.verify|verify} messages. * @function encodeDelimited - * @memberof google.protobuf.FileDescriptorSet + * @memberof google.api.TypeReference * @static - * @param {google.protobuf.IFileDescriptorSet} message FileDescriptorSet message or plain object to encode + * @param {google.api.ITypeReference} message TypeReference message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - FileDescriptorSet.encodeDelimited = function encodeDelimited(message, writer) { + TypeReference.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes a FileDescriptorSet message from the specified reader or buffer. + * Decodes a TypeReference message from the specified reader or buffer. * @function decode - * @memberof google.protobuf.FileDescriptorSet + * @memberof google.api.TypeReference * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet + * @returns {google.api.TypeReference} TypeReference * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - FileDescriptorSet.decode = function decode(reader, length, error) { + TypeReference.decode = function decode(reader, length, error) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FileDescriptorSet(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.TypeReference(); while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) break; switch (tag >>> 3) { case 1: { - if (!(message.file && message.file.length)) - message.file = []; - message.file.push($root.google.protobuf.FileDescriptorProto.decode(reader, reader.uint32())); + message.typeName = reader.string(); break; } default: @@ -48054,37 +48697,258 @@ }; /** - * Decodes a FileDescriptorSet message from the specified reader or buffer, length delimited. + * Decodes a TypeReference message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof google.protobuf.FileDescriptorSet + * @memberof google.api.TypeReference * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet + * @returns {google.api.TypeReference} TypeReference * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - FileDescriptorSet.decodeDelimited = function decodeDelimited(reader) { + TypeReference.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies a FileDescriptorSet message. + * Verifies a TypeReference message. * @function verify - * @memberof google.protobuf.FileDescriptorSet + * @memberof google.api.TypeReference * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - FileDescriptorSet.verify = function verify(message) { + TypeReference.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - if (message.file != null && message.hasOwnProperty("file")) { - if (!Array.isArray(message.file)) - return "file: array expected"; - for (var i = 0; i < message.file.length; ++i) { - var error = $root.google.protobuf.FileDescriptorProto.verify(message.file[i]); + if (message.typeName != null && message.hasOwnProperty("typeName")) + if (!$util.isString(message.typeName)) + return "typeName: string expected"; + return null; + }; + + /** + * Creates a TypeReference message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.TypeReference + * @static + * @param {Object.} object Plain object + * @returns {google.api.TypeReference} TypeReference + */ + TypeReference.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.TypeReference) + return object; + var message = new $root.google.api.TypeReference(); + if (object.typeName != null) + message.typeName = String(object.typeName); + return message; + }; + + /** + * Creates a plain object from a TypeReference message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.TypeReference + * @static + * @param {google.api.TypeReference} message TypeReference + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TypeReference.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.typeName = ""; + if (message.typeName != null && message.hasOwnProperty("typeName")) + object.typeName = message.typeName; + return object; + }; + + /** + * Converts this TypeReference to JSON. + * @function toJSON + * @memberof google.api.TypeReference + * @instance + * @returns {Object.} JSON object + */ + TypeReference.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for TypeReference + * @function getTypeUrl + * @memberof google.api.TypeReference + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + TypeReference.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.TypeReference"; + }; + + return TypeReference; + })(); + + return api; + })(); + + google.protobuf = (function() { + + /** + * Namespace protobuf. + * @memberof google + * @namespace + */ + var protobuf = {}; + + protobuf.FileDescriptorSet = (function() { + + /** + * Properties of a FileDescriptorSet. + * @memberof google.protobuf + * @interface IFileDescriptorSet + * @property {Array.|null} [file] FileDescriptorSet file + */ + + /** + * Constructs a new FileDescriptorSet. + * @memberof google.protobuf + * @classdesc Represents a FileDescriptorSet. + * @implements IFileDescriptorSet + * @constructor + * @param {google.protobuf.IFileDescriptorSet=} [properties] Properties to set + */ + function FileDescriptorSet(properties) { + this.file = []; + 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]]; + } + + /** + * FileDescriptorSet file. + * @member {Array.} file + * @memberof google.protobuf.FileDescriptorSet + * @instance + */ + FileDescriptorSet.prototype.file = $util.emptyArray; + + /** + * Creates a new FileDescriptorSet instance using the specified properties. + * @function create + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {google.protobuf.IFileDescriptorSet=} [properties] Properties to set + * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet instance + */ + FileDescriptorSet.create = function create(properties) { + return new FileDescriptorSet(properties); + }; + + /** + * Encodes the specified FileDescriptorSet message. Does not implicitly {@link google.protobuf.FileDescriptorSet.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {google.protobuf.IFileDescriptorSet} message FileDescriptorSet message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileDescriptorSet.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.file != null && message.file.length) + for (var i = 0; i < message.file.length; ++i) + $root.google.protobuf.FileDescriptorProto.encode(message.file[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified FileDescriptorSet message, length delimited. Does not implicitly {@link google.protobuf.FileDescriptorSet.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {google.protobuf.IFileDescriptorSet} message FileDescriptorSet message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileDescriptorSet.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FileDescriptorSet message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileDescriptorSet.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FileDescriptorSet(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + if (!(message.file && message.file.length)) + message.file = []; + message.file.push($root.google.protobuf.FileDescriptorProto.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FileDescriptorSet message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileDescriptorSet.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FileDescriptorSet message. + * @function verify + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FileDescriptorSet.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.file != null && message.hasOwnProperty("file")) { + if (!Array.isArray(message.file)) + return "file: array expected"; + for (var i = 0; i < message.file.length; ++i) { + var error = $root.google.protobuf.FileDescriptorProto.verify(message.file[i]); if (error) return "file." + error; } @@ -48174,6 +49038,7 @@ * @name google.protobuf.Edition * @enum {number} * @property {number} EDITION_UNKNOWN=0 EDITION_UNKNOWN value + * @property {number} EDITION_LEGACY=900 EDITION_LEGACY value * @property {number} EDITION_PROTO2=998 EDITION_PROTO2 value * @property {number} EDITION_PROTO3=999 EDITION_PROTO3 value * @property {number} EDITION_2023=1000 EDITION_2023 value @@ -48188,6 +49053,7 @@ protobuf.Edition = (function() { var valuesById = {}, values = Object.create(valuesById); values[valuesById[0] = "EDITION_UNKNOWN"] = 0; + values[valuesById[900] = "EDITION_LEGACY"] = 900; values[valuesById[998] = "EDITION_PROTO2"] = 998; values[valuesById[999] = "EDITION_PROTO3"] = 999; values[valuesById[1000] = "EDITION_2023"] = 1000; @@ -48212,6 +49078,7 @@ * @property {Array.|null} [dependency] FileDescriptorProto dependency * @property {Array.|null} [publicDependency] FileDescriptorProto publicDependency * @property {Array.|null} [weakDependency] FileDescriptorProto weakDependency + * @property {Array.|null} [optionDependency] FileDescriptorProto optionDependency * @property {Array.|null} [messageType] FileDescriptorProto messageType * @property {Array.|null} [enumType] FileDescriptorProto enumType * @property {Array.|null} [service] FileDescriptorProto service @@ -48234,6 +49101,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -48284,6 +49152,14 @@ */ FileDescriptorProto.prototype.weakDependency = $util.emptyArray; + /** + * FileDescriptorProto optionDependency. + * @member {Array.} optionDependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.optionDependency = $util.emptyArray; + /** * FileDescriptorProto messageType. * @member {Array.} messageType @@ -48405,6 +49281,9 @@ writer.uint32(/* id 12, wireType 2 =*/98).string(message.syntax); if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) writer.uint32(/* id 14, wireType 0 =*/112).int32(message.edition); + if (message.optionDependency != null && message.optionDependency.length) + for (var i = 0; i < message.optionDependency.length; ++i) + writer.uint32(/* id 15, wireType 2 =*/122).string(message.optionDependency[i]); return writer; }; @@ -48477,6 +49356,12 @@ message.weakDependency.push(reader.int32()); break; } + case 15: { + if (!(message.optionDependency && message.optionDependency.length)) + message.optionDependency = []; + message.optionDependency.push(reader.string()); + break; + } case 4: { if (!(message.messageType && message.messageType.length)) message.messageType = []; @@ -48579,6 +49464,13 @@ if (!$util.isInteger(message.weakDependency[i])) return "weakDependency: integer[] expected"; } + if (message.optionDependency != null && message.hasOwnProperty("optionDependency")) { + if (!Array.isArray(message.optionDependency)) + return "optionDependency: array expected"; + for (var i = 0; i < message.optionDependency.length; ++i) + if (!$util.isString(message.optionDependency[i])) + return "optionDependency: string[] expected"; + } if (message.messageType != null && message.hasOwnProperty("messageType")) { if (!Array.isArray(message.messageType)) return "messageType: array expected"; @@ -48633,6 +49525,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -48685,6 +49578,13 @@ for (var i = 0; i < object.weakDependency.length; ++i) message.weakDependency[i] = object.weakDependency[i] | 0; } + if (object.optionDependency) { + if (!Array.isArray(object.optionDependency)) + throw TypeError(".google.protobuf.FileDescriptorProto.optionDependency: array expected"); + message.optionDependency = []; + for (var i = 0; i < object.optionDependency.length; ++i) + message.optionDependency[i] = String(object.optionDependency[i]); + } if (object.messageType) { if (!Array.isArray(object.messageType)) throw TypeError(".google.protobuf.FileDescriptorProto.messageType: array expected"); @@ -48748,6 +49648,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -48813,6 +49717,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -48869,6 +49774,11 @@ object.syntax = message.syntax; if (message.edition != null && message.hasOwnProperty("edition")) object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.optionDependency && message.optionDependency.length) { + object.optionDependency = []; + for (var j = 0; j < message.optionDependency.length; ++j) + object.optionDependency[j] = message.optionDependency[j]; + } return object; }; @@ -48917,6 +49827,7 @@ * @property {google.protobuf.IMessageOptions|null} [options] DescriptorProto options * @property {Array.|null} [reservedRange] DescriptorProto reservedRange * @property {Array.|null} [reservedName] DescriptorProto reservedName + * @property {google.protobuf.SymbolVisibility|null} [visibility] DescriptorProto visibility */ /** @@ -49022,6 +49933,14 @@ */ DescriptorProto.prototype.reservedName = $util.emptyArray; + /** + * DescriptorProto visibility. + * @member {google.protobuf.SymbolVisibility} visibility + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.visibility = 0; + /** * Creates a new DescriptorProto instance using the specified properties. * @function create @@ -49074,6 +49993,8 @@ if (message.reservedName != null && message.reservedName.length) for (var i = 0; i < message.reservedName.length; ++i) writer.uint32(/* id 10, wireType 2 =*/82).string(message.reservedName[i]); + if (message.visibility != null && Object.hasOwnProperty.call(message, "visibility")) + writer.uint32(/* id 11, wireType 0 =*/88).int32(message.visibility); return writer; }; @@ -49166,6 +50087,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -49279,6 +50204,15 @@ if (!$util.isString(message.reservedName[i])) return "reservedName: string[] expected"; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + switch (message.visibility) { + default: + return "visibility: enum value expected"; + case 0: + case 1: + case 2: + break; + } return null; }; @@ -49378,6 +50312,26 @@ for (var i = 0; i < object.reservedName.length; ++i) message.reservedName[i] = String(object.reservedName[i]); } + switch (object.visibility) { + default: + if (typeof object.visibility === "number") { + message.visibility = object.visibility; + break; + } + break; + case "VISIBILITY_UNSET": + case 0: + message.visibility = 0; + break; + case "VISIBILITY_LOCAL": + case 1: + message.visibility = 1; + break; + case "VISIBILITY_EXPORT": + case 2: + message.visibility = 2; + break; + } return message; }; @@ -49407,6 +50361,7 @@ if (options.defaults) { object.name = ""; object.options = null; + object.visibility = options.enums === String ? "VISIBILITY_UNSET" : 0; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -49452,6 +50407,8 @@ for (var j = 0; j < message.reservedName.length; ++j) object.reservedName[j] = message.reservedName[j]; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + object.visibility = options.enums === String ? $root.google.protobuf.SymbolVisibility[message.visibility] === undefined ? message.visibility : $root.google.protobuf.SymbolVisibility[message.visibility] : message.visibility; return object; }; @@ -51496,6 +52453,7 @@ * @property {google.protobuf.IEnumOptions|null} [options] EnumDescriptorProto options * @property {Array.|null} [reservedRange] EnumDescriptorProto reservedRange * @property {Array.|null} [reservedName] EnumDescriptorProto reservedName + * @property {google.protobuf.SymbolVisibility|null} [visibility] EnumDescriptorProto visibility */ /** @@ -51556,6 +52514,14 @@ */ EnumDescriptorProto.prototype.reservedName = $util.emptyArray; + /** + * EnumDescriptorProto visibility. + * @member {google.protobuf.SymbolVisibility} visibility + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.visibility = 0; + /** * Creates a new EnumDescriptorProto instance using the specified properties. * @function create @@ -51593,6 +52559,8 @@ if (message.reservedName != null && message.reservedName.length) for (var i = 0; i < message.reservedName.length; ++i) writer.uint32(/* id 5, wireType 2 =*/42).string(message.reservedName[i]); + if (message.visibility != null && Object.hasOwnProperty.call(message, "visibility")) + writer.uint32(/* id 6, wireType 0 =*/48).int32(message.visibility); return writer; }; @@ -51655,6 +52623,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -51723,9 +52695,18 @@ if (!$util.isString(message.reservedName[i])) return "reservedName: string[] expected"; } - return null; - }; - + if (message.visibility != null && message.hasOwnProperty("visibility")) + switch (message.visibility) { + default: + return "visibility: enum value expected"; + case 0: + case 1: + case 2: + break; + } + return null; + }; + /** * Creates an EnumDescriptorProto message from a plain object. Also converts values to their respective internal types. * @function fromObject @@ -51772,6 +52753,26 @@ for (var i = 0; i < object.reservedName.length; ++i) message.reservedName[i] = String(object.reservedName[i]); } + switch (object.visibility) { + default: + if (typeof object.visibility === "number") { + message.visibility = object.visibility; + break; + } + break; + case "VISIBILITY_UNSET": + case 0: + message.visibility = 0; + break; + case "VISIBILITY_LOCAL": + case 1: + message.visibility = 1; + break; + case "VISIBILITY_EXPORT": + case 2: + message.visibility = 2; + break; + } return message; }; @@ -51796,6 +52797,7 @@ if (options.defaults) { object.name = ""; object.options = null; + object.visibility = options.enums === String ? "VISIBILITY_UNSET" : 0; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -51816,6 +52818,8 @@ for (var j = 0; j < message.reservedName.length; ++j) object.reservedName[j] = message.reservedName[j]; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + object.visibility = options.enums === String ? $root.google.protobuf.SymbolVisibility[message.visibility] === undefined ? message.visibility : $root.google.protobuf.SymbolVisibility[message.visibility] : message.visibility; return object; }; @@ -54134,6 +55138,7 @@ * @property {Array.|null} [targets] FieldOptions targets * @property {Array.|null} [editionDefaults] FieldOptions editionDefaults * @property {google.protobuf.IFeatureSet|null} [features] FieldOptions features + * @property {google.protobuf.FieldOptions.IFeatureSupport|null} [featureSupport] FieldOptions featureSupport * @property {Array.|null} [uninterpretedOption] FieldOptions uninterpretedOption * @property {Array.|null} [".google.api.fieldBehavior"] FieldOptions .google.api.fieldBehavior * @property {google.api.IResourceReference|null} [".google.api.resourceReference"] FieldOptions .google.api.resourceReference @@ -54255,6 +55260,14 @@ */ FieldOptions.prototype.features = null; + /** + * FieldOptions featureSupport. + * @member {google.protobuf.FieldOptions.IFeatureSupport|null|undefined} featureSupport + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.featureSupport = null; + /** * FieldOptions uninterpretedOption. * @member {Array.} uninterpretedOption @@ -54337,6 +55350,8 @@ $root.google.protobuf.FieldOptions.EditionDefault.encode(message.editionDefaults[i], writer.uint32(/* id 20, wireType 2 =*/162).fork()).ldelim(); if (message.features != null && Object.hasOwnProperty.call(message, "features")) $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 21, wireType 2 =*/170).fork()).ldelim(); + if (message.featureSupport != null && Object.hasOwnProperty.call(message, "featureSupport")) + $root.google.protobuf.FieldOptions.FeatureSupport.encode(message.featureSupport, writer.uint32(/* id 22, wireType 2 =*/178).fork()).ldelim(); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); @@ -54440,6 +55455,10 @@ message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); break; } + case 22: { + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.decode(reader, reader.uint32()); + break; + } case 999: { if (!(message.uninterpretedOption && message.uninterpretedOption.length)) message.uninterpretedOption = []; @@ -54579,6 +55598,11 @@ if (error) return "features." + error; } + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) { + var error = $root.google.protobuf.FieldOptions.FeatureSupport.verify(message.featureSupport); + if (error) + return "featureSupport." + error; + } if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { if (!Array.isArray(message.uninterpretedOption)) return "uninterpretedOption: array expected"; @@ -54772,6 +55796,11 @@ throw TypeError(".google.protobuf.FieldOptions.features: object expected"); message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); } + if (object.featureSupport != null) { + if (typeof object.featureSupport !== "object") + throw TypeError(".google.protobuf.FieldOptions.featureSupport: object expected"); + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.fromObject(object.featureSupport); + } if (object.uninterpretedOption) { if (!Array.isArray(object.uninterpretedOption)) throw TypeError(".google.protobuf.FieldOptions.uninterpretedOption: array expected"); @@ -54874,6 +55903,7 @@ object.debugRedact = false; object.retention = options.enums === String ? "RETENTION_UNKNOWN" : 0; object.features = null; + object.featureSupport = null; object[".google.api.resourceReference"] = null; object[".google.api.fieldInfo"] = null; } @@ -54907,6 +55937,8 @@ } if (message.features != null && message.hasOwnProperty("features")) object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) + object.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.toObject(message.featureSupport, options); if (message.uninterpretedOption && message.uninterpretedOption.length) { object.uninterpretedOption = []; for (var j = 0; j < message.uninterpretedOption.length; ++j) @@ -55181,6 +56213,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -55222,103 +56255,589 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; + case "EDITION_PROTO2": + case 998: + message.edition = 998; + break; + case "EDITION_PROTO3": + case 999: + message.edition = 999; + break; + case "EDITION_2023": + case 1000: + message.edition = 1000; + break; + case "EDITION_2024": + case 1001: + message.edition = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.edition = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.edition = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.edition = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.edition = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.edition = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.edition = 2147483647; + break; + } + if (object.value != null) + message.value = String(object.value); + return message; + }; + + /** + * Creates a plain object from an EditionDefault message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {google.protobuf.FieldOptions.EditionDefault} message EditionDefault + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EditionDefault.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.value = ""; + object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + } + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + if (message.edition != null && message.hasOwnProperty("edition")) + object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + return object; + }; + + /** + * Converts this EditionDefault to JSON. + * @function toJSON + * @memberof google.protobuf.FieldOptions.EditionDefault + * @instance + * @returns {Object.} JSON object + */ + EditionDefault.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for EditionDefault + * @function getTypeUrl + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + EditionDefault.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FieldOptions.EditionDefault"; + }; + + return EditionDefault; + })(); + + FieldOptions.FeatureSupport = (function() { + + /** + * Properties of a FeatureSupport. + * @memberof google.protobuf.FieldOptions + * @interface IFeatureSupport + * @property {google.protobuf.Edition|null} [editionIntroduced] FeatureSupport editionIntroduced + * @property {google.protobuf.Edition|null} [editionDeprecated] FeatureSupport editionDeprecated + * @property {string|null} [deprecationWarning] FeatureSupport deprecationWarning + * @property {google.protobuf.Edition|null} [editionRemoved] FeatureSupport editionRemoved + */ + + /** + * Constructs a new FeatureSupport. + * @memberof google.protobuf.FieldOptions + * @classdesc Represents a FeatureSupport. + * @implements IFeatureSupport + * @constructor + * @param {google.protobuf.FieldOptions.IFeatureSupport=} [properties] Properties to set + */ + function FeatureSupport(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]]; + } + + /** + * FeatureSupport editionIntroduced. + * @member {google.protobuf.Edition} editionIntroduced + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionIntroduced = 0; + + /** + * FeatureSupport editionDeprecated. + * @member {google.protobuf.Edition} editionDeprecated + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionDeprecated = 0; + + /** + * FeatureSupport deprecationWarning. + * @member {string} deprecationWarning + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.deprecationWarning = ""; + + /** + * FeatureSupport editionRemoved. + * @member {google.protobuf.Edition} editionRemoved + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionRemoved = 0; + + /** + * Creates a new FeatureSupport instance using the specified properties. + * @function create + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport=} [properties] Properties to set + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport instance + */ + FeatureSupport.create = function create(properties) { + return new FeatureSupport(properties); + }; + + /** + * Encodes the specified FeatureSupport message. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport} message FeatureSupport message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSupport.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.editionIntroduced != null && Object.hasOwnProperty.call(message, "editionIntroduced")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.editionIntroduced); + if (message.editionDeprecated != null && Object.hasOwnProperty.call(message, "editionDeprecated")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.editionDeprecated); + if (message.deprecationWarning != null && Object.hasOwnProperty.call(message, "deprecationWarning")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.deprecationWarning); + if (message.editionRemoved != null && Object.hasOwnProperty.call(message, "editionRemoved")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.editionRemoved); + return writer; + }; + + /** + * Encodes the specified FeatureSupport message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport} message FeatureSupport message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSupport.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSupport.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FieldOptions.FeatureSupport(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.editionIntroduced = reader.int32(); + break; + } + case 2: { + message.editionDeprecated = reader.int32(); + break; + } + case 3: { + message.deprecationWarning = reader.string(); + break; + } + case 4: { + message.editionRemoved = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSupport.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FeatureSupport message. + * @function verify + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FeatureSupport.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.editionIntroduced != null && message.hasOwnProperty("editionIntroduced")) + switch (message.editionIntroduced) { + default: + return "editionIntroduced: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + if (message.editionDeprecated != null && message.hasOwnProperty("editionDeprecated")) + switch (message.editionDeprecated) { + default: + return "editionDeprecated: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + if (message.deprecationWarning != null && message.hasOwnProperty("deprecationWarning")) + if (!$util.isString(message.deprecationWarning)) + return "deprecationWarning: string expected"; + if (message.editionRemoved != null && message.hasOwnProperty("editionRemoved")) + switch (message.editionRemoved) { + default: + return "editionRemoved: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + return null; + }; + + /** + * Creates a FeatureSupport message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + */ + FeatureSupport.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FieldOptions.FeatureSupport) + return object; + var message = new $root.google.protobuf.FieldOptions.FeatureSupport(); + switch (object.editionIntroduced) { + default: + if (typeof object.editionIntroduced === "number") { + message.editionIntroduced = object.editionIntroduced; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionIntroduced = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionIntroduced = 900; + break; + case "EDITION_PROTO2": + case 998: + message.editionIntroduced = 998; + break; + case "EDITION_PROTO3": + case 999: + message.editionIntroduced = 999; + break; + case "EDITION_2023": + case 1000: + message.editionIntroduced = 1000; + break; + case "EDITION_2024": + case 1001: + message.editionIntroduced = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.editionIntroduced = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.editionIntroduced = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.editionIntroduced = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.editionIntroduced = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.editionIntroduced = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.editionIntroduced = 2147483647; + break; + } + switch (object.editionDeprecated) { + default: + if (typeof object.editionDeprecated === "number") { + message.editionDeprecated = object.editionDeprecated; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionDeprecated = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionDeprecated = 900; + break; + case "EDITION_PROTO2": + case 998: + message.editionDeprecated = 998; + break; + case "EDITION_PROTO3": + case 999: + message.editionDeprecated = 999; + break; + case "EDITION_2023": + case 1000: + message.editionDeprecated = 1000; + break; + case "EDITION_2024": + case 1001: + message.editionDeprecated = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.editionDeprecated = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.editionDeprecated = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.editionDeprecated = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.editionDeprecated = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.editionDeprecated = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.editionDeprecated = 2147483647; + break; + } + if (object.deprecationWarning != null) + message.deprecationWarning = String(object.deprecationWarning); + switch (object.editionRemoved) { + default: + if (typeof object.editionRemoved === "number") { + message.editionRemoved = object.editionRemoved; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionRemoved = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionRemoved = 900; + break; case "EDITION_PROTO2": case 998: - message.edition = 998; + message.editionRemoved = 998; break; case "EDITION_PROTO3": case 999: - message.edition = 999; + message.editionRemoved = 999; break; case "EDITION_2023": case 1000: - message.edition = 1000; + message.editionRemoved = 1000; break; case "EDITION_2024": case 1001: - message.edition = 1001; + message.editionRemoved = 1001; break; case "EDITION_1_TEST_ONLY": case 1: - message.edition = 1; + message.editionRemoved = 1; break; case "EDITION_2_TEST_ONLY": case 2: - message.edition = 2; + message.editionRemoved = 2; break; case "EDITION_99997_TEST_ONLY": case 99997: - message.edition = 99997; + message.editionRemoved = 99997; break; case "EDITION_99998_TEST_ONLY": case 99998: - message.edition = 99998; + message.editionRemoved = 99998; break; case "EDITION_99999_TEST_ONLY": case 99999: - message.edition = 99999; + message.editionRemoved = 99999; break; case "EDITION_MAX": case 2147483647: - message.edition = 2147483647; + message.editionRemoved = 2147483647; break; } - if (object.value != null) - message.value = String(object.value); return message; }; /** - * Creates a plain object from an EditionDefault message. Also converts values to other types if specified. + * Creates a plain object from a FeatureSupport message. Also converts values to other types if specified. * @function toObject - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @static - * @param {google.protobuf.FieldOptions.EditionDefault} message EditionDefault + * @param {google.protobuf.FieldOptions.FeatureSupport} message FeatureSupport * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - EditionDefault.toObject = function toObject(message, options) { + FeatureSupport.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { - object.value = ""; - object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.editionIntroduced = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.editionDeprecated = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.deprecationWarning = ""; + object.editionRemoved = options.enums === String ? "EDITION_UNKNOWN" : 0; } - if (message.value != null && message.hasOwnProperty("value")) - object.value = message.value; - if (message.edition != null && message.hasOwnProperty("edition")) - object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.editionIntroduced != null && message.hasOwnProperty("editionIntroduced")) + object.editionIntroduced = options.enums === String ? $root.google.protobuf.Edition[message.editionIntroduced] === undefined ? message.editionIntroduced : $root.google.protobuf.Edition[message.editionIntroduced] : message.editionIntroduced; + if (message.editionDeprecated != null && message.hasOwnProperty("editionDeprecated")) + object.editionDeprecated = options.enums === String ? $root.google.protobuf.Edition[message.editionDeprecated] === undefined ? message.editionDeprecated : $root.google.protobuf.Edition[message.editionDeprecated] : message.editionDeprecated; + if (message.deprecationWarning != null && message.hasOwnProperty("deprecationWarning")) + object.deprecationWarning = message.deprecationWarning; + if (message.editionRemoved != null && message.hasOwnProperty("editionRemoved")) + object.editionRemoved = options.enums === String ? $root.google.protobuf.Edition[message.editionRemoved] === undefined ? message.editionRemoved : $root.google.protobuf.Edition[message.editionRemoved] : message.editionRemoved; return object; }; /** - * Converts this EditionDefault to JSON. + * Converts this FeatureSupport to JSON. * @function toJSON - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @instance * @returns {Object.} JSON object */ - EditionDefault.prototype.toJSON = function toJSON() { + FeatureSupport.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for EditionDefault + * Gets the default type url for FeatureSupport * @function getTypeUrl - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - EditionDefault.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + FeatureSupport.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.protobuf.FieldOptions.EditionDefault"; + return typeUrlPrefix + "/google.protobuf.FieldOptions.FeatureSupport"; }; - return EditionDefault; + return FeatureSupport; })(); return FieldOptions; @@ -55913,6 +57432,7 @@ * @property {boolean|null} [deprecated] EnumValueOptions deprecated * @property {google.protobuf.IFeatureSet|null} [features] EnumValueOptions features * @property {boolean|null} [debugRedact] EnumValueOptions debugRedact + * @property {google.protobuf.FieldOptions.IFeatureSupport|null} [featureSupport] EnumValueOptions featureSupport * @property {Array.|null} [uninterpretedOption] EnumValueOptions uninterpretedOption */ @@ -55956,6 +57476,14 @@ */ EnumValueOptions.prototype.debugRedact = false; + /** + * EnumValueOptions featureSupport. + * @member {google.protobuf.FieldOptions.IFeatureSupport|null|undefined} featureSupport + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.featureSupport = null; + /** * EnumValueOptions uninterpretedOption. * @member {Array.} uninterpretedOption @@ -55994,6 +57522,8 @@ $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.debugRedact != null && Object.hasOwnProperty.call(message, "debugRedact")) writer.uint32(/* id 3, wireType 0 =*/24).bool(message.debugRedact); + if (message.featureSupport != null && Object.hasOwnProperty.call(message, "featureSupport")) + $root.google.protobuf.FieldOptions.FeatureSupport.encode(message.featureSupport, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); @@ -56045,6 +57575,10 @@ message.debugRedact = reader.bool(); break; } + case 4: { + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.decode(reader, reader.uint32()); + break; + } case 999: { if (!(message.uninterpretedOption && message.uninterpretedOption.length)) message.uninterpretedOption = []; @@ -56097,6 +57631,11 @@ if (message.debugRedact != null && message.hasOwnProperty("debugRedact")) if (typeof message.debugRedact !== "boolean") return "debugRedact: boolean expected"; + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) { + var error = $root.google.protobuf.FieldOptions.FeatureSupport.verify(message.featureSupport); + if (error) + return "featureSupport." + error; + } if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { if (!Array.isArray(message.uninterpretedOption)) return "uninterpretedOption: array expected"; @@ -56130,6 +57669,11 @@ } if (object.debugRedact != null) message.debugRedact = Boolean(object.debugRedact); + if (object.featureSupport != null) { + if (typeof object.featureSupport !== "object") + throw TypeError(".google.protobuf.EnumValueOptions.featureSupport: object expected"); + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.fromObject(object.featureSupport); + } if (object.uninterpretedOption) { if (!Array.isArray(object.uninterpretedOption)) throw TypeError(".google.protobuf.EnumValueOptions.uninterpretedOption: array expected"); @@ -56162,6 +57706,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -56169,6 +57714,8 @@ object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); if (message.debugRedact != null && message.hasOwnProperty("debugRedact")) object.debugRedact = message.debugRedact; + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) + object.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.toObject(message.featureSupport, options); if (message.uninterpretedOption && message.uninterpretedOption.length) { object.uninterpretedOption = []; for (var j = 0; j < message.uninterpretedOption.length; ++j) @@ -57636,6 +59183,8 @@ * @property {google.protobuf.FeatureSet.Utf8Validation|null} [utf8Validation] FeatureSet utf8Validation * @property {google.protobuf.FeatureSet.MessageEncoding|null} [messageEncoding] FeatureSet messageEncoding * @property {google.protobuf.FeatureSet.JsonFormat|null} [jsonFormat] FeatureSet jsonFormat + * @property {google.protobuf.FeatureSet.EnforceNamingStyle|null} [enforceNamingStyle] FeatureSet enforceNamingStyle + * @property {google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|null} [defaultSymbolVisibility] FeatureSet defaultSymbolVisibility */ /** @@ -57701,6 +59250,22 @@ */ FeatureSet.prototype.jsonFormat = 0; + /** + * FeatureSet enforceNamingStyle. + * @member {google.protobuf.FeatureSet.EnforceNamingStyle} enforceNamingStyle + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.enforceNamingStyle = 0; + + /** + * FeatureSet defaultSymbolVisibility. + * @member {google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility} defaultSymbolVisibility + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.defaultSymbolVisibility = 0; + /** * Creates a new FeatureSet instance using the specified properties. * @function create @@ -57737,6 +59302,10 @@ writer.uint32(/* id 5, wireType 0 =*/40).int32(message.messageEncoding); if (message.jsonFormat != null && Object.hasOwnProperty.call(message, "jsonFormat")) writer.uint32(/* id 6, wireType 0 =*/48).int32(message.jsonFormat); + if (message.enforceNamingStyle != null && Object.hasOwnProperty.call(message, "enforceNamingStyle")) + writer.uint32(/* id 7, wireType 0 =*/56).int32(message.enforceNamingStyle); + if (message.defaultSymbolVisibility != null && Object.hasOwnProperty.call(message, "defaultSymbolVisibility")) + writer.uint32(/* id 8, wireType 0 =*/64).int32(message.defaultSymbolVisibility); return writer; }; @@ -57797,6 +59366,14 @@ message.jsonFormat = reader.int32(); break; } + case 7: { + message.enforceNamingStyle = reader.int32(); + break; + } + case 8: { + message.defaultSymbolVisibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -57887,6 +59464,26 @@ case 2: break; } + if (message.enforceNamingStyle != null && message.hasOwnProperty("enforceNamingStyle")) + switch (message.enforceNamingStyle) { + default: + return "enforceNamingStyle: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.defaultSymbolVisibility != null && message.hasOwnProperty("defaultSymbolVisibility")) + switch (message.defaultSymbolVisibility) { + default: + return "defaultSymbolVisibility: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } return null; }; @@ -58026,6 +59623,54 @@ message.jsonFormat = 2; break; } + switch (object.enforceNamingStyle) { + default: + if (typeof object.enforceNamingStyle === "number") { + message.enforceNamingStyle = object.enforceNamingStyle; + break; + } + break; + case "ENFORCE_NAMING_STYLE_UNKNOWN": + case 0: + message.enforceNamingStyle = 0; + break; + case "STYLE2024": + case 1: + message.enforceNamingStyle = 1; + break; + case "STYLE_LEGACY": + case 2: + message.enforceNamingStyle = 2; + break; + } + switch (object.defaultSymbolVisibility) { + default: + if (typeof object.defaultSymbolVisibility === "number") { + message.defaultSymbolVisibility = object.defaultSymbolVisibility; + break; + } + break; + case "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN": + case 0: + message.defaultSymbolVisibility = 0; + break; + case "EXPORT_ALL": + case 1: + message.defaultSymbolVisibility = 1; + break; + case "EXPORT_TOP_LEVEL": + case 2: + message.defaultSymbolVisibility = 2; + break; + case "LOCAL_ALL": + case 3: + message.defaultSymbolVisibility = 3; + break; + case "STRICT": + case 4: + message.defaultSymbolVisibility = 4; + break; + } return message; }; @@ -58049,6 +59694,8 @@ object.utf8Validation = options.enums === String ? "UTF8_VALIDATION_UNKNOWN" : 0; object.messageEncoding = options.enums === String ? "MESSAGE_ENCODING_UNKNOWN" : 0; object.jsonFormat = options.enums === String ? "JSON_FORMAT_UNKNOWN" : 0; + object.enforceNamingStyle = options.enums === String ? "ENFORCE_NAMING_STYLE_UNKNOWN" : 0; + object.defaultSymbolVisibility = options.enums === String ? "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN" : 0; } if (message.fieldPresence != null && message.hasOwnProperty("fieldPresence")) object.fieldPresence = options.enums === String ? $root.google.protobuf.FeatureSet.FieldPresence[message.fieldPresence] === undefined ? message.fieldPresence : $root.google.protobuf.FeatureSet.FieldPresence[message.fieldPresence] : message.fieldPresence; @@ -58062,6 +59709,10 @@ object.messageEncoding = options.enums === String ? $root.google.protobuf.FeatureSet.MessageEncoding[message.messageEncoding] === undefined ? message.messageEncoding : $root.google.protobuf.FeatureSet.MessageEncoding[message.messageEncoding] : message.messageEncoding; if (message.jsonFormat != null && message.hasOwnProperty("jsonFormat")) object.jsonFormat = options.enums === String ? $root.google.protobuf.FeatureSet.JsonFormat[message.jsonFormat] === undefined ? message.jsonFormat : $root.google.protobuf.FeatureSet.JsonFormat[message.jsonFormat] : message.jsonFormat; + if (message.enforceNamingStyle != null && message.hasOwnProperty("enforceNamingStyle")) + object.enforceNamingStyle = options.enums === String ? $root.google.protobuf.FeatureSet.EnforceNamingStyle[message.enforceNamingStyle] === undefined ? message.enforceNamingStyle : $root.google.protobuf.FeatureSet.EnforceNamingStyle[message.enforceNamingStyle] : message.enforceNamingStyle; + if (message.defaultSymbolVisibility != null && message.hasOwnProperty("defaultSymbolVisibility")) + object.defaultSymbolVisibility = options.enums === String ? $root.google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility[message.defaultSymbolVisibility] === undefined ? message.defaultSymbolVisibility : $root.google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility[message.defaultSymbolVisibility] : message.defaultSymbolVisibility; return object; }; @@ -58189,6 +59840,219 @@ return values; })(); + /** + * EnforceNamingStyle enum. + * @name google.protobuf.FeatureSet.EnforceNamingStyle + * @enum {number} + * @property {number} ENFORCE_NAMING_STYLE_UNKNOWN=0 ENFORCE_NAMING_STYLE_UNKNOWN value + * @property {number} STYLE2024=1 STYLE2024 value + * @property {number} STYLE_LEGACY=2 STYLE_LEGACY value + */ + FeatureSet.EnforceNamingStyle = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "ENFORCE_NAMING_STYLE_UNKNOWN"] = 0; + values[valuesById[1] = "STYLE2024"] = 1; + values[valuesById[2] = "STYLE_LEGACY"] = 2; + return values; + })(); + + FeatureSet.VisibilityFeature = (function() { + + /** + * Properties of a VisibilityFeature. + * @memberof google.protobuf.FeatureSet + * @interface IVisibilityFeature + */ + + /** + * Constructs a new VisibilityFeature. + * @memberof google.protobuf.FeatureSet + * @classdesc Represents a VisibilityFeature. + * @implements IVisibilityFeature + * @constructor + * @param {google.protobuf.FeatureSet.IVisibilityFeature=} [properties] Properties to set + */ + function VisibilityFeature(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]]; + } + + /** + * Creates a new VisibilityFeature instance using the specified properties. + * @function create + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature=} [properties] Properties to set + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature instance + */ + VisibilityFeature.create = function create(properties) { + return new VisibilityFeature(properties); + }; + + /** + * Encodes the specified VisibilityFeature message. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature} message VisibilityFeature message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VisibilityFeature.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified VisibilityFeature message, length delimited. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature} message VisibilityFeature message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VisibilityFeature.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VisibilityFeature.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FeatureSet.VisibilityFeature(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VisibilityFeature.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a VisibilityFeature message. + * @function verify + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + VisibilityFeature.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a VisibilityFeature message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + */ + VisibilityFeature.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FeatureSet.VisibilityFeature) + return object; + return new $root.google.protobuf.FeatureSet.VisibilityFeature(); + }; + + /** + * Creates a plain object from a VisibilityFeature message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.VisibilityFeature} message VisibilityFeature + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + VisibilityFeature.toObject = function toObject() { + return {}; + }; + + /** + * Converts this VisibilityFeature to JSON. + * @function toJSON + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @instance + * @returns {Object.} JSON object + */ + VisibilityFeature.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for VisibilityFeature + * @function getTypeUrl + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + VisibilityFeature.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FeatureSet.VisibilityFeature"; + }; + + /** + * DefaultSymbolVisibility enum. + * @name google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility + * @enum {number} + * @property {number} DEFAULT_SYMBOL_VISIBILITY_UNKNOWN=0 DEFAULT_SYMBOL_VISIBILITY_UNKNOWN value + * @property {number} EXPORT_ALL=1 EXPORT_ALL value + * @property {number} EXPORT_TOP_LEVEL=2 EXPORT_TOP_LEVEL value + * @property {number} LOCAL_ALL=3 LOCAL_ALL value + * @property {number} STRICT=4 STRICT value + */ + VisibilityFeature.DefaultSymbolVisibility = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN"] = 0; + values[valuesById[1] = "EXPORT_ALL"] = 1; + values[valuesById[2] = "EXPORT_TOP_LEVEL"] = 2; + values[valuesById[3] = "LOCAL_ALL"] = 3; + values[valuesById[4] = "STRICT"] = 4; + return values; + })(); + + return VisibilityFeature; + })(); + return FeatureSet; })(); @@ -58373,6 +60237,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -58390,6 +60255,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -58438,6 +60304,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -58490,6 +60360,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -58598,7 +60472,8 @@ * @memberof google.protobuf.FeatureSetDefaults * @interface IFeatureSetEditionDefault * @property {google.protobuf.Edition|null} [edition] FeatureSetEditionDefault edition - * @property {google.protobuf.IFeatureSet|null} [features] FeatureSetEditionDefault features + * @property {google.protobuf.IFeatureSet|null} [overridableFeatures] FeatureSetEditionDefault overridableFeatures + * @property {google.protobuf.IFeatureSet|null} [fixedFeatures] FeatureSetEditionDefault fixedFeatures */ /** @@ -58625,12 +60500,20 @@ FeatureSetEditionDefault.prototype.edition = 0; /** - * FeatureSetEditionDefault features. - * @member {google.protobuf.IFeatureSet|null|undefined} features + * FeatureSetEditionDefault overridableFeatures. + * @member {google.protobuf.IFeatureSet|null|undefined} overridableFeatures + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @instance + */ + FeatureSetEditionDefault.prototype.overridableFeatures = null; + + /** + * FeatureSetEditionDefault fixedFeatures. + * @member {google.protobuf.IFeatureSet|null|undefined} fixedFeatures * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault * @instance */ - FeatureSetEditionDefault.prototype.features = null; + FeatureSetEditionDefault.prototype.fixedFeatures = null; /** * Creates a new FeatureSetEditionDefault instance using the specified properties. @@ -58656,10 +60539,12 @@ FeatureSetEditionDefault.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.features != null && Object.hasOwnProperty.call(message, "features")) - $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) writer.uint32(/* id 3, wireType 0 =*/24).int32(message.edition); + if (message.overridableFeatures != null && Object.hasOwnProperty.call(message, "overridableFeatures")) + $root.google.protobuf.FeatureSet.encode(message.overridableFeatures, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.fixedFeatures != null && Object.hasOwnProperty.call(message, "fixedFeatures")) + $root.google.protobuf.FeatureSet.encode(message.fixedFeatures, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); return writer; }; @@ -58700,8 +60585,12 @@ message.edition = reader.int32(); break; } - case 2: { - message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + case 4: { + message.overridableFeatures = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + break; + } + case 5: { + message.fixedFeatures = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); break; } default: @@ -58744,6 +60633,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -58756,10 +60646,15 @@ case 2147483647: break; } - if (message.features != null && message.hasOwnProperty("features")) { - var error = $root.google.protobuf.FeatureSet.verify(message.features); + if (message.overridableFeatures != null && message.hasOwnProperty("overridableFeatures")) { + var error = $root.google.protobuf.FeatureSet.verify(message.overridableFeatures); + if (error) + return "overridableFeatures." + error; + } + if (message.fixedFeatures != null && message.hasOwnProperty("fixedFeatures")) { + var error = $root.google.protobuf.FeatureSet.verify(message.fixedFeatures); if (error) - return "features." + error; + return "fixedFeatures." + error; } return null; }; @@ -58787,6 +60682,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -58828,10 +60727,15 @@ message.edition = 2147483647; break; } - if (object.features != null) { - if (typeof object.features !== "object") - throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.features: object expected"); - message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); + if (object.overridableFeatures != null) { + if (typeof object.overridableFeatures !== "object") + throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.overridableFeatures: object expected"); + message.overridableFeatures = $root.google.protobuf.FeatureSet.fromObject(object.overridableFeatures); + } + if (object.fixedFeatures != null) { + if (typeof object.fixedFeatures !== "object") + throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.fixedFeatures: object expected"); + message.fixedFeatures = $root.google.protobuf.FeatureSet.fromObject(object.fixedFeatures); } return message; }; @@ -58850,13 +60754,16 @@ options = {}; var object = {}; if (options.defaults) { - object.features = null; object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.overridableFeatures = null; + object.fixedFeatures = null; } - if (message.features != null && message.hasOwnProperty("features")) - object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); if (message.edition != null && message.hasOwnProperty("edition")) object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.overridableFeatures != null && message.hasOwnProperty("overridableFeatures")) + object.overridableFeatures = $root.google.protobuf.FeatureSet.toObject(message.overridableFeatures, options); + if (message.fixedFeatures != null && message.hasOwnProperty("fixedFeatures")) + object.fixedFeatures = $root.google.protobuf.FeatureSet.toObject(message.fixedFeatures, options); return object; }; @@ -60071,6 +61978,22 @@ return GeneratedCodeInfo; })(); + /** + * SymbolVisibility enum. + * @name google.protobuf.SymbolVisibility + * @enum {number} + * @property {number} VISIBILITY_UNSET=0 VISIBILITY_UNSET value + * @property {number} VISIBILITY_LOCAL=1 VISIBILITY_LOCAL value + * @property {number} VISIBILITY_EXPORT=2 VISIBILITY_EXPORT value + */ + protobuf.SymbolVisibility = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "VISIBILITY_UNSET"] = 0; + values[valuesById[1] = "VISIBILITY_LOCAL"] = 1; + values[valuesById[2] = "VISIBILITY_EXPORT"] = 2; + return values; + })(); + protobuf.FieldMask = (function() { /** diff --git a/packages/google-cloud-netapp/protos/protos.json b/packages/google-cloud-netapp/protos/protos.json index 58494bf8b9db..128a23322214 100644 --- a/packages/google-cloud-netapp/protos/protos.json +++ b/packages/google-cloud-netapp/protos/protos.json @@ -6488,8 +6488,7 @@ "java_multiple_files": true, "java_outer_classname": "FieldInfoProto", "java_package": "com.google.api", - "objc_class_prefix": "GAPI", - "cc_enable_arenas": true + "objc_class_prefix": "GAPI" }, "nested": { "fieldBehavior": { @@ -6712,6 +6711,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -6852,6 +6855,28 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "experimentalFeatures": { + "type": "ExperimentalFeatures", + "id": 2 + } + }, + "nested": { + "ExperimentalFeatures": { + "fields": { + "restAsyncIoEnabled": { + "type": "bool", + "id": 1 + }, + "protobufPythonicTypesEnabled": { + "type": "bool", + "id": 2 + }, + "unversionedPackageDisabled": { + "type": "bool", + "id": 3 + } + } } } }, @@ -6909,6 +6934,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -6970,6 +7000,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -6992,6 +7035,11 @@ "format": { "type": "Format", "id": 1 + }, + "referencedTypes": { + "rule": "repeated", + "type": "TypeReference", + "id": 2 } }, "nested": { @@ -7005,6 +7053,14 @@ } } } + }, + "TypeReference": { + "fields": { + "typeName": { + "type": "string", + "id": 1 + } + } } } }, @@ -7027,12 +7083,19 @@ "type": "FileDescriptorProto", "id": 1 } - } + }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ] }, "Edition": { "edition": "proto2", "values": { "EDITION_UNKNOWN": 0, + "EDITION_LEGACY": 900, "EDITION_PROTO2": 998, "EDITION_PROTO3": 999, "EDITION_2023": 1000, @@ -7071,6 +7134,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -7159,6 +7227,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -7384,6 +7456,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -7434,7 +7510,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -7598,6 +7681,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -7733,7 +7817,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -7761,6 +7846,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -7830,6 +7919,26 @@ "id": 2 } } + }, + "FeatureSupport": { + "fields": { + "editionIntroduced": { + "type": "Edition", + "id": 1 + }, + "editionDeprecated": { + "type": "Edition", + "id": 2 + }, + "deprecationWarning": { + "type": "string", + "id": 3 + }, + "editionRemoved": { + "type": "Edition", + "id": 4 + } + } } } }, @@ -7918,6 +8027,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -8060,6 +8173,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -8070,6 +8184,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -8080,6 +8195,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -8090,6 +8206,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -8100,7 +8217,8 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", - "edition_defaults.edition": "EDITION_PROTO2", + "feature_support.edition_introduced": "EDITION_2023", + "edition_defaults.edition": "EDITION_LEGACY", "edition_defaults.value": "LENGTH_PREFIXED" } }, @@ -8110,27 +8228,38 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "ALLOW" } + }, + "enforceNamingStyle": { + "type": "EnforceNamingStyle", + "id": 7, + "options": { + "retention": "RETENTION_SOURCE", + "targets": "TARGET_TYPE_METHOD", + "feature_support.edition_introduced": "EDITION_2024", + "edition_defaults.edition": "EDITION_2024", + "edition_defaults.value": "STYLE2024" + } + }, + "defaultSymbolVisibility": { + "type": "VisibilityFeature.DefaultSymbolVisibility", + "id": 8, + "options": { + "retention": "RETENTION_SOURCE", + "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2024", + "edition_defaults.edition": "EDITION_2024", + "edition_defaults.value": "EXPORT_TOP_LEVEL" + } } }, "extensions": [ [ 1000, - 1000 - ], - [ - 1001, - 1001 - ], - [ - 1002, - 1002 - ], - [ - 9990, - 9990 + 9994 ], [ 9995, @@ -8175,7 +8304,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -8190,6 +8325,33 @@ "ALLOW": 1, "LEGACY_BEST_EFFORT": 2 } + }, + "EnforceNamingStyle": { + "values": { + "ENFORCE_NAMING_STYLE_UNKNOWN": 0, + "STYLE2024": 1, + "STYLE_LEGACY": 2 + } + }, + "VisibilityFeature": { + "fields": {}, + "reserved": [ + [ + 1, + 536870911 + ] + ], + "nested": { + "DefaultSymbolVisibility": { + "values": { + "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN": 0, + "EXPORT_ALL": 1, + "EXPORT_TOP_LEVEL": 2, + "LOCAL_ALL": 3, + "STRICT": 4 + } + } + } } } }, @@ -8217,11 +8379,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -8234,6 +8411,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -8319,6 +8502,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "FieldMask": { "fields": { "paths": { @@ -8440,6 +8631,7 @@ "java_multiple_files": true, "java_outer_classname": "OperationsProto", "java_package": "com.google.longrunning", + "objc_class_prefix": "GLRUN", "php_namespace": "Google\\LongRunning" }, "nested": { 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 6235d5f6c93a..64d944204657 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 @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-netapp", - "version": "0.17.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-netapp/src/v1/index.ts b/packages/google-cloud-netapp/src/v1/index.ts index 562b20e9c508..8c7565f72002 100644 --- a/packages/google-cloud-netapp/src/v1/index.ts +++ b/packages/google-cloud-netapp/src/v1/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {NetAppClient} from './net_app_client'; +export { NetAppClient } from './net_app_client'; 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 75a26dd48193..9f292caa16a1 100644 --- a/packages/google-cloud-netapp/src/v1/net_app_client.ts +++ b/packages/google-cloud-netapp/src/v1/net_app_client.ts @@ -18,11 +18,22 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -44,7 +55,7 @@ export class NetAppClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('netapp'); @@ -57,11 +68,11 @@ export class NetAppClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - netAppStub?: Promise<{[name: string]: Function}>; + netAppStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of NetAppClient. @@ -102,21 +113,42 @@ export class NetAppClient { * const client = new NetAppClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof NetAppClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'netapp.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -141,7 +173,7 @@ export class NetAppClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -155,15 +187,11 @@ export class NetAppClient { } this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -185,37 +213,37 @@ export class NetAppClient { // Create useful helper objects for these. this.pathTemplates = { activeDirectoryPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/activeDirectories/{active_directory}' + 'projects/{project}/locations/{location}/activeDirectories/{active_directory}', ), backupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/backupVaults/{backup_vault}/backups/{backup}' + 'projects/{project}/locations/{location}/backupVaults/{backup_vault}/backups/{backup}', ), backupPolicyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/backupPolicies/{backup_policy}' + 'projects/{project}/locations/{location}/backupPolicies/{backup_policy}', ), backupVaultPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/backupVaults/{backup_vault}' + 'projects/{project}/locations/{location}/backupVaults/{backup_vault}', ), hostGroupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/hostGroups/{host_group}' + 'projects/{project}/locations/{location}/hostGroups/{host_group}', ), kmsConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/kmsConfigs/{kms_config}' + 'projects/{project}/locations/{location}/kmsConfigs/{kms_config}', ), quotaRulePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/volumes/{volume}/quotaRules/{quota_rule}' + 'projects/{project}/locations/{location}/volumes/{volume}/quotaRules/{quota_rule}', ), replicationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/volumes/{volume}/replications/{replication}' + 'projects/{project}/locations/{location}/volumes/{volume}/replications/{replication}', ), snapshotPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/volumes/{volume}/snapshots/{snapshot}' + 'projects/{project}/locations/{location}/volumes/{volume}/snapshots/{snapshot}', ), storagePoolPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/storagePools/{storage_pool}' + 'projects/{project}/locations/{location}/storagePools/{storage_pool}', ), volumePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/volumes/{volume}' + 'projects/{project}/locations/{location}/volumes/{volume}', ), }; @@ -223,28 +251,61 @@ export class NetAppClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listStoragePools: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'storagePools'), - listVolumes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'volumes'), - listSnapshots: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'snapshots'), - listActiveDirectories: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'activeDirectories'), - listKmsConfigs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'kmsConfigs'), - listReplications: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'replications'), - listBackupVaults: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'backupVaults'), - listBackups: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'backups'), - listBackupPolicies: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'backupPolicies'), - listQuotaRules: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'quotaRules'), - listHostGroups: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'hostGroups') + listStoragePools: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'storagePools', + ), + listVolumes: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'volumes', + ), + listSnapshots: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'snapshots', + ), + listActiveDirectories: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'activeDirectories', + ), + listKmsConfigs: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'kmsConfigs', + ), + listReplications: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'replications', + ), + listBackupVaults: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'backupVaults', + ), + listBackups: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'backups', + ), + listBackupPolicies: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'backupPolicies', + ), + listQuotaRules: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'quotaRules', + ), + listHostGroups: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'hostGroups', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -253,373 +314,564 @@ export class NetAppClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1/{name=projects/*}/locations', + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createStoragePoolResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.StoragePool') as gax.protobuf.Type; + '.google.cloud.netapp.v1.StoragePool', + ) as gax.protobuf.Type; const createStoragePoolMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateStoragePoolResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.StoragePool') as gax.protobuf.Type; + '.google.cloud.netapp.v1.StoragePool', + ) as gax.protobuf.Type; const updateStoragePoolMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteStoragePoolResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteStoragePoolMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const validateDirectoryServiceResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const validateDirectoryServiceMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const switchActiveReplicaZoneResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.StoragePool') as gax.protobuf.Type; + '.google.cloud.netapp.v1.StoragePool', + ) as gax.protobuf.Type; const switchActiveReplicaZoneMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const createVolumeResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.Volume') as gax.protobuf.Type; + '.google.cloud.netapp.v1.Volume', + ) as gax.protobuf.Type; const createVolumeMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateVolumeResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.Volume') as gax.protobuf.Type; + '.google.cloud.netapp.v1.Volume', + ) as gax.protobuf.Type; const updateVolumeMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteVolumeResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteVolumeMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const revertVolumeResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.Volume') as gax.protobuf.Type; + '.google.cloud.netapp.v1.Volume', + ) as gax.protobuf.Type; const revertVolumeMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const establishVolumePeeringResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.Volume') as gax.protobuf.Type; + '.google.cloud.netapp.v1.Volume', + ) as gax.protobuf.Type; const establishVolumePeeringMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const createSnapshotResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.Snapshot') as gax.protobuf.Type; + '.google.cloud.netapp.v1.Snapshot', + ) as gax.protobuf.Type; const createSnapshotMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteSnapshotResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteSnapshotMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateSnapshotResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.Snapshot') as gax.protobuf.Type; + '.google.cloud.netapp.v1.Snapshot', + ) as gax.protobuf.Type; const updateSnapshotMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const createActiveDirectoryResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.ActiveDirectory') as gax.protobuf.Type; + '.google.cloud.netapp.v1.ActiveDirectory', + ) as gax.protobuf.Type; const createActiveDirectoryMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateActiveDirectoryResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.ActiveDirectory') as gax.protobuf.Type; + '.google.cloud.netapp.v1.ActiveDirectory', + ) as gax.protobuf.Type; const updateActiveDirectoryMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteActiveDirectoryResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteActiveDirectoryMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const createKmsConfigResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.KmsConfig') as gax.protobuf.Type; + '.google.cloud.netapp.v1.KmsConfig', + ) as gax.protobuf.Type; const createKmsConfigMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateKmsConfigResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.KmsConfig') as gax.protobuf.Type; + '.google.cloud.netapp.v1.KmsConfig', + ) as gax.protobuf.Type; const updateKmsConfigMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const encryptVolumesResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.KmsConfig') as gax.protobuf.Type; + '.google.cloud.netapp.v1.KmsConfig', + ) as gax.protobuf.Type; const encryptVolumesMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteKmsConfigResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteKmsConfigMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const createReplicationResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.Replication') as gax.protobuf.Type; + '.google.cloud.netapp.v1.Replication', + ) as gax.protobuf.Type; const createReplicationMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteReplicationResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteReplicationMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateReplicationResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.Replication') as gax.protobuf.Type; + '.google.cloud.netapp.v1.Replication', + ) as gax.protobuf.Type; const updateReplicationMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const stopReplicationResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.Replication') as gax.protobuf.Type; + '.google.cloud.netapp.v1.Replication', + ) as gax.protobuf.Type; const stopReplicationMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const resumeReplicationResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.Replication') as gax.protobuf.Type; + '.google.cloud.netapp.v1.Replication', + ) as gax.protobuf.Type; const resumeReplicationMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const reverseReplicationDirectionResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.Replication') as gax.protobuf.Type; + '.google.cloud.netapp.v1.Replication', + ) as gax.protobuf.Type; const reverseReplicationDirectionMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const establishPeeringResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.Replication') as gax.protobuf.Type; + '.google.cloud.netapp.v1.Replication', + ) as gax.protobuf.Type; const establishPeeringMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const syncReplicationResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.Replication') as gax.protobuf.Type; + '.google.cloud.netapp.v1.Replication', + ) as gax.protobuf.Type; const syncReplicationMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const createBackupVaultResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.BackupVault') as gax.protobuf.Type; + '.google.cloud.netapp.v1.BackupVault', + ) as gax.protobuf.Type; const createBackupVaultMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateBackupVaultResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.BackupVault') as gax.protobuf.Type; + '.google.cloud.netapp.v1.BackupVault', + ) as gax.protobuf.Type; const updateBackupVaultMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteBackupVaultResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteBackupVaultMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const createBackupResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.Backup') as gax.protobuf.Type; + '.google.cloud.netapp.v1.Backup', + ) as gax.protobuf.Type; const createBackupMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteBackupResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteBackupMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateBackupResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.Backup') as gax.protobuf.Type; + '.google.cloud.netapp.v1.Backup', + ) as gax.protobuf.Type; const updateBackupMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const createBackupPolicyResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.BackupPolicy') as gax.protobuf.Type; + '.google.cloud.netapp.v1.BackupPolicy', + ) as gax.protobuf.Type; const createBackupPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateBackupPolicyResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.BackupPolicy') as gax.protobuf.Type; + '.google.cloud.netapp.v1.BackupPolicy', + ) as gax.protobuf.Type; const updateBackupPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteBackupPolicyResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteBackupPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const createQuotaRuleResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.QuotaRule') as gax.protobuf.Type; + '.google.cloud.netapp.v1.QuotaRule', + ) as gax.protobuf.Type; const createQuotaRuleMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateQuotaRuleResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.QuotaRule') as gax.protobuf.Type; + '.google.cloud.netapp.v1.QuotaRule', + ) as gax.protobuf.Type; const updateQuotaRuleMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteQuotaRuleResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteQuotaRuleMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const restoreBackupFilesResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.RestoreBackupFilesResponse') as gax.protobuf.Type; + '.google.cloud.netapp.v1.RestoreBackupFilesResponse', + ) as gax.protobuf.Type; const restoreBackupFilesMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const createHostGroupResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.HostGroup') as gax.protobuf.Type; + '.google.cloud.netapp.v1.HostGroup', + ) as gax.protobuf.Type; const createHostGroupMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateHostGroupResponse = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.HostGroup') as gax.protobuf.Type; + '.google.cloud.netapp.v1.HostGroup', + ) as gax.protobuf.Type; const updateHostGroupMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteHostGroupResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteHostGroupMetadata = protoFilesRoot.lookup( - '.google.cloud.netapp.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.netapp.v1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createStoragePool: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createStoragePoolResponse.decode.bind(createStoragePoolResponse), - createStoragePoolMetadata.decode.bind(createStoragePoolMetadata)), + createStoragePoolMetadata.decode.bind(createStoragePoolMetadata), + ), updateStoragePool: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateStoragePoolResponse.decode.bind(updateStoragePoolResponse), - updateStoragePoolMetadata.decode.bind(updateStoragePoolMetadata)), + updateStoragePoolMetadata.decode.bind(updateStoragePoolMetadata), + ), deleteStoragePool: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteStoragePoolResponse.decode.bind(deleteStoragePoolResponse), - deleteStoragePoolMetadata.decode.bind(deleteStoragePoolMetadata)), + deleteStoragePoolMetadata.decode.bind(deleteStoragePoolMetadata), + ), validateDirectoryService: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - validateDirectoryServiceResponse.decode.bind(validateDirectoryServiceResponse), - validateDirectoryServiceMetadata.decode.bind(validateDirectoryServiceMetadata)), + validateDirectoryServiceResponse.decode.bind( + validateDirectoryServiceResponse, + ), + validateDirectoryServiceMetadata.decode.bind( + validateDirectoryServiceMetadata, + ), + ), switchActiveReplicaZone: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - switchActiveReplicaZoneResponse.decode.bind(switchActiveReplicaZoneResponse), - switchActiveReplicaZoneMetadata.decode.bind(switchActiveReplicaZoneMetadata)), + switchActiveReplicaZoneResponse.decode.bind( + switchActiveReplicaZoneResponse, + ), + switchActiveReplicaZoneMetadata.decode.bind( + switchActiveReplicaZoneMetadata, + ), + ), createVolume: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createVolumeResponse.decode.bind(createVolumeResponse), - createVolumeMetadata.decode.bind(createVolumeMetadata)), + createVolumeMetadata.decode.bind(createVolumeMetadata), + ), updateVolume: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateVolumeResponse.decode.bind(updateVolumeResponse), - updateVolumeMetadata.decode.bind(updateVolumeMetadata)), + updateVolumeMetadata.decode.bind(updateVolumeMetadata), + ), deleteVolume: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteVolumeResponse.decode.bind(deleteVolumeResponse), - deleteVolumeMetadata.decode.bind(deleteVolumeMetadata)), + deleteVolumeMetadata.decode.bind(deleteVolumeMetadata), + ), revertVolume: new this._gaxModule.LongrunningDescriptor( this.operationsClient, revertVolumeResponse.decode.bind(revertVolumeResponse), - revertVolumeMetadata.decode.bind(revertVolumeMetadata)), + revertVolumeMetadata.decode.bind(revertVolumeMetadata), + ), establishVolumePeering: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - establishVolumePeeringResponse.decode.bind(establishVolumePeeringResponse), - establishVolumePeeringMetadata.decode.bind(establishVolumePeeringMetadata)), + establishVolumePeeringResponse.decode.bind( + establishVolumePeeringResponse, + ), + establishVolumePeeringMetadata.decode.bind( + establishVolumePeeringMetadata, + ), + ), createSnapshot: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createSnapshotResponse.decode.bind(createSnapshotResponse), - createSnapshotMetadata.decode.bind(createSnapshotMetadata)), + createSnapshotMetadata.decode.bind(createSnapshotMetadata), + ), deleteSnapshot: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteSnapshotResponse.decode.bind(deleteSnapshotResponse), - deleteSnapshotMetadata.decode.bind(deleteSnapshotMetadata)), + deleteSnapshotMetadata.decode.bind(deleteSnapshotMetadata), + ), updateSnapshot: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateSnapshotResponse.decode.bind(updateSnapshotResponse), - updateSnapshotMetadata.decode.bind(updateSnapshotMetadata)), + updateSnapshotMetadata.decode.bind(updateSnapshotMetadata), + ), createActiveDirectory: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - createActiveDirectoryResponse.decode.bind(createActiveDirectoryResponse), - createActiveDirectoryMetadata.decode.bind(createActiveDirectoryMetadata)), + createActiveDirectoryResponse.decode.bind( + createActiveDirectoryResponse, + ), + createActiveDirectoryMetadata.decode.bind( + createActiveDirectoryMetadata, + ), + ), updateActiveDirectory: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - updateActiveDirectoryResponse.decode.bind(updateActiveDirectoryResponse), - updateActiveDirectoryMetadata.decode.bind(updateActiveDirectoryMetadata)), + updateActiveDirectoryResponse.decode.bind( + updateActiveDirectoryResponse, + ), + updateActiveDirectoryMetadata.decode.bind( + updateActiveDirectoryMetadata, + ), + ), deleteActiveDirectory: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - deleteActiveDirectoryResponse.decode.bind(deleteActiveDirectoryResponse), - deleteActiveDirectoryMetadata.decode.bind(deleteActiveDirectoryMetadata)), + deleteActiveDirectoryResponse.decode.bind( + deleteActiveDirectoryResponse, + ), + deleteActiveDirectoryMetadata.decode.bind( + deleteActiveDirectoryMetadata, + ), + ), createKmsConfig: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createKmsConfigResponse.decode.bind(createKmsConfigResponse), - createKmsConfigMetadata.decode.bind(createKmsConfigMetadata)), + createKmsConfigMetadata.decode.bind(createKmsConfigMetadata), + ), updateKmsConfig: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateKmsConfigResponse.decode.bind(updateKmsConfigResponse), - updateKmsConfigMetadata.decode.bind(updateKmsConfigMetadata)), + updateKmsConfigMetadata.decode.bind(updateKmsConfigMetadata), + ), encryptVolumes: new this._gaxModule.LongrunningDescriptor( this.operationsClient, encryptVolumesResponse.decode.bind(encryptVolumesResponse), - encryptVolumesMetadata.decode.bind(encryptVolumesMetadata)), + encryptVolumesMetadata.decode.bind(encryptVolumesMetadata), + ), deleteKmsConfig: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteKmsConfigResponse.decode.bind(deleteKmsConfigResponse), - deleteKmsConfigMetadata.decode.bind(deleteKmsConfigMetadata)), + deleteKmsConfigMetadata.decode.bind(deleteKmsConfigMetadata), + ), createReplication: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createReplicationResponse.decode.bind(createReplicationResponse), - createReplicationMetadata.decode.bind(createReplicationMetadata)), + createReplicationMetadata.decode.bind(createReplicationMetadata), + ), deleteReplication: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteReplicationResponse.decode.bind(deleteReplicationResponse), - deleteReplicationMetadata.decode.bind(deleteReplicationMetadata)), + deleteReplicationMetadata.decode.bind(deleteReplicationMetadata), + ), updateReplication: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateReplicationResponse.decode.bind(updateReplicationResponse), - updateReplicationMetadata.decode.bind(updateReplicationMetadata)), + updateReplicationMetadata.decode.bind(updateReplicationMetadata), + ), stopReplication: new this._gaxModule.LongrunningDescriptor( this.operationsClient, stopReplicationResponse.decode.bind(stopReplicationResponse), - stopReplicationMetadata.decode.bind(stopReplicationMetadata)), + stopReplicationMetadata.decode.bind(stopReplicationMetadata), + ), resumeReplication: new this._gaxModule.LongrunningDescriptor( this.operationsClient, resumeReplicationResponse.decode.bind(resumeReplicationResponse), - resumeReplicationMetadata.decode.bind(resumeReplicationMetadata)), + resumeReplicationMetadata.decode.bind(resumeReplicationMetadata), + ), reverseReplicationDirection: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - reverseReplicationDirectionResponse.decode.bind(reverseReplicationDirectionResponse), - reverseReplicationDirectionMetadata.decode.bind(reverseReplicationDirectionMetadata)), + reverseReplicationDirectionResponse.decode.bind( + reverseReplicationDirectionResponse, + ), + reverseReplicationDirectionMetadata.decode.bind( + reverseReplicationDirectionMetadata, + ), + ), establishPeering: new this._gaxModule.LongrunningDescriptor( this.operationsClient, establishPeeringResponse.decode.bind(establishPeeringResponse), - establishPeeringMetadata.decode.bind(establishPeeringMetadata)), + establishPeeringMetadata.decode.bind(establishPeeringMetadata), + ), syncReplication: new this._gaxModule.LongrunningDescriptor( this.operationsClient, syncReplicationResponse.decode.bind(syncReplicationResponse), - syncReplicationMetadata.decode.bind(syncReplicationMetadata)), + syncReplicationMetadata.decode.bind(syncReplicationMetadata), + ), createBackupVault: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createBackupVaultResponse.decode.bind(createBackupVaultResponse), - createBackupVaultMetadata.decode.bind(createBackupVaultMetadata)), + createBackupVaultMetadata.decode.bind(createBackupVaultMetadata), + ), updateBackupVault: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateBackupVaultResponse.decode.bind(updateBackupVaultResponse), - updateBackupVaultMetadata.decode.bind(updateBackupVaultMetadata)), + updateBackupVaultMetadata.decode.bind(updateBackupVaultMetadata), + ), deleteBackupVault: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteBackupVaultResponse.decode.bind(deleteBackupVaultResponse), - deleteBackupVaultMetadata.decode.bind(deleteBackupVaultMetadata)), + deleteBackupVaultMetadata.decode.bind(deleteBackupVaultMetadata), + ), createBackup: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createBackupResponse.decode.bind(createBackupResponse), - createBackupMetadata.decode.bind(createBackupMetadata)), + createBackupMetadata.decode.bind(createBackupMetadata), + ), deleteBackup: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteBackupResponse.decode.bind(deleteBackupResponse), - deleteBackupMetadata.decode.bind(deleteBackupMetadata)), + deleteBackupMetadata.decode.bind(deleteBackupMetadata), + ), updateBackup: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateBackupResponse.decode.bind(updateBackupResponse), - updateBackupMetadata.decode.bind(updateBackupMetadata)), + updateBackupMetadata.decode.bind(updateBackupMetadata), + ), createBackupPolicy: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createBackupPolicyResponse.decode.bind(createBackupPolicyResponse), - createBackupPolicyMetadata.decode.bind(createBackupPolicyMetadata)), + createBackupPolicyMetadata.decode.bind(createBackupPolicyMetadata), + ), updateBackupPolicy: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateBackupPolicyResponse.decode.bind(updateBackupPolicyResponse), - updateBackupPolicyMetadata.decode.bind(updateBackupPolicyMetadata)), + updateBackupPolicyMetadata.decode.bind(updateBackupPolicyMetadata), + ), deleteBackupPolicy: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteBackupPolicyResponse.decode.bind(deleteBackupPolicyResponse), - deleteBackupPolicyMetadata.decode.bind(deleteBackupPolicyMetadata)), + deleteBackupPolicyMetadata.decode.bind(deleteBackupPolicyMetadata), + ), createQuotaRule: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createQuotaRuleResponse.decode.bind(createQuotaRuleResponse), - createQuotaRuleMetadata.decode.bind(createQuotaRuleMetadata)), + createQuotaRuleMetadata.decode.bind(createQuotaRuleMetadata), + ), updateQuotaRule: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateQuotaRuleResponse.decode.bind(updateQuotaRuleResponse), - updateQuotaRuleMetadata.decode.bind(updateQuotaRuleMetadata)), + updateQuotaRuleMetadata.decode.bind(updateQuotaRuleMetadata), + ), deleteQuotaRule: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteQuotaRuleResponse.decode.bind(deleteQuotaRuleResponse), - deleteQuotaRuleMetadata.decode.bind(deleteQuotaRuleMetadata)), + deleteQuotaRuleMetadata.decode.bind(deleteQuotaRuleMetadata), + ), restoreBackupFiles: new this._gaxModule.LongrunningDescriptor( this.operationsClient, restoreBackupFilesResponse.decode.bind(restoreBackupFilesResponse), - restoreBackupFilesMetadata.decode.bind(restoreBackupFilesMetadata)), + restoreBackupFilesMetadata.decode.bind(restoreBackupFilesMetadata), + ), createHostGroup: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createHostGroupResponse.decode.bind(createHostGroupResponse), - createHostGroupMetadata.decode.bind(createHostGroupMetadata)), + createHostGroupMetadata.decode.bind(createHostGroupMetadata), + ), updateHostGroup: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateHostGroupResponse.decode.bind(updateHostGroupResponse), - updateHostGroupMetadata.decode.bind(updateHostGroupMetadata)), + updateHostGroupMetadata.decode.bind(updateHostGroupMetadata), + ), deleteHostGroup: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteHostGroupResponse.decode.bind(deleteHostGroupResponse), - deleteHostGroupMetadata.decode.bind(deleteHostGroupMetadata)) + deleteHostGroupMetadata.decode.bind(deleteHostGroupMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.netapp.v1.NetApp', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.netapp.v1.NetApp', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -650,28 +902,105 @@ export class NetAppClient { // Put together the "service stub" for // google.cloud.netapp.v1.NetApp. this.netAppStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.netapp.v1.NetApp') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.netapp.v1.NetApp', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.netapp.v1.NetApp, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const netAppStubMethods = - ['listStoragePools', 'createStoragePool', 'getStoragePool', 'updateStoragePool', 'deleteStoragePool', 'validateDirectoryService', 'switchActiveReplicaZone', 'listVolumes', 'getVolume', 'createVolume', 'updateVolume', 'deleteVolume', 'revertVolume', 'establishVolumePeering', 'listSnapshots', 'getSnapshot', 'createSnapshot', 'deleteSnapshot', 'updateSnapshot', 'listActiveDirectories', 'getActiveDirectory', 'createActiveDirectory', 'updateActiveDirectory', 'deleteActiveDirectory', 'listKmsConfigs', 'createKmsConfig', 'getKmsConfig', 'updateKmsConfig', 'encryptVolumes', 'verifyKmsConfig', 'deleteKmsConfig', 'listReplications', 'getReplication', 'createReplication', 'deleteReplication', 'updateReplication', 'stopReplication', 'resumeReplication', 'reverseReplicationDirection', 'establishPeering', 'syncReplication', 'createBackupVault', 'getBackupVault', 'listBackupVaults', 'updateBackupVault', 'deleteBackupVault', 'createBackup', 'getBackup', 'listBackups', 'deleteBackup', 'updateBackup', 'createBackupPolicy', 'getBackupPolicy', 'listBackupPolicies', 'updateBackupPolicy', 'deleteBackupPolicy', 'listQuotaRules', 'getQuotaRule', 'createQuotaRule', 'updateQuotaRule', 'deleteQuotaRule', 'restoreBackupFiles', 'listHostGroups', 'getHostGroup', 'createHostGroup', 'updateHostGroup', 'deleteHostGroup', 'executeOntapPost', 'executeOntapGet', 'executeOntapDelete', 'executeOntapPatch']; + const netAppStubMethods = [ + 'listStoragePools', + 'createStoragePool', + 'getStoragePool', + 'updateStoragePool', + 'deleteStoragePool', + 'validateDirectoryService', + 'switchActiveReplicaZone', + 'listVolumes', + 'getVolume', + 'createVolume', + 'updateVolume', + 'deleteVolume', + 'revertVolume', + 'establishVolumePeering', + 'listSnapshots', + 'getSnapshot', + 'createSnapshot', + 'deleteSnapshot', + 'updateSnapshot', + 'listActiveDirectories', + 'getActiveDirectory', + 'createActiveDirectory', + 'updateActiveDirectory', + 'deleteActiveDirectory', + 'listKmsConfigs', + 'createKmsConfig', + 'getKmsConfig', + 'updateKmsConfig', + 'encryptVolumes', + 'verifyKmsConfig', + 'deleteKmsConfig', + 'listReplications', + 'getReplication', + 'createReplication', + 'deleteReplication', + 'updateReplication', + 'stopReplication', + 'resumeReplication', + 'reverseReplicationDirection', + 'establishPeering', + 'syncReplication', + 'createBackupVault', + 'getBackupVault', + 'listBackupVaults', + 'updateBackupVault', + 'deleteBackupVault', + 'createBackup', + 'getBackup', + 'listBackups', + 'deleteBackup', + 'updateBackup', + 'createBackupPolicy', + 'getBackupPolicy', + 'listBackupPolicies', + 'updateBackupPolicy', + 'deleteBackupPolicy', + 'listQuotaRules', + 'getQuotaRule', + 'createQuotaRule', + 'updateQuotaRule', + 'deleteQuotaRule', + 'restoreBackupFiles', + 'listHostGroups', + 'getHostGroup', + 'createHostGroup', + 'updateHostGroup', + 'deleteHostGroup', + 'executeOntapPost', + 'executeOntapGet', + 'executeOntapDelete', + 'executeOntapPatch', + ]; for (const methodName of netAppStubMethods) { const callPromise = this.netAppStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -681,7 +1010,7 @@ export class NetAppClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -696,8 +1025,14 @@ export class NetAppClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'netapp.googleapis.com'; } @@ -708,8 +1043,14 @@ export class NetAppClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'netapp.googleapis.com'; } @@ -740,9 +1081,7 @@ export class NetAppClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -751,8 +1090,9 @@ export class NetAppClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -763,6576 +1103,9873 @@ export class NetAppClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Returns the description of the specified storage pool by poolId. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of 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 {@link protos.google.cloud.netapp.v1.StoragePool|StoragePool}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/net_app.get_storage_pool.js - * region_tag:netapp_v1_generated_NetApp_GetStoragePool_async - */ + /** + * Returns the description of the specified storage pool by poolId. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of 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 {@link protos.google.cloud.netapp.v1.StoragePool|StoragePool}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/net_app.get_storage_pool.js + * region_tag:netapp_v1_generated_NetApp_GetStoragePool_async + */ getStoragePool( - request?: protos.google.cloud.netapp.v1.IGetStoragePoolRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.netapp.v1.IStoragePool, - protos.google.cloud.netapp.v1.IGetStoragePoolRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IGetStoragePoolRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IGetStoragePoolRequest | undefined, + {} | undefined, + ] + >; getStoragePool( - request: protos.google.cloud.netapp.v1.IGetStoragePoolRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.netapp.v1.IStoragePool, - protos.google.cloud.netapp.v1.IGetStoragePoolRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IGetStoragePoolRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IGetStoragePoolRequest | null | undefined, + {} | null | undefined + >, + ): void; getStoragePool( - request: protos.google.cloud.netapp.v1.IGetStoragePoolRequest, - callback: Callback< - protos.google.cloud.netapp.v1.IStoragePool, - protos.google.cloud.netapp.v1.IGetStoragePoolRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IGetStoragePoolRequest, + callback: Callback< + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IGetStoragePoolRequest | null | undefined, + {} | null | undefined + >, + ): void; getStoragePool( - request?: protos.google.cloud.netapp.v1.IGetStoragePoolRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.netapp.v1.IStoragePool, - protos.google.cloud.netapp.v1.IGetStoragePoolRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.netapp.v1.IGetStoragePoolRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.netapp.v1.IStoragePool, - protos.google.cloud.netapp.v1.IGetStoragePoolRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.netapp.v1.IStoragePool, - protos.google.cloud.netapp.v1.IGetStoragePoolRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.netapp.v1.IGetStoragePoolRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IGetStoragePoolRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IGetStoragePoolRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getStoragePool request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.netapp.v1.IStoragePool, - protos.google.cloud.netapp.v1.IGetStoragePoolRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.netapp.v1.IStoragePool, + | protos.google.cloud.netapp.v1.IGetStoragePoolRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getStoragePool response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getStoragePool(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.netapp.v1.IStoragePool, - protos.google.cloud.netapp.v1.IGetStoragePoolRequest|undefined, - {}|undefined - ]) => { - this._log.info('getStoragePool response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getStoragePool(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IGetStoragePoolRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getStoragePool response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single Volume. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the volume - * @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 {@link protos.google.cloud.netapp.v1.Volume|Volume}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/net_app.get_volume.js - * region_tag:netapp_v1_generated_NetApp_GetVolume_async - */ + /** + * Gets details of a single Volume. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the volume + * @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 {@link protos.google.cloud.netapp.v1.Volume|Volume}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/net_app.get_volume.js + * region_tag:netapp_v1_generated_NetApp_GetVolume_async + */ getVolume( - request?: protos.google.cloud.netapp.v1.IGetVolumeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.netapp.v1.IVolume, - protos.google.cloud.netapp.v1.IGetVolumeRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IGetVolumeRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IGetVolumeRequest | undefined, + {} | undefined, + ] + >; getVolume( - request: protos.google.cloud.netapp.v1.IGetVolumeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.netapp.v1.IVolume, - protos.google.cloud.netapp.v1.IGetVolumeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IGetVolumeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IGetVolumeRequest | null | undefined, + {} | null | undefined + >, + ): void; getVolume( - request: protos.google.cloud.netapp.v1.IGetVolumeRequest, - callback: Callback< - protos.google.cloud.netapp.v1.IVolume, - protos.google.cloud.netapp.v1.IGetVolumeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IGetVolumeRequest, + callback: Callback< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IGetVolumeRequest | null | undefined, + {} | null | undefined + >, + ): void; getVolume( - request?: protos.google.cloud.netapp.v1.IGetVolumeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.netapp.v1.IVolume, - protos.google.cloud.netapp.v1.IGetVolumeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.netapp.v1.IGetVolumeRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.netapp.v1.IVolume, - protos.google.cloud.netapp.v1.IGetVolumeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.netapp.v1.IVolume, - protos.google.cloud.netapp.v1.IGetVolumeRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.netapp.v1.IGetVolumeRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IGetVolumeRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IGetVolumeRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getVolume request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.netapp.v1.IVolume, - protos.google.cloud.netapp.v1.IGetVolumeRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IGetVolumeRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getVolume response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getVolume(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.netapp.v1.IVolume, - protos.google.cloud.netapp.v1.IGetVolumeRequest|undefined, - {}|undefined - ]) => { - this._log.info('getVolume response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getVolume(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IGetVolumeRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getVolume response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Describe a snapshot for a volume. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The snapshot resource name, in the format - * `projects/{project_id}/locations/{location}/volumes/{volume_id}/snapshots/{snapshot_id}` - * @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 {@link protos.google.cloud.netapp.v1.Snapshot|Snapshot}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/net_app.get_snapshot.js - * region_tag:netapp_v1_generated_NetApp_GetSnapshot_async - */ + /** + * Describe a snapshot for a volume. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The snapshot resource name, in the format + * `projects/{project_id}/locations/{location}/volumes/{volume_id}/snapshots/{snapshot_id}` + * @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 {@link protos.google.cloud.netapp.v1.Snapshot|Snapshot}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/net_app.get_snapshot.js + * region_tag:netapp_v1_generated_NetApp_GetSnapshot_async + */ getSnapshot( - request?: protos.google.cloud.netapp.v1.IGetSnapshotRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.netapp.v1.ISnapshot, - protos.google.cloud.netapp.v1.IGetSnapshotRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IGetSnapshotRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.netapp.v1.ISnapshot, + protos.google.cloud.netapp.v1.IGetSnapshotRequest | undefined, + {} | undefined, + ] + >; getSnapshot( - request: protos.google.cloud.netapp.v1.IGetSnapshotRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.netapp.v1.ISnapshot, - protos.google.cloud.netapp.v1.IGetSnapshotRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IGetSnapshotRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.netapp.v1.ISnapshot, + protos.google.cloud.netapp.v1.IGetSnapshotRequest | null | undefined, + {} | null | undefined + >, + ): void; getSnapshot( - request: protos.google.cloud.netapp.v1.IGetSnapshotRequest, - callback: Callback< - protos.google.cloud.netapp.v1.ISnapshot, - protos.google.cloud.netapp.v1.IGetSnapshotRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IGetSnapshotRequest, + callback: Callback< + protos.google.cloud.netapp.v1.ISnapshot, + protos.google.cloud.netapp.v1.IGetSnapshotRequest | null | undefined, + {} | null | undefined + >, + ): void; getSnapshot( - request?: protos.google.cloud.netapp.v1.IGetSnapshotRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.netapp.v1.ISnapshot, - protos.google.cloud.netapp.v1.IGetSnapshotRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.netapp.v1.IGetSnapshotRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.netapp.v1.ISnapshot, - protos.google.cloud.netapp.v1.IGetSnapshotRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.netapp.v1.ISnapshot, - protos.google.cloud.netapp.v1.IGetSnapshotRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.netapp.v1.IGetSnapshotRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.netapp.v1.ISnapshot, + protos.google.cloud.netapp.v1.IGetSnapshotRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.netapp.v1.ISnapshot, + protos.google.cloud.netapp.v1.IGetSnapshotRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getSnapshot request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.netapp.v1.ISnapshot, - protos.google.cloud.netapp.v1.IGetSnapshotRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.netapp.v1.ISnapshot, + protos.google.cloud.netapp.v1.IGetSnapshotRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getSnapshot response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getSnapshot(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.netapp.v1.ISnapshot, - protos.google.cloud.netapp.v1.IGetSnapshotRequest|undefined, - {}|undefined - ]) => { - this._log.info('getSnapshot response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getSnapshot(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.netapp.v1.ISnapshot, + protos.google.cloud.netapp.v1.IGetSnapshotRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getSnapshot response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Describes a specified active directory. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the active directory. - * @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 {@link protos.google.cloud.netapp.v1.ActiveDirectory|ActiveDirectory}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/net_app.get_active_directory.js - * region_tag:netapp_v1_generated_NetApp_GetActiveDirectory_async - */ + /** + * Describes a specified active directory. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the active directory. + * @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 {@link protos.google.cloud.netapp.v1.ActiveDirectory|ActiveDirectory}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/net_app.get_active_directory.js + * region_tag:netapp_v1_generated_NetApp_GetActiveDirectory_async + */ getActiveDirectory( - request?: protos.google.cloud.netapp.v1.IGetActiveDirectoryRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.netapp.v1.IActiveDirectory, - protos.google.cloud.netapp.v1.IGetActiveDirectoryRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IGetActiveDirectoryRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.netapp.v1.IActiveDirectory, + protos.google.cloud.netapp.v1.IGetActiveDirectoryRequest | undefined, + {} | undefined, + ] + >; getActiveDirectory( - request: protos.google.cloud.netapp.v1.IGetActiveDirectoryRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.netapp.v1.IActiveDirectory, - protos.google.cloud.netapp.v1.IGetActiveDirectoryRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IGetActiveDirectoryRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.netapp.v1.IActiveDirectory, + | protos.google.cloud.netapp.v1.IGetActiveDirectoryRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getActiveDirectory( - request: protos.google.cloud.netapp.v1.IGetActiveDirectoryRequest, - callback: Callback< - protos.google.cloud.netapp.v1.IActiveDirectory, - protos.google.cloud.netapp.v1.IGetActiveDirectoryRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IGetActiveDirectoryRequest, + callback: Callback< + protos.google.cloud.netapp.v1.IActiveDirectory, + | protos.google.cloud.netapp.v1.IGetActiveDirectoryRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getActiveDirectory( - request?: protos.google.cloud.netapp.v1.IGetActiveDirectoryRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.netapp.v1.IActiveDirectory, - protos.google.cloud.netapp.v1.IGetActiveDirectoryRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.netapp.v1.IGetActiveDirectoryRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.netapp.v1.IActiveDirectory, - protos.google.cloud.netapp.v1.IGetActiveDirectoryRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.netapp.v1.IActiveDirectory, - protos.google.cloud.netapp.v1.IGetActiveDirectoryRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.netapp.v1.IGetActiveDirectoryRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.netapp.v1.IActiveDirectory, + | protos.google.cloud.netapp.v1.IGetActiveDirectoryRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.netapp.v1.IActiveDirectory, + protos.google.cloud.netapp.v1.IGetActiveDirectoryRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getActiveDirectory request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.netapp.v1.IActiveDirectory, - protos.google.cloud.netapp.v1.IGetActiveDirectoryRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.netapp.v1.IActiveDirectory, + | protos.google.cloud.netapp.v1.IGetActiveDirectoryRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getActiveDirectory response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getActiveDirectory(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.netapp.v1.IActiveDirectory, - protos.google.cloud.netapp.v1.IGetActiveDirectoryRequest|undefined, - {}|undefined - ]) => { - this._log.info('getActiveDirectory response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getActiveDirectory(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.netapp.v1.IActiveDirectory, + protos.google.cloud.netapp.v1.IGetActiveDirectoryRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getActiveDirectory response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Returns the description of the specified KMS config by kms_config_id. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the KmsConfig - * @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 {@link protos.google.cloud.netapp.v1.KmsConfig|KmsConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/net_app.get_kms_config.js - * region_tag:netapp_v1_generated_NetApp_GetKmsConfig_async - */ + /** + * Returns the description of the specified KMS config by kms_config_id. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the KmsConfig + * @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 {@link protos.google.cloud.netapp.v1.KmsConfig|KmsConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/net_app.get_kms_config.js + * region_tag:netapp_v1_generated_NetApp_GetKmsConfig_async + */ getKmsConfig( - request?: protos.google.cloud.netapp.v1.IGetKmsConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.netapp.v1.IKmsConfig, - protos.google.cloud.netapp.v1.IGetKmsConfigRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IGetKmsConfigRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IGetKmsConfigRequest | undefined, + {} | undefined, + ] + >; getKmsConfig( - request: protos.google.cloud.netapp.v1.IGetKmsConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.netapp.v1.IKmsConfig, - protos.google.cloud.netapp.v1.IGetKmsConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IGetKmsConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IGetKmsConfigRequest | null | undefined, + {} | null | undefined + >, + ): void; getKmsConfig( - request: protos.google.cloud.netapp.v1.IGetKmsConfigRequest, - callback: Callback< - protos.google.cloud.netapp.v1.IKmsConfig, - protos.google.cloud.netapp.v1.IGetKmsConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IGetKmsConfigRequest, + callback: Callback< + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IGetKmsConfigRequest | null | undefined, + {} | null | undefined + >, + ): void; getKmsConfig( - request?: protos.google.cloud.netapp.v1.IGetKmsConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.netapp.v1.IKmsConfig, - protos.google.cloud.netapp.v1.IGetKmsConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.netapp.v1.IGetKmsConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.netapp.v1.IKmsConfig, - protos.google.cloud.netapp.v1.IGetKmsConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.netapp.v1.IKmsConfig, - protos.google.cloud.netapp.v1.IGetKmsConfigRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.netapp.v1.IGetKmsConfigRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IGetKmsConfigRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IGetKmsConfigRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getKmsConfig request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.netapp.v1.IKmsConfig, - protos.google.cloud.netapp.v1.IGetKmsConfigRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IGetKmsConfigRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getKmsConfig response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getKmsConfig(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.netapp.v1.IKmsConfig, - protos.google.cloud.netapp.v1.IGetKmsConfigRequest|undefined, - {}|undefined - ]) => { - this._log.info('getKmsConfig response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getKmsConfig(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IGetKmsConfigRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getKmsConfig response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Verifies KMS config reachability. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the KMS Config to be verified. - * @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 {@link protos.google.cloud.netapp.v1.VerifyKmsConfigResponse|VerifyKmsConfigResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/net_app.verify_kms_config.js - * region_tag:netapp_v1_generated_NetApp_VerifyKmsConfig_async - */ + /** + * Verifies KMS config reachability. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the KMS Config to be verified. + * @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 {@link protos.google.cloud.netapp.v1.VerifyKmsConfigResponse|VerifyKmsConfigResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/net_app.verify_kms_config.js + * region_tag:netapp_v1_generated_NetApp_VerifyKmsConfig_async + */ verifyKmsConfig( - request?: protos.google.cloud.netapp.v1.IVerifyKmsConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.netapp.v1.IVerifyKmsConfigResponse, - protos.google.cloud.netapp.v1.IVerifyKmsConfigRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IVerifyKmsConfigRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.netapp.v1.IVerifyKmsConfigResponse, + protos.google.cloud.netapp.v1.IVerifyKmsConfigRequest | undefined, + {} | undefined, + ] + >; verifyKmsConfig( - request: protos.google.cloud.netapp.v1.IVerifyKmsConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.netapp.v1.IVerifyKmsConfigResponse, - protos.google.cloud.netapp.v1.IVerifyKmsConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IVerifyKmsConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.netapp.v1.IVerifyKmsConfigResponse, + protos.google.cloud.netapp.v1.IVerifyKmsConfigRequest | null | undefined, + {} | null | undefined + >, + ): void; verifyKmsConfig( - request: protos.google.cloud.netapp.v1.IVerifyKmsConfigRequest, - callback: Callback< - protos.google.cloud.netapp.v1.IVerifyKmsConfigResponse, - protos.google.cloud.netapp.v1.IVerifyKmsConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IVerifyKmsConfigRequest, + callback: Callback< + protos.google.cloud.netapp.v1.IVerifyKmsConfigResponse, + protos.google.cloud.netapp.v1.IVerifyKmsConfigRequest | null | undefined, + {} | null | undefined + >, + ): void; verifyKmsConfig( - request?: protos.google.cloud.netapp.v1.IVerifyKmsConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.netapp.v1.IVerifyKmsConfigResponse, - protos.google.cloud.netapp.v1.IVerifyKmsConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.netapp.v1.IVerifyKmsConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.netapp.v1.IVerifyKmsConfigResponse, - protos.google.cloud.netapp.v1.IVerifyKmsConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.netapp.v1.IVerifyKmsConfigResponse, - protos.google.cloud.netapp.v1.IVerifyKmsConfigRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.netapp.v1.IVerifyKmsConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.netapp.v1.IVerifyKmsConfigResponse, + protos.google.cloud.netapp.v1.IVerifyKmsConfigRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.netapp.v1.IVerifyKmsConfigResponse, + protos.google.cloud.netapp.v1.IVerifyKmsConfigRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('verifyKmsConfig request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.netapp.v1.IVerifyKmsConfigResponse, - protos.google.cloud.netapp.v1.IVerifyKmsConfigRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.netapp.v1.IVerifyKmsConfigResponse, + | protos.google.cloud.netapp.v1.IVerifyKmsConfigRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('verifyKmsConfig response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.verifyKmsConfig(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.netapp.v1.IVerifyKmsConfigResponse, - protos.google.cloud.netapp.v1.IVerifyKmsConfigRequest|undefined, - {}|undefined - ]) => { - this._log.info('verifyKmsConfig response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .verifyKmsConfig(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.netapp.v1.IVerifyKmsConfigResponse, + protos.google.cloud.netapp.v1.IVerifyKmsConfigRequest | undefined, + {} | undefined, + ]) => { + this._log.info('verifyKmsConfig response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Describe a replication for a volume. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The replication resource name, in the format - * `projects/{project_id}/locations/{location}/volumes/{volume_id}/replications/{replication_id}` - * @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 {@link protos.google.cloud.netapp.v1.Replication|Replication}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/net_app.get_replication.js - * region_tag:netapp_v1_generated_NetApp_GetReplication_async - */ + /** + * Describe a replication for a volume. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The replication resource name, in the format + * `projects/{project_id}/locations/{location}/volumes/{volume_id}/replications/{replication_id}` + * @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 {@link protos.google.cloud.netapp.v1.Replication|Replication}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/net_app.get_replication.js + * region_tag:netapp_v1_generated_NetApp_GetReplication_async + */ getReplication( - request?: protos.google.cloud.netapp.v1.IGetReplicationRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.netapp.v1.IReplication, - protos.google.cloud.netapp.v1.IGetReplicationRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IGetReplicationRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IGetReplicationRequest | undefined, + {} | undefined, + ] + >; getReplication( - request: protos.google.cloud.netapp.v1.IGetReplicationRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.netapp.v1.IReplication, - protos.google.cloud.netapp.v1.IGetReplicationRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IGetReplicationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IGetReplicationRequest | null | undefined, + {} | null | undefined + >, + ): void; getReplication( - request: protos.google.cloud.netapp.v1.IGetReplicationRequest, - callback: Callback< - protos.google.cloud.netapp.v1.IReplication, - protos.google.cloud.netapp.v1.IGetReplicationRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IGetReplicationRequest, + callback: Callback< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IGetReplicationRequest | null | undefined, + {} | null | undefined + >, + ): void; getReplication( - request?: protos.google.cloud.netapp.v1.IGetReplicationRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.netapp.v1.IReplication, - protos.google.cloud.netapp.v1.IGetReplicationRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.netapp.v1.IGetReplicationRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.netapp.v1.IReplication, - protos.google.cloud.netapp.v1.IGetReplicationRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.netapp.v1.IReplication, - protos.google.cloud.netapp.v1.IGetReplicationRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.netapp.v1.IGetReplicationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IGetReplicationRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IGetReplicationRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getReplication request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.netapp.v1.IReplication, - protos.google.cloud.netapp.v1.IGetReplicationRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.netapp.v1.IReplication, + | protos.google.cloud.netapp.v1.IGetReplicationRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getReplication response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getReplication(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.netapp.v1.IReplication, - protos.google.cloud.netapp.v1.IGetReplicationRequest|undefined, - {}|undefined - ]) => { - this._log.info('getReplication response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getReplication(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IGetReplicationRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getReplication response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Returns the description of the specified backup vault - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The backupVault resource name, in the format - * `projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}` - * @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 {@link protos.google.cloud.netapp.v1.BackupVault|BackupVault}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/net_app.get_backup_vault.js - * region_tag:netapp_v1_generated_NetApp_GetBackupVault_async - */ + /** + * Returns the description of the specified backup vault + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The backupVault resource name, in the format + * `projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}` + * @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 {@link protos.google.cloud.netapp.v1.BackupVault|BackupVault}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/net_app.get_backup_vault.js + * region_tag:netapp_v1_generated_NetApp_GetBackupVault_async + */ getBackupVault( - request?: protos.google.cloud.netapp.v1.IGetBackupVaultRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.netapp.v1.IBackupVault, - protos.google.cloud.netapp.v1.IGetBackupVaultRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IGetBackupVaultRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.netapp.v1.IBackupVault, + protos.google.cloud.netapp.v1.IGetBackupVaultRequest | undefined, + {} | undefined, + ] + >; getBackupVault( - request: protos.google.cloud.netapp.v1.IGetBackupVaultRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.netapp.v1.IBackupVault, - protos.google.cloud.netapp.v1.IGetBackupVaultRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IGetBackupVaultRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.netapp.v1.IBackupVault, + protos.google.cloud.netapp.v1.IGetBackupVaultRequest | null | undefined, + {} | null | undefined + >, + ): void; getBackupVault( - request: protos.google.cloud.netapp.v1.IGetBackupVaultRequest, - callback: Callback< - protos.google.cloud.netapp.v1.IBackupVault, - protos.google.cloud.netapp.v1.IGetBackupVaultRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IGetBackupVaultRequest, + callback: Callback< + protos.google.cloud.netapp.v1.IBackupVault, + protos.google.cloud.netapp.v1.IGetBackupVaultRequest | null | undefined, + {} | null | undefined + >, + ): void; getBackupVault( - request?: protos.google.cloud.netapp.v1.IGetBackupVaultRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.netapp.v1.IBackupVault, - protos.google.cloud.netapp.v1.IGetBackupVaultRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.netapp.v1.IGetBackupVaultRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.netapp.v1.IBackupVault, - protos.google.cloud.netapp.v1.IGetBackupVaultRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.netapp.v1.IBackupVault, - protos.google.cloud.netapp.v1.IGetBackupVaultRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.netapp.v1.IGetBackupVaultRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.netapp.v1.IBackupVault, + protos.google.cloud.netapp.v1.IGetBackupVaultRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.netapp.v1.IBackupVault, + protos.google.cloud.netapp.v1.IGetBackupVaultRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getBackupVault request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.netapp.v1.IBackupVault, - protos.google.cloud.netapp.v1.IGetBackupVaultRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.netapp.v1.IBackupVault, + | protos.google.cloud.netapp.v1.IGetBackupVaultRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getBackupVault response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getBackupVault(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.netapp.v1.IBackupVault, - protos.google.cloud.netapp.v1.IGetBackupVaultRequest|undefined, - {}|undefined - ]) => { - this._log.info('getBackupVault response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getBackupVault(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.netapp.v1.IBackupVault, + protos.google.cloud.netapp.v1.IGetBackupVaultRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getBackupVault response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Returns the description of the specified backup - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The backup resource name, in the format - * `projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}/backups/{backup_id}` - * @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 {@link protos.google.cloud.netapp.v1.Backup|Backup}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/net_app.get_backup.js - * region_tag:netapp_v1_generated_NetApp_GetBackup_async - */ + /** + * Returns the description of the specified backup + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The backup resource name, in the format + * `projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}/backups/{backup_id}` + * @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 {@link protos.google.cloud.netapp.v1.Backup|Backup}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/net_app.get_backup.js + * region_tag:netapp_v1_generated_NetApp_GetBackup_async + */ getBackup( - request?: protos.google.cloud.netapp.v1.IGetBackupRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.netapp.v1.IBackup, - protos.google.cloud.netapp.v1.IGetBackupRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IGetBackupRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.netapp.v1.IBackup, + protos.google.cloud.netapp.v1.IGetBackupRequest | undefined, + {} | undefined, + ] + >; getBackup( - request: protos.google.cloud.netapp.v1.IGetBackupRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.netapp.v1.IBackup, - protos.google.cloud.netapp.v1.IGetBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IGetBackupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.netapp.v1.IBackup, + protos.google.cloud.netapp.v1.IGetBackupRequest | null | undefined, + {} | null | undefined + >, + ): void; getBackup( - request: protos.google.cloud.netapp.v1.IGetBackupRequest, - callback: Callback< - protos.google.cloud.netapp.v1.IBackup, - protos.google.cloud.netapp.v1.IGetBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IGetBackupRequest, + callback: Callback< + protos.google.cloud.netapp.v1.IBackup, + protos.google.cloud.netapp.v1.IGetBackupRequest | null | undefined, + {} | null | undefined + >, + ): void; getBackup( - request?: protos.google.cloud.netapp.v1.IGetBackupRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.netapp.v1.IBackup, - protos.google.cloud.netapp.v1.IGetBackupRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.netapp.v1.IGetBackupRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.netapp.v1.IBackup, - protos.google.cloud.netapp.v1.IGetBackupRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.netapp.v1.IBackup, - protos.google.cloud.netapp.v1.IGetBackupRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.netapp.v1.IGetBackupRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.netapp.v1.IBackup, + protos.google.cloud.netapp.v1.IGetBackupRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.netapp.v1.IBackup, + protos.google.cloud.netapp.v1.IGetBackupRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getBackup request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.netapp.v1.IBackup, - protos.google.cloud.netapp.v1.IGetBackupRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.netapp.v1.IBackup, + protos.google.cloud.netapp.v1.IGetBackupRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getBackup response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getBackup(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.netapp.v1.IBackup, - protos.google.cloud.netapp.v1.IGetBackupRequest|undefined, - {}|undefined - ]) => { - this._log.info('getBackup response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getBackup(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.netapp.v1.IBackup, + protos.google.cloud.netapp.v1.IGetBackupRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getBackup response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Returns the description of the specified backup policy by backup_policy_id. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The backupPolicy resource name, in the format - * `projects/{project_id}/locations/{location}/backupPolicies/{backup_policy_id}` - * @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 {@link protos.google.cloud.netapp.v1.BackupPolicy|BackupPolicy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/net_app.get_backup_policy.js - * region_tag:netapp_v1_generated_NetApp_GetBackupPolicy_async - */ + /** + * Returns the description of the specified backup policy by backup_policy_id. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The backupPolicy resource name, in the format + * `projects/{project_id}/locations/{location}/backupPolicies/{backup_policy_id}` + * @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 {@link protos.google.cloud.netapp.v1.BackupPolicy|BackupPolicy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/net_app.get_backup_policy.js + * region_tag:netapp_v1_generated_NetApp_GetBackupPolicy_async + */ getBackupPolicy( - request?: protos.google.cloud.netapp.v1.IGetBackupPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.netapp.v1.IBackupPolicy, - protos.google.cloud.netapp.v1.IGetBackupPolicyRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IGetBackupPolicyRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.netapp.v1.IBackupPolicy, + protos.google.cloud.netapp.v1.IGetBackupPolicyRequest | undefined, + {} | undefined, + ] + >; getBackupPolicy( - request: protos.google.cloud.netapp.v1.IGetBackupPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.netapp.v1.IBackupPolicy, - protos.google.cloud.netapp.v1.IGetBackupPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IGetBackupPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.netapp.v1.IBackupPolicy, + protos.google.cloud.netapp.v1.IGetBackupPolicyRequest | null | undefined, + {} | null | undefined + >, + ): void; getBackupPolicy( - request: protos.google.cloud.netapp.v1.IGetBackupPolicyRequest, - callback: Callback< - protos.google.cloud.netapp.v1.IBackupPolicy, - protos.google.cloud.netapp.v1.IGetBackupPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IGetBackupPolicyRequest, + callback: Callback< + protos.google.cloud.netapp.v1.IBackupPolicy, + protos.google.cloud.netapp.v1.IGetBackupPolicyRequest | null | undefined, + {} | null | undefined + >, + ): void; getBackupPolicy( - request?: protos.google.cloud.netapp.v1.IGetBackupPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.netapp.v1.IBackupPolicy, - protos.google.cloud.netapp.v1.IGetBackupPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.netapp.v1.IGetBackupPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.netapp.v1.IBackupPolicy, - protos.google.cloud.netapp.v1.IGetBackupPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.netapp.v1.IBackupPolicy, - protos.google.cloud.netapp.v1.IGetBackupPolicyRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.netapp.v1.IGetBackupPolicyRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.netapp.v1.IBackupPolicy, + protos.google.cloud.netapp.v1.IGetBackupPolicyRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.netapp.v1.IBackupPolicy, + protos.google.cloud.netapp.v1.IGetBackupPolicyRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getBackupPolicy request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.netapp.v1.IBackupPolicy, - protos.google.cloud.netapp.v1.IGetBackupPolicyRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.netapp.v1.IBackupPolicy, + | protos.google.cloud.netapp.v1.IGetBackupPolicyRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getBackupPolicy response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getBackupPolicy(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.netapp.v1.IBackupPolicy, - protos.google.cloud.netapp.v1.IGetBackupPolicyRequest|undefined, - {}|undefined - ]) => { - this._log.info('getBackupPolicy response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getBackupPolicy(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.netapp.v1.IBackupPolicy, + protos.google.cloud.netapp.v1.IGetBackupPolicyRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getBackupPolicy response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Returns details of the specified quota rule. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the quota rule - * @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 {@link protos.google.cloud.netapp.v1.QuotaRule|QuotaRule}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/net_app.get_quota_rule.js - * region_tag:netapp_v1_generated_NetApp_GetQuotaRule_async - */ + /** + * Returns details of the specified quota rule. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the quota rule + * @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 {@link protos.google.cloud.netapp.v1.QuotaRule|QuotaRule}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/net_app.get_quota_rule.js + * region_tag:netapp_v1_generated_NetApp_GetQuotaRule_async + */ getQuotaRule( - request?: protos.google.cloud.netapp.v1.IGetQuotaRuleRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.netapp.v1.IQuotaRule, - protos.google.cloud.netapp.v1.IGetQuotaRuleRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IGetQuotaRuleRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.netapp.v1.IQuotaRule, + protos.google.cloud.netapp.v1.IGetQuotaRuleRequest | undefined, + {} | undefined, + ] + >; getQuotaRule( - request: protos.google.cloud.netapp.v1.IGetQuotaRuleRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.netapp.v1.IQuotaRule, - protos.google.cloud.netapp.v1.IGetQuotaRuleRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IGetQuotaRuleRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.netapp.v1.IQuotaRule, + protos.google.cloud.netapp.v1.IGetQuotaRuleRequest | null | undefined, + {} | null | undefined + >, + ): void; getQuotaRule( - request: protos.google.cloud.netapp.v1.IGetQuotaRuleRequest, - callback: Callback< - protos.google.cloud.netapp.v1.IQuotaRule, - protos.google.cloud.netapp.v1.IGetQuotaRuleRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IGetQuotaRuleRequest, + callback: Callback< + protos.google.cloud.netapp.v1.IQuotaRule, + protos.google.cloud.netapp.v1.IGetQuotaRuleRequest | null | undefined, + {} | null | undefined + >, + ): void; getQuotaRule( - request?: protos.google.cloud.netapp.v1.IGetQuotaRuleRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.netapp.v1.IQuotaRule, - protos.google.cloud.netapp.v1.IGetQuotaRuleRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.netapp.v1.IGetQuotaRuleRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.netapp.v1.IQuotaRule, - protos.google.cloud.netapp.v1.IGetQuotaRuleRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.netapp.v1.IQuotaRule, - protos.google.cloud.netapp.v1.IGetQuotaRuleRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.netapp.v1.IGetQuotaRuleRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.netapp.v1.IQuotaRule, + protos.google.cloud.netapp.v1.IGetQuotaRuleRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.netapp.v1.IQuotaRule, + protos.google.cloud.netapp.v1.IGetQuotaRuleRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getQuotaRule request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.netapp.v1.IQuotaRule, - protos.google.cloud.netapp.v1.IGetQuotaRuleRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.netapp.v1.IQuotaRule, + protos.google.cloud.netapp.v1.IGetQuotaRuleRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getQuotaRule response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getQuotaRule(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.netapp.v1.IQuotaRule, - protos.google.cloud.netapp.v1.IGetQuotaRuleRequest|undefined, - {}|undefined - ]) => { - this._log.info('getQuotaRule response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getQuotaRule(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.netapp.v1.IQuotaRule, + protos.google.cloud.netapp.v1.IGetQuotaRuleRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getQuotaRule response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Returns details of the specified host group. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the host group. - * Format: - * `projects/{project_number}/locations/{location_id}/hostGroups/{host_group_id}`. - * @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 {@link protos.google.cloud.netapp.v1.HostGroup|HostGroup}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/net_app.get_host_group.js - * region_tag:netapp_v1_generated_NetApp_GetHostGroup_async - */ + /** + * Returns details of the specified host group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the host group. + * Format: + * `projects/{project_number}/locations/{location_id}/hostGroups/{host_group_id}`. + * @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 {@link protos.google.cloud.netapp.v1.HostGroup|HostGroup}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/net_app.get_host_group.js + * region_tag:netapp_v1_generated_NetApp_GetHostGroup_async + */ getHostGroup( - request?: protos.google.cloud.netapp.v1.IGetHostGroupRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.netapp.v1.IHostGroup, - protos.google.cloud.netapp.v1.IGetHostGroupRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IGetHostGroupRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.netapp.v1.IHostGroup, + protos.google.cloud.netapp.v1.IGetHostGroupRequest | undefined, + {} | undefined, + ] + >; getHostGroup( - request: protos.google.cloud.netapp.v1.IGetHostGroupRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.netapp.v1.IHostGroup, - protos.google.cloud.netapp.v1.IGetHostGroupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IGetHostGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.netapp.v1.IHostGroup, + protos.google.cloud.netapp.v1.IGetHostGroupRequest | null | undefined, + {} | null | undefined + >, + ): void; getHostGroup( - request: protos.google.cloud.netapp.v1.IGetHostGroupRequest, - callback: Callback< - protos.google.cloud.netapp.v1.IHostGroup, - protos.google.cloud.netapp.v1.IGetHostGroupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IGetHostGroupRequest, + callback: Callback< + protos.google.cloud.netapp.v1.IHostGroup, + protos.google.cloud.netapp.v1.IGetHostGroupRequest | null | undefined, + {} | null | undefined + >, + ): void; getHostGroup( - request?: protos.google.cloud.netapp.v1.IGetHostGroupRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.netapp.v1.IHostGroup, - protos.google.cloud.netapp.v1.IGetHostGroupRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.netapp.v1.IGetHostGroupRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.netapp.v1.IHostGroup, - protos.google.cloud.netapp.v1.IGetHostGroupRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.netapp.v1.IHostGroup, - protos.google.cloud.netapp.v1.IGetHostGroupRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.netapp.v1.IGetHostGroupRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.netapp.v1.IHostGroup, + protos.google.cloud.netapp.v1.IGetHostGroupRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.netapp.v1.IHostGroup, + protos.google.cloud.netapp.v1.IGetHostGroupRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getHostGroup request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.netapp.v1.IHostGroup, - protos.google.cloud.netapp.v1.IGetHostGroupRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.netapp.v1.IHostGroup, + protos.google.cloud.netapp.v1.IGetHostGroupRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getHostGroup response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getHostGroup(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.netapp.v1.IHostGroup, - protos.google.cloud.netapp.v1.IGetHostGroupRequest|undefined, - {}|undefined - ]) => { - this._log.info('getHostGroup response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getHostGroup(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.netapp.v1.IHostGroup, + protos.google.cloud.netapp.v1.IGetHostGroupRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getHostGroup response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * `ExecuteOntapPost` dispatches the ONTAP `POST` request to the - * `StoragePool` cluster. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.Struct} request.body - * Required. The raw `JSON` body of the request. - * The body should be in the format of the ONTAP resource. - * For example: - * ``` - * { - * "body": { - * "field1": "value1", - * "field2": "value2", - * } - * } - * ``` - * @param {string} request.ontapPath - * Required. The resource path of the ONTAP resource. - * Format: - * `projects/{project_number}/locations/{location_id}/storagePools/{storage_pool_id}/ontap/{ontap_resource_path}`. - * For example: - * `projects/123456789/locations/us-central1/storagePools/my-storage-pool/ontap/api/storage/volumes`. - * @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 {@link protos.google.cloud.netapp.v1.ExecuteOntapPostResponse|ExecuteOntapPostResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/net_app.execute_ontap_post.js - * region_tag:netapp_v1_generated_NetApp_ExecuteOntapPost_async - */ + /** + * `ExecuteOntapPost` dispatches the ONTAP `POST` request to the + * `StoragePool` cluster. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.Struct} request.body + * Required. The raw `JSON` body of the request. + * The body should be in the format of the ONTAP resource. + * For example: + * ``` + * { + * "body": { + * "field1": "value1", + * "field2": "value2", + * } + * } + * ``` + * @param {string} request.ontapPath + * Required. The resource path of the ONTAP resource. + * Format: + * `projects/{project_number}/locations/{location_id}/storagePools/{storage_pool_id}/ontap/{ontap_resource_path}`. + * For example: + * `projects/123456789/locations/us-central1/storagePools/my-storage-pool/ontap/api/storage/volumes`. + * @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 {@link protos.google.cloud.netapp.v1.ExecuteOntapPostResponse|ExecuteOntapPostResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/net_app.execute_ontap_post.js + * region_tag:netapp_v1_generated_NetApp_ExecuteOntapPost_async + */ executeOntapPost( - request?: protos.google.cloud.netapp.v1.IExecuteOntapPostRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.netapp.v1.IExecuteOntapPostResponse, - protos.google.cloud.netapp.v1.IExecuteOntapPostRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IExecuteOntapPostRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.netapp.v1.IExecuteOntapPostResponse, + protos.google.cloud.netapp.v1.IExecuteOntapPostRequest | undefined, + {} | undefined, + ] + >; executeOntapPost( - request: protos.google.cloud.netapp.v1.IExecuteOntapPostRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.netapp.v1.IExecuteOntapPostResponse, - protos.google.cloud.netapp.v1.IExecuteOntapPostRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IExecuteOntapPostRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.netapp.v1.IExecuteOntapPostResponse, + protos.google.cloud.netapp.v1.IExecuteOntapPostRequest | null | undefined, + {} | null | undefined + >, + ): void; executeOntapPost( - request: protos.google.cloud.netapp.v1.IExecuteOntapPostRequest, - callback: Callback< - protos.google.cloud.netapp.v1.IExecuteOntapPostResponse, - protos.google.cloud.netapp.v1.IExecuteOntapPostRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IExecuteOntapPostRequest, + callback: Callback< + protos.google.cloud.netapp.v1.IExecuteOntapPostResponse, + protos.google.cloud.netapp.v1.IExecuteOntapPostRequest | null | undefined, + {} | null | undefined + >, + ): void; executeOntapPost( - request?: protos.google.cloud.netapp.v1.IExecuteOntapPostRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.netapp.v1.IExecuteOntapPostResponse, - protos.google.cloud.netapp.v1.IExecuteOntapPostRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.netapp.v1.IExecuteOntapPostRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.netapp.v1.IExecuteOntapPostResponse, - protos.google.cloud.netapp.v1.IExecuteOntapPostRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.netapp.v1.IExecuteOntapPostResponse, - protos.google.cloud.netapp.v1.IExecuteOntapPostRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.netapp.v1.IExecuteOntapPostRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.netapp.v1.IExecuteOntapPostResponse, + protos.google.cloud.netapp.v1.IExecuteOntapPostRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.netapp.v1.IExecuteOntapPostResponse, + protos.google.cloud.netapp.v1.IExecuteOntapPostRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'ontap_path': request.ontapPath ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + ontap_path: request.ontapPath ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('executeOntapPost request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.netapp.v1.IExecuteOntapPostResponse, - protos.google.cloud.netapp.v1.IExecuteOntapPostRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.netapp.v1.IExecuteOntapPostResponse, + | protos.google.cloud.netapp.v1.IExecuteOntapPostRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('executeOntapPost response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.executeOntapPost(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.netapp.v1.IExecuteOntapPostResponse, - protos.google.cloud.netapp.v1.IExecuteOntapPostRequest|undefined, - {}|undefined - ]) => { - this._log.info('executeOntapPost response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .executeOntapPost(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.netapp.v1.IExecuteOntapPostResponse, + protos.google.cloud.netapp.v1.IExecuteOntapPostRequest | undefined, + {} | undefined, + ]) => { + this._log.info('executeOntapPost response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * `ExecuteOntapGet` dispatches the ONTAP `GET` request to the - * `StoragePool` cluster. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.ontapPath - * Required. The resource path of the ONTAP resource. - * Format: - * `projects/{project_number}/locations/{location_id}/storagePools/{storage_pool_id}/ontap/{ontap_resource_path}`. - * For example: - * `projects/123456789/locations/us-central1/storagePools/my-storage-pool/ontap/api/storage/volumes`. - * @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 {@link protos.google.cloud.netapp.v1.ExecuteOntapGetResponse|ExecuteOntapGetResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/net_app.execute_ontap_get.js - * region_tag:netapp_v1_generated_NetApp_ExecuteOntapGet_async - */ + /** + * `ExecuteOntapGet` dispatches the ONTAP `GET` request to the + * `StoragePool` cluster. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.ontapPath + * Required. The resource path of the ONTAP resource. + * Format: + * `projects/{project_number}/locations/{location_id}/storagePools/{storage_pool_id}/ontap/{ontap_resource_path}`. + * For example: + * `projects/123456789/locations/us-central1/storagePools/my-storage-pool/ontap/api/storage/volumes`. + * @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 {@link protos.google.cloud.netapp.v1.ExecuteOntapGetResponse|ExecuteOntapGetResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/net_app.execute_ontap_get.js + * region_tag:netapp_v1_generated_NetApp_ExecuteOntapGet_async + */ executeOntapGet( - request?: protos.google.cloud.netapp.v1.IExecuteOntapGetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.netapp.v1.IExecuteOntapGetResponse, - protos.google.cloud.netapp.v1.IExecuteOntapGetRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IExecuteOntapGetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.netapp.v1.IExecuteOntapGetResponse, + protos.google.cloud.netapp.v1.IExecuteOntapGetRequest | undefined, + {} | undefined, + ] + >; executeOntapGet( - request: protos.google.cloud.netapp.v1.IExecuteOntapGetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.netapp.v1.IExecuteOntapGetResponse, - protos.google.cloud.netapp.v1.IExecuteOntapGetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IExecuteOntapGetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.netapp.v1.IExecuteOntapGetResponse, + protos.google.cloud.netapp.v1.IExecuteOntapGetRequest | null | undefined, + {} | null | undefined + >, + ): void; executeOntapGet( - request: protos.google.cloud.netapp.v1.IExecuteOntapGetRequest, - callback: Callback< - protos.google.cloud.netapp.v1.IExecuteOntapGetResponse, - protos.google.cloud.netapp.v1.IExecuteOntapGetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IExecuteOntapGetRequest, + callback: Callback< + protos.google.cloud.netapp.v1.IExecuteOntapGetResponse, + protos.google.cloud.netapp.v1.IExecuteOntapGetRequest | null | undefined, + {} | null | undefined + >, + ): void; executeOntapGet( - request?: protos.google.cloud.netapp.v1.IExecuteOntapGetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.netapp.v1.IExecuteOntapGetResponse, - protos.google.cloud.netapp.v1.IExecuteOntapGetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.netapp.v1.IExecuteOntapGetRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.netapp.v1.IExecuteOntapGetResponse, - protos.google.cloud.netapp.v1.IExecuteOntapGetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.netapp.v1.IExecuteOntapGetResponse, - protos.google.cloud.netapp.v1.IExecuteOntapGetRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.netapp.v1.IExecuteOntapGetRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.netapp.v1.IExecuteOntapGetResponse, + protos.google.cloud.netapp.v1.IExecuteOntapGetRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.netapp.v1.IExecuteOntapGetResponse, + protos.google.cloud.netapp.v1.IExecuteOntapGetRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'ontap_path': request.ontapPath ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + ontap_path: request.ontapPath ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('executeOntapGet request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.netapp.v1.IExecuteOntapGetResponse, - protos.google.cloud.netapp.v1.IExecuteOntapGetRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.netapp.v1.IExecuteOntapGetResponse, + | protos.google.cloud.netapp.v1.IExecuteOntapGetRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('executeOntapGet response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.executeOntapGet(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.netapp.v1.IExecuteOntapGetResponse, - protos.google.cloud.netapp.v1.IExecuteOntapGetRequest|undefined, - {}|undefined - ]) => { - this._log.info('executeOntapGet response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .executeOntapGet(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.netapp.v1.IExecuteOntapGetResponse, + protos.google.cloud.netapp.v1.IExecuteOntapGetRequest | undefined, + {} | undefined, + ]) => { + this._log.info('executeOntapGet response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * `ExecuteOntapDelete` dispatches the ONTAP `DELETE` request to the - * `StoragePool` cluster. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.ontapPath - * Required. The resource path of the ONTAP resource. - * Format: - * `projects/{project_number}/locations/{location_id}/storagePools/{storage_pool_id}/ontap/{ontap_resource_path}`. - * For example: - * `projects/123456789/locations/us-central1/storagePools/my-storage-pool/ontap/api/storage/volumes`. - * @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 {@link protos.google.cloud.netapp.v1.ExecuteOntapDeleteResponse|ExecuteOntapDeleteResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/net_app.execute_ontap_delete.js - * region_tag:netapp_v1_generated_NetApp_ExecuteOntapDelete_async - */ + /** + * `ExecuteOntapDelete` dispatches the ONTAP `DELETE` request to the + * `StoragePool` cluster. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.ontapPath + * Required. The resource path of the ONTAP resource. + * Format: + * `projects/{project_number}/locations/{location_id}/storagePools/{storage_pool_id}/ontap/{ontap_resource_path}`. + * For example: + * `projects/123456789/locations/us-central1/storagePools/my-storage-pool/ontap/api/storage/volumes`. + * @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 {@link protos.google.cloud.netapp.v1.ExecuteOntapDeleteResponse|ExecuteOntapDeleteResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/net_app.execute_ontap_delete.js + * region_tag:netapp_v1_generated_NetApp_ExecuteOntapDelete_async + */ executeOntapDelete( - request?: protos.google.cloud.netapp.v1.IExecuteOntapDeleteRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.netapp.v1.IExecuteOntapDeleteResponse, - protos.google.cloud.netapp.v1.IExecuteOntapDeleteRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IExecuteOntapDeleteRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.netapp.v1.IExecuteOntapDeleteResponse, + protos.google.cloud.netapp.v1.IExecuteOntapDeleteRequest | undefined, + {} | undefined, + ] + >; executeOntapDelete( - request: protos.google.cloud.netapp.v1.IExecuteOntapDeleteRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.netapp.v1.IExecuteOntapDeleteResponse, - protos.google.cloud.netapp.v1.IExecuteOntapDeleteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IExecuteOntapDeleteRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.netapp.v1.IExecuteOntapDeleteResponse, + | protos.google.cloud.netapp.v1.IExecuteOntapDeleteRequest + | null + | undefined, + {} | null | undefined + >, + ): void; executeOntapDelete( - request: protos.google.cloud.netapp.v1.IExecuteOntapDeleteRequest, - callback: Callback< - protos.google.cloud.netapp.v1.IExecuteOntapDeleteResponse, - protos.google.cloud.netapp.v1.IExecuteOntapDeleteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IExecuteOntapDeleteRequest, + callback: Callback< + protos.google.cloud.netapp.v1.IExecuteOntapDeleteResponse, + | protos.google.cloud.netapp.v1.IExecuteOntapDeleteRequest + | null + | undefined, + {} | null | undefined + >, + ): void; executeOntapDelete( - request?: protos.google.cloud.netapp.v1.IExecuteOntapDeleteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.netapp.v1.IExecuteOntapDeleteResponse, - protos.google.cloud.netapp.v1.IExecuteOntapDeleteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.netapp.v1.IExecuteOntapDeleteRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.netapp.v1.IExecuteOntapDeleteResponse, - protos.google.cloud.netapp.v1.IExecuteOntapDeleteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.netapp.v1.IExecuteOntapDeleteResponse, - protos.google.cloud.netapp.v1.IExecuteOntapDeleteRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.netapp.v1.IExecuteOntapDeleteRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.netapp.v1.IExecuteOntapDeleteResponse, + | protos.google.cloud.netapp.v1.IExecuteOntapDeleteRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.netapp.v1.IExecuteOntapDeleteResponse, + protos.google.cloud.netapp.v1.IExecuteOntapDeleteRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'ontap_path': request.ontapPath ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + ontap_path: request.ontapPath ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('executeOntapDelete request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.netapp.v1.IExecuteOntapDeleteResponse, - protos.google.cloud.netapp.v1.IExecuteOntapDeleteRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.netapp.v1.IExecuteOntapDeleteResponse, + | protos.google.cloud.netapp.v1.IExecuteOntapDeleteRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('executeOntapDelete response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.executeOntapDelete(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.netapp.v1.IExecuteOntapDeleteResponse, - protos.google.cloud.netapp.v1.IExecuteOntapDeleteRequest|undefined, - {}|undefined - ]) => { - this._log.info('executeOntapDelete response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .executeOntapDelete(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.netapp.v1.IExecuteOntapDeleteResponse, + protos.google.cloud.netapp.v1.IExecuteOntapDeleteRequest | undefined, + {} | undefined, + ]) => { + this._log.info('executeOntapDelete response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * `ExecuteOntapPatch` dispatches the ONTAP `PATCH` request to the - * `StoragePool` cluster. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.Struct} request.body - * Required. The raw `JSON` body of the request. - * The body should be in the format of the ONTAP resource. - * For example: - * ``` - * { - * "body": { - * "field1": "value1", - * "field2": "value2", - * } - * } - * ``` - * @param {string} request.ontapPath - * Required. The resource path of the ONTAP resource. - * Format: - * `projects/{project_number}/locations/{location_id}/storagePools/{storage_pool_id}/ontap/{ontap_resource_path}`. - * For example: - * `projects/123456789/locations/us-central1/storagePools/my-storage-pool/ontap/api/storage/volumes`. - * @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 {@link protos.google.cloud.netapp.v1.ExecuteOntapPatchResponse|ExecuteOntapPatchResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/net_app.execute_ontap_patch.js - * region_tag:netapp_v1_generated_NetApp_ExecuteOntapPatch_async - */ + /** + * `ExecuteOntapPatch` dispatches the ONTAP `PATCH` request to the + * `StoragePool` cluster. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.Struct} request.body + * Required. The raw `JSON` body of the request. + * The body should be in the format of the ONTAP resource. + * For example: + * ``` + * { + * "body": { + * "field1": "value1", + * "field2": "value2", + * } + * } + * ``` + * @param {string} request.ontapPath + * Required. The resource path of the ONTAP resource. + * Format: + * `projects/{project_number}/locations/{location_id}/storagePools/{storage_pool_id}/ontap/{ontap_resource_path}`. + * For example: + * `projects/123456789/locations/us-central1/storagePools/my-storage-pool/ontap/api/storage/volumes`. + * @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 {@link protos.google.cloud.netapp.v1.ExecuteOntapPatchResponse|ExecuteOntapPatchResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/net_app.execute_ontap_patch.js + * region_tag:netapp_v1_generated_NetApp_ExecuteOntapPatch_async + */ executeOntapPatch( - request?: protos.google.cloud.netapp.v1.IExecuteOntapPatchRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.netapp.v1.IExecuteOntapPatchResponse, - protos.google.cloud.netapp.v1.IExecuteOntapPatchRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IExecuteOntapPatchRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.netapp.v1.IExecuteOntapPatchResponse, + protos.google.cloud.netapp.v1.IExecuteOntapPatchRequest | undefined, + {} | undefined, + ] + >; executeOntapPatch( - request: protos.google.cloud.netapp.v1.IExecuteOntapPatchRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.netapp.v1.IExecuteOntapPatchResponse, - protos.google.cloud.netapp.v1.IExecuteOntapPatchRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IExecuteOntapPatchRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.netapp.v1.IExecuteOntapPatchResponse, + | protos.google.cloud.netapp.v1.IExecuteOntapPatchRequest + | null + | undefined, + {} | null | undefined + >, + ): void; executeOntapPatch( - request: protos.google.cloud.netapp.v1.IExecuteOntapPatchRequest, - callback: Callback< - protos.google.cloud.netapp.v1.IExecuteOntapPatchResponse, - protos.google.cloud.netapp.v1.IExecuteOntapPatchRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IExecuteOntapPatchRequest, + callback: Callback< + protos.google.cloud.netapp.v1.IExecuteOntapPatchResponse, + | protos.google.cloud.netapp.v1.IExecuteOntapPatchRequest + | null + | undefined, + {} | null | undefined + >, + ): void; executeOntapPatch( - request?: protos.google.cloud.netapp.v1.IExecuteOntapPatchRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.netapp.v1.IExecuteOntapPatchResponse, - protos.google.cloud.netapp.v1.IExecuteOntapPatchRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.netapp.v1.IExecuteOntapPatchRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.netapp.v1.IExecuteOntapPatchResponse, - protos.google.cloud.netapp.v1.IExecuteOntapPatchRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.netapp.v1.IExecuteOntapPatchResponse, - protos.google.cloud.netapp.v1.IExecuteOntapPatchRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.netapp.v1.IExecuteOntapPatchRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.netapp.v1.IExecuteOntapPatchResponse, + | protos.google.cloud.netapp.v1.IExecuteOntapPatchRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.netapp.v1.IExecuteOntapPatchResponse, + protos.google.cloud.netapp.v1.IExecuteOntapPatchRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'ontap_path': request.ontapPath ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + ontap_path: request.ontapPath ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('executeOntapPatch request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.netapp.v1.IExecuteOntapPatchResponse, - protos.google.cloud.netapp.v1.IExecuteOntapPatchRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.netapp.v1.IExecuteOntapPatchResponse, + | protos.google.cloud.netapp.v1.IExecuteOntapPatchRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('executeOntapPatch response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.executeOntapPatch(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.netapp.v1.IExecuteOntapPatchResponse, - protos.google.cloud.netapp.v1.IExecuteOntapPatchRequest|undefined, - {}|undefined - ]) => { - this._log.info('executeOntapPatch response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .executeOntapPatch(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.netapp.v1.IExecuteOntapPatchResponse, + protos.google.cloud.netapp.v1.IExecuteOntapPatchRequest | undefined, + {} | undefined, + ]) => { + this._log.info('executeOntapPatch response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a new storage pool. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Value for parent. - * @param {string} request.storagePoolId - * Required. Id of the requesting storage pool. Must be unique within the - * parent resource. Must contain only letters, numbers and hyphen, with the - * first character a letter, the last a letter or a number, and a 63 character - * maximum. - * @param {google.cloud.netapp.v1.StoragePool} request.storagePool - * Required. The required parameters to create a new 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.create_storage_pool.js - * region_tag:netapp_v1_generated_NetApp_CreateStoragePool_async - */ + /** + * Creates a new storage pool. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Value for parent. + * @param {string} request.storagePoolId + * Required. Id of the requesting storage pool. Must be unique within the + * parent resource. Must contain only letters, numbers and hyphen, with the + * first character a letter, the last a letter or a number, and a 63 character + * maximum. + * @param {google.cloud.netapp.v1.StoragePool} request.storagePool + * Required. The required parameters to create a new 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.create_storage_pool.js + * region_tag:netapp_v1_generated_NetApp_CreateStoragePool_async + */ createStoragePool( - request?: protos.google.cloud.netapp.v1.ICreateStoragePoolRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.ICreateStoragePoolRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createStoragePool( - request: protos.google.cloud.netapp.v1.ICreateStoragePoolRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.ICreateStoragePoolRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createStoragePool( - request: protos.google.cloud.netapp.v1.ICreateStoragePoolRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.ICreateStoragePoolRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createStoragePool( - request?: protos.google.cloud.netapp.v1.ICreateStoragePoolRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.ICreateStoragePoolRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IStoragePool, + 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 { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createStoragePool response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createStoragePool request %j', request); - return this.innerApiCalls.createStoragePool(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createStoragePool response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createStoragePool(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createStoragePool response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createStoragePool()`. - * @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.create_storage_pool.js - * region_tag:netapp_v1_generated_NetApp_CreateStoragePool_async - */ - async checkCreateStoragePoolProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createStoragePool()`. + * @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.create_storage_pool.js + * region_tag:netapp_v1_generated_NetApp_CreateStoragePool_async + */ + async checkCreateStoragePoolProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.StoragePool, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('createStoragePool long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createStoragePool, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createStoragePool, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.StoragePool, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Updates the storage pool properties with the full spec - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Field mask is used to specify the fields to be overwritten in the - * StoragePool resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - * @param {google.cloud.netapp.v1.StoragePool} request.storagePool - * Required. The pool being updated - * @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.update_storage_pool.js - * region_tag:netapp_v1_generated_NetApp_UpdateStoragePool_async - */ - updateStoragePool( - request?: protos.google.cloud.netapp.v1.IUpdateStoragePoolRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateStoragePool( - request: protos.google.cloud.netapp.v1.IUpdateStoragePoolRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateStoragePool( - request: protos.google.cloud.netapp.v1.IUpdateStoragePoolRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateStoragePool( - request?: protos.google.cloud.netapp.v1.IUpdateStoragePoolRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; + /** + * Updates the storage pool properties with the full spec + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Field mask is used to specify the fields to be overwritten in the + * StoragePool resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @param {google.cloud.netapp.v1.StoragePool} request.storagePool + * Required. The pool being updated + * @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.update_storage_pool.js + * region_tag:netapp_v1_generated_NetApp_UpdateStoragePool_async + */ + updateStoragePool( + request?: protos.google.cloud.netapp.v1.IUpdateStoragePoolRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; + updateStoragePool( + request: protos.google.cloud.netapp.v1.IUpdateStoragePoolRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; + updateStoragePool( + request: protos.google.cloud.netapp.v1.IUpdateStoragePoolRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; + updateStoragePool( + request?: protos.google.cloud.netapp.v1.IUpdateStoragePoolRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IStoragePool, + 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 { + } 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({ - 'storage_pool.name': request.storagePool!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'storage_pool.name': request.storagePool!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateStoragePool response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateStoragePool request %j', request); - return this.innerApiCalls.updateStoragePool(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateStoragePool response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateStoragePool(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateStoragePool response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateStoragePool()`. - * @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.update_storage_pool.js - * region_tag:netapp_v1_generated_NetApp_UpdateStoragePool_async - */ - async checkUpdateStoragePoolProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateStoragePool()`. + * @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.update_storage_pool.js + * region_tag:netapp_v1_generated_NetApp_UpdateStoragePool_async + */ + async checkUpdateStoragePoolProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.StoragePool, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('updateStoragePool long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateStoragePool, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateStoragePool, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.StoragePool, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Warning! This operation will permanently delete the storage pool. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of 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.delete_storage_pool.js - * region_tag:netapp_v1_generated_NetApp_DeleteStoragePool_async - */ + /** + * Warning! This operation will permanently delete the storage pool. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of 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.delete_storage_pool.js + * region_tag:netapp_v1_generated_NetApp_DeleteStoragePool_async + */ deleteStoragePool( - request?: protos.google.cloud.netapp.v1.IDeleteStoragePoolRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IDeleteStoragePoolRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteStoragePool( - request: protos.google.cloud.netapp.v1.IDeleteStoragePoolRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IDeleteStoragePoolRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteStoragePool( - request: protos.google.cloud.netapp.v1.IDeleteStoragePoolRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IDeleteStoragePoolRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteStoragePool( - request?: protos.google.cloud.netapp.v1.IDeleteStoragePoolRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.IDeleteStoragePoolRequest, + 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 { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteStoragePool response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteStoragePool request %j', request); - return this.innerApiCalls.deleteStoragePool(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteStoragePool response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteStoragePool(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteStoragePool response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteStoragePool()`. - * @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.delete_storage_pool.js - * region_tag:netapp_v1_generated_NetApp_DeleteStoragePool_async - */ - async checkDeleteStoragePoolProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteStoragePool()`. + * @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.delete_storage_pool.js + * region_tag:netapp_v1_generated_NetApp_DeleteStoragePool_async + */ + async checkDeleteStoragePoolProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('deleteStoragePool long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteStoragePool, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteStoragePool, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + 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 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.longrunning.IOperation|undefined, {}|undefined - ]>; + 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.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + 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.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + 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.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + 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 { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('validateDirectoryService response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('validateDirectoryService request %j', request); - return this.innerApiCalls.validateDirectoryService(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('validateDirectoryService response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .validateDirectoryService(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('validateDirectoryService response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * 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>{ + /** + * 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 + > + > { this._log.info('validateDirectoryService long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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; + 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. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of 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.switch_active_replica_zone.js - * region_tag:netapp_v1_generated_NetApp_SwitchActiveReplicaZone_async - */ + /** + * This operation will switch the active/replica zone for a regional + * storagePool. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of 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.switch_active_replica_zone.js + * region_tag:netapp_v1_generated_NetApp_SwitchActiveReplicaZone_async + */ switchActiveReplicaZone( - request?: protos.google.cloud.netapp.v1.ISwitchActiveReplicaZoneRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.ISwitchActiveReplicaZoneRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; switchActiveReplicaZone( - request: protos.google.cloud.netapp.v1.ISwitchActiveReplicaZoneRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.ISwitchActiveReplicaZoneRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; switchActiveReplicaZone( - request: protos.google.cloud.netapp.v1.ISwitchActiveReplicaZoneRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.ISwitchActiveReplicaZoneRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; switchActiveReplicaZone( - request?: protos.google.cloud.netapp.v1.ISwitchActiveReplicaZoneRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.ISwitchActiveReplicaZoneRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IStoragePool, + 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 { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('switchActiveReplicaZone response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('switchActiveReplicaZone request %j', request); - return this.innerApiCalls.switchActiveReplicaZone(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('switchActiveReplicaZone response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .switchActiveReplicaZone(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('switchActiveReplicaZone response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `switchActiveReplicaZone()`. - * @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.switch_active_replica_zone.js - * region_tag:netapp_v1_generated_NetApp_SwitchActiveReplicaZone_async - */ - async checkSwitchActiveReplicaZoneProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `switchActiveReplicaZone()`. + * @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.switch_active_replica_zone.js + * region_tag:netapp_v1_generated_NetApp_SwitchActiveReplicaZone_async + */ + async checkSwitchActiveReplicaZoneProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.StoragePool, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('switchActiveReplicaZone long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.switchActiveReplicaZone, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.switchActiveReplicaZone, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.StoragePool, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Creates a new Volume in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Value for parent. - * @param {string} request.volumeId - * Required. Id of the requesting volume. Must be unique within the parent - * resource. Must contain only letters, numbers and hyphen, with the first - * character a letter, the last a letter or a number, - * and a 63 character maximum. - * @param {google.cloud.netapp.v1.Volume} request.volume - * Required. The volume being created. - * @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.create_volume.js - * region_tag:netapp_v1_generated_NetApp_CreateVolume_async - */ + /** + * Creates a new Volume in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Value for parent. + * @param {string} request.volumeId + * Required. Id of the requesting volume. Must be unique within the parent + * resource. Must contain only letters, numbers and hyphen, with the first + * character a letter, the last a letter or a number, + * and a 63 character maximum. + * @param {google.cloud.netapp.v1.Volume} request.volume + * Required. The volume being created. + * @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.create_volume.js + * region_tag:netapp_v1_generated_NetApp_CreateVolume_async + */ createVolume( - request?: protos.google.cloud.netapp.v1.ICreateVolumeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.ICreateVolumeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createVolume( - request: protos.google.cloud.netapp.v1.ICreateVolumeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.ICreateVolumeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createVolume( - request: protos.google.cloud.netapp.v1.ICreateVolumeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.ICreateVolumeRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createVolume( - request?: protos.google.cloud.netapp.v1.ICreateVolumeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.ICreateVolumeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IVolume, + 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 { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createVolume response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createVolume request %j', request); - return this.innerApiCalls.createVolume(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createVolume response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createVolume(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createVolume response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createVolume()`. - * @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.create_volume.js - * region_tag:netapp_v1_generated_NetApp_CreateVolume_async - */ - async checkCreateVolumeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createVolume()`. + * @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.create_volume.js + * region_tag:netapp_v1_generated_NetApp_CreateVolume_async + */ + async checkCreateVolumeProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.Volume, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('createVolume long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createVolume, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createVolume, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.Volume, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Updates the parameters of a single Volume. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Field mask is used to specify the fields to be overwritten in the - * Volume resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - * @param {google.cloud.netapp.v1.Volume} request.volume - * Required. The volume being updated - * @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.update_volume.js - * region_tag:netapp_v1_generated_NetApp_UpdateVolume_async - */ + /** + * Updates the parameters of a single Volume. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Field mask is used to specify the fields to be overwritten in the + * Volume resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @param {google.cloud.netapp.v1.Volume} request.volume + * Required. The volume being updated + * @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.update_volume.js + * region_tag:netapp_v1_generated_NetApp_UpdateVolume_async + */ updateVolume( - request?: protos.google.cloud.netapp.v1.IUpdateVolumeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IUpdateVolumeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateVolume( - request: protos.google.cloud.netapp.v1.IUpdateVolumeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IUpdateVolumeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateVolume( - request: protos.google.cloud.netapp.v1.IUpdateVolumeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IUpdateVolumeRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateVolume( - request?: protos.google.cloud.netapp.v1.IUpdateVolumeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.IUpdateVolumeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IVolume, + 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 { + } 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({ - 'volume.name': request.volume!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'volume.name': request.volume!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateVolume response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateVolume request %j', request); - return this.innerApiCalls.updateVolume(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateVolume response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateVolume(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateVolume response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateVolume()`. - * @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.update_volume.js - * region_tag:netapp_v1_generated_NetApp_UpdateVolume_async - */ - async checkUpdateVolumeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateVolume()`. + * @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.update_volume.js + * region_tag:netapp_v1_generated_NetApp_UpdateVolume_async + */ + async checkUpdateVolumeProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.Volume, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('updateVolume long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateVolume, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateVolume, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.Volume, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Deletes a single Volume. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the volume - * @param {boolean} request.force - * If this field is set as true, CCFE will not block the volume resource - * deletion even if it has any snapshots resource. (Otherwise, the request - * will only work if the volume has no snapshots.) - * @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.delete_volume.js - * region_tag:netapp_v1_generated_NetApp_DeleteVolume_async - */ + /** + * Deletes a single Volume. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the volume + * @param {boolean} request.force + * If this field is set as true, CCFE will not block the volume resource + * deletion even if it has any snapshots resource. (Otherwise, the request + * will only work if the volume has no snapshots.) + * @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.delete_volume.js + * region_tag:netapp_v1_generated_NetApp_DeleteVolume_async + */ deleteVolume( - request?: protos.google.cloud.netapp.v1.IDeleteVolumeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IDeleteVolumeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteVolume( - request: protos.google.cloud.netapp.v1.IDeleteVolumeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IDeleteVolumeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteVolume( - request: protos.google.cloud.netapp.v1.IDeleteVolumeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IDeleteVolumeRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteVolume( - request?: protos.google.cloud.netapp.v1.IDeleteVolumeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.IDeleteVolumeRequest, + 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 { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteVolume response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteVolume request %j', request); - return this.innerApiCalls.deleteVolume(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteVolume response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteVolume(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteVolume response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteVolume()`. - * @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.delete_volume.js - * region_tag:netapp_v1_generated_NetApp_DeleteVolume_async - */ - async checkDeleteVolumeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteVolume()`. + * @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.delete_volume.js + * region_tag:netapp_v1_generated_NetApp_DeleteVolume_async + */ + async checkDeleteVolumeProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('deleteVolume long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteVolume, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteVolume, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Revert an existing volume to a specified snapshot. - * Warning! This operation will permanently revert all changes made after the - * snapshot was created. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the volume, in the format of - * projects/{project_id}/locations/{location}/volumes/{volume_id}. - * @param {string} request.snapshotId - * Required. The snapshot resource ID, in the format 'my-snapshot', where the - * specified ID is the {snapshot_id} of the fully qualified name like - * projects/{project_id}/locations/{location_id}/volumes/{volume_id}/snapshots/{snapshot_id} - * @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.revert_volume.js - * region_tag:netapp_v1_generated_NetApp_RevertVolume_async - */ + /** + * Revert an existing volume to a specified snapshot. + * Warning! This operation will permanently revert all changes made after the + * snapshot was created. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the volume, in the format of + * projects/{project_id}/locations/{location}/volumes/{volume_id}. + * @param {string} request.snapshotId + * Required. The snapshot resource ID, in the format 'my-snapshot', where the + * specified ID is the {snapshot_id} of the fully qualified name like + * projects/{project_id}/locations/{location_id}/volumes/{volume_id}/snapshots/{snapshot_id} + * @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.revert_volume.js + * region_tag:netapp_v1_generated_NetApp_RevertVolume_async + */ revertVolume( - request?: protos.google.cloud.netapp.v1.IRevertVolumeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IRevertVolumeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; revertVolume( - request: protos.google.cloud.netapp.v1.IRevertVolumeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IRevertVolumeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; revertVolume( - request: protos.google.cloud.netapp.v1.IRevertVolumeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IRevertVolumeRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; revertVolume( - request?: protos.google.cloud.netapp.v1.IRevertVolumeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.IRevertVolumeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IVolume, + 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 { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('revertVolume response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('revertVolume request %j', request); - return this.innerApiCalls.revertVolume(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('revertVolume response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .revertVolume(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('revertVolume response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `revertVolume()`. - * @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.revert_volume.js - * region_tag:netapp_v1_generated_NetApp_RevertVolume_async - */ - async checkRevertVolumeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `revertVolume()`. + * @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.revert_volume.js + * region_tag:netapp_v1_generated_NetApp_RevertVolume_async + */ + async checkRevertVolumeProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.Volume, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('revertVolume long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.revertVolume, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.revertVolume, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.Volume, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Establish volume peering. This is used to establish cluster and svm - * peerings between the GCNV and OnPrem clusters. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The volume resource name, in the format - * `projects/{project_id}/locations/{location}/volumes/{volume_id}` - * @param {string} request.peerClusterName - * Required. Name of the user's local source cluster to be peered with the - * destination cluster. - * @param {string} request.peerSvmName - * Required. Name of the user's local source vserver svm to be peered with the - * destination vserver svm. - * @param {string[]} [request.peerIpAddresses] - * Optional. List of IPv4 ip addresses to be used for peering. - * @param {string} request.peerVolumeName - * Required. Name of the user's local source volume to be peered with the - * destination volume. - * @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.establish_volume_peering.js - * region_tag:netapp_v1_generated_NetApp_EstablishVolumePeering_async - */ + /** + * Establish volume peering. This is used to establish cluster and svm + * peerings between the GCNV and OnPrem clusters. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The volume resource name, in the format + * `projects/{project_id}/locations/{location}/volumes/{volume_id}` + * @param {string} request.peerClusterName + * Required. Name of the user's local source cluster to be peered with the + * destination cluster. + * @param {string} request.peerSvmName + * Required. Name of the user's local source vserver svm to be peered with the + * destination vserver svm. + * @param {string[]} [request.peerIpAddresses] + * Optional. List of IPv4 ip addresses to be used for peering. + * @param {string} request.peerVolumeName + * Required. Name of the user's local source volume to be peered with the + * destination volume. + * @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.establish_volume_peering.js + * region_tag:netapp_v1_generated_NetApp_EstablishVolumePeering_async + */ establishVolumePeering( - request?: protos.google.cloud.netapp.v1.IEstablishVolumePeeringRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IEstablishVolumePeeringRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; establishVolumePeering( - request: protos.google.cloud.netapp.v1.IEstablishVolumePeeringRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IEstablishVolumePeeringRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; establishVolumePeering( - request: protos.google.cloud.netapp.v1.IEstablishVolumePeeringRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IEstablishVolumePeeringRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; establishVolumePeering( - request?: protos.google.cloud.netapp.v1.IEstablishVolumePeeringRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.IEstablishVolumePeeringRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IVolume, + 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 { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('establishVolumePeering response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('establishVolumePeering request %j', request); - return this.innerApiCalls.establishVolumePeering(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('establishVolumePeering response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .establishVolumePeering(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('establishVolumePeering response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `establishVolumePeering()`. - * @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.establish_volume_peering.js - * region_tag:netapp_v1_generated_NetApp_EstablishVolumePeering_async - */ - async checkEstablishVolumePeeringProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `establishVolumePeering()`. + * @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.establish_volume_peering.js + * region_tag:netapp_v1_generated_NetApp_EstablishVolumePeering_async + */ + async checkEstablishVolumePeeringProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.Volume, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('establishVolumePeering long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.establishVolumePeering, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.establishVolumePeering, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.Volume, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Create a new snapshot for a volume. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The NetApp volume to create the snapshots of, in the format - * `projects/{project_id}/locations/{location}/volumes/{volume_id}` - * @param {google.cloud.netapp.v1.Snapshot} request.snapshot - * Required. A snapshot resource - * @param {string} request.snapshotId - * Required. ID of the snapshot to create. Must be unique within the parent - * resource. Must contain only letters, numbers and hyphen, with the first - * character a letter, the last a letter or a - * number, and a 63 character maximum. - * @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.create_snapshot.js - * region_tag:netapp_v1_generated_NetApp_CreateSnapshot_async - */ + /** + * Create a new snapshot for a volume. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The NetApp volume to create the snapshots of, in the format + * `projects/{project_id}/locations/{location}/volumes/{volume_id}` + * @param {google.cloud.netapp.v1.Snapshot} request.snapshot + * Required. A snapshot resource + * @param {string} request.snapshotId + * Required. ID of the snapshot to create. Must be unique within the parent + * resource. Must contain only letters, numbers and hyphen, with the first + * character a letter, the last a letter or a + * number, and a 63 character maximum. + * @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.create_snapshot.js + * region_tag:netapp_v1_generated_NetApp_CreateSnapshot_async + */ createSnapshot( - request?: protos.google.cloud.netapp.v1.ICreateSnapshotRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.ICreateSnapshotRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.ISnapshot, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createSnapshot( - request: protos.google.cloud.netapp.v1.ICreateSnapshotRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.ICreateSnapshotRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.ISnapshot, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createSnapshot( - request: protos.google.cloud.netapp.v1.ICreateSnapshotRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.ICreateSnapshotRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.ISnapshot, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createSnapshot( - request?: protos.google.cloud.netapp.v1.ICreateSnapshotRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.ICreateSnapshotRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.ISnapshot, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.ISnapshot, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.ISnapshot, + 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 { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.ISnapshot, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createSnapshot response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createSnapshot request %j', request); - return this.innerApiCalls.createSnapshot(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createSnapshot response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createSnapshot(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.ISnapshot, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createSnapshot response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createSnapshot()`. - * @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.create_snapshot.js - * region_tag:netapp_v1_generated_NetApp_CreateSnapshot_async - */ - async checkCreateSnapshotProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createSnapshot()`. + * @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.create_snapshot.js + * region_tag:netapp_v1_generated_NetApp_CreateSnapshot_async + */ + async checkCreateSnapshotProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.Snapshot, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('createSnapshot long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createSnapshot, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createSnapshot, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.Snapshot, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Deletes a snapshot. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The snapshot resource name, in the format - * `projects/* /locations/* /volumes/* /snapshots/{snapshot_id}` - * @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.delete_snapshot.js - * region_tag:netapp_v1_generated_NetApp_DeleteSnapshot_async - */ + /** + * Deletes a snapshot. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The snapshot resource name, in the format + * `projects/* /locations/* /volumes/* /snapshots/{snapshot_id}` + * @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.delete_snapshot.js + * region_tag:netapp_v1_generated_NetApp_DeleteSnapshot_async + */ deleteSnapshot( - request?: protos.google.cloud.netapp.v1.IDeleteSnapshotRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IDeleteSnapshotRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteSnapshot( - request: protos.google.cloud.netapp.v1.IDeleteSnapshotRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IDeleteSnapshotRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteSnapshot( - request: protos.google.cloud.netapp.v1.IDeleteSnapshotRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IDeleteSnapshotRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteSnapshot( - request?: protos.google.cloud.netapp.v1.IDeleteSnapshotRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.IDeleteSnapshotRequest, + 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 { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteSnapshot response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteSnapshot request %j', request); - return this.innerApiCalls.deleteSnapshot(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteSnapshot response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteSnapshot(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteSnapshot response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteSnapshot()`. - * @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.delete_snapshot.js - * region_tag:netapp_v1_generated_NetApp_DeleteSnapshot_async - */ - async checkDeleteSnapshotProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteSnapshot()`. + * @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.delete_snapshot.js + * region_tag:netapp_v1_generated_NetApp_DeleteSnapshot_async + */ + async checkDeleteSnapshotProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('deleteSnapshot long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteSnapshot, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteSnapshot, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Updates the settings of a specific snapshot. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Mask of fields to update. At least one path must be supplied in - * this field. - * @param {google.cloud.netapp.v1.Snapshot} request.snapshot - * Required. A snapshot resource - * @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.update_snapshot.js - * region_tag:netapp_v1_generated_NetApp_UpdateSnapshot_async - */ + /** + * Updates the settings of a specific snapshot. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Mask of fields to update. At least one path must be supplied in + * this field. + * @param {google.cloud.netapp.v1.Snapshot} request.snapshot + * Required. A snapshot resource + * @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.update_snapshot.js + * region_tag:netapp_v1_generated_NetApp_UpdateSnapshot_async + */ updateSnapshot( - request?: protos.google.cloud.netapp.v1.IUpdateSnapshotRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IUpdateSnapshotRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.ISnapshot, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateSnapshot( - request: protos.google.cloud.netapp.v1.IUpdateSnapshotRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IUpdateSnapshotRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.ISnapshot, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateSnapshot( - request: protos.google.cloud.netapp.v1.IUpdateSnapshotRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IUpdateSnapshotRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.ISnapshot, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateSnapshot( - request?: protos.google.cloud.netapp.v1.IUpdateSnapshotRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.IUpdateSnapshotRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.ISnapshot, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.ISnapshot, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.ISnapshot, + 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 { + } 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({ - 'snapshot.name': request.snapshot!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'snapshot.name': request.snapshot!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.ISnapshot, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateSnapshot response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateSnapshot request %j', request); - return this.innerApiCalls.updateSnapshot(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateSnapshot response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateSnapshot(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.ISnapshot, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateSnapshot response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateSnapshot()`. - * @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.update_snapshot.js - * region_tag:netapp_v1_generated_NetApp_UpdateSnapshot_async - */ - async checkUpdateSnapshotProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateSnapshot()`. + * @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.update_snapshot.js + * region_tag:netapp_v1_generated_NetApp_UpdateSnapshot_async + */ + async checkUpdateSnapshotProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.Snapshot, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('updateSnapshot long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateSnapshot, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateSnapshot, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.Snapshot, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * CreateActiveDirectory - * Creates the active directory specified in the request. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Value for parent. - * @param {google.cloud.netapp.v1.ActiveDirectory} request.activeDirectory - * Required. Fields of the to be created active directory. - * @param {string} request.activeDirectoryId - * Required. ID of the active directory to create. Must be unique within the - * parent resource. Must contain only letters, numbers and hyphen, with the - * first character a letter , the last a letter or a number, and a 63 - * character maximum. - * @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.create_active_directory.js - * region_tag:netapp_v1_generated_NetApp_CreateActiveDirectory_async - */ + /** + * CreateActiveDirectory + * Creates the active directory specified in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Value for parent. + * @param {google.cloud.netapp.v1.ActiveDirectory} request.activeDirectory + * Required. Fields of the to be created active directory. + * @param {string} request.activeDirectoryId + * Required. ID of the active directory to create. Must be unique within the + * parent resource. Must contain only letters, numbers and hyphen, with the + * first character a letter , the last a letter or a number, and a 63 + * character maximum. + * @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.create_active_directory.js + * region_tag:netapp_v1_generated_NetApp_CreateActiveDirectory_async + */ createActiveDirectory( - request?: protos.google.cloud.netapp.v1.ICreateActiveDirectoryRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.ICreateActiveDirectoryRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IActiveDirectory, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createActiveDirectory( - request: protos.google.cloud.netapp.v1.ICreateActiveDirectoryRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.ICreateActiveDirectoryRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IActiveDirectory, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createActiveDirectory( - request: protos.google.cloud.netapp.v1.ICreateActiveDirectoryRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.ICreateActiveDirectoryRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IActiveDirectory, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createActiveDirectory( - request?: protos.google.cloud.netapp.v1.ICreateActiveDirectoryRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.ICreateActiveDirectoryRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IActiveDirectory, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.IActiveDirectory, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IActiveDirectory, + 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 { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IActiveDirectory, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createActiveDirectory response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createActiveDirectory request %j', request); - return this.innerApiCalls.createActiveDirectory(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createActiveDirectory response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createActiveDirectory(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.IActiveDirectory, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createActiveDirectory response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createActiveDirectory()`. - * @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.create_active_directory.js - * region_tag:netapp_v1_generated_NetApp_CreateActiveDirectory_async - */ - async checkCreateActiveDirectoryProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createActiveDirectory()`. + * @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.create_active_directory.js + * region_tag:netapp_v1_generated_NetApp_CreateActiveDirectory_async + */ + async checkCreateActiveDirectoryProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.ActiveDirectory, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('createActiveDirectory long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createActiveDirectory, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createActiveDirectory, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.ActiveDirectory, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Update the parameters of an active directories. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Field mask is used to specify the fields to be overwritten in the - * Active Directory resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - * @param {google.cloud.netapp.v1.ActiveDirectory} request.activeDirectory - * Required. The volume being updated - * @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.update_active_directory.js - * region_tag:netapp_v1_generated_NetApp_UpdateActiveDirectory_async - */ + /** + * Update the parameters of an active directories. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Field mask is used to specify the fields to be overwritten in the + * Active Directory resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @param {google.cloud.netapp.v1.ActiveDirectory} request.activeDirectory + * Required. The volume being updated + * @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.update_active_directory.js + * region_tag:netapp_v1_generated_NetApp_UpdateActiveDirectory_async + */ updateActiveDirectory( - request?: protos.google.cloud.netapp.v1.IUpdateActiveDirectoryRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IUpdateActiveDirectoryRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IActiveDirectory, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateActiveDirectory( - request: protos.google.cloud.netapp.v1.IUpdateActiveDirectoryRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IUpdateActiveDirectoryRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IActiveDirectory, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateActiveDirectory( - request: protos.google.cloud.netapp.v1.IUpdateActiveDirectoryRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IUpdateActiveDirectoryRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IActiveDirectory, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateActiveDirectory( - request?: protos.google.cloud.netapp.v1.IUpdateActiveDirectoryRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.IUpdateActiveDirectoryRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IActiveDirectory, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.IActiveDirectory, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IActiveDirectory, + 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 { + } 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({ - 'active_directory.name': request.activeDirectory!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'active_directory.name': request.activeDirectory!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IActiveDirectory, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateActiveDirectory response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateActiveDirectory request %j', request); - return this.innerApiCalls.updateActiveDirectory(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateActiveDirectory response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateActiveDirectory(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.IActiveDirectory, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateActiveDirectory response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateActiveDirectory()`. - * @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.update_active_directory.js - * region_tag:netapp_v1_generated_NetApp_UpdateActiveDirectory_async - */ - async checkUpdateActiveDirectoryProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateActiveDirectory()`. + * @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.update_active_directory.js + * region_tag:netapp_v1_generated_NetApp_UpdateActiveDirectory_async + */ + async checkUpdateActiveDirectoryProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.ActiveDirectory, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('updateActiveDirectory long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateActiveDirectory, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateActiveDirectory, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.ActiveDirectory, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Delete the active directory specified in the request. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the active directory. - * @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.delete_active_directory.js - * region_tag:netapp_v1_generated_NetApp_DeleteActiveDirectory_async - */ + /** + * Delete the active directory specified in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the active directory. + * @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.delete_active_directory.js + * region_tag:netapp_v1_generated_NetApp_DeleteActiveDirectory_async + */ deleteActiveDirectory( - request?: protos.google.cloud.netapp.v1.IDeleteActiveDirectoryRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IDeleteActiveDirectoryRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteActiveDirectory( - request: protos.google.cloud.netapp.v1.IDeleteActiveDirectoryRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IDeleteActiveDirectoryRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteActiveDirectory( - request: protos.google.cloud.netapp.v1.IDeleteActiveDirectoryRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IDeleteActiveDirectoryRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteActiveDirectory( - request?: protos.google.cloud.netapp.v1.IDeleteActiveDirectoryRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.IDeleteActiveDirectoryRequest, + 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 { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteActiveDirectory response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteActiveDirectory request %j', request); - return this.innerApiCalls.deleteActiveDirectory(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteActiveDirectory response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteActiveDirectory(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteActiveDirectory response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteActiveDirectory()`. - * @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.delete_active_directory.js - * region_tag:netapp_v1_generated_NetApp_DeleteActiveDirectory_async - */ - async checkDeleteActiveDirectoryProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteActiveDirectory()`. + * @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.delete_active_directory.js + * region_tag:netapp_v1_generated_NetApp_DeleteActiveDirectory_async + */ + async checkDeleteActiveDirectoryProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('deleteActiveDirectory long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteActiveDirectory, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteActiveDirectory, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Creates a new KMS config. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Value for parent. - * @param {string} request.kmsConfigId - * Required. Id of the requesting KmsConfig. Must be unique within the parent - * resource. Must contain only letters, numbers and hyphen, with the first - * character a letter, the last a letter or a - * number, and a 63 character maximum. - * @param {google.cloud.netapp.v1.KmsConfig} request.kmsConfig - * Required. The required parameters to create a new KmsConfig. - * @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.create_kms_config.js - * region_tag:netapp_v1_generated_NetApp_CreateKmsConfig_async - */ + /** + * Creates a new KMS config. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Value for parent. + * @param {string} request.kmsConfigId + * Required. Id of the requesting KmsConfig. Must be unique within the parent + * resource. Must contain only letters, numbers and hyphen, with the first + * character a letter, the last a letter or a + * number, and a 63 character maximum. + * @param {google.cloud.netapp.v1.KmsConfig} request.kmsConfig + * Required. The required parameters to create a new KmsConfig. + * @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.create_kms_config.js + * region_tag:netapp_v1_generated_NetApp_CreateKmsConfig_async + */ createKmsConfig( - request?: protos.google.cloud.netapp.v1.ICreateKmsConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.ICreateKmsConfigRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createKmsConfig( - request: protos.google.cloud.netapp.v1.ICreateKmsConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.ICreateKmsConfigRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createKmsConfig( - request: protos.google.cloud.netapp.v1.ICreateKmsConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.ICreateKmsConfigRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createKmsConfig( - request?: protos.google.cloud.netapp.v1.ICreateKmsConfigRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.ICreateKmsConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IKmsConfig, + 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 { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createKmsConfig response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createKmsConfig request %j', request); - return this.innerApiCalls.createKmsConfig(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createKmsConfig response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createKmsConfig(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createKmsConfig response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createKmsConfig()`. - * @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.create_kms_config.js - * region_tag:netapp_v1_generated_NetApp_CreateKmsConfig_async - */ - async checkCreateKmsConfigProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createKmsConfig()`. + * @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.create_kms_config.js + * region_tag:netapp_v1_generated_NetApp_CreateKmsConfig_async + */ + async checkCreateKmsConfigProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.KmsConfig, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('createKmsConfig long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createKmsConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createKmsConfig, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.KmsConfig, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Updates the Kms config properties with the full spec - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Field mask is used to specify the fields to be overwritten in the - * KmsConfig resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - * @param {google.cloud.netapp.v1.KmsConfig} request.kmsConfig - * Required. The KmsConfig being updated - * @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.update_kms_config.js - * region_tag:netapp_v1_generated_NetApp_UpdateKmsConfig_async - */ + /** + * Updates the Kms config properties with the full spec + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Field mask is used to specify the fields to be overwritten in the + * KmsConfig resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @param {google.cloud.netapp.v1.KmsConfig} request.kmsConfig + * Required. The KmsConfig being updated + * @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.update_kms_config.js + * region_tag:netapp_v1_generated_NetApp_UpdateKmsConfig_async + */ updateKmsConfig( - request?: protos.google.cloud.netapp.v1.IUpdateKmsConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IUpdateKmsConfigRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateKmsConfig( - request: protos.google.cloud.netapp.v1.IUpdateKmsConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IUpdateKmsConfigRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateKmsConfig( - request: protos.google.cloud.netapp.v1.IUpdateKmsConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IUpdateKmsConfigRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateKmsConfig( - request?: protos.google.cloud.netapp.v1.IUpdateKmsConfigRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.IUpdateKmsConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IKmsConfig, + 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 { + } 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({ - 'kms_config.name': request.kmsConfig!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'kms_config.name': request.kmsConfig!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateKmsConfig response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateKmsConfig request %j', request); - return this.innerApiCalls.updateKmsConfig(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateKmsConfig response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateKmsConfig(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateKmsConfig response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateKmsConfig()`. - * @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.update_kms_config.js - * region_tag:netapp_v1_generated_NetApp_UpdateKmsConfig_async - */ - async checkUpdateKmsConfigProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateKmsConfig()`. + * @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.update_kms_config.js + * region_tag:netapp_v1_generated_NetApp_UpdateKmsConfig_async + */ + async checkUpdateKmsConfigProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.KmsConfig, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('updateKmsConfig long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateKmsConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateKmsConfig, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.KmsConfig, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Encrypt the existing volumes without CMEK encryption with the desired the - * KMS config for the whole region. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the KmsConfig. - * @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.encrypt_volumes.js - * region_tag:netapp_v1_generated_NetApp_EncryptVolumes_async - */ + /** + * Encrypt the existing volumes without CMEK encryption with the desired the + * KMS config for the whole region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the KmsConfig. + * @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.encrypt_volumes.js + * region_tag:netapp_v1_generated_NetApp_EncryptVolumes_async + */ encryptVolumes( - request?: protos.google.cloud.netapp.v1.IEncryptVolumesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IEncryptVolumesRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; encryptVolumes( - request: protos.google.cloud.netapp.v1.IEncryptVolumesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IEncryptVolumesRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; encryptVolumes( - request: protos.google.cloud.netapp.v1.IEncryptVolumesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IEncryptVolumesRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; encryptVolumes( - request?: protos.google.cloud.netapp.v1.IEncryptVolumesRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.IEncryptVolumesRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IKmsConfig, + 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 { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('encryptVolumes response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('encryptVolumes request %j', request); - return this.innerApiCalls.encryptVolumes(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('encryptVolumes response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .encryptVolumes(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('encryptVolumes response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `encryptVolumes()`. - * @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.encrypt_volumes.js - * region_tag:netapp_v1_generated_NetApp_EncryptVolumes_async - */ - async checkEncryptVolumesProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `encryptVolumes()`. + * @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.encrypt_volumes.js + * region_tag:netapp_v1_generated_NetApp_EncryptVolumes_async + */ + async checkEncryptVolumesProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.KmsConfig, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('encryptVolumes long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.encryptVolumes, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.encryptVolumes, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.KmsConfig, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Warning! This operation will permanently delete the Kms config. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the KmsConfig. - * @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.delete_kms_config.js - * region_tag:netapp_v1_generated_NetApp_DeleteKmsConfig_async - */ + /** + * Warning! This operation will permanently delete the Kms config. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the KmsConfig. + * @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.delete_kms_config.js + * region_tag:netapp_v1_generated_NetApp_DeleteKmsConfig_async + */ deleteKmsConfig( - request?: protos.google.cloud.netapp.v1.IDeleteKmsConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IDeleteKmsConfigRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteKmsConfig( - request: protos.google.cloud.netapp.v1.IDeleteKmsConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IDeleteKmsConfigRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteKmsConfig( - request: protos.google.cloud.netapp.v1.IDeleteKmsConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IDeleteKmsConfigRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteKmsConfig( - request?: protos.google.cloud.netapp.v1.IDeleteKmsConfigRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.IDeleteKmsConfigRequest, + 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 { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteKmsConfig response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteKmsConfig request %j', request); - return this.innerApiCalls.deleteKmsConfig(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteKmsConfig response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteKmsConfig(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteKmsConfig response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteKmsConfig()`. - * @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.delete_kms_config.js - * region_tag:netapp_v1_generated_NetApp_DeleteKmsConfig_async - */ - async checkDeleteKmsConfigProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteKmsConfig()`. + * @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.delete_kms_config.js + * region_tag:netapp_v1_generated_NetApp_DeleteKmsConfig_async + */ + async checkDeleteKmsConfigProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('deleteKmsConfig long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteKmsConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteKmsConfig, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Create a new replication for a volume. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The NetApp volume to create the replications of, in the format - * `projects/{project_id}/locations/{location}/volumes/{volume_id}` - * @param {google.cloud.netapp.v1.Replication} request.replication - * Required. A replication resource - * @param {string} request.replicationId - * Required. ID of the replication to create. Must be unique within the parent - * resource. Must contain only letters, numbers and hyphen, with the first - * character a letter, the last a letter or a - * number, and a 63 character maximum. - * @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.create_replication.js - * region_tag:netapp_v1_generated_NetApp_CreateReplication_async - */ + /** + * Create a new replication for a volume. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The NetApp volume to create the replications of, in the format + * `projects/{project_id}/locations/{location}/volumes/{volume_id}` + * @param {google.cloud.netapp.v1.Replication} request.replication + * Required. A replication resource + * @param {string} request.replicationId + * Required. ID of the replication to create. Must be unique within the parent + * resource. Must contain only letters, numbers and hyphen, with the first + * character a letter, the last a letter or a + * number, and a 63 character maximum. + * @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.create_replication.js + * region_tag:netapp_v1_generated_NetApp_CreateReplication_async + */ createReplication( - request?: protos.google.cloud.netapp.v1.ICreateReplicationRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.ICreateReplicationRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createReplication( - request: protos.google.cloud.netapp.v1.ICreateReplicationRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.ICreateReplicationRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createReplication( - request: protos.google.cloud.netapp.v1.ICreateReplicationRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.ICreateReplicationRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createReplication( - request?: protos.google.cloud.netapp.v1.ICreateReplicationRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.ICreateReplicationRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IReplication, + 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 { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createReplication response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createReplication request %j', request); - return this.innerApiCalls.createReplication(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createReplication response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createReplication(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createReplication response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createReplication()`. - * @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.create_replication.js - * region_tag:netapp_v1_generated_NetApp_CreateReplication_async - */ - async checkCreateReplicationProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createReplication()`. + * @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.create_replication.js + * region_tag:netapp_v1_generated_NetApp_CreateReplication_async + */ + async checkCreateReplicationProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.Replication, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('createReplication long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createReplication, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createReplication, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.Replication, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Deletes a replication. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The replication resource name, in the format - * `projects/* /locations/* /volumes/* /replications/{replication_id}` - * @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.delete_replication.js - * region_tag:netapp_v1_generated_NetApp_DeleteReplication_async - */ + /** + * Deletes a replication. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The replication resource name, in the format + * `projects/* /locations/* /volumes/* /replications/{replication_id}` + * @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.delete_replication.js + * region_tag:netapp_v1_generated_NetApp_DeleteReplication_async + */ deleteReplication( - request?: protos.google.cloud.netapp.v1.IDeleteReplicationRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IDeleteReplicationRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteReplication( - request: protos.google.cloud.netapp.v1.IDeleteReplicationRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IDeleteReplicationRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteReplication( - request: protos.google.cloud.netapp.v1.IDeleteReplicationRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IDeleteReplicationRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteReplication( - request?: protos.google.cloud.netapp.v1.IDeleteReplicationRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.IDeleteReplicationRequest, + 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 { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteReplication response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteReplication request %j', request); - return this.innerApiCalls.deleteReplication(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteReplication response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteReplication(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteReplication response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteReplication()`. - * @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.delete_replication.js - * region_tag:netapp_v1_generated_NetApp_DeleteReplication_async - */ - async checkDeleteReplicationProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteReplication()`. + * @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.delete_replication.js + * region_tag:netapp_v1_generated_NetApp_DeleteReplication_async + */ + async checkDeleteReplicationProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('deleteReplication long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteReplication, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteReplication, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Updates the settings of a specific replication. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Mask of fields to update. At least one path must be supplied in - * this field. - * @param {google.cloud.netapp.v1.Replication} request.replication - * Required. A replication resource - * @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.update_replication.js - * region_tag:netapp_v1_generated_NetApp_UpdateReplication_async - */ + /** + * Updates the settings of a specific replication. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Mask of fields to update. At least one path must be supplied in + * this field. + * @param {google.cloud.netapp.v1.Replication} request.replication + * Required. A replication resource + * @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.update_replication.js + * region_tag:netapp_v1_generated_NetApp_UpdateReplication_async + */ updateReplication( - request?: protos.google.cloud.netapp.v1.IUpdateReplicationRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IUpdateReplicationRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateReplication( - request: protos.google.cloud.netapp.v1.IUpdateReplicationRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IUpdateReplicationRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateReplication( - request: protos.google.cloud.netapp.v1.IUpdateReplicationRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IUpdateReplicationRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateReplication( - request?: protos.google.cloud.netapp.v1.IUpdateReplicationRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.IUpdateReplicationRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IReplication, + 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 { + } 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({ - 'replication.name': request.replication!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'replication.name': request.replication!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateReplication response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateReplication request %j', request); - return this.innerApiCalls.updateReplication(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateReplication response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateReplication(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateReplication response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateReplication()`. - * @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.update_replication.js - * region_tag:netapp_v1_generated_NetApp_UpdateReplication_async - */ - async checkUpdateReplicationProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateReplication()`. + * @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.update_replication.js + * region_tag:netapp_v1_generated_NetApp_UpdateReplication_async + */ + async checkUpdateReplicationProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.Replication, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('updateReplication long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateReplication, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateReplication, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.Replication, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Stop Cross Region Replication. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the replication, in the format of - * projects/{project_id}/locations/{location}/volumes/{volume_id}/replications/{replication_id}. - * @param {boolean} request.force - * Indicates whether to stop replication forcefully while data transfer is in - * progress. - * Warning! if force is true, this will abort any current transfers - * and can lead to data loss due to partial transfer. - * If force is false, stop replication will fail while data transfer is in - * progress and you will need to retry later. - * @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.stop_replication.js - * region_tag:netapp_v1_generated_NetApp_StopReplication_async - */ + /** + * Stop Cross Region Replication. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the replication, in the format of + * projects/{project_id}/locations/{location}/volumes/{volume_id}/replications/{replication_id}. + * @param {boolean} request.force + * Indicates whether to stop replication forcefully while data transfer is in + * progress. + * Warning! if force is true, this will abort any current transfers + * and can lead to data loss due to partial transfer. + * If force is false, stop replication will fail while data transfer is in + * progress and you will need to retry later. + * @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.stop_replication.js + * region_tag:netapp_v1_generated_NetApp_StopReplication_async + */ stopReplication( - request?: protos.google.cloud.netapp.v1.IStopReplicationRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IStopReplicationRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; stopReplication( - request: protos.google.cloud.netapp.v1.IStopReplicationRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IStopReplicationRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; stopReplication( - request: protos.google.cloud.netapp.v1.IStopReplicationRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IStopReplicationRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; stopReplication( - request?: protos.google.cloud.netapp.v1.IStopReplicationRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.IStopReplicationRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IReplication, + 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 { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('stopReplication response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('stopReplication request %j', request); - return this.innerApiCalls.stopReplication(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('stopReplication response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .stopReplication(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('stopReplication response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `stopReplication()`. - * @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.stop_replication.js - * region_tag:netapp_v1_generated_NetApp_StopReplication_async - */ - async checkStopReplicationProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `stopReplication()`. + * @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.stop_replication.js + * region_tag:netapp_v1_generated_NetApp_StopReplication_async + */ + async checkStopReplicationProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.Replication, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('stopReplication long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.stopReplication, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.stopReplication, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.Replication, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Resume Cross Region Replication. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the replication, in the format of - * projects/{project_id}/locations/{location}/volumes/{volume_id}/replications/{replication_id}. - * @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.resume_replication.js - * region_tag:netapp_v1_generated_NetApp_ResumeReplication_async - */ + /** + * Resume Cross Region Replication. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the replication, in the format of + * projects/{project_id}/locations/{location}/volumes/{volume_id}/replications/{replication_id}. + * @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.resume_replication.js + * region_tag:netapp_v1_generated_NetApp_ResumeReplication_async + */ resumeReplication( - request?: protos.google.cloud.netapp.v1.IResumeReplicationRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IResumeReplicationRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; resumeReplication( - request: protos.google.cloud.netapp.v1.IResumeReplicationRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IResumeReplicationRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; resumeReplication( - request: protos.google.cloud.netapp.v1.IResumeReplicationRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IResumeReplicationRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; resumeReplication( - request?: protos.google.cloud.netapp.v1.IResumeReplicationRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.IResumeReplicationRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IReplication, + 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 { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('resumeReplication response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('resumeReplication request %j', request); - return this.innerApiCalls.resumeReplication(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('resumeReplication response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .resumeReplication(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('resumeReplication response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `resumeReplication()`. - * @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.resume_replication.js - * region_tag:netapp_v1_generated_NetApp_ResumeReplication_async - */ - async checkResumeReplicationProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `resumeReplication()`. + * @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.resume_replication.js + * region_tag:netapp_v1_generated_NetApp_ResumeReplication_async + */ + async checkResumeReplicationProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.Replication, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('resumeReplication long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.resumeReplication, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.resumeReplication, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.Replication, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Reverses direction of replication. Source becomes destination and - * destination becomes source. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the replication, in the format of - * projects/{project_id}/locations/{location}/volumes/{volume_id}/replications/{replication_id}. - * @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.reverse_replication_direction.js - * region_tag:netapp_v1_generated_NetApp_ReverseReplicationDirection_async - */ + /** + * Reverses direction of replication. Source becomes destination and + * destination becomes source. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the replication, in the format of + * projects/{project_id}/locations/{location}/volumes/{volume_id}/replications/{replication_id}. + * @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.reverse_replication_direction.js + * region_tag:netapp_v1_generated_NetApp_ReverseReplicationDirection_async + */ reverseReplicationDirection( - request?: protos.google.cloud.netapp.v1.IReverseReplicationDirectionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IReverseReplicationDirectionRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; reverseReplicationDirection( - request: protos.google.cloud.netapp.v1.IReverseReplicationDirectionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IReverseReplicationDirectionRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; reverseReplicationDirection( - request: protos.google.cloud.netapp.v1.IReverseReplicationDirectionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IReverseReplicationDirectionRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; reverseReplicationDirection( - request?: protos.google.cloud.netapp.v1.IReverseReplicationDirectionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.IReverseReplicationDirectionRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IReplication, + 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 { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { - this._log.info('reverseReplicationDirection response %j', rawResponse); + this._log.info( + 'reverseReplicationDirection response %j', + rawResponse, + ); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('reverseReplicationDirection request %j', request); - return this.innerApiCalls.reverseReplicationDirection(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('reverseReplicationDirection response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .reverseReplicationDirection(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info( + 'reverseReplicationDirection response %j', + rawResponse, + ); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `reverseReplicationDirection()`. - * @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.reverse_replication_direction.js - * region_tag:netapp_v1_generated_NetApp_ReverseReplicationDirection_async - */ - async checkReverseReplicationDirectionProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `reverseReplicationDirection()`. + * @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.reverse_replication_direction.js + * region_tag:netapp_v1_generated_NetApp_ReverseReplicationDirection_async + */ + async checkReverseReplicationDirectionProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.Replication, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('reverseReplicationDirection long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.reverseReplicationDirection, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.reverseReplicationDirection, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.Replication, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Establish replication peering. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the replication, in the format of - * projects/{project_id}/locations/{location}/volumes/{volume_id}/replications/{replication_id}. - * @param {string} request.peerClusterName - * Required. Name of the user's local source cluster to be peered with the - * destination cluster. - * @param {string} request.peerSvmName - * Required. Name of the user's local source vserver svm to be peered with the - * destination vserver svm. - * @param {string[]} [request.peerIpAddresses] - * Optional. List of IPv4 ip addresses to be used for peering. - * @param {string} request.peerVolumeName - * Required. Name of the user's local source volume to be peered with the - * destination volume. - * @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.establish_peering.js - * region_tag:netapp_v1_generated_NetApp_EstablishPeering_async - */ + /** + * Establish replication peering. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the replication, in the format of + * projects/{project_id}/locations/{location}/volumes/{volume_id}/replications/{replication_id}. + * @param {string} request.peerClusterName + * Required. Name of the user's local source cluster to be peered with the + * destination cluster. + * @param {string} request.peerSvmName + * Required. Name of the user's local source vserver svm to be peered with the + * destination vserver svm. + * @param {string[]} [request.peerIpAddresses] + * Optional. List of IPv4 ip addresses to be used for peering. + * @param {string} request.peerVolumeName + * Required. Name of the user's local source volume to be peered with the + * destination volume. + * @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.establish_peering.js + * region_tag:netapp_v1_generated_NetApp_EstablishPeering_async + */ establishPeering( - request?: protos.google.cloud.netapp.v1.IEstablishPeeringRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IEstablishPeeringRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; establishPeering( - request: protos.google.cloud.netapp.v1.IEstablishPeeringRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IEstablishPeeringRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; establishPeering( - request: protos.google.cloud.netapp.v1.IEstablishPeeringRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IEstablishPeeringRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; establishPeering( - request?: protos.google.cloud.netapp.v1.IEstablishPeeringRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.IEstablishPeeringRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IReplication, + 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 { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('establishPeering response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('establishPeering request %j', request); - return this.innerApiCalls.establishPeering(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('establishPeering response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .establishPeering(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('establishPeering response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `establishPeering()`. - * @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.establish_peering.js - * region_tag:netapp_v1_generated_NetApp_EstablishPeering_async - */ - async checkEstablishPeeringProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `establishPeering()`. + * @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.establish_peering.js + * region_tag:netapp_v1_generated_NetApp_EstablishPeering_async + */ + async checkEstablishPeeringProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.Replication, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('establishPeering long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.establishPeering, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.establishPeering, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.Replication, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Syncs the replication. This will invoke one time volume data transfer from - * source to destination. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the replication, in the format of - * projects/{project_id}/locations/{location}/volumes/{volume_id}/replications/{replication_id}. - * @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.sync_replication.js - * region_tag:netapp_v1_generated_NetApp_SyncReplication_async - */ + /** + * Syncs the replication. This will invoke one time volume data transfer from + * source to destination. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the replication, in the format of + * projects/{project_id}/locations/{location}/volumes/{volume_id}/replications/{replication_id}. + * @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.sync_replication.js + * region_tag:netapp_v1_generated_NetApp_SyncReplication_async + */ syncReplication( - request?: protos.google.cloud.netapp.v1.ISyncReplicationRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.ISyncReplicationRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; syncReplication( - request: protos.google.cloud.netapp.v1.ISyncReplicationRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.ISyncReplicationRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; syncReplication( - request: protos.google.cloud.netapp.v1.ISyncReplicationRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.ISyncReplicationRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; syncReplication( - request?: protos.google.cloud.netapp.v1.ISyncReplicationRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.ISyncReplicationRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IReplication, + 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 { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('syncReplication response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('syncReplication request %j', request); - return this.innerApiCalls.syncReplication(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('syncReplication response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .syncReplication(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('syncReplication response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `syncReplication()`. - * @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.sync_replication.js - * region_tag:netapp_v1_generated_NetApp_SyncReplication_async - */ - async checkSyncReplicationProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `syncReplication()`. + * @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.sync_replication.js + * region_tag:netapp_v1_generated_NetApp_SyncReplication_async + */ + async checkSyncReplicationProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.Replication, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('syncReplication long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.syncReplication, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.syncReplication, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.Replication, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Creates new backup vault - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location to create the backup vaults, in the format - * `projects/{project_id}/locations/{location}` - * @param {string} request.backupVaultId - * Required. The ID to use for the backupVault. - * The ID must be unique within the specified location. - * Must contain only letters, numbers and hyphen, with the first - * character a letter, the last a letter or a - * number, and a 63 character maximum. - * @param {google.cloud.netapp.v1.BackupVault} request.backupVault - * Required. A backupVault resource - * @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.create_backup_vault.js - * region_tag:netapp_v1_generated_NetApp_CreateBackupVault_async - */ + /** + * Creates new backup vault + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location to create the backup vaults, in the format + * `projects/{project_id}/locations/{location}` + * @param {string} request.backupVaultId + * Required. The ID to use for the backupVault. + * The ID must be unique within the specified location. + * Must contain only letters, numbers and hyphen, with the first + * character a letter, the last a letter or a + * number, and a 63 character maximum. + * @param {google.cloud.netapp.v1.BackupVault} request.backupVault + * Required. A backupVault resource + * @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.create_backup_vault.js + * region_tag:netapp_v1_generated_NetApp_CreateBackupVault_async + */ createBackupVault( - request?: protos.google.cloud.netapp.v1.ICreateBackupVaultRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.ICreateBackupVaultRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IBackupVault, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createBackupVault( - request: protos.google.cloud.netapp.v1.ICreateBackupVaultRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.ICreateBackupVaultRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IBackupVault, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createBackupVault( - request: protos.google.cloud.netapp.v1.ICreateBackupVaultRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.ICreateBackupVaultRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IBackupVault, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createBackupVault( - request?: protos.google.cloud.netapp.v1.ICreateBackupVaultRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.ICreateBackupVaultRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IBackupVault, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.IBackupVault, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IBackupVault, + 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 { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IBackupVault, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createBackupVault response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createBackupVault request %j', request); - return this.innerApiCalls.createBackupVault(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createBackupVault response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createBackupVault(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.IBackupVault, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createBackupVault response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createBackupVault()`. - * @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.create_backup_vault.js - * region_tag:netapp_v1_generated_NetApp_CreateBackupVault_async - */ - async checkCreateBackupVaultProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createBackupVault()`. + * @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.create_backup_vault.js + * region_tag:netapp_v1_generated_NetApp_CreateBackupVault_async + */ + async checkCreateBackupVaultProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.BackupVault, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('createBackupVault long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createBackupVault, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createBackupVault, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.BackupVault, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Updates the settings of a specific backup vault. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Field mask is used to specify the fields to be overwritten in the - * Backup resource to be updated. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - * @param {google.cloud.netapp.v1.BackupVault} request.backupVault - * Required. The backupVault being updated - * @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.update_backup_vault.js - * region_tag:netapp_v1_generated_NetApp_UpdateBackupVault_async - */ + /** + * Updates the settings of a specific backup vault. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Field mask is used to specify the fields to be overwritten in the + * Backup resource to be updated. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @param {google.cloud.netapp.v1.BackupVault} request.backupVault + * Required. The backupVault being updated + * @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.update_backup_vault.js + * region_tag:netapp_v1_generated_NetApp_UpdateBackupVault_async + */ updateBackupVault( - request?: protos.google.cloud.netapp.v1.IUpdateBackupVaultRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IUpdateBackupVaultRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IBackupVault, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateBackupVault( - request: protos.google.cloud.netapp.v1.IUpdateBackupVaultRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IUpdateBackupVaultRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IBackupVault, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateBackupVault( - request: protos.google.cloud.netapp.v1.IUpdateBackupVaultRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IUpdateBackupVaultRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IBackupVault, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateBackupVault( - request?: protos.google.cloud.netapp.v1.IUpdateBackupVaultRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.IUpdateBackupVaultRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IBackupVault, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.IBackupVault, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IBackupVault, + 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 { + } 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({ - 'backup_vault.name': request.backupVault!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'backup_vault.name': request.backupVault!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IBackupVault, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateBackupVault response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateBackupVault request %j', request); - return this.innerApiCalls.updateBackupVault(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateBackupVault response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateBackupVault(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.IBackupVault, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateBackupVault response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateBackupVault()`. - * @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.update_backup_vault.js - * region_tag:netapp_v1_generated_NetApp_UpdateBackupVault_async - */ - async checkUpdateBackupVaultProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateBackupVault()`. + * @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.update_backup_vault.js + * region_tag:netapp_v1_generated_NetApp_UpdateBackupVault_async + */ + async checkUpdateBackupVaultProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.BackupVault, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('updateBackupVault long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateBackupVault, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateBackupVault, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.BackupVault, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Warning! This operation will permanently delete the backup vault. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The backupVault resource name, in the format - * `projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}` - * @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.delete_backup_vault.js - * region_tag:netapp_v1_generated_NetApp_DeleteBackupVault_async - */ + /** + * Warning! This operation will permanently delete the backup vault. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The backupVault resource name, in the format + * `projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}` + * @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.delete_backup_vault.js + * region_tag:netapp_v1_generated_NetApp_DeleteBackupVault_async + */ deleteBackupVault( - request?: protos.google.cloud.netapp.v1.IDeleteBackupVaultRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IDeleteBackupVaultRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteBackupVault( - request: protos.google.cloud.netapp.v1.IDeleteBackupVaultRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IDeleteBackupVaultRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteBackupVault( - request: protos.google.cloud.netapp.v1.IDeleteBackupVaultRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IDeleteBackupVaultRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteBackupVault( - request?: protos.google.cloud.netapp.v1.IDeleteBackupVaultRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.IDeleteBackupVaultRequest, + 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 { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteBackupVault response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteBackupVault request %j', request); - return this.innerApiCalls.deleteBackupVault(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteBackupVault response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteBackupVault(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteBackupVault response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteBackupVault()`. - * @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.delete_backup_vault.js - * region_tag:netapp_v1_generated_NetApp_DeleteBackupVault_async - */ - async checkDeleteBackupVaultProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteBackupVault()`. + * @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.delete_backup_vault.js + * region_tag:netapp_v1_generated_NetApp_DeleteBackupVault_async + */ + async checkDeleteBackupVaultProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('deleteBackupVault long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteBackupVault, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteBackupVault, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Creates a backup from the volume specified in the request - * The backup can be created from the given snapshot if specified in the - * request. If no snapshot specified, there'll be a new snapshot taken to - * initiate the backup creation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The NetApp backupVault to create the backups of, in the format - * `projects/* /locations/* /backupVaults/{backup_vault_id}` - * @param {string} request.backupId - * Required. The ID to use for the backup. - * The ID must be unique within the specified backupVault. - * Must contain only letters, numbers and hyphen, with the first - * character a letter, the last a letter or a - * number, and a 63 character maximum. - * @param {google.cloud.netapp.v1.Backup} request.backup - * Required. A backup resource - * @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.create_backup.js - * region_tag:netapp_v1_generated_NetApp_CreateBackup_async - */ + /** + * Creates a backup from the volume specified in the request + * The backup can be created from the given snapshot if specified in the + * request. If no snapshot specified, there'll be a new snapshot taken to + * initiate the backup creation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The NetApp backupVault to create the backups of, in the format + * `projects/* /locations/* /backupVaults/{backup_vault_id}` + * @param {string} request.backupId + * Required. The ID to use for the backup. + * The ID must be unique within the specified backupVault. + * Must contain only letters, numbers and hyphen, with the first + * character a letter, the last a letter or a + * number, and a 63 character maximum. + * @param {google.cloud.netapp.v1.Backup} request.backup + * Required. A backup resource + * @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.create_backup.js + * region_tag:netapp_v1_generated_NetApp_CreateBackup_async + */ createBackup( - request?: protos.google.cloud.netapp.v1.ICreateBackupRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.ICreateBackupRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IBackup, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createBackup( - request: protos.google.cloud.netapp.v1.ICreateBackupRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.ICreateBackupRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IBackup, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createBackup( - request: protos.google.cloud.netapp.v1.ICreateBackupRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.ICreateBackupRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IBackup, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createBackup( - request?: protos.google.cloud.netapp.v1.ICreateBackupRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.ICreateBackupRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IBackup, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.IBackup, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IBackup, + 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 { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IBackup, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createBackup response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createBackup request %j', request); - return this.innerApiCalls.createBackup(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createBackup response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createBackup(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.IBackup, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createBackup response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createBackup()`. - * @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.create_backup.js - * region_tag:netapp_v1_generated_NetApp_CreateBackup_async - */ - async checkCreateBackupProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createBackup()`. + * @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.create_backup.js + * region_tag:netapp_v1_generated_NetApp_CreateBackup_async + */ + async checkCreateBackupProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.Backup, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('createBackup long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createBackup, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createBackup, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.Backup, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Warning! This operation will permanently delete the backup. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The backup resource name, in the format - * `projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}/backups/{backup_id}` - * @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.delete_backup.js - * region_tag:netapp_v1_generated_NetApp_DeleteBackup_async - */ + /** + * Warning! This operation will permanently delete the backup. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The backup resource name, in the format + * `projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}/backups/{backup_id}` + * @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.delete_backup.js + * region_tag:netapp_v1_generated_NetApp_DeleteBackup_async + */ deleteBackup( - request?: protos.google.cloud.netapp.v1.IDeleteBackupRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IDeleteBackupRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteBackup( - request: protos.google.cloud.netapp.v1.IDeleteBackupRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IDeleteBackupRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteBackup( - request: protos.google.cloud.netapp.v1.IDeleteBackupRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IDeleteBackupRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteBackup( - request?: protos.google.cloud.netapp.v1.IDeleteBackupRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.IDeleteBackupRequest, + 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 { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteBackup response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteBackup request %j', request); - return this.innerApiCalls.deleteBackup(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteBackup response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteBackup(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteBackup response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteBackup()`. - * @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.delete_backup.js - * region_tag:netapp_v1_generated_NetApp_DeleteBackup_async - */ - async checkDeleteBackupProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteBackup()`. + * @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.delete_backup.js + * region_tag:netapp_v1_generated_NetApp_DeleteBackup_async + */ + async checkDeleteBackupProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('deleteBackup long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteBackup, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteBackup, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Update backup with full spec. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Field mask is used to specify the fields to be overwritten in the - * Backup resource to be updated. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - * @param {google.cloud.netapp.v1.Backup} request.backup - * Required. The backup being updated - * @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.update_backup.js - * region_tag:netapp_v1_generated_NetApp_UpdateBackup_async - */ + /** + * Update backup with full spec. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Field mask is used to specify the fields to be overwritten in the + * Backup resource to be updated. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @param {google.cloud.netapp.v1.Backup} request.backup + * Required. The backup being updated + * @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.update_backup.js + * region_tag:netapp_v1_generated_NetApp_UpdateBackup_async + */ updateBackup( - request?: protos.google.cloud.netapp.v1.IUpdateBackupRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IUpdateBackupRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IBackup, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateBackup( - request: protos.google.cloud.netapp.v1.IUpdateBackupRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IUpdateBackupRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IBackup, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateBackup( - request: protos.google.cloud.netapp.v1.IUpdateBackupRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IUpdateBackupRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IBackup, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateBackup( - request?: protos.google.cloud.netapp.v1.IUpdateBackupRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.IUpdateBackupRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IBackup, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.IBackup, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IBackup, + 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 { + } 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({ - 'backup.name': request.backup!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'backup.name': request.backup!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IBackup, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateBackup response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateBackup request %j', request); - return this.innerApiCalls.updateBackup(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateBackup response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateBackup(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.IBackup, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateBackup response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateBackup()`. - * @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.update_backup.js - * region_tag:netapp_v1_generated_NetApp_UpdateBackup_async - */ - async checkUpdateBackupProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateBackup()`. + * @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.update_backup.js + * region_tag:netapp_v1_generated_NetApp_UpdateBackup_async + */ + async checkUpdateBackupProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.Backup, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('updateBackup long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateBackup, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateBackup, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.Backup, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Creates new backup policy - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location to create the backup policies of, in the format - * `projects/{project_id}/locations/{location}` - * @param {google.cloud.netapp.v1.BackupPolicy} request.backupPolicy - * Required. A backupPolicy resource - * @param {string} request.backupPolicyId - * Required. The ID to use for the backup policy. - * The ID must be unique within the specified location. - * Must contain only letters, numbers and hyphen, with the first - * character a letter, the last a letter or a - * number, and a 63 character maximum. - * @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.create_backup_policy.js - * region_tag:netapp_v1_generated_NetApp_CreateBackupPolicy_async - */ + /** + * Creates new backup policy + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location to create the backup policies of, in the format + * `projects/{project_id}/locations/{location}` + * @param {google.cloud.netapp.v1.BackupPolicy} request.backupPolicy + * Required. A backupPolicy resource + * @param {string} request.backupPolicyId + * Required. The ID to use for the backup policy. + * The ID must be unique within the specified location. + * Must contain only letters, numbers and hyphen, with the first + * character a letter, the last a letter or a + * number, and a 63 character maximum. + * @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.create_backup_policy.js + * region_tag:netapp_v1_generated_NetApp_CreateBackupPolicy_async + */ createBackupPolicy( - request?: protos.google.cloud.netapp.v1.ICreateBackupPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.ICreateBackupPolicyRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IBackupPolicy, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createBackupPolicy( - request: protos.google.cloud.netapp.v1.ICreateBackupPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.ICreateBackupPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IBackupPolicy, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createBackupPolicy( - request: protos.google.cloud.netapp.v1.ICreateBackupPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.ICreateBackupPolicyRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IBackupPolicy, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createBackupPolicy( - request?: protos.google.cloud.netapp.v1.ICreateBackupPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.ICreateBackupPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IBackupPolicy, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.IBackupPolicy, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IBackupPolicy, + 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 { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IBackupPolicy, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createBackupPolicy response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createBackupPolicy request %j', request); - return this.innerApiCalls.createBackupPolicy(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createBackupPolicy response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createBackupPolicy(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.IBackupPolicy, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createBackupPolicy response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createBackupPolicy()`. - * @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.create_backup_policy.js - * region_tag:netapp_v1_generated_NetApp_CreateBackupPolicy_async - */ - async checkCreateBackupPolicyProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createBackupPolicy()`. + * @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.create_backup_policy.js + * region_tag:netapp_v1_generated_NetApp_CreateBackupPolicy_async + */ + async checkCreateBackupPolicyProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.BackupPolicy, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('createBackupPolicy long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createBackupPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createBackupPolicy, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.BackupPolicy, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Updates settings of a specific backup policy. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Field mask is used to specify the fields to be overwritten in the - * Backup Policy resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - * @param {google.cloud.netapp.v1.BackupPolicy} request.backupPolicy - * Required. The backup policy being updated - * @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.update_backup_policy.js - * region_tag:netapp_v1_generated_NetApp_UpdateBackupPolicy_async - */ + /** + * Updates settings of a specific backup policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Field mask is used to specify the fields to be overwritten in the + * Backup Policy resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @param {google.cloud.netapp.v1.BackupPolicy} request.backupPolicy + * Required. The backup policy being updated + * @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.update_backup_policy.js + * region_tag:netapp_v1_generated_NetApp_UpdateBackupPolicy_async + */ updateBackupPolicy( - request?: protos.google.cloud.netapp.v1.IUpdateBackupPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IUpdateBackupPolicyRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IBackupPolicy, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateBackupPolicy( - request: protos.google.cloud.netapp.v1.IUpdateBackupPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IUpdateBackupPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IBackupPolicy, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateBackupPolicy( - request: protos.google.cloud.netapp.v1.IUpdateBackupPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IUpdateBackupPolicyRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IBackupPolicy, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateBackupPolicy( - request?: protos.google.cloud.netapp.v1.IUpdateBackupPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.IUpdateBackupPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IBackupPolicy, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.IBackupPolicy, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IBackupPolicy, + 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 { + } 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({ - 'backup_policy.name': request.backupPolicy!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'backup_policy.name': request.backupPolicy!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IBackupPolicy, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateBackupPolicy response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateBackupPolicy request %j', request); - return this.innerApiCalls.updateBackupPolicy(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateBackupPolicy response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateBackupPolicy(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.IBackupPolicy, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateBackupPolicy response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateBackupPolicy()`. - * @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.update_backup_policy.js - * region_tag:netapp_v1_generated_NetApp_UpdateBackupPolicy_async - */ - async checkUpdateBackupPolicyProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateBackupPolicy()`. + * @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.update_backup_policy.js + * region_tag:netapp_v1_generated_NetApp_UpdateBackupPolicy_async + */ + async checkUpdateBackupPolicyProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.BackupPolicy, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('updateBackupPolicy long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateBackupPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateBackupPolicy, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.BackupPolicy, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Warning! This operation will permanently delete the backup policy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The backup policy resource name, in the format - * `projects/{project_id}/locations/{location}/backupPolicies/{backup_policy_id}` - * @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.delete_backup_policy.js - * region_tag:netapp_v1_generated_NetApp_DeleteBackupPolicy_async - */ + /** + * Warning! This operation will permanently delete the backup policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The backup policy resource name, in the format + * `projects/{project_id}/locations/{location}/backupPolicies/{backup_policy_id}` + * @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.delete_backup_policy.js + * region_tag:netapp_v1_generated_NetApp_DeleteBackupPolicy_async + */ deleteBackupPolicy( - request?: protos.google.cloud.netapp.v1.IDeleteBackupPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IDeleteBackupPolicyRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteBackupPolicy( - request: protos.google.cloud.netapp.v1.IDeleteBackupPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IDeleteBackupPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteBackupPolicy( - request: protos.google.cloud.netapp.v1.IDeleteBackupPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IDeleteBackupPolicyRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteBackupPolicy( - request?: protos.google.cloud.netapp.v1.IDeleteBackupPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.IDeleteBackupPolicyRequest, + 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 { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteBackupPolicy response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteBackupPolicy request %j', request); - return this.innerApiCalls.deleteBackupPolicy(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteBackupPolicy response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteBackupPolicy(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteBackupPolicy response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteBackupPolicy()`. - * @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.delete_backup_policy.js - * region_tag:netapp_v1_generated_NetApp_DeleteBackupPolicy_async - */ - async checkDeleteBackupPolicyProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteBackupPolicy()`. + * @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.delete_backup_policy.js + * region_tag:netapp_v1_generated_NetApp_DeleteBackupPolicy_async + */ + async checkDeleteBackupPolicyProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('deleteBackupPolicy long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteBackupPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteBackupPolicy, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Creates a new quota rule. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for CreateQuotaRuleRequest - * @param {google.cloud.netapp.v1.QuotaRule} request.quotaRule - * Required. Fields of the to be created quota rule. - * @param {string} request.quotaRuleId - * Required. ID of the quota rule to create. Must be unique within the parent - * resource. Must contain only letters, numbers, underscore and hyphen, with - * the first character a letter or underscore, the last a letter or underscore - * or a number, and a 63 character maximum. - * @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.create_quota_rule.js - * region_tag:netapp_v1_generated_NetApp_CreateQuotaRule_async - */ + /** + * Creates a new quota rule. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for CreateQuotaRuleRequest + * @param {google.cloud.netapp.v1.QuotaRule} request.quotaRule + * Required. Fields of the to be created quota rule. + * @param {string} request.quotaRuleId + * Required. ID of the quota rule to create. Must be unique within the parent + * resource. Must contain only letters, numbers, underscore and hyphen, with + * the first character a letter or underscore, the last a letter or underscore + * or a number, and a 63 character maximum. + * @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.create_quota_rule.js + * region_tag:netapp_v1_generated_NetApp_CreateQuotaRule_async + */ createQuotaRule( - request?: protos.google.cloud.netapp.v1.ICreateQuotaRuleRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.ICreateQuotaRuleRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IQuotaRule, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createQuotaRule( - request: protos.google.cloud.netapp.v1.ICreateQuotaRuleRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.ICreateQuotaRuleRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IQuotaRule, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createQuotaRule( - request: protos.google.cloud.netapp.v1.ICreateQuotaRuleRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.ICreateQuotaRuleRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IQuotaRule, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createQuotaRule( - request?: protos.google.cloud.netapp.v1.ICreateQuotaRuleRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.ICreateQuotaRuleRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IQuotaRule, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.IQuotaRule, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IQuotaRule, + 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 { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IQuotaRule, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createQuotaRule response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createQuotaRule request %j', request); - return this.innerApiCalls.createQuotaRule(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createQuotaRule response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createQuotaRule(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.IQuotaRule, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createQuotaRule response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createQuotaRule()`. - * @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.create_quota_rule.js - * region_tag:netapp_v1_generated_NetApp_CreateQuotaRule_async - */ - async checkCreateQuotaRuleProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createQuotaRule()`. + * @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.create_quota_rule.js + * region_tag:netapp_v1_generated_NetApp_CreateQuotaRule_async + */ + async checkCreateQuotaRuleProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.QuotaRule, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('createQuotaRule long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createQuotaRule, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createQuotaRule, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.QuotaRule, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Updates a quota rule. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask is used to specify the fields to be overwritten in the - * Quota Rule resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - * @param {google.cloud.netapp.v1.QuotaRule} request.quotaRule - * Required. The quota rule being updated - * @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.update_quota_rule.js - * region_tag:netapp_v1_generated_NetApp_UpdateQuotaRule_async - */ + /** + * Updates a quota rule. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask is used to specify the fields to be overwritten in the + * Quota Rule resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @param {google.cloud.netapp.v1.QuotaRule} request.quotaRule + * Required. The quota rule being updated + * @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.update_quota_rule.js + * region_tag:netapp_v1_generated_NetApp_UpdateQuotaRule_async + */ updateQuotaRule( - request?: protos.google.cloud.netapp.v1.IUpdateQuotaRuleRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IUpdateQuotaRuleRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IQuotaRule, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateQuotaRule( - request: protos.google.cloud.netapp.v1.IUpdateQuotaRuleRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IUpdateQuotaRuleRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IQuotaRule, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateQuotaRule( - request: protos.google.cloud.netapp.v1.IUpdateQuotaRuleRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IUpdateQuotaRuleRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IQuotaRule, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateQuotaRule( - request?: protos.google.cloud.netapp.v1.IUpdateQuotaRuleRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.IUpdateQuotaRuleRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IQuotaRule, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.IQuotaRule, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IQuotaRule, + 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 { + } 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({ - 'quota_rule.name': request.quotaRule!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'quota_rule.name': request.quotaRule!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IQuotaRule, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateQuotaRule response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateQuotaRule request %j', request); - return this.innerApiCalls.updateQuotaRule(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateQuotaRule response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateQuotaRule(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.IQuotaRule, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateQuotaRule response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateQuotaRule()`. - * @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.update_quota_rule.js - * region_tag:netapp_v1_generated_NetApp_UpdateQuotaRule_async - */ - async checkUpdateQuotaRuleProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateQuotaRule()`. + * @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.update_quota_rule.js + * region_tag:netapp_v1_generated_NetApp_UpdateQuotaRule_async + */ + async checkUpdateQuotaRuleProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.QuotaRule, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('updateQuotaRule long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateQuotaRule, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateQuotaRule, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.QuotaRule, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Deletes a quota rule. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the quota rule. - * @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.delete_quota_rule.js - * region_tag:netapp_v1_generated_NetApp_DeleteQuotaRule_async - */ + /** + * Deletes a quota rule. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the quota rule. + * @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.delete_quota_rule.js + * region_tag:netapp_v1_generated_NetApp_DeleteQuotaRule_async + */ deleteQuotaRule( - request?: protos.google.cloud.netapp.v1.IDeleteQuotaRuleRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IDeleteQuotaRuleRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteQuotaRule( - request: protos.google.cloud.netapp.v1.IDeleteQuotaRuleRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IDeleteQuotaRuleRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteQuotaRule( - request: protos.google.cloud.netapp.v1.IDeleteQuotaRuleRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IDeleteQuotaRuleRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteQuotaRule( - request?: protos.google.cloud.netapp.v1.IDeleteQuotaRuleRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.IDeleteQuotaRuleRequest, + 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 { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteQuotaRule response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteQuotaRule request %j', request); - return this.innerApiCalls.deleteQuotaRule(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteQuotaRule response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteQuotaRule(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteQuotaRule response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteQuotaRule()`. - * @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.delete_quota_rule.js - * region_tag:netapp_v1_generated_NetApp_DeleteQuotaRule_async - */ - async checkDeleteQuotaRuleProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteQuotaRule()`. + * @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.delete_quota_rule.js + * region_tag:netapp_v1_generated_NetApp_DeleteQuotaRule_async + */ + async checkDeleteQuotaRuleProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('deleteQuotaRule long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteQuotaRule, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteQuotaRule, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Restore files from a backup to a volume. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The volume resource name, in the format - * `projects/{project_id}/locations/{location}/volumes/{volume_id}` - * @param {string} request.backup - * Required. The backup resource name, in the format - * `projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}/backups/{backup_id}` - * @param {string[]} request.fileList - * Required. List of files to be restored, specified by their absolute path in - * the source volume. - * @param {string} [request.restoreDestinationPath] - * Optional. Absolute directory path in the destination volume. This is - * required if the `file_list` is provided. - * @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.restore_backup_files.js - * region_tag:netapp_v1_generated_NetApp_RestoreBackupFiles_async - */ + /** + * Restore files from a backup to a volume. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The volume resource name, in the format + * `projects/{project_id}/locations/{location}/volumes/{volume_id}` + * @param {string} request.backup + * Required. The backup resource name, in the format + * `projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}/backups/{backup_id}` + * @param {string[]} request.fileList + * Required. List of files to be restored, specified by their absolute path in + * the source volume. + * @param {string} [request.restoreDestinationPath] + * Optional. Absolute directory path in the destination volume. This is + * required if the `file_list` is provided. + * @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.restore_backup_files.js + * region_tag:netapp_v1_generated_NetApp_RestoreBackupFiles_async + */ restoreBackupFiles( - request?: protos.google.cloud.netapp.v1.IRestoreBackupFilesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IRestoreBackupFilesRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IRestoreBackupFilesResponse, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; restoreBackupFiles( - request: protos.google.cloud.netapp.v1.IRestoreBackupFilesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IRestoreBackupFilesRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IRestoreBackupFilesResponse, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; restoreBackupFiles( - request: protos.google.cloud.netapp.v1.IRestoreBackupFilesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IRestoreBackupFilesRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IRestoreBackupFilesResponse, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; restoreBackupFiles( - request?: protos.google.cloud.netapp.v1.IRestoreBackupFilesRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.IRestoreBackupFilesRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IRestoreBackupFilesResponse, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.IRestoreBackupFilesResponse, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IRestoreBackupFilesResponse, + 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 { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IRestoreBackupFilesResponse, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('restoreBackupFiles response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('restoreBackupFiles request %j', request); - return this.innerApiCalls.restoreBackupFiles(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('restoreBackupFiles response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .restoreBackupFiles(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.IRestoreBackupFilesResponse, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('restoreBackupFiles response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `restoreBackupFiles()`. - * @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.restore_backup_files.js - * region_tag:netapp_v1_generated_NetApp_RestoreBackupFiles_async - */ - async checkRestoreBackupFilesProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `restoreBackupFiles()`. + * @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.restore_backup_files.js + * region_tag:netapp_v1_generated_NetApp_RestoreBackupFiles_async + */ + async checkRestoreBackupFilesProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.RestoreBackupFilesResponse, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('restoreBackupFiles long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.restoreBackupFiles, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.restoreBackupFiles, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.RestoreBackupFilesResponse, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Creates a new host group. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for CreateHostGroupRequest - * @param {google.cloud.netapp.v1.HostGroup} request.hostGroup - * Required. Fields of the host group to create. - * @param {string} request.hostGroupId - * Required. ID of the host group to create. Must be unique within the parent - * resource. Must contain only letters, numbers, and hyphen, with - * the first character a letter or underscore, the last a letter or underscore - * or a number, and a 63 character maximum. - * @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.create_host_group.js - * region_tag:netapp_v1_generated_NetApp_CreateHostGroup_async - */ + /** + * Creates a new host group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for CreateHostGroupRequest + * @param {google.cloud.netapp.v1.HostGroup} request.hostGroup + * Required. Fields of the host group to create. + * @param {string} request.hostGroupId + * Required. ID of the host group to create. Must be unique within the parent + * resource. Must contain only letters, numbers, and hyphen, with + * the first character a letter or underscore, the last a letter or underscore + * or a number, and a 63 character maximum. + * @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.create_host_group.js + * region_tag:netapp_v1_generated_NetApp_CreateHostGroup_async + */ createHostGroup( - request?: protos.google.cloud.netapp.v1.ICreateHostGroupRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.ICreateHostGroupRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IHostGroup, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createHostGroup( - request: protos.google.cloud.netapp.v1.ICreateHostGroupRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.ICreateHostGroupRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IHostGroup, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createHostGroup( - request: protos.google.cloud.netapp.v1.ICreateHostGroupRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.ICreateHostGroupRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IHostGroup, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createHostGroup( - request?: protos.google.cloud.netapp.v1.ICreateHostGroupRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.ICreateHostGroupRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IHostGroup, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.IHostGroup, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IHostGroup, + 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 { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IHostGroup, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createHostGroup response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createHostGroup request %j', request); - return this.innerApiCalls.createHostGroup(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createHostGroup response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createHostGroup(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.IHostGroup, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createHostGroup response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createHostGroup()`. - * @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.create_host_group.js - * region_tag:netapp_v1_generated_NetApp_CreateHostGroup_async - */ - async checkCreateHostGroupProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createHostGroup()`. + * @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.create_host_group.js + * region_tag:netapp_v1_generated_NetApp_CreateHostGroup_async + */ + async checkCreateHostGroupProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.HostGroup, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('createHostGroup long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createHostGroup, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createHostGroup, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.HostGroup, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Updates an existing host group. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.netapp.v1.HostGroup} request.hostGroup - * Required. The host group to update. - * The host group's `name` field is used to identify the host group. - * Format: - * `projects/{project_number}/locations/{location_id}/hostGroups/{host_group_id}`. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. The list of fields to update. - * @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.update_host_group.js - * region_tag:netapp_v1_generated_NetApp_UpdateHostGroup_async - */ + /** + * Updates an existing host group. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.netapp.v1.HostGroup} request.hostGroup + * Required. The host group to update. + * The host group's `name` field is used to identify the host group. + * Format: + * `projects/{project_number}/locations/{location_id}/hostGroups/{host_group_id}`. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. The list of fields to update. + * @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.update_host_group.js + * region_tag:netapp_v1_generated_NetApp_UpdateHostGroup_async + */ updateHostGroup( - request?: protos.google.cloud.netapp.v1.IUpdateHostGroupRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IUpdateHostGroupRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IHostGroup, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateHostGroup( - request: protos.google.cloud.netapp.v1.IUpdateHostGroupRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IUpdateHostGroupRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IHostGroup, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateHostGroup( - request: protos.google.cloud.netapp.v1.IUpdateHostGroupRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IUpdateHostGroupRequest, + callback: Callback< + LROperation< + protos.google.cloud.netapp.v1.IHostGroup, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateHostGroup( - request?: protos.google.cloud.netapp.v1.IUpdateHostGroupRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.IUpdateHostGroupRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IHostGroup, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.netapp.v1.IHostGroup, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.netapp.v1.IHostGroup, + 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 { + } 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({ - 'host_group.name': request.hostGroup!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'host_group.name': request.hostGroup!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.netapp.v1.IHostGroup, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateHostGroup response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateHostGroup request %j', request); - return this.innerApiCalls.updateHostGroup(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateHostGroup response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateHostGroup(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.netapp.v1.IHostGroup, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateHostGroup response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateHostGroup()`. - * @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.update_host_group.js - * region_tag:netapp_v1_generated_NetApp_UpdateHostGroup_async - */ - async checkUpdateHostGroupProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateHostGroup()`. + * @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.update_host_group.js + * region_tag:netapp_v1_generated_NetApp_UpdateHostGroup_async + */ + async checkUpdateHostGroupProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.netapp.v1.HostGroup, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('updateHostGroup long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateHostGroup, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateHostGroup, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.netapp.v1.HostGroup, + protos.google.cloud.netapp.v1.OperationMetadata + >; } -/** - * Deletes a host group. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the host group. - * Format: - * `projects/{project_number}/locations/{location_id}/hostGroups/{host_group_id}`. - * @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.delete_host_group.js - * region_tag:netapp_v1_generated_NetApp_DeleteHostGroup_async - */ + /** + * Deletes a host group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the host group. + * Format: + * `projects/{project_number}/locations/{location_id}/hostGroups/{host_group_id}`. + * @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.delete_host_group.js + * region_tag:netapp_v1_generated_NetApp_DeleteHostGroup_async + */ deleteHostGroup( - request?: protos.google.cloud.netapp.v1.IDeleteHostGroupRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.netapp.v1.IDeleteHostGroupRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteHostGroup( - request: protos.google.cloud.netapp.v1.IDeleteHostGroupRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IDeleteHostGroupRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteHostGroup( - request: protos.google.cloud.netapp.v1.IDeleteHostGroupRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.netapp.v1.IDeleteHostGroupRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteHostGroup( - request?: protos.google.cloud.netapp.v1.IDeleteHostGroupRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.netapp.v1.IDeleteHostGroupRequest, + 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 { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteHostGroup response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteHostGroup request %j', request); - return this.innerApiCalls.deleteHostGroup(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteHostGroup response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteHostGroup(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteHostGroup response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteHostGroup()`. - * @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.delete_host_group.js - * region_tag:netapp_v1_generated_NetApp_DeleteHostGroup_async - */ - async checkDeleteHostGroupProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteHostGroup()`. + * @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.delete_host_group.js + * region_tag:netapp_v1_generated_NetApp_DeleteHostGroup_async + */ + async checkDeleteHostGroupProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { this._log.info('deleteHostGroup long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteHostGroup, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Returns descriptions of all storage pools owned by the caller. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * @param {string} [request.pageToken] - * Optional. The next_page_token value to use if there are additional - * results to retrieve for this list request. - * @param {string} [request.orderBy] - * Optional. Sort results. Supported values are "name", "name desc" or "" - * (unsorted). - * @param {string} [request.filter] - * Optional. List filter. - * @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 Array of {@link protos.google.cloud.netapp.v1.StoragePool|StoragePool}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listStoragePoolsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteHostGroup, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.netapp.v1.OperationMetadata + >; + } + /** + * Returns descriptions of all storage pools owned by the caller. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * @param {string} [request.pageToken] + * Optional. The next_page_token value to use if there are additional + * results to retrieve for this list request. + * @param {string} [request.orderBy] + * Optional. Sort results. Supported values are "name", "name desc" or "" + * (unsorted). + * @param {string} [request.filter] + * Optional. List filter. + * @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 Array of {@link protos.google.cloud.netapp.v1.StoragePool|StoragePool}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listStoragePoolsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listStoragePools( - request?: protos.google.cloud.netapp.v1.IListStoragePoolsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.netapp.v1.IStoragePool[], - protos.google.cloud.netapp.v1.IListStoragePoolsRequest|null, - protos.google.cloud.netapp.v1.IListStoragePoolsResponse - ]>; + request?: protos.google.cloud.netapp.v1.IListStoragePoolsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.netapp.v1.IStoragePool[], + protos.google.cloud.netapp.v1.IListStoragePoolsRequest | null, + protos.google.cloud.netapp.v1.IListStoragePoolsResponse, + ] + >; listStoragePools( - request: protos.google.cloud.netapp.v1.IListStoragePoolsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.netapp.v1.IListStoragePoolsRequest, - protos.google.cloud.netapp.v1.IListStoragePoolsResponse|null|undefined, - protos.google.cloud.netapp.v1.IStoragePool>): void; + request: protos.google.cloud.netapp.v1.IListStoragePoolsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.netapp.v1.IListStoragePoolsRequest, + | protos.google.cloud.netapp.v1.IListStoragePoolsResponse + | null + | undefined, + protos.google.cloud.netapp.v1.IStoragePool + >, + ): void; listStoragePools( - request: protos.google.cloud.netapp.v1.IListStoragePoolsRequest, - callback: PaginationCallback< - protos.google.cloud.netapp.v1.IListStoragePoolsRequest, - protos.google.cloud.netapp.v1.IListStoragePoolsResponse|null|undefined, - protos.google.cloud.netapp.v1.IStoragePool>): void; + request: protos.google.cloud.netapp.v1.IListStoragePoolsRequest, + callback: PaginationCallback< + protos.google.cloud.netapp.v1.IListStoragePoolsRequest, + | protos.google.cloud.netapp.v1.IListStoragePoolsResponse + | null + | undefined, + protos.google.cloud.netapp.v1.IStoragePool + >, + ): void; listStoragePools( - request?: protos.google.cloud.netapp.v1.IListStoragePoolsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.netapp.v1.IListStoragePoolsRequest, - protos.google.cloud.netapp.v1.IListStoragePoolsResponse|null|undefined, - protos.google.cloud.netapp.v1.IStoragePool>, - callback?: PaginationCallback< + request?: protos.google.cloud.netapp.v1.IListStoragePoolsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.netapp.v1.IListStoragePoolsRequest, - protos.google.cloud.netapp.v1.IListStoragePoolsResponse|null|undefined, - protos.google.cloud.netapp.v1.IStoragePool>): - Promise<[ - protos.google.cloud.netapp.v1.IStoragePool[], - protos.google.cloud.netapp.v1.IListStoragePoolsRequest|null, - protos.google.cloud.netapp.v1.IListStoragePoolsResponse - ]>|void { + | protos.google.cloud.netapp.v1.IListStoragePoolsResponse + | null + | undefined, + protos.google.cloud.netapp.v1.IStoragePool + >, + callback?: PaginationCallback< + protos.google.cloud.netapp.v1.IListStoragePoolsRequest, + | protos.google.cloud.netapp.v1.IListStoragePoolsResponse + | null + | undefined, + protos.google.cloud.netapp.v1.IStoragePool + >, + ): Promise< + [ + protos.google.cloud.netapp.v1.IStoragePool[], + protos.google.cloud.netapp.v1.IListStoragePoolsRequest | null, + protos.google.cloud.netapp.v1.IListStoragePoolsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.netapp.v1.IListStoragePoolsRequest, - protos.google.cloud.netapp.v1.IListStoragePoolsResponse|null|undefined, - protos.google.cloud.netapp.v1.IStoragePool>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.netapp.v1.IListStoragePoolsRequest, + | protos.google.cloud.netapp.v1.IListStoragePoolsResponse + | null + | undefined, + protos.google.cloud.netapp.v1.IStoragePool + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listStoragePools values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -7341,206 +10978,225 @@ export class NetAppClient { this._log.info('listStoragePools request %j', request); return this.innerApiCalls .listStoragePools(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.netapp.v1.IStoragePool[], - protos.google.cloud.netapp.v1.IListStoragePoolsRequest|null, - protos.google.cloud.netapp.v1.IListStoragePoolsResponse - ]) => { - this._log.info('listStoragePools values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.netapp.v1.IStoragePool[], + protos.google.cloud.netapp.v1.IListStoragePoolsRequest | null, + protos.google.cloud.netapp.v1.IListStoragePoolsResponse, + ]) => { + this._log.info('listStoragePools values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listStoragePools`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * @param {string} [request.pageToken] - * Optional. The next_page_token value to use if there are additional - * results to retrieve for this list request. - * @param {string} [request.orderBy] - * Optional. Sort results. Supported values are "name", "name desc" or "" - * (unsorted). - * @param {string} [request.filter] - * Optional. List filter. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.netapp.v1.StoragePool|StoragePool} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listStoragePoolsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listStoragePools`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * @param {string} [request.pageToken] + * Optional. The next_page_token value to use if there are additional + * results to retrieve for this list request. + * @param {string} [request.orderBy] + * Optional. Sort results. Supported values are "name", "name desc" or "" + * (unsorted). + * @param {string} [request.filter] + * Optional. List filter. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.netapp.v1.StoragePool|StoragePool} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listStoragePoolsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listStoragePoolsStream( - request?: protos.google.cloud.netapp.v1.IListStoragePoolsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.netapp.v1.IListStoragePoolsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listStoragePools']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listStoragePools stream %j', request); return this.descriptors.page.listStoragePools.createStream( this.innerApiCalls.listStoragePools as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listStoragePools`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * @param {string} [request.pageToken] - * Optional. The next_page_token value to use if there are additional - * results to retrieve for this list request. - * @param {string} [request.orderBy] - * Optional. Sort results. Supported values are "name", "name desc" or "" - * (unsorted). - * @param {string} [request.filter] - * Optional. List filter. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.netapp.v1.StoragePool|StoragePool}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/net_app.list_storage_pools.js - * region_tag:netapp_v1_generated_NetApp_ListStoragePools_async - */ + /** + * Equivalent to `listStoragePools`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * @param {string} [request.pageToken] + * Optional. The next_page_token value to use if there are additional + * results to retrieve for this list request. + * @param {string} [request.orderBy] + * Optional. Sort results. Supported values are "name", "name desc" or "" + * (unsorted). + * @param {string} [request.filter] + * Optional. List filter. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.netapp.v1.StoragePool|StoragePool}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/net_app.list_storage_pools.js + * region_tag:netapp_v1_generated_NetApp_ListStoragePools_async + */ listStoragePoolsAsync( - request?: protos.google.cloud.netapp.v1.IListStoragePoolsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.netapp.v1.IListStoragePoolsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listStoragePools']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listStoragePools iterate %j', request); return this.descriptors.page.listStoragePools.asyncIterate( this.innerApiCalls['listStoragePools'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists Volumes in a given project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListVolumesRequest - * @param {number} request.pageSize - * Requested page size. Server may return fewer items than requested. - * If unspecified, the server will pick an appropriate default. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. - * @param {string} request.filter - * Filtering results - * @param {string} request.orderBy - * Hint for how to order the results - * @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 Array of {@link protos.google.cloud.netapp.v1.Volume|Volume}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listVolumesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists Volumes in a given project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListVolumesRequest + * @param {number} request.pageSize + * Requested page size. Server may return fewer items than requested. + * If unspecified, the server will pick an appropriate default. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. + * @param {string} request.filter + * Filtering results + * @param {string} request.orderBy + * Hint for how to order the results + * @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 Array of {@link protos.google.cloud.netapp.v1.Volume|Volume}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listVolumesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listVolumes( - request?: protos.google.cloud.netapp.v1.IListVolumesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.netapp.v1.IVolume[], - protos.google.cloud.netapp.v1.IListVolumesRequest|null, - protos.google.cloud.netapp.v1.IListVolumesResponse - ]>; + request?: protos.google.cloud.netapp.v1.IListVolumesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.netapp.v1.IVolume[], + protos.google.cloud.netapp.v1.IListVolumesRequest | null, + protos.google.cloud.netapp.v1.IListVolumesResponse, + ] + >; listVolumes( - request: protos.google.cloud.netapp.v1.IListVolumesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.netapp.v1.IListVolumesRequest, - protos.google.cloud.netapp.v1.IListVolumesResponse|null|undefined, - protos.google.cloud.netapp.v1.IVolume>): void; + request: protos.google.cloud.netapp.v1.IListVolumesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.netapp.v1.IListVolumesRequest, + protos.google.cloud.netapp.v1.IListVolumesResponse | null | undefined, + protos.google.cloud.netapp.v1.IVolume + >, + ): void; listVolumes( - request: protos.google.cloud.netapp.v1.IListVolumesRequest, - callback: PaginationCallback< - protos.google.cloud.netapp.v1.IListVolumesRequest, - protos.google.cloud.netapp.v1.IListVolumesResponse|null|undefined, - protos.google.cloud.netapp.v1.IVolume>): void; + request: protos.google.cloud.netapp.v1.IListVolumesRequest, + callback: PaginationCallback< + protos.google.cloud.netapp.v1.IListVolumesRequest, + protos.google.cloud.netapp.v1.IListVolumesResponse | null | undefined, + protos.google.cloud.netapp.v1.IVolume + >, + ): void; listVolumes( - request?: protos.google.cloud.netapp.v1.IListVolumesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.netapp.v1.IListVolumesRequest, - protos.google.cloud.netapp.v1.IListVolumesResponse|null|undefined, - protos.google.cloud.netapp.v1.IVolume>, - callback?: PaginationCallback< + request?: protos.google.cloud.netapp.v1.IListVolumesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.netapp.v1.IListVolumesRequest, - protos.google.cloud.netapp.v1.IListVolumesResponse|null|undefined, - protos.google.cloud.netapp.v1.IVolume>): - Promise<[ - protos.google.cloud.netapp.v1.IVolume[], - protos.google.cloud.netapp.v1.IListVolumesRequest|null, - protos.google.cloud.netapp.v1.IListVolumesResponse - ]>|void { + protos.google.cloud.netapp.v1.IListVolumesResponse | null | undefined, + protos.google.cloud.netapp.v1.IVolume + >, + callback?: PaginationCallback< + protos.google.cloud.netapp.v1.IListVolumesRequest, + protos.google.cloud.netapp.v1.IListVolumesResponse | null | undefined, + protos.google.cloud.netapp.v1.IVolume + >, + ): Promise< + [ + protos.google.cloud.netapp.v1.IVolume[], + protos.google.cloud.netapp.v1.IListVolumesRequest | null, + protos.google.cloud.netapp.v1.IListVolumesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.netapp.v1.IListVolumesRequest, - protos.google.cloud.netapp.v1.IListVolumesResponse|null|undefined, - protos.google.cloud.netapp.v1.IVolume>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.netapp.v1.IListVolumesRequest, + protos.google.cloud.netapp.v1.IListVolumesResponse | null | undefined, + protos.google.cloud.netapp.v1.IVolume + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listVolumes values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -7549,206 +11205,229 @@ export class NetAppClient { this._log.info('listVolumes request %j', request); return this.innerApiCalls .listVolumes(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.netapp.v1.IVolume[], - protos.google.cloud.netapp.v1.IListVolumesRequest|null, - protos.google.cloud.netapp.v1.IListVolumesResponse - ]) => { - this._log.info('listVolumes values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.netapp.v1.IVolume[], + protos.google.cloud.netapp.v1.IListVolumesRequest | null, + protos.google.cloud.netapp.v1.IListVolumesResponse, + ]) => { + this._log.info('listVolumes values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listVolumes`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListVolumesRequest - * @param {number} request.pageSize - * Requested page size. Server may return fewer items than requested. - * If unspecified, the server will pick an appropriate default. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. - * @param {string} request.filter - * Filtering results - * @param {string} request.orderBy - * Hint for how to order the results - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.netapp.v1.Volume|Volume} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listVolumesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listVolumes`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListVolumesRequest + * @param {number} request.pageSize + * Requested page size. Server may return fewer items than requested. + * If unspecified, the server will pick an appropriate default. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. + * @param {string} request.filter + * Filtering results + * @param {string} request.orderBy + * Hint for how to order the results + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.netapp.v1.Volume|Volume} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listVolumesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listVolumesStream( - request?: protos.google.cloud.netapp.v1.IListVolumesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.netapp.v1.IListVolumesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listVolumes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listVolumes stream %j', request); return this.descriptors.page.listVolumes.createStream( this.innerApiCalls.listVolumes as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listVolumes`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListVolumesRequest - * @param {number} request.pageSize - * Requested page size. Server may return fewer items than requested. - * If unspecified, the server will pick an appropriate default. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. - * @param {string} request.filter - * Filtering results - * @param {string} request.orderBy - * Hint for how to order the results - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.netapp.v1.Volume|Volume}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/net_app.list_volumes.js - * region_tag:netapp_v1_generated_NetApp_ListVolumes_async - */ + /** + * Equivalent to `listVolumes`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListVolumesRequest + * @param {number} request.pageSize + * Requested page size. Server may return fewer items than requested. + * If unspecified, the server will pick an appropriate default. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. + * @param {string} request.filter + * Filtering results + * @param {string} request.orderBy + * Hint for how to order the results + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.netapp.v1.Volume|Volume}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/net_app.list_volumes.js + * region_tag:netapp_v1_generated_NetApp_ListVolumes_async + */ listVolumesAsync( - request?: protos.google.cloud.netapp.v1.IListVolumesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.netapp.v1.IListVolumesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listVolumes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listVolumes iterate %j', request); return this.descriptors.page.listVolumes.asyncIterate( this.innerApiCalls['listVolumes'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Returns descriptions of all snapshots for a volume. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The volume for which to retrieve snapshot information, - * in the format - * `projects/{project_id}/locations/{location}/volumes/{volume_id}`. - * @param {number} request.pageSize - * The maximum number of items to return. - * @param {string} request.pageToken - * The next_page_token value to use if there are additional - * results to retrieve for this list request. - * @param {string} request.orderBy - * Sort results. Supported values are "name", "name desc" or "" (unsorted). - * @param {string} request.filter - * List filter. - * @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 Array of {@link protos.google.cloud.netapp.v1.Snapshot|Snapshot}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listSnapshotsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Returns descriptions of all snapshots for a volume. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The volume for which to retrieve snapshot information, + * in the format + * `projects/{project_id}/locations/{location}/volumes/{volume_id}`. + * @param {number} request.pageSize + * The maximum number of items to return. + * @param {string} request.pageToken + * The next_page_token value to use if there are additional + * results to retrieve for this list request. + * @param {string} request.orderBy + * Sort results. Supported values are "name", "name desc" or "" (unsorted). + * @param {string} request.filter + * List filter. + * @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 Array of {@link protos.google.cloud.netapp.v1.Snapshot|Snapshot}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listSnapshotsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listSnapshots( - request?: protos.google.cloud.netapp.v1.IListSnapshotsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.netapp.v1.ISnapshot[], - protos.google.cloud.netapp.v1.IListSnapshotsRequest|null, - protos.google.cloud.netapp.v1.IListSnapshotsResponse - ]>; + request?: protos.google.cloud.netapp.v1.IListSnapshotsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.netapp.v1.ISnapshot[], + protos.google.cloud.netapp.v1.IListSnapshotsRequest | null, + protos.google.cloud.netapp.v1.IListSnapshotsResponse, + ] + >; listSnapshots( - request: protos.google.cloud.netapp.v1.IListSnapshotsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.netapp.v1.IListSnapshotsRequest, - protos.google.cloud.netapp.v1.IListSnapshotsResponse|null|undefined, - protos.google.cloud.netapp.v1.ISnapshot>): void; + request: protos.google.cloud.netapp.v1.IListSnapshotsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.netapp.v1.IListSnapshotsRequest, + protos.google.cloud.netapp.v1.IListSnapshotsResponse | null | undefined, + protos.google.cloud.netapp.v1.ISnapshot + >, + ): void; listSnapshots( - request: protos.google.cloud.netapp.v1.IListSnapshotsRequest, - callback: PaginationCallback< - protos.google.cloud.netapp.v1.IListSnapshotsRequest, - protos.google.cloud.netapp.v1.IListSnapshotsResponse|null|undefined, - protos.google.cloud.netapp.v1.ISnapshot>): void; + request: protos.google.cloud.netapp.v1.IListSnapshotsRequest, + callback: PaginationCallback< + protos.google.cloud.netapp.v1.IListSnapshotsRequest, + protos.google.cloud.netapp.v1.IListSnapshotsResponse | null | undefined, + protos.google.cloud.netapp.v1.ISnapshot + >, + ): void; listSnapshots( - request?: protos.google.cloud.netapp.v1.IListSnapshotsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.netapp.v1.IListSnapshotsRequest, - protos.google.cloud.netapp.v1.IListSnapshotsResponse|null|undefined, - protos.google.cloud.netapp.v1.ISnapshot>, - callback?: PaginationCallback< + request?: protos.google.cloud.netapp.v1.IListSnapshotsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.netapp.v1.IListSnapshotsRequest, - protos.google.cloud.netapp.v1.IListSnapshotsResponse|null|undefined, - protos.google.cloud.netapp.v1.ISnapshot>): - Promise<[ - protos.google.cloud.netapp.v1.ISnapshot[], - protos.google.cloud.netapp.v1.IListSnapshotsRequest|null, - protos.google.cloud.netapp.v1.IListSnapshotsResponse - ]>|void { + | protos.google.cloud.netapp.v1.IListSnapshotsResponse + | null + | undefined, + protos.google.cloud.netapp.v1.ISnapshot + >, + callback?: PaginationCallback< + protos.google.cloud.netapp.v1.IListSnapshotsRequest, + protos.google.cloud.netapp.v1.IListSnapshotsResponse | null | undefined, + protos.google.cloud.netapp.v1.ISnapshot + >, + ): Promise< + [ + protos.google.cloud.netapp.v1.ISnapshot[], + protos.google.cloud.netapp.v1.IListSnapshotsRequest | null, + protos.google.cloud.netapp.v1.IListSnapshotsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.netapp.v1.IListSnapshotsRequest, - protos.google.cloud.netapp.v1.IListSnapshotsResponse|null|undefined, - protos.google.cloud.netapp.v1.ISnapshot>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.netapp.v1.IListSnapshotsRequest, + | protos.google.cloud.netapp.v1.IListSnapshotsResponse + | null + | undefined, + protos.google.cloud.netapp.v1.ISnapshot + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listSnapshots values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -7757,208 +11436,237 @@ export class NetAppClient { this._log.info('listSnapshots request %j', request); return this.innerApiCalls .listSnapshots(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.netapp.v1.ISnapshot[], - protos.google.cloud.netapp.v1.IListSnapshotsRequest|null, - protos.google.cloud.netapp.v1.IListSnapshotsResponse - ]) => { - this._log.info('listSnapshots values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.netapp.v1.ISnapshot[], + protos.google.cloud.netapp.v1.IListSnapshotsRequest | null, + protos.google.cloud.netapp.v1.IListSnapshotsResponse, + ]) => { + this._log.info('listSnapshots values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listSnapshots`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The volume for which to retrieve snapshot information, - * in the format - * `projects/{project_id}/locations/{location}/volumes/{volume_id}`. - * @param {number} request.pageSize - * The maximum number of items to return. - * @param {string} request.pageToken - * The next_page_token value to use if there are additional - * results to retrieve for this list request. - * @param {string} request.orderBy - * Sort results. Supported values are "name", "name desc" or "" (unsorted). - * @param {string} request.filter - * List filter. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.netapp.v1.Snapshot|Snapshot} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listSnapshotsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listSnapshots`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The volume for which to retrieve snapshot information, + * in the format + * `projects/{project_id}/locations/{location}/volumes/{volume_id}`. + * @param {number} request.pageSize + * The maximum number of items to return. + * @param {string} request.pageToken + * The next_page_token value to use if there are additional + * results to retrieve for this list request. + * @param {string} request.orderBy + * Sort results. Supported values are "name", "name desc" or "" (unsorted). + * @param {string} request.filter + * List filter. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.netapp.v1.Snapshot|Snapshot} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listSnapshotsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listSnapshotsStream( - request?: protos.google.cloud.netapp.v1.IListSnapshotsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.netapp.v1.IListSnapshotsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listSnapshots']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listSnapshots stream %j', request); return this.descriptors.page.listSnapshots.createStream( this.innerApiCalls.listSnapshots as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listSnapshots`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The volume for which to retrieve snapshot information, - * in the format - * `projects/{project_id}/locations/{location}/volumes/{volume_id}`. - * @param {number} request.pageSize - * The maximum number of items to return. - * @param {string} request.pageToken - * The next_page_token value to use if there are additional - * results to retrieve for this list request. - * @param {string} request.orderBy - * Sort results. Supported values are "name", "name desc" or "" (unsorted). - * @param {string} request.filter - * List filter. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.netapp.v1.Snapshot|Snapshot}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/net_app.list_snapshots.js - * region_tag:netapp_v1_generated_NetApp_ListSnapshots_async - */ + /** + * Equivalent to `listSnapshots`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The volume for which to retrieve snapshot information, + * in the format + * `projects/{project_id}/locations/{location}/volumes/{volume_id}`. + * @param {number} request.pageSize + * The maximum number of items to return. + * @param {string} request.pageToken + * The next_page_token value to use if there are additional + * results to retrieve for this list request. + * @param {string} request.orderBy + * Sort results. Supported values are "name", "name desc" or "" (unsorted). + * @param {string} request.filter + * List filter. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.netapp.v1.Snapshot|Snapshot}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/net_app.list_snapshots.js + * region_tag:netapp_v1_generated_NetApp_ListSnapshots_async + */ listSnapshotsAsync( - request?: protos.google.cloud.netapp.v1.IListSnapshotsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.netapp.v1.IListSnapshotsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listSnapshots']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listSnapshots iterate %j', request); return this.descriptors.page.listSnapshots.asyncIterate( this.innerApiCalls['listSnapshots'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists active directories. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListActiveDirectoriesRequest - * @param {number} request.pageSize - * Requested page size. Server may return fewer items than requested. - * If unspecified, the server will pick an appropriate default. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. - * @param {string} request.filter - * Filtering results - * @param {string} request.orderBy - * Hint for how to order the results - * @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 Array of {@link protos.google.cloud.netapp.v1.ActiveDirectory|ActiveDirectory}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listActiveDirectoriesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists active directories. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListActiveDirectoriesRequest + * @param {number} request.pageSize + * Requested page size. Server may return fewer items than requested. + * If unspecified, the server will pick an appropriate default. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. + * @param {string} request.filter + * Filtering results + * @param {string} request.orderBy + * Hint for how to order the results + * @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 Array of {@link protos.google.cloud.netapp.v1.ActiveDirectory|ActiveDirectory}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listActiveDirectoriesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listActiveDirectories( - request?: protos.google.cloud.netapp.v1.IListActiveDirectoriesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.netapp.v1.IActiveDirectory[], - protos.google.cloud.netapp.v1.IListActiveDirectoriesRequest|null, - protos.google.cloud.netapp.v1.IListActiveDirectoriesResponse - ]>; + request?: protos.google.cloud.netapp.v1.IListActiveDirectoriesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.netapp.v1.IActiveDirectory[], + protos.google.cloud.netapp.v1.IListActiveDirectoriesRequest | null, + protos.google.cloud.netapp.v1.IListActiveDirectoriesResponse, + ] + >; listActiveDirectories( - request: protos.google.cloud.netapp.v1.IListActiveDirectoriesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.netapp.v1.IListActiveDirectoriesRequest, - protos.google.cloud.netapp.v1.IListActiveDirectoriesResponse|null|undefined, - protos.google.cloud.netapp.v1.IActiveDirectory>): void; + request: protos.google.cloud.netapp.v1.IListActiveDirectoriesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.netapp.v1.IListActiveDirectoriesRequest, + | protos.google.cloud.netapp.v1.IListActiveDirectoriesResponse + | null + | undefined, + protos.google.cloud.netapp.v1.IActiveDirectory + >, + ): void; listActiveDirectories( - request: protos.google.cloud.netapp.v1.IListActiveDirectoriesRequest, - callback: PaginationCallback< - protos.google.cloud.netapp.v1.IListActiveDirectoriesRequest, - protos.google.cloud.netapp.v1.IListActiveDirectoriesResponse|null|undefined, - protos.google.cloud.netapp.v1.IActiveDirectory>): void; + request: protos.google.cloud.netapp.v1.IListActiveDirectoriesRequest, + callback: PaginationCallback< + protos.google.cloud.netapp.v1.IListActiveDirectoriesRequest, + | protos.google.cloud.netapp.v1.IListActiveDirectoriesResponse + | null + | undefined, + protos.google.cloud.netapp.v1.IActiveDirectory + >, + ): void; listActiveDirectories( - request?: protos.google.cloud.netapp.v1.IListActiveDirectoriesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.netapp.v1.IListActiveDirectoriesRequest, - protos.google.cloud.netapp.v1.IListActiveDirectoriesResponse|null|undefined, - protos.google.cloud.netapp.v1.IActiveDirectory>, - callback?: PaginationCallback< + request?: protos.google.cloud.netapp.v1.IListActiveDirectoriesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.netapp.v1.IListActiveDirectoriesRequest, - protos.google.cloud.netapp.v1.IListActiveDirectoriesResponse|null|undefined, - protos.google.cloud.netapp.v1.IActiveDirectory>): - Promise<[ - protos.google.cloud.netapp.v1.IActiveDirectory[], - protos.google.cloud.netapp.v1.IListActiveDirectoriesRequest|null, - protos.google.cloud.netapp.v1.IListActiveDirectoriesResponse - ]>|void { + | protos.google.cloud.netapp.v1.IListActiveDirectoriesResponse + | null + | undefined, + protos.google.cloud.netapp.v1.IActiveDirectory + >, + callback?: PaginationCallback< + protos.google.cloud.netapp.v1.IListActiveDirectoriesRequest, + | protos.google.cloud.netapp.v1.IListActiveDirectoriesResponse + | null + | undefined, + protos.google.cloud.netapp.v1.IActiveDirectory + >, + ): Promise< + [ + protos.google.cloud.netapp.v1.IActiveDirectory[], + protos.google.cloud.netapp.v1.IListActiveDirectoriesRequest | null, + protos.google.cloud.netapp.v1.IListActiveDirectoriesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.netapp.v1.IListActiveDirectoriesRequest, - protos.google.cloud.netapp.v1.IListActiveDirectoriesResponse|null|undefined, - protos.google.cloud.netapp.v1.IActiveDirectory>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.netapp.v1.IListActiveDirectoriesRequest, + | protos.google.cloud.netapp.v1.IListActiveDirectoriesResponse + | null + | undefined, + protos.google.cloud.netapp.v1.IActiveDirectory + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listActiveDirectories values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -7967,204 +11675,227 @@ export class NetAppClient { this._log.info('listActiveDirectories request %j', request); return this.innerApiCalls .listActiveDirectories(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.netapp.v1.IActiveDirectory[], - protos.google.cloud.netapp.v1.IListActiveDirectoriesRequest|null, - protos.google.cloud.netapp.v1.IListActiveDirectoriesResponse - ]) => { - this._log.info('listActiveDirectories values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.netapp.v1.IActiveDirectory[], + protos.google.cloud.netapp.v1.IListActiveDirectoriesRequest | null, + protos.google.cloud.netapp.v1.IListActiveDirectoriesResponse, + ]) => { + this._log.info('listActiveDirectories values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listActiveDirectories`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListActiveDirectoriesRequest - * @param {number} request.pageSize - * Requested page size. Server may return fewer items than requested. - * If unspecified, the server will pick an appropriate default. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. - * @param {string} request.filter - * Filtering results - * @param {string} request.orderBy - * Hint for how to order the results - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.netapp.v1.ActiveDirectory|ActiveDirectory} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listActiveDirectoriesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listActiveDirectories`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListActiveDirectoriesRequest + * @param {number} request.pageSize + * Requested page size. Server may return fewer items than requested. + * If unspecified, the server will pick an appropriate default. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. + * @param {string} request.filter + * Filtering results + * @param {string} request.orderBy + * Hint for how to order the results + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.netapp.v1.ActiveDirectory|ActiveDirectory} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listActiveDirectoriesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listActiveDirectoriesStream( - request?: protos.google.cloud.netapp.v1.IListActiveDirectoriesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.netapp.v1.IListActiveDirectoriesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listActiveDirectories']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listActiveDirectories stream %j', request); return this.descriptors.page.listActiveDirectories.createStream( this.innerApiCalls.listActiveDirectories as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listActiveDirectories`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListActiveDirectoriesRequest - * @param {number} request.pageSize - * Requested page size. Server may return fewer items than requested. - * If unspecified, the server will pick an appropriate default. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. - * @param {string} request.filter - * Filtering results - * @param {string} request.orderBy - * Hint for how to order the results - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.netapp.v1.ActiveDirectory|ActiveDirectory}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/net_app.list_active_directories.js - * region_tag:netapp_v1_generated_NetApp_ListActiveDirectories_async - */ + /** + * Equivalent to `listActiveDirectories`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListActiveDirectoriesRequest + * @param {number} request.pageSize + * Requested page size. Server may return fewer items than requested. + * If unspecified, the server will pick an appropriate default. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. + * @param {string} request.filter + * Filtering results + * @param {string} request.orderBy + * Hint for how to order the results + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.netapp.v1.ActiveDirectory|ActiveDirectory}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/net_app.list_active_directories.js + * region_tag:netapp_v1_generated_NetApp_ListActiveDirectories_async + */ listActiveDirectoriesAsync( - request?: protos.google.cloud.netapp.v1.IListActiveDirectoriesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.netapp.v1.IListActiveDirectoriesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listActiveDirectories']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listActiveDirectories iterate %j', request); return this.descriptors.page.listActiveDirectories.asyncIterate( this.innerApiCalls['listActiveDirectories'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Returns descriptions of all KMS configs owned by the caller. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value - * @param {number} request.pageSize - * The maximum number of items to return. - * @param {string} request.pageToken - * The next_page_token value to use if there are additional - * results to retrieve for this list request. - * @param {string} request.orderBy - * Sort results. Supported values are "name", "name desc" or "" (unsorted). - * @param {string} request.filter - * List filter. - * @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 Array of {@link protos.google.cloud.netapp.v1.KmsConfig|KmsConfig}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listKmsConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Returns descriptions of all KMS configs owned by the caller. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value + * @param {number} request.pageSize + * The maximum number of items to return. + * @param {string} request.pageToken + * The next_page_token value to use if there are additional + * results to retrieve for this list request. + * @param {string} request.orderBy + * Sort results. Supported values are "name", "name desc" or "" (unsorted). + * @param {string} request.filter + * List filter. + * @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 Array of {@link protos.google.cloud.netapp.v1.KmsConfig|KmsConfig}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listKmsConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listKmsConfigs( - request?: protos.google.cloud.netapp.v1.IListKmsConfigsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.netapp.v1.IKmsConfig[], - protos.google.cloud.netapp.v1.IListKmsConfigsRequest|null, - protos.google.cloud.netapp.v1.IListKmsConfigsResponse - ]>; + request?: protos.google.cloud.netapp.v1.IListKmsConfigsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.netapp.v1.IKmsConfig[], + protos.google.cloud.netapp.v1.IListKmsConfigsRequest | null, + protos.google.cloud.netapp.v1.IListKmsConfigsResponse, + ] + >; listKmsConfigs( - request: protos.google.cloud.netapp.v1.IListKmsConfigsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.netapp.v1.IListKmsConfigsRequest, - protos.google.cloud.netapp.v1.IListKmsConfigsResponse|null|undefined, - protos.google.cloud.netapp.v1.IKmsConfig>): void; + request: protos.google.cloud.netapp.v1.IListKmsConfigsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.netapp.v1.IListKmsConfigsRequest, + protos.google.cloud.netapp.v1.IListKmsConfigsResponse | null | undefined, + protos.google.cloud.netapp.v1.IKmsConfig + >, + ): void; listKmsConfigs( - request: protos.google.cloud.netapp.v1.IListKmsConfigsRequest, - callback: PaginationCallback< - protos.google.cloud.netapp.v1.IListKmsConfigsRequest, - protos.google.cloud.netapp.v1.IListKmsConfigsResponse|null|undefined, - protos.google.cloud.netapp.v1.IKmsConfig>): void; + request: protos.google.cloud.netapp.v1.IListKmsConfigsRequest, + callback: PaginationCallback< + protos.google.cloud.netapp.v1.IListKmsConfigsRequest, + protos.google.cloud.netapp.v1.IListKmsConfigsResponse | null | undefined, + protos.google.cloud.netapp.v1.IKmsConfig + >, + ): void; listKmsConfigs( - request?: protos.google.cloud.netapp.v1.IListKmsConfigsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.netapp.v1.IListKmsConfigsRequest, - protos.google.cloud.netapp.v1.IListKmsConfigsResponse|null|undefined, - protos.google.cloud.netapp.v1.IKmsConfig>, - callback?: PaginationCallback< + request?: protos.google.cloud.netapp.v1.IListKmsConfigsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.netapp.v1.IListKmsConfigsRequest, - protos.google.cloud.netapp.v1.IListKmsConfigsResponse|null|undefined, - protos.google.cloud.netapp.v1.IKmsConfig>): - Promise<[ - protos.google.cloud.netapp.v1.IKmsConfig[], - protos.google.cloud.netapp.v1.IListKmsConfigsRequest|null, - protos.google.cloud.netapp.v1.IListKmsConfigsResponse - ]>|void { + | protos.google.cloud.netapp.v1.IListKmsConfigsResponse + | null + | undefined, + protos.google.cloud.netapp.v1.IKmsConfig + >, + callback?: PaginationCallback< + protos.google.cloud.netapp.v1.IListKmsConfigsRequest, + protos.google.cloud.netapp.v1.IListKmsConfigsResponse | null | undefined, + protos.google.cloud.netapp.v1.IKmsConfig + >, + ): Promise< + [ + protos.google.cloud.netapp.v1.IKmsConfig[], + protos.google.cloud.netapp.v1.IListKmsConfigsRequest | null, + protos.google.cloud.netapp.v1.IListKmsConfigsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.netapp.v1.IListKmsConfigsRequest, - protos.google.cloud.netapp.v1.IListKmsConfigsResponse|null|undefined, - protos.google.cloud.netapp.v1.IKmsConfig>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.netapp.v1.IListKmsConfigsRequest, + | protos.google.cloud.netapp.v1.IListKmsConfigsResponse + | null + | undefined, + protos.google.cloud.netapp.v1.IKmsConfig + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listKmsConfigs values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -8173,206 +11904,235 @@ export class NetAppClient { this._log.info('listKmsConfigs request %j', request); return this.innerApiCalls .listKmsConfigs(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.netapp.v1.IKmsConfig[], - protos.google.cloud.netapp.v1.IListKmsConfigsRequest|null, - protos.google.cloud.netapp.v1.IListKmsConfigsResponse - ]) => { - this._log.info('listKmsConfigs values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.netapp.v1.IKmsConfig[], + protos.google.cloud.netapp.v1.IListKmsConfigsRequest | null, + protos.google.cloud.netapp.v1.IListKmsConfigsResponse, + ]) => { + this._log.info('listKmsConfigs values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listKmsConfigs`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value - * @param {number} request.pageSize - * The maximum number of items to return. - * @param {string} request.pageToken - * The next_page_token value to use if there are additional - * results to retrieve for this list request. - * @param {string} request.orderBy - * Sort results. Supported values are "name", "name desc" or "" (unsorted). - * @param {string} request.filter - * List filter. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.netapp.v1.KmsConfig|KmsConfig} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listKmsConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listKmsConfigs`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value + * @param {number} request.pageSize + * The maximum number of items to return. + * @param {string} request.pageToken + * The next_page_token value to use if there are additional + * results to retrieve for this list request. + * @param {string} request.orderBy + * Sort results. Supported values are "name", "name desc" or "" (unsorted). + * @param {string} request.filter + * List filter. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.netapp.v1.KmsConfig|KmsConfig} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listKmsConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listKmsConfigsStream( - request?: protos.google.cloud.netapp.v1.IListKmsConfigsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.netapp.v1.IListKmsConfigsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listKmsConfigs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listKmsConfigs stream %j', request); return this.descriptors.page.listKmsConfigs.createStream( this.innerApiCalls.listKmsConfigs as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listKmsConfigs`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value - * @param {number} request.pageSize - * The maximum number of items to return. - * @param {string} request.pageToken - * The next_page_token value to use if there are additional - * results to retrieve for this list request. - * @param {string} request.orderBy - * Sort results. Supported values are "name", "name desc" or "" (unsorted). - * @param {string} request.filter - * List filter. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.netapp.v1.KmsConfig|KmsConfig}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/net_app.list_kms_configs.js - * region_tag:netapp_v1_generated_NetApp_ListKmsConfigs_async - */ + /** + * Equivalent to `listKmsConfigs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value + * @param {number} request.pageSize + * The maximum number of items to return. + * @param {string} request.pageToken + * The next_page_token value to use if there are additional + * results to retrieve for this list request. + * @param {string} request.orderBy + * Sort results. Supported values are "name", "name desc" or "" (unsorted). + * @param {string} request.filter + * List filter. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.netapp.v1.KmsConfig|KmsConfig}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/net_app.list_kms_configs.js + * region_tag:netapp_v1_generated_NetApp_ListKmsConfigs_async + */ listKmsConfigsAsync( - request?: protos.google.cloud.netapp.v1.IListKmsConfigsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.netapp.v1.IListKmsConfigsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listKmsConfigs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listKmsConfigs iterate %j', request); return this.descriptors.page.listKmsConfigs.asyncIterate( this.innerApiCalls['listKmsConfigs'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Returns descriptions of all replications for a volume. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The volume for which to retrieve replication information, - * in the format - * `projects/{project_id}/locations/{location}/volumes/{volume_id}`. - * @param {number} request.pageSize - * The maximum number of items to return. - * @param {string} request.pageToken - * The next_page_token value to use if there are additional - * results to retrieve for this list request. - * @param {string} request.orderBy - * Sort results. Supported values are "name", "name desc" or "" (unsorted). - * @param {string} request.filter - * List filter. - * @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 Array of {@link protos.google.cloud.netapp.v1.Replication|Replication}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listReplicationsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Returns descriptions of all replications for a volume. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The volume for which to retrieve replication information, + * in the format + * `projects/{project_id}/locations/{location}/volumes/{volume_id}`. + * @param {number} request.pageSize + * The maximum number of items to return. + * @param {string} request.pageToken + * The next_page_token value to use if there are additional + * results to retrieve for this list request. + * @param {string} request.orderBy + * Sort results. Supported values are "name", "name desc" or "" (unsorted). + * @param {string} request.filter + * List filter. + * @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 Array of {@link protos.google.cloud.netapp.v1.Replication|Replication}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listReplicationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listReplications( - request?: protos.google.cloud.netapp.v1.IListReplicationsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.netapp.v1.IReplication[], - protos.google.cloud.netapp.v1.IListReplicationsRequest|null, - protos.google.cloud.netapp.v1.IListReplicationsResponse - ]>; + request?: protos.google.cloud.netapp.v1.IListReplicationsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.netapp.v1.IReplication[], + protos.google.cloud.netapp.v1.IListReplicationsRequest | null, + protos.google.cloud.netapp.v1.IListReplicationsResponse, + ] + >; listReplications( - request: protos.google.cloud.netapp.v1.IListReplicationsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.netapp.v1.IListReplicationsRequest, - protos.google.cloud.netapp.v1.IListReplicationsResponse|null|undefined, - protos.google.cloud.netapp.v1.IReplication>): void; + request: protos.google.cloud.netapp.v1.IListReplicationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.netapp.v1.IListReplicationsRequest, + | protos.google.cloud.netapp.v1.IListReplicationsResponse + | null + | undefined, + protos.google.cloud.netapp.v1.IReplication + >, + ): void; listReplications( - request: protos.google.cloud.netapp.v1.IListReplicationsRequest, - callback: PaginationCallback< - protos.google.cloud.netapp.v1.IListReplicationsRequest, - protos.google.cloud.netapp.v1.IListReplicationsResponse|null|undefined, - protos.google.cloud.netapp.v1.IReplication>): void; + request: protos.google.cloud.netapp.v1.IListReplicationsRequest, + callback: PaginationCallback< + protos.google.cloud.netapp.v1.IListReplicationsRequest, + | protos.google.cloud.netapp.v1.IListReplicationsResponse + | null + | undefined, + protos.google.cloud.netapp.v1.IReplication + >, + ): void; listReplications( - request?: protos.google.cloud.netapp.v1.IListReplicationsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.netapp.v1.IListReplicationsRequest, - protos.google.cloud.netapp.v1.IListReplicationsResponse|null|undefined, - protos.google.cloud.netapp.v1.IReplication>, - callback?: PaginationCallback< + request?: protos.google.cloud.netapp.v1.IListReplicationsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.netapp.v1.IListReplicationsRequest, - protos.google.cloud.netapp.v1.IListReplicationsResponse|null|undefined, - protos.google.cloud.netapp.v1.IReplication>): - Promise<[ - protos.google.cloud.netapp.v1.IReplication[], - protos.google.cloud.netapp.v1.IListReplicationsRequest|null, - protos.google.cloud.netapp.v1.IListReplicationsResponse - ]>|void { + | protos.google.cloud.netapp.v1.IListReplicationsResponse + | null + | undefined, + protos.google.cloud.netapp.v1.IReplication + >, + callback?: PaginationCallback< + protos.google.cloud.netapp.v1.IListReplicationsRequest, + | protos.google.cloud.netapp.v1.IListReplicationsResponse + | null + | undefined, + protos.google.cloud.netapp.v1.IReplication + >, + ): Promise< + [ + protos.google.cloud.netapp.v1.IReplication[], + protos.google.cloud.netapp.v1.IListReplicationsRequest | null, + protos.google.cloud.netapp.v1.IListReplicationsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.netapp.v1.IListReplicationsRequest, - protos.google.cloud.netapp.v1.IListReplicationsResponse|null|undefined, - protos.google.cloud.netapp.v1.IReplication>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.netapp.v1.IListReplicationsRequest, + | protos.google.cloud.netapp.v1.IListReplicationsResponse + | null + | undefined, + protos.google.cloud.netapp.v1.IReplication + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listReplications values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -8381,210 +12141,239 @@ export class NetAppClient { this._log.info('listReplications request %j', request); return this.innerApiCalls .listReplications(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.netapp.v1.IReplication[], - protos.google.cloud.netapp.v1.IListReplicationsRequest|null, - protos.google.cloud.netapp.v1.IListReplicationsResponse - ]) => { - this._log.info('listReplications values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.netapp.v1.IReplication[], + protos.google.cloud.netapp.v1.IListReplicationsRequest | null, + protos.google.cloud.netapp.v1.IListReplicationsResponse, + ]) => { + this._log.info('listReplications values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listReplications`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The volume for which to retrieve replication information, - * in the format - * `projects/{project_id}/locations/{location}/volumes/{volume_id}`. - * @param {number} request.pageSize - * The maximum number of items to return. - * @param {string} request.pageToken - * The next_page_token value to use if there are additional - * results to retrieve for this list request. - * @param {string} request.orderBy - * Sort results. Supported values are "name", "name desc" or "" (unsorted). - * @param {string} request.filter - * List filter. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.netapp.v1.Replication|Replication} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listReplicationsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listReplications`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The volume for which to retrieve replication information, + * in the format + * `projects/{project_id}/locations/{location}/volumes/{volume_id}`. + * @param {number} request.pageSize + * The maximum number of items to return. + * @param {string} request.pageToken + * The next_page_token value to use if there are additional + * results to retrieve for this list request. + * @param {string} request.orderBy + * Sort results. Supported values are "name", "name desc" or "" (unsorted). + * @param {string} request.filter + * List filter. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.netapp.v1.Replication|Replication} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listReplicationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listReplicationsStream( - request?: protos.google.cloud.netapp.v1.IListReplicationsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.netapp.v1.IListReplicationsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listReplications']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listReplications stream %j', request); return this.descriptors.page.listReplications.createStream( this.innerApiCalls.listReplications as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listReplications`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The volume for which to retrieve replication information, - * in the format - * `projects/{project_id}/locations/{location}/volumes/{volume_id}`. - * @param {number} request.pageSize - * The maximum number of items to return. - * @param {string} request.pageToken - * The next_page_token value to use if there are additional - * results to retrieve for this list request. - * @param {string} request.orderBy - * Sort results. Supported values are "name", "name desc" or "" (unsorted). - * @param {string} request.filter - * List filter. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.netapp.v1.Replication|Replication}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/net_app.list_replications.js - * region_tag:netapp_v1_generated_NetApp_ListReplications_async - */ + /** + * Equivalent to `listReplications`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The volume for which to retrieve replication information, + * in the format + * `projects/{project_id}/locations/{location}/volumes/{volume_id}`. + * @param {number} request.pageSize + * The maximum number of items to return. + * @param {string} request.pageToken + * The next_page_token value to use if there are additional + * results to retrieve for this list request. + * @param {string} request.orderBy + * Sort results. Supported values are "name", "name desc" or "" (unsorted). + * @param {string} request.filter + * List filter. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.netapp.v1.Replication|Replication}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/net_app.list_replications.js + * region_tag:netapp_v1_generated_NetApp_ListReplications_async + */ listReplicationsAsync( - request?: protos.google.cloud.netapp.v1.IListReplicationsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.netapp.v1.IListReplicationsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listReplications']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listReplications iterate %j', request); return this.descriptors.page.listReplications.asyncIterate( this.innerApiCalls['listReplications'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Returns list of all available backup vaults. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location for which to retrieve backupVault information, - * in the format - * `projects/{project_id}/locations/{location}`. - * @param {number} request.pageSize - * The maximum number of items to return. - * @param {string} request.pageToken - * The next_page_token value to use if there are additional - * results to retrieve for this list request. - * @param {string} request.orderBy - * Sort results. Supported values are "name", "name desc" or "" (unsorted). - * @param {string} request.filter - * List filter. - * @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 Array of {@link protos.google.cloud.netapp.v1.BackupVault|BackupVault}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listBackupVaultsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Returns list of all available backup vaults. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location for which to retrieve backupVault information, + * in the format + * `projects/{project_id}/locations/{location}`. + * @param {number} request.pageSize + * The maximum number of items to return. + * @param {string} request.pageToken + * The next_page_token value to use if there are additional + * results to retrieve for this list request. + * @param {string} request.orderBy + * Sort results. Supported values are "name", "name desc" or "" (unsorted). + * @param {string} request.filter + * List filter. + * @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 Array of {@link protos.google.cloud.netapp.v1.BackupVault|BackupVault}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listBackupVaultsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listBackupVaults( - request?: protos.google.cloud.netapp.v1.IListBackupVaultsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.netapp.v1.IBackupVault[], - protos.google.cloud.netapp.v1.IListBackupVaultsRequest|null, - protos.google.cloud.netapp.v1.IListBackupVaultsResponse - ]>; + request?: protos.google.cloud.netapp.v1.IListBackupVaultsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.netapp.v1.IBackupVault[], + protos.google.cloud.netapp.v1.IListBackupVaultsRequest | null, + protos.google.cloud.netapp.v1.IListBackupVaultsResponse, + ] + >; listBackupVaults( - request: protos.google.cloud.netapp.v1.IListBackupVaultsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.netapp.v1.IListBackupVaultsRequest, - protos.google.cloud.netapp.v1.IListBackupVaultsResponse|null|undefined, - protos.google.cloud.netapp.v1.IBackupVault>): void; + request: protos.google.cloud.netapp.v1.IListBackupVaultsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.netapp.v1.IListBackupVaultsRequest, + | protos.google.cloud.netapp.v1.IListBackupVaultsResponse + | null + | undefined, + protos.google.cloud.netapp.v1.IBackupVault + >, + ): void; listBackupVaults( - request: protos.google.cloud.netapp.v1.IListBackupVaultsRequest, - callback: PaginationCallback< - protos.google.cloud.netapp.v1.IListBackupVaultsRequest, - protos.google.cloud.netapp.v1.IListBackupVaultsResponse|null|undefined, - protos.google.cloud.netapp.v1.IBackupVault>): void; + request: protos.google.cloud.netapp.v1.IListBackupVaultsRequest, + callback: PaginationCallback< + protos.google.cloud.netapp.v1.IListBackupVaultsRequest, + | protos.google.cloud.netapp.v1.IListBackupVaultsResponse + | null + | undefined, + protos.google.cloud.netapp.v1.IBackupVault + >, + ): void; listBackupVaults( - request?: protos.google.cloud.netapp.v1.IListBackupVaultsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.netapp.v1.IListBackupVaultsRequest, - protos.google.cloud.netapp.v1.IListBackupVaultsResponse|null|undefined, - protos.google.cloud.netapp.v1.IBackupVault>, - callback?: PaginationCallback< + request?: protos.google.cloud.netapp.v1.IListBackupVaultsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.netapp.v1.IListBackupVaultsRequest, - protos.google.cloud.netapp.v1.IListBackupVaultsResponse|null|undefined, - protos.google.cloud.netapp.v1.IBackupVault>): - Promise<[ - protos.google.cloud.netapp.v1.IBackupVault[], - protos.google.cloud.netapp.v1.IListBackupVaultsRequest|null, - protos.google.cloud.netapp.v1.IListBackupVaultsResponse - ]>|void { + | protos.google.cloud.netapp.v1.IListBackupVaultsResponse + | null + | undefined, + protos.google.cloud.netapp.v1.IBackupVault + >, + callback?: PaginationCallback< + protos.google.cloud.netapp.v1.IListBackupVaultsRequest, + | protos.google.cloud.netapp.v1.IListBackupVaultsResponse + | null + | undefined, + protos.google.cloud.netapp.v1.IBackupVault + >, + ): Promise< + [ + protos.google.cloud.netapp.v1.IBackupVault[], + protos.google.cloud.netapp.v1.IListBackupVaultsRequest | null, + protos.google.cloud.netapp.v1.IListBackupVaultsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.netapp.v1.IListBackupVaultsRequest, - protos.google.cloud.netapp.v1.IListBackupVaultsResponse|null|undefined, - protos.google.cloud.netapp.v1.IBackupVault>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.netapp.v1.IListBackupVaultsRequest, + | protos.google.cloud.netapp.v1.IListBackupVaultsResponse + | null + | undefined, + protos.google.cloud.netapp.v1.IBackupVault + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listBackupVaults values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -8593,221 +12382,240 @@ export class NetAppClient { this._log.info('listBackupVaults request %j', request); return this.innerApiCalls .listBackupVaults(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.netapp.v1.IBackupVault[], - protos.google.cloud.netapp.v1.IListBackupVaultsRequest|null, - protos.google.cloud.netapp.v1.IListBackupVaultsResponse - ]) => { - this._log.info('listBackupVaults values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.netapp.v1.IBackupVault[], + protos.google.cloud.netapp.v1.IListBackupVaultsRequest | null, + protos.google.cloud.netapp.v1.IListBackupVaultsResponse, + ]) => { + this._log.info('listBackupVaults values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listBackupVaults`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location for which to retrieve backupVault information, - * in the format - * `projects/{project_id}/locations/{location}`. - * @param {number} request.pageSize - * The maximum number of items to return. - * @param {string} request.pageToken - * The next_page_token value to use if there are additional - * results to retrieve for this list request. - * @param {string} request.orderBy - * Sort results. Supported values are "name", "name desc" or "" (unsorted). - * @param {string} request.filter - * List filter. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.netapp.v1.BackupVault|BackupVault} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listBackupVaultsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listBackupVaults`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location for which to retrieve backupVault information, + * in the format + * `projects/{project_id}/locations/{location}`. + * @param {number} request.pageSize + * The maximum number of items to return. + * @param {string} request.pageToken + * The next_page_token value to use if there are additional + * results to retrieve for this list request. + * @param {string} request.orderBy + * Sort results. Supported values are "name", "name desc" or "" (unsorted). + * @param {string} request.filter + * List filter. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.netapp.v1.BackupVault|BackupVault} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listBackupVaultsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listBackupVaultsStream( - request?: protos.google.cloud.netapp.v1.IListBackupVaultsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.netapp.v1.IListBackupVaultsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listBackupVaults']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listBackupVaults stream %j', request); return this.descriptors.page.listBackupVaults.createStream( this.innerApiCalls.listBackupVaults as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listBackupVaults`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location for which to retrieve backupVault information, - * in the format - * `projects/{project_id}/locations/{location}`. - * @param {number} request.pageSize - * The maximum number of items to return. - * @param {string} request.pageToken - * The next_page_token value to use if there are additional - * results to retrieve for this list request. - * @param {string} request.orderBy - * Sort results. Supported values are "name", "name desc" or "" (unsorted). - * @param {string} request.filter - * List filter. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.netapp.v1.BackupVault|BackupVault}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/net_app.list_backup_vaults.js - * region_tag:netapp_v1_generated_NetApp_ListBackupVaults_async - */ + /** + * Equivalent to `listBackupVaults`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location for which to retrieve backupVault information, + * in the format + * `projects/{project_id}/locations/{location}`. + * @param {number} request.pageSize + * The maximum number of items to return. + * @param {string} request.pageToken + * The next_page_token value to use if there are additional + * results to retrieve for this list request. + * @param {string} request.orderBy + * Sort results. Supported values are "name", "name desc" or "" (unsorted). + * @param {string} request.filter + * List filter. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.netapp.v1.BackupVault|BackupVault}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/net_app.list_backup_vaults.js + * region_tag:netapp_v1_generated_NetApp_ListBackupVaults_async + */ listBackupVaultsAsync( - request?: protos.google.cloud.netapp.v1.IListBackupVaultsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.netapp.v1.IListBackupVaultsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listBackupVaults']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listBackupVaults iterate %j', request); return this.descriptors.page.listBackupVaults.asyncIterate( this.innerApiCalls['listBackupVaults'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Returns descriptions of all backups for a backupVault. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The backupVault for which to retrieve backup information, - * in the format - * `projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}`. - * To retrieve backup information for all locations, use "-" for the - * `{location}` value. - * To retrieve backup information for all backupVaults, use "-" for the - * `{backup_vault_id}` value. - * To retrieve backup information for a volume, use "-" for the - * `{backup_vault_id}` value and specify volume full name with the filter. - * @param {number} request.pageSize - * The maximum number of items to return. The service may return fewer - * than this value. The maximum value - * is 1000; values above 1000 will be coerced to 1000. - * @param {string} request.pageToken - * The next_page_token value to use if there are additional - * results to retrieve for this list request. - * @param {string} request.orderBy - * Sort results. Supported values are "name", "name desc" or "" (unsorted). - * @param {string} request.filter - * The standard list filter. - * If specified, backups will be returned based on the attribute name that - * matches the filter expression. If empty, then no backups are filtered out. - * See https://google.aip.dev/160 - * @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 Array of {@link protos.google.cloud.netapp.v1.Backup|Backup}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listBackupsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Returns descriptions of all backups for a backupVault. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The backupVault for which to retrieve backup information, + * in the format + * `projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}`. + * To retrieve backup information for all locations, use "-" for the + * `{location}` value. + * To retrieve backup information for all backupVaults, use "-" for the + * `{backup_vault_id}` value. + * To retrieve backup information for a volume, use "-" for the + * `{backup_vault_id}` value and specify volume full name with the filter. + * @param {number} request.pageSize + * The maximum number of items to return. The service may return fewer + * than this value. The maximum value + * is 1000; values above 1000 will be coerced to 1000. + * @param {string} request.pageToken + * The next_page_token value to use if there are additional + * results to retrieve for this list request. + * @param {string} request.orderBy + * Sort results. Supported values are "name", "name desc" or "" (unsorted). + * @param {string} request.filter + * The standard list filter. + * If specified, backups will be returned based on the attribute name that + * matches the filter expression. If empty, then no backups are filtered out. + * See https://google.aip.dev/160 + * @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 Array of {@link protos.google.cloud.netapp.v1.Backup|Backup}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listBackupsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listBackups( - request?: protos.google.cloud.netapp.v1.IListBackupsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.netapp.v1.IBackup[], - protos.google.cloud.netapp.v1.IListBackupsRequest|null, - protos.google.cloud.netapp.v1.IListBackupsResponse - ]>; + request?: protos.google.cloud.netapp.v1.IListBackupsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.netapp.v1.IBackup[], + protos.google.cloud.netapp.v1.IListBackupsRequest | null, + protos.google.cloud.netapp.v1.IListBackupsResponse, + ] + >; listBackups( - request: protos.google.cloud.netapp.v1.IListBackupsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.netapp.v1.IListBackupsRequest, - protos.google.cloud.netapp.v1.IListBackupsResponse|null|undefined, - protos.google.cloud.netapp.v1.IBackup>): void; + request: protos.google.cloud.netapp.v1.IListBackupsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.netapp.v1.IListBackupsRequest, + protos.google.cloud.netapp.v1.IListBackupsResponse | null | undefined, + protos.google.cloud.netapp.v1.IBackup + >, + ): void; listBackups( - request: protos.google.cloud.netapp.v1.IListBackupsRequest, - callback: PaginationCallback< - protos.google.cloud.netapp.v1.IListBackupsRequest, - protos.google.cloud.netapp.v1.IListBackupsResponse|null|undefined, - protos.google.cloud.netapp.v1.IBackup>): void; + request: protos.google.cloud.netapp.v1.IListBackupsRequest, + callback: PaginationCallback< + protos.google.cloud.netapp.v1.IListBackupsRequest, + protos.google.cloud.netapp.v1.IListBackupsResponse | null | undefined, + protos.google.cloud.netapp.v1.IBackup + >, + ): void; listBackups( - request?: protos.google.cloud.netapp.v1.IListBackupsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.netapp.v1.IListBackupsRequest, - protos.google.cloud.netapp.v1.IListBackupsResponse|null|undefined, - protos.google.cloud.netapp.v1.IBackup>, - callback?: PaginationCallback< + request?: protos.google.cloud.netapp.v1.IListBackupsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.netapp.v1.IListBackupsRequest, - protos.google.cloud.netapp.v1.IListBackupsResponse|null|undefined, - protos.google.cloud.netapp.v1.IBackup>): - Promise<[ - protos.google.cloud.netapp.v1.IBackup[], - protos.google.cloud.netapp.v1.IListBackupsRequest|null, - protos.google.cloud.netapp.v1.IListBackupsResponse - ]>|void { + protos.google.cloud.netapp.v1.IListBackupsResponse | null | undefined, + protos.google.cloud.netapp.v1.IBackup + >, + callback?: PaginationCallback< + protos.google.cloud.netapp.v1.IListBackupsRequest, + protos.google.cloud.netapp.v1.IListBackupsResponse | null | undefined, + protos.google.cloud.netapp.v1.IBackup + >, + ): Promise< + [ + protos.google.cloud.netapp.v1.IBackup[], + protos.google.cloud.netapp.v1.IListBackupsRequest | null, + protos.google.cloud.netapp.v1.IListBackupsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.netapp.v1.IListBackupsRequest, - protos.google.cloud.netapp.v1.IListBackupsResponse|null|undefined, - protos.google.cloud.netapp.v1.IBackup>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.netapp.v1.IListBackupsRequest, + protos.google.cloud.netapp.v1.IListBackupsResponse | null | undefined, + protos.google.cloud.netapp.v1.IBackup + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listBackups values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -8816,230 +12624,259 @@ export class NetAppClient { this._log.info('listBackups request %j', request); return this.innerApiCalls .listBackups(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.netapp.v1.IBackup[], - protos.google.cloud.netapp.v1.IListBackupsRequest|null, - protos.google.cloud.netapp.v1.IListBackupsResponse - ]) => { - this._log.info('listBackups values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.netapp.v1.IBackup[], + protos.google.cloud.netapp.v1.IListBackupsRequest | null, + protos.google.cloud.netapp.v1.IListBackupsResponse, + ]) => { + this._log.info('listBackups values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listBackups`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The backupVault for which to retrieve backup information, - * in the format - * `projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}`. - * To retrieve backup information for all locations, use "-" for the - * `{location}` value. - * To retrieve backup information for all backupVaults, use "-" for the - * `{backup_vault_id}` value. - * To retrieve backup information for a volume, use "-" for the - * `{backup_vault_id}` value and specify volume full name with the filter. - * @param {number} request.pageSize - * The maximum number of items to return. The service may return fewer - * than this value. The maximum value - * is 1000; values above 1000 will be coerced to 1000. - * @param {string} request.pageToken - * The next_page_token value to use if there are additional - * results to retrieve for this list request. - * @param {string} request.orderBy - * Sort results. Supported values are "name", "name desc" or "" (unsorted). - * @param {string} request.filter - * The standard list filter. - * If specified, backups will be returned based on the attribute name that - * matches the filter expression. If empty, then no backups are filtered out. - * See https://google.aip.dev/160 - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.netapp.v1.Backup|Backup} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listBackupsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listBackups`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The backupVault for which to retrieve backup information, + * in the format + * `projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}`. + * To retrieve backup information for all locations, use "-" for the + * `{location}` value. + * To retrieve backup information for all backupVaults, use "-" for the + * `{backup_vault_id}` value. + * To retrieve backup information for a volume, use "-" for the + * `{backup_vault_id}` value and specify volume full name with the filter. + * @param {number} request.pageSize + * The maximum number of items to return. The service may return fewer + * than this value. The maximum value + * is 1000; values above 1000 will be coerced to 1000. + * @param {string} request.pageToken + * The next_page_token value to use if there are additional + * results to retrieve for this list request. + * @param {string} request.orderBy + * Sort results. Supported values are "name", "name desc" or "" (unsorted). + * @param {string} request.filter + * The standard list filter. + * If specified, backups will be returned based on the attribute name that + * matches the filter expression. If empty, then no backups are filtered out. + * See https://google.aip.dev/160 + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.netapp.v1.Backup|Backup} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listBackupsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listBackupsStream( - request?: protos.google.cloud.netapp.v1.IListBackupsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.netapp.v1.IListBackupsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listBackups']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listBackups stream %j', request); return this.descriptors.page.listBackups.createStream( this.innerApiCalls.listBackups as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listBackups`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The backupVault for which to retrieve backup information, - * in the format - * `projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}`. - * To retrieve backup information for all locations, use "-" for the - * `{location}` value. - * To retrieve backup information for all backupVaults, use "-" for the - * `{backup_vault_id}` value. - * To retrieve backup information for a volume, use "-" for the - * `{backup_vault_id}` value and specify volume full name with the filter. - * @param {number} request.pageSize - * The maximum number of items to return. The service may return fewer - * than this value. The maximum value - * is 1000; values above 1000 will be coerced to 1000. - * @param {string} request.pageToken - * The next_page_token value to use if there are additional - * results to retrieve for this list request. - * @param {string} request.orderBy - * Sort results. Supported values are "name", "name desc" or "" (unsorted). - * @param {string} request.filter - * The standard list filter. - * If specified, backups will be returned based on the attribute name that - * matches the filter expression. If empty, then no backups are filtered out. - * See https://google.aip.dev/160 - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.netapp.v1.Backup|Backup}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/net_app.list_backups.js - * region_tag:netapp_v1_generated_NetApp_ListBackups_async - */ + /** + * Equivalent to `listBackups`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The backupVault for which to retrieve backup information, + * in the format + * `projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}`. + * To retrieve backup information for all locations, use "-" for the + * `{location}` value. + * To retrieve backup information for all backupVaults, use "-" for the + * `{backup_vault_id}` value. + * To retrieve backup information for a volume, use "-" for the + * `{backup_vault_id}` value and specify volume full name with the filter. + * @param {number} request.pageSize + * The maximum number of items to return. The service may return fewer + * than this value. The maximum value + * is 1000; values above 1000 will be coerced to 1000. + * @param {string} request.pageToken + * The next_page_token value to use if there are additional + * results to retrieve for this list request. + * @param {string} request.orderBy + * Sort results. Supported values are "name", "name desc" or "" (unsorted). + * @param {string} request.filter + * The standard list filter. + * If specified, backups will be returned based on the attribute name that + * matches the filter expression. If empty, then no backups are filtered out. + * See https://google.aip.dev/160 + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.netapp.v1.Backup|Backup}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/net_app.list_backups.js + * region_tag:netapp_v1_generated_NetApp_ListBackups_async + */ listBackupsAsync( - request?: protos.google.cloud.netapp.v1.IListBackupsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.netapp.v1.IListBackupsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listBackups']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listBackups iterate %j', request); return this.descriptors.page.listBackups.asyncIterate( this.innerApiCalls['listBackups'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Returns list of all available backup policies. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListBackupPoliciesRequest - * @param {number} request.pageSize - * Requested page size. Server may return fewer items than requested. - * If unspecified, the server will pick an appropriate default. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. - * @param {string} request.filter - * Filtering results - * @param {string} request.orderBy - * Hint for how to order the results - * @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 Array of {@link protos.google.cloud.netapp.v1.BackupPolicy|BackupPolicy}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listBackupPoliciesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Returns list of all available backup policies. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListBackupPoliciesRequest + * @param {number} request.pageSize + * Requested page size. Server may return fewer items than requested. + * If unspecified, the server will pick an appropriate default. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. + * @param {string} request.filter + * Filtering results + * @param {string} request.orderBy + * Hint for how to order the results + * @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 Array of {@link protos.google.cloud.netapp.v1.BackupPolicy|BackupPolicy}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listBackupPoliciesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listBackupPolicies( - request?: protos.google.cloud.netapp.v1.IListBackupPoliciesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.netapp.v1.IBackupPolicy[], - protos.google.cloud.netapp.v1.IListBackupPoliciesRequest|null, - protos.google.cloud.netapp.v1.IListBackupPoliciesResponse - ]>; + request?: protos.google.cloud.netapp.v1.IListBackupPoliciesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.netapp.v1.IBackupPolicy[], + protos.google.cloud.netapp.v1.IListBackupPoliciesRequest | null, + protos.google.cloud.netapp.v1.IListBackupPoliciesResponse, + ] + >; listBackupPolicies( - request: protos.google.cloud.netapp.v1.IListBackupPoliciesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.netapp.v1.IListBackupPoliciesRequest, - protos.google.cloud.netapp.v1.IListBackupPoliciesResponse|null|undefined, - protos.google.cloud.netapp.v1.IBackupPolicy>): void; + request: protos.google.cloud.netapp.v1.IListBackupPoliciesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.netapp.v1.IListBackupPoliciesRequest, + | protos.google.cloud.netapp.v1.IListBackupPoliciesResponse + | null + | undefined, + protos.google.cloud.netapp.v1.IBackupPolicy + >, + ): void; listBackupPolicies( - request: protos.google.cloud.netapp.v1.IListBackupPoliciesRequest, - callback: PaginationCallback< - protos.google.cloud.netapp.v1.IListBackupPoliciesRequest, - protos.google.cloud.netapp.v1.IListBackupPoliciesResponse|null|undefined, - protos.google.cloud.netapp.v1.IBackupPolicy>): void; + request: protos.google.cloud.netapp.v1.IListBackupPoliciesRequest, + callback: PaginationCallback< + protos.google.cloud.netapp.v1.IListBackupPoliciesRequest, + | protos.google.cloud.netapp.v1.IListBackupPoliciesResponse + | null + | undefined, + protos.google.cloud.netapp.v1.IBackupPolicy + >, + ): void; listBackupPolicies( - request?: protos.google.cloud.netapp.v1.IListBackupPoliciesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.netapp.v1.IListBackupPoliciesRequest, - protos.google.cloud.netapp.v1.IListBackupPoliciesResponse|null|undefined, - protos.google.cloud.netapp.v1.IBackupPolicy>, - callback?: PaginationCallback< + request?: protos.google.cloud.netapp.v1.IListBackupPoliciesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.netapp.v1.IListBackupPoliciesRequest, - protos.google.cloud.netapp.v1.IListBackupPoliciesResponse|null|undefined, - protos.google.cloud.netapp.v1.IBackupPolicy>): - Promise<[ - protos.google.cloud.netapp.v1.IBackupPolicy[], - protos.google.cloud.netapp.v1.IListBackupPoliciesRequest|null, - protos.google.cloud.netapp.v1.IListBackupPoliciesResponse - ]>|void { + | protos.google.cloud.netapp.v1.IListBackupPoliciesResponse + | null + | undefined, + protos.google.cloud.netapp.v1.IBackupPolicy + >, + callback?: PaginationCallback< + protos.google.cloud.netapp.v1.IListBackupPoliciesRequest, + | protos.google.cloud.netapp.v1.IListBackupPoliciesResponse + | null + | undefined, + protos.google.cloud.netapp.v1.IBackupPolicy + >, + ): Promise< + [ + protos.google.cloud.netapp.v1.IBackupPolicy[], + protos.google.cloud.netapp.v1.IListBackupPoliciesRequest | null, + protos.google.cloud.netapp.v1.IListBackupPoliciesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.netapp.v1.IListBackupPoliciesRequest, - protos.google.cloud.netapp.v1.IListBackupPoliciesResponse|null|undefined, - protos.google.cloud.netapp.v1.IBackupPolicy>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.netapp.v1.IListBackupPoliciesRequest, + | protos.google.cloud.netapp.v1.IListBackupPoliciesResponse + | null + | undefined, + protos.google.cloud.netapp.v1.IBackupPolicy + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listBackupPolicies values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -9048,204 +12885,227 @@ export class NetAppClient { this._log.info('listBackupPolicies request %j', request); return this.innerApiCalls .listBackupPolicies(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.netapp.v1.IBackupPolicy[], - protos.google.cloud.netapp.v1.IListBackupPoliciesRequest|null, - protos.google.cloud.netapp.v1.IListBackupPoliciesResponse - ]) => { - this._log.info('listBackupPolicies values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.netapp.v1.IBackupPolicy[], + protos.google.cloud.netapp.v1.IListBackupPoliciesRequest | null, + protos.google.cloud.netapp.v1.IListBackupPoliciesResponse, + ]) => { + this._log.info('listBackupPolicies values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listBackupPolicies`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListBackupPoliciesRequest - * @param {number} request.pageSize - * Requested page size. Server may return fewer items than requested. - * If unspecified, the server will pick an appropriate default. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. - * @param {string} request.filter - * Filtering results - * @param {string} request.orderBy - * Hint for how to order the results - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.netapp.v1.BackupPolicy|BackupPolicy} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listBackupPoliciesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listBackupPolicies`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListBackupPoliciesRequest + * @param {number} request.pageSize + * Requested page size. Server may return fewer items than requested. + * If unspecified, the server will pick an appropriate default. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. + * @param {string} request.filter + * Filtering results + * @param {string} request.orderBy + * Hint for how to order the results + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.netapp.v1.BackupPolicy|BackupPolicy} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listBackupPoliciesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listBackupPoliciesStream( - request?: protos.google.cloud.netapp.v1.IListBackupPoliciesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.netapp.v1.IListBackupPoliciesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listBackupPolicies']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listBackupPolicies stream %j', request); return this.descriptors.page.listBackupPolicies.createStream( this.innerApiCalls.listBackupPolicies as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listBackupPolicies`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListBackupPoliciesRequest - * @param {number} request.pageSize - * Requested page size. Server may return fewer items than requested. - * If unspecified, the server will pick an appropriate default. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. - * @param {string} request.filter - * Filtering results - * @param {string} request.orderBy - * Hint for how to order the results - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.netapp.v1.BackupPolicy|BackupPolicy}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/net_app.list_backup_policies.js - * region_tag:netapp_v1_generated_NetApp_ListBackupPolicies_async - */ + /** + * Equivalent to `listBackupPolicies`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListBackupPoliciesRequest + * @param {number} request.pageSize + * Requested page size. Server may return fewer items than requested. + * If unspecified, the server will pick an appropriate default. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. + * @param {string} request.filter + * Filtering results + * @param {string} request.orderBy + * Hint for how to order the results + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.netapp.v1.BackupPolicy|BackupPolicy}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/net_app.list_backup_policies.js + * region_tag:netapp_v1_generated_NetApp_ListBackupPolicies_async + */ listBackupPoliciesAsync( - request?: protos.google.cloud.netapp.v1.IListBackupPoliciesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.netapp.v1.IListBackupPoliciesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listBackupPolicies']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listBackupPolicies iterate %j', request); return this.descriptors.page.listBackupPolicies.asyncIterate( this.innerApiCalls['listBackupPolicies'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Returns list of all quota rules in a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListQuotaRulesRequest - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, the server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Filtering results - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results - * @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 Array of {@link protos.google.cloud.netapp.v1.QuotaRule|QuotaRule}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listQuotaRulesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Returns list of all quota rules in a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListQuotaRulesRequest + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, the server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Filtering results + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results + * @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 Array of {@link protos.google.cloud.netapp.v1.QuotaRule|QuotaRule}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listQuotaRulesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listQuotaRules( - request?: protos.google.cloud.netapp.v1.IListQuotaRulesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.netapp.v1.IQuotaRule[], - protos.google.cloud.netapp.v1.IListQuotaRulesRequest|null, - protos.google.cloud.netapp.v1.IListQuotaRulesResponse - ]>; + request?: protos.google.cloud.netapp.v1.IListQuotaRulesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.netapp.v1.IQuotaRule[], + protos.google.cloud.netapp.v1.IListQuotaRulesRequest | null, + protos.google.cloud.netapp.v1.IListQuotaRulesResponse, + ] + >; listQuotaRules( - request: protos.google.cloud.netapp.v1.IListQuotaRulesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.netapp.v1.IListQuotaRulesRequest, - protos.google.cloud.netapp.v1.IListQuotaRulesResponse|null|undefined, - protos.google.cloud.netapp.v1.IQuotaRule>): void; + request: protos.google.cloud.netapp.v1.IListQuotaRulesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.netapp.v1.IListQuotaRulesRequest, + protos.google.cloud.netapp.v1.IListQuotaRulesResponse | null | undefined, + protos.google.cloud.netapp.v1.IQuotaRule + >, + ): void; listQuotaRules( - request: protos.google.cloud.netapp.v1.IListQuotaRulesRequest, - callback: PaginationCallback< - protos.google.cloud.netapp.v1.IListQuotaRulesRequest, - protos.google.cloud.netapp.v1.IListQuotaRulesResponse|null|undefined, - protos.google.cloud.netapp.v1.IQuotaRule>): void; + request: protos.google.cloud.netapp.v1.IListQuotaRulesRequest, + callback: PaginationCallback< + protos.google.cloud.netapp.v1.IListQuotaRulesRequest, + protos.google.cloud.netapp.v1.IListQuotaRulesResponse | null | undefined, + protos.google.cloud.netapp.v1.IQuotaRule + >, + ): void; listQuotaRules( - request?: protos.google.cloud.netapp.v1.IListQuotaRulesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.netapp.v1.IListQuotaRulesRequest, - protos.google.cloud.netapp.v1.IListQuotaRulesResponse|null|undefined, - protos.google.cloud.netapp.v1.IQuotaRule>, - callback?: PaginationCallback< + request?: protos.google.cloud.netapp.v1.IListQuotaRulesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.netapp.v1.IListQuotaRulesRequest, - protos.google.cloud.netapp.v1.IListQuotaRulesResponse|null|undefined, - protos.google.cloud.netapp.v1.IQuotaRule>): - Promise<[ - protos.google.cloud.netapp.v1.IQuotaRule[], - protos.google.cloud.netapp.v1.IListQuotaRulesRequest|null, - protos.google.cloud.netapp.v1.IListQuotaRulesResponse - ]>|void { + | protos.google.cloud.netapp.v1.IListQuotaRulesResponse + | null + | undefined, + protos.google.cloud.netapp.v1.IQuotaRule + >, + callback?: PaginationCallback< + protos.google.cloud.netapp.v1.IListQuotaRulesRequest, + protos.google.cloud.netapp.v1.IListQuotaRulesResponse | null | undefined, + protos.google.cloud.netapp.v1.IQuotaRule + >, + ): Promise< + [ + protos.google.cloud.netapp.v1.IQuotaRule[], + protos.google.cloud.netapp.v1.IListQuotaRulesRequest | null, + protos.google.cloud.netapp.v1.IListQuotaRulesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.netapp.v1.IListQuotaRulesRequest, - protos.google.cloud.netapp.v1.IListQuotaRulesResponse|null|undefined, - protos.google.cloud.netapp.v1.IQuotaRule>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.netapp.v1.IListQuotaRulesRequest, + | protos.google.cloud.netapp.v1.IListQuotaRulesResponse + | null + | undefined, + protos.google.cloud.netapp.v1.IQuotaRule + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listQuotaRules values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -9254,205 +13114,228 @@ export class NetAppClient { this._log.info('listQuotaRules request %j', request); return this.innerApiCalls .listQuotaRules(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.netapp.v1.IQuotaRule[], - protos.google.cloud.netapp.v1.IListQuotaRulesRequest|null, - protos.google.cloud.netapp.v1.IListQuotaRulesResponse - ]) => { - this._log.info('listQuotaRules values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.netapp.v1.IQuotaRule[], + protos.google.cloud.netapp.v1.IListQuotaRulesRequest | null, + protos.google.cloud.netapp.v1.IListQuotaRulesResponse, + ]) => { + this._log.info('listQuotaRules values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listQuotaRules`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListQuotaRulesRequest - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, the server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Filtering results - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.netapp.v1.QuotaRule|QuotaRule} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listQuotaRulesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listQuotaRules`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListQuotaRulesRequest + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, the server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Filtering results + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.netapp.v1.QuotaRule|QuotaRule} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listQuotaRulesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listQuotaRulesStream( - request?: protos.google.cloud.netapp.v1.IListQuotaRulesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.netapp.v1.IListQuotaRulesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listQuotaRules']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listQuotaRules stream %j', request); return this.descriptors.page.listQuotaRules.createStream( this.innerApiCalls.listQuotaRules as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listQuotaRules`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListQuotaRulesRequest - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, the server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Filtering results - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.netapp.v1.QuotaRule|QuotaRule}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/net_app.list_quota_rules.js - * region_tag:netapp_v1_generated_NetApp_ListQuotaRules_async - */ + /** + * Equivalent to `listQuotaRules`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListQuotaRulesRequest + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, the server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Filtering results + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.netapp.v1.QuotaRule|QuotaRule}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/net_app.list_quota_rules.js + * region_tag:netapp_v1_generated_NetApp_ListQuotaRules_async + */ listQuotaRulesAsync( - request?: protos.google.cloud.netapp.v1.IListQuotaRulesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.netapp.v1.IListQuotaRulesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listQuotaRules']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listQuotaRules iterate %j', request); return this.descriptors.page.listQuotaRules.asyncIterate( this.innerApiCalls['listQuotaRules'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Returns a list of host groups in a `location`. Use `-` as location to list - * host groups across all locations. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListHostGroupsRequest - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, the server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Filter to apply to the request. - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results - * @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 Array of {@link protos.google.cloud.netapp.v1.HostGroup|HostGroup}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listHostGroupsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Returns a list of host groups in a `location`. Use `-` as location to list + * host groups across all locations. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListHostGroupsRequest + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, the server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Filter to apply to the request. + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results + * @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 Array of {@link protos.google.cloud.netapp.v1.HostGroup|HostGroup}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listHostGroupsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listHostGroups( - request?: protos.google.cloud.netapp.v1.IListHostGroupsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.netapp.v1.IHostGroup[], - protos.google.cloud.netapp.v1.IListHostGroupsRequest|null, - protos.google.cloud.netapp.v1.IListHostGroupsResponse - ]>; + request?: protos.google.cloud.netapp.v1.IListHostGroupsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.netapp.v1.IHostGroup[], + protos.google.cloud.netapp.v1.IListHostGroupsRequest | null, + protos.google.cloud.netapp.v1.IListHostGroupsResponse, + ] + >; listHostGroups( - request: protos.google.cloud.netapp.v1.IListHostGroupsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.netapp.v1.IListHostGroupsRequest, - protos.google.cloud.netapp.v1.IListHostGroupsResponse|null|undefined, - protos.google.cloud.netapp.v1.IHostGroup>): void; + request: protos.google.cloud.netapp.v1.IListHostGroupsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.netapp.v1.IListHostGroupsRequest, + protos.google.cloud.netapp.v1.IListHostGroupsResponse | null | undefined, + protos.google.cloud.netapp.v1.IHostGroup + >, + ): void; listHostGroups( - request: protos.google.cloud.netapp.v1.IListHostGroupsRequest, - callback: PaginationCallback< - protos.google.cloud.netapp.v1.IListHostGroupsRequest, - protos.google.cloud.netapp.v1.IListHostGroupsResponse|null|undefined, - protos.google.cloud.netapp.v1.IHostGroup>): void; + request: protos.google.cloud.netapp.v1.IListHostGroupsRequest, + callback: PaginationCallback< + protos.google.cloud.netapp.v1.IListHostGroupsRequest, + protos.google.cloud.netapp.v1.IListHostGroupsResponse | null | undefined, + protos.google.cloud.netapp.v1.IHostGroup + >, + ): void; listHostGroups( - request?: protos.google.cloud.netapp.v1.IListHostGroupsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.netapp.v1.IListHostGroupsRequest, - protos.google.cloud.netapp.v1.IListHostGroupsResponse|null|undefined, - protos.google.cloud.netapp.v1.IHostGroup>, - callback?: PaginationCallback< + request?: protos.google.cloud.netapp.v1.IListHostGroupsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.netapp.v1.IListHostGroupsRequest, - protos.google.cloud.netapp.v1.IListHostGroupsResponse|null|undefined, - protos.google.cloud.netapp.v1.IHostGroup>): - Promise<[ - protos.google.cloud.netapp.v1.IHostGroup[], - protos.google.cloud.netapp.v1.IListHostGroupsRequest|null, - protos.google.cloud.netapp.v1.IListHostGroupsResponse - ]>|void { + | protos.google.cloud.netapp.v1.IListHostGroupsResponse + | null + | undefined, + protos.google.cloud.netapp.v1.IHostGroup + >, + callback?: PaginationCallback< + protos.google.cloud.netapp.v1.IListHostGroupsRequest, + protos.google.cloud.netapp.v1.IListHostGroupsResponse | null | undefined, + protos.google.cloud.netapp.v1.IHostGroup + >, + ): Promise< + [ + protos.google.cloud.netapp.v1.IHostGroup[], + protos.google.cloud.netapp.v1.IListHostGroupsRequest | null, + protos.google.cloud.netapp.v1.IListHostGroupsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.netapp.v1.IListHostGroupsRequest, - protos.google.cloud.netapp.v1.IListHostGroupsResponse|null|undefined, - protos.google.cloud.netapp.v1.IHostGroup>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.netapp.v1.IListHostGroupsRequest, + | protos.google.cloud.netapp.v1.IListHostGroupsResponse + | null + | undefined, + protos.google.cloud.netapp.v1.IHostGroup + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listHostGroups values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -9461,119 +13344,124 @@ export class NetAppClient { this._log.info('listHostGroups request %j', request); return this.innerApiCalls .listHostGroups(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.netapp.v1.IHostGroup[], - protos.google.cloud.netapp.v1.IListHostGroupsRequest|null, - protos.google.cloud.netapp.v1.IListHostGroupsResponse - ]) => { - this._log.info('listHostGroups values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.netapp.v1.IHostGroup[], + protos.google.cloud.netapp.v1.IListHostGroupsRequest | null, + protos.google.cloud.netapp.v1.IListHostGroupsResponse, + ]) => { + this._log.info('listHostGroups values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listHostGroups`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListHostGroupsRequest - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, the server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Filter to apply to the request. - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.netapp.v1.HostGroup|HostGroup} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listHostGroupsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listHostGroups`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListHostGroupsRequest + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, the server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Filter to apply to the request. + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.netapp.v1.HostGroup|HostGroup} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listHostGroupsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listHostGroupsStream( - request?: protos.google.cloud.netapp.v1.IListHostGroupsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.netapp.v1.IListHostGroupsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listHostGroups']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listHostGroups stream %j', request); return this.descriptors.page.listHostGroups.createStream( this.innerApiCalls.listHostGroups as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listHostGroups`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListHostGroupsRequest - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, the server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Filter to apply to the request. - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.netapp.v1.HostGroup|HostGroup}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/net_app.list_host_groups.js - * region_tag:netapp_v1_generated_NetApp_ListHostGroups_async - */ + /** + * Equivalent to `listHostGroups`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListHostGroupsRequest + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, the server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Filter to apply to the request. + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.netapp.v1.HostGroup|HostGroup}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/net_app.list_host_groups.js + * region_tag:netapp_v1_generated_NetApp_ListHostGroups_async + */ listHostGroupsAsync( - request?: protos.google.cloud.netapp.v1.IListHostGroupsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.netapp.v1.IListHostGroupsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listHostGroups']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listHostGroups iterate %j', request); return this.descriptors.page.listHostGroups.asyncIterate( this.innerApiCalls['listHostGroups'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** + + /** * Gets information about a location. * * @param {Object} request @@ -9608,12 +13496,11 @@ export class NetAppClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -9646,12 +13533,12 @@ export class NetAppClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -9694,22 +13581,22 @@ export class NetAppClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -9744,15 +13631,15 @@ export class NetAppClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - 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 ?? '', - }); + 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 ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -9786,7 +13673,7 @@ export class NetAppClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -9799,25 +13686,24 @@ export class NetAppClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -9856,22 +13742,22 @@ export class NetAppClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -9887,7 +13773,11 @@ export class NetAppClient { * @param {string} active_directory * @returns {string} Resource name string. */ - activeDirectoryPath(project:string,location:string,activeDirectory:string) { + activeDirectoryPath( + project: string, + location: string, + activeDirectory: string, + ) { return this.pathTemplates.activeDirectoryPathTemplate.render({ project: project, location: location, @@ -9903,7 +13793,9 @@ export class NetAppClient { * @returns {string} A string representing the project. */ matchProjectFromActiveDirectoryName(activeDirectoryName: string) { - return this.pathTemplates.activeDirectoryPathTemplate.match(activeDirectoryName).project; + return this.pathTemplates.activeDirectoryPathTemplate.match( + activeDirectoryName, + ).project; } /** @@ -9914,7 +13806,9 @@ export class NetAppClient { * @returns {string} A string representing the location. */ matchLocationFromActiveDirectoryName(activeDirectoryName: string) { - return this.pathTemplates.activeDirectoryPathTemplate.match(activeDirectoryName).location; + return this.pathTemplates.activeDirectoryPathTemplate.match( + activeDirectoryName, + ).location; } /** @@ -9925,7 +13819,9 @@ export class NetAppClient { * @returns {string} A string representing the active_directory. */ matchActiveDirectoryFromActiveDirectoryName(activeDirectoryName: string) { - return this.pathTemplates.activeDirectoryPathTemplate.match(activeDirectoryName).active_directory; + return this.pathTemplates.activeDirectoryPathTemplate.match( + activeDirectoryName, + ).active_directory; } /** @@ -9937,7 +13833,12 @@ export class NetAppClient { * @param {string} backup * @returns {string} Resource name string. */ - backupPath(project:string,location:string,backupVault:string,backup:string) { + backupPath( + project: string, + location: string, + backupVault: string, + backup: string, + ) { return this.pathTemplates.backupPathTemplate.render({ project: project, location: location, @@ -9998,7 +13899,7 @@ export class NetAppClient { * @param {string} backup_policy * @returns {string} Resource name string. */ - backupPolicyPath(project:string,location:string,backupPolicy:string) { + backupPolicyPath(project: string, location: string, backupPolicy: string) { return this.pathTemplates.backupPolicyPathTemplate.render({ project: project, location: location, @@ -10014,7 +13915,8 @@ export class NetAppClient { * @returns {string} A string representing the project. */ matchProjectFromBackupPolicyName(backupPolicyName: string) { - return this.pathTemplates.backupPolicyPathTemplate.match(backupPolicyName).project; + return this.pathTemplates.backupPolicyPathTemplate.match(backupPolicyName) + .project; } /** @@ -10025,7 +13927,8 @@ export class NetAppClient { * @returns {string} A string representing the location. */ matchLocationFromBackupPolicyName(backupPolicyName: string) { - return this.pathTemplates.backupPolicyPathTemplate.match(backupPolicyName).location; + return this.pathTemplates.backupPolicyPathTemplate.match(backupPolicyName) + .location; } /** @@ -10036,7 +13939,8 @@ export class NetAppClient { * @returns {string} A string representing the backup_policy. */ matchBackupPolicyFromBackupPolicyName(backupPolicyName: string) { - return this.pathTemplates.backupPolicyPathTemplate.match(backupPolicyName).backup_policy; + return this.pathTemplates.backupPolicyPathTemplate.match(backupPolicyName) + .backup_policy; } /** @@ -10047,7 +13951,7 @@ export class NetAppClient { * @param {string} backup_vault * @returns {string} Resource name string. */ - backupVaultPath(project:string,location:string,backupVault:string) { + backupVaultPath(project: string, location: string, backupVault: string) { return this.pathTemplates.backupVaultPathTemplate.render({ project: project, location: location, @@ -10063,7 +13967,8 @@ export class NetAppClient { * @returns {string} A string representing the project. */ matchProjectFromBackupVaultName(backupVaultName: string) { - return this.pathTemplates.backupVaultPathTemplate.match(backupVaultName).project; + return this.pathTemplates.backupVaultPathTemplate.match(backupVaultName) + .project; } /** @@ -10074,7 +13979,8 @@ export class NetAppClient { * @returns {string} A string representing the location. */ matchLocationFromBackupVaultName(backupVaultName: string) { - return this.pathTemplates.backupVaultPathTemplate.match(backupVaultName).location; + return this.pathTemplates.backupVaultPathTemplate.match(backupVaultName) + .location; } /** @@ -10085,7 +13991,8 @@ export class NetAppClient { * @returns {string} A string representing the backup_vault. */ matchBackupVaultFromBackupVaultName(backupVaultName: string) { - return this.pathTemplates.backupVaultPathTemplate.match(backupVaultName).backup_vault; + return this.pathTemplates.backupVaultPathTemplate.match(backupVaultName) + .backup_vault; } /** @@ -10096,7 +14003,7 @@ export class NetAppClient { * @param {string} host_group * @returns {string} Resource name string. */ - hostGroupPath(project:string,location:string,hostGroup:string) { + hostGroupPath(project: string, location: string, hostGroup: string) { return this.pathTemplates.hostGroupPathTemplate.render({ project: project, location: location, @@ -10112,7 +14019,8 @@ export class NetAppClient { * @returns {string} A string representing the project. */ matchProjectFromHostGroupName(hostGroupName: string) { - return this.pathTemplates.hostGroupPathTemplate.match(hostGroupName).project; + return this.pathTemplates.hostGroupPathTemplate.match(hostGroupName) + .project; } /** @@ -10123,7 +14031,8 @@ export class NetAppClient { * @returns {string} A string representing the location. */ matchLocationFromHostGroupName(hostGroupName: string) { - return this.pathTemplates.hostGroupPathTemplate.match(hostGroupName).location; + return this.pathTemplates.hostGroupPathTemplate.match(hostGroupName) + .location; } /** @@ -10134,7 +14043,8 @@ export class NetAppClient { * @returns {string} A string representing the host_group. */ matchHostGroupFromHostGroupName(hostGroupName: string) { - return this.pathTemplates.hostGroupPathTemplate.match(hostGroupName).host_group; + return this.pathTemplates.hostGroupPathTemplate.match(hostGroupName) + .host_group; } /** @@ -10145,7 +14055,7 @@ export class NetAppClient { * @param {string} kms_config * @returns {string} Resource name string. */ - kmsConfigPath(project:string,location:string,kmsConfig:string) { + kmsConfigPath(project: string, location: string, kmsConfig: string) { return this.pathTemplates.kmsConfigPathTemplate.render({ project: project, location: location, @@ -10161,7 +14071,8 @@ export class NetAppClient { * @returns {string} A string representing the project. */ matchProjectFromKmsConfigName(kmsConfigName: string) { - return this.pathTemplates.kmsConfigPathTemplate.match(kmsConfigName).project; + return this.pathTemplates.kmsConfigPathTemplate.match(kmsConfigName) + .project; } /** @@ -10172,7 +14083,8 @@ export class NetAppClient { * @returns {string} A string representing the location. */ matchLocationFromKmsConfigName(kmsConfigName: string) { - return this.pathTemplates.kmsConfigPathTemplate.match(kmsConfigName).location; + return this.pathTemplates.kmsConfigPathTemplate.match(kmsConfigName) + .location; } /** @@ -10183,7 +14095,8 @@ export class NetAppClient { * @returns {string} A string representing the kms_config. */ matchKmsConfigFromKmsConfigName(kmsConfigName: string) { - return this.pathTemplates.kmsConfigPathTemplate.match(kmsConfigName).kms_config; + return this.pathTemplates.kmsConfigPathTemplate.match(kmsConfigName) + .kms_config; } /** @@ -10195,7 +14108,12 @@ export class NetAppClient { * @param {string} quota_rule * @returns {string} Resource name string. */ - quotaRulePath(project:string,location:string,volume:string,quotaRule:string) { + quotaRulePath( + project: string, + location: string, + volume: string, + quotaRule: string, + ) { return this.pathTemplates.quotaRulePathTemplate.render({ project: project, location: location, @@ -10212,7 +14130,8 @@ export class NetAppClient { * @returns {string} A string representing the project. */ matchProjectFromQuotaRuleName(quotaRuleName: string) { - return this.pathTemplates.quotaRulePathTemplate.match(quotaRuleName).project; + return this.pathTemplates.quotaRulePathTemplate.match(quotaRuleName) + .project; } /** @@ -10223,7 +14142,8 @@ export class NetAppClient { * @returns {string} A string representing the location. */ matchLocationFromQuotaRuleName(quotaRuleName: string) { - return this.pathTemplates.quotaRulePathTemplate.match(quotaRuleName).location; + return this.pathTemplates.quotaRulePathTemplate.match(quotaRuleName) + .location; } /** @@ -10245,7 +14165,8 @@ export class NetAppClient { * @returns {string} A string representing the quota_rule. */ matchQuotaRuleFromQuotaRuleName(quotaRuleName: string) { - return this.pathTemplates.quotaRulePathTemplate.match(quotaRuleName).quota_rule; + return this.pathTemplates.quotaRulePathTemplate.match(quotaRuleName) + .quota_rule; } /** @@ -10257,7 +14178,12 @@ export class NetAppClient { * @param {string} replication * @returns {string} Resource name string. */ - replicationPath(project:string,location:string,volume:string,replication:string) { + replicationPath( + project: string, + location: string, + volume: string, + replication: string, + ) { return this.pathTemplates.replicationPathTemplate.render({ project: project, location: location, @@ -10274,7 +14200,8 @@ export class NetAppClient { * @returns {string} A string representing the project. */ matchProjectFromReplicationName(replicationName: string) { - return this.pathTemplates.replicationPathTemplate.match(replicationName).project; + return this.pathTemplates.replicationPathTemplate.match(replicationName) + .project; } /** @@ -10285,7 +14212,8 @@ export class NetAppClient { * @returns {string} A string representing the location. */ matchLocationFromReplicationName(replicationName: string) { - return this.pathTemplates.replicationPathTemplate.match(replicationName).location; + return this.pathTemplates.replicationPathTemplate.match(replicationName) + .location; } /** @@ -10296,7 +14224,8 @@ export class NetAppClient { * @returns {string} A string representing the volume. */ matchVolumeFromReplicationName(replicationName: string) { - return this.pathTemplates.replicationPathTemplate.match(replicationName).volume; + return this.pathTemplates.replicationPathTemplate.match(replicationName) + .volume; } /** @@ -10307,7 +14236,8 @@ export class NetAppClient { * @returns {string} A string representing the replication. */ matchReplicationFromReplicationName(replicationName: string) { - return this.pathTemplates.replicationPathTemplate.match(replicationName).replication; + return this.pathTemplates.replicationPathTemplate.match(replicationName) + .replication; } /** @@ -10319,7 +14249,12 @@ export class NetAppClient { * @param {string} snapshot * @returns {string} Resource name string. */ - snapshotPath(project:string,location:string,volume:string,snapshot:string) { + snapshotPath( + project: string, + location: string, + volume: string, + snapshot: string, + ) { return this.pathTemplates.snapshotPathTemplate.render({ project: project, location: location, @@ -10380,7 +14315,7 @@ export class NetAppClient { * @param {string} storage_pool * @returns {string} Resource name string. */ - storagePoolPath(project:string,location:string,storagePool:string) { + storagePoolPath(project: string, location: string, storagePool: string) { return this.pathTemplates.storagePoolPathTemplate.render({ project: project, location: location, @@ -10396,7 +14331,8 @@ export class NetAppClient { * @returns {string} A string representing the project. */ matchProjectFromStoragePoolName(storagePoolName: string) { - return this.pathTemplates.storagePoolPathTemplate.match(storagePoolName).project; + return this.pathTemplates.storagePoolPathTemplate.match(storagePoolName) + .project; } /** @@ -10407,7 +14343,8 @@ export class NetAppClient { * @returns {string} A string representing the location. */ matchLocationFromStoragePoolName(storagePoolName: string) { - return this.pathTemplates.storagePoolPathTemplate.match(storagePoolName).location; + return this.pathTemplates.storagePoolPathTemplate.match(storagePoolName) + .location; } /** @@ -10418,7 +14355,8 @@ export class NetAppClient { * @returns {string} A string representing the storage_pool. */ matchStoragePoolFromStoragePoolName(storagePoolName: string) { - return this.pathTemplates.storagePoolPathTemplate.match(storagePoolName).storage_pool; + return this.pathTemplates.storagePoolPathTemplate.match(storagePoolName) + .storage_pool; } /** @@ -10429,7 +14367,7 @@ export class NetAppClient { * @param {string} volume * @returns {string} Resource name string. */ - volumePath(project:string,location:string,volume:string) { + volumePath(project: string, location: string, volume: string) { return this.pathTemplates.volumePathTemplate.render({ project: project, location: location, @@ -10478,14 +14416,16 @@ export class NetAppClient { */ close(): Promise { if (this.netAppStub && !this._terminated) { - return this.netAppStub.then(stub => { + return this.netAppStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.locationsClient.close().catch(err => {throw err}); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-netapp/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-netapp/system-test/fixtures/sample/src/index.ts index 04c911e2a640..7b4e1dc531a9 100644 --- a/packages/google-cloud-netapp/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-netapp/system-test/fixtures/sample/src/index.ts @@ -16,7 +16,7 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {NetAppClient} from '@google-cloud/netapp'; +import { NetAppClient } from '@google-cloud/netapp'; // check that the client class type name can be used function doStuffWithNetAppClient(client: NetAppClient) { diff --git a/packages/google-cloud-netapp/system-test/install.ts b/packages/google-cloud-netapp/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-netapp/system-test/install.ts +++ b/packages/google-cloud-netapp/system-test/install.ts @@ -16,34 +16,36 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {packNTest} from 'pack-n-play'; -import {readFileSync} from 'fs'; -import {describe, it} from 'mocha'; +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; +import { describe, it } from 'mocha'; describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { + it('TypeScript code', async function () { this.timeout(300000); const options = { packageDir: process.cwd(), sample: { description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } + ts: readFileSync( + './system-test/fixtures/sample/src/index.ts', + ).toString(), + }, }; await packNTest(options); }); - it('JavaScript code', async function() { + it('JavaScript code', async function () { this.timeout(300000); const options = { packageDir: process.cwd(), sample: { description: 'JavaScript user can use the library', - cjs: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } + cjs: readFileSync( + './system-test/fixtures/sample/src/index.js', + ).toString(), + }, }; await packNTest(options); }); - }); 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 9c37ee83a632..d9344a6bc991 100644 --- a/packages/google-cloud-netapp/test/gapic_net_app_v1.ts +++ b/packages/google-cloud-netapp/test/gapic_net_app_v1.ts @@ -19,12464 +19,15644 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as netappModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1.NetAppClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new netappModule.v1.NetAppClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'netapp.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new netappModule.v1.NetAppClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'netapp.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new netappModule.v1.NetAppClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new netappModule.v1.NetAppClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = netappModule.v1.NetAppClient.servicePath; - assert.strictEqual(servicePath, 'netapp.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = netappModule.v1.NetAppClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'netapp.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new netappModule.v1.NetAppClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'netapp.example.com'); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = netappModule.v1.NetAppClient.servicePath; + assert.strictEqual(servicePath, 'netapp.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = netappModule.v1.NetAppClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'netapp.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new netappModule.v1.NetAppClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'netapp.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new netappModule.v1.NetAppClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'netapp.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new netappModule.v1.NetAppClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'netapp.example.com'); + }); - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new netappModule.v1.NetAppClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'netapp.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new netappModule.v1.NetAppClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'netapp.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new netappModule.v1.NetAppClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new netappModule.v1.NetAppClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'netapp.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new netappModule.v1.NetAppClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'netapp.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new netappModule.v1.NetAppClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has port', () => { - const port = netappModule.v1.NetAppClient.port; - assert(port); - assert(typeof port === 'number'); - }); + it('has port', () => { + const port = netappModule.v1.NetAppClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('should create a client with no option', () => { - const client = new netappModule.v1.NetAppClient(); - assert(client); - }); + it('should create a client with no option', () => { + const client = new netappModule.v1.NetAppClient(); + assert(client); + }); - it('should create a client with gRPC fallback', () => { - const client = new netappModule.v1.NetAppClient({ - fallback: true, - }); - assert(client); - }); + it('should create a client with gRPC fallback', () => { + const client = new netappModule.v1.NetAppClient({ + fallback: true, + }); + assert(client); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.netAppStub, undefined); - await client.initialize(); - assert(client.netAppStub); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.netAppStub, undefined); + await client.initialize(); + assert(client.netAppStub); + }); - it('has close method for the initialized client', done => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.netAppStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the initialized client', (done) => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.netAppStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has close method for the non-initialized client', done => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.netAppStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the non-initialized client', (done) => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.netAppStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getStoragePool', () => { + it('invokes getStoragePool without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetStoragePoolRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetStoragePoolRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.StoragePool(), + ); + client.innerApiCalls.getStoragePool = stubSimpleCall(expectedResponse); + const [response] = await client.getStoragePool(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getStoragePool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getStoragePool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getStoragePool', () => { - it('invokes getStoragePool without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetStoragePoolRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetStoragePoolRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.StoragePool() - ); - client.innerApiCalls.getStoragePool = stubSimpleCall(expectedResponse); - const [response] = await client.getStoragePool(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getStoragePool as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getStoragePool as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getStoragePool without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetStoragePoolRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetStoragePoolRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.StoragePool(), + ); + client.innerApiCalls.getStoragePool = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getStoragePool( + request, + ( + err?: Error | null, + result?: protos.google.cloud.netapp.v1.IStoragePool | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getStoragePool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getStoragePool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getStoragePool without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetStoragePoolRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetStoragePoolRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.StoragePool() - ); - client.innerApiCalls.getStoragePool = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getStoragePool( - request, - (err?: Error|null, result?: protos.google.cloud.netapp.v1.IStoragePool|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getStoragePool as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getStoragePool as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getStoragePool with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetStoragePoolRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetStoragePoolRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getStoragePool = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getStoragePool(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getStoragePool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getStoragePool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getStoragePool with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetStoragePoolRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetStoragePoolRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getStoragePool = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getStoragePool(request), expectedError); - const actualRequest = (client.innerApiCalls.getStoragePool as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getStoragePool as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getStoragePool with closed client', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetStoragePoolRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetStoragePoolRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getStoragePool(request), expectedError); + }); + }); + + describe('getVolume', () => { + it('invokes getVolume without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetVolumeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetVolumeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.Volume(), + ); + client.innerApiCalls.getVolume = stubSimpleCall(expectedResponse); + const [response] = await client.getVolume(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getVolume as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getVolume as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getStoragePool with closed client', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetStoragePoolRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetStoragePoolRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getStoragePool(request), expectedError); - }); + it('invokes getVolume without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetVolumeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetVolumeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.Volume(), + ); + client.innerApiCalls.getVolume = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getVolume( + request, + ( + err?: Error | null, + result?: protos.google.cloud.netapp.v1.IVolume | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getVolume as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getVolume as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getVolume', () => { - it('invokes getVolume without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetVolumeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetVolumeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.Volume() - ); - client.innerApiCalls.getVolume = stubSimpleCall(expectedResponse); - const [response] = await client.getVolume(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getVolume as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getVolume as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getVolume with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetVolumeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetVolumeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getVolume = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getVolume(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getVolume as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getVolume as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getVolume without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetVolumeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetVolumeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.Volume() - ); - client.innerApiCalls.getVolume = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getVolume( - request, - (err?: Error|null, result?: protos.google.cloud.netapp.v1.IVolume|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getVolume as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getVolume as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getVolume with closed client', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetVolumeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetVolumeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getVolume(request), expectedError); + }); + }); + + describe('getSnapshot', () => { + it('invokes getSnapshot without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetSnapshotRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetSnapshotRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.Snapshot(), + ); + client.innerApiCalls.getSnapshot = stubSimpleCall(expectedResponse); + const [response] = await client.getSnapshot(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getSnapshot as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSnapshot as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getVolume with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetVolumeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetVolumeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getVolume = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getVolume(request), expectedError); - const actualRequest = (client.innerApiCalls.getVolume as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getVolume as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getSnapshot without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetSnapshotRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetSnapshotRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.Snapshot(), + ); + client.innerApiCalls.getSnapshot = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getSnapshot( + request, + ( + err?: Error | null, + result?: protos.google.cloud.netapp.v1.ISnapshot | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getSnapshot as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSnapshot as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getVolume with closed client', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetVolumeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetVolumeRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getVolume(request), expectedError); - }); + it('invokes getSnapshot with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetSnapshotRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetSnapshotRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getSnapshot = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getSnapshot(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getSnapshot as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSnapshot as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getSnapshot', () => { - it('invokes getSnapshot without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetSnapshotRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetSnapshotRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.Snapshot() - ); - client.innerApiCalls.getSnapshot = stubSimpleCall(expectedResponse); - const [response] = await client.getSnapshot(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSnapshot as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSnapshot as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getSnapshot with closed client', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetSnapshotRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetSnapshotRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getSnapshot(request), expectedError); + }); + }); + + describe('getActiveDirectory', () => { + it('invokes getActiveDirectory without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetActiveDirectoryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetActiveDirectoryRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.ActiveDirectory(), + ); + client.innerApiCalls.getActiveDirectory = + stubSimpleCall(expectedResponse); + const [response] = await client.getActiveDirectory(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getActiveDirectory as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getActiveDirectory as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getSnapshot without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetSnapshotRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetSnapshotRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.Snapshot() - ); - client.innerApiCalls.getSnapshot = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getSnapshot( - request, - (err?: Error|null, result?: protos.google.cloud.netapp.v1.ISnapshot|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSnapshot as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSnapshot as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getActiveDirectory without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetActiveDirectoryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetActiveDirectoryRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.ActiveDirectory(), + ); + client.innerApiCalls.getActiveDirectory = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getActiveDirectory( + request, + ( + err?: Error | null, + result?: protos.google.cloud.netapp.v1.IActiveDirectory | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getActiveDirectory as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getActiveDirectory as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getSnapshot with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetSnapshotRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetSnapshotRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getSnapshot = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getSnapshot(request), expectedError); - const actualRequest = (client.innerApiCalls.getSnapshot as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSnapshot as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getActiveDirectory with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetActiveDirectoryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetActiveDirectoryRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getActiveDirectory = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getActiveDirectory(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getActiveDirectory as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getActiveDirectory as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getSnapshot with closed client', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetSnapshotRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetSnapshotRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getSnapshot(request), expectedError); - }); + it('invokes getActiveDirectory with closed client', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetActiveDirectoryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetActiveDirectoryRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getActiveDirectory(request), expectedError); + }); + }); + + describe('getKmsConfig', () => { + it('invokes getKmsConfig without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetKmsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetKmsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.KmsConfig(), + ); + client.innerApiCalls.getKmsConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getKmsConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getKmsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getKmsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getActiveDirectory', () => { - it('invokes getActiveDirectory without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetActiveDirectoryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetActiveDirectoryRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.ActiveDirectory() - ); - client.innerApiCalls.getActiveDirectory = stubSimpleCall(expectedResponse); - const [response] = await client.getActiveDirectory(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getActiveDirectory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getActiveDirectory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getKmsConfig without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetKmsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetKmsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.KmsConfig(), + ); + client.innerApiCalls.getKmsConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getKmsConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.netapp.v1.IKmsConfig | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getKmsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getKmsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getActiveDirectory without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetActiveDirectoryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetActiveDirectoryRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.ActiveDirectory() - ); - client.innerApiCalls.getActiveDirectory = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getActiveDirectory( - request, - (err?: Error|null, result?: protos.google.cloud.netapp.v1.IActiveDirectory|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getActiveDirectory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getActiveDirectory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getKmsConfig with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetKmsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetKmsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getKmsConfig = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getKmsConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getKmsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getKmsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getActiveDirectory with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetActiveDirectoryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetActiveDirectoryRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getActiveDirectory = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getActiveDirectory(request), expectedError); - const actualRequest = (client.innerApiCalls.getActiveDirectory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getActiveDirectory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getKmsConfig with closed client', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetKmsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetKmsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getKmsConfig(request), expectedError); + }); + }); + + describe('verifyKmsConfig', () => { + it('invokes verifyKmsConfig without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.VerifyKmsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.VerifyKmsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.VerifyKmsConfigResponse(), + ); + client.innerApiCalls.verifyKmsConfig = stubSimpleCall(expectedResponse); + const [response] = await client.verifyKmsConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.verifyKmsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.verifyKmsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getActiveDirectory with closed client', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetActiveDirectoryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetActiveDirectoryRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getActiveDirectory(request), expectedError); - }); + it('invokes verifyKmsConfig without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.VerifyKmsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.VerifyKmsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.VerifyKmsConfigResponse(), + ); + client.innerApiCalls.verifyKmsConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.verifyKmsConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.netapp.v1.IVerifyKmsConfigResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.verifyKmsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.verifyKmsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getKmsConfig', () => { - it('invokes getKmsConfig without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetKmsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetKmsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.KmsConfig() - ); - client.innerApiCalls.getKmsConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getKmsConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getKmsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getKmsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes verifyKmsConfig with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.VerifyKmsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.VerifyKmsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.verifyKmsConfig = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.verifyKmsConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.verifyKmsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.verifyKmsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getKmsConfig without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetKmsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetKmsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.KmsConfig() - ); - client.innerApiCalls.getKmsConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getKmsConfig( - request, - (err?: Error|null, result?: protos.google.cloud.netapp.v1.IKmsConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getKmsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getKmsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes verifyKmsConfig with closed client', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.VerifyKmsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.VerifyKmsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.verifyKmsConfig(request), expectedError); + }); + }); + + describe('getReplication', () => { + it('invokes getReplication without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetReplicationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetReplicationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.Replication(), + ); + client.innerApiCalls.getReplication = stubSimpleCall(expectedResponse); + const [response] = await client.getReplication(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getReplication as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getReplication as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getKmsConfig with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetKmsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetKmsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getKmsConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getKmsConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.getKmsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getKmsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getReplication without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetReplicationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetReplicationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.Replication(), + ); + client.innerApiCalls.getReplication = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getReplication( + request, + ( + err?: Error | null, + result?: protos.google.cloud.netapp.v1.IReplication | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getReplication as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getReplication as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getKmsConfig with closed client', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetKmsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetKmsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getKmsConfig(request), expectedError); - }); + it('invokes getReplication with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetReplicationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetReplicationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getReplication = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getReplication(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getReplication as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getReplication as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('verifyKmsConfig', () => { - it('invokes verifyKmsConfig without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.VerifyKmsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.VerifyKmsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.VerifyKmsConfigResponse() - ); - client.innerApiCalls.verifyKmsConfig = stubSimpleCall(expectedResponse); - const [response] = await client.verifyKmsConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.verifyKmsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.verifyKmsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getReplication with closed client', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetReplicationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetReplicationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getReplication(request), expectedError); + }); + }); + + describe('getBackupVault', () => { + it('invokes getBackupVault without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetBackupVaultRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetBackupVaultRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.BackupVault(), + ); + client.innerApiCalls.getBackupVault = stubSimpleCall(expectedResponse); + const [response] = await client.getBackupVault(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getBackupVault as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBackupVault as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes verifyKmsConfig without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.VerifyKmsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.VerifyKmsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.VerifyKmsConfigResponse() - ); - client.innerApiCalls.verifyKmsConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.verifyKmsConfig( - request, - (err?: Error|null, result?: protos.google.cloud.netapp.v1.IVerifyKmsConfigResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.verifyKmsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.verifyKmsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getBackupVault without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetBackupVaultRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetBackupVaultRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.BackupVault(), + ); + client.innerApiCalls.getBackupVault = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getBackupVault( + request, + ( + err?: Error | null, + result?: protos.google.cloud.netapp.v1.IBackupVault | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getBackupVault as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBackupVault as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes verifyKmsConfig with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.VerifyKmsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.VerifyKmsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.verifyKmsConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.verifyKmsConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.verifyKmsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.verifyKmsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getBackupVault with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetBackupVaultRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetBackupVaultRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getBackupVault = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getBackupVault(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getBackupVault as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBackupVault as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes verifyKmsConfig with closed client', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.VerifyKmsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.VerifyKmsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.verifyKmsConfig(request), expectedError); - }); + it('invokes getBackupVault with closed client', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetBackupVaultRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetBackupVaultRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getBackupVault(request), expectedError); + }); + }); + + describe('getBackup', () => { + it('invokes getBackup without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.Backup(), + ); + client.innerApiCalls.getBackup = stubSimpleCall(expectedResponse); + const [response] = await client.getBackup(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getReplication', () => { - it('invokes getReplication without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetReplicationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetReplicationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.Replication() - ); - client.innerApiCalls.getReplication = stubSimpleCall(expectedResponse); - const [response] = await client.getReplication(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getReplication as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getReplication as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getBackup without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.Backup(), + ); + client.innerApiCalls.getBackup = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getBackup( + request, + ( + err?: Error | null, + result?: protos.google.cloud.netapp.v1.IBackup | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getReplication without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetReplicationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetReplicationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.Replication() - ); - client.innerApiCalls.getReplication = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getReplication( - request, - (err?: Error|null, result?: protos.google.cloud.netapp.v1.IReplication|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getReplication as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getReplication as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getBackup with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getBackup = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getBackup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getReplication with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetReplicationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetReplicationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getReplication = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getReplication(request), expectedError); - const actualRequest = (client.innerApiCalls.getReplication as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getReplication as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getBackup with closed client', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getBackup(request), expectedError); + }); + }); + + describe('getBackupPolicy', () => { + it('invokes getBackupPolicy without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetBackupPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetBackupPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.BackupPolicy(), + ); + client.innerApiCalls.getBackupPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getBackupPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getBackupPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBackupPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getReplication with closed client', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetReplicationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetReplicationRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getReplication(request), expectedError); - }); + it('invokes getBackupPolicy without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetBackupPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetBackupPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.BackupPolicy(), + ); + client.innerApiCalls.getBackupPolicy = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getBackupPolicy( + request, + ( + err?: Error | null, + result?: protos.google.cloud.netapp.v1.IBackupPolicy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getBackupPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBackupPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getBackupVault', () => { - it('invokes getBackupVault without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetBackupVaultRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetBackupVaultRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.BackupVault() - ); - client.innerApiCalls.getBackupVault = stubSimpleCall(expectedResponse); - const [response] = await client.getBackupVault(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getBackupVault as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBackupVault as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getBackupPolicy with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetBackupPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetBackupPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getBackupPolicy = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getBackupPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getBackupPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBackupPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getBackupVault without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetBackupVaultRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetBackupVaultRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.BackupVault() - ); - client.innerApiCalls.getBackupVault = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getBackupVault( - request, - (err?: Error|null, result?: protos.google.cloud.netapp.v1.IBackupVault|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getBackupVault as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBackupVault as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getBackupPolicy with closed client', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetBackupPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetBackupPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getBackupPolicy(request), expectedError); + }); + }); + + describe('getQuotaRule', () => { + it('invokes getQuotaRule without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetQuotaRuleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetQuotaRuleRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.QuotaRule(), + ); + client.innerApiCalls.getQuotaRule = stubSimpleCall(expectedResponse); + const [response] = await client.getQuotaRule(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getQuotaRule as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getQuotaRule as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getBackupVault with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetBackupVaultRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetBackupVaultRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getBackupVault = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getBackupVault(request), expectedError); - const actualRequest = (client.innerApiCalls.getBackupVault as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBackupVault as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getQuotaRule without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetQuotaRuleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetQuotaRuleRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.QuotaRule(), + ); + client.innerApiCalls.getQuotaRule = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getQuotaRule( + request, + ( + err?: Error | null, + result?: protos.google.cloud.netapp.v1.IQuotaRule | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getQuotaRule as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getQuotaRule as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getBackupVault with closed client', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetBackupVaultRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetBackupVaultRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getBackupVault(request), expectedError); - }); + it('invokes getQuotaRule with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetQuotaRuleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetQuotaRuleRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getQuotaRule = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getQuotaRule(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getQuotaRule as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getQuotaRule as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getBackup', () => { - it('invokes getBackup without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.Backup() - ); - client.innerApiCalls.getBackup = stubSimpleCall(expectedResponse); - const [response] = await client.getBackup(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getQuotaRule with closed client', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetQuotaRuleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetQuotaRuleRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getQuotaRule(request), expectedError); + }); + }); + + describe('getHostGroup', () => { + it('invokes getHostGroup without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetHostGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetHostGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.HostGroup(), + ); + client.innerApiCalls.getHostGroup = stubSimpleCall(expectedResponse); + const [response] = await client.getHostGroup(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getHostGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getHostGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getBackup without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.Backup() - ); - client.innerApiCalls.getBackup = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getBackup( - request, - (err?: Error|null, result?: protos.google.cloud.netapp.v1.IBackup|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getHostGroup without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetHostGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetHostGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.HostGroup(), + ); + client.innerApiCalls.getHostGroup = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getHostGroup( + request, + ( + err?: Error | null, + result?: protos.google.cloud.netapp.v1.IHostGroup | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getHostGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getHostGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getBackup with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getBackup = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getBackup(request), expectedError); - const actualRequest = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getHostGroup with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetHostGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetHostGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getHostGroup = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getHostGroup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getHostGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getHostGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getBackup with closed client', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetBackupRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getBackup(request), expectedError); - }); + it('invokes getHostGroup with closed client', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.GetHostGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.GetHostGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getHostGroup(request), expectedError); + }); + }); + + describe('executeOntapPost', () => { + it('invokes executeOntapPost without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ExecuteOntapPostRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ExecuteOntapPostRequest', + ['ontapPath'], + ); + request.ontapPath = defaultValue1; + const expectedHeaderRequestParams = `ontap_path=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.ExecuteOntapPostResponse(), + ); + client.innerApiCalls.executeOntapPost = stubSimpleCall(expectedResponse); + const [response] = await client.executeOntapPost(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.executeOntapPost as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.executeOntapPost as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getBackupPolicy', () => { - it('invokes getBackupPolicy without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetBackupPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetBackupPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.BackupPolicy() - ); - client.innerApiCalls.getBackupPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getBackupPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getBackupPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBackupPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes executeOntapPost without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ExecuteOntapPostRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ExecuteOntapPostRequest', + ['ontapPath'], + ); + request.ontapPath = defaultValue1; + const expectedHeaderRequestParams = `ontap_path=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.ExecuteOntapPostResponse(), + ); + client.innerApiCalls.executeOntapPost = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.executeOntapPost( + request, + ( + err?: Error | null, + result?: protos.google.cloud.netapp.v1.IExecuteOntapPostResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.executeOntapPost as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.executeOntapPost as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getBackupPolicy without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetBackupPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetBackupPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.BackupPolicy() - ); - client.innerApiCalls.getBackupPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getBackupPolicy( - request, - (err?: Error|null, result?: protos.google.cloud.netapp.v1.IBackupPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getBackupPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBackupPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes executeOntapPost with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ExecuteOntapPostRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ExecuteOntapPostRequest', + ['ontapPath'], + ); + request.ontapPath = defaultValue1; + const expectedHeaderRequestParams = `ontap_path=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.executeOntapPost = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.executeOntapPost(request), expectedError); + const actualRequest = ( + client.innerApiCalls.executeOntapPost as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.executeOntapPost as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getBackupPolicy with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetBackupPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetBackupPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getBackupPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getBackupPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.getBackupPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBackupPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes executeOntapPost with closed client', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ExecuteOntapPostRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ExecuteOntapPostRequest', + ['ontapPath'], + ); + request.ontapPath = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.executeOntapPost(request), expectedError); + }); + }); + + describe('executeOntapGet', () => { + it('invokes executeOntapGet without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ExecuteOntapGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ExecuteOntapGetRequest', + ['ontapPath'], + ); + request.ontapPath = defaultValue1; + const expectedHeaderRequestParams = `ontap_path=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.ExecuteOntapGetResponse(), + ); + client.innerApiCalls.executeOntapGet = stubSimpleCall(expectedResponse); + const [response] = await client.executeOntapGet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.executeOntapGet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.executeOntapGet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getBackupPolicy with closed client', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetBackupPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetBackupPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getBackupPolicy(request), expectedError); - }); + it('invokes executeOntapGet without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ExecuteOntapGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ExecuteOntapGetRequest', + ['ontapPath'], + ); + request.ontapPath = defaultValue1; + const expectedHeaderRequestParams = `ontap_path=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.ExecuteOntapGetResponse(), + ); + client.innerApiCalls.executeOntapGet = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.executeOntapGet( + request, + ( + err?: Error | null, + result?: protos.google.cloud.netapp.v1.IExecuteOntapGetResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.executeOntapGet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.executeOntapGet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getQuotaRule', () => { - it('invokes getQuotaRule without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetQuotaRuleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetQuotaRuleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.QuotaRule() - ); - client.innerApiCalls.getQuotaRule = stubSimpleCall(expectedResponse); - const [response] = await client.getQuotaRule(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getQuotaRule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getQuotaRule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes executeOntapGet with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ExecuteOntapGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ExecuteOntapGetRequest', + ['ontapPath'], + ); + request.ontapPath = defaultValue1; + const expectedHeaderRequestParams = `ontap_path=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.executeOntapGet = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.executeOntapGet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.executeOntapGet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.executeOntapGet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getQuotaRule without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetQuotaRuleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetQuotaRuleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.QuotaRule() - ); - client.innerApiCalls.getQuotaRule = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getQuotaRule( - request, - (err?: Error|null, result?: protos.google.cloud.netapp.v1.IQuotaRule|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getQuotaRule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getQuotaRule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes executeOntapGet with closed client', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ExecuteOntapGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ExecuteOntapGetRequest', + ['ontapPath'], + ); + request.ontapPath = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.executeOntapGet(request), expectedError); + }); + }); + + describe('executeOntapDelete', () => { + it('invokes executeOntapDelete without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ExecuteOntapDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ExecuteOntapDeleteRequest', + ['ontapPath'], + ); + request.ontapPath = defaultValue1; + const expectedHeaderRequestParams = `ontap_path=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.ExecuteOntapDeleteResponse(), + ); + client.innerApiCalls.executeOntapDelete = + stubSimpleCall(expectedResponse); + const [response] = await client.executeOntapDelete(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.executeOntapDelete as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.executeOntapDelete as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getQuotaRule with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetQuotaRuleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetQuotaRuleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getQuotaRule = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getQuotaRule(request), expectedError); - const actualRequest = (client.innerApiCalls.getQuotaRule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getQuotaRule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes executeOntapDelete without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ExecuteOntapDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ExecuteOntapDeleteRequest', + ['ontapPath'], + ); + request.ontapPath = defaultValue1; + const expectedHeaderRequestParams = `ontap_path=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.ExecuteOntapDeleteResponse(), + ); + client.innerApiCalls.executeOntapDelete = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.executeOntapDelete( + request, + ( + err?: Error | null, + result?: protos.google.cloud.netapp.v1.IExecuteOntapDeleteResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.executeOntapDelete as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.executeOntapDelete as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getQuotaRule with closed client', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetQuotaRuleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetQuotaRuleRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getQuotaRule(request), expectedError); - }); + it('invokes executeOntapDelete with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ExecuteOntapDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ExecuteOntapDeleteRequest', + ['ontapPath'], + ); + request.ontapPath = defaultValue1; + const expectedHeaderRequestParams = `ontap_path=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.executeOntapDelete = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.executeOntapDelete(request), expectedError); + const actualRequest = ( + client.innerApiCalls.executeOntapDelete as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.executeOntapDelete as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getHostGroup', () => { - it('invokes getHostGroup without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetHostGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetHostGroupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.HostGroup() - ); - client.innerApiCalls.getHostGroup = stubSimpleCall(expectedResponse); - const [response] = await client.getHostGroup(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getHostGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getHostGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes executeOntapDelete with closed client', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ExecuteOntapDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ExecuteOntapDeleteRequest', + ['ontapPath'], + ); + request.ontapPath = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.executeOntapDelete(request), expectedError); + }); + }); + + describe('executeOntapPatch', () => { + it('invokes executeOntapPatch without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ExecuteOntapPatchRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ExecuteOntapPatchRequest', + ['ontapPath'], + ); + request.ontapPath = defaultValue1; + const expectedHeaderRequestParams = `ontap_path=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.ExecuteOntapPatchResponse(), + ); + client.innerApiCalls.executeOntapPatch = stubSimpleCall(expectedResponse); + const [response] = await client.executeOntapPatch(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.executeOntapPatch as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.executeOntapPatch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getHostGroup without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetHostGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetHostGroupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.HostGroup() - ); - client.innerApiCalls.getHostGroup = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getHostGroup( - request, - (err?: Error|null, result?: protos.google.cloud.netapp.v1.IHostGroup|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getHostGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getHostGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes executeOntapPatch without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ExecuteOntapPatchRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ExecuteOntapPatchRequest', + ['ontapPath'], + ); + request.ontapPath = defaultValue1; + const expectedHeaderRequestParams = `ontap_path=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.netapp.v1.ExecuteOntapPatchResponse(), + ); + client.innerApiCalls.executeOntapPatch = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.executeOntapPatch( + request, + ( + err?: Error | null, + result?: protos.google.cloud.netapp.v1.IExecuteOntapPatchResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.executeOntapPatch as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.executeOntapPatch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getHostGroup with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetHostGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetHostGroupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getHostGroup = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getHostGroup(request), expectedError); - const actualRequest = (client.innerApiCalls.getHostGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getHostGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes executeOntapPatch with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ExecuteOntapPatchRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ExecuteOntapPatchRequest', + ['ontapPath'], + ); + request.ontapPath = defaultValue1; + const expectedHeaderRequestParams = `ontap_path=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.executeOntapPatch = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.executeOntapPatch(request), expectedError); + const actualRequest = ( + client.innerApiCalls.executeOntapPatch as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.executeOntapPatch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getHostGroup with closed client', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.GetHostGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.GetHostGroupRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getHostGroup(request), expectedError); - }); + it('invokes executeOntapPatch with closed client', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ExecuteOntapPatchRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ExecuteOntapPatchRequest', + ['ontapPath'], + ); + request.ontapPath = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.executeOntapPatch(request), expectedError); + }); + }); + + describe('createStoragePool', () => { + it('invokes createStoragePool without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateStoragePoolRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateStoragePoolRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createStoragePool = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createStoragePool(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createStoragePool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createStoragePool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('executeOntapPost', () => { - it('invokes executeOntapPost without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ExecuteOntapPostRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ExecuteOntapPostRequest', ['ontapPath']); - request.ontapPath = defaultValue1; - const expectedHeaderRequestParams = `ontap_path=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.ExecuteOntapPostResponse() - ); - client.innerApiCalls.executeOntapPost = stubSimpleCall(expectedResponse); - const [response] = await client.executeOntapPost(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.executeOntapPost as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeOntapPost as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createStoragePool without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateStoragePoolRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateStoragePoolRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createStoragePool = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createStoragePool( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createStoragePool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createStoragePool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes executeOntapPost without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ExecuteOntapPostRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ExecuteOntapPostRequest', ['ontapPath']); - request.ontapPath = defaultValue1; - const expectedHeaderRequestParams = `ontap_path=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.ExecuteOntapPostResponse() - ); - client.innerApiCalls.executeOntapPost = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.executeOntapPost( - request, - (err?: Error|null, result?: protos.google.cloud.netapp.v1.IExecuteOntapPostResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.executeOntapPost as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeOntapPost as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createStoragePool with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateStoragePoolRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateStoragePoolRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createStoragePool = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createStoragePool(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createStoragePool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createStoragePool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes executeOntapPost with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ExecuteOntapPostRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ExecuteOntapPostRequest', ['ontapPath']); - request.ontapPath = defaultValue1; - const expectedHeaderRequestParams = `ontap_path=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.executeOntapPost = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.executeOntapPost(request), expectedError); - const actualRequest = (client.innerApiCalls.executeOntapPost as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeOntapPost as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createStoragePool with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateStoragePoolRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateStoragePoolRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createStoragePool = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createStoragePool(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createStoragePool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createStoragePool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes executeOntapPost with closed client', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ExecuteOntapPostRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ExecuteOntapPostRequest', ['ontapPath']); - request.ontapPath = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.executeOntapPost(request), expectedError); - }); + it('invokes checkCreateStoragePoolProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateStoragePoolProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('executeOntapGet', () => { - it('invokes executeOntapGet without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ExecuteOntapGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ExecuteOntapGetRequest', ['ontapPath']); - request.ontapPath = defaultValue1; - const expectedHeaderRequestParams = `ontap_path=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.ExecuteOntapGetResponse() - ); - client.innerApiCalls.executeOntapGet = stubSimpleCall(expectedResponse); - const [response] = await client.executeOntapGet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.executeOntapGet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeOntapGet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateStoragePoolProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateStoragePoolProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateStoragePool', () => { + it('invokes updateStoragePool without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateStoragePoolRequest(), + ); + request.storagePool ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateStoragePoolRequest', + ['storagePool', 'name'], + ); + request.storagePool.name = defaultValue1; + const expectedHeaderRequestParams = `storage_pool.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateStoragePool = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateStoragePool(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateStoragePool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateStoragePool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes executeOntapGet without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ExecuteOntapGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ExecuteOntapGetRequest', ['ontapPath']); - request.ontapPath = defaultValue1; - const expectedHeaderRequestParams = `ontap_path=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.ExecuteOntapGetResponse() - ); - client.innerApiCalls.executeOntapGet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.executeOntapGet( - request, - (err?: Error|null, result?: protos.google.cloud.netapp.v1.IExecuteOntapGetResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.executeOntapGet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeOntapGet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateStoragePool without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateStoragePoolRequest(), + ); + request.storagePool ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateStoragePoolRequest', + ['storagePool', 'name'], + ); + request.storagePool.name = defaultValue1; + const expectedHeaderRequestParams = `storage_pool.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateStoragePool = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateStoragePool( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateStoragePool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateStoragePool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes executeOntapGet with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ExecuteOntapGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ExecuteOntapGetRequest', ['ontapPath']); - request.ontapPath = defaultValue1; - const expectedHeaderRequestParams = `ontap_path=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.executeOntapGet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.executeOntapGet(request), expectedError); - const actualRequest = (client.innerApiCalls.executeOntapGet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeOntapGet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateStoragePool with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateStoragePoolRequest(), + ); + request.storagePool ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateStoragePoolRequest', + ['storagePool', 'name'], + ); + request.storagePool.name = defaultValue1; + const expectedHeaderRequestParams = `storage_pool.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateStoragePool = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateStoragePool(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateStoragePool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateStoragePool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes executeOntapGet with closed client', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ExecuteOntapGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ExecuteOntapGetRequest', ['ontapPath']); - request.ontapPath = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.executeOntapGet(request), expectedError); - }); + it('invokes updateStoragePool with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateStoragePoolRequest(), + ); + request.storagePool ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateStoragePoolRequest', + ['storagePool', 'name'], + ); + request.storagePool.name = defaultValue1; + const expectedHeaderRequestParams = `storage_pool.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateStoragePool = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateStoragePool(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateStoragePool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateStoragePool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('executeOntapDelete', () => { - it('invokes executeOntapDelete without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ExecuteOntapDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ExecuteOntapDeleteRequest', ['ontapPath']); - request.ontapPath = defaultValue1; - const expectedHeaderRequestParams = `ontap_path=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.ExecuteOntapDeleteResponse() - ); - client.innerApiCalls.executeOntapDelete = stubSimpleCall(expectedResponse); - const [response] = await client.executeOntapDelete(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.executeOntapDelete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeOntapDelete as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateStoragePoolProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateStoragePoolProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes executeOntapDelete without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ExecuteOntapDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ExecuteOntapDeleteRequest', ['ontapPath']); - request.ontapPath = defaultValue1; - const expectedHeaderRequestParams = `ontap_path=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.ExecuteOntapDeleteResponse() - ); - client.innerApiCalls.executeOntapDelete = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.executeOntapDelete( - request, - (err?: Error|null, result?: protos.google.cloud.netapp.v1.IExecuteOntapDeleteResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.executeOntapDelete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeOntapDelete as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateStoragePoolProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateStoragePoolProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteStoragePool', () => { + it('invokes deleteStoragePool without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteStoragePoolRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteStoragePoolRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteStoragePool = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteStoragePool(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteStoragePool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteStoragePool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes executeOntapDelete with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ExecuteOntapDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ExecuteOntapDeleteRequest', ['ontapPath']); - request.ontapPath = defaultValue1; - const expectedHeaderRequestParams = `ontap_path=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.executeOntapDelete = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.executeOntapDelete(request), expectedError); - const actualRequest = (client.innerApiCalls.executeOntapDelete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeOntapDelete as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteStoragePool without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteStoragePoolRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteStoragePoolRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteStoragePool = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteStoragePool( + 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.deleteStoragePool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteStoragePool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes executeOntapDelete with closed client', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ExecuteOntapDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ExecuteOntapDeleteRequest', ['ontapPath']); - request.ontapPath = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.executeOntapDelete(request), expectedError); - }); + it('invokes deleteStoragePool with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteStoragePoolRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteStoragePoolRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteStoragePool = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteStoragePool(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteStoragePool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteStoragePool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('executeOntapPatch', () => { - it('invokes executeOntapPatch without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ExecuteOntapPatchRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ExecuteOntapPatchRequest', ['ontapPath']); - request.ontapPath = defaultValue1; - const expectedHeaderRequestParams = `ontap_path=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.ExecuteOntapPatchResponse() - ); - client.innerApiCalls.executeOntapPatch = stubSimpleCall(expectedResponse); - const [response] = await client.executeOntapPatch(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.executeOntapPatch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeOntapPatch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteStoragePool with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteStoragePoolRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteStoragePoolRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteStoragePool = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteStoragePool(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteStoragePool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteStoragePool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes executeOntapPatch without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ExecuteOntapPatchRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ExecuteOntapPatchRequest', ['ontapPath']); - request.ontapPath = defaultValue1; - const expectedHeaderRequestParams = `ontap_path=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.netapp.v1.ExecuteOntapPatchResponse() - ); - client.innerApiCalls.executeOntapPatch = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.executeOntapPatch( - request, - (err?: Error|null, result?: protos.google.cloud.netapp.v1.IExecuteOntapPatchResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.executeOntapPatch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeOntapPatch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteStoragePoolProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteStoragePoolProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes executeOntapPatch with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ExecuteOntapPatchRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ExecuteOntapPatchRequest', ['ontapPath']); - request.ontapPath = defaultValue1; - const expectedHeaderRequestParams = `ontap_path=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.executeOntapPatch = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.executeOntapPatch(request), expectedError); - const actualRequest = (client.innerApiCalls.executeOntapPatch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeOntapPatch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteStoragePoolProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteStoragePoolProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('validateDirectoryService', () => { + it('invokes validateDirectoryService without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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 executeOntapPatch with closed client', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ExecuteOntapPatchRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ExecuteOntapPatchRequest', ['ontapPath']); - request.ontapPath = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.executeOntapPatch(request), expectedError); - }); + it('invokes validateDirectoryService without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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)); }); - describe('createStoragePool', () => { - it('invokes createStoragePool without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateStoragePoolRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateStoragePoolRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createStoragePool = stubLongRunningCall(expectedResponse); - const [operation] = await client.createStoragePool(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createStoragePool as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createStoragePool 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', + }); + await 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 createStoragePool without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateStoragePoolRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateStoragePoolRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createStoragePool = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createStoragePool( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createStoragePool as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createStoragePool 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', + }); + await 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 createStoragePool with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateStoragePoolRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateStoragePoolRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createStoragePool = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createStoragePool(request), expectedError); - const actualRequest = (client.innerApiCalls.createStoragePool as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createStoragePool 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', + }); + await 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 createStoragePool with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateStoragePoolRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateStoragePoolRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createStoragePool = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createStoragePool(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createStoragePool as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createStoragePool as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkValidateDirectoryServiceProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.SwitchActiveReplicaZoneRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.SwitchActiveReplicaZoneRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.switchActiveReplicaZone = + stubLongRunningCall(expectedResponse); + const [operation] = await client.switchActiveReplicaZone(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.switchActiveReplicaZone as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.switchActiveReplicaZone as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateStoragePoolProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateStoragePoolProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes switchActiveReplicaZone without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.SwitchActiveReplicaZoneRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.SwitchActiveReplicaZoneRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.switchActiveReplicaZone = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.switchActiveReplicaZone( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.IStoragePool, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.switchActiveReplicaZone as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.switchActiveReplicaZone as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateStoragePoolProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateStoragePoolProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes switchActiveReplicaZone with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.SwitchActiveReplicaZoneRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.SwitchActiveReplicaZoneRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.switchActiveReplicaZone = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.switchActiveReplicaZone(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.switchActiveReplicaZone as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.switchActiveReplicaZone as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateStoragePool', () => { - it('invokes updateStoragePool without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateStoragePoolRequest() - ); - request.storagePool ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateStoragePoolRequest', ['storagePool', 'name']); - request.storagePool.name = defaultValue1; - const expectedHeaderRequestParams = `storage_pool.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateStoragePool = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateStoragePool(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateStoragePool as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateStoragePool as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes switchActiveReplicaZone with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.SwitchActiveReplicaZoneRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.SwitchActiveReplicaZoneRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.switchActiveReplicaZone = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.switchActiveReplicaZone(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.switchActiveReplicaZone as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.switchActiveReplicaZone as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateStoragePool without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateStoragePoolRequest() - ); - request.storagePool ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateStoragePoolRequest', ['storagePool', 'name']); - request.storagePool.name = defaultValue1; - const expectedHeaderRequestParams = `storage_pool.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateStoragePool = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateStoragePool( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateStoragePool as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateStoragePool as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkSwitchActiveReplicaZoneProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkSwitchActiveReplicaZoneProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateStoragePool with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateStoragePoolRequest() - ); - request.storagePool ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateStoragePoolRequest', ['storagePool', 'name']); - request.storagePool.name = defaultValue1; - const expectedHeaderRequestParams = `storage_pool.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateStoragePool = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateStoragePool(request), expectedError); - const actualRequest = (client.innerApiCalls.updateStoragePool as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateStoragePool as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkSwitchActiveReplicaZoneProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkSwitchActiveReplicaZoneProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createVolume', () => { + it('invokes createVolume without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateVolumeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateVolumeRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createVolume = stubLongRunningCall(expectedResponse); + const [operation] = await client.createVolume(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createVolume as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createVolume as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateStoragePool with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateStoragePoolRequest() - ); - request.storagePool ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateStoragePoolRequest', ['storagePool', 'name']); - request.storagePool.name = defaultValue1; - const expectedHeaderRequestParams = `storage_pool.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateStoragePool = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateStoragePool(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateStoragePool as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateStoragePool as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createVolume without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateVolumeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateVolumeRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createVolume = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createVolume( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createVolume as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createVolume as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateStoragePoolProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateStoragePoolProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createVolume with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateVolumeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateVolumeRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createVolume = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createVolume(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createVolume as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createVolume as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateStoragePoolProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateStoragePoolProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createVolume with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateVolumeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateVolumeRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createVolume = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createVolume(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createVolume as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createVolume as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteStoragePool', () => { - it('invokes deleteStoragePool without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteStoragePoolRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteStoragePoolRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteStoragePool = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteStoragePool(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteStoragePool as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteStoragePool as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateVolumeProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateVolumeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteStoragePool without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteStoragePoolRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteStoragePoolRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteStoragePool = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteStoragePool( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteStoragePool as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteStoragePool as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateVolumeProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkCreateVolumeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateVolume', () => { + it('invokes updateVolume without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateVolumeRequest(), + ); + request.volume ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateVolumeRequest', + ['volume', 'name'], + ); + request.volume.name = defaultValue1; + const expectedHeaderRequestParams = `volume.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateVolume = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateVolume(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateVolume as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateVolume as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteStoragePool with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteStoragePoolRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteStoragePoolRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteStoragePool = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteStoragePool(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteStoragePool as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteStoragePool as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateVolume without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateVolumeRequest(), + ); + request.volume ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateVolumeRequest', + ['volume', 'name'], + ); + request.volume.name = defaultValue1; + const expectedHeaderRequestParams = `volume.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateVolume = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateVolume( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateVolume as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateVolume as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteStoragePool with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteStoragePoolRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteStoragePoolRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteStoragePool = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteStoragePool(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteStoragePool as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteStoragePool as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateVolume with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateVolumeRequest(), + ); + request.volume ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateVolumeRequest', + ['volume', 'name'], + ); + request.volume.name = defaultValue1; + const expectedHeaderRequestParams = `volume.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateVolume = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateVolume(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateVolume as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateVolume as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteStoragePoolProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteStoragePoolProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateVolume with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateVolumeRequest(), + ); + request.volume ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateVolumeRequest', + ['volume', 'name'], + ); + request.volume.name = defaultValue1; + const expectedHeaderRequestParams = `volume.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateVolume = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateVolume(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateVolume as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateVolume as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteStoragePoolProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteStoragePoolProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpdateVolumeProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateVolumeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('validateDirectoryService', () => { - it('invokes validateDirectoryService without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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 checkUpdateVolumeProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkUpdateVolumeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteVolume', () => { + it('invokes deleteVolume without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteVolumeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteVolumeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteVolume = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteVolume(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteVolume as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteVolume 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', - }); - await 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|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - 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 deleteVolume without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteVolumeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteVolumeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteVolume = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteVolume( + 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.deleteVolume as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteVolume 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', - }); - await 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 deleteVolume with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteVolumeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteVolumeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteVolume = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteVolume(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteVolume as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteVolume 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', - }); - await 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 deleteVolume with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteVolumeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteVolumeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteVolume = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteVolume(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteVolume as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteVolume 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', - }); - await 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 checkDeleteVolumeProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteVolumeProgress( + 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', - }); - await 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)); - }); + it('invokes checkDeleteVolumeProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkDeleteVolumeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('revertVolume', () => { + it('invokes revertVolume without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.RevertVolumeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.RevertVolumeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.revertVolume = stubLongRunningCall(expectedResponse); + const [operation] = await client.revertVolume(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.revertVolume as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.revertVolume as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('switchActiveReplicaZone', () => { - it('invokes switchActiveReplicaZone without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.SwitchActiveReplicaZoneRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.SwitchActiveReplicaZoneRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.switchActiveReplicaZone = stubLongRunningCall(expectedResponse); - const [operation] = await client.switchActiveReplicaZone(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.switchActiveReplicaZone as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.switchActiveReplicaZone as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes revertVolume without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.RevertVolumeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.RevertVolumeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.revertVolume = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.revertVolume( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.revertVolume as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.revertVolume as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes switchActiveReplicaZone without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.SwitchActiveReplicaZoneRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.SwitchActiveReplicaZoneRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.switchActiveReplicaZone = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.switchActiveReplicaZone( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.switchActiveReplicaZone as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.switchActiveReplicaZone as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes revertVolume with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.RevertVolumeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.RevertVolumeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.revertVolume = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.revertVolume(request), expectedError); + const actualRequest = ( + client.innerApiCalls.revertVolume as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.revertVolume as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes switchActiveReplicaZone with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.SwitchActiveReplicaZoneRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.SwitchActiveReplicaZoneRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.switchActiveReplicaZone = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.switchActiveReplicaZone(request), expectedError); - const actualRequest = (client.innerApiCalls.switchActiveReplicaZone as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.switchActiveReplicaZone as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes revertVolume with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.RevertVolumeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.RevertVolumeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.revertVolume = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.revertVolume(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.revertVolume as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.revertVolume as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes switchActiveReplicaZone with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.SwitchActiveReplicaZoneRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.SwitchActiveReplicaZoneRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.switchActiveReplicaZone = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.switchActiveReplicaZone(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.switchActiveReplicaZone as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.switchActiveReplicaZone as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRevertVolumeProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkRevertVolumeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkSwitchActiveReplicaZoneProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkSwitchActiveReplicaZoneProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkRevertVolumeProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkRevertVolumeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('establishVolumePeering', () => { + it('invokes establishVolumePeering without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.EstablishVolumePeeringRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.EstablishVolumePeeringRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.establishVolumePeering = + stubLongRunningCall(expectedResponse); + const [operation] = await client.establishVolumePeering(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.establishVolumePeering as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.establishVolumePeering as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkSwitchActiveReplicaZoneProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkSwitchActiveReplicaZoneProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes establishVolumePeering without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.EstablishVolumePeeringRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.EstablishVolumePeeringRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.establishVolumePeering = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.establishVolumePeering( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.IVolume, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.establishVolumePeering as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.establishVolumePeering as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createVolume', () => { - it('invokes createVolume without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateVolumeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateVolumeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createVolume = stubLongRunningCall(expectedResponse); - const [operation] = await client.createVolume(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createVolume as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createVolume as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes establishVolumePeering with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.EstablishVolumePeeringRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.EstablishVolumePeeringRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.establishVolumePeering = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.establishVolumePeering(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.establishVolumePeering as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.establishVolumePeering as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createVolume without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateVolumeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateVolumeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createVolume = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createVolume( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createVolume as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createVolume as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes establishVolumePeering with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.EstablishVolumePeeringRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.EstablishVolumePeeringRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.establishVolumePeering = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.establishVolumePeering(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.establishVolumePeering as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.establishVolumePeering as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createVolume with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateVolumeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateVolumeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createVolume = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createVolume(request), expectedError); - const actualRequest = (client.innerApiCalls.createVolume as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createVolume as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkEstablishVolumePeeringProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkEstablishVolumePeeringProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createVolume with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateVolumeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateVolumeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createVolume = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createVolume(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createVolume as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createVolume as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkEstablishVolumePeeringProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkEstablishVolumePeeringProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createSnapshot', () => { + it('invokes createSnapshot without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateSnapshotRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateSnapshotRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createSnapshot = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createSnapshot(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createSnapshot as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSnapshot as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateVolumeProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateVolumeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createSnapshot without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateSnapshotRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateSnapshotRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createSnapshot = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createSnapshot( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.ISnapshot, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.ISnapshot, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createSnapshot as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSnapshot as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateVolumeProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateVolumeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createSnapshot with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateSnapshotRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateSnapshotRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createSnapshot = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createSnapshot(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createSnapshot as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSnapshot as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateVolume', () => { - it('invokes updateVolume without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateVolumeRequest() - ); - request.volume ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateVolumeRequest', ['volume', 'name']); - request.volume.name = defaultValue1; - const expectedHeaderRequestParams = `volume.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateVolume = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateVolume(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateVolume as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateVolume as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createSnapshot with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateSnapshotRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateSnapshotRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createSnapshot = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createSnapshot(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createSnapshot as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSnapshot as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateVolume without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateVolumeRequest() - ); - request.volume ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateVolumeRequest', ['volume', 'name']); - request.volume.name = defaultValue1; - const expectedHeaderRequestParams = `volume.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateVolume = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateVolume( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateVolume as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateVolume as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateSnapshotProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateSnapshotProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateVolume with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateVolumeRequest() - ); - request.volume ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateVolumeRequest', ['volume', 'name']); - request.volume.name = defaultValue1; - const expectedHeaderRequestParams = `volume.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateVolume = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateVolume(request), expectedError); - const actualRequest = (client.innerApiCalls.updateVolume as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateVolume as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateSnapshotProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateSnapshotProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteSnapshot', () => { + it('invokes deleteSnapshot without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteSnapshotRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteSnapshotRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteSnapshot = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteSnapshot(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteSnapshot as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSnapshot as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateVolume with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateVolumeRequest() - ); - request.volume ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateVolumeRequest', ['volume', 'name']); - request.volume.name = defaultValue1; - const expectedHeaderRequestParams = `volume.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateVolume = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateVolume(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateVolume as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateVolume as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteSnapshot without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteSnapshotRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteSnapshotRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteSnapshot = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteSnapshot( + 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.deleteSnapshot as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSnapshot as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateVolumeProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateVolumeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteSnapshot with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteSnapshotRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteSnapshotRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteSnapshot = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteSnapshot(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteSnapshot as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSnapshot as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateVolumeProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateVolumeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteSnapshot with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteSnapshotRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteSnapshotRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteSnapshot = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteSnapshot(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteSnapshot as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSnapshot as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteVolume', () => { - it('invokes deleteVolume without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteVolumeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteVolumeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteVolume = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteVolume(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteVolume as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteVolume as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteSnapshotProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteSnapshotProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteVolume without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteVolumeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteVolumeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteVolume = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteVolume( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteVolume as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteVolume as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteSnapshotProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteSnapshotProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateSnapshot', () => { + it('invokes updateSnapshot without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateSnapshotRequest(), + ); + request.snapshot ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateSnapshotRequest', + ['snapshot', 'name'], + ); + request.snapshot.name = defaultValue1; + const expectedHeaderRequestParams = `snapshot.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateSnapshot = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateSnapshot(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateSnapshot as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSnapshot as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteVolume with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteVolumeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteVolumeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteVolume = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteVolume(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteVolume as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteVolume as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateSnapshot without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateSnapshotRequest(), + ); + request.snapshot ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateSnapshotRequest', + ['snapshot', 'name'], + ); + request.snapshot.name = defaultValue1; + const expectedHeaderRequestParams = `snapshot.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateSnapshot = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateSnapshot( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.ISnapshot, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.ISnapshot, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateSnapshot as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSnapshot as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteVolume with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteVolumeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteVolumeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteVolume = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteVolume(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteVolume as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteVolume as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateSnapshot with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateSnapshotRequest(), + ); + request.snapshot ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateSnapshotRequest', + ['snapshot', 'name'], + ); + request.snapshot.name = defaultValue1; + const expectedHeaderRequestParams = `snapshot.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateSnapshot = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateSnapshot(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateSnapshot as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSnapshot as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteVolumeProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteVolumeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateSnapshot with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateSnapshotRequest(), + ); + request.snapshot ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateSnapshotRequest', + ['snapshot', 'name'], + ); + request.snapshot.name = defaultValue1; + const expectedHeaderRequestParams = `snapshot.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateSnapshot = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateSnapshot(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateSnapshot as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSnapshot as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteVolumeProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteVolumeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpdateSnapshotProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateSnapshotProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('revertVolume', () => { - it('invokes revertVolume without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.RevertVolumeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.RevertVolumeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.revertVolume = stubLongRunningCall(expectedResponse); - const [operation] = await client.revertVolume(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.revertVolume as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.revertVolume as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateSnapshotProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateSnapshotProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createActiveDirectory', () => { + it('invokes createActiveDirectory without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateActiveDirectoryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateActiveDirectoryRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createActiveDirectory = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createActiveDirectory(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createActiveDirectory as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createActiveDirectory as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes revertVolume without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.RevertVolumeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.RevertVolumeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.revertVolume = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.revertVolume( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.revertVolume as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.revertVolume as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createActiveDirectory without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateActiveDirectoryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateActiveDirectoryRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createActiveDirectory = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createActiveDirectory( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.IActiveDirectory, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.IActiveDirectory, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createActiveDirectory as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createActiveDirectory as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes revertVolume with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.RevertVolumeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.RevertVolumeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.revertVolume = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.revertVolume(request), expectedError); - const actualRequest = (client.innerApiCalls.revertVolume as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.revertVolume as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createActiveDirectory with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateActiveDirectoryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateActiveDirectoryRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createActiveDirectory = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.createActiveDirectory(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createActiveDirectory as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createActiveDirectory as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes revertVolume with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.RevertVolumeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.RevertVolumeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.revertVolume = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.revertVolume(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.revertVolume as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.revertVolume as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createActiveDirectory with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateActiveDirectoryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateActiveDirectoryRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createActiveDirectory = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createActiveDirectory(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createActiveDirectory as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createActiveDirectory as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRevertVolumeProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkRevertVolumeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkCreateActiveDirectoryProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateActiveDirectoryProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkRevertVolumeProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRevertVolumeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateActiveDirectoryProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateActiveDirectoryProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateActiveDirectory', () => { + it('invokes updateActiveDirectory without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateActiveDirectoryRequest(), + ); + request.activeDirectory ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateActiveDirectoryRequest', + ['activeDirectory', 'name'], + ); + request.activeDirectory.name = defaultValue1; + const expectedHeaderRequestParams = `active_directory.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateActiveDirectory = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateActiveDirectory(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateActiveDirectory as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateActiveDirectory as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('establishVolumePeering', () => { - it('invokes establishVolumePeering without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.EstablishVolumePeeringRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.EstablishVolumePeeringRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.establishVolumePeering = stubLongRunningCall(expectedResponse); - const [operation] = await client.establishVolumePeering(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.establishVolumePeering as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.establishVolumePeering as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateActiveDirectory without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateActiveDirectoryRequest(), + ); + request.activeDirectory ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateActiveDirectoryRequest', + ['activeDirectory', 'name'], + ); + request.activeDirectory.name = defaultValue1; + const expectedHeaderRequestParams = `active_directory.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateActiveDirectory = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateActiveDirectory( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.IActiveDirectory, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.IActiveDirectory, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateActiveDirectory as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateActiveDirectory as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes establishVolumePeering without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.EstablishVolumePeeringRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.EstablishVolumePeeringRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.establishVolumePeering = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.establishVolumePeering( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.establishVolumePeering as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.establishVolumePeering as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateActiveDirectory with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateActiveDirectoryRequest(), + ); + request.activeDirectory ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateActiveDirectoryRequest', + ['activeDirectory', 'name'], + ); + request.activeDirectory.name = defaultValue1; + const expectedHeaderRequestParams = `active_directory.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateActiveDirectory = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.updateActiveDirectory(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.updateActiveDirectory as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateActiveDirectory as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes establishVolumePeering with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.EstablishVolumePeeringRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.EstablishVolumePeeringRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.establishVolumePeering = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.establishVolumePeering(request), expectedError); - const actualRequest = (client.innerApiCalls.establishVolumePeering as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.establishVolumePeering as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateActiveDirectory with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateActiveDirectoryRequest(), + ); + request.activeDirectory ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateActiveDirectoryRequest', + ['activeDirectory', 'name'], + ); + request.activeDirectory.name = defaultValue1; + const expectedHeaderRequestParams = `active_directory.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateActiveDirectory = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateActiveDirectory(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateActiveDirectory as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateActiveDirectory as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes establishVolumePeering with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.EstablishVolumePeeringRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.EstablishVolumePeeringRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.establishVolumePeering = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.establishVolumePeering(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.establishVolumePeering as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.establishVolumePeering as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateActiveDirectoryProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateActiveDirectoryProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkEstablishVolumePeeringProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkEstablishVolumePeeringProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateActiveDirectoryProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateActiveDirectoryProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteActiveDirectory', () => { + it('invokes deleteActiveDirectory without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteActiveDirectoryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteActiveDirectoryRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteActiveDirectory = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteActiveDirectory(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteActiveDirectory as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteActiveDirectory as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkEstablishVolumePeeringProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkEstablishVolumePeeringProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteActiveDirectory without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteActiveDirectoryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteActiveDirectoryRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteActiveDirectory = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteActiveDirectory( + 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.deleteActiveDirectory as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteActiveDirectory as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createSnapshot', () => { - it('invokes createSnapshot without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateSnapshotRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateSnapshotRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createSnapshot = stubLongRunningCall(expectedResponse); - const [operation] = await client.createSnapshot(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createSnapshot as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSnapshot as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteActiveDirectory with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteActiveDirectoryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteActiveDirectoryRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteActiveDirectory = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.deleteActiveDirectory(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteActiveDirectory as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteActiveDirectory as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createSnapshot without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateSnapshotRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateSnapshotRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createSnapshot = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createSnapshot( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createSnapshot as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSnapshot as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteActiveDirectory with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteActiveDirectoryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteActiveDirectoryRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteActiveDirectory = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteActiveDirectory(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteActiveDirectory as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteActiveDirectory as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createSnapshot with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateSnapshotRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateSnapshotRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createSnapshot = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createSnapshot(request), expectedError); - const actualRequest = (client.innerApiCalls.createSnapshot as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSnapshot as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteActiveDirectoryProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteActiveDirectoryProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createSnapshot with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateSnapshotRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateSnapshotRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createSnapshot = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createSnapshot(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createSnapshot as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSnapshot as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteActiveDirectoryProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteActiveDirectoryProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createKmsConfig', () => { + it('invokes createKmsConfig without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateKmsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateKmsConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createKmsConfig = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createKmsConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createKmsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createKmsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateSnapshotProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateSnapshotProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createKmsConfig without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateKmsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateKmsConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createKmsConfig = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createKmsConfig( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createKmsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createKmsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateSnapshotProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateSnapshotProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createKmsConfig with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateKmsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateKmsConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createKmsConfig = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createKmsConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createKmsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createKmsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteSnapshot', () => { - it('invokes deleteSnapshot without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteSnapshotRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteSnapshotRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteSnapshot = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteSnapshot(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteSnapshot as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSnapshot as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createKmsConfig with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateKmsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateKmsConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createKmsConfig = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createKmsConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createKmsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createKmsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteSnapshot without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteSnapshotRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteSnapshotRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteSnapshot = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteSnapshot( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteSnapshot as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSnapshot as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateKmsConfigProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateKmsConfigProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteSnapshot with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteSnapshotRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteSnapshotRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteSnapshot = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteSnapshot(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteSnapshot as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSnapshot as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateKmsConfigProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateKmsConfigProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateKmsConfig', () => { + it('invokes updateKmsConfig without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateKmsConfigRequest(), + ); + request.kmsConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateKmsConfigRequest', + ['kmsConfig', 'name'], + ); + request.kmsConfig.name = defaultValue1; + const expectedHeaderRequestParams = `kms_config.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateKmsConfig = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateKmsConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateKmsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateKmsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteSnapshot with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteSnapshotRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteSnapshotRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteSnapshot = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteSnapshot(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteSnapshot as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSnapshot as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateKmsConfig without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateKmsConfigRequest(), + ); + request.kmsConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateKmsConfigRequest', + ['kmsConfig', 'name'], + ); + request.kmsConfig.name = defaultValue1; + const expectedHeaderRequestParams = `kms_config.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateKmsConfig = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateKmsConfig( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateKmsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateKmsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteSnapshotProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteSnapshotProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateKmsConfig with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateKmsConfigRequest(), + ); + request.kmsConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateKmsConfigRequest', + ['kmsConfig', 'name'], + ); + request.kmsConfig.name = defaultValue1; + const expectedHeaderRequestParams = `kms_config.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateKmsConfig = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateKmsConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateKmsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateKmsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteSnapshotProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteSnapshotProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateKmsConfig with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateKmsConfigRequest(), + ); + request.kmsConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateKmsConfigRequest', + ['kmsConfig', 'name'], + ); + request.kmsConfig.name = defaultValue1; + const expectedHeaderRequestParams = `kms_config.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateKmsConfig = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateKmsConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateKmsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateKmsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateSnapshot', () => { - it('invokes updateSnapshot without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateSnapshotRequest() - ); - request.snapshot ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateSnapshotRequest', ['snapshot', 'name']); - request.snapshot.name = defaultValue1; - const expectedHeaderRequestParams = `snapshot.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateSnapshot = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateSnapshot(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateSnapshot as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSnapshot as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateKmsConfigProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateKmsConfigProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateSnapshot without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateSnapshotRequest() - ); - request.snapshot ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateSnapshotRequest', ['snapshot', 'name']); - request.snapshot.name = defaultValue1; - const expectedHeaderRequestParams = `snapshot.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateSnapshot = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateSnapshot( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateSnapshot as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSnapshot as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateKmsConfigProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateKmsConfigProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('encryptVolumes', () => { + it('invokes encryptVolumes without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.EncryptVolumesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.EncryptVolumesRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.encryptVolumes = + stubLongRunningCall(expectedResponse); + const [operation] = await client.encryptVolumes(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.encryptVolumes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.encryptVolumes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateSnapshot with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateSnapshotRequest() - ); - request.snapshot ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateSnapshotRequest', ['snapshot', 'name']); - request.snapshot.name = defaultValue1; - const expectedHeaderRequestParams = `snapshot.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateSnapshot = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateSnapshot(request), expectedError); - const actualRequest = (client.innerApiCalls.updateSnapshot as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSnapshot as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes encryptVolumes without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.EncryptVolumesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.EncryptVolumesRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.encryptVolumes = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.encryptVolumes( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.IKmsConfig, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.encryptVolumes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.encryptVolumes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateSnapshot with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateSnapshotRequest() - ); - request.snapshot ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateSnapshotRequest', ['snapshot', 'name']); - request.snapshot.name = defaultValue1; - const expectedHeaderRequestParams = `snapshot.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateSnapshot = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateSnapshot(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateSnapshot as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSnapshot as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes encryptVolumes with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.EncryptVolumesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.EncryptVolumesRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.encryptVolumes = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.encryptVolumes(request), expectedError); + const actualRequest = ( + client.innerApiCalls.encryptVolumes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.encryptVolumes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateSnapshotProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateSnapshotProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes encryptVolumes with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.EncryptVolumesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.EncryptVolumesRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.encryptVolumes = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.encryptVolumes(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.encryptVolumes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.encryptVolumes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateSnapshotProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateSnapshotProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkEncryptVolumesProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkEncryptVolumesProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('createActiveDirectory', () => { - it('invokes createActiveDirectory without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateActiveDirectoryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateActiveDirectoryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createActiveDirectory = stubLongRunningCall(expectedResponse); - const [operation] = await client.createActiveDirectory(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createActiveDirectory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createActiveDirectory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkEncryptVolumesProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkEncryptVolumesProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteKmsConfig', () => { + it('invokes deleteKmsConfig without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteKmsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteKmsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteKmsConfig = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteKmsConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteKmsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteKmsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createActiveDirectory without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateActiveDirectoryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateActiveDirectoryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createActiveDirectory = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createActiveDirectory( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createActiveDirectory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createActiveDirectory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteKmsConfig without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteKmsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteKmsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteKmsConfig = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteKmsConfig( + 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.deleteKmsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteKmsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createActiveDirectory with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateActiveDirectoryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateActiveDirectoryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createActiveDirectory = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createActiveDirectory(request), expectedError); - const actualRequest = (client.innerApiCalls.createActiveDirectory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createActiveDirectory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteKmsConfig with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteKmsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteKmsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteKmsConfig = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteKmsConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteKmsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteKmsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createActiveDirectory with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateActiveDirectoryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateActiveDirectoryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createActiveDirectory = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createActiveDirectory(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createActiveDirectory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createActiveDirectory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteKmsConfig with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteKmsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteKmsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteKmsConfig = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteKmsConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteKmsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteKmsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateActiveDirectoryProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateActiveDirectoryProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkDeleteKmsConfigProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteKmsConfigProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkCreateActiveDirectoryProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateActiveDirectoryProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteKmsConfigProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteKmsConfigProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createReplication', () => { + it('invokes createReplication without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateReplicationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateReplicationRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createReplication = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createReplication(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createReplication as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createReplication as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateActiveDirectory', () => { - it('invokes updateActiveDirectory without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateActiveDirectoryRequest() - ); - request.activeDirectory ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateActiveDirectoryRequest', ['activeDirectory', 'name']); - request.activeDirectory.name = defaultValue1; - const expectedHeaderRequestParams = `active_directory.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateActiveDirectory = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateActiveDirectory(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateActiveDirectory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateActiveDirectory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createReplication without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateReplicationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateReplicationRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createReplication = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createReplication( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createReplication as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createReplication as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateActiveDirectory without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateActiveDirectoryRequest() - ); - request.activeDirectory ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateActiveDirectoryRequest', ['activeDirectory', 'name']); - request.activeDirectory.name = defaultValue1; - const expectedHeaderRequestParams = `active_directory.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateActiveDirectory = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateActiveDirectory( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateActiveDirectory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateActiveDirectory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createReplication with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateReplicationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateReplicationRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createReplication = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createReplication(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createReplication as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createReplication as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateActiveDirectory with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateActiveDirectoryRequest() - ); - request.activeDirectory ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateActiveDirectoryRequest', ['activeDirectory', 'name']); - request.activeDirectory.name = defaultValue1; - const expectedHeaderRequestParams = `active_directory.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateActiveDirectory = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateActiveDirectory(request), expectedError); - const actualRequest = (client.innerApiCalls.updateActiveDirectory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateActiveDirectory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createReplication with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateReplicationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateReplicationRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createReplication = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createReplication(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createReplication as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createReplication as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateActiveDirectory with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateActiveDirectoryRequest() - ); - request.activeDirectory ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateActiveDirectoryRequest', ['activeDirectory', 'name']); - request.activeDirectory.name = defaultValue1; - const expectedHeaderRequestParams = `active_directory.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateActiveDirectory = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateActiveDirectory(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateActiveDirectory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateActiveDirectory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateReplicationProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateReplicationProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkUpdateActiveDirectoryProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateActiveDirectoryProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkCreateReplicationProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateReplicationProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteReplication', () => { + it('invokes deleteReplication without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteReplicationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteReplicationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteReplication = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteReplication(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteReplication as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteReplication as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateActiveDirectoryProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateActiveDirectoryProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteReplication without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteReplicationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteReplicationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteReplication = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteReplication( + 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.deleteReplication as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteReplication as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteActiveDirectory', () => { - it('invokes deleteActiveDirectory without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteActiveDirectoryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteActiveDirectoryRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteActiveDirectory = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteActiveDirectory(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteActiveDirectory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteActiveDirectory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteReplication with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteReplicationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteReplicationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteReplication = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteReplication(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteReplication as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteReplication as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteActiveDirectory without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteActiveDirectoryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteActiveDirectoryRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteActiveDirectory = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteActiveDirectory( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteActiveDirectory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteActiveDirectory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteReplication with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteReplicationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteReplicationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteReplication = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteReplication(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteReplication as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteReplication as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteActiveDirectory with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteActiveDirectoryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteActiveDirectoryRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteActiveDirectory = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteActiveDirectory(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteActiveDirectory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteActiveDirectory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteReplicationProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteReplicationProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteActiveDirectory with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteActiveDirectoryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteActiveDirectoryRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteActiveDirectory = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteActiveDirectory(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteActiveDirectory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteActiveDirectory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteReplicationProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteReplicationProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateReplication', () => { + it('invokes updateReplication without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateReplicationRequest(), + ); + request.replication ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateReplicationRequest', + ['replication', 'name'], + ); + request.replication.name = defaultValue1; + const expectedHeaderRequestParams = `replication.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateReplication = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateReplication(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateReplication as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateReplication as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteActiveDirectoryProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteActiveDirectoryProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateReplication without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateReplicationRequest(), + ); + request.replication ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateReplicationRequest', + ['replication', 'name'], + ); + request.replication.name = defaultValue1; + const expectedHeaderRequestParams = `replication.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateReplication = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateReplication( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateReplication as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateReplication as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteActiveDirectoryProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteActiveDirectoryProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateReplication with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateReplicationRequest(), + ); + request.replication ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateReplicationRequest', + ['replication', 'name'], + ); + request.replication.name = defaultValue1; + const expectedHeaderRequestParams = `replication.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateReplication = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateReplication(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateReplication as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateReplication as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createKmsConfig', () => { - it('invokes createKmsConfig without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateKmsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateKmsConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createKmsConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.createKmsConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createKmsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createKmsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateReplication with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateReplicationRequest(), + ); + request.replication ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateReplicationRequest', + ['replication', 'name'], + ); + request.replication.name = defaultValue1; + const expectedHeaderRequestParams = `replication.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateReplication = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateReplication(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateReplication as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateReplication as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createKmsConfig without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateKmsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateKmsConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createKmsConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createKmsConfig( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createKmsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createKmsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateReplicationProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateReplicationProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createKmsConfig with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateKmsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateKmsConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createKmsConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createKmsConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.createKmsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createKmsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateReplicationProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateReplicationProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('stopReplication', () => { + it('invokes stopReplication without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.StopReplicationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.StopReplicationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.stopReplication = + stubLongRunningCall(expectedResponse); + const [operation] = await client.stopReplication(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.stopReplication as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopReplication as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createKmsConfig with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateKmsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateKmsConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createKmsConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createKmsConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createKmsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createKmsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes stopReplication without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.StopReplicationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.StopReplicationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.stopReplication = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.stopReplication( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.stopReplication as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopReplication as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateKmsConfigProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateKmsConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes stopReplication with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.StopReplicationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.StopReplicationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.stopReplication = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.stopReplication(request), expectedError); + const actualRequest = ( + client.innerApiCalls.stopReplication as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopReplication as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateKmsConfigProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateKmsConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes stopReplication with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.StopReplicationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.StopReplicationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.stopReplication = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.stopReplication(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.stopReplication as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopReplication as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateKmsConfig', () => { - it('invokes updateKmsConfig without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateKmsConfigRequest() - ); - request.kmsConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateKmsConfigRequest', ['kmsConfig', 'name']); - request.kmsConfig.name = defaultValue1; - const expectedHeaderRequestParams = `kms_config.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateKmsConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateKmsConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateKmsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateKmsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkStopReplicationProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkStopReplicationProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateKmsConfig without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateKmsConfigRequest() - ); - request.kmsConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateKmsConfigRequest', ['kmsConfig', 'name']); - request.kmsConfig.name = defaultValue1; - const expectedHeaderRequestParams = `kms_config.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateKmsConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateKmsConfig( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateKmsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateKmsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkStopReplicationProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkStopReplicationProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('resumeReplication', () => { + it('invokes resumeReplication without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ResumeReplicationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ResumeReplicationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.resumeReplication = + stubLongRunningCall(expectedResponse); + const [operation] = await client.resumeReplication(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resumeReplication as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resumeReplication as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateKmsConfig with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateKmsConfigRequest() - ); - request.kmsConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateKmsConfigRequest', ['kmsConfig', 'name']); - request.kmsConfig.name = defaultValue1; - const expectedHeaderRequestParams = `kms_config.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateKmsConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateKmsConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.updateKmsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateKmsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes resumeReplication without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ResumeReplicationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ResumeReplicationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.resumeReplication = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resumeReplication( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resumeReplication as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resumeReplication as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateKmsConfig with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateKmsConfigRequest() - ); - request.kmsConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateKmsConfigRequest', ['kmsConfig', 'name']); - request.kmsConfig.name = defaultValue1; - const expectedHeaderRequestParams = `kms_config.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateKmsConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateKmsConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateKmsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateKmsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes resumeReplication with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ResumeReplicationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ResumeReplicationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resumeReplication = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.resumeReplication(request), expectedError); + const actualRequest = ( + client.innerApiCalls.resumeReplication as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resumeReplication as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateKmsConfigProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateKmsConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes resumeReplication with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ResumeReplicationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ResumeReplicationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resumeReplication = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.resumeReplication(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.resumeReplication as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resumeReplication as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateKmsConfigProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateKmsConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkResumeReplicationProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkResumeReplicationProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('encryptVolumes', () => { - it('invokes encryptVolumes without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.EncryptVolumesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.EncryptVolumesRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.encryptVolumes = stubLongRunningCall(expectedResponse); - const [operation] = await client.encryptVolumes(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.encryptVolumes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.encryptVolumes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkResumeReplicationProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkResumeReplicationProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('reverseReplicationDirection', () => { + it('invokes reverseReplicationDirection without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ReverseReplicationDirectionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ReverseReplicationDirectionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.reverseReplicationDirection = + stubLongRunningCall(expectedResponse); + const [operation] = await client.reverseReplicationDirection(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.reverseReplicationDirection as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reverseReplicationDirection as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes encryptVolumes without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.EncryptVolumesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.EncryptVolumesRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.encryptVolumes = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.encryptVolumes( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.encryptVolumes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.encryptVolumes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes reverseReplicationDirection without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ReverseReplicationDirectionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ReverseReplicationDirectionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.reverseReplicationDirection = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.reverseReplicationDirection( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.reverseReplicationDirection as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reverseReplicationDirection as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes encryptVolumes with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.EncryptVolumesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.EncryptVolumesRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.encryptVolumes = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.encryptVolumes(request), expectedError); - const actualRequest = (client.innerApiCalls.encryptVolumes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.encryptVolumes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes reverseReplicationDirection with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ReverseReplicationDirectionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ReverseReplicationDirectionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.reverseReplicationDirection = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.reverseReplicationDirection(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.reverseReplicationDirection as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reverseReplicationDirection as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes encryptVolumes with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.EncryptVolumesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.EncryptVolumesRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.encryptVolumes = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.encryptVolumes(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.encryptVolumes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.encryptVolumes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes reverseReplicationDirection with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ReverseReplicationDirectionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ReverseReplicationDirectionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.reverseReplicationDirection = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.reverseReplicationDirection(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.reverseReplicationDirection as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reverseReplicationDirection as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkEncryptVolumesProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkEncryptVolumesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkReverseReplicationDirectionProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkReverseReplicationDirectionProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkEncryptVolumesProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkEncryptVolumesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkReverseReplicationDirectionProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkReverseReplicationDirectionProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('establishPeering', () => { + it('invokes establishPeering without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.EstablishPeeringRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.EstablishPeeringRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.establishPeering = + stubLongRunningCall(expectedResponse); + const [operation] = await client.establishPeering(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.establishPeering as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.establishPeering as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteKmsConfig', () => { - it('invokes deleteKmsConfig without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteKmsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteKmsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteKmsConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteKmsConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteKmsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteKmsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes establishPeering without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.EstablishPeeringRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.EstablishPeeringRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.establishPeering = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.establishPeering( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.establishPeering as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.establishPeering as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteKmsConfig without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteKmsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteKmsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteKmsConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteKmsConfig( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteKmsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteKmsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes establishPeering with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.EstablishPeeringRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.EstablishPeeringRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.establishPeering = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.establishPeering(request), expectedError); + const actualRequest = ( + client.innerApiCalls.establishPeering as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.establishPeering as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteKmsConfig with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteKmsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteKmsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteKmsConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteKmsConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteKmsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteKmsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes establishPeering with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.EstablishPeeringRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.EstablishPeeringRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.establishPeering = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.establishPeering(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.establishPeering as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.establishPeering as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteKmsConfig with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteKmsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteKmsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteKmsConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteKmsConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteKmsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteKmsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkEstablishPeeringProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkEstablishPeeringProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteKmsConfigProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteKmsConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkEstablishPeeringProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkEstablishPeeringProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('syncReplication', () => { + it('invokes syncReplication without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.SyncReplicationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.SyncReplicationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.syncReplication = + stubLongRunningCall(expectedResponse); + const [operation] = await client.syncReplication(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.syncReplication as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.syncReplication as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteKmsConfigProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteKmsConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes syncReplication without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.SyncReplicationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.SyncReplicationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.syncReplication = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.syncReplication( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.IReplication, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.syncReplication as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.syncReplication as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createReplication', () => { - it('invokes createReplication without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateReplicationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateReplicationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createReplication = stubLongRunningCall(expectedResponse); - const [operation] = await client.createReplication(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createReplication as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createReplication as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes syncReplication with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.SyncReplicationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.SyncReplicationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.syncReplication = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.syncReplication(request), expectedError); + const actualRequest = ( + client.innerApiCalls.syncReplication as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.syncReplication as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createReplication without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateReplicationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateReplicationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createReplication = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createReplication( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createReplication as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createReplication as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes syncReplication with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.SyncReplicationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.SyncReplicationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.syncReplication = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.syncReplication(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.syncReplication as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.syncReplication as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createReplication with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateReplicationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateReplicationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createReplication = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createReplication(request), expectedError); - const actualRequest = (client.innerApiCalls.createReplication as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createReplication as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkSyncReplicationProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkSyncReplicationProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createReplication with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateReplicationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateReplicationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createReplication = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createReplication(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createReplication as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createReplication as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkSyncReplicationProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkSyncReplicationProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createBackupVault', () => { + it('invokes createBackupVault without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateBackupVaultRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateBackupVaultRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createBackupVault = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createBackupVault(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createBackupVault as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBackupVault as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateReplicationProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateReplicationProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createBackupVault without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateBackupVaultRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateBackupVaultRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createBackupVault = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createBackupVault( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.IBackupVault, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.IBackupVault, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createBackupVault as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBackupVault as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateReplicationProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateReplicationProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createBackupVault with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateBackupVaultRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateBackupVaultRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createBackupVault = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createBackupVault(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createBackupVault as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBackupVault as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteReplication', () => { - it('invokes deleteReplication without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteReplicationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteReplicationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteReplication = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteReplication(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteReplication as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteReplication as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createBackupVault with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateBackupVaultRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateBackupVaultRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createBackupVault = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createBackupVault(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createBackupVault as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBackupVault as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteReplication without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteReplicationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteReplicationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteReplication = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteReplication( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteReplication as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteReplication as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateBackupVaultProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateBackupVaultProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteReplication with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteReplicationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteReplicationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteReplication = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteReplication(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteReplication as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteReplication as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateBackupVaultProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateBackupVaultProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateBackupVault', () => { + it('invokes updateBackupVault without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateBackupVaultRequest(), + ); + request.backupVault ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateBackupVaultRequest', + ['backupVault', 'name'], + ); + request.backupVault.name = defaultValue1; + const expectedHeaderRequestParams = `backup_vault.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateBackupVault = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateBackupVault(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateBackupVault as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateBackupVault as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteReplication with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteReplicationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteReplicationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteReplication = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteReplication(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteReplication as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteReplication as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateBackupVault without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateBackupVaultRequest(), + ); + request.backupVault ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateBackupVaultRequest', + ['backupVault', 'name'], + ); + request.backupVault.name = defaultValue1; + const expectedHeaderRequestParams = `backup_vault.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateBackupVault = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateBackupVault( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.IBackupVault, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.IBackupVault, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateBackupVault as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateBackupVault as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteReplicationProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteReplicationProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateBackupVault with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateBackupVaultRequest(), + ); + request.backupVault ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateBackupVaultRequest', + ['backupVault', 'name'], + ); + request.backupVault.name = defaultValue1; + const expectedHeaderRequestParams = `backup_vault.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateBackupVault = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateBackupVault(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateBackupVault as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateBackupVault as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteReplicationProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteReplicationProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateBackupVault with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateBackupVaultRequest(), + ); + request.backupVault ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateBackupVaultRequest', + ['backupVault', 'name'], + ); + request.backupVault.name = defaultValue1; + const expectedHeaderRequestParams = `backup_vault.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateBackupVault = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateBackupVault(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateBackupVault as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateBackupVault as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateReplication', () => { - it('invokes updateReplication without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateReplicationRequest() - ); - request.replication ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateReplicationRequest', ['replication', 'name']); - request.replication.name = defaultValue1; - const expectedHeaderRequestParams = `replication.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateReplication = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateReplication(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateReplication as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateReplication as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateBackupVaultProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateBackupVaultProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateReplication without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateReplicationRequest() - ); - request.replication ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateReplicationRequest', ['replication', 'name']); - request.replication.name = defaultValue1; - const expectedHeaderRequestParams = `replication.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateReplication = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateReplication( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateReplication as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateReplication as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateBackupVaultProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateBackupVaultProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteBackupVault', () => { + it('invokes deleteBackupVault without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteBackupVaultRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteBackupVaultRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteBackupVault = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteBackupVault(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteBackupVault as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBackupVault as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateReplication with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateReplicationRequest() - ); - request.replication ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateReplicationRequest', ['replication', 'name']); - request.replication.name = defaultValue1; - const expectedHeaderRequestParams = `replication.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateReplication = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateReplication(request), expectedError); - const actualRequest = (client.innerApiCalls.updateReplication as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateReplication as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteBackupVault without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteBackupVaultRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteBackupVaultRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteBackupVault = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteBackupVault( + 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.deleteBackupVault as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBackupVault as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateReplication with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateReplicationRequest() - ); - request.replication ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateReplicationRequest', ['replication', 'name']); - request.replication.name = defaultValue1; - const expectedHeaderRequestParams = `replication.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateReplication = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateReplication(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateReplication as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateReplication as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteBackupVault with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteBackupVaultRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteBackupVaultRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteBackupVault = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteBackupVault(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteBackupVault as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBackupVault as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateReplicationProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateReplicationProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteBackupVault with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteBackupVaultRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteBackupVaultRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteBackupVault = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteBackupVault(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteBackupVault as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBackupVault as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateReplicationProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateReplicationProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteBackupVaultProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteBackupVaultProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('stopReplication', () => { - it('invokes stopReplication without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.StopReplicationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.StopReplicationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.stopReplication = stubLongRunningCall(expectedResponse); - const [operation] = await client.stopReplication(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.stopReplication as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopReplication as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteBackupVaultProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteBackupVaultProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createBackup', () => { + it('invokes createBackup without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateBackupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createBackup = stubLongRunningCall(expectedResponse); + const [operation] = await client.createBackup(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes stopReplication without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.StopReplicationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.StopReplicationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.stopReplication = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.stopReplication( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.stopReplication as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopReplication as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createBackup without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateBackupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createBackup = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createBackup( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.IBackup, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.IBackup, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes stopReplication with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.StopReplicationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.StopReplicationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.stopReplication = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.stopReplication(request), expectedError); - const actualRequest = (client.innerApiCalls.stopReplication as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopReplication as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createBackup with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateBackupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createBackup = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createBackup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes stopReplication with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.StopReplicationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.StopReplicationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.stopReplication = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.stopReplication(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.stopReplication as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopReplication as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createBackup with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateBackupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createBackup = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createBackup(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkStopReplicationProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkStopReplicationProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkCreateBackupProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateBackupProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkStopReplicationProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkStopReplicationProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateBackupProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkCreateBackupProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteBackup', () => { + it('invokes deleteBackup without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteBackup = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteBackup(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('resumeReplication', () => { - it('invokes resumeReplication without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ResumeReplicationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ResumeReplicationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.resumeReplication = stubLongRunningCall(expectedResponse); - const [operation] = await client.resumeReplication(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resumeReplication as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeReplication as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteBackup without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteBackup = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteBackup( + 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.deleteBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes resumeReplication without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ResumeReplicationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ResumeReplicationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.resumeReplication = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.resumeReplication( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resumeReplication as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeReplication as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteBackup with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteBackup = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteBackup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes resumeReplication with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ResumeReplicationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ResumeReplicationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.resumeReplication = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.resumeReplication(request), expectedError); - const actualRequest = (client.innerApiCalls.resumeReplication as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeReplication as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resumeReplication with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ResumeReplicationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ResumeReplicationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.resumeReplication = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.resumeReplication(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.resumeReplication as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeReplication as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkResumeReplicationProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkResumeReplicationProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkResumeReplicationProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkResumeReplicationProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteBackup with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteBackup = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteBackup(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('reverseReplicationDirection', () => { - it('invokes reverseReplicationDirection without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ReverseReplicationDirectionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ReverseReplicationDirectionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.reverseReplicationDirection = stubLongRunningCall(expectedResponse); - const [operation] = await client.reverseReplicationDirection(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.reverseReplicationDirection as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reverseReplicationDirection as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes reverseReplicationDirection without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ReverseReplicationDirectionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ReverseReplicationDirectionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.reverseReplicationDirection = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.reverseReplicationDirection( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.reverseReplicationDirection as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reverseReplicationDirection as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes reverseReplicationDirection with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ReverseReplicationDirectionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ReverseReplicationDirectionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.reverseReplicationDirection = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.reverseReplicationDirection(request), expectedError); - const actualRequest = (client.innerApiCalls.reverseReplicationDirection as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reverseReplicationDirection as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes reverseReplicationDirection with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ReverseReplicationDirectionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ReverseReplicationDirectionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.reverseReplicationDirection = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.reverseReplicationDirection(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.reverseReplicationDirection as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reverseReplicationDirection as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkReverseReplicationDirectionProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkReverseReplicationDirectionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkReverseReplicationDirectionProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkReverseReplicationDirectionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteBackupProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteBackupProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('establishPeering', () => { - it('invokes establishPeering without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.EstablishPeeringRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.EstablishPeeringRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.establishPeering = stubLongRunningCall(expectedResponse); - const [operation] = await client.establishPeering(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.establishPeering as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.establishPeering as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes establishPeering without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.EstablishPeeringRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.EstablishPeeringRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.establishPeering = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.establishPeering( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.establishPeering as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.establishPeering as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes establishPeering with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.EstablishPeeringRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.EstablishPeeringRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.establishPeering = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.establishPeering(request), expectedError); - const actualRequest = (client.innerApiCalls.establishPeering as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.establishPeering as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes establishPeering with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.EstablishPeeringRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.EstablishPeeringRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.establishPeering = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.establishPeering(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.establishPeering as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.establishPeering as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkEstablishPeeringProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkEstablishPeeringProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkEstablishPeeringProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkEstablishPeeringProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteBackupProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkDeleteBackupProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - - describe('syncReplication', () => { - it('invokes syncReplication without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.SyncReplicationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.SyncReplicationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.syncReplication = stubLongRunningCall(expectedResponse); - const [operation] = await client.syncReplication(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.syncReplication as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.syncReplication as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes syncReplication without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.SyncReplicationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.SyncReplicationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.syncReplication = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.syncReplication( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.syncReplication as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.syncReplication as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes syncReplication with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.SyncReplicationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.SyncReplicationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.syncReplication = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.syncReplication(request), expectedError); - const actualRequest = (client.innerApiCalls.syncReplication as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.syncReplication as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes syncReplication with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.SyncReplicationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.SyncReplicationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.syncReplication = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.syncReplication(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.syncReplication as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.syncReplication as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkSyncReplicationProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkSyncReplicationProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkSyncReplicationProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkSyncReplicationProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + }); + + describe('updateBackup', () => { + it('invokes updateBackup without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateBackupRequest(), + ); + request.backup ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateBackupRequest', + ['backup', 'name'], + ); + request.backup.name = defaultValue1; + const expectedHeaderRequestParams = `backup.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateBackup = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateBackup(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createBackupVault', () => { - it('invokes createBackupVault without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateBackupVaultRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateBackupVaultRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createBackupVault = stubLongRunningCall(expectedResponse); - const [operation] = await client.createBackupVault(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createBackupVault as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createBackupVault as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createBackupVault without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateBackupVaultRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateBackupVaultRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createBackupVault = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createBackupVault( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createBackupVault as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createBackupVault as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createBackupVault with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateBackupVaultRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateBackupVaultRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createBackupVault = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createBackupVault(request), expectedError); - const actualRequest = (client.innerApiCalls.createBackupVault as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createBackupVault as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createBackupVault with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateBackupVaultRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateBackupVaultRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createBackupVault = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createBackupVault(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createBackupVault as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createBackupVault as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateBackupVaultProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateBackupVaultProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateBackupVaultProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateBackupVaultProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateBackup without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateBackupRequest(), + ); + request.backup ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateBackupRequest', + ['backup', 'name'], + ); + request.backup.name = defaultValue1; + const expectedHeaderRequestParams = `backup.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateBackup = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateBackup( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.IBackup, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.IBackup, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateBackupVault', () => { - it('invokes updateBackupVault without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateBackupVaultRequest() - ); - request.backupVault ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateBackupVaultRequest', ['backupVault', 'name']); - request.backupVault.name = defaultValue1; - const expectedHeaderRequestParams = `backup_vault.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateBackupVault = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateBackupVault(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateBackupVault as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateBackupVault as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateBackupVault without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateBackupVaultRequest() - ); - request.backupVault ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateBackupVaultRequest', ['backupVault', 'name']); - request.backupVault.name = defaultValue1; - const expectedHeaderRequestParams = `backup_vault.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateBackupVault = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateBackupVault( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateBackupVault as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateBackupVault as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateBackupVault with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateBackupVaultRequest() - ); - request.backupVault ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateBackupVaultRequest', ['backupVault', 'name']); - request.backupVault.name = defaultValue1; - const expectedHeaderRequestParams = `backup_vault.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateBackupVault = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateBackupVault(request), expectedError); - const actualRequest = (client.innerApiCalls.updateBackupVault as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateBackupVault as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateBackupVault with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateBackupVaultRequest() - ); - request.backupVault ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateBackupVaultRequest', ['backupVault', 'name']); - request.backupVault.name = defaultValue1; - const expectedHeaderRequestParams = `backup_vault.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateBackupVault = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateBackupVault(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateBackupVault as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateBackupVault as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateBackupVaultProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateBackupVaultProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateBackupVaultProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateBackupVaultProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateBackup with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateBackupRequest(), + ); + request.backup ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateBackupRequest', + ['backup', 'name'], + ); + request.backup.name = defaultValue1; + const expectedHeaderRequestParams = `backup.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateBackup = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateBackup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteBackupVault', () => { - it('invokes deleteBackupVault without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteBackupVaultRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteBackupVaultRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteBackupVault = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteBackupVault(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteBackupVault as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteBackupVault as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteBackupVault without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteBackupVaultRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteBackupVaultRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteBackupVault = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteBackupVault( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteBackupVault as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteBackupVault as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteBackupVault with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteBackupVaultRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteBackupVaultRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteBackupVault = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteBackupVault(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteBackupVault as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteBackupVault as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteBackupVault with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteBackupVaultRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteBackupVaultRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteBackupVault = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteBackupVault(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteBackupVault as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteBackupVault as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteBackupVaultProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteBackupVaultProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteBackupVaultProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteBackupVaultProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateBackup with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateBackupRequest(), + ); + request.backup ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateBackupRequest', + ['backup', 'name'], + ); + request.backup.name = defaultValue1; + const expectedHeaderRequestParams = `backup.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateBackup = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateBackup(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createBackup', () => { - it('invokes createBackup without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createBackup = stubLongRunningCall(expectedResponse); - const [operation] = await client.createBackup(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createBackup without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createBackup = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createBackup( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createBackup with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createBackup = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createBackup(request), expectedError); - const actualRequest = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createBackup with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createBackup = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createBackup(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateBackupProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateBackupProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateBackupProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateBackupProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpdateBackupProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateBackupProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('deleteBackup', () => { - it('invokes deleteBackup without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteBackup = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteBackup(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteBackup without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteBackup = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteBackup( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteBackup with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteBackup = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteBackup(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteBackup with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteBackup = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteBackup(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteBackupProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteBackupProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteBackupProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteBackupProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpdateBackupProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkUpdateBackupProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - - describe('updateBackup', () => { - it('invokes updateBackup without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateBackupRequest() - ); - request.backup ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateBackupRequest', ['backup', 'name']); - request.backup.name = defaultValue1; - const expectedHeaderRequestParams = `backup.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateBackup = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateBackup(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateBackup without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateBackupRequest() - ); - request.backup ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateBackupRequest', ['backup', 'name']); - request.backup.name = defaultValue1; - const expectedHeaderRequestParams = `backup.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateBackup = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateBackup( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateBackup with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateBackupRequest() - ); - request.backup ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateBackupRequest', ['backup', 'name']); - request.backup.name = defaultValue1; - const expectedHeaderRequestParams = `backup.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateBackup = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateBackup(request), expectedError); - const actualRequest = (client.innerApiCalls.updateBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateBackup with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateBackupRequest() - ); - request.backup ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateBackupRequest', ['backup', 'name']); - request.backup.name = defaultValue1; - const expectedHeaderRequestParams = `backup.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateBackup = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateBackup(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateBackupProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateBackupProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateBackupProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateBackupProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + }); + + describe('createBackupPolicy', () => { + it('invokes createBackupPolicy without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateBackupPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateBackupPolicyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createBackupPolicy = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createBackupPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createBackupPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBackupPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createBackupPolicy', () => { - it('invokes createBackupPolicy without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateBackupPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateBackupPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createBackupPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.createBackupPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createBackupPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createBackupPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createBackupPolicy without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateBackupPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateBackupPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createBackupPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createBackupPolicy( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createBackupPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createBackupPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createBackupPolicy with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateBackupPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateBackupPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createBackupPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createBackupPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.createBackupPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createBackupPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createBackupPolicy with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateBackupPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateBackupPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createBackupPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createBackupPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createBackupPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createBackupPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateBackupPolicyProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateBackupPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateBackupPolicyProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateBackupPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createBackupPolicy without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateBackupPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateBackupPolicyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createBackupPolicy = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createBackupPolicy( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.IBackupPolicy, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.IBackupPolicy, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createBackupPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBackupPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateBackupPolicy', () => { - it('invokes updateBackupPolicy without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateBackupPolicyRequest() - ); - request.backupPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateBackupPolicyRequest', ['backupPolicy', 'name']); - request.backupPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `backup_policy.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateBackupPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateBackupPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateBackupPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateBackupPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateBackupPolicy without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateBackupPolicyRequest() - ); - request.backupPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateBackupPolicyRequest', ['backupPolicy', 'name']); - request.backupPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `backup_policy.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateBackupPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateBackupPolicy( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateBackupPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateBackupPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateBackupPolicy with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateBackupPolicyRequest() - ); - request.backupPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateBackupPolicyRequest', ['backupPolicy', 'name']); - request.backupPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `backup_policy.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateBackupPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateBackupPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.updateBackupPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateBackupPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateBackupPolicy with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateBackupPolicyRequest() - ); - request.backupPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateBackupPolicyRequest', ['backupPolicy', 'name']); - request.backupPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `backup_policy.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateBackupPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateBackupPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateBackupPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateBackupPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateBackupPolicyProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateBackupPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createBackupPolicy with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateBackupPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateBackupPolicyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createBackupPolicy = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createBackupPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createBackupPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBackupPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateBackupPolicyProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateBackupPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createBackupPolicy with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateBackupPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateBackupPolicyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createBackupPolicy = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createBackupPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createBackupPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBackupPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteBackupPolicy', () => { - it('invokes deleteBackupPolicy without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteBackupPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteBackupPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteBackupPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteBackupPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteBackupPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteBackupPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateBackupPolicyProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateBackupPolicyProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteBackupPolicy without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteBackupPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteBackupPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteBackupPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteBackupPolicy( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteBackupPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteBackupPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateBackupPolicyProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateBackupPolicyProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateBackupPolicy', () => { + it('invokes updateBackupPolicy without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateBackupPolicyRequest(), + ); + request.backupPolicy ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateBackupPolicyRequest', + ['backupPolicy', 'name'], + ); + request.backupPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `backup_policy.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateBackupPolicy = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateBackupPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateBackupPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateBackupPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteBackupPolicy with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteBackupPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteBackupPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteBackupPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteBackupPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteBackupPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteBackupPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateBackupPolicy without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateBackupPolicyRequest(), + ); + request.backupPolicy ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateBackupPolicyRequest', + ['backupPolicy', 'name'], + ); + request.backupPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `backup_policy.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateBackupPolicy = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateBackupPolicy( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.IBackupPolicy, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.IBackupPolicy, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateBackupPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateBackupPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteBackupPolicy with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteBackupPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteBackupPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteBackupPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteBackupPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteBackupPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteBackupPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateBackupPolicy with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateBackupPolicyRequest(), + ); + request.backupPolicy ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateBackupPolicyRequest', + ['backupPolicy', 'name'], + ); + request.backupPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `backup_policy.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateBackupPolicy = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateBackupPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateBackupPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateBackupPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteBackupPolicyProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteBackupPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateBackupPolicy with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateBackupPolicyRequest(), + ); + request.backupPolicy ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateBackupPolicyRequest', + ['backupPolicy', 'name'], + ); + request.backupPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `backup_policy.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateBackupPolicy = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateBackupPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateBackupPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateBackupPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteBackupPolicyProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteBackupPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpdateBackupPolicyProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateBackupPolicyProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('createQuotaRule', () => { - it('invokes createQuotaRule without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateQuotaRuleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateQuotaRuleRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createQuotaRule = stubLongRunningCall(expectedResponse); - const [operation] = await client.createQuotaRule(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createQuotaRule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createQuotaRule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateBackupPolicyProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateBackupPolicyProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteBackupPolicy', () => { + it('invokes deleteBackupPolicy without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteBackupPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteBackupPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteBackupPolicy = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteBackupPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteBackupPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBackupPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createQuotaRule without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateQuotaRuleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateQuotaRuleRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createQuotaRule = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createQuotaRule( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createQuotaRule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createQuotaRule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteBackupPolicy without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteBackupPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteBackupPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteBackupPolicy = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteBackupPolicy( + 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.deleteBackupPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBackupPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createQuotaRule with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateQuotaRuleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateQuotaRuleRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createQuotaRule = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createQuotaRule(request), expectedError); - const actualRequest = (client.innerApiCalls.createQuotaRule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createQuotaRule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteBackupPolicy with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteBackupPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteBackupPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteBackupPolicy = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteBackupPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteBackupPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBackupPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createQuotaRule with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateQuotaRuleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateQuotaRuleRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createQuotaRule = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createQuotaRule(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createQuotaRule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createQuotaRule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteBackupPolicy with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteBackupPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteBackupPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteBackupPolicy = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteBackupPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteBackupPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBackupPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateQuotaRuleProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateQuotaRuleProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkDeleteBackupPolicyProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteBackupPolicyProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkCreateQuotaRuleProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateQuotaRuleProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteBackupPolicyProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteBackupPolicyProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createQuotaRule', () => { + it('invokes createQuotaRule without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateQuotaRuleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateQuotaRuleRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createQuotaRule = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createQuotaRule(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createQuotaRule as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createQuotaRule as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateQuotaRule', () => { - it('invokes updateQuotaRule without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateQuotaRuleRequest() - ); - request.quotaRule ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateQuotaRuleRequest', ['quotaRule', 'name']); - request.quotaRule.name = defaultValue1; - const expectedHeaderRequestParams = `quota_rule.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateQuotaRule = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateQuotaRule(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateQuotaRule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateQuotaRule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createQuotaRule without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateQuotaRuleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateQuotaRuleRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createQuotaRule = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createQuotaRule( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.IQuotaRule, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.IQuotaRule, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createQuotaRule as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createQuotaRule as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateQuotaRule without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateQuotaRuleRequest() - ); - request.quotaRule ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateQuotaRuleRequest', ['quotaRule', 'name']); - request.quotaRule.name = defaultValue1; - const expectedHeaderRequestParams = `quota_rule.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateQuotaRule = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateQuotaRule( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateQuotaRule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateQuotaRule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createQuotaRule with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateQuotaRuleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateQuotaRuleRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createQuotaRule = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createQuotaRule(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createQuotaRule as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createQuotaRule as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateQuotaRule with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateQuotaRuleRequest() - ); - request.quotaRule ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateQuotaRuleRequest', ['quotaRule', 'name']); - request.quotaRule.name = defaultValue1; - const expectedHeaderRequestParams = `quota_rule.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateQuotaRule = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateQuotaRule(request), expectedError); - const actualRequest = (client.innerApiCalls.updateQuotaRule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateQuotaRule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createQuotaRule with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateQuotaRuleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateQuotaRuleRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createQuotaRule = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createQuotaRule(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createQuotaRule as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createQuotaRule as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateQuotaRule with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateQuotaRuleRequest() - ); - request.quotaRule ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateQuotaRuleRequest', ['quotaRule', 'name']); - request.quotaRule.name = defaultValue1; - const expectedHeaderRequestParams = `quota_rule.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateQuotaRule = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateQuotaRule(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateQuotaRule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateQuotaRule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateQuotaRuleProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateQuotaRuleProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkUpdateQuotaRuleProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateQuotaRuleProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkCreateQuotaRuleProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateQuotaRuleProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateQuotaRule', () => { + it('invokes updateQuotaRule without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateQuotaRuleRequest(), + ); + request.quotaRule ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateQuotaRuleRequest', + ['quotaRule', 'name'], + ); + request.quotaRule.name = defaultValue1; + const expectedHeaderRequestParams = `quota_rule.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateQuotaRule = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateQuotaRule(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateQuotaRule as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateQuotaRule as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateQuotaRuleProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateQuotaRuleProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateQuotaRule without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateQuotaRuleRequest(), + ); + request.quotaRule ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateQuotaRuleRequest', + ['quotaRule', 'name'], + ); + request.quotaRule.name = defaultValue1; + const expectedHeaderRequestParams = `quota_rule.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateQuotaRule = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateQuotaRule( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.IQuotaRule, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.IQuotaRule, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateQuotaRule as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateQuotaRule as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteQuotaRule', () => { - it('invokes deleteQuotaRule without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteQuotaRuleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteQuotaRuleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteQuotaRule = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteQuotaRule(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteQuotaRule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteQuotaRule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateQuotaRule with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateQuotaRuleRequest(), + ); + request.quotaRule ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateQuotaRuleRequest', + ['quotaRule', 'name'], + ); + request.quotaRule.name = defaultValue1; + const expectedHeaderRequestParams = `quota_rule.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateQuotaRule = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateQuotaRule(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateQuotaRule as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateQuotaRule as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteQuotaRule without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteQuotaRuleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteQuotaRuleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteQuotaRule = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteQuotaRule( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteQuotaRule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteQuotaRule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateQuotaRule with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateQuotaRuleRequest(), + ); + request.quotaRule ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateQuotaRuleRequest', + ['quotaRule', 'name'], + ); + request.quotaRule.name = defaultValue1; + const expectedHeaderRequestParams = `quota_rule.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateQuotaRule = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateQuotaRule(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateQuotaRule as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateQuotaRule as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteQuotaRule with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteQuotaRuleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteQuotaRuleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteQuotaRule = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteQuotaRule(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteQuotaRule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteQuotaRule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateQuotaRuleProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateQuotaRuleProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteQuotaRule with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteQuotaRuleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteQuotaRuleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteQuotaRule = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteQuotaRule(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteQuotaRule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteQuotaRule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateQuotaRuleProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateQuotaRuleProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteQuotaRule', () => { + it('invokes deleteQuotaRule without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteQuotaRuleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteQuotaRuleRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteQuotaRule = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteQuotaRule(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteQuotaRule as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteQuotaRule as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteQuotaRuleProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteQuotaRuleProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteQuotaRule without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteQuotaRuleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteQuotaRuleRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteQuotaRule = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteQuotaRule( + 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.deleteQuotaRule as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteQuotaRule as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteQuotaRuleProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteQuotaRuleProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteQuotaRule with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteQuotaRuleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteQuotaRuleRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteQuotaRule = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteQuotaRule(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteQuotaRule as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteQuotaRule as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('restoreBackupFiles', () => { - it('invokes restoreBackupFiles without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.RestoreBackupFilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.RestoreBackupFilesRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.restoreBackupFiles = stubLongRunningCall(expectedResponse); - const [operation] = await client.restoreBackupFiles(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.restoreBackupFiles as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreBackupFiles as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteQuotaRule with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteQuotaRuleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteQuotaRuleRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteQuotaRule = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteQuotaRule(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteQuotaRule as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteQuotaRule as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes restoreBackupFiles without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.RestoreBackupFilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.RestoreBackupFilesRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.restoreBackupFiles = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.restoreBackupFiles( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.restoreBackupFiles as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreBackupFiles as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteQuotaRuleProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteQuotaRuleProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes restoreBackupFiles with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.RestoreBackupFilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.RestoreBackupFilesRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.restoreBackupFiles = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.restoreBackupFiles(request), expectedError); - const actualRequest = (client.innerApiCalls.restoreBackupFiles as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreBackupFiles as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteQuotaRuleProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteQuotaRuleProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('restoreBackupFiles', () => { + it('invokes restoreBackupFiles without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.RestoreBackupFilesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.RestoreBackupFilesRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.restoreBackupFiles = + stubLongRunningCall(expectedResponse); + const [operation] = await client.restoreBackupFiles(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.restoreBackupFiles as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreBackupFiles as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes restoreBackupFiles with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.RestoreBackupFilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.RestoreBackupFilesRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.restoreBackupFiles = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.restoreBackupFiles(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.restoreBackupFiles as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreBackupFiles as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes restoreBackupFiles without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.RestoreBackupFilesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.RestoreBackupFilesRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.restoreBackupFiles = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.restoreBackupFiles( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.IRestoreBackupFilesResponse, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.IRestoreBackupFilesResponse, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.restoreBackupFiles as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreBackupFiles as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRestoreBackupFilesProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkRestoreBackupFilesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes restoreBackupFiles with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.RestoreBackupFilesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.RestoreBackupFilesRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.restoreBackupFiles = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.restoreBackupFiles(request), expectedError); + const actualRequest = ( + client.innerApiCalls.restoreBackupFiles as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreBackupFiles as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRestoreBackupFilesProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRestoreBackupFilesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes restoreBackupFiles with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.RestoreBackupFilesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.RestoreBackupFilesRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.restoreBackupFiles = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.restoreBackupFiles(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.restoreBackupFiles as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreBackupFiles as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createHostGroup', () => { - it('invokes createHostGroup without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateHostGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateHostGroupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createHostGroup = stubLongRunningCall(expectedResponse); - const [operation] = await client.createHostGroup(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createHostGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createHostGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRestoreBackupFilesProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkRestoreBackupFilesProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createHostGroup without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateHostGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateHostGroupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createHostGroup = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createHostGroup( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createHostGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createHostGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRestoreBackupFilesProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkRestoreBackupFilesProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createHostGroup', () => { + it('invokes createHostGroup without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateHostGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateHostGroupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createHostGroup = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createHostGroup(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createHostGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createHostGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createHostGroup with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateHostGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateHostGroupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createHostGroup = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createHostGroup(request), expectedError); - const actualRequest = (client.innerApiCalls.createHostGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createHostGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createHostGroup without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateHostGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateHostGroupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createHostGroup = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createHostGroup( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.IHostGroup, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.IHostGroup, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createHostGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createHostGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createHostGroup with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.CreateHostGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.CreateHostGroupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createHostGroup = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createHostGroup(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createHostGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createHostGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createHostGroup with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateHostGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateHostGroupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createHostGroup = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createHostGroup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createHostGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createHostGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateHostGroupProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateHostGroupProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createHostGroup with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.CreateHostGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.CreateHostGroupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createHostGroup = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createHostGroup(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createHostGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createHostGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateHostGroupProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateHostGroupProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateHostGroupProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateHostGroupProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('updateHostGroup', () => { - it('invokes updateHostGroup without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateHostGroupRequest() - ); - request.hostGroup ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateHostGroupRequest', ['hostGroup', 'name']); - request.hostGroup.name = defaultValue1; - const expectedHeaderRequestParams = `host_group.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateHostGroup = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateHostGroup(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateHostGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateHostGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateHostGroupProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateHostGroupProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateHostGroup', () => { + it('invokes updateHostGroup without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateHostGroupRequest(), + ); + request.hostGroup ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateHostGroupRequest', + ['hostGroup', 'name'], + ); + request.hostGroup.name = defaultValue1; + const expectedHeaderRequestParams = `host_group.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateHostGroup = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateHostGroup(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateHostGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateHostGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateHostGroup without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateHostGroupRequest() - ); - request.hostGroup ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateHostGroupRequest', ['hostGroup', 'name']); - request.hostGroup.name = defaultValue1; - const expectedHeaderRequestParams = `host_group.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateHostGroup = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateHostGroup( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateHostGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateHostGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateHostGroup without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateHostGroupRequest(), + ); + request.hostGroup ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateHostGroupRequest', + ['hostGroup', 'name'], + ); + request.hostGroup.name = defaultValue1; + const expectedHeaderRequestParams = `host_group.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateHostGroup = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateHostGroup( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.netapp.v1.IHostGroup, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.netapp.v1.IHostGroup, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateHostGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateHostGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateHostGroup with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateHostGroupRequest() - ); - request.hostGroup ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateHostGroupRequest', ['hostGroup', 'name']); - request.hostGroup.name = defaultValue1; - const expectedHeaderRequestParams = `host_group.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateHostGroup = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateHostGroup(request), expectedError); - const actualRequest = (client.innerApiCalls.updateHostGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateHostGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateHostGroup with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateHostGroupRequest(), + ); + request.hostGroup ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateHostGroupRequest', + ['hostGroup', 'name'], + ); + request.hostGroup.name = defaultValue1; + const expectedHeaderRequestParams = `host_group.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateHostGroup = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateHostGroup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateHostGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateHostGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateHostGroup with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.UpdateHostGroupRequest() - ); - request.hostGroup ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.UpdateHostGroupRequest', ['hostGroup', 'name']); - request.hostGroup.name = defaultValue1; - const expectedHeaderRequestParams = `host_group.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateHostGroup = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateHostGroup(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateHostGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateHostGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateHostGroup with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.UpdateHostGroupRequest(), + ); + request.hostGroup ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.UpdateHostGroupRequest', + ['hostGroup', 'name'], + ); + request.hostGroup.name = defaultValue1; + const expectedHeaderRequestParams = `host_group.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateHostGroup = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateHostGroup(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateHostGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateHostGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateHostGroupProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateHostGroupProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateHostGroupProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateHostGroupProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkUpdateHostGroupProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateHostGroupProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpdateHostGroupProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateHostGroupProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteHostGroup', () => { + it('invokes deleteHostGroup without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteHostGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteHostGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteHostGroup = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteHostGroup(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteHostGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteHostGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteHostGroup', () => { - it('invokes deleteHostGroup without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteHostGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteHostGroupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteHostGroup = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteHostGroup(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteHostGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteHostGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteHostGroup without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteHostGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteHostGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteHostGroup = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteHostGroup( + 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.deleteHostGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteHostGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteHostGroup without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteHostGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteHostGroupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteHostGroup = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteHostGroup( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteHostGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteHostGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteHostGroup with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteHostGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteHostGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteHostGroup = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteHostGroup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteHostGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteHostGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteHostGroup with call error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteHostGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteHostGroupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteHostGroup = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteHostGroup(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteHostGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteHostGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteHostGroup with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.DeleteHostGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.DeleteHostGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteHostGroup = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteHostGroup(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteHostGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteHostGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteHostGroup with LRO error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.DeleteHostGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.DeleteHostGroupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteHostGroup = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteHostGroup(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteHostGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteHostGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteHostGroupProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteHostGroupProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteHostGroupProgress without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteHostGroupProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkDeleteHostGroupProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteHostGroupProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listStoragePools', () => { + it('invokes listStoragePools without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListStoragePoolsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListStoragePoolsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.StoragePool()), + generateSampleMessage(new protos.google.cloud.netapp.v1.StoragePool()), + generateSampleMessage(new protos.google.cloud.netapp.v1.StoragePool()), + ]; + client.innerApiCalls.listStoragePools = stubSimpleCall(expectedResponse); + const [response] = await client.listStoragePools(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listStoragePools as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listStoragePools as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteHostGroupProgress with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteHostGroupProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes listStoragePools without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListStoragePoolsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListStoragePoolsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.StoragePool()), + generateSampleMessage(new protos.google.cloud.netapp.v1.StoragePool()), + generateSampleMessage(new protos.google.cloud.netapp.v1.StoragePool()), + ]; + client.innerApiCalls.listStoragePools = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listStoragePools( + request, + ( + err?: Error | null, + result?: protos.google.cloud.netapp.v1.IStoragePool[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listStoragePools as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listStoragePools as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listStoragePools', () => { - it('invokes listStoragePools without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListStoragePoolsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListStoragePoolsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.StoragePool()), - generateSampleMessage(new protos.google.cloud.netapp.v1.StoragePool()), - generateSampleMessage(new protos.google.cloud.netapp.v1.StoragePool()), - ]; - client.innerApiCalls.listStoragePools = stubSimpleCall(expectedResponse); - const [response] = await client.listStoragePools(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listStoragePools as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listStoragePools as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listStoragePools with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListStoragePoolsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListStoragePoolsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listStoragePools = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listStoragePools(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listStoragePools as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listStoragePools as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listStoragePools without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListStoragePoolsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListStoragePoolsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.StoragePool()), - generateSampleMessage(new protos.google.cloud.netapp.v1.StoragePool()), - generateSampleMessage(new protos.google.cloud.netapp.v1.StoragePool()), - ]; - client.innerApiCalls.listStoragePools = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listStoragePools( - request, - (err?: Error|null, result?: protos.google.cloud.netapp.v1.IStoragePool[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listStoragePools as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listStoragePools as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listStoragePoolsStream without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListStoragePoolsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListStoragePoolsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.StoragePool()), + generateSampleMessage(new protos.google.cloud.netapp.v1.StoragePool()), + generateSampleMessage(new protos.google.cloud.netapp.v1.StoragePool()), + ]; + client.descriptors.page.listStoragePools.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listStoragePoolsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.netapp.v1.StoragePool[] = []; + stream.on( + 'data', + (response: protos.google.cloud.netapp.v1.StoragePool) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listStoragePools.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listStoragePools, request), + ); + assert( + (client.descriptors.page.listStoragePools.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listStoragePools with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListStoragePoolsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListStoragePoolsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listStoragePools = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listStoragePools(request), expectedError); - const actualRequest = (client.innerApiCalls.listStoragePools as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listStoragePools as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listStoragePoolsStream with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListStoragePoolsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListStoragePoolsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listStoragePools.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listStoragePoolsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.netapp.v1.StoragePool[] = []; + stream.on( + 'data', + (response: protos.google.cloud.netapp.v1.StoragePool) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listStoragePools.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listStoragePools, request), + ); + assert( + (client.descriptors.page.listStoragePools.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listStoragePoolsStream without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListStoragePoolsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListStoragePoolsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.StoragePool()), - generateSampleMessage(new protos.google.cloud.netapp.v1.StoragePool()), - generateSampleMessage(new protos.google.cloud.netapp.v1.StoragePool()), - ]; - client.descriptors.page.listStoragePools.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listStoragePoolsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.netapp.v1.StoragePool[] = []; - stream.on('data', (response: protos.google.cloud.netapp.v1.StoragePool) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listStoragePools.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listStoragePools, request)); - assert( - (client.descriptors.page.listStoragePools.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listStoragePools without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListStoragePoolsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListStoragePoolsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.StoragePool()), + generateSampleMessage(new protos.google.cloud.netapp.v1.StoragePool()), + generateSampleMessage(new protos.google.cloud.netapp.v1.StoragePool()), + ]; + client.descriptors.page.listStoragePools.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.netapp.v1.IStoragePool[] = []; + const iterable = client.listStoragePoolsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listStoragePools.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listStoragePools.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listStoragePoolsStream with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListStoragePoolsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListStoragePoolsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listStoragePools.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listStoragePoolsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.netapp.v1.StoragePool[] = []; - stream.on('data', (response: protos.google.cloud.netapp.v1.StoragePool) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listStoragePools.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listStoragePools, request)); - assert( - (client.descriptors.page.listStoragePools.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listStoragePools with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListStoragePoolsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListStoragePoolsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listStoragePools.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listStoragePoolsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.netapp.v1.IStoragePool[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listStoragePools.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listStoragePools.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listVolumes', () => { + it('invokes listVolumes without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListVolumesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListVolumesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.Volume()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Volume()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Volume()), + ]; + client.innerApiCalls.listVolumes = stubSimpleCall(expectedResponse); + const [response] = await client.listVolumes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listVolumes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listVolumes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listStoragePools without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListStoragePoolsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListStoragePoolsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.StoragePool()), - generateSampleMessage(new protos.google.cloud.netapp.v1.StoragePool()), - generateSampleMessage(new protos.google.cloud.netapp.v1.StoragePool()), - ]; - client.descriptors.page.listStoragePools.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.netapp.v1.IStoragePool[] = []; - const iterable = client.listStoragePoolsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listVolumes without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListVolumesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListVolumesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.Volume()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Volume()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Volume()), + ]; + client.innerApiCalls.listVolumes = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listVolumes( + request, + ( + err?: Error | null, + result?: protos.google.cloud.netapp.v1.IVolume[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listStoragePools.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listStoragePools.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listStoragePools with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListStoragePoolsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListStoragePoolsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listStoragePools.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listStoragePoolsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.netapp.v1.IStoragePool[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listStoragePools.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listStoragePools.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listVolumes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listVolumes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listVolumes', () => { - it('invokes listVolumes without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListVolumesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListVolumesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.Volume()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Volume()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Volume()), - ]; - client.innerApiCalls.listVolumes = stubSimpleCall(expectedResponse); - const [response] = await client.listVolumes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listVolumes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listVolumes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listVolumes with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListVolumesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListVolumesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listVolumes = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listVolumes(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listVolumes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listVolumes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listVolumes without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListVolumesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListVolumesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.Volume()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Volume()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Volume()), - ]; - client.innerApiCalls.listVolumes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listVolumes( - request, - (err?: Error|null, result?: protos.google.cloud.netapp.v1.IVolume[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listVolumes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listVolumes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listVolumesStream without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListVolumesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListVolumesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.Volume()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Volume()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Volume()), + ]; + client.descriptors.page.listVolumes.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listVolumesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.netapp.v1.Volume[] = []; + stream.on('data', (response: protos.google.cloud.netapp.v1.Volume) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listVolumes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listVolumes, request), + ); + assert( + (client.descriptors.page.listVolumes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listVolumes with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListVolumesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListVolumesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listVolumes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listVolumes(request), expectedError); - const actualRequest = (client.innerApiCalls.listVolumes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listVolumes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listVolumesStream with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListVolumesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListVolumesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listVolumes.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listVolumesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.netapp.v1.Volume[] = []; + stream.on('data', (response: protos.google.cloud.netapp.v1.Volume) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listVolumes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listVolumes, request), + ); + assert( + (client.descriptors.page.listVolumes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listVolumesStream without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListVolumesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListVolumesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.Volume()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Volume()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Volume()), - ]; - client.descriptors.page.listVolumes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listVolumesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.netapp.v1.Volume[] = []; - stream.on('data', (response: protos.google.cloud.netapp.v1.Volume) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listVolumes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listVolumes, request)); - assert( - (client.descriptors.page.listVolumes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listVolumes without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListVolumesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListVolumesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.Volume()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Volume()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Volume()), + ]; + client.descriptors.page.listVolumes.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.netapp.v1.IVolume[] = []; + const iterable = client.listVolumesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listVolumes.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listVolumes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listVolumesStream with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListVolumesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListVolumesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listVolumes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listVolumesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.netapp.v1.Volume[] = []; - stream.on('data', (response: protos.google.cloud.netapp.v1.Volume) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listVolumes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listVolumes, request)); - assert( - (client.descriptors.page.listVolumes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listVolumes with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListVolumesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListVolumesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listVolumes.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listVolumesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.netapp.v1.IVolume[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listVolumes.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listVolumes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listSnapshots', () => { + it('invokes listSnapshots without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListSnapshotsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListSnapshotsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.Snapshot()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Snapshot()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Snapshot()), + ]; + client.innerApiCalls.listSnapshots = stubSimpleCall(expectedResponse); + const [response] = await client.listSnapshots(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listSnapshots as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSnapshots as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listVolumes without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListVolumesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListVolumesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.Volume()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Volume()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Volume()), - ]; - client.descriptors.page.listVolumes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.netapp.v1.IVolume[] = []; - const iterable = client.listVolumesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listSnapshots without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListSnapshotsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListSnapshotsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.Snapshot()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Snapshot()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Snapshot()), + ]; + client.innerApiCalls.listSnapshots = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listSnapshots( + request, + ( + err?: Error | null, + result?: protos.google.cloud.netapp.v1.ISnapshot[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listVolumes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listVolumes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listVolumes with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListVolumesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListVolumesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listVolumes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listVolumesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.netapp.v1.IVolume[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listVolumes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listVolumes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listSnapshots as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSnapshots as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listSnapshots', () => { - it('invokes listSnapshots without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListSnapshotsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListSnapshotsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.Snapshot()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Snapshot()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Snapshot()), - ]; - client.innerApiCalls.listSnapshots = stubSimpleCall(expectedResponse); - const [response] = await client.listSnapshots(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSnapshots as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSnapshots as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listSnapshots with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListSnapshotsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListSnapshotsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listSnapshots = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listSnapshots(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listSnapshots as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSnapshots as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listSnapshots without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListSnapshotsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListSnapshotsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.Snapshot()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Snapshot()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Snapshot()), - ]; - client.innerApiCalls.listSnapshots = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listSnapshots( - request, - (err?: Error|null, result?: protos.google.cloud.netapp.v1.ISnapshot[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSnapshots as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSnapshots as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listSnapshotsStream without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListSnapshotsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListSnapshotsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.Snapshot()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Snapshot()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Snapshot()), + ]; + client.descriptors.page.listSnapshots.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listSnapshotsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.netapp.v1.Snapshot[] = []; + stream.on( + 'data', + (response: protos.google.cloud.netapp.v1.Snapshot) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listSnapshots.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listSnapshots, request), + ); + assert( + (client.descriptors.page.listSnapshots.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listSnapshots with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListSnapshotsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListSnapshotsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listSnapshots = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listSnapshots(request), expectedError); - const actualRequest = (client.innerApiCalls.listSnapshots as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSnapshots as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listSnapshotsStream with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListSnapshotsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListSnapshotsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSnapshots.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listSnapshotsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.netapp.v1.Snapshot[] = []; + stream.on( + 'data', + (response: protos.google.cloud.netapp.v1.Snapshot) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listSnapshots.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listSnapshots, request), + ); + assert( + (client.descriptors.page.listSnapshots.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listSnapshotsStream without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListSnapshotsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListSnapshotsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.Snapshot()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Snapshot()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Snapshot()), - ]; - client.descriptors.page.listSnapshots.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listSnapshotsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.netapp.v1.Snapshot[] = []; - stream.on('data', (response: protos.google.cloud.netapp.v1.Snapshot) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listSnapshots.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSnapshots, request)); - assert( - (client.descriptors.page.listSnapshots.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listSnapshots without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListSnapshotsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListSnapshotsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.Snapshot()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Snapshot()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Snapshot()), + ]; + client.descriptors.page.listSnapshots.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.netapp.v1.ISnapshot[] = []; + const iterable = client.listSnapshotsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listSnapshots.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listSnapshots.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listSnapshotsStream with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListSnapshotsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListSnapshotsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listSnapshots.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listSnapshotsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.netapp.v1.Snapshot[] = []; - stream.on('data', (response: protos.google.cloud.netapp.v1.Snapshot) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listSnapshots.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSnapshots, request)); - assert( - (client.descriptors.page.listSnapshots.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listSnapshots with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListSnapshotsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListSnapshotsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSnapshots.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listSnapshotsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.netapp.v1.ISnapshot[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listSnapshots.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listSnapshots.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listActiveDirectories', () => { + it('invokes listActiveDirectories without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListActiveDirectoriesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListActiveDirectoriesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.netapp.v1.ActiveDirectory(), + ), + generateSampleMessage( + new protos.google.cloud.netapp.v1.ActiveDirectory(), + ), + generateSampleMessage( + new protos.google.cloud.netapp.v1.ActiveDirectory(), + ), + ]; + client.innerApiCalls.listActiveDirectories = + stubSimpleCall(expectedResponse); + const [response] = await client.listActiveDirectories(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listActiveDirectories as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listActiveDirectories as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listSnapshots without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListSnapshotsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListSnapshotsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.Snapshot()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Snapshot()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Snapshot()), - ]; - client.descriptors.page.listSnapshots.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.netapp.v1.ISnapshot[] = []; - const iterable = client.listSnapshotsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listActiveDirectories without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListActiveDirectoriesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListActiveDirectoriesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.netapp.v1.ActiveDirectory(), + ), + generateSampleMessage( + new protos.google.cloud.netapp.v1.ActiveDirectory(), + ), + generateSampleMessage( + new protos.google.cloud.netapp.v1.ActiveDirectory(), + ), + ]; + client.innerApiCalls.listActiveDirectories = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listActiveDirectories( + request, + ( + err?: Error | null, + result?: protos.google.cloud.netapp.v1.IActiveDirectory[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listSnapshots.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSnapshots.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listSnapshots with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListSnapshotsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListSnapshotsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listSnapshots.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listSnapshotsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.netapp.v1.ISnapshot[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listSnapshots.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSnapshots.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listActiveDirectories as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listActiveDirectories as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listActiveDirectories', () => { - it('invokes listActiveDirectories without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListActiveDirectoriesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListActiveDirectoriesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.ActiveDirectory()), - generateSampleMessage(new protos.google.cloud.netapp.v1.ActiveDirectory()), - generateSampleMessage(new protos.google.cloud.netapp.v1.ActiveDirectory()), - ]; - client.innerApiCalls.listActiveDirectories = stubSimpleCall(expectedResponse); - const [response] = await client.listActiveDirectories(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listActiveDirectories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listActiveDirectories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listActiveDirectories with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListActiveDirectoriesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListActiveDirectoriesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listActiveDirectories = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listActiveDirectories(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listActiveDirectories as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listActiveDirectories as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listActiveDirectories without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListActiveDirectoriesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListActiveDirectoriesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.ActiveDirectory()), - generateSampleMessage(new protos.google.cloud.netapp.v1.ActiveDirectory()), - generateSampleMessage(new protos.google.cloud.netapp.v1.ActiveDirectory()), - ]; - client.innerApiCalls.listActiveDirectories = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listActiveDirectories( - request, - (err?: Error|null, result?: protos.google.cloud.netapp.v1.IActiveDirectory[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listActiveDirectories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listActiveDirectories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listActiveDirectoriesStream without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListActiveDirectoriesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListActiveDirectoriesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.netapp.v1.ActiveDirectory(), + ), + generateSampleMessage( + new protos.google.cloud.netapp.v1.ActiveDirectory(), + ), + generateSampleMessage( + new protos.google.cloud.netapp.v1.ActiveDirectory(), + ), + ]; + client.descriptors.page.listActiveDirectories.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listActiveDirectoriesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.netapp.v1.ActiveDirectory[] = []; + stream.on( + 'data', + (response: protos.google.cloud.netapp.v1.ActiveDirectory) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listActiveDirectories + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listActiveDirectories, request), + ); + assert( + ( + client.descriptors.page.listActiveDirectories + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listActiveDirectories with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListActiveDirectoriesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListActiveDirectoriesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listActiveDirectories = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listActiveDirectories(request), expectedError); - const actualRequest = (client.innerApiCalls.listActiveDirectories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listActiveDirectories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listActiveDirectoriesStream with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListActiveDirectoriesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListActiveDirectoriesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listActiveDirectories.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listActiveDirectoriesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.netapp.v1.ActiveDirectory[] = []; + stream.on( + 'data', + (response: protos.google.cloud.netapp.v1.ActiveDirectory) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listActiveDirectories + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listActiveDirectories, request), + ); + assert( + ( + client.descriptors.page.listActiveDirectories + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listActiveDirectoriesStream without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListActiveDirectoriesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListActiveDirectoriesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.ActiveDirectory()), - generateSampleMessage(new protos.google.cloud.netapp.v1.ActiveDirectory()), - generateSampleMessage(new protos.google.cloud.netapp.v1.ActiveDirectory()), - ]; - client.descriptors.page.listActiveDirectories.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listActiveDirectoriesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.netapp.v1.ActiveDirectory[] = []; - stream.on('data', (response: protos.google.cloud.netapp.v1.ActiveDirectory) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listActiveDirectories.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listActiveDirectories, request)); - assert( - (client.descriptors.page.listActiveDirectories.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listActiveDirectories without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListActiveDirectoriesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListActiveDirectoriesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.netapp.v1.ActiveDirectory(), + ), + generateSampleMessage( + new protos.google.cloud.netapp.v1.ActiveDirectory(), + ), + generateSampleMessage( + new protos.google.cloud.netapp.v1.ActiveDirectory(), + ), + ]; + client.descriptors.page.listActiveDirectories.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.netapp.v1.IActiveDirectory[] = []; + const iterable = client.listActiveDirectoriesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listActiveDirectories + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listActiveDirectories + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listActiveDirectoriesStream with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListActiveDirectoriesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListActiveDirectoriesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listActiveDirectories.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listActiveDirectoriesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.netapp.v1.ActiveDirectory[] = []; - stream.on('data', (response: protos.google.cloud.netapp.v1.ActiveDirectory) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listActiveDirectories.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listActiveDirectories, request)); - assert( - (client.descriptors.page.listActiveDirectories.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listActiveDirectories with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListActiveDirectoriesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListActiveDirectoriesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listActiveDirectories.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listActiveDirectoriesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.netapp.v1.IActiveDirectory[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listActiveDirectories + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listActiveDirectories + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('listKmsConfigs', () => { + it('invokes listKmsConfigs without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListKmsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListKmsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.KmsConfig()), + generateSampleMessage(new protos.google.cloud.netapp.v1.KmsConfig()), + generateSampleMessage(new protos.google.cloud.netapp.v1.KmsConfig()), + ]; + client.innerApiCalls.listKmsConfigs = stubSimpleCall(expectedResponse); + const [response] = await client.listKmsConfigs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listKmsConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listKmsConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listActiveDirectories without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListActiveDirectoriesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListActiveDirectoriesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.ActiveDirectory()), - generateSampleMessage(new protos.google.cloud.netapp.v1.ActiveDirectory()), - generateSampleMessage(new protos.google.cloud.netapp.v1.ActiveDirectory()), - ]; - client.descriptors.page.listActiveDirectories.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.netapp.v1.IActiveDirectory[] = []; - const iterable = client.listActiveDirectoriesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listKmsConfigs without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListKmsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListKmsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.KmsConfig()), + generateSampleMessage(new protos.google.cloud.netapp.v1.KmsConfig()), + generateSampleMessage(new protos.google.cloud.netapp.v1.KmsConfig()), + ]; + client.innerApiCalls.listKmsConfigs = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listKmsConfigs( + request, + ( + err?: Error | null, + result?: protos.google.cloud.netapp.v1.IKmsConfig[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listActiveDirectories.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listActiveDirectories.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listActiveDirectories with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListActiveDirectoriesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListActiveDirectoriesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listActiveDirectories.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listActiveDirectoriesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.netapp.v1.IActiveDirectory[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listActiveDirectories.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listActiveDirectories.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listKmsConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listKmsConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listKmsConfigs', () => { - it('invokes listKmsConfigs without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListKmsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListKmsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.KmsConfig()), - generateSampleMessage(new protos.google.cloud.netapp.v1.KmsConfig()), - generateSampleMessage(new protos.google.cloud.netapp.v1.KmsConfig()), - ]; - client.innerApiCalls.listKmsConfigs = stubSimpleCall(expectedResponse); - const [response] = await client.listKmsConfigs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listKmsConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listKmsConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listKmsConfigs with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListKmsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListKmsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listKmsConfigs = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listKmsConfigs(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listKmsConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listKmsConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listKmsConfigs without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListKmsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListKmsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.KmsConfig()), - generateSampleMessage(new protos.google.cloud.netapp.v1.KmsConfig()), - generateSampleMessage(new protos.google.cloud.netapp.v1.KmsConfig()), - ]; - client.innerApiCalls.listKmsConfigs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listKmsConfigs( - request, - (err?: Error|null, result?: protos.google.cloud.netapp.v1.IKmsConfig[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listKmsConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listKmsConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listKmsConfigsStream without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListKmsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListKmsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.KmsConfig()), + generateSampleMessage(new protos.google.cloud.netapp.v1.KmsConfig()), + generateSampleMessage(new protos.google.cloud.netapp.v1.KmsConfig()), + ]; + client.descriptors.page.listKmsConfigs.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listKmsConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.netapp.v1.KmsConfig[] = []; + stream.on( + 'data', + (response: protos.google.cloud.netapp.v1.KmsConfig) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listKmsConfigs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listKmsConfigs, request), + ); + assert( + (client.descriptors.page.listKmsConfigs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listKmsConfigs with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListKmsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListKmsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listKmsConfigs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listKmsConfigs(request), expectedError); - const actualRequest = (client.innerApiCalls.listKmsConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listKmsConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listKmsConfigsStream with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListKmsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListKmsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listKmsConfigs.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listKmsConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.netapp.v1.KmsConfig[] = []; + stream.on( + 'data', + (response: protos.google.cloud.netapp.v1.KmsConfig) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listKmsConfigs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listKmsConfigs, request), + ); + assert( + (client.descriptors.page.listKmsConfigs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listKmsConfigsStream without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListKmsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListKmsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.KmsConfig()), - generateSampleMessage(new protos.google.cloud.netapp.v1.KmsConfig()), - generateSampleMessage(new protos.google.cloud.netapp.v1.KmsConfig()), - ]; - client.descriptors.page.listKmsConfigs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listKmsConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.netapp.v1.KmsConfig[] = []; - stream.on('data', (response: protos.google.cloud.netapp.v1.KmsConfig) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listKmsConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listKmsConfigs, request)); - assert( - (client.descriptors.page.listKmsConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listKmsConfigs without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListKmsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListKmsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.KmsConfig()), + generateSampleMessage(new protos.google.cloud.netapp.v1.KmsConfig()), + generateSampleMessage(new protos.google.cloud.netapp.v1.KmsConfig()), + ]; + client.descriptors.page.listKmsConfigs.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.netapp.v1.IKmsConfig[] = []; + const iterable = client.listKmsConfigsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listKmsConfigs.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listKmsConfigs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listKmsConfigsStream with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListKmsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListKmsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listKmsConfigs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listKmsConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.netapp.v1.KmsConfig[] = []; - stream.on('data', (response: protos.google.cloud.netapp.v1.KmsConfig) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listKmsConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listKmsConfigs, request)); - assert( - (client.descriptors.page.listKmsConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listKmsConfigs with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListKmsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListKmsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listKmsConfigs.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listKmsConfigsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.netapp.v1.IKmsConfig[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listKmsConfigs.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listKmsConfigs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listReplications', () => { + it('invokes listReplications without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListReplicationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListReplicationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.Replication()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Replication()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Replication()), + ]; + client.innerApiCalls.listReplications = stubSimpleCall(expectedResponse); + const [response] = await client.listReplications(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listReplications as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listReplications as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listKmsConfigs without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListKmsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListKmsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.KmsConfig()), - generateSampleMessage(new protos.google.cloud.netapp.v1.KmsConfig()), - generateSampleMessage(new protos.google.cloud.netapp.v1.KmsConfig()), - ]; - client.descriptors.page.listKmsConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.netapp.v1.IKmsConfig[] = []; - const iterable = client.listKmsConfigsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listReplications without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListReplicationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListReplicationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.Replication()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Replication()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Replication()), + ]; + client.innerApiCalls.listReplications = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listReplications( + request, + ( + err?: Error | null, + result?: protos.google.cloud.netapp.v1.IReplication[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listKmsConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listKmsConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listKmsConfigs with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListKmsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListKmsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listKmsConfigs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listKmsConfigsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.netapp.v1.IKmsConfig[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listKmsConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listKmsConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listReplications as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listReplications as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listReplications', () => { - it('invokes listReplications without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListReplicationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListReplicationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.Replication()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Replication()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Replication()), - ]; - client.innerApiCalls.listReplications = stubSimpleCall(expectedResponse); - const [response] = await client.listReplications(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listReplications as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listReplications as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listReplications with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListReplicationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListReplicationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listReplications = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listReplications(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listReplications as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listReplications as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listReplications without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListReplicationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListReplicationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.Replication()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Replication()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Replication()), - ]; - client.innerApiCalls.listReplications = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listReplications( - request, - (err?: Error|null, result?: protos.google.cloud.netapp.v1.IReplication[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listReplications as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listReplications as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listReplicationsStream without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListReplicationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListReplicationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.Replication()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Replication()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Replication()), + ]; + client.descriptors.page.listReplications.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listReplicationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.netapp.v1.Replication[] = []; + stream.on( + 'data', + (response: protos.google.cloud.netapp.v1.Replication) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listReplications.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listReplications, request), + ); + assert( + (client.descriptors.page.listReplications.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listReplications with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListReplicationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListReplicationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listReplications = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listReplications(request), expectedError); - const actualRequest = (client.innerApiCalls.listReplications as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listReplications as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listReplicationsStream with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListReplicationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListReplicationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listReplications.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listReplicationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.netapp.v1.Replication[] = []; + stream.on( + 'data', + (response: protos.google.cloud.netapp.v1.Replication) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listReplications.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listReplications, request), + ); + assert( + (client.descriptors.page.listReplications.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listReplicationsStream without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListReplicationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListReplicationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.Replication()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Replication()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Replication()), - ]; - client.descriptors.page.listReplications.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listReplicationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.netapp.v1.Replication[] = []; - stream.on('data', (response: protos.google.cloud.netapp.v1.Replication) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listReplications.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReplications, request)); - assert( - (client.descriptors.page.listReplications.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listReplications without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListReplicationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListReplicationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.Replication()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Replication()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Replication()), + ]; + client.descriptors.page.listReplications.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.netapp.v1.IReplication[] = []; + const iterable = client.listReplicationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listReplications.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listReplications.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listReplicationsStream with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListReplicationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListReplicationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listReplications.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listReplicationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.netapp.v1.Replication[] = []; - stream.on('data', (response: protos.google.cloud.netapp.v1.Replication) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listReplications.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReplications, request)); - assert( - (client.descriptors.page.listReplications.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listReplications with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListReplicationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListReplicationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listReplications.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listReplicationsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.netapp.v1.IReplication[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listReplications.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listReplications.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listBackupVaults', () => { + it('invokes listBackupVaults without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListBackupVaultsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListBackupVaultsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.BackupVault()), + generateSampleMessage(new protos.google.cloud.netapp.v1.BackupVault()), + generateSampleMessage(new protos.google.cloud.netapp.v1.BackupVault()), + ]; + client.innerApiCalls.listBackupVaults = stubSimpleCall(expectedResponse); + const [response] = await client.listBackupVaults(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listBackupVaults as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBackupVaults as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listReplications without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListReplicationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListReplicationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.Replication()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Replication()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Replication()), - ]; - client.descriptors.page.listReplications.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.netapp.v1.IReplication[] = []; - const iterable = client.listReplicationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listBackupVaults without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListBackupVaultsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListBackupVaultsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.BackupVault()), + generateSampleMessage(new protos.google.cloud.netapp.v1.BackupVault()), + generateSampleMessage(new protos.google.cloud.netapp.v1.BackupVault()), + ]; + client.innerApiCalls.listBackupVaults = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listBackupVaults( + request, + ( + err?: Error | null, + result?: protos.google.cloud.netapp.v1.IBackupVault[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listReplications.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listReplications.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listReplications with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListReplicationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListReplicationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listReplications.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listReplicationsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.netapp.v1.IReplication[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listReplications.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listReplications.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listBackupVaults as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBackupVaults as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listBackupVaults', () => { - it('invokes listBackupVaults without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListBackupVaultsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListBackupVaultsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.BackupVault()), - generateSampleMessage(new protos.google.cloud.netapp.v1.BackupVault()), - generateSampleMessage(new protos.google.cloud.netapp.v1.BackupVault()), - ]; - client.innerApiCalls.listBackupVaults = stubSimpleCall(expectedResponse); - const [response] = await client.listBackupVaults(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listBackupVaults as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBackupVaults as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listBackupVaults with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListBackupVaultsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListBackupVaultsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listBackupVaults = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listBackupVaults(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listBackupVaults as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBackupVaults as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listBackupVaults without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListBackupVaultsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListBackupVaultsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.BackupVault()), - generateSampleMessage(new protos.google.cloud.netapp.v1.BackupVault()), - generateSampleMessage(new protos.google.cloud.netapp.v1.BackupVault()), - ]; - client.innerApiCalls.listBackupVaults = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listBackupVaults( - request, - (err?: Error|null, result?: protos.google.cloud.netapp.v1.IBackupVault[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listBackupVaults as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBackupVaults as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listBackupVaultsStream without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListBackupVaultsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListBackupVaultsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.BackupVault()), + generateSampleMessage(new protos.google.cloud.netapp.v1.BackupVault()), + generateSampleMessage(new protos.google.cloud.netapp.v1.BackupVault()), + ]; + client.descriptors.page.listBackupVaults.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listBackupVaultsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.netapp.v1.BackupVault[] = []; + stream.on( + 'data', + (response: protos.google.cloud.netapp.v1.BackupVault) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listBackupVaults.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listBackupVaults, request), + ); + assert( + (client.descriptors.page.listBackupVaults.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listBackupVaults with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListBackupVaultsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListBackupVaultsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listBackupVaults = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listBackupVaults(request), expectedError); - const actualRequest = (client.innerApiCalls.listBackupVaults as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBackupVaults as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listBackupVaultsStream with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListBackupVaultsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListBackupVaultsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listBackupVaults.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listBackupVaultsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.netapp.v1.BackupVault[] = []; + stream.on( + 'data', + (response: protos.google.cloud.netapp.v1.BackupVault) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listBackupVaults.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listBackupVaults, request), + ); + assert( + (client.descriptors.page.listBackupVaults.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listBackupVaultsStream without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListBackupVaultsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListBackupVaultsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.BackupVault()), - generateSampleMessage(new protos.google.cloud.netapp.v1.BackupVault()), - generateSampleMessage(new protos.google.cloud.netapp.v1.BackupVault()), - ]; - client.descriptors.page.listBackupVaults.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listBackupVaultsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.netapp.v1.BackupVault[] = []; - stream.on('data', (response: protos.google.cloud.netapp.v1.BackupVault) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listBackupVaults.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listBackupVaults, request)); - assert( - (client.descriptors.page.listBackupVaults.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listBackupVaults without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListBackupVaultsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListBackupVaultsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.BackupVault()), + generateSampleMessage(new protos.google.cloud.netapp.v1.BackupVault()), + generateSampleMessage(new protos.google.cloud.netapp.v1.BackupVault()), + ]; + client.descriptors.page.listBackupVaults.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.netapp.v1.IBackupVault[] = []; + const iterable = client.listBackupVaultsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listBackupVaults.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listBackupVaults.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listBackupVaultsStream with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListBackupVaultsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListBackupVaultsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listBackupVaults.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listBackupVaultsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.netapp.v1.BackupVault[] = []; - stream.on('data', (response: protos.google.cloud.netapp.v1.BackupVault) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listBackupVaults.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listBackupVaults, request)); - assert( - (client.descriptors.page.listBackupVaults.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listBackupVaults with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListBackupVaultsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListBackupVaultsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listBackupVaults.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listBackupVaultsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.netapp.v1.IBackupVault[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listBackupVaults.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listBackupVaults.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listBackups', () => { + it('invokes listBackups without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.Backup()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Backup()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Backup()), + ]; + client.innerApiCalls.listBackups = stubSimpleCall(expectedResponse); + const [response] = await client.listBackups(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listBackupVaults without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListBackupVaultsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListBackupVaultsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.BackupVault()), - generateSampleMessage(new protos.google.cloud.netapp.v1.BackupVault()), - generateSampleMessage(new protos.google.cloud.netapp.v1.BackupVault()), - ]; - client.descriptors.page.listBackupVaults.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.netapp.v1.IBackupVault[] = []; - const iterable = client.listBackupVaultsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listBackups without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.Backup()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Backup()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Backup()), + ]; + client.innerApiCalls.listBackups = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listBackups( + request, + ( + err?: Error | null, + result?: protos.google.cloud.netapp.v1.IBackup[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listBackupVaults.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listBackupVaults.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listBackupVaults with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListBackupVaultsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListBackupVaultsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listBackupVaults.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listBackupVaultsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.netapp.v1.IBackupVault[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listBackupVaults.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listBackupVaults.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listBackups', () => { - it('invokes listBackups without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.Backup()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Backup()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Backup()), - ]; - client.innerApiCalls.listBackups = stubSimpleCall(expectedResponse); - const [response] = await client.listBackups(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listBackups with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listBackups = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listBackups(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBackups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listBackups without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.Backup()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Backup()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Backup()), - ]; - client.innerApiCalls.listBackups = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listBackups( - request, - (err?: Error|null, result?: protos.google.cloud.netapp.v1.IBackup[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listBackupsStream without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.Backup()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Backup()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Backup()), + ]; + client.descriptors.page.listBackups.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listBackupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.netapp.v1.Backup[] = []; + stream.on('data', (response: protos.google.cloud.netapp.v1.Backup) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listBackups.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listBackups, request), + ); + assert( + (client.descriptors.page.listBackups.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listBackups with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listBackups = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listBackups(request), expectedError); - const actualRequest = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listBackupsStream with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listBackups.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listBackupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.netapp.v1.Backup[] = []; + stream.on('data', (response: protos.google.cloud.netapp.v1.Backup) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listBackups.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listBackups, request), + ); + assert( + (client.descriptors.page.listBackups.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listBackupsStream without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.Backup()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Backup()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Backup()), - ]; - client.descriptors.page.listBackups.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listBackupsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.netapp.v1.Backup[] = []; - stream.on('data', (response: protos.google.cloud.netapp.v1.Backup) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listBackups.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listBackups, request)); - assert( - (client.descriptors.page.listBackups.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listBackups without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.Backup()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Backup()), + generateSampleMessage(new protos.google.cloud.netapp.v1.Backup()), + ]; + client.descriptors.page.listBackups.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.netapp.v1.IBackup[] = []; + const iterable = client.listBackupsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listBackups.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listBackups.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listBackupsStream with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listBackups.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listBackupsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.netapp.v1.Backup[] = []; - stream.on('data', (response: protos.google.cloud.netapp.v1.Backup) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listBackups.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listBackups, request)); - assert( - (client.descriptors.page.listBackups.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listBackups with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listBackups.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listBackupsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.netapp.v1.IBackup[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listBackups.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listBackups.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listBackupPolicies', () => { + it('invokes listBackupPolicies without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListBackupPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListBackupPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.BackupPolicy()), + generateSampleMessage(new protos.google.cloud.netapp.v1.BackupPolicy()), + generateSampleMessage(new protos.google.cloud.netapp.v1.BackupPolicy()), + ]; + client.innerApiCalls.listBackupPolicies = + stubSimpleCall(expectedResponse); + const [response] = await client.listBackupPolicies(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listBackupPolicies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBackupPolicies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listBackups without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.Backup()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Backup()), - generateSampleMessage(new protos.google.cloud.netapp.v1.Backup()), - ]; - client.descriptors.page.listBackups.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.netapp.v1.IBackup[] = []; - const iterable = client.listBackupsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listBackupPolicies without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListBackupPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListBackupPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.BackupPolicy()), + generateSampleMessage(new protos.google.cloud.netapp.v1.BackupPolicy()), + generateSampleMessage(new protos.google.cloud.netapp.v1.BackupPolicy()), + ]; + client.innerApiCalls.listBackupPolicies = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listBackupPolicies( + request, + ( + err?: Error | null, + result?: protos.google.cloud.netapp.v1.IBackupPolicy[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listBackups.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listBackups.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listBackups with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listBackups.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listBackupsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.netapp.v1.IBackup[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listBackups.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listBackups.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listBackupPolicies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBackupPolicies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listBackupPolicies', () => { - it('invokes listBackupPolicies without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListBackupPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListBackupPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.BackupPolicy()), - generateSampleMessage(new protos.google.cloud.netapp.v1.BackupPolicy()), - generateSampleMessage(new protos.google.cloud.netapp.v1.BackupPolicy()), - ]; - client.innerApiCalls.listBackupPolicies = stubSimpleCall(expectedResponse); - const [response] = await client.listBackupPolicies(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listBackupPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBackupPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listBackupPolicies with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListBackupPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListBackupPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listBackupPolicies = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listBackupPolicies(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listBackupPolicies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBackupPolicies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listBackupPolicies without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListBackupPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListBackupPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.BackupPolicy()), - generateSampleMessage(new protos.google.cloud.netapp.v1.BackupPolicy()), - generateSampleMessage(new protos.google.cloud.netapp.v1.BackupPolicy()), - ]; - client.innerApiCalls.listBackupPolicies = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listBackupPolicies( - request, - (err?: Error|null, result?: protos.google.cloud.netapp.v1.IBackupPolicy[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listBackupPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBackupPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listBackupPoliciesStream without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListBackupPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListBackupPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.BackupPolicy()), + generateSampleMessage(new protos.google.cloud.netapp.v1.BackupPolicy()), + generateSampleMessage(new protos.google.cloud.netapp.v1.BackupPolicy()), + ]; + client.descriptors.page.listBackupPolicies.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listBackupPoliciesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.netapp.v1.BackupPolicy[] = []; + stream.on( + 'data', + (response: protos.google.cloud.netapp.v1.BackupPolicy) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listBackupPolicies.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listBackupPolicies, request), + ); + assert( + (client.descriptors.page.listBackupPolicies.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listBackupPolicies with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListBackupPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListBackupPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listBackupPolicies = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listBackupPolicies(request), expectedError); - const actualRequest = (client.innerApiCalls.listBackupPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBackupPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listBackupPoliciesStream with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListBackupPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListBackupPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listBackupPolicies.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listBackupPoliciesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.netapp.v1.BackupPolicy[] = []; + stream.on( + 'data', + (response: protos.google.cloud.netapp.v1.BackupPolicy) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listBackupPolicies.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listBackupPolicies, request), + ); + assert( + (client.descriptors.page.listBackupPolicies.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listBackupPoliciesStream without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListBackupPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListBackupPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.BackupPolicy()), - generateSampleMessage(new protos.google.cloud.netapp.v1.BackupPolicy()), - generateSampleMessage(new protos.google.cloud.netapp.v1.BackupPolicy()), - ]; - client.descriptors.page.listBackupPolicies.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listBackupPoliciesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.netapp.v1.BackupPolicy[] = []; - stream.on('data', (response: protos.google.cloud.netapp.v1.BackupPolicy) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listBackupPolicies.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listBackupPolicies, request)); - assert( - (client.descriptors.page.listBackupPolicies.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listBackupPolicies without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListBackupPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListBackupPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.BackupPolicy()), + generateSampleMessage(new protos.google.cloud.netapp.v1.BackupPolicy()), + generateSampleMessage(new protos.google.cloud.netapp.v1.BackupPolicy()), + ]; + client.descriptors.page.listBackupPolicies.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.netapp.v1.IBackupPolicy[] = []; + const iterable = client.listBackupPoliciesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listBackupPolicies.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listBackupPolicies.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listBackupPoliciesStream with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListBackupPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListBackupPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listBackupPolicies.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listBackupPoliciesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.netapp.v1.BackupPolicy[] = []; - stream.on('data', (response: protos.google.cloud.netapp.v1.BackupPolicy) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listBackupPolicies.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listBackupPolicies, request)); - assert( - (client.descriptors.page.listBackupPolicies.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listBackupPolicies with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListBackupPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListBackupPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listBackupPolicies.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listBackupPoliciesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.netapp.v1.IBackupPolicy[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listBackupPolicies.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listBackupPolicies.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listQuotaRules', () => { + it('invokes listQuotaRules without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListQuotaRulesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListQuotaRulesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.QuotaRule()), + generateSampleMessage(new protos.google.cloud.netapp.v1.QuotaRule()), + generateSampleMessage(new protos.google.cloud.netapp.v1.QuotaRule()), + ]; + client.innerApiCalls.listQuotaRules = stubSimpleCall(expectedResponse); + const [response] = await client.listQuotaRules(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listQuotaRules as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listQuotaRules as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listBackupPolicies without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListBackupPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListBackupPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.BackupPolicy()), - generateSampleMessage(new protos.google.cloud.netapp.v1.BackupPolicy()), - generateSampleMessage(new protos.google.cloud.netapp.v1.BackupPolicy()), - ]; - client.descriptors.page.listBackupPolicies.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.netapp.v1.IBackupPolicy[] = []; - const iterable = client.listBackupPoliciesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listQuotaRules without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListQuotaRulesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListQuotaRulesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.QuotaRule()), + generateSampleMessage(new protos.google.cloud.netapp.v1.QuotaRule()), + generateSampleMessage(new protos.google.cloud.netapp.v1.QuotaRule()), + ]; + client.innerApiCalls.listQuotaRules = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listQuotaRules( + request, + ( + err?: Error | null, + result?: protos.google.cloud.netapp.v1.IQuotaRule[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listBackupPolicies.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listBackupPolicies.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listBackupPolicies with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListBackupPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListBackupPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listBackupPolicies.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listBackupPoliciesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.netapp.v1.IBackupPolicy[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listBackupPolicies.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listBackupPolicies.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listQuotaRules as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listQuotaRules as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listQuotaRules', () => { - it('invokes listQuotaRules without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListQuotaRulesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListQuotaRulesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.QuotaRule()), - generateSampleMessage(new protos.google.cloud.netapp.v1.QuotaRule()), - generateSampleMessage(new protos.google.cloud.netapp.v1.QuotaRule()), - ]; - client.innerApiCalls.listQuotaRules = stubSimpleCall(expectedResponse); - const [response] = await client.listQuotaRules(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listQuotaRules as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listQuotaRules as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listQuotaRules with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListQuotaRulesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListQuotaRulesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listQuotaRules = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listQuotaRules(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listQuotaRules as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listQuotaRules as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listQuotaRules without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListQuotaRulesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListQuotaRulesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.QuotaRule()), - generateSampleMessage(new protos.google.cloud.netapp.v1.QuotaRule()), - generateSampleMessage(new protos.google.cloud.netapp.v1.QuotaRule()), - ]; - client.innerApiCalls.listQuotaRules = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listQuotaRules( - request, - (err?: Error|null, result?: protos.google.cloud.netapp.v1.IQuotaRule[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listQuotaRules as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listQuotaRules as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listQuotaRulesStream without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListQuotaRulesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListQuotaRulesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.QuotaRule()), + generateSampleMessage(new protos.google.cloud.netapp.v1.QuotaRule()), + generateSampleMessage(new protos.google.cloud.netapp.v1.QuotaRule()), + ]; + client.descriptors.page.listQuotaRules.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listQuotaRulesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.netapp.v1.QuotaRule[] = []; + stream.on( + 'data', + (response: protos.google.cloud.netapp.v1.QuotaRule) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listQuotaRules.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listQuotaRules, request), + ); + assert( + (client.descriptors.page.listQuotaRules.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listQuotaRules with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListQuotaRulesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListQuotaRulesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listQuotaRules = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listQuotaRules(request), expectedError); - const actualRequest = (client.innerApiCalls.listQuotaRules as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listQuotaRules as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listQuotaRulesStream with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListQuotaRulesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListQuotaRulesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listQuotaRules.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listQuotaRulesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.netapp.v1.QuotaRule[] = []; + stream.on( + 'data', + (response: protos.google.cloud.netapp.v1.QuotaRule) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listQuotaRules.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listQuotaRules, request), + ); + assert( + (client.descriptors.page.listQuotaRules.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listQuotaRulesStream without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListQuotaRulesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListQuotaRulesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.QuotaRule()), - generateSampleMessage(new protos.google.cloud.netapp.v1.QuotaRule()), - generateSampleMessage(new protos.google.cloud.netapp.v1.QuotaRule()), - ]; - client.descriptors.page.listQuotaRules.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listQuotaRulesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.netapp.v1.QuotaRule[] = []; - stream.on('data', (response: protos.google.cloud.netapp.v1.QuotaRule) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listQuotaRules.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listQuotaRules, request)); - assert( - (client.descriptors.page.listQuotaRules.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listQuotaRules without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListQuotaRulesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListQuotaRulesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.QuotaRule()), + generateSampleMessage(new protos.google.cloud.netapp.v1.QuotaRule()), + generateSampleMessage(new protos.google.cloud.netapp.v1.QuotaRule()), + ]; + client.descriptors.page.listQuotaRules.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.netapp.v1.IQuotaRule[] = []; + const iterable = client.listQuotaRulesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listQuotaRules.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listQuotaRules.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listQuotaRulesStream with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListQuotaRulesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListQuotaRulesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listQuotaRules.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listQuotaRulesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.netapp.v1.QuotaRule[] = []; - stream.on('data', (response: protos.google.cloud.netapp.v1.QuotaRule) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listQuotaRules.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listQuotaRules, request)); - assert( - (client.descriptors.page.listQuotaRules.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listQuotaRules with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListQuotaRulesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListQuotaRulesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listQuotaRules.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listQuotaRulesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.netapp.v1.IQuotaRule[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listQuotaRules.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listQuotaRules.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listHostGroups', () => { + it('invokes listHostGroups without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListHostGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListHostGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.HostGroup()), + generateSampleMessage(new protos.google.cloud.netapp.v1.HostGroup()), + generateSampleMessage(new protos.google.cloud.netapp.v1.HostGroup()), + ]; + client.innerApiCalls.listHostGroups = stubSimpleCall(expectedResponse); + const [response] = await client.listHostGroups(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listHostGroups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listHostGroups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listQuotaRules without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListQuotaRulesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListQuotaRulesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.QuotaRule()), - generateSampleMessage(new protos.google.cloud.netapp.v1.QuotaRule()), - generateSampleMessage(new protos.google.cloud.netapp.v1.QuotaRule()), - ]; - client.descriptors.page.listQuotaRules.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.netapp.v1.IQuotaRule[] = []; - const iterable = client.listQuotaRulesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listHostGroups without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListHostGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListHostGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.HostGroup()), + generateSampleMessage(new protos.google.cloud.netapp.v1.HostGroup()), + generateSampleMessage(new protos.google.cloud.netapp.v1.HostGroup()), + ]; + client.innerApiCalls.listHostGroups = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listHostGroups( + request, + ( + err?: Error | null, + result?: protos.google.cloud.netapp.v1.IHostGroup[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listQuotaRules.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listQuotaRules.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listQuotaRules with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListQuotaRulesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListQuotaRulesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listQuotaRules.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listQuotaRulesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.netapp.v1.IQuotaRule[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listQuotaRules.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listQuotaRules.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listHostGroups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listHostGroups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listHostGroups', () => { - it('invokes listHostGroups without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListHostGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListHostGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.HostGroup()), - generateSampleMessage(new protos.google.cloud.netapp.v1.HostGroup()), - generateSampleMessage(new protos.google.cloud.netapp.v1.HostGroup()), - ]; - client.innerApiCalls.listHostGroups = stubSimpleCall(expectedResponse); - const [response] = await client.listHostGroups(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listHostGroups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listHostGroups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listHostGroups without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListHostGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListHostGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.HostGroup()), - generateSampleMessage(new protos.google.cloud.netapp.v1.HostGroup()), - generateSampleMessage(new protos.google.cloud.netapp.v1.HostGroup()), - ]; - client.innerApiCalls.listHostGroups = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listHostGroups( - request, - (err?: Error|null, result?: protos.google.cloud.netapp.v1.IHostGroup[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listHostGroups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listHostGroups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listHostGroups with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListHostGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListHostGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listHostGroups = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listHostGroups(request), expectedError); - const actualRequest = (client.innerApiCalls.listHostGroups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listHostGroups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listHostGroups with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListHostGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListHostGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listHostGroups = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listHostGroups(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listHostGroups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listHostGroups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listHostGroupsStream without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListHostGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListHostGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.HostGroup()), - generateSampleMessage(new protos.google.cloud.netapp.v1.HostGroup()), - generateSampleMessage(new protos.google.cloud.netapp.v1.HostGroup()), - ]; - client.descriptors.page.listHostGroups.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listHostGroupsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.netapp.v1.HostGroup[] = []; - stream.on('data', (response: protos.google.cloud.netapp.v1.HostGroup) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listHostGroups.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listHostGroups, request)); - assert( - (client.descriptors.page.listHostGroups.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listHostGroupsStream without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListHostGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListHostGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.HostGroup()), + generateSampleMessage(new protos.google.cloud.netapp.v1.HostGroup()), + generateSampleMessage(new protos.google.cloud.netapp.v1.HostGroup()), + ]; + client.descriptors.page.listHostGroups.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listHostGroupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.netapp.v1.HostGroup[] = []; + stream.on( + 'data', + (response: protos.google.cloud.netapp.v1.HostGroup) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listHostGroups.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listHostGroups, request), + ); + assert( + (client.descriptors.page.listHostGroups.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listHostGroupsStream with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListHostGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListHostGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listHostGroups.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listHostGroupsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.netapp.v1.HostGroup[] = []; - stream.on('data', (response: protos.google.cloud.netapp.v1.HostGroup) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listHostGroups.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listHostGroups, request)); - assert( - (client.descriptors.page.listHostGroups.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listHostGroupsStream with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListHostGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListHostGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listHostGroups.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listHostGroupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.netapp.v1.HostGroup[] = []; + stream.on( + 'data', + (response: protos.google.cloud.netapp.v1.HostGroup) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listHostGroups.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listHostGroups, request), + ); + assert( + (client.descriptors.page.listHostGroups.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listHostGroups without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListHostGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListHostGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.netapp.v1.HostGroup()), - generateSampleMessage(new protos.google.cloud.netapp.v1.HostGroup()), - generateSampleMessage(new protos.google.cloud.netapp.v1.HostGroup()), - ]; - client.descriptors.page.listHostGroups.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.netapp.v1.IHostGroup[] = []; - const iterable = client.listHostGroupsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listHostGroups.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listHostGroups.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listHostGroups without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListHostGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListHostGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.netapp.v1.HostGroup()), + generateSampleMessage(new protos.google.cloud.netapp.v1.HostGroup()), + generateSampleMessage(new protos.google.cloud.netapp.v1.HostGroup()), + ]; + client.descriptors.page.listHostGroups.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.netapp.v1.IHostGroup[] = []; + const iterable = client.listHostGroupsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listHostGroups.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listHostGroups.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listHostGroups with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.netapp.v1.ListHostGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.netapp.v1.ListHostGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listHostGroups.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listHostGroupsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.netapp.v1.IHostGroup[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listHostGroups.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listHostGroups.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listHostGroups with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ListHostGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ListHostGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listHostGroups.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listHostGroupsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.netapp.v1.IHostGroup[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listHostGroups.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listHostGroups.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes getLocation without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes getLocation with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('uses async iteration with listLocations with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('activeDirectory', async () => { + const fakePath = '/rendered/path/activeDirectory'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + active_directory: 'activeDirectoryValue', + }; + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.activeDirectoryPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.activeDirectoryPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('activeDirectoryPath', () => { + const result = client.activeDirectoryPath( + 'projectValue', + 'locationValue', + 'activeDirectoryValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.activeDirectoryPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromActiveDirectoryName', () => { + const result = client.matchProjectFromActiveDirectoryName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.activeDirectoryPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromActiveDirectoryName', () => { + const result = client.matchLocationFromActiveDirectoryName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.activeDirectoryPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchActiveDirectoryFromActiveDirectoryName', () => { + const result = + client.matchActiveDirectoryFromActiveDirectoryName(fakePath); + assert.strictEqual(result, 'activeDirectoryValue'); + assert( + (client.pathTemplates.activeDirectoryPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('activeDirectory', async () => { - const fakePath = "/rendered/path/activeDirectory"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - active_directory: "activeDirectoryValue", - }; - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.activeDirectoryPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.activeDirectoryPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('activeDirectoryPath', () => { - const result = client.activeDirectoryPath("projectValue", "locationValue", "activeDirectoryValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.activeDirectoryPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromActiveDirectoryName', () => { - const result = client.matchProjectFromActiveDirectoryName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.activeDirectoryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromActiveDirectoryName', () => { - const result = client.matchLocationFromActiveDirectoryName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.activeDirectoryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchActiveDirectoryFromActiveDirectoryName', () => { - const result = client.matchActiveDirectoryFromActiveDirectoryName(fakePath); - assert.strictEqual(result, "activeDirectoryValue"); - assert((client.pathTemplates.activeDirectoryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('backup', async () => { - const fakePath = "/rendered/path/backup"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - backup_vault: "backupVaultValue", - backup: "backupValue", - }; - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.backupPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.backupPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('backupPath', () => { - const result = client.backupPath("projectValue", "locationValue", "backupVaultValue", "backupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.backupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBackupName', () => { - const result = client.matchProjectFromBackupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBackupName', () => { - const result = client.matchLocationFromBackupName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBackupVaultFromBackupName', () => { - const result = client.matchBackupVaultFromBackupName(fakePath); - assert.strictEqual(result, "backupVaultValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBackupFromBackupName', () => { - const result = client.matchBackupFromBackupName(fakePath); - assert.strictEqual(result, "backupValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('backup', async () => { + const fakePath = '/rendered/path/backup'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + backup_vault: 'backupVaultValue', + backup: 'backupValue', + }; + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.backupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.backupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('backupPath', () => { + const result = client.backupPath( + 'projectValue', + 'locationValue', + 'backupVaultValue', + 'backupValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.backupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromBackupName', () => { + const result = client.matchProjectFromBackupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromBackupName', () => { + const result = client.matchLocationFromBackupName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchBackupVaultFromBackupName', () => { + const result = client.matchBackupVaultFromBackupName(fakePath); + assert.strictEqual(result, 'backupVaultValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchBackupFromBackupName', () => { + const result = client.matchBackupFromBackupName(fakePath); + assert.strictEqual(result, 'backupValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('backupPolicy', async () => { - const fakePath = "/rendered/path/backupPolicy"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - backup_policy: "backupPolicyValue", - }; - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.backupPolicyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.backupPolicyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('backupPolicyPath', () => { - const result = client.backupPolicyPath("projectValue", "locationValue", "backupPolicyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.backupPolicyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBackupPolicyName', () => { - const result = client.matchProjectFromBackupPolicyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.backupPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBackupPolicyName', () => { - const result = client.matchLocationFromBackupPolicyName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.backupPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBackupPolicyFromBackupPolicyName', () => { - const result = client.matchBackupPolicyFromBackupPolicyName(fakePath); - assert.strictEqual(result, "backupPolicyValue"); - assert((client.pathTemplates.backupPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('backupPolicy', async () => { + const fakePath = '/rendered/path/backupPolicy'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + backup_policy: 'backupPolicyValue', + }; + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.backupPolicyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.backupPolicyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('backupPolicyPath', () => { + const result = client.backupPolicyPath( + 'projectValue', + 'locationValue', + 'backupPolicyValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.backupPolicyPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromBackupPolicyName', () => { + const result = client.matchProjectFromBackupPolicyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.backupPolicyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromBackupPolicyName', () => { + const result = client.matchLocationFromBackupPolicyName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.backupPolicyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchBackupPolicyFromBackupPolicyName', () => { + const result = client.matchBackupPolicyFromBackupPolicyName(fakePath); + assert.strictEqual(result, 'backupPolicyValue'); + assert( + (client.pathTemplates.backupPolicyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('backupVault', async () => { - const fakePath = "/rendered/path/backupVault"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - backup_vault: "backupVaultValue", - }; - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.backupVaultPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.backupVaultPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('backupVaultPath', () => { - const result = client.backupVaultPath("projectValue", "locationValue", "backupVaultValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.backupVaultPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBackupVaultName', () => { - const result = client.matchProjectFromBackupVaultName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.backupVaultPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBackupVaultName', () => { - const result = client.matchLocationFromBackupVaultName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.backupVaultPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBackupVaultFromBackupVaultName', () => { - const result = client.matchBackupVaultFromBackupVaultName(fakePath); - assert.strictEqual(result, "backupVaultValue"); - assert((client.pathTemplates.backupVaultPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('backupVault', async () => { + const fakePath = '/rendered/path/backupVault'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + backup_vault: 'backupVaultValue', + }; + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.backupVaultPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.backupVaultPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('backupVaultPath', () => { + const result = client.backupVaultPath( + 'projectValue', + 'locationValue', + 'backupVaultValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.backupVaultPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromBackupVaultName', () => { + const result = client.matchProjectFromBackupVaultName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.backupVaultPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromBackupVaultName', () => { + const result = client.matchLocationFromBackupVaultName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.backupVaultPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchBackupVaultFromBackupVaultName', () => { + const result = client.matchBackupVaultFromBackupVaultName(fakePath); + assert.strictEqual(result, 'backupVaultValue'); + assert( + (client.pathTemplates.backupVaultPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('hostGroup', async () => { - const fakePath = "/rendered/path/hostGroup"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - host_group: "hostGroupValue", - }; - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.hostGroupPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.hostGroupPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('hostGroupPath', () => { - const result = client.hostGroupPath("projectValue", "locationValue", "hostGroupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.hostGroupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromHostGroupName', () => { - const result = client.matchProjectFromHostGroupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.hostGroupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromHostGroupName', () => { - const result = client.matchLocationFromHostGroupName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.hostGroupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHostGroupFromHostGroupName', () => { - const result = client.matchHostGroupFromHostGroupName(fakePath); - assert.strictEqual(result, "hostGroupValue"); - assert((client.pathTemplates.hostGroupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('hostGroup', async () => { + const fakePath = '/rendered/path/hostGroup'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + host_group: 'hostGroupValue', + }; + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.hostGroupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.hostGroupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('hostGroupPath', () => { + const result = client.hostGroupPath( + 'projectValue', + 'locationValue', + 'hostGroupValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.hostGroupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromHostGroupName', () => { + const result = client.matchProjectFromHostGroupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.hostGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromHostGroupName', () => { + const result = client.matchLocationFromHostGroupName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.hostGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHostGroupFromHostGroupName', () => { + const result = client.matchHostGroupFromHostGroupName(fakePath); + assert.strictEqual(result, 'hostGroupValue'); + assert( + (client.pathTemplates.hostGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('kmsConfig', async () => { - const fakePath = "/rendered/path/kmsConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - kms_config: "kmsConfigValue", - }; - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.kmsConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.kmsConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('kmsConfigPath', () => { - const result = client.kmsConfigPath("projectValue", "locationValue", "kmsConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.kmsConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromKmsConfigName', () => { - const result = client.matchProjectFromKmsConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.kmsConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromKmsConfigName', () => { - const result = client.matchLocationFromKmsConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.kmsConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKmsConfigFromKmsConfigName', () => { - const result = client.matchKmsConfigFromKmsConfigName(fakePath); - assert.strictEqual(result, "kmsConfigValue"); - assert((client.pathTemplates.kmsConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('kmsConfig', async () => { + const fakePath = '/rendered/path/kmsConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + kms_config: 'kmsConfigValue', + }; + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.kmsConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.kmsConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('kmsConfigPath', () => { + const result = client.kmsConfigPath( + 'projectValue', + 'locationValue', + 'kmsConfigValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.kmsConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromKmsConfigName', () => { + const result = client.matchProjectFromKmsConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.kmsConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromKmsConfigName', () => { + const result = client.matchLocationFromKmsConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.kmsConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKmsConfigFromKmsConfigName', () => { + const result = client.matchKmsConfigFromKmsConfigName(fakePath); + assert.strictEqual(result, 'kmsConfigValue'); + assert( + (client.pathTemplates.kmsConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('quotaRule', async () => { - const fakePath = "/rendered/path/quotaRule"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - volume: "volumeValue", - quota_rule: "quotaRuleValue", - }; - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.quotaRulePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.quotaRulePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('quotaRulePath', () => { - const result = client.quotaRulePath("projectValue", "locationValue", "volumeValue", "quotaRuleValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.quotaRulePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromQuotaRuleName', () => { - const result = client.matchProjectFromQuotaRuleName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.quotaRulePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromQuotaRuleName', () => { - const result = client.matchLocationFromQuotaRuleName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.quotaRulePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchVolumeFromQuotaRuleName', () => { - const result = client.matchVolumeFromQuotaRuleName(fakePath); - assert.strictEqual(result, "volumeValue"); - assert((client.pathTemplates.quotaRulePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchQuotaRuleFromQuotaRuleName', () => { - const result = client.matchQuotaRuleFromQuotaRuleName(fakePath); - assert.strictEqual(result, "quotaRuleValue"); - assert((client.pathTemplates.quotaRulePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('quotaRule', async () => { + const fakePath = '/rendered/path/quotaRule'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + volume: 'volumeValue', + quota_rule: 'quotaRuleValue', + }; + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.quotaRulePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.quotaRulePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('quotaRulePath', () => { + const result = client.quotaRulePath( + 'projectValue', + 'locationValue', + 'volumeValue', + 'quotaRuleValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.quotaRulePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromQuotaRuleName', () => { + const result = client.matchProjectFromQuotaRuleName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.quotaRulePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromQuotaRuleName', () => { + const result = client.matchLocationFromQuotaRuleName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.quotaRulePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchVolumeFromQuotaRuleName', () => { + const result = client.matchVolumeFromQuotaRuleName(fakePath); + assert.strictEqual(result, 'volumeValue'); + assert( + (client.pathTemplates.quotaRulePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchQuotaRuleFromQuotaRuleName', () => { + const result = client.matchQuotaRuleFromQuotaRuleName(fakePath); + assert.strictEqual(result, 'quotaRuleValue'); + assert( + (client.pathTemplates.quotaRulePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('replication', async () => { - const fakePath = "/rendered/path/replication"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - volume: "volumeValue", - replication: "replicationValue", - }; - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.replicationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.replicationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('replicationPath', () => { - const result = client.replicationPath("projectValue", "locationValue", "volumeValue", "replicationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.replicationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromReplicationName', () => { - const result = client.matchProjectFromReplicationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.replicationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromReplicationName', () => { - const result = client.matchLocationFromReplicationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.replicationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchVolumeFromReplicationName', () => { - const result = client.matchVolumeFromReplicationName(fakePath); - assert.strictEqual(result, "volumeValue"); - assert((client.pathTemplates.replicationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReplicationFromReplicationName', () => { - const result = client.matchReplicationFromReplicationName(fakePath); - assert.strictEqual(result, "replicationValue"); - assert((client.pathTemplates.replicationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('replication', async () => { + const fakePath = '/rendered/path/replication'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + volume: 'volumeValue', + replication: 'replicationValue', + }; + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.replicationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.replicationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('replicationPath', () => { + const result = client.replicationPath( + 'projectValue', + 'locationValue', + 'volumeValue', + 'replicationValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.replicationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromReplicationName', () => { + const result = client.matchProjectFromReplicationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.replicationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromReplicationName', () => { + const result = client.matchLocationFromReplicationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.replicationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchVolumeFromReplicationName', () => { + const result = client.matchVolumeFromReplicationName(fakePath); + assert.strictEqual(result, 'volumeValue'); + assert( + (client.pathTemplates.replicationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchReplicationFromReplicationName', () => { + const result = client.matchReplicationFromReplicationName(fakePath); + assert.strictEqual(result, 'replicationValue'); + assert( + (client.pathTemplates.replicationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('snapshot', async () => { - const fakePath = "/rendered/path/snapshot"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - volume: "volumeValue", - snapshot: "snapshotValue", - }; - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.snapshotPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.snapshotPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('snapshotPath', () => { - const result = client.snapshotPath("projectValue", "locationValue", "volumeValue", "snapshotValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.snapshotPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromSnapshotName', () => { - const result = client.matchProjectFromSnapshotName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.snapshotPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromSnapshotName', () => { - const result = client.matchLocationFromSnapshotName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.snapshotPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchVolumeFromSnapshotName', () => { - const result = client.matchVolumeFromSnapshotName(fakePath); - assert.strictEqual(result, "volumeValue"); - assert((client.pathTemplates.snapshotPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSnapshotFromSnapshotName', () => { - const result = client.matchSnapshotFromSnapshotName(fakePath); - assert.strictEqual(result, "snapshotValue"); - assert((client.pathTemplates.snapshotPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('snapshot', async () => { + const fakePath = '/rendered/path/snapshot'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + volume: 'volumeValue', + snapshot: 'snapshotValue', + }; + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.snapshotPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.snapshotPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('snapshotPath', () => { + const result = client.snapshotPath( + 'projectValue', + 'locationValue', + 'volumeValue', + 'snapshotValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.snapshotPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromSnapshotName', () => { + const result = client.matchProjectFromSnapshotName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.snapshotPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromSnapshotName', () => { + const result = client.matchLocationFromSnapshotName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.snapshotPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchVolumeFromSnapshotName', () => { + const result = client.matchVolumeFromSnapshotName(fakePath); + assert.strictEqual(result, 'volumeValue'); + assert( + (client.pathTemplates.snapshotPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchSnapshotFromSnapshotName', () => { + const result = client.matchSnapshotFromSnapshotName(fakePath); + assert.strictEqual(result, 'snapshotValue'); + assert( + (client.pathTemplates.snapshotPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('storagePool', async () => { - const fakePath = "/rendered/path/storagePool"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - storage_pool: "storagePoolValue", - }; - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.storagePoolPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.storagePoolPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('storagePoolPath', () => { - const result = client.storagePoolPath("projectValue", "locationValue", "storagePoolValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.storagePoolPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromStoragePoolName', () => { - const result = client.matchProjectFromStoragePoolName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.storagePoolPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromStoragePoolName', () => { - const result = client.matchLocationFromStoragePoolName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.storagePoolPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchStoragePoolFromStoragePoolName', () => { - const result = client.matchStoragePoolFromStoragePoolName(fakePath); - assert.strictEqual(result, "storagePoolValue"); - assert((client.pathTemplates.storagePoolPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('storagePool', async () => { + const fakePath = '/rendered/path/storagePool'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + storage_pool: 'storagePoolValue', + }; + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.storagePoolPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.storagePoolPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('storagePoolPath', () => { + const result = client.storagePoolPath( + 'projectValue', + 'locationValue', + 'storagePoolValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.storagePoolPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromStoragePoolName', () => { + const result = client.matchProjectFromStoragePoolName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.storagePoolPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromStoragePoolName', () => { + const result = client.matchLocationFromStoragePoolName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.storagePoolPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchStoragePoolFromStoragePoolName', () => { + const result = client.matchStoragePoolFromStoragePoolName(fakePath); + assert.strictEqual(result, 'storagePoolValue'); + assert( + (client.pathTemplates.storagePoolPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('volume', async () => { - const fakePath = "/rendered/path/volume"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - volume: "volumeValue", - }; - const client = new netappModule.v1.NetAppClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.volumePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.volumePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('volumePath', () => { - const result = client.volumePath("projectValue", "locationValue", "volumeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.volumePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromVolumeName', () => { - const result = client.matchProjectFromVolumeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.volumePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromVolumeName', () => { - const result = client.matchLocationFromVolumeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.volumePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchVolumeFromVolumeName', () => { - const result = client.matchVolumeFromVolumeName(fakePath); - assert.strictEqual(result, "volumeValue"); - assert((client.pathTemplates.volumePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('volume', async () => { + const fakePath = '/rendered/path/volume'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + volume: 'volumeValue', + }; + const client = new netappModule.v1.NetAppClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.volumePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.volumePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('volumePath', () => { + const result = client.volumePath( + 'projectValue', + 'locationValue', + 'volumeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.volumePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromVolumeName', () => { + const result = client.matchProjectFromVolumeName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.volumePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromVolumeName', () => { + const result = client.matchLocationFromVolumeName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.volumePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchVolumeFromVolumeName', () => { + const result = client.matchVolumeFromVolumeName(fakePath); + assert.strictEqual(result, 'volumeValue'); + assert( + (client.pathTemplates.volumePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-netapp/webpack.config.js b/packages/google-cloud-netapp/webpack.config.js index 97f683839d11..a2b8685a4217 100644 --- a/packages/google-cloud-netapp/webpack.config.js +++ b/packages/google-cloud-netapp/webpack.config.js @@ -1,4 +1,4 @@ -// Copyright 2026 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-networkconnectivity/.eslintignore b/packages/google-cloud-networkconnectivity/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-networkconnectivity/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-networkconnectivity/.eslintrc.json b/packages/google-cloud-networkconnectivity/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-networkconnectivity/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-networkconnectivity/README.md b/packages/google-cloud-networkconnectivity/README.md index fe452a620f26..06281fae7f87 100644 --- a/packages/google-cloud-networkconnectivity/README.md +++ b/packages/google-cloud-networkconnectivity/README.md @@ -218,7 +218,7 @@ More Information: [Google Cloud Platform Launch Stages][launch_stages] ## Contributing -Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-networkconnectivity/CONTRIBUTING.md). +Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/CONTRIBUTING.md). Please note that this `README.md` and a variety of configuration files in this repository (including `.nycrc` and `tsconfig.json`) @@ -228,7 +228,7 @@ are generated from a central template. Apache Version 2.0 -See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-networkconnectivity/LICENSE) +See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/LICENSE) [shell_img]: https://gstatic.com/cloudssh/images/open-btn.png [projects]: https://console.cloud.google.com/project diff --git a/packages/google-cloud-networkconnectivity/protos/protos.d.ts b/packages/google-cloud-networkconnectivity/protos/protos.d.ts index 018e5fcb4d00..fa056184015e 100644 --- a/packages/google-cloud-networkconnectivity/protos/protos.d.ts +++ b/packages/google-cloud-networkconnectivity/protos/protos.d.ts @@ -34409,6 +34409,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -34426,6 +34429,9 @@ export namespace google { /** CommonLanguageSettings destinations. */ public destinations: google.api.ClientLibraryDestination[]; + /** CommonLanguageSettings selectiveGapicGeneration. */ + public selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); + /** * Creates a new CommonLanguageSettings instance using the specified properties. * @param [properties] Properties to set @@ -35126,6 +35132,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -35140,6 +35149,9 @@ export namespace google { /** PythonSettings common. */ public common?: (google.api.ICommonLanguageSettings|null); + /** PythonSettings experimentalFeatures. */ + public experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); + /** * Creates a new PythonSettings instance using the specified properties. * @param [properties] Properties to set @@ -35218,6 +35230,118 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + namespace PythonSettings { + + /** Properties of an ExperimentalFeatures. */ + interface IExperimentalFeatures { + + /** ExperimentalFeatures restAsyncIoEnabled */ + restAsyncIoEnabled?: (boolean|null); + + /** ExperimentalFeatures protobufPythonicTypesEnabled */ + protobufPythonicTypesEnabled?: (boolean|null); + + /** ExperimentalFeatures unversionedPackageDisabled */ + unversionedPackageDisabled?: (boolean|null); + } + + /** Represents an ExperimentalFeatures. */ + class ExperimentalFeatures implements IExperimentalFeatures { + + /** + * Constructs a new ExperimentalFeatures. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.PythonSettings.IExperimentalFeatures); + + /** ExperimentalFeatures restAsyncIoEnabled. */ + public restAsyncIoEnabled: boolean; + + /** ExperimentalFeatures protobufPythonicTypesEnabled. */ + public protobufPythonicTypesEnabled: boolean; + + /** ExperimentalFeatures unversionedPackageDisabled. */ + public unversionedPackageDisabled: boolean; + + /** + * Creates a new ExperimentalFeatures instance using the specified properties. + * @param [properties] Properties to set + * @returns ExperimentalFeatures instance + */ + public static create(properties?: google.api.PythonSettings.IExperimentalFeatures): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Encodes the specified ExperimentalFeatures message. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @param message ExperimentalFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.PythonSettings.IExperimentalFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExperimentalFeatures message, length delimited. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @param message ExperimentalFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.PythonSettings.IExperimentalFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExperimentalFeatures + * @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.api.PythonSettings.ExperimentalFeatures; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExperimentalFeatures + * @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.api.PythonSettings.ExperimentalFeatures; + + /** + * Verifies an ExperimentalFeatures 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 an ExperimentalFeatures message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExperimentalFeatures + */ + public static fromObject(object: { [k: string]: any }): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Creates a plain object from an ExperimentalFeatures message. Also converts values to other types if specified. + * @param message ExperimentalFeatures + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.PythonSettings.ExperimentalFeatures, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExperimentalFeatures to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExperimentalFeatures + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + /** Properties of a NodeSettings. */ interface INodeSettings { @@ -35544,6 +35668,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -35558,6 +35685,9 @@ export namespace google { /** GoSettings common. */ public common?: (google.api.ICommonLanguageSettings|null); + /** GoSettings renamedServices. */ + public renamedServices: { [k: string]: string }; + /** * Creates a new GoSettings instance using the specified properties. * @param [properties] Properties to set @@ -35882,6 +36012,109 @@ export namespace google { PACKAGE_MANAGER = 20 } + /** Properties of a SelectiveGapicGeneration. */ + interface ISelectiveGapicGeneration { + + /** SelectiveGapicGeneration methods */ + methods?: (string[]|null); + + /** SelectiveGapicGeneration generateOmittedAsInternal */ + generateOmittedAsInternal?: (boolean|null); + } + + /** Represents a SelectiveGapicGeneration. */ + class SelectiveGapicGeneration implements ISelectiveGapicGeneration { + + /** + * Constructs a new SelectiveGapicGeneration. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.ISelectiveGapicGeneration); + + /** SelectiveGapicGeneration methods. */ + public methods: string[]; + + /** SelectiveGapicGeneration generateOmittedAsInternal. */ + public generateOmittedAsInternal: boolean; + + /** + * Creates a new SelectiveGapicGeneration instance using the specified properties. + * @param [properties] Properties to set + * @returns SelectiveGapicGeneration instance + */ + public static create(properties?: google.api.ISelectiveGapicGeneration): google.api.SelectiveGapicGeneration; + + /** + * Encodes the specified SelectiveGapicGeneration message. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @param message SelectiveGapicGeneration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.ISelectiveGapicGeneration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SelectiveGapicGeneration message, length delimited. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @param message SelectiveGapicGeneration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.ISelectiveGapicGeneration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SelectiveGapicGeneration + * @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.api.SelectiveGapicGeneration; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SelectiveGapicGeneration + * @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.api.SelectiveGapicGeneration; + + /** + * Verifies a SelectiveGapicGeneration 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 SelectiveGapicGeneration message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SelectiveGapicGeneration + */ + public static fromObject(object: { [k: string]: any }): google.api.SelectiveGapicGeneration; + + /** + * Creates a plain object from a SelectiveGapicGeneration message. Also converts values to other types if specified. + * @param message SelectiveGapicGeneration + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.SelectiveGapicGeneration, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SelectiveGapicGeneration to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SelectiveGapicGeneration + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** LaunchStage enum. */ enum LaunchStage { LAUNCH_STAGE_UNSPECIFIED = 0, @@ -35899,6 +36132,9 @@ export namespace google { /** FieldInfo format */ format?: (google.api.FieldInfo.Format|keyof typeof google.api.FieldInfo.Format|null); + + /** FieldInfo referencedTypes */ + referencedTypes?: (google.api.ITypeReference[]|null); } /** Represents a FieldInfo. */ @@ -35913,6 +36149,9 @@ export namespace google { /** FieldInfo format. */ public format: (google.api.FieldInfo.Format|keyof typeof google.api.FieldInfo.Format); + /** FieldInfo referencedTypes. */ + public referencedTypes: google.api.ITypeReference[]; + /** * Creates a new FieldInfo instance using the specified properties. * @param [properties] Properties to set @@ -36002,6 +36241,103 @@ export namespace google { IPV4_OR_IPV6 = 4 } } + + /** Properties of a TypeReference. */ + interface ITypeReference { + + /** TypeReference typeName */ + typeName?: (string|null); + } + + /** Represents a TypeReference. */ + class TypeReference implements ITypeReference { + + /** + * Constructs a new TypeReference. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.ITypeReference); + + /** TypeReference typeName. */ + public typeName: string; + + /** + * Creates a new TypeReference instance using the specified properties. + * @param [properties] Properties to set + * @returns TypeReference instance + */ + public static create(properties?: google.api.ITypeReference): google.api.TypeReference; + + /** + * Encodes the specified TypeReference message. Does not implicitly {@link google.api.TypeReference.verify|verify} messages. + * @param message TypeReference message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.ITypeReference, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified TypeReference message, length delimited. Does not implicitly {@link google.api.TypeReference.verify|verify} messages. + * @param message TypeReference message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.ITypeReference, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TypeReference message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns TypeReference + * @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.api.TypeReference; + + /** + * Decodes a TypeReference message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns TypeReference + * @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.api.TypeReference; + + /** + * Verifies a TypeReference 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 TypeReference message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TypeReference + */ + public static fromObject(object: { [k: string]: any }): google.api.TypeReference; + + /** + * Creates a plain object from a TypeReference message. Also converts values to other types if specified. + * @param message TypeReference + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.TypeReference, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TypeReference to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for TypeReference + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } } /** Namespace protobuf. */ @@ -36107,6 +36443,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -36137,6 +36474,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -36186,6 +36526,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -36320,6 +36663,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -36361,6 +36707,9 @@ export namespace google { /** DescriptorProto reservedName. */ public reservedName: string[]; + /** DescriptorProto visibility. */ + public visibility: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility); + /** * Creates a new DescriptorProto instance using the specified properties. * @param [properties] Properties to set @@ -37208,6 +37557,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -37234,6 +37586,9 @@ export namespace google { /** EnumDescriptorProto reservedName. */ public reservedName: string[]; + /** EnumDescriptorProto visibility. */ + public visibility: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility); + /** * Creates a new EnumDescriptorProto instance using the specified properties. * @param [properties] Properties to set @@ -38168,6 +38523,9 @@ export namespace google { /** FieldOptions features */ features?: (google.protobuf.IFeatureSet|null); + /** FieldOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** FieldOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); @@ -38226,6 +38584,9 @@ export namespace google { /** FieldOptions features. */ public features?: (google.protobuf.IFeatureSet|null); + /** FieldOptions featureSupport. */ + public featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** FieldOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; @@ -38446,6 +38807,121 @@ export namespace google { */ public static getTypeUrl(typeUrlPrefix?: string): string; } + + /** Properties of a FeatureSupport. */ + interface IFeatureSupport { + + /** FeatureSupport editionIntroduced */ + editionIntroduced?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSupport editionDeprecated */ + editionDeprecated?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSupport deprecationWarning */ + deprecationWarning?: (string|null); + + /** FeatureSupport editionRemoved */ + editionRemoved?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + } + + /** Represents a FeatureSupport. */ + class FeatureSupport implements IFeatureSupport { + + /** + * Constructs a new FeatureSupport. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.FieldOptions.IFeatureSupport); + + /** FeatureSupport editionIntroduced. */ + public editionIntroduced: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSupport editionDeprecated. */ + public editionDeprecated: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSupport deprecationWarning. */ + public deprecationWarning: string; + + /** FeatureSupport editionRemoved. */ + public editionRemoved: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** + * Creates a new FeatureSupport instance using the specified properties. + * @param [properties] Properties to set + * @returns FeatureSupport instance + */ + public static create(properties?: google.protobuf.FieldOptions.IFeatureSupport): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Encodes the specified FeatureSupport message. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @param message FeatureSupport message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.FieldOptions.IFeatureSupport, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FeatureSupport message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @param message FeatureSupport message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.FieldOptions.IFeatureSupport, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FeatureSupport + * @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.protobuf.FieldOptions.FeatureSupport; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FeatureSupport + * @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.protobuf.FieldOptions.FeatureSupport; + + /** + * Verifies a FeatureSupport 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 FeatureSupport message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FeatureSupport + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Creates a plain object from a FeatureSupport message. Also converts values to other types if specified. + * @param message FeatureSupport + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldOptions.FeatureSupport, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FeatureSupport to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FeatureSupport + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } } /** Properties of an OneofOptions. */ @@ -38684,6 +39160,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -38706,6 +39185,9 @@ export namespace google { /** EnumValueOptions debugRedact. */ public debugRedact: boolean; + /** EnumValueOptions featureSupport. */ + public featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; @@ -39298,6 +39780,12 @@ export namespace google { /** FeatureSet jsonFormat */ jsonFormat?: (google.protobuf.FeatureSet.JsonFormat|keyof typeof google.protobuf.FeatureSet.JsonFormat|null); + + /** FeatureSet enforceNamingStyle */ + enforceNamingStyle?: (google.protobuf.FeatureSet.EnforceNamingStyle|keyof typeof google.protobuf.FeatureSet.EnforceNamingStyle|null); + + /** FeatureSet defaultSymbolVisibility */ + defaultSymbolVisibility?: (google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|keyof typeof google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|null); } /** Represents a FeatureSet. */ @@ -39327,6 +39815,12 @@ export namespace google { /** FeatureSet jsonFormat. */ public jsonFormat: (google.protobuf.FeatureSet.JsonFormat|keyof typeof google.protobuf.FeatureSet.JsonFormat); + /** FeatureSet enforceNamingStyle. */ + public enforceNamingStyle: (google.protobuf.FeatureSet.EnforceNamingStyle|keyof typeof google.protobuf.FeatureSet.EnforceNamingStyle); + + /** FeatureSet defaultSymbolVisibility. */ + public defaultSymbolVisibility: (google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|keyof typeof google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility); + /** * Creates a new FeatureSet instance using the specified properties. * @param [properties] Properties to set @@ -39449,6 +39943,116 @@ export namespace google { ALLOW = 1, LEGACY_BEST_EFFORT = 2 } + + /** EnforceNamingStyle enum. */ + enum EnforceNamingStyle { + ENFORCE_NAMING_STYLE_UNKNOWN = 0, + STYLE2024 = 1, + STYLE_LEGACY = 2 + } + + /** Properties of a VisibilityFeature. */ + interface IVisibilityFeature { + } + + /** Represents a VisibilityFeature. */ + class VisibilityFeature implements IVisibilityFeature { + + /** + * Constructs a new VisibilityFeature. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.FeatureSet.IVisibilityFeature); + + /** + * Creates a new VisibilityFeature instance using the specified properties. + * @param [properties] Properties to set + * @returns VisibilityFeature instance + */ + public static create(properties?: google.protobuf.FeatureSet.IVisibilityFeature): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Encodes the specified VisibilityFeature message. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @param message VisibilityFeature message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.FeatureSet.IVisibilityFeature, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified VisibilityFeature message, length delimited. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @param message VisibilityFeature message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.FeatureSet.IVisibilityFeature, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns VisibilityFeature + * @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.protobuf.FeatureSet.VisibilityFeature; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns VisibilityFeature + * @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.protobuf.FeatureSet.VisibilityFeature; + + /** + * Verifies a VisibilityFeature 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 VisibilityFeature message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns VisibilityFeature + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Creates a plain object from a VisibilityFeature message. Also converts values to other types if specified. + * @param message VisibilityFeature + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FeatureSet.VisibilityFeature, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this VisibilityFeature to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for VisibilityFeature + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace VisibilityFeature { + + /** DefaultSymbolVisibility enum. */ + enum DefaultSymbolVisibility { + DEFAULT_SYMBOL_VISIBILITY_UNKNOWN = 0, + EXPORT_ALL = 1, + EXPORT_TOP_LEVEL = 2, + LOCAL_ALL = 3, + STRICT = 4 + } + } } /** Properties of a FeatureSetDefaults. */ @@ -39568,8 +40172,11 @@ export namespace google { /** FeatureSetEditionDefault edition */ edition?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); - /** FeatureSetEditionDefault features */ - features?: (google.protobuf.IFeatureSet|null); + /** FeatureSetEditionDefault overridableFeatures */ + overridableFeatures?: (google.protobuf.IFeatureSet|null); + + /** FeatureSetEditionDefault fixedFeatures */ + fixedFeatures?: (google.protobuf.IFeatureSet|null); } /** Represents a FeatureSetEditionDefault. */ @@ -39584,8 +40191,11 @@ export namespace google { /** FeatureSetEditionDefault edition. */ public edition: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); - /** FeatureSetEditionDefault features. */ - public features?: (google.protobuf.IFeatureSet|null); + /** FeatureSetEditionDefault overridableFeatures. */ + public overridableFeatures?: (google.protobuf.IFeatureSet|null); + + /** FeatureSetEditionDefault fixedFeatures. */ + public fixedFeatures?: (google.protobuf.IFeatureSet|null); /** * Creates a new FeatureSetEditionDefault instance using the specified properties. @@ -40118,6 +40728,13 @@ export namespace google { } } + /** SymbolVisibility enum. */ + enum SymbolVisibility { + VISIBILITY_UNSET = 0, + VISIBILITY_LOCAL = 1, + VISIBILITY_EXPORT = 2 + } + /** Properties of a Timestamp. */ interface ITimestamp { @@ -42116,6 +42733,24 @@ export namespace google { /** Violation description */ description?: (string|null); + + /** Violation apiService */ + apiService?: (string|null); + + /** Violation quotaMetric */ + quotaMetric?: (string|null); + + /** Violation quotaId */ + quotaId?: (string|null); + + /** Violation quotaDimensions */ + quotaDimensions?: ({ [k: string]: string }|null); + + /** Violation quotaValue */ + quotaValue?: (number|Long|string|null); + + /** Violation futureQuotaValue */ + futureQuotaValue?: (number|Long|string|null); } /** Represents a Violation. */ @@ -42133,6 +42768,24 @@ export namespace google { /** Violation description. */ public description: string; + /** Violation apiService. */ + public apiService: string; + + /** Violation quotaMetric. */ + public quotaMetric: string; + + /** Violation quotaId. */ + public quotaId: string; + + /** Violation quotaDimensions. */ + public quotaDimensions: { [k: string]: string }; + + /** Violation quotaValue. */ + public quotaValue: (number|Long|string); + + /** Violation futureQuotaValue. */ + public futureQuotaValue?: (number|Long|string|null); + /** * Creates a new Violation instance using the specified properties. * @param [properties] Properties to set @@ -42528,6 +43181,12 @@ export namespace google { /** FieldViolation description */ description?: (string|null); + + /** FieldViolation reason */ + reason?: (string|null); + + /** FieldViolation localizedMessage */ + localizedMessage?: (google.rpc.ILocalizedMessage|null); } /** Represents a FieldViolation. */ @@ -42545,6 +43204,12 @@ export namespace google { /** FieldViolation description. */ public description: string; + /** FieldViolation reason. */ + public reason: string; + + /** FieldViolation localizedMessage. */ + public localizedMessage?: (google.rpc.ILocalizedMessage|null); + /** * Creates a new FieldViolation instance using the specified properties. * @param [properties] Properties to set diff --git a/packages/google-cloud-networkconnectivity/protos/protos.js b/packages/google-cloud-networkconnectivity/protos/protos.js index 54694750a6d8..31de042018c2 100644 --- a/packages/google-cloud-networkconnectivity/protos/protos.js +++ b/packages/google-cloud-networkconnectivity/protos/protos.js @@ -87617,6 +87617,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -87651,6 +87652,14 @@ */ CommonLanguageSettings.prototype.destinations = $util.emptyArray; + /** + * CommonLanguageSettings selectiveGapicGeneration. + * @member {google.api.ISelectiveGapicGeneration|null|undefined} selectiveGapicGeneration + * @memberof google.api.CommonLanguageSettings + * @instance + */ + CommonLanguageSettings.prototype.selectiveGapicGeneration = null; + /** * Creates a new CommonLanguageSettings instance using the specified properties. * @function create @@ -87683,6 +87692,8 @@ writer.int32(message.destinations[i]); writer.ldelim(); } + if (message.selectiveGapicGeneration != null && Object.hasOwnProperty.call(message, "selectiveGapicGeneration")) + $root.google.api.SelectiveGapicGeneration.encode(message.selectiveGapicGeneration, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); return writer; }; @@ -87734,6 +87745,10 @@ message.destinations.push(reader.int32()); break; } + case 3: { + message.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -87785,6 +87800,11 @@ break; } } + if (message.selectiveGapicGeneration != null && message.hasOwnProperty("selectiveGapicGeneration")) { + var error = $root.google.api.SelectiveGapicGeneration.verify(message.selectiveGapicGeneration); + if (error) + return "selectiveGapicGeneration." + error; + } return null; }; @@ -87827,6 +87847,11 @@ break; } } + if (object.selectiveGapicGeneration != null) { + if (typeof object.selectiveGapicGeneration !== "object") + throw TypeError(".google.api.CommonLanguageSettings.selectiveGapicGeneration: object expected"); + message.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.fromObject(object.selectiveGapicGeneration); + } return message; }; @@ -87845,8 +87870,10 @@ var object = {}; if (options.arrays || options.defaults) object.destinations = []; - if (options.defaults) + if (options.defaults) { object.referenceDocsUri = ""; + object.selectiveGapicGeneration = null; + } if (message.referenceDocsUri != null && message.hasOwnProperty("referenceDocsUri")) object.referenceDocsUri = message.referenceDocsUri; if (message.destinations && message.destinations.length) { @@ -87854,6 +87881,8 @@ for (var j = 0; j < message.destinations.length; ++j) object.destinations[j] = options.enums === String ? $root.google.api.ClientLibraryDestination[message.destinations[j]] === undefined ? message.destinations[j] : $root.google.api.ClientLibraryDestination[message.destinations[j]] : message.destinations[j]; } + if (message.selectiveGapicGeneration != null && message.hasOwnProperty("selectiveGapicGeneration")) + object.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.toObject(message.selectiveGapicGeneration, options); return object; }; @@ -89676,6 +89705,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -89701,6 +89731,14 @@ */ PythonSettings.prototype.common = null; + /** + * PythonSettings experimentalFeatures. + * @member {google.api.PythonSettings.IExperimentalFeatures|null|undefined} experimentalFeatures + * @memberof google.api.PythonSettings + * @instance + */ + PythonSettings.prototype.experimentalFeatures = null; + /** * Creates a new PythonSettings instance using the specified properties. * @function create @@ -89727,6 +89765,8 @@ writer = $Writer.create(); if (message.common != null && Object.hasOwnProperty.call(message, "common")) $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.experimentalFeatures != null && Object.hasOwnProperty.call(message, "experimentalFeatures")) + $root.google.api.PythonSettings.ExperimentalFeatures.encode(message.experimentalFeatures, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; @@ -89767,6 +89807,10 @@ message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); break; } + case 2: { + message.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -89807,6 +89851,11 @@ if (error) return "common." + error; } + if (message.experimentalFeatures != null && message.hasOwnProperty("experimentalFeatures")) { + var error = $root.google.api.PythonSettings.ExperimentalFeatures.verify(message.experimentalFeatures); + if (error) + return "experimentalFeatures." + error; + } return null; }; @@ -89827,6 +89876,11 @@ throw TypeError(".google.api.PythonSettings.common: object expected"); message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); } + if (object.experimentalFeatures != null) { + if (typeof object.experimentalFeatures !== "object") + throw TypeError(".google.api.PythonSettings.experimentalFeatures: object expected"); + message.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.fromObject(object.experimentalFeatures); + } return message; }; @@ -89843,10 +89897,14 @@ if (!options) options = {}; var object = {}; - if (options.defaults) + if (options.defaults) { object.common = null; + object.experimentalFeatures = null; + } if (message.common != null && message.hasOwnProperty("common")) object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + if (message.experimentalFeatures != null && message.hasOwnProperty("experimentalFeatures")) + object.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.toObject(message.experimentalFeatures, options); return object; }; @@ -89876,6 +89934,258 @@ return typeUrlPrefix + "/google.api.PythonSettings"; }; + PythonSettings.ExperimentalFeatures = (function() { + + /** + * Properties of an ExperimentalFeatures. + * @memberof google.api.PythonSettings + * @interface IExperimentalFeatures + * @property {boolean|null} [restAsyncIoEnabled] ExperimentalFeatures restAsyncIoEnabled + * @property {boolean|null} [protobufPythonicTypesEnabled] ExperimentalFeatures protobufPythonicTypesEnabled + * @property {boolean|null} [unversionedPackageDisabled] ExperimentalFeatures unversionedPackageDisabled + */ + + /** + * Constructs a new ExperimentalFeatures. + * @memberof google.api.PythonSettings + * @classdesc Represents an ExperimentalFeatures. + * @implements IExperimentalFeatures + * @constructor + * @param {google.api.PythonSettings.IExperimentalFeatures=} [properties] Properties to set + */ + function ExperimentalFeatures(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]]; + } + + /** + * ExperimentalFeatures restAsyncIoEnabled. + * @member {boolean} restAsyncIoEnabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.restAsyncIoEnabled = false; + + /** + * ExperimentalFeatures protobufPythonicTypesEnabled. + * @member {boolean} protobufPythonicTypesEnabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.protobufPythonicTypesEnabled = false; + + /** + * ExperimentalFeatures unversionedPackageDisabled. + * @member {boolean} unversionedPackageDisabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.unversionedPackageDisabled = false; + + /** + * Creates a new ExperimentalFeatures instance using the specified properties. + * @function create + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures=} [properties] Properties to set + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures instance + */ + ExperimentalFeatures.create = function create(properties) { + return new ExperimentalFeatures(properties); + }; + + /** + * Encodes the specified ExperimentalFeatures message. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @function encode + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures} message ExperimentalFeatures message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExperimentalFeatures.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.restAsyncIoEnabled != null && Object.hasOwnProperty.call(message, "restAsyncIoEnabled")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.restAsyncIoEnabled); + if (message.protobufPythonicTypesEnabled != null && Object.hasOwnProperty.call(message, "protobufPythonicTypesEnabled")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.protobufPythonicTypesEnabled); + if (message.unversionedPackageDisabled != null && Object.hasOwnProperty.call(message, "unversionedPackageDisabled")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.unversionedPackageDisabled); + return writer; + }; + + /** + * Encodes the specified ExperimentalFeatures message, length delimited. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures} message ExperimentalFeatures message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExperimentalFeatures.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer. + * @function decode + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExperimentalFeatures.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.PythonSettings.ExperimentalFeatures(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.restAsyncIoEnabled = reader.bool(); + break; + } + case 2: { + message.protobufPythonicTypesEnabled = reader.bool(); + break; + } + case 3: { + message.unversionedPackageDisabled = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExperimentalFeatures.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExperimentalFeatures message. + * @function verify + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExperimentalFeatures.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.restAsyncIoEnabled != null && message.hasOwnProperty("restAsyncIoEnabled")) + if (typeof message.restAsyncIoEnabled !== "boolean") + return "restAsyncIoEnabled: boolean expected"; + if (message.protobufPythonicTypesEnabled != null && message.hasOwnProperty("protobufPythonicTypesEnabled")) + if (typeof message.protobufPythonicTypesEnabled !== "boolean") + return "protobufPythonicTypesEnabled: boolean expected"; + if (message.unversionedPackageDisabled != null && message.hasOwnProperty("unversionedPackageDisabled")) + if (typeof message.unversionedPackageDisabled !== "boolean") + return "unversionedPackageDisabled: boolean expected"; + return null; + }; + + /** + * Creates an ExperimentalFeatures message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {Object.} object Plain object + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + */ + ExperimentalFeatures.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.PythonSettings.ExperimentalFeatures) + return object; + var message = new $root.google.api.PythonSettings.ExperimentalFeatures(); + if (object.restAsyncIoEnabled != null) + message.restAsyncIoEnabled = Boolean(object.restAsyncIoEnabled); + if (object.protobufPythonicTypesEnabled != null) + message.protobufPythonicTypesEnabled = Boolean(object.protobufPythonicTypesEnabled); + if (object.unversionedPackageDisabled != null) + message.unversionedPackageDisabled = Boolean(object.unversionedPackageDisabled); + return message; + }; + + /** + * Creates a plain object from an ExperimentalFeatures message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.ExperimentalFeatures} message ExperimentalFeatures + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExperimentalFeatures.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.restAsyncIoEnabled = false; + object.protobufPythonicTypesEnabled = false; + object.unversionedPackageDisabled = false; + } + if (message.restAsyncIoEnabled != null && message.hasOwnProperty("restAsyncIoEnabled")) + object.restAsyncIoEnabled = message.restAsyncIoEnabled; + if (message.protobufPythonicTypesEnabled != null && message.hasOwnProperty("protobufPythonicTypesEnabled")) + object.protobufPythonicTypesEnabled = message.protobufPythonicTypesEnabled; + if (message.unversionedPackageDisabled != null && message.hasOwnProperty("unversionedPackageDisabled")) + object.unversionedPackageDisabled = message.unversionedPackageDisabled; + return object; + }; + + /** + * Converts this ExperimentalFeatures to JSON. + * @function toJSON + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + * @returns {Object.} JSON object + */ + ExperimentalFeatures.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExperimentalFeatures + * @function getTypeUrl + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExperimentalFeatures.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.PythonSettings.ExperimentalFeatures"; + }; + + return ExperimentalFeatures; + })(); + return PythonSettings; })(); @@ -90752,6 +91062,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -90763,6 +91074,7 @@ * @param {google.api.IGoSettings=} [properties] Properties to set */ function GoSettings(properties) { + this.renamedServices = {}; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -90777,6 +91089,14 @@ */ GoSettings.prototype.common = null; + /** + * GoSettings renamedServices. + * @member {Object.} renamedServices + * @memberof google.api.GoSettings + * @instance + */ + GoSettings.prototype.renamedServices = $util.emptyObject; + /** * Creates a new GoSettings instance using the specified properties. * @function create @@ -90803,6 +91123,9 @@ writer = $Writer.create(); if (message.common != null && Object.hasOwnProperty.call(message, "common")) $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.renamedServices != null && Object.hasOwnProperty.call(message, "renamedServices")) + for (var keys = Object.keys(message.renamedServices), i = 0; i < keys.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.renamedServices[keys[i]]).ldelim(); return writer; }; @@ -90833,7 +91156,7 @@ GoSettings.decode = function decode(reader, length, error) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.GoSettings(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.GoSettings(), key, value; while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) @@ -90843,6 +91166,29 @@ message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); break; } + case 2: { + if (message.renamedServices === $util.emptyObject) + message.renamedServices = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = ""; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = reader.string(); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.renamedServices[key] = value; + break; + } default: reader.skipType(tag & 7); break; @@ -90883,6 +91229,14 @@ if (error) return "common." + error; } + if (message.renamedServices != null && message.hasOwnProperty("renamedServices")) { + if (!$util.isObject(message.renamedServices)) + return "renamedServices: object expected"; + var key = Object.keys(message.renamedServices); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.renamedServices[key[i]])) + return "renamedServices: string{k:string} expected"; + } return null; }; @@ -90903,6 +91257,13 @@ throw TypeError(".google.api.GoSettings.common: object expected"); message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); } + if (object.renamedServices) { + if (typeof object.renamedServices !== "object") + throw TypeError(".google.api.GoSettings.renamedServices: object expected"); + message.renamedServices = {}; + for (var keys = Object.keys(object.renamedServices), i = 0; i < keys.length; ++i) + message.renamedServices[keys[i]] = String(object.renamedServices[keys[i]]); + } return message; }; @@ -90919,10 +91280,18 @@ if (!options) options = {}; var object = {}; + if (options.objects || options.defaults) + object.renamedServices = {}; if (options.defaults) object.common = null; if (message.common != null && message.hasOwnProperty("common")) object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + var keys2; + if (message.renamedServices && (keys2 = Object.keys(message.renamedServices)).length) { + object.renamedServices = {}; + for (var j = 0; j < keys2.length; ++j) + object.renamedServices[keys2[j]] = message.renamedServices[keys2[j]]; + } return object; }; @@ -91561,29 +91930,274 @@ return values; })(); - /** - * LaunchStage enum. - * @name google.api.LaunchStage - * @enum {number} - * @property {number} LAUNCH_STAGE_UNSPECIFIED=0 LAUNCH_STAGE_UNSPECIFIED value - * @property {number} UNIMPLEMENTED=6 UNIMPLEMENTED value - * @property {number} PRELAUNCH=7 PRELAUNCH value - * @property {number} EARLY_ACCESS=1 EARLY_ACCESS value - * @property {number} ALPHA=2 ALPHA value - * @property {number} BETA=3 BETA value - * @property {number} GA=4 GA value - * @property {number} DEPRECATED=5 DEPRECATED value - */ - api.LaunchStage = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "LAUNCH_STAGE_UNSPECIFIED"] = 0; - values[valuesById[6] = "UNIMPLEMENTED"] = 6; - values[valuesById[7] = "PRELAUNCH"] = 7; - values[valuesById[1] = "EARLY_ACCESS"] = 1; - values[valuesById[2] = "ALPHA"] = 2; - values[valuesById[3] = "BETA"] = 3; - values[valuesById[4] = "GA"] = 4; - values[valuesById[5] = "DEPRECATED"] = 5; + api.SelectiveGapicGeneration = (function() { + + /** + * Properties of a SelectiveGapicGeneration. + * @memberof google.api + * @interface ISelectiveGapicGeneration + * @property {Array.|null} [methods] SelectiveGapicGeneration methods + * @property {boolean|null} [generateOmittedAsInternal] SelectiveGapicGeneration generateOmittedAsInternal + */ + + /** + * Constructs a new SelectiveGapicGeneration. + * @memberof google.api + * @classdesc Represents a SelectiveGapicGeneration. + * @implements ISelectiveGapicGeneration + * @constructor + * @param {google.api.ISelectiveGapicGeneration=} [properties] Properties to set + */ + function SelectiveGapicGeneration(properties) { + this.methods = []; + 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]]; + } + + /** + * SelectiveGapicGeneration methods. + * @member {Array.} methods + * @memberof google.api.SelectiveGapicGeneration + * @instance + */ + SelectiveGapicGeneration.prototype.methods = $util.emptyArray; + + /** + * SelectiveGapicGeneration generateOmittedAsInternal. + * @member {boolean} generateOmittedAsInternal + * @memberof google.api.SelectiveGapicGeneration + * @instance + */ + SelectiveGapicGeneration.prototype.generateOmittedAsInternal = false; + + /** + * Creates a new SelectiveGapicGeneration instance using the specified properties. + * @function create + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration=} [properties] Properties to set + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration instance + */ + SelectiveGapicGeneration.create = function create(properties) { + return new SelectiveGapicGeneration(properties); + }; + + /** + * Encodes the specified SelectiveGapicGeneration message. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @function encode + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration} message SelectiveGapicGeneration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SelectiveGapicGeneration.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.methods != null && message.methods.length) + for (var i = 0; i < message.methods.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.methods[i]); + if (message.generateOmittedAsInternal != null && Object.hasOwnProperty.call(message, "generateOmittedAsInternal")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.generateOmittedAsInternal); + return writer; + }; + + /** + * Encodes the specified SelectiveGapicGeneration message, length delimited. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration} message SelectiveGapicGeneration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SelectiveGapicGeneration.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer. + * @function decode + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SelectiveGapicGeneration.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.SelectiveGapicGeneration(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + if (!(message.methods && message.methods.length)) + message.methods = []; + message.methods.push(reader.string()); + break; + } + case 2: { + message.generateOmittedAsInternal = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SelectiveGapicGeneration.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SelectiveGapicGeneration message. + * @function verify + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SelectiveGapicGeneration.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.methods != null && message.hasOwnProperty("methods")) { + if (!Array.isArray(message.methods)) + return "methods: array expected"; + for (var i = 0; i < message.methods.length; ++i) + if (!$util.isString(message.methods[i])) + return "methods: string[] expected"; + } + if (message.generateOmittedAsInternal != null && message.hasOwnProperty("generateOmittedAsInternal")) + if (typeof message.generateOmittedAsInternal !== "boolean") + return "generateOmittedAsInternal: boolean expected"; + return null; + }; + + /** + * Creates a SelectiveGapicGeneration message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {Object.} object Plain object + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + */ + SelectiveGapicGeneration.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.SelectiveGapicGeneration) + return object; + var message = new $root.google.api.SelectiveGapicGeneration(); + if (object.methods) { + if (!Array.isArray(object.methods)) + throw TypeError(".google.api.SelectiveGapicGeneration.methods: array expected"); + message.methods = []; + for (var i = 0; i < object.methods.length; ++i) + message.methods[i] = String(object.methods[i]); + } + if (object.generateOmittedAsInternal != null) + message.generateOmittedAsInternal = Boolean(object.generateOmittedAsInternal); + return message; + }; + + /** + * Creates a plain object from a SelectiveGapicGeneration message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.SelectiveGapicGeneration} message SelectiveGapicGeneration + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SelectiveGapicGeneration.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.methods = []; + if (options.defaults) + object.generateOmittedAsInternal = false; + if (message.methods && message.methods.length) { + object.methods = []; + for (var j = 0; j < message.methods.length; ++j) + object.methods[j] = message.methods[j]; + } + if (message.generateOmittedAsInternal != null && message.hasOwnProperty("generateOmittedAsInternal")) + object.generateOmittedAsInternal = message.generateOmittedAsInternal; + return object; + }; + + /** + * Converts this SelectiveGapicGeneration to JSON. + * @function toJSON + * @memberof google.api.SelectiveGapicGeneration + * @instance + * @returns {Object.} JSON object + */ + SelectiveGapicGeneration.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SelectiveGapicGeneration + * @function getTypeUrl + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SelectiveGapicGeneration.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.SelectiveGapicGeneration"; + }; + + return SelectiveGapicGeneration; + })(); + + /** + * LaunchStage enum. + * @name google.api.LaunchStage + * @enum {number} + * @property {number} LAUNCH_STAGE_UNSPECIFIED=0 LAUNCH_STAGE_UNSPECIFIED value + * @property {number} UNIMPLEMENTED=6 UNIMPLEMENTED value + * @property {number} PRELAUNCH=7 PRELAUNCH value + * @property {number} EARLY_ACCESS=1 EARLY_ACCESS value + * @property {number} ALPHA=2 ALPHA value + * @property {number} BETA=3 BETA value + * @property {number} GA=4 GA value + * @property {number} DEPRECATED=5 DEPRECATED value + */ + api.LaunchStage = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "LAUNCH_STAGE_UNSPECIFIED"] = 0; + values[valuesById[6] = "UNIMPLEMENTED"] = 6; + values[valuesById[7] = "PRELAUNCH"] = 7; + values[valuesById[1] = "EARLY_ACCESS"] = 1; + values[valuesById[2] = "ALPHA"] = 2; + values[valuesById[3] = "BETA"] = 3; + values[valuesById[4] = "GA"] = 4; + values[valuesById[5] = "DEPRECATED"] = 5; return values; })(); @@ -91594,6 +92208,7 @@ * @memberof google.api * @interface IFieldInfo * @property {google.api.FieldInfo.Format|null} [format] FieldInfo format + * @property {Array.|null} [referencedTypes] FieldInfo referencedTypes */ /** @@ -91605,6 +92220,7 @@ * @param {google.api.IFieldInfo=} [properties] Properties to set */ function FieldInfo(properties) { + this.referencedTypes = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -91619,6 +92235,14 @@ */ FieldInfo.prototype.format = 0; + /** + * FieldInfo referencedTypes. + * @member {Array.} referencedTypes + * @memberof google.api.FieldInfo + * @instance + */ + FieldInfo.prototype.referencedTypes = $util.emptyArray; + /** * Creates a new FieldInfo instance using the specified properties. * @function create @@ -91645,6 +92269,9 @@ writer = $Writer.create(); if (message.format != null && Object.hasOwnProperty.call(message, "format")) writer.uint32(/* id 1, wireType 0 =*/8).int32(message.format); + if (message.referencedTypes != null && message.referencedTypes.length) + for (var i = 0; i < message.referencedTypes.length; ++i) + $root.google.api.TypeReference.encode(message.referencedTypes[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; @@ -91685,6 +92312,12 @@ message.format = reader.int32(); break; } + case 2: { + if (!(message.referencedTypes && message.referencedTypes.length)) + message.referencedTypes = []; + message.referencedTypes.push($root.google.api.TypeReference.decode(reader, reader.uint32())); + break; + } default: reader.skipType(tag & 7); break; @@ -91731,6 +92364,15 @@ case 4: break; } + if (message.referencedTypes != null && message.hasOwnProperty("referencedTypes")) { + if (!Array.isArray(message.referencedTypes)) + return "referencedTypes: array expected"; + for (var i = 0; i < message.referencedTypes.length; ++i) { + var error = $root.google.api.TypeReference.verify(message.referencedTypes[i]); + if (error) + return "referencedTypes." + error; + } + } return null; }; @@ -91774,6 +92416,16 @@ message.format = 4; break; } + if (object.referencedTypes) { + if (!Array.isArray(object.referencedTypes)) + throw TypeError(".google.api.FieldInfo.referencedTypes: array expected"); + message.referencedTypes = []; + for (var i = 0; i < object.referencedTypes.length; ++i) { + if (typeof object.referencedTypes[i] !== "object") + throw TypeError(".google.api.FieldInfo.referencedTypes: object expected"); + message.referencedTypes[i] = $root.google.api.TypeReference.fromObject(object.referencedTypes[i]); + } + } return message; }; @@ -91790,10 +92442,17 @@ if (!options) options = {}; var object = {}; + if (options.arrays || options.defaults) + object.referencedTypes = []; if (options.defaults) object.format = options.enums === String ? "FORMAT_UNSPECIFIED" : 0; if (message.format != null && message.hasOwnProperty("format")) object.format = options.enums === String ? $root.google.api.FieldInfo.Format[message.format] === undefined ? message.format : $root.google.api.FieldInfo.Format[message.format] : message.format; + if (message.referencedTypes && message.referencedTypes.length) { + object.referencedTypes = []; + for (var j = 0; j < message.referencedTypes.length; ++j) + object.referencedTypes[j] = $root.google.api.TypeReference.toObject(message.referencedTypes[j], options); + } return object; }; @@ -91846,37 +92505,24 @@ return FieldInfo; })(); - return api; - })(); - - google.protobuf = (function() { - - /** - * Namespace protobuf. - * @memberof google - * @namespace - */ - var protobuf = {}; - - protobuf.FileDescriptorSet = (function() { + api.TypeReference = (function() { /** - * Properties of a FileDescriptorSet. - * @memberof google.protobuf - * @interface IFileDescriptorSet - * @property {Array.|null} [file] FileDescriptorSet file + * Properties of a TypeReference. + * @memberof google.api + * @interface ITypeReference + * @property {string|null} [typeName] TypeReference typeName */ /** - * Constructs a new FileDescriptorSet. - * @memberof google.protobuf - * @classdesc Represents a FileDescriptorSet. - * @implements IFileDescriptorSet + * Constructs a new TypeReference. + * @memberof google.api + * @classdesc Represents a TypeReference. + * @implements ITypeReference * @constructor - * @param {google.protobuf.IFileDescriptorSet=} [properties] Properties to set + * @param {google.api.ITypeReference=} [properties] Properties to set */ - function FileDescriptorSet(properties) { - this.file = []; + function TypeReference(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -91884,80 +92530,77 @@ } /** - * FileDescriptorSet file. - * @member {Array.} file - * @memberof google.protobuf.FileDescriptorSet + * TypeReference typeName. + * @member {string} typeName + * @memberof google.api.TypeReference * @instance */ - FileDescriptorSet.prototype.file = $util.emptyArray; + TypeReference.prototype.typeName = ""; /** - * Creates a new FileDescriptorSet instance using the specified properties. + * Creates a new TypeReference instance using the specified properties. * @function create - * @memberof google.protobuf.FileDescriptorSet + * @memberof google.api.TypeReference * @static - * @param {google.protobuf.IFileDescriptorSet=} [properties] Properties to set - * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet instance + * @param {google.api.ITypeReference=} [properties] Properties to set + * @returns {google.api.TypeReference} TypeReference instance */ - FileDescriptorSet.create = function create(properties) { - return new FileDescriptorSet(properties); + TypeReference.create = function create(properties) { + return new TypeReference(properties); }; /** - * Encodes the specified FileDescriptorSet message. Does not implicitly {@link google.protobuf.FileDescriptorSet.verify|verify} messages. + * Encodes the specified TypeReference message. Does not implicitly {@link google.api.TypeReference.verify|verify} messages. * @function encode - * @memberof google.protobuf.FileDescriptorSet + * @memberof google.api.TypeReference * @static - * @param {google.protobuf.IFileDescriptorSet} message FileDescriptorSet message or plain object to encode + * @param {google.api.ITypeReference} message TypeReference message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - FileDescriptorSet.encode = function encode(message, writer) { + TypeReference.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.file != null && message.file.length) - for (var i = 0; i < message.file.length; ++i) - $root.google.protobuf.FileDescriptorProto.encode(message.file[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.typeName != null && Object.hasOwnProperty.call(message, "typeName")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.typeName); return writer; }; /** - * Encodes the specified FileDescriptorSet message, length delimited. Does not implicitly {@link google.protobuf.FileDescriptorSet.verify|verify} messages. + * Encodes the specified TypeReference message, length delimited. Does not implicitly {@link google.api.TypeReference.verify|verify} messages. * @function encodeDelimited - * @memberof google.protobuf.FileDescriptorSet + * @memberof google.api.TypeReference * @static - * @param {google.protobuf.IFileDescriptorSet} message FileDescriptorSet message or plain object to encode + * @param {google.api.ITypeReference} message TypeReference message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - FileDescriptorSet.encodeDelimited = function encodeDelimited(message, writer) { + TypeReference.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes a FileDescriptorSet message from the specified reader or buffer. + * Decodes a TypeReference message from the specified reader or buffer. * @function decode - * @memberof google.protobuf.FileDescriptorSet + * @memberof google.api.TypeReference * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet + * @returns {google.api.TypeReference} TypeReference * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - FileDescriptorSet.decode = function decode(reader, length, error) { + TypeReference.decode = function decode(reader, length, error) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FileDescriptorSet(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.TypeReference(); while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) break; switch (tag >>> 3) { case 1: { - if (!(message.file && message.file.length)) - message.file = []; - message.file.push($root.google.protobuf.FileDescriptorProto.decode(reader, reader.uint32())); + message.typeName = reader.string(); break; } default: @@ -91969,37 +92612,258 @@ }; /** - * Decodes a FileDescriptorSet message from the specified reader or buffer, length delimited. + * Decodes a TypeReference message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof google.protobuf.FileDescriptorSet + * @memberof google.api.TypeReference * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet + * @returns {google.api.TypeReference} TypeReference * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - FileDescriptorSet.decodeDelimited = function decodeDelimited(reader) { + TypeReference.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies a FileDescriptorSet message. + * Verifies a TypeReference message. * @function verify - * @memberof google.protobuf.FileDescriptorSet + * @memberof google.api.TypeReference * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - FileDescriptorSet.verify = function verify(message) { + TypeReference.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - if (message.file != null && message.hasOwnProperty("file")) { - if (!Array.isArray(message.file)) - return "file: array expected"; - for (var i = 0; i < message.file.length; ++i) { - var error = $root.google.protobuf.FileDescriptorProto.verify(message.file[i]); + if (message.typeName != null && message.hasOwnProperty("typeName")) + if (!$util.isString(message.typeName)) + return "typeName: string expected"; + return null; + }; + + /** + * Creates a TypeReference message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.TypeReference + * @static + * @param {Object.} object Plain object + * @returns {google.api.TypeReference} TypeReference + */ + TypeReference.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.TypeReference) + return object; + var message = new $root.google.api.TypeReference(); + if (object.typeName != null) + message.typeName = String(object.typeName); + return message; + }; + + /** + * Creates a plain object from a TypeReference message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.TypeReference + * @static + * @param {google.api.TypeReference} message TypeReference + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TypeReference.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.typeName = ""; + if (message.typeName != null && message.hasOwnProperty("typeName")) + object.typeName = message.typeName; + return object; + }; + + /** + * Converts this TypeReference to JSON. + * @function toJSON + * @memberof google.api.TypeReference + * @instance + * @returns {Object.} JSON object + */ + TypeReference.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for TypeReference + * @function getTypeUrl + * @memberof google.api.TypeReference + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + TypeReference.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.TypeReference"; + }; + + return TypeReference; + })(); + + return api; + })(); + + google.protobuf = (function() { + + /** + * Namespace protobuf. + * @memberof google + * @namespace + */ + var protobuf = {}; + + protobuf.FileDescriptorSet = (function() { + + /** + * Properties of a FileDescriptorSet. + * @memberof google.protobuf + * @interface IFileDescriptorSet + * @property {Array.|null} [file] FileDescriptorSet file + */ + + /** + * Constructs a new FileDescriptorSet. + * @memberof google.protobuf + * @classdesc Represents a FileDescriptorSet. + * @implements IFileDescriptorSet + * @constructor + * @param {google.protobuf.IFileDescriptorSet=} [properties] Properties to set + */ + function FileDescriptorSet(properties) { + this.file = []; + 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]]; + } + + /** + * FileDescriptorSet file. + * @member {Array.} file + * @memberof google.protobuf.FileDescriptorSet + * @instance + */ + FileDescriptorSet.prototype.file = $util.emptyArray; + + /** + * Creates a new FileDescriptorSet instance using the specified properties. + * @function create + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {google.protobuf.IFileDescriptorSet=} [properties] Properties to set + * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet instance + */ + FileDescriptorSet.create = function create(properties) { + return new FileDescriptorSet(properties); + }; + + /** + * Encodes the specified FileDescriptorSet message. Does not implicitly {@link google.protobuf.FileDescriptorSet.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {google.protobuf.IFileDescriptorSet} message FileDescriptorSet message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileDescriptorSet.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.file != null && message.file.length) + for (var i = 0; i < message.file.length; ++i) + $root.google.protobuf.FileDescriptorProto.encode(message.file[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified FileDescriptorSet message, length delimited. Does not implicitly {@link google.protobuf.FileDescriptorSet.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {google.protobuf.IFileDescriptorSet} message FileDescriptorSet message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileDescriptorSet.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FileDescriptorSet message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileDescriptorSet.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FileDescriptorSet(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + if (!(message.file && message.file.length)) + message.file = []; + message.file.push($root.google.protobuf.FileDescriptorProto.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FileDescriptorSet message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileDescriptorSet.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FileDescriptorSet message. + * @function verify + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FileDescriptorSet.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.file != null && message.hasOwnProperty("file")) { + if (!Array.isArray(message.file)) + return "file: array expected"; + for (var i = 0; i < message.file.length; ++i) { + var error = $root.google.protobuf.FileDescriptorProto.verify(message.file[i]); if (error) return "file." + error; } @@ -92089,6 +92953,7 @@ * @name google.protobuf.Edition * @enum {number} * @property {number} EDITION_UNKNOWN=0 EDITION_UNKNOWN value + * @property {number} EDITION_LEGACY=900 EDITION_LEGACY value * @property {number} EDITION_PROTO2=998 EDITION_PROTO2 value * @property {number} EDITION_PROTO3=999 EDITION_PROTO3 value * @property {number} EDITION_2023=1000 EDITION_2023 value @@ -92103,6 +92968,7 @@ protobuf.Edition = (function() { var valuesById = {}, values = Object.create(valuesById); values[valuesById[0] = "EDITION_UNKNOWN"] = 0; + values[valuesById[900] = "EDITION_LEGACY"] = 900; values[valuesById[998] = "EDITION_PROTO2"] = 998; values[valuesById[999] = "EDITION_PROTO3"] = 999; values[valuesById[1000] = "EDITION_2023"] = 1000; @@ -92127,6 +92993,7 @@ * @property {Array.|null} [dependency] FileDescriptorProto dependency * @property {Array.|null} [publicDependency] FileDescriptorProto publicDependency * @property {Array.|null} [weakDependency] FileDescriptorProto weakDependency + * @property {Array.|null} [optionDependency] FileDescriptorProto optionDependency * @property {Array.|null} [messageType] FileDescriptorProto messageType * @property {Array.|null} [enumType] FileDescriptorProto enumType * @property {Array.|null} [service] FileDescriptorProto service @@ -92149,6 +93016,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -92199,6 +93067,14 @@ */ FileDescriptorProto.prototype.weakDependency = $util.emptyArray; + /** + * FileDescriptorProto optionDependency. + * @member {Array.} optionDependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.optionDependency = $util.emptyArray; + /** * FileDescriptorProto messageType. * @member {Array.} messageType @@ -92320,6 +93196,9 @@ writer.uint32(/* id 12, wireType 2 =*/98).string(message.syntax); if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) writer.uint32(/* id 14, wireType 0 =*/112).int32(message.edition); + if (message.optionDependency != null && message.optionDependency.length) + for (var i = 0; i < message.optionDependency.length; ++i) + writer.uint32(/* id 15, wireType 2 =*/122).string(message.optionDependency[i]); return writer; }; @@ -92392,6 +93271,12 @@ message.weakDependency.push(reader.int32()); break; } + case 15: { + if (!(message.optionDependency && message.optionDependency.length)) + message.optionDependency = []; + message.optionDependency.push(reader.string()); + break; + } case 4: { if (!(message.messageType && message.messageType.length)) message.messageType = []; @@ -92494,6 +93379,13 @@ if (!$util.isInteger(message.weakDependency[i])) return "weakDependency: integer[] expected"; } + if (message.optionDependency != null && message.hasOwnProperty("optionDependency")) { + if (!Array.isArray(message.optionDependency)) + return "optionDependency: array expected"; + for (var i = 0; i < message.optionDependency.length; ++i) + if (!$util.isString(message.optionDependency[i])) + return "optionDependency: string[] expected"; + } if (message.messageType != null && message.hasOwnProperty("messageType")) { if (!Array.isArray(message.messageType)) return "messageType: array expected"; @@ -92548,6 +93440,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -92600,6 +93493,13 @@ for (var i = 0; i < object.weakDependency.length; ++i) message.weakDependency[i] = object.weakDependency[i] | 0; } + if (object.optionDependency) { + if (!Array.isArray(object.optionDependency)) + throw TypeError(".google.protobuf.FileDescriptorProto.optionDependency: array expected"); + message.optionDependency = []; + for (var i = 0; i < object.optionDependency.length; ++i) + message.optionDependency[i] = String(object.optionDependency[i]); + } if (object.messageType) { if (!Array.isArray(object.messageType)) throw TypeError(".google.protobuf.FileDescriptorProto.messageType: array expected"); @@ -92663,6 +93563,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -92728,6 +93632,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -92784,6 +93689,11 @@ object.syntax = message.syntax; if (message.edition != null && message.hasOwnProperty("edition")) object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.optionDependency && message.optionDependency.length) { + object.optionDependency = []; + for (var j = 0; j < message.optionDependency.length; ++j) + object.optionDependency[j] = message.optionDependency[j]; + } return object; }; @@ -92832,6 +93742,7 @@ * @property {google.protobuf.IMessageOptions|null} [options] DescriptorProto options * @property {Array.|null} [reservedRange] DescriptorProto reservedRange * @property {Array.|null} [reservedName] DescriptorProto reservedName + * @property {google.protobuf.SymbolVisibility|null} [visibility] DescriptorProto visibility */ /** @@ -92937,6 +93848,14 @@ */ DescriptorProto.prototype.reservedName = $util.emptyArray; + /** + * DescriptorProto visibility. + * @member {google.protobuf.SymbolVisibility} visibility + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.visibility = 0; + /** * Creates a new DescriptorProto instance using the specified properties. * @function create @@ -92989,6 +93908,8 @@ if (message.reservedName != null && message.reservedName.length) for (var i = 0; i < message.reservedName.length; ++i) writer.uint32(/* id 10, wireType 2 =*/82).string(message.reservedName[i]); + if (message.visibility != null && Object.hasOwnProperty.call(message, "visibility")) + writer.uint32(/* id 11, wireType 0 =*/88).int32(message.visibility); return writer; }; @@ -93081,6 +94002,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -93194,6 +94119,15 @@ if (!$util.isString(message.reservedName[i])) return "reservedName: string[] expected"; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + switch (message.visibility) { + default: + return "visibility: enum value expected"; + case 0: + case 1: + case 2: + break; + } return null; }; @@ -93293,6 +94227,26 @@ for (var i = 0; i < object.reservedName.length; ++i) message.reservedName[i] = String(object.reservedName[i]); } + switch (object.visibility) { + default: + if (typeof object.visibility === "number") { + message.visibility = object.visibility; + break; + } + break; + case "VISIBILITY_UNSET": + case 0: + message.visibility = 0; + break; + case "VISIBILITY_LOCAL": + case 1: + message.visibility = 1; + break; + case "VISIBILITY_EXPORT": + case 2: + message.visibility = 2; + break; + } return message; }; @@ -93322,6 +94276,7 @@ if (options.defaults) { object.name = ""; object.options = null; + object.visibility = options.enums === String ? "VISIBILITY_UNSET" : 0; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -93367,6 +94322,8 @@ for (var j = 0; j < message.reservedName.length; ++j) object.reservedName[j] = message.reservedName[j]; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + object.visibility = options.enums === String ? $root.google.protobuf.SymbolVisibility[message.visibility] === undefined ? message.visibility : $root.google.protobuf.SymbolVisibility[message.visibility] : message.visibility; return object; }; @@ -95411,6 +96368,7 @@ * @property {google.protobuf.IEnumOptions|null} [options] EnumDescriptorProto options * @property {Array.|null} [reservedRange] EnumDescriptorProto reservedRange * @property {Array.|null} [reservedName] EnumDescriptorProto reservedName + * @property {google.protobuf.SymbolVisibility|null} [visibility] EnumDescriptorProto visibility */ /** @@ -95471,6 +96429,14 @@ */ EnumDescriptorProto.prototype.reservedName = $util.emptyArray; + /** + * EnumDescriptorProto visibility. + * @member {google.protobuf.SymbolVisibility} visibility + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.visibility = 0; + /** * Creates a new EnumDescriptorProto instance using the specified properties. * @function create @@ -95508,6 +96474,8 @@ if (message.reservedName != null && message.reservedName.length) for (var i = 0; i < message.reservedName.length; ++i) writer.uint32(/* id 5, wireType 2 =*/42).string(message.reservedName[i]); + if (message.visibility != null && Object.hasOwnProperty.call(message, "visibility")) + writer.uint32(/* id 6, wireType 0 =*/48).int32(message.visibility); return writer; }; @@ -95570,6 +96538,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -95638,9 +96610,18 @@ if (!$util.isString(message.reservedName[i])) return "reservedName: string[] expected"; } - return null; - }; - + if (message.visibility != null && message.hasOwnProperty("visibility")) + switch (message.visibility) { + default: + return "visibility: enum value expected"; + case 0: + case 1: + case 2: + break; + } + return null; + }; + /** * Creates an EnumDescriptorProto message from a plain object. Also converts values to their respective internal types. * @function fromObject @@ -95687,6 +96668,26 @@ for (var i = 0; i < object.reservedName.length; ++i) message.reservedName[i] = String(object.reservedName[i]); } + switch (object.visibility) { + default: + if (typeof object.visibility === "number") { + message.visibility = object.visibility; + break; + } + break; + case "VISIBILITY_UNSET": + case 0: + message.visibility = 0; + break; + case "VISIBILITY_LOCAL": + case 1: + message.visibility = 1; + break; + case "VISIBILITY_EXPORT": + case 2: + message.visibility = 2; + break; + } return message; }; @@ -95711,6 +96712,7 @@ if (options.defaults) { object.name = ""; object.options = null; + object.visibility = options.enums === String ? "VISIBILITY_UNSET" : 0; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -95731,6 +96733,8 @@ for (var j = 0; j < message.reservedName.length; ++j) object.reservedName[j] = message.reservedName[j]; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + object.visibility = options.enums === String ? $root.google.protobuf.SymbolVisibility[message.visibility] === undefined ? message.visibility : $root.google.protobuf.SymbolVisibility[message.visibility] : message.visibility; return object; }; @@ -98049,6 +99053,7 @@ * @property {Array.|null} [targets] FieldOptions targets * @property {Array.|null} [editionDefaults] FieldOptions editionDefaults * @property {google.protobuf.IFeatureSet|null} [features] FieldOptions features + * @property {google.protobuf.FieldOptions.IFeatureSupport|null} [featureSupport] FieldOptions featureSupport * @property {Array.|null} [uninterpretedOption] FieldOptions uninterpretedOption * @property {Array.|null} [".google.api.fieldBehavior"] FieldOptions .google.api.fieldBehavior * @property {google.api.IResourceReference|null} [".google.api.resourceReference"] FieldOptions .google.api.resourceReference @@ -98170,6 +99175,14 @@ */ FieldOptions.prototype.features = null; + /** + * FieldOptions featureSupport. + * @member {google.protobuf.FieldOptions.IFeatureSupport|null|undefined} featureSupport + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.featureSupport = null; + /** * FieldOptions uninterpretedOption. * @member {Array.} uninterpretedOption @@ -98252,6 +99265,8 @@ $root.google.protobuf.FieldOptions.EditionDefault.encode(message.editionDefaults[i], writer.uint32(/* id 20, wireType 2 =*/162).fork()).ldelim(); if (message.features != null && Object.hasOwnProperty.call(message, "features")) $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 21, wireType 2 =*/170).fork()).ldelim(); + if (message.featureSupport != null && Object.hasOwnProperty.call(message, "featureSupport")) + $root.google.protobuf.FieldOptions.FeatureSupport.encode(message.featureSupport, writer.uint32(/* id 22, wireType 2 =*/178).fork()).ldelim(); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); @@ -98355,6 +99370,10 @@ message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); break; } + case 22: { + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.decode(reader, reader.uint32()); + break; + } case 999: { if (!(message.uninterpretedOption && message.uninterpretedOption.length)) message.uninterpretedOption = []; @@ -98494,6 +99513,11 @@ if (error) return "features." + error; } + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) { + var error = $root.google.protobuf.FieldOptions.FeatureSupport.verify(message.featureSupport); + if (error) + return "featureSupport." + error; + } if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { if (!Array.isArray(message.uninterpretedOption)) return "uninterpretedOption: array expected"; @@ -98687,6 +99711,11 @@ throw TypeError(".google.protobuf.FieldOptions.features: object expected"); message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); } + if (object.featureSupport != null) { + if (typeof object.featureSupport !== "object") + throw TypeError(".google.protobuf.FieldOptions.featureSupport: object expected"); + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.fromObject(object.featureSupport); + } if (object.uninterpretedOption) { if (!Array.isArray(object.uninterpretedOption)) throw TypeError(".google.protobuf.FieldOptions.uninterpretedOption: array expected"); @@ -98789,6 +99818,7 @@ object.debugRedact = false; object.retention = options.enums === String ? "RETENTION_UNKNOWN" : 0; object.features = null; + object.featureSupport = null; object[".google.api.resourceReference"] = null; object[".google.api.fieldInfo"] = null; } @@ -98822,6 +99852,8 @@ } if (message.features != null && message.hasOwnProperty("features")) object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) + object.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.toObject(message.featureSupport, options); if (message.uninterpretedOption && message.uninterpretedOption.length) { object.uninterpretedOption = []; for (var j = 0; j < message.uninterpretedOption.length; ++j) @@ -99018,42 +100050,370 @@ /** * Encodes the specified EditionDefault message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.EditionDefault.verify|verify} messages. * @function encodeDelimited - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {google.protobuf.FieldOptions.IEditionDefault} message EditionDefault message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EditionDefault.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an EditionDefault message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FieldOptions.EditionDefault} EditionDefault + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EditionDefault.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FieldOptions.EditionDefault(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 3: { + message.edition = reader.int32(); + break; + } + case 2: { + message.value = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an EditionDefault message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FieldOptions.EditionDefault} EditionDefault + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EditionDefault.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an EditionDefault message. + * @function verify + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EditionDefault.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.edition != null && message.hasOwnProperty("edition")) + switch (message.edition) { + default: + return "edition: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + if (message.value != null && message.hasOwnProperty("value")) + if (!$util.isString(message.value)) + return "value: string expected"; + return null; + }; + + /** + * Creates an EditionDefault message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldOptions.EditionDefault} EditionDefault + */ + EditionDefault.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FieldOptions.EditionDefault) + return object; + var message = new $root.google.protobuf.FieldOptions.EditionDefault(); + switch (object.edition) { + default: + if (typeof object.edition === "number") { + message.edition = object.edition; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.edition = 0; + break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; + case "EDITION_PROTO2": + case 998: + message.edition = 998; + break; + case "EDITION_PROTO3": + case 999: + message.edition = 999; + break; + case "EDITION_2023": + case 1000: + message.edition = 1000; + break; + case "EDITION_2024": + case 1001: + message.edition = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.edition = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.edition = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.edition = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.edition = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.edition = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.edition = 2147483647; + break; + } + if (object.value != null) + message.value = String(object.value); + return message; + }; + + /** + * Creates a plain object from an EditionDefault message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {google.protobuf.FieldOptions.EditionDefault} message EditionDefault + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EditionDefault.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.value = ""; + object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + } + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + if (message.edition != null && message.hasOwnProperty("edition")) + object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + return object; + }; + + /** + * Converts this EditionDefault to JSON. + * @function toJSON + * @memberof google.protobuf.FieldOptions.EditionDefault + * @instance + * @returns {Object.} JSON object + */ + EditionDefault.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for EditionDefault + * @function getTypeUrl + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + EditionDefault.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FieldOptions.EditionDefault"; + }; + + return EditionDefault; + })(); + + FieldOptions.FeatureSupport = (function() { + + /** + * Properties of a FeatureSupport. + * @memberof google.protobuf.FieldOptions + * @interface IFeatureSupport + * @property {google.protobuf.Edition|null} [editionIntroduced] FeatureSupport editionIntroduced + * @property {google.protobuf.Edition|null} [editionDeprecated] FeatureSupport editionDeprecated + * @property {string|null} [deprecationWarning] FeatureSupport deprecationWarning + * @property {google.protobuf.Edition|null} [editionRemoved] FeatureSupport editionRemoved + */ + + /** + * Constructs a new FeatureSupport. + * @memberof google.protobuf.FieldOptions + * @classdesc Represents a FeatureSupport. + * @implements IFeatureSupport + * @constructor + * @param {google.protobuf.FieldOptions.IFeatureSupport=} [properties] Properties to set + */ + function FeatureSupport(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]]; + } + + /** + * FeatureSupport editionIntroduced. + * @member {google.protobuf.Edition} editionIntroduced + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionIntroduced = 0; + + /** + * FeatureSupport editionDeprecated. + * @member {google.protobuf.Edition} editionDeprecated + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionDeprecated = 0; + + /** + * FeatureSupport deprecationWarning. + * @member {string} deprecationWarning + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.deprecationWarning = ""; + + /** + * FeatureSupport editionRemoved. + * @member {google.protobuf.Edition} editionRemoved + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionRemoved = 0; + + /** + * Creates a new FeatureSupport instance using the specified properties. + * @function create + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport=} [properties] Properties to set + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport instance + */ + FeatureSupport.create = function create(properties) { + return new FeatureSupport(properties); + }; + + /** + * Encodes the specified FeatureSupport message. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport} message FeatureSupport message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSupport.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.editionIntroduced != null && Object.hasOwnProperty.call(message, "editionIntroduced")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.editionIntroduced); + if (message.editionDeprecated != null && Object.hasOwnProperty.call(message, "editionDeprecated")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.editionDeprecated); + if (message.deprecationWarning != null && Object.hasOwnProperty.call(message, "deprecationWarning")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.deprecationWarning); + if (message.editionRemoved != null && Object.hasOwnProperty.call(message, "editionRemoved")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.editionRemoved); + return writer; + }; + + /** + * Encodes the specified FeatureSupport message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FieldOptions.FeatureSupport * @static - * @param {google.protobuf.FieldOptions.IEditionDefault} message EditionDefault message or plain object to encode + * @param {google.protobuf.FieldOptions.IFeatureSupport} message FeatureSupport message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - EditionDefault.encodeDelimited = function encodeDelimited(message, writer) { + FeatureSupport.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes an EditionDefault message from the specified reader or buffer. + * Decodes a FeatureSupport message from the specified reader or buffer. * @function decode - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {google.protobuf.FieldOptions.EditionDefault} EditionDefault + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - EditionDefault.decode = function decode(reader, length, error) { + FeatureSupport.decode = function decode(reader, length, error) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FieldOptions.EditionDefault(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FieldOptions.FeatureSupport(); while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) break; switch (tag >>> 3) { - case 3: { - message.edition = reader.int32(); + case 1: { + message.editionIntroduced = reader.int32(); break; } case 2: { - message.value = reader.string(); + message.editionDeprecated = reader.int32(); + break; + } + case 3: { + message.deprecationWarning = reader.string(); + break; + } + case 4: { + message.editionRemoved = reader.int32(); break; } default: @@ -99065,37 +100425,77 @@ }; /** - * Decodes an EditionDefault message from the specified reader or buffer, length delimited. + * Decodes a FeatureSupport message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.protobuf.FieldOptions.EditionDefault} EditionDefault + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - EditionDefault.decodeDelimited = function decodeDelimited(reader) { + FeatureSupport.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies an EditionDefault message. + * Verifies a FeatureSupport message. * @function verify - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - EditionDefault.verify = function verify(message) { + FeatureSupport.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - if (message.edition != null && message.hasOwnProperty("edition")) - switch (message.edition) { + if (message.editionIntroduced != null && message.hasOwnProperty("editionIntroduced")) + switch (message.editionIntroduced) { default: - return "edition: enum value expected"; + return "editionIntroduced: enum value expected"; case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + if (message.editionDeprecated != null && message.hasOwnProperty("editionDeprecated")) + switch (message.editionDeprecated) { + default: + return "editionDeprecated: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + if (message.deprecationWarning != null && message.hasOwnProperty("deprecationWarning")) + if (!$util.isString(message.deprecationWarning)) + return "deprecationWarning: string expected"; + if (message.editionRemoved != null && message.hasOwnProperty("editionRemoved")) + switch (message.editionRemoved) { + default: + return "editionRemoved: enum value expected"; + case 0: + case 900: case 998: case 999: case 1000: @@ -99108,132 +100508,251 @@ case 2147483647: break; } - if (message.value != null && message.hasOwnProperty("value")) - if (!$util.isString(message.value)) - return "value: string expected"; return null; }; /** - * Creates an EditionDefault message from a plain object. Also converts values to their respective internal types. + * Creates a FeatureSupport message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @static * @param {Object.} object Plain object - * @returns {google.protobuf.FieldOptions.EditionDefault} EditionDefault + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport */ - EditionDefault.fromObject = function fromObject(object) { - if (object instanceof $root.google.protobuf.FieldOptions.EditionDefault) + FeatureSupport.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FieldOptions.FeatureSupport) return object; - var message = new $root.google.protobuf.FieldOptions.EditionDefault(); - switch (object.edition) { + var message = new $root.google.protobuf.FieldOptions.FeatureSupport(); + switch (object.editionIntroduced) { default: - if (typeof object.edition === "number") { - message.edition = object.edition; + if (typeof object.editionIntroduced === "number") { + message.editionIntroduced = object.editionIntroduced; break; } break; case "EDITION_UNKNOWN": case 0: - message.edition = 0; + message.editionIntroduced = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionIntroduced = 900; break; case "EDITION_PROTO2": case 998: - message.edition = 998; + message.editionIntroduced = 998; break; case "EDITION_PROTO3": case 999: - message.edition = 999; + message.editionIntroduced = 999; break; case "EDITION_2023": case 1000: - message.edition = 1000; + message.editionIntroduced = 1000; break; case "EDITION_2024": case 1001: - message.edition = 1001; + message.editionIntroduced = 1001; break; case "EDITION_1_TEST_ONLY": case 1: - message.edition = 1; + message.editionIntroduced = 1; break; case "EDITION_2_TEST_ONLY": case 2: - message.edition = 2; + message.editionIntroduced = 2; break; case "EDITION_99997_TEST_ONLY": case 99997: - message.edition = 99997; + message.editionIntroduced = 99997; break; case "EDITION_99998_TEST_ONLY": case 99998: - message.edition = 99998; + message.editionIntroduced = 99998; break; case "EDITION_99999_TEST_ONLY": case 99999: - message.edition = 99999; + message.editionIntroduced = 99999; break; case "EDITION_MAX": case 2147483647: - message.edition = 2147483647; + message.editionIntroduced = 2147483647; + break; + } + switch (object.editionDeprecated) { + default: + if (typeof object.editionDeprecated === "number") { + message.editionDeprecated = object.editionDeprecated; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionDeprecated = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionDeprecated = 900; + break; + case "EDITION_PROTO2": + case 998: + message.editionDeprecated = 998; + break; + case "EDITION_PROTO3": + case 999: + message.editionDeprecated = 999; + break; + case "EDITION_2023": + case 1000: + message.editionDeprecated = 1000; + break; + case "EDITION_2024": + case 1001: + message.editionDeprecated = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.editionDeprecated = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.editionDeprecated = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.editionDeprecated = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.editionDeprecated = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.editionDeprecated = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.editionDeprecated = 2147483647; + break; + } + if (object.deprecationWarning != null) + message.deprecationWarning = String(object.deprecationWarning); + switch (object.editionRemoved) { + default: + if (typeof object.editionRemoved === "number") { + message.editionRemoved = object.editionRemoved; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionRemoved = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionRemoved = 900; + break; + case "EDITION_PROTO2": + case 998: + message.editionRemoved = 998; + break; + case "EDITION_PROTO3": + case 999: + message.editionRemoved = 999; + break; + case "EDITION_2023": + case 1000: + message.editionRemoved = 1000; + break; + case "EDITION_2024": + case 1001: + message.editionRemoved = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.editionRemoved = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.editionRemoved = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.editionRemoved = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.editionRemoved = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.editionRemoved = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.editionRemoved = 2147483647; break; } - if (object.value != null) - message.value = String(object.value); return message; }; /** - * Creates a plain object from an EditionDefault message. Also converts values to other types if specified. + * Creates a plain object from a FeatureSupport message. Also converts values to other types if specified. * @function toObject - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @static - * @param {google.protobuf.FieldOptions.EditionDefault} message EditionDefault + * @param {google.protobuf.FieldOptions.FeatureSupport} message FeatureSupport * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - EditionDefault.toObject = function toObject(message, options) { + FeatureSupport.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { - object.value = ""; - object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.editionIntroduced = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.editionDeprecated = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.deprecationWarning = ""; + object.editionRemoved = options.enums === String ? "EDITION_UNKNOWN" : 0; } - if (message.value != null && message.hasOwnProperty("value")) - object.value = message.value; - if (message.edition != null && message.hasOwnProperty("edition")) - object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.editionIntroduced != null && message.hasOwnProperty("editionIntroduced")) + object.editionIntroduced = options.enums === String ? $root.google.protobuf.Edition[message.editionIntroduced] === undefined ? message.editionIntroduced : $root.google.protobuf.Edition[message.editionIntroduced] : message.editionIntroduced; + if (message.editionDeprecated != null && message.hasOwnProperty("editionDeprecated")) + object.editionDeprecated = options.enums === String ? $root.google.protobuf.Edition[message.editionDeprecated] === undefined ? message.editionDeprecated : $root.google.protobuf.Edition[message.editionDeprecated] : message.editionDeprecated; + if (message.deprecationWarning != null && message.hasOwnProperty("deprecationWarning")) + object.deprecationWarning = message.deprecationWarning; + if (message.editionRemoved != null && message.hasOwnProperty("editionRemoved")) + object.editionRemoved = options.enums === String ? $root.google.protobuf.Edition[message.editionRemoved] === undefined ? message.editionRemoved : $root.google.protobuf.Edition[message.editionRemoved] : message.editionRemoved; return object; }; /** - * Converts this EditionDefault to JSON. + * Converts this FeatureSupport to JSON. * @function toJSON - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @instance * @returns {Object.} JSON object */ - EditionDefault.prototype.toJSON = function toJSON() { + FeatureSupport.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for EditionDefault + * Gets the default type url for FeatureSupport * @function getTypeUrl - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - EditionDefault.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + FeatureSupport.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.protobuf.FieldOptions.EditionDefault"; + return typeUrlPrefix + "/google.protobuf.FieldOptions.FeatureSupport"; }; - return EditionDefault; + return FeatureSupport; })(); return FieldOptions; @@ -99828,6 +101347,7 @@ * @property {boolean|null} [deprecated] EnumValueOptions deprecated * @property {google.protobuf.IFeatureSet|null} [features] EnumValueOptions features * @property {boolean|null} [debugRedact] EnumValueOptions debugRedact + * @property {google.protobuf.FieldOptions.IFeatureSupport|null} [featureSupport] EnumValueOptions featureSupport * @property {Array.|null} [uninterpretedOption] EnumValueOptions uninterpretedOption */ @@ -99871,6 +101391,14 @@ */ EnumValueOptions.prototype.debugRedact = false; + /** + * EnumValueOptions featureSupport. + * @member {google.protobuf.FieldOptions.IFeatureSupport|null|undefined} featureSupport + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.featureSupport = null; + /** * EnumValueOptions uninterpretedOption. * @member {Array.} uninterpretedOption @@ -99909,6 +101437,8 @@ $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.debugRedact != null && Object.hasOwnProperty.call(message, "debugRedact")) writer.uint32(/* id 3, wireType 0 =*/24).bool(message.debugRedact); + if (message.featureSupport != null && Object.hasOwnProperty.call(message, "featureSupport")) + $root.google.protobuf.FieldOptions.FeatureSupport.encode(message.featureSupport, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); @@ -99960,6 +101490,10 @@ message.debugRedact = reader.bool(); break; } + case 4: { + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.decode(reader, reader.uint32()); + break; + } case 999: { if (!(message.uninterpretedOption && message.uninterpretedOption.length)) message.uninterpretedOption = []; @@ -100012,6 +101546,11 @@ if (message.debugRedact != null && message.hasOwnProperty("debugRedact")) if (typeof message.debugRedact !== "boolean") return "debugRedact: boolean expected"; + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) { + var error = $root.google.protobuf.FieldOptions.FeatureSupport.verify(message.featureSupport); + if (error) + return "featureSupport." + error; + } if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { if (!Array.isArray(message.uninterpretedOption)) return "uninterpretedOption: array expected"; @@ -100045,6 +101584,11 @@ } if (object.debugRedact != null) message.debugRedact = Boolean(object.debugRedact); + if (object.featureSupport != null) { + if (typeof object.featureSupport !== "object") + throw TypeError(".google.protobuf.EnumValueOptions.featureSupport: object expected"); + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.fromObject(object.featureSupport); + } if (object.uninterpretedOption) { if (!Array.isArray(object.uninterpretedOption)) throw TypeError(".google.protobuf.EnumValueOptions.uninterpretedOption: array expected"); @@ -100077,6 +101621,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -100084,6 +101629,8 @@ object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); if (message.debugRedact != null && message.hasOwnProperty("debugRedact")) object.debugRedact = message.debugRedact; + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) + object.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.toObject(message.featureSupport, options); if (message.uninterpretedOption && message.uninterpretedOption.length) { object.uninterpretedOption = []; for (var j = 0; j < message.uninterpretedOption.length; ++j) @@ -101551,6 +103098,8 @@ * @property {google.protobuf.FeatureSet.Utf8Validation|null} [utf8Validation] FeatureSet utf8Validation * @property {google.protobuf.FeatureSet.MessageEncoding|null} [messageEncoding] FeatureSet messageEncoding * @property {google.protobuf.FeatureSet.JsonFormat|null} [jsonFormat] FeatureSet jsonFormat + * @property {google.protobuf.FeatureSet.EnforceNamingStyle|null} [enforceNamingStyle] FeatureSet enforceNamingStyle + * @property {google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|null} [defaultSymbolVisibility] FeatureSet defaultSymbolVisibility */ /** @@ -101616,6 +103165,22 @@ */ FeatureSet.prototype.jsonFormat = 0; + /** + * FeatureSet enforceNamingStyle. + * @member {google.protobuf.FeatureSet.EnforceNamingStyle} enforceNamingStyle + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.enforceNamingStyle = 0; + + /** + * FeatureSet defaultSymbolVisibility. + * @member {google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility} defaultSymbolVisibility + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.defaultSymbolVisibility = 0; + /** * Creates a new FeatureSet instance using the specified properties. * @function create @@ -101652,6 +103217,10 @@ writer.uint32(/* id 5, wireType 0 =*/40).int32(message.messageEncoding); if (message.jsonFormat != null && Object.hasOwnProperty.call(message, "jsonFormat")) writer.uint32(/* id 6, wireType 0 =*/48).int32(message.jsonFormat); + if (message.enforceNamingStyle != null && Object.hasOwnProperty.call(message, "enforceNamingStyle")) + writer.uint32(/* id 7, wireType 0 =*/56).int32(message.enforceNamingStyle); + if (message.defaultSymbolVisibility != null && Object.hasOwnProperty.call(message, "defaultSymbolVisibility")) + writer.uint32(/* id 8, wireType 0 =*/64).int32(message.defaultSymbolVisibility); return writer; }; @@ -101712,6 +103281,14 @@ message.jsonFormat = reader.int32(); break; } + case 7: { + message.enforceNamingStyle = reader.int32(); + break; + } + case 8: { + message.defaultSymbolVisibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -101802,6 +103379,26 @@ case 2: break; } + if (message.enforceNamingStyle != null && message.hasOwnProperty("enforceNamingStyle")) + switch (message.enforceNamingStyle) { + default: + return "enforceNamingStyle: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.defaultSymbolVisibility != null && message.hasOwnProperty("defaultSymbolVisibility")) + switch (message.defaultSymbolVisibility) { + default: + return "defaultSymbolVisibility: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } return null; }; @@ -101908,37 +103505,85 @@ break; } break; - case "MESSAGE_ENCODING_UNKNOWN": + case "MESSAGE_ENCODING_UNKNOWN": + case 0: + message.messageEncoding = 0; + break; + case "LENGTH_PREFIXED": + case 1: + message.messageEncoding = 1; + break; + case "DELIMITED": + case 2: + message.messageEncoding = 2; + break; + } + switch (object.jsonFormat) { + default: + if (typeof object.jsonFormat === "number") { + message.jsonFormat = object.jsonFormat; + break; + } + break; + case "JSON_FORMAT_UNKNOWN": + case 0: + message.jsonFormat = 0; + break; + case "ALLOW": + case 1: + message.jsonFormat = 1; + break; + case "LEGACY_BEST_EFFORT": + case 2: + message.jsonFormat = 2; + break; + } + switch (object.enforceNamingStyle) { + default: + if (typeof object.enforceNamingStyle === "number") { + message.enforceNamingStyle = object.enforceNamingStyle; + break; + } + break; + case "ENFORCE_NAMING_STYLE_UNKNOWN": case 0: - message.messageEncoding = 0; + message.enforceNamingStyle = 0; break; - case "LENGTH_PREFIXED": + case "STYLE2024": case 1: - message.messageEncoding = 1; + message.enforceNamingStyle = 1; break; - case "DELIMITED": + case "STYLE_LEGACY": case 2: - message.messageEncoding = 2; + message.enforceNamingStyle = 2; break; } - switch (object.jsonFormat) { + switch (object.defaultSymbolVisibility) { default: - if (typeof object.jsonFormat === "number") { - message.jsonFormat = object.jsonFormat; + if (typeof object.defaultSymbolVisibility === "number") { + message.defaultSymbolVisibility = object.defaultSymbolVisibility; break; } break; - case "JSON_FORMAT_UNKNOWN": + case "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN": case 0: - message.jsonFormat = 0; + message.defaultSymbolVisibility = 0; break; - case "ALLOW": + case "EXPORT_ALL": case 1: - message.jsonFormat = 1; + message.defaultSymbolVisibility = 1; break; - case "LEGACY_BEST_EFFORT": + case "EXPORT_TOP_LEVEL": case 2: - message.jsonFormat = 2; + message.defaultSymbolVisibility = 2; + break; + case "LOCAL_ALL": + case 3: + message.defaultSymbolVisibility = 3; + break; + case "STRICT": + case 4: + message.defaultSymbolVisibility = 4; break; } return message; @@ -101964,6 +103609,8 @@ object.utf8Validation = options.enums === String ? "UTF8_VALIDATION_UNKNOWN" : 0; object.messageEncoding = options.enums === String ? "MESSAGE_ENCODING_UNKNOWN" : 0; object.jsonFormat = options.enums === String ? "JSON_FORMAT_UNKNOWN" : 0; + object.enforceNamingStyle = options.enums === String ? "ENFORCE_NAMING_STYLE_UNKNOWN" : 0; + object.defaultSymbolVisibility = options.enums === String ? "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN" : 0; } if (message.fieldPresence != null && message.hasOwnProperty("fieldPresence")) object.fieldPresence = options.enums === String ? $root.google.protobuf.FeatureSet.FieldPresence[message.fieldPresence] === undefined ? message.fieldPresence : $root.google.protobuf.FeatureSet.FieldPresence[message.fieldPresence] : message.fieldPresence; @@ -101977,6 +103624,10 @@ object.messageEncoding = options.enums === String ? $root.google.protobuf.FeatureSet.MessageEncoding[message.messageEncoding] === undefined ? message.messageEncoding : $root.google.protobuf.FeatureSet.MessageEncoding[message.messageEncoding] : message.messageEncoding; if (message.jsonFormat != null && message.hasOwnProperty("jsonFormat")) object.jsonFormat = options.enums === String ? $root.google.protobuf.FeatureSet.JsonFormat[message.jsonFormat] === undefined ? message.jsonFormat : $root.google.protobuf.FeatureSet.JsonFormat[message.jsonFormat] : message.jsonFormat; + if (message.enforceNamingStyle != null && message.hasOwnProperty("enforceNamingStyle")) + object.enforceNamingStyle = options.enums === String ? $root.google.protobuf.FeatureSet.EnforceNamingStyle[message.enforceNamingStyle] === undefined ? message.enforceNamingStyle : $root.google.protobuf.FeatureSet.EnforceNamingStyle[message.enforceNamingStyle] : message.enforceNamingStyle; + if (message.defaultSymbolVisibility != null && message.hasOwnProperty("defaultSymbolVisibility")) + object.defaultSymbolVisibility = options.enums === String ? $root.google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility[message.defaultSymbolVisibility] === undefined ? message.defaultSymbolVisibility : $root.google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility[message.defaultSymbolVisibility] : message.defaultSymbolVisibility; return object; }; @@ -102104,6 +103755,219 @@ return values; })(); + /** + * EnforceNamingStyle enum. + * @name google.protobuf.FeatureSet.EnforceNamingStyle + * @enum {number} + * @property {number} ENFORCE_NAMING_STYLE_UNKNOWN=0 ENFORCE_NAMING_STYLE_UNKNOWN value + * @property {number} STYLE2024=1 STYLE2024 value + * @property {number} STYLE_LEGACY=2 STYLE_LEGACY value + */ + FeatureSet.EnforceNamingStyle = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "ENFORCE_NAMING_STYLE_UNKNOWN"] = 0; + values[valuesById[1] = "STYLE2024"] = 1; + values[valuesById[2] = "STYLE_LEGACY"] = 2; + return values; + })(); + + FeatureSet.VisibilityFeature = (function() { + + /** + * Properties of a VisibilityFeature. + * @memberof google.protobuf.FeatureSet + * @interface IVisibilityFeature + */ + + /** + * Constructs a new VisibilityFeature. + * @memberof google.protobuf.FeatureSet + * @classdesc Represents a VisibilityFeature. + * @implements IVisibilityFeature + * @constructor + * @param {google.protobuf.FeatureSet.IVisibilityFeature=} [properties] Properties to set + */ + function VisibilityFeature(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]]; + } + + /** + * Creates a new VisibilityFeature instance using the specified properties. + * @function create + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature=} [properties] Properties to set + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature instance + */ + VisibilityFeature.create = function create(properties) { + return new VisibilityFeature(properties); + }; + + /** + * Encodes the specified VisibilityFeature message. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature} message VisibilityFeature message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VisibilityFeature.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified VisibilityFeature message, length delimited. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature} message VisibilityFeature message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VisibilityFeature.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VisibilityFeature.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FeatureSet.VisibilityFeature(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VisibilityFeature.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a VisibilityFeature message. + * @function verify + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + VisibilityFeature.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a VisibilityFeature message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + */ + VisibilityFeature.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FeatureSet.VisibilityFeature) + return object; + return new $root.google.protobuf.FeatureSet.VisibilityFeature(); + }; + + /** + * Creates a plain object from a VisibilityFeature message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.VisibilityFeature} message VisibilityFeature + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + VisibilityFeature.toObject = function toObject() { + return {}; + }; + + /** + * Converts this VisibilityFeature to JSON. + * @function toJSON + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @instance + * @returns {Object.} JSON object + */ + VisibilityFeature.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for VisibilityFeature + * @function getTypeUrl + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + VisibilityFeature.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FeatureSet.VisibilityFeature"; + }; + + /** + * DefaultSymbolVisibility enum. + * @name google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility + * @enum {number} + * @property {number} DEFAULT_SYMBOL_VISIBILITY_UNKNOWN=0 DEFAULT_SYMBOL_VISIBILITY_UNKNOWN value + * @property {number} EXPORT_ALL=1 EXPORT_ALL value + * @property {number} EXPORT_TOP_LEVEL=2 EXPORT_TOP_LEVEL value + * @property {number} LOCAL_ALL=3 LOCAL_ALL value + * @property {number} STRICT=4 STRICT value + */ + VisibilityFeature.DefaultSymbolVisibility = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN"] = 0; + values[valuesById[1] = "EXPORT_ALL"] = 1; + values[valuesById[2] = "EXPORT_TOP_LEVEL"] = 2; + values[valuesById[3] = "LOCAL_ALL"] = 3; + values[valuesById[4] = "STRICT"] = 4; + return values; + })(); + + return VisibilityFeature; + })(); + return FeatureSet; })(); @@ -102288,6 +104152,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -102305,6 +104170,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -102353,6 +104219,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -102405,6 +104275,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -102513,7 +104387,8 @@ * @memberof google.protobuf.FeatureSetDefaults * @interface IFeatureSetEditionDefault * @property {google.protobuf.Edition|null} [edition] FeatureSetEditionDefault edition - * @property {google.protobuf.IFeatureSet|null} [features] FeatureSetEditionDefault features + * @property {google.protobuf.IFeatureSet|null} [overridableFeatures] FeatureSetEditionDefault overridableFeatures + * @property {google.protobuf.IFeatureSet|null} [fixedFeatures] FeatureSetEditionDefault fixedFeatures */ /** @@ -102540,12 +104415,20 @@ FeatureSetEditionDefault.prototype.edition = 0; /** - * FeatureSetEditionDefault features. - * @member {google.protobuf.IFeatureSet|null|undefined} features + * FeatureSetEditionDefault overridableFeatures. + * @member {google.protobuf.IFeatureSet|null|undefined} overridableFeatures + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @instance + */ + FeatureSetEditionDefault.prototype.overridableFeatures = null; + + /** + * FeatureSetEditionDefault fixedFeatures. + * @member {google.protobuf.IFeatureSet|null|undefined} fixedFeatures * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault * @instance */ - FeatureSetEditionDefault.prototype.features = null; + FeatureSetEditionDefault.prototype.fixedFeatures = null; /** * Creates a new FeatureSetEditionDefault instance using the specified properties. @@ -102571,10 +104454,12 @@ FeatureSetEditionDefault.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.features != null && Object.hasOwnProperty.call(message, "features")) - $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) writer.uint32(/* id 3, wireType 0 =*/24).int32(message.edition); + if (message.overridableFeatures != null && Object.hasOwnProperty.call(message, "overridableFeatures")) + $root.google.protobuf.FeatureSet.encode(message.overridableFeatures, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.fixedFeatures != null && Object.hasOwnProperty.call(message, "fixedFeatures")) + $root.google.protobuf.FeatureSet.encode(message.fixedFeatures, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); return writer; }; @@ -102615,8 +104500,12 @@ message.edition = reader.int32(); break; } - case 2: { - message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + case 4: { + message.overridableFeatures = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + break; + } + case 5: { + message.fixedFeatures = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); break; } default: @@ -102659,6 +104548,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -102671,10 +104561,15 @@ case 2147483647: break; } - if (message.features != null && message.hasOwnProperty("features")) { - var error = $root.google.protobuf.FeatureSet.verify(message.features); + if (message.overridableFeatures != null && message.hasOwnProperty("overridableFeatures")) { + var error = $root.google.protobuf.FeatureSet.verify(message.overridableFeatures); + if (error) + return "overridableFeatures." + error; + } + if (message.fixedFeatures != null && message.hasOwnProperty("fixedFeatures")) { + var error = $root.google.protobuf.FeatureSet.verify(message.fixedFeatures); if (error) - return "features." + error; + return "fixedFeatures." + error; } return null; }; @@ -102702,6 +104597,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -102743,10 +104642,15 @@ message.edition = 2147483647; break; } - if (object.features != null) { - if (typeof object.features !== "object") - throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.features: object expected"); - message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); + if (object.overridableFeatures != null) { + if (typeof object.overridableFeatures !== "object") + throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.overridableFeatures: object expected"); + message.overridableFeatures = $root.google.protobuf.FeatureSet.fromObject(object.overridableFeatures); + } + if (object.fixedFeatures != null) { + if (typeof object.fixedFeatures !== "object") + throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.fixedFeatures: object expected"); + message.fixedFeatures = $root.google.protobuf.FeatureSet.fromObject(object.fixedFeatures); } return message; }; @@ -102765,13 +104669,16 @@ options = {}; var object = {}; if (options.defaults) { - object.features = null; object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.overridableFeatures = null; + object.fixedFeatures = null; } - if (message.features != null && message.hasOwnProperty("features")) - object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); if (message.edition != null && message.hasOwnProperty("edition")) object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.overridableFeatures != null && message.hasOwnProperty("overridableFeatures")) + object.overridableFeatures = $root.google.protobuf.FeatureSet.toObject(message.overridableFeatures, options); + if (message.fixedFeatures != null && message.hasOwnProperty("fixedFeatures")) + object.fixedFeatures = $root.google.protobuf.FeatureSet.toObject(message.fixedFeatures, options); return object; }; @@ -103986,6 +105893,22 @@ return GeneratedCodeInfo; })(); + /** + * SymbolVisibility enum. + * @name google.protobuf.SymbolVisibility + * @enum {number} + * @property {number} VISIBILITY_UNSET=0 VISIBILITY_UNSET value + * @property {number} VISIBILITY_LOCAL=1 VISIBILITY_LOCAL value + * @property {number} VISIBILITY_EXPORT=2 VISIBILITY_EXPORT value + */ + protobuf.SymbolVisibility = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "VISIBILITY_UNSET"] = 0; + values[valuesById[1] = "VISIBILITY_LOCAL"] = 1; + values[valuesById[2] = "VISIBILITY_EXPORT"] = 2; + return values; + })(); + protobuf.Timestamp = (function() { /** @@ -108523,6 +110446,12 @@ * @interface IViolation * @property {string|null} [subject] Violation subject * @property {string|null} [description] Violation description + * @property {string|null} [apiService] Violation apiService + * @property {string|null} [quotaMetric] Violation quotaMetric + * @property {string|null} [quotaId] Violation quotaId + * @property {Object.|null} [quotaDimensions] Violation quotaDimensions + * @property {number|Long|null} [quotaValue] Violation quotaValue + * @property {number|Long|null} [futureQuotaValue] Violation futureQuotaValue */ /** @@ -108534,6 +110463,7 @@ * @param {google.rpc.QuotaFailure.IViolation=} [properties] Properties to set */ function Violation(properties) { + this.quotaDimensions = {}; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -108556,6 +110486,63 @@ */ Violation.prototype.description = ""; + /** + * Violation apiService. + * @member {string} apiService + * @memberof google.rpc.QuotaFailure.Violation + * @instance + */ + Violation.prototype.apiService = ""; + + /** + * Violation quotaMetric. + * @member {string} quotaMetric + * @memberof google.rpc.QuotaFailure.Violation + * @instance + */ + Violation.prototype.quotaMetric = ""; + + /** + * Violation quotaId. + * @member {string} quotaId + * @memberof google.rpc.QuotaFailure.Violation + * @instance + */ + Violation.prototype.quotaId = ""; + + /** + * Violation quotaDimensions. + * @member {Object.} quotaDimensions + * @memberof google.rpc.QuotaFailure.Violation + * @instance + */ + Violation.prototype.quotaDimensions = $util.emptyObject; + + /** + * Violation quotaValue. + * @member {number|Long} quotaValue + * @memberof google.rpc.QuotaFailure.Violation + * @instance + */ + Violation.prototype.quotaValue = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Violation futureQuotaValue. + * @member {number|Long|null|undefined} futureQuotaValue + * @memberof google.rpc.QuotaFailure.Violation + * @instance + */ + Violation.prototype.futureQuotaValue = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + // Virtual OneOf for proto3 optional field + Object.defineProperty(Violation.prototype, "_futureQuotaValue", { + get: $util.oneOfGetter($oneOfFields = ["futureQuotaValue"]), + set: $util.oneOfSetter($oneOfFields) + }); + /** * Creates a new Violation instance using the specified properties. * @function create @@ -108584,6 +110571,19 @@ writer.uint32(/* id 1, wireType 2 =*/10).string(message.subject); if (message.description != null && Object.hasOwnProperty.call(message, "description")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.description); + if (message.apiService != null && Object.hasOwnProperty.call(message, "apiService")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.apiService); + if (message.quotaMetric != null && Object.hasOwnProperty.call(message, "quotaMetric")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.quotaMetric); + if (message.quotaId != null && Object.hasOwnProperty.call(message, "quotaId")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.quotaId); + if (message.quotaDimensions != null && Object.hasOwnProperty.call(message, "quotaDimensions")) + for (var keys = Object.keys(message.quotaDimensions), i = 0; i < keys.length; ++i) + writer.uint32(/* id 6, wireType 2 =*/50).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.quotaDimensions[keys[i]]).ldelim(); + if (message.quotaValue != null && Object.hasOwnProperty.call(message, "quotaValue")) + writer.uint32(/* id 7, wireType 0 =*/56).int64(message.quotaValue); + if (message.futureQuotaValue != null && Object.hasOwnProperty.call(message, "futureQuotaValue")) + writer.uint32(/* id 8, wireType 0 =*/64).int64(message.futureQuotaValue); return writer; }; @@ -108614,7 +110614,7 @@ Violation.decode = function decode(reader, length, error) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.rpc.QuotaFailure.Violation(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.rpc.QuotaFailure.Violation(), key, value; while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) @@ -108628,6 +110628,49 @@ message.description = reader.string(); break; } + case 3: { + message.apiService = reader.string(); + break; + } + case 4: { + message.quotaMetric = reader.string(); + break; + } + case 5: { + message.quotaId = reader.string(); + break; + } + case 6: { + if (message.quotaDimensions === $util.emptyObject) + message.quotaDimensions = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = ""; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = reader.string(); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.quotaDimensions[key] = value; + break; + } + case 7: { + message.quotaValue = reader.int64(); + break; + } + case 8: { + message.futureQuotaValue = reader.int64(); + break; + } default: reader.skipType(tag & 7); break; @@ -108663,12 +110706,38 @@ Violation.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; + var properties = {}; if (message.subject != null && message.hasOwnProperty("subject")) if (!$util.isString(message.subject)) return "subject: string expected"; if (message.description != null && message.hasOwnProperty("description")) if (!$util.isString(message.description)) return "description: string expected"; + if (message.apiService != null && message.hasOwnProperty("apiService")) + if (!$util.isString(message.apiService)) + return "apiService: string expected"; + if (message.quotaMetric != null && message.hasOwnProperty("quotaMetric")) + if (!$util.isString(message.quotaMetric)) + return "quotaMetric: string expected"; + if (message.quotaId != null && message.hasOwnProperty("quotaId")) + if (!$util.isString(message.quotaId)) + return "quotaId: string expected"; + if (message.quotaDimensions != null && message.hasOwnProperty("quotaDimensions")) { + if (!$util.isObject(message.quotaDimensions)) + return "quotaDimensions: object expected"; + var key = Object.keys(message.quotaDimensions); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.quotaDimensions[key[i]])) + return "quotaDimensions: string{k:string} expected"; + } + if (message.quotaValue != null && message.hasOwnProperty("quotaValue")) + if (!$util.isInteger(message.quotaValue) && !(message.quotaValue && $util.isInteger(message.quotaValue.low) && $util.isInteger(message.quotaValue.high))) + return "quotaValue: integer|Long expected"; + if (message.futureQuotaValue != null && message.hasOwnProperty("futureQuotaValue")) { + properties._futureQuotaValue = 1; + if (!$util.isInteger(message.futureQuotaValue) && !(message.futureQuotaValue && $util.isInteger(message.futureQuotaValue.low) && $util.isInteger(message.futureQuotaValue.high))) + return "futureQuotaValue: integer|Long expected"; + } return null; }; @@ -108688,6 +110757,37 @@ message.subject = String(object.subject); if (object.description != null) message.description = String(object.description); + if (object.apiService != null) + message.apiService = String(object.apiService); + if (object.quotaMetric != null) + message.quotaMetric = String(object.quotaMetric); + if (object.quotaId != null) + message.quotaId = String(object.quotaId); + if (object.quotaDimensions) { + if (typeof object.quotaDimensions !== "object") + throw TypeError(".google.rpc.QuotaFailure.Violation.quotaDimensions: object expected"); + message.quotaDimensions = {}; + for (var keys = Object.keys(object.quotaDimensions), i = 0; i < keys.length; ++i) + message.quotaDimensions[keys[i]] = String(object.quotaDimensions[keys[i]]); + } + if (object.quotaValue != null) + if ($util.Long) + (message.quotaValue = $util.Long.fromValue(object.quotaValue)).unsigned = false; + else if (typeof object.quotaValue === "string") + message.quotaValue = parseInt(object.quotaValue, 10); + else if (typeof object.quotaValue === "number") + message.quotaValue = object.quotaValue; + else if (typeof object.quotaValue === "object") + message.quotaValue = new $util.LongBits(object.quotaValue.low >>> 0, object.quotaValue.high >>> 0).toNumber(); + if (object.futureQuotaValue != null) + if ($util.Long) + (message.futureQuotaValue = $util.Long.fromValue(object.futureQuotaValue)).unsigned = false; + else if (typeof object.futureQuotaValue === "string") + message.futureQuotaValue = parseInt(object.futureQuotaValue, 10); + else if (typeof object.futureQuotaValue === "number") + message.futureQuotaValue = object.futureQuotaValue; + else if (typeof object.futureQuotaValue === "object") + message.futureQuotaValue = new $util.LongBits(object.futureQuotaValue.low >>> 0, object.futureQuotaValue.high >>> 0).toNumber(); return message; }; @@ -108704,14 +110804,49 @@ if (!options) options = {}; var object = {}; + if (options.objects || options.defaults) + object.quotaDimensions = {}; if (options.defaults) { object.subject = ""; object.description = ""; + object.apiService = ""; + object.quotaMetric = ""; + object.quotaId = ""; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.quotaValue = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.quotaValue = options.longs === String ? "0" : 0; } if (message.subject != null && message.hasOwnProperty("subject")) object.subject = message.subject; if (message.description != null && message.hasOwnProperty("description")) object.description = message.description; + if (message.apiService != null && message.hasOwnProperty("apiService")) + object.apiService = message.apiService; + if (message.quotaMetric != null && message.hasOwnProperty("quotaMetric")) + object.quotaMetric = message.quotaMetric; + if (message.quotaId != null && message.hasOwnProperty("quotaId")) + object.quotaId = message.quotaId; + var keys2; + if (message.quotaDimensions && (keys2 = Object.keys(message.quotaDimensions)).length) { + object.quotaDimensions = {}; + for (var j = 0; j < keys2.length; ++j) + object.quotaDimensions[keys2[j]] = message.quotaDimensions[keys2[j]]; + } + if (message.quotaValue != null && message.hasOwnProperty("quotaValue")) + if (typeof message.quotaValue === "number") + object.quotaValue = options.longs === String ? String(message.quotaValue) : message.quotaValue; + else + object.quotaValue = options.longs === String ? $util.Long.prototype.toString.call(message.quotaValue) : options.longs === Number ? new $util.LongBits(message.quotaValue.low >>> 0, message.quotaValue.high >>> 0).toNumber() : message.quotaValue; + if (message.futureQuotaValue != null && message.hasOwnProperty("futureQuotaValue")) { + if (typeof message.futureQuotaValue === "number") + object.futureQuotaValue = options.longs === String ? String(message.futureQuotaValue) : message.futureQuotaValue; + else + object.futureQuotaValue = options.longs === String ? $util.Long.prototype.toString.call(message.futureQuotaValue) : options.longs === Number ? new $util.LongBits(message.futureQuotaValue.low >>> 0, message.futureQuotaValue.high >>> 0).toNumber() : message.futureQuotaValue; + if (options.oneofs) + object._futureQuotaValue = "futureQuotaValue"; + } return object; }; @@ -109456,6 +111591,8 @@ * @interface IFieldViolation * @property {string|null} [field] FieldViolation field * @property {string|null} [description] FieldViolation description + * @property {string|null} [reason] FieldViolation reason + * @property {google.rpc.ILocalizedMessage|null} [localizedMessage] FieldViolation localizedMessage */ /** @@ -109489,6 +111626,22 @@ */ FieldViolation.prototype.description = ""; + /** + * FieldViolation reason. + * @member {string} reason + * @memberof google.rpc.BadRequest.FieldViolation + * @instance + */ + FieldViolation.prototype.reason = ""; + + /** + * FieldViolation localizedMessage. + * @member {google.rpc.ILocalizedMessage|null|undefined} localizedMessage + * @memberof google.rpc.BadRequest.FieldViolation + * @instance + */ + FieldViolation.prototype.localizedMessage = null; + /** * Creates a new FieldViolation instance using the specified properties. * @function create @@ -109517,6 +111670,10 @@ writer.uint32(/* id 1, wireType 2 =*/10).string(message.field); if (message.description != null && Object.hasOwnProperty.call(message, "description")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.description); + if (message.reason != null && Object.hasOwnProperty.call(message, "reason")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.reason); + if (message.localizedMessage != null && Object.hasOwnProperty.call(message, "localizedMessage")) + $root.google.rpc.LocalizedMessage.encode(message.localizedMessage, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); return writer; }; @@ -109561,6 +111718,14 @@ message.description = reader.string(); break; } + case 3: { + message.reason = reader.string(); + break; + } + case 4: { + message.localizedMessage = $root.google.rpc.LocalizedMessage.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -109602,6 +111767,14 @@ if (message.description != null && message.hasOwnProperty("description")) if (!$util.isString(message.description)) return "description: string expected"; + if (message.reason != null && message.hasOwnProperty("reason")) + if (!$util.isString(message.reason)) + return "reason: string expected"; + if (message.localizedMessage != null && message.hasOwnProperty("localizedMessage")) { + var error = $root.google.rpc.LocalizedMessage.verify(message.localizedMessage); + if (error) + return "localizedMessage." + error; + } return null; }; @@ -109621,6 +111794,13 @@ message.field = String(object.field); if (object.description != null) message.description = String(object.description); + if (object.reason != null) + message.reason = String(object.reason); + if (object.localizedMessage != null) { + if (typeof object.localizedMessage !== "object") + throw TypeError(".google.rpc.BadRequest.FieldViolation.localizedMessage: object expected"); + message.localizedMessage = $root.google.rpc.LocalizedMessage.fromObject(object.localizedMessage); + } return message; }; @@ -109640,11 +111820,17 @@ if (options.defaults) { object.field = ""; object.description = ""; + object.reason = ""; + object.localizedMessage = null; } if (message.field != null && message.hasOwnProperty("field")) object.field = message.field; if (message.description != null && message.hasOwnProperty("description")) object.description = message.description; + if (message.reason != null && message.hasOwnProperty("reason")) + object.reason = message.reason; + if (message.localizedMessage != null && message.hasOwnProperty("localizedMessage")) + object.localizedMessage = $root.google.rpc.LocalizedMessage.toObject(message.localizedMessage, options); return object; }; diff --git a/packages/google-cloud-networkconnectivity/protos/protos.json b/packages/google-cloud-networkconnectivity/protos/protos.json index 55b779345273..bb352c82d39f 100644 --- a/packages/google-cloud-networkconnectivity/protos/protos.json +++ b/packages/google-cloud-networkconnectivity/protos/protos.json @@ -11704,8 +11704,7 @@ "java_multiple_files": true, "java_outer_classname": "FieldInfoProto", "java_package": "com.google.api", - "objc_class_prefix": "GAPI", - "cc_enable_arenas": true + "objc_class_prefix": "GAPI" }, "nested": { "fieldBehavior": { @@ -11928,6 +11927,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -12068,6 +12071,28 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "experimentalFeatures": { + "type": "ExperimentalFeatures", + "id": 2 + } + }, + "nested": { + "ExperimentalFeatures": { + "fields": { + "restAsyncIoEnabled": { + "type": "bool", + "id": 1 + }, + "protobufPythonicTypesEnabled": { + "type": "bool", + "id": 2 + }, + "unversionedPackageDisabled": { + "type": "bool", + "id": 3 + } + } } } }, @@ -12125,6 +12150,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -12186,6 +12216,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -12208,6 +12251,11 @@ "format": { "type": "Format", "id": 1 + }, + "referencedTypes": { + "rule": "repeated", + "type": "TypeReference", + "id": 2 } }, "nested": { @@ -12221,6 +12269,14 @@ } } } + }, + "TypeReference": { + "fields": { + "typeName": { + "type": "string", + "id": 1 + } + } } } }, @@ -12243,12 +12299,19 @@ "type": "FileDescriptorProto", "id": 1 } - } + }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ] }, "Edition": { "edition": "proto2", "values": { "EDITION_UNKNOWN": 0, + "EDITION_LEGACY": 900, "EDITION_PROTO2": 998, "EDITION_PROTO3": 999, "EDITION_2023": 1000, @@ -12287,6 +12350,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -12375,6 +12443,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -12600,6 +12672,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -12650,7 +12726,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -12814,6 +12897,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -12949,7 +13033,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -12977,6 +13062,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -13046,6 +13135,26 @@ "id": 2 } } + }, + "FeatureSupport": { + "fields": { + "editionIntroduced": { + "type": "Edition", + "id": 1 + }, + "editionDeprecated": { + "type": "Edition", + "id": 2 + }, + "deprecationWarning": { + "type": "string", + "id": 3 + }, + "editionRemoved": { + "type": "Edition", + "id": 4 + } + } } } }, @@ -13134,6 +13243,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -13276,6 +13389,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -13286,6 +13400,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -13296,6 +13411,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -13306,6 +13422,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -13316,7 +13433,8 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", - "edition_defaults.edition": "EDITION_PROTO2", + "feature_support.edition_introduced": "EDITION_2023", + "edition_defaults.edition": "EDITION_LEGACY", "edition_defaults.value": "LENGTH_PREFIXED" } }, @@ -13326,27 +13444,38 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "ALLOW" } + }, + "enforceNamingStyle": { + "type": "EnforceNamingStyle", + "id": 7, + "options": { + "retention": "RETENTION_SOURCE", + "targets": "TARGET_TYPE_METHOD", + "feature_support.edition_introduced": "EDITION_2024", + "edition_defaults.edition": "EDITION_2024", + "edition_defaults.value": "STYLE2024" + } + }, + "defaultSymbolVisibility": { + "type": "VisibilityFeature.DefaultSymbolVisibility", + "id": 8, + "options": { + "retention": "RETENTION_SOURCE", + "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2024", + "edition_defaults.edition": "EDITION_2024", + "edition_defaults.value": "EXPORT_TOP_LEVEL" + } } }, "extensions": [ [ 1000, - 1000 - ], - [ - 1001, - 1001 - ], - [ - 1002, - 1002 - ], - [ - 9990, - 9990 + 9994 ], [ 9995, @@ -13391,7 +13520,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -13406,6 +13541,33 @@ "ALLOW": 1, "LEGACY_BEST_EFFORT": 2 } + }, + "EnforceNamingStyle": { + "values": { + "ENFORCE_NAMING_STYLE_UNKNOWN": 0, + "STYLE2024": 1, + "STYLE_LEGACY": 2 + } + }, + "VisibilityFeature": { + "fields": {}, + "reserved": [ + [ + 1, + 536870911 + ] + ], + "nested": { + "DefaultSymbolVisibility": { + "values": { + "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN": 0, + "EXPORT_ALL": 1, + "EXPORT_TOP_LEVEL": 2, + "LOCAL_ALL": 3, + "STRICT": 4 + } + } + } } } }, @@ -13433,11 +13595,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -13450,6 +13627,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -13535,6 +13718,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Timestamp": { "fields": { "seconds": { @@ -13593,6 +13784,7 @@ "java_multiple_files": true, "java_outer_classname": "OperationsProto", "java_package": "com.google.longrunning", + "objc_class_prefix": "GLRUN", "php_namespace": "Google\\LongRunning" }, "nested": { @@ -13876,6 +14068,13 @@ }, "nested": { "Violation": { + "oneofs": { + "_futureQuotaValue": { + "oneof": [ + "futureQuotaValue" + ] + } + }, "fields": { "subject": { "type": "string", @@ -13884,6 +14083,34 @@ "description": { "type": "string", "id": 2 + }, + "apiService": { + "type": "string", + "id": 3 + }, + "quotaMetric": { + "type": "string", + "id": 4 + }, + "quotaId": { + "type": "string", + "id": 5 + }, + "quotaDimensions": { + "keyType": "string", + "type": "string", + "id": 6 + }, + "quotaValue": { + "type": "int64", + "id": 7 + }, + "futureQuotaValue": { + "type": "int64", + "id": 8, + "options": { + "proto3_optional": true + } } } } @@ -13934,6 +14161,14 @@ "description": { "type": "string", "id": 2 + }, + "reason": { + "type": "string", + "id": 3 + }, + "localizedMessage": { + "type": "LocalizedMessage", + "id": 4 } } } diff --git a/packages/google-cloud-networkconnectivity/samples/generated/v1/snippet_metadata_google.cloud.networkconnectivity.v1.json b/packages/google-cloud-networkconnectivity/samples/generated/v1/snippet_metadata_google.cloud.networkconnectivity.v1.json index e1486f87ada4..0c531beb5f50 100644 --- a/packages/google-cloud-networkconnectivity/samples/generated/v1/snippet_metadata_google.cloud.networkconnectivity.v1.json +++ b/packages/google-cloud-networkconnectivity/samples/generated/v1/snippet_metadata_google.cloud.networkconnectivity.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-networkconnectivity", - "version": "4.6.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-networkconnectivity/samples/generated/v1alpha1/snippet_metadata_google.cloud.networkconnectivity.v1alpha1.json b/packages/google-cloud-networkconnectivity/samples/generated/v1alpha1/snippet_metadata_google.cloud.networkconnectivity.v1alpha1.json index ee5537ebd4a6..9aa3324b1dd4 100644 --- a/packages/google-cloud-networkconnectivity/samples/generated/v1alpha1/snippet_metadata_google.cloud.networkconnectivity.v1alpha1.json +++ b/packages/google-cloud-networkconnectivity/samples/generated/v1alpha1/snippet_metadata_google.cloud.networkconnectivity.v1alpha1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-networkconnectivity", - "version": "4.6.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-networkconnectivity/samples/generated/v1beta/snippet_metadata_google.cloud.networkconnectivity.v1beta.json b/packages/google-cloud-networkconnectivity/samples/generated/v1beta/snippet_metadata_google.cloud.networkconnectivity.v1beta.json index 7656341ab253..ade8cb2088b3 100644 --- a/packages/google-cloud-networkconnectivity/samples/generated/v1beta/snippet_metadata_google.cloud.networkconnectivity.v1beta.json +++ b/packages/google-cloud-networkconnectivity/samples/generated/v1beta/snippet_metadata_google.cloud.networkconnectivity.v1beta.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-networkconnectivity", - "version": "4.6.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-networkconnectivity/src/v1/cross_network_automation_service_client.ts b/packages/google-cloud-networkconnectivity/src/v1/cross_network_automation_service_client.ts index 381d73d43490..bd70c6460057 100644 --- a/packages/google-cloud-networkconnectivity/src/v1/cross_network_automation_service_client.ts +++ b/packages/google-cloud-networkconnectivity/src/v1/cross_network_automation_service_client.ts @@ -18,11 +18,24 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -44,7 +57,7 @@ export class CrossNetworkAutomationServiceClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('network-connectivity'); @@ -57,12 +70,12 @@ export class CrossNetworkAutomationServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - crossNetworkAutomationServiceStub?: Promise<{[name: string]: Function}>; + crossNetworkAutomationServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of CrossNetworkAutomationServiceClient. @@ -103,21 +116,43 @@ export class CrossNetworkAutomationServiceClient { * const client = new CrossNetworkAutomationServiceClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof CrossNetworkAutomationServiceClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + const staticMembers = this + .constructor as typeof CrossNetworkAutomationServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'networkconnectivity.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -142,7 +177,7 @@ export class CrossNetworkAutomationServiceClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -155,18 +190,14 @@ export class CrossNetworkAutomationServiceClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -188,55 +219,57 @@ export class CrossNetworkAutomationServiceClient { // Create useful helper objects for these. this.pathTemplates = { destinationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}/destinations/{destination}' + 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}/destinations/{destination}', ), groupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}/groups/{group}' + 'projects/{project}/locations/global/hubs/{hub}/groups/{group}', ), hubPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}' + 'projects/{project}/locations/global/hubs/{hub}', ), hubRoutePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}/routes/{route}' + 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}/routes/{route}', ), internalRangePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/internalRanges/{internal_range}' + 'projects/{project}/locations/{location}/internalRanges/{internal_range}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - multicloudDataTransferConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}' - ), - multicloudDataTransferSupportedServicePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/multicloudDataTransferSupportedServices/{multicloud_data_transfer_supported_service}' + 'projects/{project}/locations/{location}', ), + multicloudDataTransferConfigPathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}', + ), + multicloudDataTransferSupportedServicePathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/multicloudDataTransferSupportedServices/{multicloud_data_transfer_supported_service}', + ), networkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/global/networks/{resource_id}' + 'projects/{project}/global/networks/{resource_id}', ), policyBasedRoutePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/PolicyBasedRoutes/{policy_based_route}' + 'projects/{project}/locations/global/PolicyBasedRoutes/{policy_based_route}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), routeTablePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}' + 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}', ), serviceClassPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/serviceClasses/{service_class}' + 'projects/{project}/locations/{location}/serviceClasses/{service_class}', ), serviceConnectionMapPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/serviceConnectionMaps/{service_connection_map}' + 'projects/{project}/locations/{location}/serviceConnectionMaps/{service_connection_map}', ), serviceConnectionPolicyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/serviceConnectionPolicies/{service_connection_policy}' + 'projects/{project}/locations/{location}/serviceConnectionPolicies/{service_connection_policy}', ), serviceConnectionTokenPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/serviceConnectionTokens/{service_connection_token}' + 'projects/{project}/locations/{location}/serviceConnectionTokens/{service_connection_token}', ), spokePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/spokes/{spoke}' + 'projects/{project}/locations/{location}/spokes/{spoke}', ), }; @@ -244,14 +277,26 @@ export class CrossNetworkAutomationServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listServiceConnectionMaps: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'serviceConnectionMaps'), - listServiceConnectionPolicies: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'serviceConnectionPolicies'), - listServiceClasses: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'serviceClasses'), - listServiceConnectionTokens: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'serviceConnectionTokens') + listServiceConnectionMaps: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'serviceConnectionMaps', + ), + listServiceConnectionPolicies: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'serviceConnectionPolicies', + ), + listServiceClasses: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'serviceClasses', + ), + listServiceConnectionTokens: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'serviceConnectionTokens', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -260,104 +305,291 @@ export class CrossNetworkAutomationServiceClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1/{resource=projects/*/locations/global/hubs/*}:getIamPolicy',additional_bindings: [{get: '/v1/{resource=projects/*/locations/global/hubs/*/groups/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/spokes/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/global/policyBasedRoutes/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/serviceConnectionMaps/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/serviceConnectionPolicies/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/serviceClasses/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/internalRanges/*}:getIamPolicy',}], - },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1/{resource=projects/*/locations/global/hubs/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/global/hubs/*/groups/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/spokes/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/global/policyBasedRoutes/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceConnectionMaps/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceConnectionPolicies/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceClasses/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/internalRanges/*}:setIamPolicy',body: '*',}], - },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1/{resource=projects/*/locations/global/hubs/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/global/hubs/*/groups/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/spokes/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/global/policyBasedRoutes/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceConnectionMaps/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceConnectionPolicies/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceClasses/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/internalRanges/*}:testIamPermissions',body: '*',}], - },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1/{resource=projects/*/locations/global/hubs/*}:getIamPolicy', + additional_bindings: [ + { + get: '/v1/{resource=projects/*/locations/global/hubs/*/groups/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/spokes/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/global/policyBasedRoutes/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/serviceConnectionMaps/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/serviceConnectionPolicies/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/serviceClasses/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/internalRanges/*}:getIamPolicy', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1/{resource=projects/*/locations/global/hubs/*}:setIamPolicy', + body: '*', + additional_bindings: [ + { + post: '/v1/{resource=projects/*/locations/global/hubs/*/groups/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/spokes/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/global/policyBasedRoutes/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceConnectionMaps/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceConnectionPolicies/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceClasses/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/internalRanges/*}:setIamPolicy', + body: '*', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1/{resource=projects/*/locations/global/hubs/*}:testIamPermissions', + body: '*', + additional_bindings: [ + { + post: '/v1/{resource=projects/*/locations/global/hubs/*/groups/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/spokes/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/global/policyBasedRoutes/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceConnectionMaps/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceConnectionPolicies/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceClasses/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/internalRanges/*}:testIamPermissions', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createServiceConnectionMapResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.ServiceConnectionMap') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.ServiceConnectionMap', + ) as gax.protobuf.Type; const createServiceConnectionMapMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateServiceConnectionMapResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.ServiceConnectionMap') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.ServiceConnectionMap', + ) as gax.protobuf.Type; const updateServiceConnectionMapMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteServiceConnectionMapResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteServiceConnectionMapMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; const createServiceConnectionPolicyResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy', + ) as gax.protobuf.Type; const createServiceConnectionPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateServiceConnectionPolicyResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy', + ) as gax.protobuf.Type; const updateServiceConnectionPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteServiceConnectionPolicyResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteServiceConnectionPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateServiceClassResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.ServiceClass') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.ServiceClass', + ) as gax.protobuf.Type; const updateServiceClassMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteServiceClassResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteServiceClassMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; const createServiceConnectionTokenResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.ServiceConnectionToken') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.ServiceConnectionToken', + ) as gax.protobuf.Type; const createServiceConnectionTokenMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteServiceConnectionTokenResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteServiceConnectionTokenMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createServiceConnectionMap: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - createServiceConnectionMapResponse.decode.bind(createServiceConnectionMapResponse), - createServiceConnectionMapMetadata.decode.bind(createServiceConnectionMapMetadata)), + createServiceConnectionMapResponse.decode.bind( + createServiceConnectionMapResponse, + ), + createServiceConnectionMapMetadata.decode.bind( + createServiceConnectionMapMetadata, + ), + ), updateServiceConnectionMap: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - updateServiceConnectionMapResponse.decode.bind(updateServiceConnectionMapResponse), - updateServiceConnectionMapMetadata.decode.bind(updateServiceConnectionMapMetadata)), + updateServiceConnectionMapResponse.decode.bind( + updateServiceConnectionMapResponse, + ), + updateServiceConnectionMapMetadata.decode.bind( + updateServiceConnectionMapMetadata, + ), + ), deleteServiceConnectionMap: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - deleteServiceConnectionMapResponse.decode.bind(deleteServiceConnectionMapResponse), - deleteServiceConnectionMapMetadata.decode.bind(deleteServiceConnectionMapMetadata)), + deleteServiceConnectionMapResponse.decode.bind( + deleteServiceConnectionMapResponse, + ), + deleteServiceConnectionMapMetadata.decode.bind( + deleteServiceConnectionMapMetadata, + ), + ), createServiceConnectionPolicy: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - createServiceConnectionPolicyResponse.decode.bind(createServiceConnectionPolicyResponse), - createServiceConnectionPolicyMetadata.decode.bind(createServiceConnectionPolicyMetadata)), + createServiceConnectionPolicyResponse.decode.bind( + createServiceConnectionPolicyResponse, + ), + createServiceConnectionPolicyMetadata.decode.bind( + createServiceConnectionPolicyMetadata, + ), + ), updateServiceConnectionPolicy: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - updateServiceConnectionPolicyResponse.decode.bind(updateServiceConnectionPolicyResponse), - updateServiceConnectionPolicyMetadata.decode.bind(updateServiceConnectionPolicyMetadata)), + updateServiceConnectionPolicyResponse.decode.bind( + updateServiceConnectionPolicyResponse, + ), + updateServiceConnectionPolicyMetadata.decode.bind( + updateServiceConnectionPolicyMetadata, + ), + ), deleteServiceConnectionPolicy: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - deleteServiceConnectionPolicyResponse.decode.bind(deleteServiceConnectionPolicyResponse), - deleteServiceConnectionPolicyMetadata.decode.bind(deleteServiceConnectionPolicyMetadata)), + deleteServiceConnectionPolicyResponse.decode.bind( + deleteServiceConnectionPolicyResponse, + ), + deleteServiceConnectionPolicyMetadata.decode.bind( + deleteServiceConnectionPolicyMetadata, + ), + ), updateServiceClass: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateServiceClassResponse.decode.bind(updateServiceClassResponse), - updateServiceClassMetadata.decode.bind(updateServiceClassMetadata)), + updateServiceClassMetadata.decode.bind(updateServiceClassMetadata), + ), deleteServiceClass: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteServiceClassResponse.decode.bind(deleteServiceClassResponse), - deleteServiceClassMetadata.decode.bind(deleteServiceClassMetadata)), + deleteServiceClassMetadata.decode.bind(deleteServiceClassMetadata), + ), createServiceConnectionToken: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - createServiceConnectionTokenResponse.decode.bind(createServiceConnectionTokenResponse), - createServiceConnectionTokenMetadata.decode.bind(createServiceConnectionTokenMetadata)), + createServiceConnectionTokenResponse.decode.bind( + createServiceConnectionTokenResponse, + ), + createServiceConnectionTokenMetadata.decode.bind( + createServiceConnectionTokenMetadata, + ), + ), deleteServiceConnectionToken: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - deleteServiceConnectionTokenResponse.decode.bind(deleteServiceConnectionTokenResponse), - deleteServiceConnectionTokenMetadata.decode.bind(deleteServiceConnectionTokenMetadata)) + deleteServiceConnectionTokenResponse.decode.bind( + deleteServiceConnectionTokenResponse, + ), + deleteServiceConnectionTokenMetadata.decode.bind( + deleteServiceConnectionTokenMetadata, + ), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.networkconnectivity.v1.CrossNetworkAutomationService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.networkconnectivity.v1.CrossNetworkAutomationService', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -388,28 +620,53 @@ export class CrossNetworkAutomationServiceClient { // Put together the "service stub" for // google.cloud.networkconnectivity.v1.CrossNetworkAutomationService. this.crossNetworkAutomationServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.networkconnectivity.v1.CrossNetworkAutomationService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.networkconnectivity.v1.CrossNetworkAutomationService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.networkconnectivity.v1.CrossNetworkAutomationService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.networkconnectivity.v1 + .CrossNetworkAutomationService, + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const crossNetworkAutomationServiceStubMethods = - ['listServiceConnectionMaps', 'getServiceConnectionMap', 'createServiceConnectionMap', 'updateServiceConnectionMap', 'deleteServiceConnectionMap', 'listServiceConnectionPolicies', 'getServiceConnectionPolicy', 'createServiceConnectionPolicy', 'updateServiceConnectionPolicy', 'deleteServiceConnectionPolicy', 'listServiceClasses', 'getServiceClass', 'updateServiceClass', 'deleteServiceClass', 'getServiceConnectionToken', 'listServiceConnectionTokens', 'createServiceConnectionToken', 'deleteServiceConnectionToken']; + const crossNetworkAutomationServiceStubMethods = [ + 'listServiceConnectionMaps', + 'getServiceConnectionMap', + 'createServiceConnectionMap', + 'updateServiceConnectionMap', + 'deleteServiceConnectionMap', + 'listServiceConnectionPolicies', + 'getServiceConnectionPolicy', + 'createServiceConnectionPolicy', + 'updateServiceConnectionPolicy', + 'deleteServiceConnectionPolicy', + 'listServiceClasses', + 'getServiceClass', + 'updateServiceClass', + 'deleteServiceClass', + 'getServiceConnectionToken', + 'listServiceConnectionTokens', + 'createServiceConnectionToken', + 'deleteServiceConnectionToken', + ]; for (const methodName of crossNetworkAutomationServiceStubMethods) { const callPromise = this.crossNetworkAutomationServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -419,7 +676,7 @@ export class CrossNetworkAutomationServiceClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -434,8 +691,14 @@ export class CrossNetworkAutomationServiceClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkconnectivity.googleapis.com'; } @@ -446,8 +709,14 @@ export class CrossNetworkAutomationServiceClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkconnectivity.googleapis.com'; } @@ -478,9 +747,7 @@ export class CrossNetworkAutomationServiceClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -489,8 +756,9 @@ export class CrossNetworkAutomationServiceClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -501,1738 +769,2610 @@ export class CrossNetworkAutomationServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets details of a single ServiceConnectionMap. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the ServiceConnectionMap to get. - * @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 {@link protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap|ServiceConnectionMap}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cross_network_automation_service.get_service_connection_map.js - * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_GetServiceConnectionMap_async - */ + /** + * Gets details of a single ServiceConnectionMap. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the ServiceConnectionMap to get. + * @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 {@link protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap|ServiceConnectionMap}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cross_network_automation_service.get_service_connection_map.js + * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_GetServiceConnectionMap_async + */ getServiceConnectionMap( - request?: protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionMapRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, - protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionMapRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionMapRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, + ( + | protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionMapRequest + | undefined + ), + {} | undefined, + ] + >; getServiceConnectionMap( - request: protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionMapRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, - protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionMapRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionMapRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, + | protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionMapRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getServiceConnectionMap( - request: protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionMapRequest, - callback: Callback< - protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, - protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionMapRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionMapRequest, + callback: Callback< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, + | protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionMapRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getServiceConnectionMap( - request?: protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionMapRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, - protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionMapRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionMapRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, - protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionMapRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, - protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionMapRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionMapRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, + | protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionMapRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, + ( + | protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionMapRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getServiceConnectionMap request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, - protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionMapRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, + | protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionMapRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getServiceConnectionMap response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getServiceConnectionMap(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, - protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionMapRequest|undefined, - {}|undefined - ]) => { - this._log.info('getServiceConnectionMap response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getServiceConnectionMap(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, + ( + | protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionMapRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getServiceConnectionMap response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single ServiceConnectionPolicy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the ServiceConnectionPolicy to get. - * @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 {@link protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy|ServiceConnectionPolicy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cross_network_automation_service.get_service_connection_policy.js - * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_GetServiceConnectionPolicy_async - */ + /** + * Gets details of a single ServiceConnectionPolicy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the ServiceConnectionPolicy to get. + * @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 {@link protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy|ServiceConnectionPolicy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cross_network_automation_service.get_service_connection_policy.js + * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_GetServiceConnectionPolicy_async + */ getServiceConnectionPolicy( - request?: protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, - protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionPolicyRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionPolicyRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, + ( + | protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionPolicyRequest + | undefined + ), + {} | undefined, + ] + >; getServiceConnectionPolicy( - request: protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, - protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, + | protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionPolicyRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getServiceConnectionPolicy( - request: protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionPolicyRequest, - callback: Callback< - protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, - protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionPolicyRequest, + callback: Callback< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, + | protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionPolicyRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getServiceConnectionPolicy( - request?: protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, - protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, - protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, - protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionPolicyRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionPolicyRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, + | protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionPolicyRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, + ( + | protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionPolicyRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getServiceConnectionPolicy request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, - protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionPolicyRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, + | protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionPolicyRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getServiceConnectionPolicy response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getServiceConnectionPolicy(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, - protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionPolicyRequest|undefined, - {}|undefined - ]) => { - this._log.info('getServiceConnectionPolicy response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getServiceConnectionPolicy(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, + ( + | protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionPolicyRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getServiceConnectionPolicy response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single ServiceClass. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the ServiceClass to get. - * @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 {@link protos.google.cloud.networkconnectivity.v1.ServiceClass|ServiceClass}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cross_network_automation_service.get_service_class.js - * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_GetServiceClass_async - */ + /** + * Gets details of a single ServiceClass. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the ServiceClass to get. + * @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 {@link protos.google.cloud.networkconnectivity.v1.ServiceClass|ServiceClass}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cross_network_automation_service.get_service_class.js + * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_GetServiceClass_async + */ getServiceClass( - request?: protos.google.cloud.networkconnectivity.v1.IGetServiceClassRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IServiceClass, - protos.google.cloud.networkconnectivity.v1.IGetServiceClassRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IGetServiceClassRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IServiceClass, + ( + | protos.google.cloud.networkconnectivity.v1.IGetServiceClassRequest + | undefined + ), + {} | undefined, + ] + >; getServiceClass( - request: protos.google.cloud.networkconnectivity.v1.IGetServiceClassRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkconnectivity.v1.IServiceClass, - protos.google.cloud.networkconnectivity.v1.IGetServiceClassRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IGetServiceClassRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkconnectivity.v1.IServiceClass, + | protos.google.cloud.networkconnectivity.v1.IGetServiceClassRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getServiceClass( - request: protos.google.cloud.networkconnectivity.v1.IGetServiceClassRequest, - callback: Callback< - protos.google.cloud.networkconnectivity.v1.IServiceClass, - protos.google.cloud.networkconnectivity.v1.IGetServiceClassRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IGetServiceClassRequest, + callback: Callback< + protos.google.cloud.networkconnectivity.v1.IServiceClass, + | protos.google.cloud.networkconnectivity.v1.IGetServiceClassRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getServiceClass( - request?: protos.google.cloud.networkconnectivity.v1.IGetServiceClassRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkconnectivity.v1.IServiceClass, - protos.google.cloud.networkconnectivity.v1.IGetServiceClassRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkconnectivity.v1.IGetServiceClassRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkconnectivity.v1.IServiceClass, - protos.google.cloud.networkconnectivity.v1.IGetServiceClassRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IServiceClass, - protos.google.cloud.networkconnectivity.v1.IGetServiceClassRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkconnectivity.v1.IGetServiceClassRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkconnectivity.v1.IServiceClass, + | protos.google.cloud.networkconnectivity.v1.IGetServiceClassRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IServiceClass, + ( + | protos.google.cloud.networkconnectivity.v1.IGetServiceClassRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getServiceClass request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkconnectivity.v1.IServiceClass, - protos.google.cloud.networkconnectivity.v1.IGetServiceClassRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkconnectivity.v1.IServiceClass, + | protos.google.cloud.networkconnectivity.v1.IGetServiceClassRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getServiceClass response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getServiceClass(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkconnectivity.v1.IServiceClass, - protos.google.cloud.networkconnectivity.v1.IGetServiceClassRequest|undefined, - {}|undefined - ]) => { - this._log.info('getServiceClass response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getServiceClass(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkconnectivity.v1.IServiceClass, + ( + | protos.google.cloud.networkconnectivity.v1.IGetServiceClassRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getServiceClass response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single ServiceConnectionToken. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the ServiceConnectionToken to get. - * @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 {@link protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken|ServiceConnectionToken}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cross_network_automation_service.get_service_connection_token.js - * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_GetServiceConnectionToken_async - */ + /** + * Gets details of a single ServiceConnectionToken. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the ServiceConnectionToken to get. + * @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 {@link protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken|ServiceConnectionToken}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cross_network_automation_service.get_service_connection_token.js + * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_GetServiceConnectionToken_async + */ getServiceConnectionToken( - request?: protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionTokenRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken, - protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionTokenRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionTokenRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken, + ( + | protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionTokenRequest + | undefined + ), + {} | undefined, + ] + >; getServiceConnectionToken( - request: protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionTokenRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken, - protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionTokenRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionTokenRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken, + | protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionTokenRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getServiceConnectionToken( - request: protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionTokenRequest, - callback: Callback< - protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken, - protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionTokenRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionTokenRequest, + callback: Callback< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken, + | protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionTokenRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getServiceConnectionToken( - request?: protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionTokenRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken, - protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionTokenRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionTokenRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken, - protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionTokenRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken, - protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionTokenRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionTokenRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken, + | protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionTokenRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken, + ( + | protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionTokenRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getServiceConnectionToken request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken, - protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionTokenRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken, + | protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionTokenRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getServiceConnectionToken response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getServiceConnectionToken(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken, - protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionTokenRequest|undefined, - {}|undefined - ]) => { - this._log.info('getServiceConnectionToken response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getServiceConnectionToken(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken, + ( + | protos.google.cloud.networkconnectivity.v1.IGetServiceConnectionTokenRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getServiceConnectionToken response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a new ServiceConnectionMap in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name of the ServiceConnectionMap. ex. - * projects/123/locations/us-east1 - * @param {string} [request.serviceConnectionMapId] - * Optional. Resource ID - * (i.e. 'foo' in '[...]/projects/p/locations/l/serviceConnectionMaps/foo') - * See https://google.aip.dev/122#resource-id-segments - * Unique per location. - * If one is not provided, one will be generated. - * @param {google.cloud.networkconnectivity.v1.ServiceConnectionMap} request.serviceConnectionMap - * Required. Initial values for a new ServiceConnectionMaps - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/cross_network_automation_service.create_service_connection_map.js - * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_CreateServiceConnectionMap_async - */ - createServiceConnectionMap( - request?: protos.google.cloud.networkconnectivity.v1.ICreateServiceConnectionMapRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + /** + * Creates a new ServiceConnectionMap in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name of the ServiceConnectionMap. ex. + * projects/123/locations/us-east1 + * @param {string} [request.serviceConnectionMapId] + * Optional. Resource ID + * (i.e. 'foo' in '[...]/projects/p/locations/l/serviceConnectionMaps/foo') + * See https://google.aip.dev/122#resource-id-segments + * Unique per location. + * If one is not provided, one will be generated. + * @param {google.cloud.networkconnectivity.v1.ServiceConnectionMap} request.serviceConnectionMap + * Required. Initial values for a new ServiceConnectionMaps + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/cross_network_automation_service.create_service_connection_map.js + * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_CreateServiceConnectionMap_async + */ createServiceConnectionMap( - request: protos.google.cloud.networkconnectivity.v1.ICreateServiceConnectionMapRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request?: protos.google.cloud.networkconnectivity.v1.ICreateServiceConnectionMapRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createServiceConnectionMap( - request: protos.google.cloud.networkconnectivity.v1.ICreateServiceConnectionMapRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.ICreateServiceConnectionMapRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createServiceConnectionMap( - request?: protos.google.cloud.networkconnectivity.v1.ICreateServiceConnectionMapRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request: protos.google.cloud.networkconnectivity.v1.ICreateServiceConnectionMapRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; + createServiceConnectionMap( + request?: protos.google.cloud.networkconnectivity.v1.ICreateServiceConnectionMapRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createServiceConnectionMap response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createServiceConnectionMap request %j', request); - return this.innerApiCalls.createServiceConnectionMap(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createServiceConnectionMap response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createServiceConnectionMap(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createServiceConnectionMap response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createServiceConnectionMap()`. - * @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/cross_network_automation_service.create_service_connection_map.js - * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_CreateServiceConnectionMap_async - */ - async checkCreateServiceConnectionMapProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createServiceConnectionMap()`. + * @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/cross_network_automation_service.create_service_connection_map.js + * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_CreateServiceConnectionMap_async + */ + async checkCreateServiceConnectionMapProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('createServiceConnectionMap long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createServiceConnectionMap, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createServiceConnectionMap, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; } -/** - * Updates the parameters of a single ServiceConnectionMap. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask is used to specify the fields to be overwritten in the - * ServiceConnectionMap resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - * @param {google.cloud.networkconnectivity.v1.ServiceConnectionMap} request.serviceConnectionMap - * Required. New values to be patched into the resource. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/cross_network_automation_service.update_service_connection_map.js - * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_UpdateServiceConnectionMap_async - */ + /** + * Updates the parameters of a single ServiceConnectionMap. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask is used to specify the fields to be overwritten in the + * ServiceConnectionMap resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @param {google.cloud.networkconnectivity.v1.ServiceConnectionMap} request.serviceConnectionMap + * Required. New values to be patched into the resource. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/cross_network_automation_service.update_service_connection_map.js + * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_UpdateServiceConnectionMap_async + */ updateServiceConnectionMap( - request?: protos.google.cloud.networkconnectivity.v1.IUpdateServiceConnectionMapRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IUpdateServiceConnectionMapRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateServiceConnectionMap( - request: protos.google.cloud.networkconnectivity.v1.IUpdateServiceConnectionMapRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IUpdateServiceConnectionMapRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateServiceConnectionMap( - request: protos.google.cloud.networkconnectivity.v1.IUpdateServiceConnectionMapRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IUpdateServiceConnectionMapRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateServiceConnectionMap( - request?: protos.google.cloud.networkconnectivity.v1.IUpdateServiceConnectionMapRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1.IUpdateServiceConnectionMapRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'service_connection_map.name': request.serviceConnectionMap!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'service_connection_map.name': request.serviceConnectionMap!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateServiceConnectionMap response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateServiceConnectionMap request %j', request); - return this.innerApiCalls.updateServiceConnectionMap(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateServiceConnectionMap response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateServiceConnectionMap(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateServiceConnectionMap response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateServiceConnectionMap()`. - * @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/cross_network_automation_service.update_service_connection_map.js - * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_UpdateServiceConnectionMap_async - */ - async checkUpdateServiceConnectionMapProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateServiceConnectionMap()`. + * @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/cross_network_automation_service.update_service_connection_map.js + * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_UpdateServiceConnectionMap_async + */ + async checkUpdateServiceConnectionMapProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('updateServiceConnectionMap long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateServiceConnectionMap, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateServiceConnectionMap, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; } -/** - * Deletes a single ServiceConnectionMap. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the ServiceConnectionMap to delete. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * 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.etag] - * Optional. The etag is computed by the server, and may be sent on update and - * delete requests to ensure the client has an up-to-date value before - * proceeding. - * @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/cross_network_automation_service.delete_service_connection_map.js - * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_DeleteServiceConnectionMap_async - */ + /** + * Deletes a single ServiceConnectionMap. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the ServiceConnectionMap to delete. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * 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.etag] + * Optional. The etag is computed by the server, and may be sent on update and + * delete requests to ensure the client has an up-to-date value before + * proceeding. + * @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/cross_network_automation_service.delete_service_connection_map.js + * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_DeleteServiceConnectionMap_async + */ deleteServiceConnectionMap( - request?: protos.google.cloud.networkconnectivity.v1.IDeleteServiceConnectionMapRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IDeleteServiceConnectionMapRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteServiceConnectionMap( - request: protos.google.cloud.networkconnectivity.v1.IDeleteServiceConnectionMapRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IDeleteServiceConnectionMapRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteServiceConnectionMap( - request: protos.google.cloud.networkconnectivity.v1.IDeleteServiceConnectionMapRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IDeleteServiceConnectionMapRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteServiceConnectionMap( - request?: protos.google.cloud.networkconnectivity.v1.IDeleteServiceConnectionMapRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1.IDeleteServiceConnectionMapRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteServiceConnectionMap response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteServiceConnectionMap request %j', request); - return this.innerApiCalls.deleteServiceConnectionMap(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteServiceConnectionMap response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteServiceConnectionMap(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteServiceConnectionMap response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteServiceConnectionMap()`. - * @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/cross_network_automation_service.delete_service_connection_map.js - * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_DeleteServiceConnectionMap_async - */ - async checkDeleteServiceConnectionMapProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteServiceConnectionMap()`. + * @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/cross_network_automation_service.delete_service_connection_map.js + * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_DeleteServiceConnectionMap_async + */ + async checkDeleteServiceConnectionMapProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('deleteServiceConnectionMap long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteServiceConnectionMap, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteServiceConnectionMap, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; } -/** - * Creates a new ServiceConnectionPolicy in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name of the ServiceConnectionPolicy. ex. - * projects/123/locations/us-east1 - * @param {string} [request.serviceConnectionPolicyId] - * Optional. Resource ID - * (i.e. 'foo' in - * '[...]/projects/p/locations/l/serviceConnectionPolicies/foo') See - * https://google.aip.dev/122#resource-id-segments Unique per location. - * @param {google.cloud.networkconnectivity.v1.ServiceConnectionPolicy} request.serviceConnectionPolicy - * Required. Initial values for a new ServiceConnectionPolicies - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/cross_network_automation_service.create_service_connection_policy.js - * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_CreateServiceConnectionPolicy_async - */ + /** + * Creates a new ServiceConnectionPolicy in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name of the ServiceConnectionPolicy. ex. + * projects/123/locations/us-east1 + * @param {string} [request.serviceConnectionPolicyId] + * Optional. Resource ID + * (i.e. 'foo' in + * '[...]/projects/p/locations/l/serviceConnectionPolicies/foo') See + * https://google.aip.dev/122#resource-id-segments Unique per location. + * @param {google.cloud.networkconnectivity.v1.ServiceConnectionPolicy} request.serviceConnectionPolicy + * Required. Initial values for a new ServiceConnectionPolicies + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/cross_network_automation_service.create_service_connection_policy.js + * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_CreateServiceConnectionPolicy_async + */ createServiceConnectionPolicy( - request?: protos.google.cloud.networkconnectivity.v1.ICreateServiceConnectionPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.ICreateServiceConnectionPolicyRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createServiceConnectionPolicy( - request: protos.google.cloud.networkconnectivity.v1.ICreateServiceConnectionPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.ICreateServiceConnectionPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createServiceConnectionPolicy( - request: protos.google.cloud.networkconnectivity.v1.ICreateServiceConnectionPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.ICreateServiceConnectionPolicyRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createServiceConnectionPolicy( - request?: protos.google.cloud.networkconnectivity.v1.ICreateServiceConnectionPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1.ICreateServiceConnectionPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { - this._log.info('createServiceConnectionPolicy response %j', rawResponse); + this._log.info( + 'createServiceConnectionPolicy response %j', + rawResponse, + ); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createServiceConnectionPolicy request %j', request); - return this.innerApiCalls.createServiceConnectionPolicy(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createServiceConnectionPolicy response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createServiceConnectionPolicy(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info( + 'createServiceConnectionPolicy response %j', + rawResponse, + ); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createServiceConnectionPolicy()`. - * @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/cross_network_automation_service.create_service_connection_policy.js - * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_CreateServiceConnectionPolicy_async - */ - async checkCreateServiceConnectionPolicyProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createServiceConnectionPolicy()`. + * @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/cross_network_automation_service.create_service_connection_policy.js + * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_CreateServiceConnectionPolicy_async + */ + async checkCreateServiceConnectionPolicyProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('createServiceConnectionPolicy long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createServiceConnectionPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createServiceConnectionPolicy, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; } -/** - * Updates the parameters of a single ServiceConnectionPolicy. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask is used to specify the fields to be overwritten in the - * ServiceConnectionPolicy resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - * @param {google.cloud.networkconnectivity.v1.ServiceConnectionPolicy} request.serviceConnectionPolicy - * Required. New values to be patched into the resource. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/cross_network_automation_service.update_service_connection_policy.js - * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_UpdateServiceConnectionPolicy_async - */ + /** + * Updates the parameters of a single ServiceConnectionPolicy. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask is used to specify the fields to be overwritten in the + * ServiceConnectionPolicy resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @param {google.cloud.networkconnectivity.v1.ServiceConnectionPolicy} request.serviceConnectionPolicy + * Required. New values to be patched into the resource. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/cross_network_automation_service.update_service_connection_policy.js + * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_UpdateServiceConnectionPolicy_async + */ updateServiceConnectionPolicy( - request?: protos.google.cloud.networkconnectivity.v1.IUpdateServiceConnectionPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IUpdateServiceConnectionPolicyRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateServiceConnectionPolicy( - request: protos.google.cloud.networkconnectivity.v1.IUpdateServiceConnectionPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IUpdateServiceConnectionPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateServiceConnectionPolicy( - request: protos.google.cloud.networkconnectivity.v1.IUpdateServiceConnectionPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IUpdateServiceConnectionPolicyRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateServiceConnectionPolicy( - request?: protos.google.cloud.networkconnectivity.v1.IUpdateServiceConnectionPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1.IUpdateServiceConnectionPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'service_connection_policy.name': request.serviceConnectionPolicy!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'service_connection_policy.name': + request.serviceConnectionPolicy!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { - this._log.info('updateServiceConnectionPolicy response %j', rawResponse); + this._log.info( + 'updateServiceConnectionPolicy response %j', + rawResponse, + ); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateServiceConnectionPolicy request %j', request); - return this.innerApiCalls.updateServiceConnectionPolicy(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateServiceConnectionPolicy response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateServiceConnectionPolicy(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info( + 'updateServiceConnectionPolicy response %j', + rawResponse, + ); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateServiceConnectionPolicy()`. - * @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/cross_network_automation_service.update_service_connection_policy.js - * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_UpdateServiceConnectionPolicy_async - */ - async checkUpdateServiceConnectionPolicyProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateServiceConnectionPolicy()`. + * @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/cross_network_automation_service.update_service_connection_policy.js + * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_UpdateServiceConnectionPolicy_async + */ + async checkUpdateServiceConnectionPolicyProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('updateServiceConnectionPolicy long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateServiceConnectionPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateServiceConnectionPolicy, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; } -/** - * Deletes a single ServiceConnectionPolicy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the ServiceConnectionPolicy to delete. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * 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.etag] - * Optional. The etag is computed by the server, and may be sent on update and - * delete requests to ensure the client has an up-to-date value before - * proceeding. - * @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/cross_network_automation_service.delete_service_connection_policy.js - * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_DeleteServiceConnectionPolicy_async - */ + /** + * Deletes a single ServiceConnectionPolicy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the ServiceConnectionPolicy to delete. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * 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.etag] + * Optional. The etag is computed by the server, and may be sent on update and + * delete requests to ensure the client has an up-to-date value before + * proceeding. + * @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/cross_network_automation_service.delete_service_connection_policy.js + * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_DeleteServiceConnectionPolicy_async + */ deleteServiceConnectionPolicy( - request?: protos.google.cloud.networkconnectivity.v1.IDeleteServiceConnectionPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IDeleteServiceConnectionPolicyRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteServiceConnectionPolicy( - request: protos.google.cloud.networkconnectivity.v1.IDeleteServiceConnectionPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IDeleteServiceConnectionPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteServiceConnectionPolicy( - request: protos.google.cloud.networkconnectivity.v1.IDeleteServiceConnectionPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IDeleteServiceConnectionPolicyRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteServiceConnectionPolicy( - request?: protos.google.cloud.networkconnectivity.v1.IDeleteServiceConnectionPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1.IDeleteServiceConnectionPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { - this._log.info('deleteServiceConnectionPolicy response %j', rawResponse); + this._log.info( + 'deleteServiceConnectionPolicy response %j', + rawResponse, + ); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteServiceConnectionPolicy request %j', request); - return this.innerApiCalls.deleteServiceConnectionPolicy(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteServiceConnectionPolicy response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteServiceConnectionPolicy(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info( + 'deleteServiceConnectionPolicy response %j', + rawResponse, + ); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteServiceConnectionPolicy()`. - * @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/cross_network_automation_service.delete_service_connection_policy.js - * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_DeleteServiceConnectionPolicy_async - */ - async checkDeleteServiceConnectionPolicyProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteServiceConnectionPolicy()`. + * @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/cross_network_automation_service.delete_service_connection_policy.js + * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_DeleteServiceConnectionPolicy_async + */ + async checkDeleteServiceConnectionPolicyProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('deleteServiceConnectionPolicy long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteServiceConnectionPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteServiceConnectionPolicy, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; } -/** - * Updates the parameters of a single ServiceClass. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask is used to specify the fields to be overwritten in the - * ServiceClass resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - * @param {google.cloud.networkconnectivity.v1.ServiceClass} request.serviceClass - * Required. New values to be patched into the resource. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/cross_network_automation_service.update_service_class.js - * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_UpdateServiceClass_async - */ + /** + * Updates the parameters of a single ServiceClass. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask is used to specify the fields to be overwritten in the + * ServiceClass resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @param {google.cloud.networkconnectivity.v1.ServiceClass} request.serviceClass + * Required. New values to be patched into the resource. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/cross_network_automation_service.update_service_class.js + * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_UpdateServiceClass_async + */ updateServiceClass( - request?: protos.google.cloud.networkconnectivity.v1.IUpdateServiceClassRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IUpdateServiceClassRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceClass, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateServiceClass( - request: protos.google.cloud.networkconnectivity.v1.IUpdateServiceClassRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IUpdateServiceClassRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceClass, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateServiceClass( - request: protos.google.cloud.networkconnectivity.v1.IUpdateServiceClassRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IUpdateServiceClassRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceClass, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateServiceClass( - request?: protos.google.cloud.networkconnectivity.v1.IUpdateServiceClassRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1.IUpdateServiceClassRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceClass, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceClass, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceClass, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'service_class.name': request.serviceClass!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'service_class.name': request.serviceClass!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceClass, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateServiceClass response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateServiceClass request %j', request); - return this.innerApiCalls.updateServiceClass(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateServiceClass response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateServiceClass(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceClass, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateServiceClass response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateServiceClass()`. - * @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/cross_network_automation_service.update_service_class.js - * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_UpdateServiceClass_async - */ - async checkUpdateServiceClassProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateServiceClass()`. + * @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/cross_network_automation_service.update_service_class.js + * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_UpdateServiceClass_async + */ + async checkUpdateServiceClassProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1.ServiceClass, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('updateServiceClass long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateServiceClass, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateServiceClass, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1.ServiceClass, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; } -/** - * Deletes a single ServiceClass. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the ServiceClass to delete. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * 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.etag] - * Optional. The etag is computed by the server, and may be sent on update and - * delete requests to ensure the client has an up-to-date value before - * proceeding. - * @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/cross_network_automation_service.delete_service_class.js - * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_DeleteServiceClass_async - */ + /** + * Deletes a single ServiceClass. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the ServiceClass to delete. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * 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.etag] + * Optional. The etag is computed by the server, and may be sent on update and + * delete requests to ensure the client has an up-to-date value before + * proceeding. + * @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/cross_network_automation_service.delete_service_class.js + * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_DeleteServiceClass_async + */ deleteServiceClass( - request?: protos.google.cloud.networkconnectivity.v1.IDeleteServiceClassRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IDeleteServiceClassRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteServiceClass( - request: protos.google.cloud.networkconnectivity.v1.IDeleteServiceClassRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IDeleteServiceClassRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteServiceClass( - request: protos.google.cloud.networkconnectivity.v1.IDeleteServiceClassRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IDeleteServiceClassRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteServiceClass( - request?: protos.google.cloud.networkconnectivity.v1.IDeleteServiceClassRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1.IDeleteServiceClassRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteServiceClass response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteServiceClass request %j', request); - return this.innerApiCalls.deleteServiceClass(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteServiceClass response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteServiceClass(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteServiceClass response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteServiceClass()`. - * @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/cross_network_automation_service.delete_service_class.js - * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_DeleteServiceClass_async - */ - async checkDeleteServiceClassProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteServiceClass()`. + * @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/cross_network_automation_service.delete_service_class.js + * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_DeleteServiceClass_async + */ + async checkDeleteServiceClassProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('deleteServiceClass long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteServiceClass, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteServiceClass, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; } -/** - * Creates a new ServiceConnectionToken in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name of the ServiceConnectionToken. ex. - * projects/123/locations/us-east1 - * @param {string} [request.serviceConnectionTokenId] - * Optional. Resource ID - * (i.e. 'foo' in '[...]/projects/p/locations/l/ServiceConnectionTokens/foo') - * See https://google.aip.dev/122#resource-id-segments - * Unique per location. - * If one is not provided, one will be generated. - * @param {google.cloud.networkconnectivity.v1.ServiceConnectionToken} request.serviceConnectionToken - * Required. Initial values for a new ServiceConnectionTokens - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/cross_network_automation_service.create_service_connection_token.js - * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_CreateServiceConnectionToken_async - */ + /** + * Creates a new ServiceConnectionToken in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name of the ServiceConnectionToken. ex. + * projects/123/locations/us-east1 + * @param {string} [request.serviceConnectionTokenId] + * Optional. Resource ID + * (i.e. 'foo' in '[...]/projects/p/locations/l/ServiceConnectionTokens/foo') + * See https://google.aip.dev/122#resource-id-segments + * Unique per location. + * If one is not provided, one will be generated. + * @param {google.cloud.networkconnectivity.v1.ServiceConnectionToken} request.serviceConnectionToken + * Required. Initial values for a new ServiceConnectionTokens + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/cross_network_automation_service.create_service_connection_token.js + * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_CreateServiceConnectionToken_async + */ createServiceConnectionToken( - request?: protos.google.cloud.networkconnectivity.v1.ICreateServiceConnectionTokenRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.ICreateServiceConnectionTokenRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createServiceConnectionToken( - request: protos.google.cloud.networkconnectivity.v1.ICreateServiceConnectionTokenRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.ICreateServiceConnectionTokenRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createServiceConnectionToken( - request: protos.google.cloud.networkconnectivity.v1.ICreateServiceConnectionTokenRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.ICreateServiceConnectionTokenRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createServiceConnectionToken( - request?: protos.google.cloud.networkconnectivity.v1.ICreateServiceConnectionTokenRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1.ICreateServiceConnectionTokenRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { - this._log.info('createServiceConnectionToken response %j', rawResponse); + this._log.info( + 'createServiceConnectionToken response %j', + rawResponse, + ); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createServiceConnectionToken request %j', request); - return this.innerApiCalls.createServiceConnectionToken(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createServiceConnectionToken response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createServiceConnectionToken(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info( + 'createServiceConnectionToken response %j', + rawResponse, + ); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createServiceConnectionToken()`. - * @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/cross_network_automation_service.create_service_connection_token.js - * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_CreateServiceConnectionToken_async - */ - async checkCreateServiceConnectionTokenProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createServiceConnectionToken()`. + * @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/cross_network_automation_service.create_service_connection_token.js + * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_CreateServiceConnectionToken_async + */ + async checkCreateServiceConnectionTokenProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('createServiceConnectionToken long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createServiceConnectionToken, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createServiceConnectionToken, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; } -/** - * Deletes a single ServiceConnectionToken. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the ServiceConnectionToken to delete. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * 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.etag] - * Optional. The etag is computed by the server, and may be sent on update and - * delete requests to ensure the client has an up-to-date value before - * proceeding. - * @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/cross_network_automation_service.delete_service_connection_token.js - * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_DeleteServiceConnectionToken_async - */ + /** + * Deletes a single ServiceConnectionToken. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the ServiceConnectionToken to delete. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * 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.etag] + * Optional. The etag is computed by the server, and may be sent on update and + * delete requests to ensure the client has an up-to-date value before + * proceeding. + * @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/cross_network_automation_service.delete_service_connection_token.js + * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_DeleteServiceConnectionToken_async + */ deleteServiceConnectionToken( - request?: protos.google.cloud.networkconnectivity.v1.IDeleteServiceConnectionTokenRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IDeleteServiceConnectionTokenRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteServiceConnectionToken( - request: protos.google.cloud.networkconnectivity.v1.IDeleteServiceConnectionTokenRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IDeleteServiceConnectionTokenRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteServiceConnectionToken( - request: protos.google.cloud.networkconnectivity.v1.IDeleteServiceConnectionTokenRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IDeleteServiceConnectionTokenRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteServiceConnectionToken( - request?: protos.google.cloud.networkconnectivity.v1.IDeleteServiceConnectionTokenRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1.IDeleteServiceConnectionTokenRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { - this._log.info('deleteServiceConnectionToken response %j', rawResponse); + this._log.info( + 'deleteServiceConnectionToken response %j', + rawResponse, + ); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteServiceConnectionToken request %j', request); - return this.innerApiCalls.deleteServiceConnectionToken(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteServiceConnectionToken response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteServiceConnectionToken(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info( + 'deleteServiceConnectionToken response %j', + rawResponse, + ); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteServiceConnectionToken()`. - * @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/cross_network_automation_service.delete_service_connection_token.js - * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_DeleteServiceConnectionToken_async - */ - async checkDeleteServiceConnectionTokenProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteServiceConnectionToken()`. + * @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/cross_network_automation_service.delete_service_connection_token.js + * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_DeleteServiceConnectionToken_async + */ + async checkDeleteServiceConnectionTokenProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('deleteServiceConnectionToken long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteServiceConnectionToken, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteServiceConnectionToken, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; } - /** - * Lists ServiceConnectionMaps in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. ex. projects/123/locations/us-east1 - * @param {number} request.pageSize - * The maximum number of results per page that should be returned. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * A filter expression that filters the results listed in the response. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap|ServiceConnectionMap}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listServiceConnectionMapsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists ServiceConnectionMaps in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. ex. projects/123/locations/us-east1 + * @param {number} request.pageSize + * The maximum number of results per page that should be returned. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * A filter expression that filters the results listed in the response. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap|ServiceConnectionMap}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listServiceConnectionMapsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listServiceConnectionMaps( - request?: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap[], - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsRequest|null, - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap[], + protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsRequest | null, + protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsResponse, + ] + >; listServiceConnectionMaps( - request: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsRequest, - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap>): void; + request: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsRequest, + | protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap + >, + ): void; listServiceConnectionMaps( - request: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsRequest, - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap>): void; + request: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsRequest, + | protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap + >, + ): void; listServiceConnectionMaps( - request?: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsRequest, - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsRequest, - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap>): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap[], - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsRequest|null, - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsRequest, + | protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap[], + protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsRequest | null, + protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsRequest, - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsRequest, + | protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listServiceConnectionMaps values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2241,201 +3381,230 @@ export class CrossNetworkAutomationServiceClient { this._log.info('listServiceConnectionMaps request %j', request); return this.innerApiCalls .listServiceConnectionMaps(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap[], - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsRequest|null, - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsResponse - ]) => { - this._log.info('listServiceConnectionMaps values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap[], + protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsRequest | null, + protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsResponse, + ]) => { + this._log.info('listServiceConnectionMaps values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listServiceConnectionMaps`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. ex. projects/123/locations/us-east1 - * @param {number} request.pageSize - * The maximum number of results per page that should be returned. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * A filter expression that filters the results listed in the response. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap|ServiceConnectionMap} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listServiceConnectionMapsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listServiceConnectionMaps`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. ex. projects/123/locations/us-east1 + * @param {number} request.pageSize + * The maximum number of results per page that should be returned. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * A filter expression that filters the results listed in the response. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap|ServiceConnectionMap} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listServiceConnectionMapsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listServiceConnectionMapsStream( - request?: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listServiceConnectionMaps']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listServiceConnectionMaps stream %j', request); return this.descriptors.page.listServiceConnectionMaps.createStream( this.innerApiCalls.listServiceConnectionMaps as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listServiceConnectionMaps`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. ex. projects/123/locations/us-east1 - * @param {number} request.pageSize - * The maximum number of results per page that should be returned. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * A filter expression that filters the results listed in the response. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap|ServiceConnectionMap}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cross_network_automation_service.list_service_connection_maps.js - * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_ListServiceConnectionMaps_async - */ + /** + * Equivalent to `listServiceConnectionMaps`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. ex. projects/123/locations/us-east1 + * @param {number} request.pageSize + * The maximum number of results per page that should be returned. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * A filter expression that filters the results listed in the response. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap|ServiceConnectionMap}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cross_network_automation_service.list_service_connection_maps.js + * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_ListServiceConnectionMaps_async + */ listServiceConnectionMapsAsync( - request?: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionMapsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listServiceConnectionMaps']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listServiceConnectionMaps iterate %j', request); return this.descriptors.page.listServiceConnectionMaps.asyncIterate( this.innerApiCalls['listServiceConnectionMaps'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists ServiceConnectionPolicies in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. ex. projects/123/locations/us-east1 - * @param {number} request.pageSize - * The maximum number of results per page that should be returned. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * A filter expression that filters the results listed in the response. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy|ServiceConnectionPolicy}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listServiceConnectionPoliciesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists ServiceConnectionPolicies in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. ex. projects/123/locations/us-east1 + * @param {number} request.pageSize + * The maximum number of results per page that should be returned. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * A filter expression that filters the results listed in the response. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy|ServiceConnectionPolicy}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listServiceConnectionPoliciesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listServiceConnectionPolicies( - request?: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy[], - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesRequest|null, - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy[], + protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesRequest | null, + protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesResponse, + ] + >; listServiceConnectionPolicies( - request: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesRequest, - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy>): void; + request: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesRequest, + | protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy + >, + ): void; listServiceConnectionPolicies( - request: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesRequest, - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy>): void; + request: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesRequest, + | protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy + >, + ): void; listServiceConnectionPolicies( - request?: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesRequest, - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesRequest, - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy>): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy[], - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesRequest|null, - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesRequest, + | protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy[], + protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesRequest | null, + protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesRequest, - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesRequest, + | protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listServiceConnectionPolicies values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2444,201 +3613,230 @@ export class CrossNetworkAutomationServiceClient { this._log.info('listServiceConnectionPolicies request %j', request); return this.innerApiCalls .listServiceConnectionPolicies(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy[], - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesRequest|null, - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesResponse - ]) => { - this._log.info('listServiceConnectionPolicies values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy[], + protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesRequest | null, + protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesResponse, + ]) => { + this._log.info('listServiceConnectionPolicies values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listServiceConnectionPolicies`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. ex. projects/123/locations/us-east1 - * @param {number} request.pageSize - * The maximum number of results per page that should be returned. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * A filter expression that filters the results listed in the response. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy|ServiceConnectionPolicy} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listServiceConnectionPoliciesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listServiceConnectionPolicies`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. ex. projects/123/locations/us-east1 + * @param {number} request.pageSize + * The maximum number of results per page that should be returned. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * A filter expression that filters the results listed in the response. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy|ServiceConnectionPolicy} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listServiceConnectionPoliciesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listServiceConnectionPoliciesStream( - request?: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listServiceConnectionPolicies']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listServiceConnectionPolicies stream %j', request); return this.descriptors.page.listServiceConnectionPolicies.createStream( this.innerApiCalls.listServiceConnectionPolicies as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listServiceConnectionPolicies`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. ex. projects/123/locations/us-east1 - * @param {number} request.pageSize - * The maximum number of results per page that should be returned. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * A filter expression that filters the results listed in the response. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy|ServiceConnectionPolicy}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cross_network_automation_service.list_service_connection_policies.js - * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_ListServiceConnectionPolicies_async - */ + /** + * Equivalent to `listServiceConnectionPolicies`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. ex. projects/123/locations/us-east1 + * @param {number} request.pageSize + * The maximum number of results per page that should be returned. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * A filter expression that filters the results listed in the response. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy|ServiceConnectionPolicy}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cross_network_automation_service.list_service_connection_policies.js + * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_ListServiceConnectionPolicies_async + */ listServiceConnectionPoliciesAsync( - request?: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionPoliciesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listServiceConnectionPolicies']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listServiceConnectionPolicies iterate %j', request); return this.descriptors.page.listServiceConnectionPolicies.asyncIterate( this.innerApiCalls['listServiceConnectionPolicies'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists ServiceClasses in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. ex. projects/123/locations/us-east1 - * @param {number} request.pageSize - * The maximum number of results per page that should be returned. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * A filter expression that filters the results listed in the response. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.ServiceClass|ServiceClass}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listServiceClassesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists ServiceClasses in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. ex. projects/123/locations/us-east1 + * @param {number} request.pageSize + * The maximum number of results per page that should be returned. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * A filter expression that filters the results listed in the response. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.ServiceClass|ServiceClass}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listServiceClassesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listServiceClasses( - request?: protos.google.cloud.networkconnectivity.v1.IListServiceClassesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IServiceClass[], - protos.google.cloud.networkconnectivity.v1.IListServiceClassesRequest|null, - protos.google.cloud.networkconnectivity.v1.IListServiceClassesResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IListServiceClassesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IServiceClass[], + protos.google.cloud.networkconnectivity.v1.IListServiceClassesRequest | null, + protos.google.cloud.networkconnectivity.v1.IListServiceClassesResponse, + ] + >; listServiceClasses( - request: protos.google.cloud.networkconnectivity.v1.IListServiceClassesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListServiceClassesRequest, - protos.google.cloud.networkconnectivity.v1.IListServiceClassesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IServiceClass>): void; + request: protos.google.cloud.networkconnectivity.v1.IListServiceClassesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListServiceClassesRequest, + | protos.google.cloud.networkconnectivity.v1.IListServiceClassesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IServiceClass + >, + ): void; listServiceClasses( - request: protos.google.cloud.networkconnectivity.v1.IListServiceClassesRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListServiceClassesRequest, - protos.google.cloud.networkconnectivity.v1.IListServiceClassesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IServiceClass>): void; + request: protos.google.cloud.networkconnectivity.v1.IListServiceClassesRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListServiceClassesRequest, + | protos.google.cloud.networkconnectivity.v1.IListServiceClassesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IServiceClass + >, + ): void; listServiceClasses( - request?: protos.google.cloud.networkconnectivity.v1.IListServiceClassesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListServiceClassesRequest, - protos.google.cloud.networkconnectivity.v1.IListServiceClassesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IServiceClass>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1.IListServiceClassesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1.IListServiceClassesRequest, - protos.google.cloud.networkconnectivity.v1.IListServiceClassesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IServiceClass>): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IServiceClass[], - protos.google.cloud.networkconnectivity.v1.IListServiceClassesRequest|null, - protos.google.cloud.networkconnectivity.v1.IListServiceClassesResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1.IListServiceClassesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IServiceClass + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListServiceClassesRequest, + | protos.google.cloud.networkconnectivity.v1.IListServiceClassesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IServiceClass + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IServiceClass[], + protos.google.cloud.networkconnectivity.v1.IListServiceClassesRequest | null, + protos.google.cloud.networkconnectivity.v1.IListServiceClassesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListServiceClassesRequest, - protos.google.cloud.networkconnectivity.v1.IListServiceClassesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IServiceClass>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListServiceClassesRequest, + | protos.google.cloud.networkconnectivity.v1.IListServiceClassesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IServiceClass + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listServiceClasses values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2647,201 +3845,230 @@ export class CrossNetworkAutomationServiceClient { this._log.info('listServiceClasses request %j', request); return this.innerApiCalls .listServiceClasses(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1.IServiceClass[], - protos.google.cloud.networkconnectivity.v1.IListServiceClassesRequest|null, - protos.google.cloud.networkconnectivity.v1.IListServiceClassesResponse - ]) => { - this._log.info('listServiceClasses values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1.IServiceClass[], + protos.google.cloud.networkconnectivity.v1.IListServiceClassesRequest | null, + protos.google.cloud.networkconnectivity.v1.IListServiceClassesResponse, + ]) => { + this._log.info('listServiceClasses values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listServiceClasses`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. ex. projects/123/locations/us-east1 - * @param {number} request.pageSize - * The maximum number of results per page that should be returned. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * A filter expression that filters the results listed in the response. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.ServiceClass|ServiceClass} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listServiceClassesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listServiceClasses`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. ex. projects/123/locations/us-east1 + * @param {number} request.pageSize + * The maximum number of results per page that should be returned. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * A filter expression that filters the results listed in the response. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.ServiceClass|ServiceClass} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listServiceClassesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listServiceClassesStream( - request?: protos.google.cloud.networkconnectivity.v1.IListServiceClassesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1.IListServiceClassesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listServiceClasses']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listServiceClasses stream %j', request); return this.descriptors.page.listServiceClasses.createStream( this.innerApiCalls.listServiceClasses as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listServiceClasses`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. ex. projects/123/locations/us-east1 - * @param {number} request.pageSize - * The maximum number of results per page that should be returned. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * A filter expression that filters the results listed in the response. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1.ServiceClass|ServiceClass}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cross_network_automation_service.list_service_classes.js - * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_ListServiceClasses_async - */ + /** + * Equivalent to `listServiceClasses`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. ex. projects/123/locations/us-east1 + * @param {number} request.pageSize + * The maximum number of results per page that should be returned. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * A filter expression that filters the results listed in the response. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1.ServiceClass|ServiceClass}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cross_network_automation_service.list_service_classes.js + * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_ListServiceClasses_async + */ listServiceClassesAsync( - request?: protos.google.cloud.networkconnectivity.v1.IListServiceClassesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1.IListServiceClassesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listServiceClasses']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listServiceClasses iterate %j', request); return this.descriptors.page.listServiceClasses.asyncIterate( this.innerApiCalls['listServiceClasses'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists ServiceConnectionTokens in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. ex. projects/123/locations/us-east1 - * @param {number} request.pageSize - * The maximum number of results per page that should be returned. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * A filter expression that filters the results listed in the response. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken|ServiceConnectionToken}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listServiceConnectionTokensAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists ServiceConnectionTokens in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. ex. projects/123/locations/us-east1 + * @param {number} request.pageSize + * The maximum number of results per page that should be returned. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * A filter expression that filters the results listed in the response. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken|ServiceConnectionToken}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listServiceConnectionTokensAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listServiceConnectionTokens( - request?: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken[], - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensRequest|null, - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken[], + protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensRequest | null, + protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensResponse, + ] + >; listServiceConnectionTokens( - request: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensRequest, - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken>): void; + request: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensRequest, + | protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken + >, + ): void; listServiceConnectionTokens( - request: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensRequest, - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken>): void; + request: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensRequest, + | protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken + >, + ): void; listServiceConnectionTokens( - request?: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensRequest, - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensRequest, - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken>): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken[], - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensRequest|null, - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensRequest, + | protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken[], + protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensRequest | null, + protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensRequest, - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensRequest, + | protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listServiceConnectionTokens values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2850,141 +4077,145 @@ export class CrossNetworkAutomationServiceClient { this._log.info('listServiceConnectionTokens request %j', request); return this.innerApiCalls .listServiceConnectionTokens(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken[], - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensRequest|null, - protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensResponse - ]) => { - this._log.info('listServiceConnectionTokens values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken[], + protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensRequest | null, + protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensResponse, + ]) => { + this._log.info('listServiceConnectionTokens values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listServiceConnectionTokens`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. ex. projects/123/locations/us-east1 - * @param {number} request.pageSize - * The maximum number of results per page that should be returned. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * A filter expression that filters the results listed in the response. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken|ServiceConnectionToken} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listServiceConnectionTokensAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listServiceConnectionTokens`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. ex. projects/123/locations/us-east1 + * @param {number} request.pageSize + * The maximum number of results per page that should be returned. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * A filter expression that filters the results listed in the response. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken|ServiceConnectionToken} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listServiceConnectionTokensAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listServiceConnectionTokensStream( - request?: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listServiceConnectionTokens']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listServiceConnectionTokens stream %j', request); return this.descriptors.page.listServiceConnectionTokens.createStream( this.innerApiCalls.listServiceConnectionTokens as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listServiceConnectionTokens`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. ex. projects/123/locations/us-east1 - * @param {number} request.pageSize - * The maximum number of results per page that should be returned. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * A filter expression that filters the results listed in the response. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken|ServiceConnectionToken}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cross_network_automation_service.list_service_connection_tokens.js - * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_ListServiceConnectionTokens_async - */ + /** + * Equivalent to `listServiceConnectionTokens`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. ex. projects/123/locations/us-east1 + * @param {number} request.pageSize + * The maximum number of results per page that should be returned. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * A filter expression that filters the results listed in the response. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken|ServiceConnectionToken}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cross_network_automation_service.list_service_connection_tokens.js + * region_tag:networkconnectivity_v1_generated_CrossNetworkAutomationService_ListServiceConnectionTokens_async + */ listServiceConnectionTokensAsync( - request?: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1.IListServiceConnectionTokensRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listServiceConnectionTokens']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listServiceConnectionTokens iterate %j', request); return this.descriptors.page.listServiceConnectionTokens.asyncIterate( this.innerApiCalls['listServiceConnectionTokens'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -2998,40 +4229,40 @@ export class CrossNetworkAutomationServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -3045,41 +4276,41 @@ export class CrossNetworkAutomationServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -3093,12 +4324,12 @@ export class CrossNetworkAutomationServiceClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -3133,12 +4364,11 @@ export class CrossNetworkAutomationServiceClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -3171,12 +4401,12 @@ export class CrossNetworkAutomationServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -3219,22 +4449,22 @@ export class CrossNetworkAutomationServiceClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -3269,15 +4499,15 @@ export class CrossNetworkAutomationServiceClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - 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 ?? '', - }); + 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 ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -3311,7 +4541,7 @@ export class CrossNetworkAutomationServiceClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -3324,25 +4554,24 @@ export class CrossNetworkAutomationServiceClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -3381,22 +4610,22 @@ export class CrossNetworkAutomationServiceClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -3413,7 +4642,12 @@ export class CrossNetworkAutomationServiceClient { * @param {string} destination * @returns {string} Resource name string. */ - destinationPath(project:string,location:string,multicloudDataTransferConfig:string,destination:string) { + destinationPath( + project: string, + location: string, + multicloudDataTransferConfig: string, + destination: string, + ) { return this.pathTemplates.destinationPathTemplate.render({ project: project, location: location, @@ -3430,7 +4664,8 @@ export class CrossNetworkAutomationServiceClient { * @returns {string} A string representing the project. */ matchProjectFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).project; + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .project; } /** @@ -3441,7 +4676,8 @@ export class CrossNetworkAutomationServiceClient { * @returns {string} A string representing the location. */ matchLocationFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).location; + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .location; } /** @@ -3451,8 +4687,11 @@ export class CrossNetworkAutomationServiceClient { * A fully-qualified path representing Destination resource. * @returns {string} A string representing the multicloud_data_transfer_config. */ - matchMulticloudDataTransferConfigFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).multicloud_data_transfer_config; + matchMulticloudDataTransferConfigFromDestinationName( + destinationName: string, + ) { + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .multicloud_data_transfer_config; } /** @@ -3463,7 +4702,8 @@ export class CrossNetworkAutomationServiceClient { * @returns {string} A string representing the destination. */ matchDestinationFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).destination; + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .destination; } /** @@ -3474,7 +4714,7 @@ export class CrossNetworkAutomationServiceClient { * @param {string} group * @returns {string} Resource name string. */ - groupPath(project:string,hub:string,group:string) { + groupPath(project: string, hub: string, group: string) { return this.pathTemplates.groupPathTemplate.render({ project: project, hub: hub, @@ -3522,7 +4762,7 @@ export class CrossNetworkAutomationServiceClient { * @param {string} hub * @returns {string} Resource name string. */ - hubPath(project:string,hub:string) { + hubPath(project: string, hub: string) { return this.pathTemplates.hubPathTemplate.render({ project: project, hub: hub, @@ -3560,7 +4800,12 @@ export class CrossNetworkAutomationServiceClient { * @param {string} route * @returns {string} Resource name string. */ - hubRoutePath(project:string,hub:string,routeTable:string,route:string) { + hubRoutePath( + project: string, + hub: string, + routeTable: string, + route: string, + ) { return this.pathTemplates.hubRoutePathTemplate.render({ project: project, hub: hub, @@ -3599,7 +4844,8 @@ export class CrossNetworkAutomationServiceClient { * @returns {string} A string representing the route_table. */ matchRouteTableFromHubRouteName(hubRouteName: string) { - return this.pathTemplates.hubRoutePathTemplate.match(hubRouteName).route_table; + return this.pathTemplates.hubRoutePathTemplate.match(hubRouteName) + .route_table; } /** @@ -3621,7 +4867,7 @@ export class CrossNetworkAutomationServiceClient { * @param {string} internal_range * @returns {string} Resource name string. */ - internalRangePath(project:string,location:string,internalRange:string) { + internalRangePath(project: string, location: string, internalRange: string) { return this.pathTemplates.internalRangePathTemplate.render({ project: project, location: location, @@ -3637,7 +4883,8 @@ export class CrossNetworkAutomationServiceClient { * @returns {string} A string representing the project. */ matchProjectFromInternalRangeName(internalRangeName: string) { - return this.pathTemplates.internalRangePathTemplate.match(internalRangeName).project; + return this.pathTemplates.internalRangePathTemplate.match(internalRangeName) + .project; } /** @@ -3648,7 +4895,8 @@ export class CrossNetworkAutomationServiceClient { * @returns {string} A string representing the location. */ matchLocationFromInternalRangeName(internalRangeName: string) { - return this.pathTemplates.internalRangePathTemplate.match(internalRangeName).location; + return this.pathTemplates.internalRangePathTemplate.match(internalRangeName) + .location; } /** @@ -3659,7 +4907,8 @@ export class CrossNetworkAutomationServiceClient { * @returns {string} A string representing the internal_range. */ matchInternalRangeFromInternalRangeName(internalRangeName: string) { - return this.pathTemplates.internalRangePathTemplate.match(internalRangeName).internal_range; + return this.pathTemplates.internalRangePathTemplate.match(internalRangeName) + .internal_range; } /** @@ -3669,7 +4918,7 @@ export class CrossNetworkAutomationServiceClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -3706,7 +4955,11 @@ export class CrossNetworkAutomationServiceClient { * @param {string} multicloud_data_transfer_config * @returns {string} Resource name string. */ - multicloudDataTransferConfigPath(project:string,location:string,multicloudDataTransferConfig:string) { + multicloudDataTransferConfigPath( + project: string, + location: string, + multicloudDataTransferConfig: string, + ) { return this.pathTemplates.multicloudDataTransferConfigPathTemplate.render({ project: project, location: location, @@ -3721,8 +4974,12 @@ export class CrossNetworkAutomationServiceClient { * A fully-qualified path representing MulticloudDataTransferConfig resource. * @returns {string} A string representing the project. */ - matchProjectFromMulticloudDataTransferConfigName(multicloudDataTransferConfigName: string) { - return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match(multicloudDataTransferConfigName).project; + matchProjectFromMulticloudDataTransferConfigName( + multicloudDataTransferConfigName: string, + ) { + return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match( + multicloudDataTransferConfigName, + ).project; } /** @@ -3732,8 +4989,12 @@ export class CrossNetworkAutomationServiceClient { * A fully-qualified path representing MulticloudDataTransferConfig resource. * @returns {string} A string representing the location. */ - matchLocationFromMulticloudDataTransferConfigName(multicloudDataTransferConfigName: string) { - return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match(multicloudDataTransferConfigName).location; + matchLocationFromMulticloudDataTransferConfigName( + multicloudDataTransferConfigName: string, + ) { + return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match( + multicloudDataTransferConfigName, + ).location; } /** @@ -3743,8 +5004,12 @@ export class CrossNetworkAutomationServiceClient { * A fully-qualified path representing MulticloudDataTransferConfig resource. * @returns {string} A string representing the multicloud_data_transfer_config. */ - matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName(multicloudDataTransferConfigName: string) { - return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match(multicloudDataTransferConfigName).multicloud_data_transfer_config; + matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName( + multicloudDataTransferConfigName: string, + ) { + return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match( + multicloudDataTransferConfigName, + ).multicloud_data_transfer_config; } /** @@ -3755,12 +5020,19 @@ export class CrossNetworkAutomationServiceClient { * @param {string} multicloud_data_transfer_supported_service * @returns {string} Resource name string. */ - multicloudDataTransferSupportedServicePath(project:string,location:string,multicloudDataTransferSupportedService:string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render({ - project: project, - location: location, - multicloud_data_transfer_supported_service: multicloudDataTransferSupportedService, - }); + multicloudDataTransferSupportedServicePath( + project: string, + location: string, + multicloudDataTransferSupportedService: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render( + { + project: project, + location: location, + multicloud_data_transfer_supported_service: + multicloudDataTransferSupportedService, + }, + ); } /** @@ -3770,8 +5042,12 @@ export class CrossNetworkAutomationServiceClient { * A fully-qualified path representing MulticloudDataTransferSupportedService resource. * @returns {string} A string representing the project. */ - matchProjectFromMulticloudDataTransferSupportedServiceName(multicloudDataTransferSupportedServiceName: string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match(multicloudDataTransferSupportedServiceName).project; + matchProjectFromMulticloudDataTransferSupportedServiceName( + multicloudDataTransferSupportedServiceName: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match( + multicloudDataTransferSupportedServiceName, + ).project; } /** @@ -3781,8 +5057,12 @@ export class CrossNetworkAutomationServiceClient { * A fully-qualified path representing MulticloudDataTransferSupportedService resource. * @returns {string} A string representing the location. */ - matchLocationFromMulticloudDataTransferSupportedServiceName(multicloudDataTransferSupportedServiceName: string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match(multicloudDataTransferSupportedServiceName).location; + matchLocationFromMulticloudDataTransferSupportedServiceName( + multicloudDataTransferSupportedServiceName: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match( + multicloudDataTransferSupportedServiceName, + ).location; } /** @@ -3792,8 +5072,12 @@ export class CrossNetworkAutomationServiceClient { * A fully-qualified path representing MulticloudDataTransferSupportedService resource. * @returns {string} A string representing the multicloud_data_transfer_supported_service. */ - matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName(multicloudDataTransferSupportedServiceName: string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match(multicloudDataTransferSupportedServiceName).multicloud_data_transfer_supported_service; + matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName( + multicloudDataTransferSupportedServiceName: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match( + multicloudDataTransferSupportedServiceName, + ).multicloud_data_transfer_supported_service; } /** @@ -3803,7 +5087,7 @@ export class CrossNetworkAutomationServiceClient { * @param {string} resource_id * @returns {string} Resource name string. */ - networkPath(project:string,resourceId:string) { + networkPath(project: string, resourceId: string) { return this.pathTemplates.networkPathTemplate.render({ project: project, resource_id: resourceId, @@ -3829,7 +5113,8 @@ export class CrossNetworkAutomationServiceClient { * @returns {string} A string representing the resource_id. */ matchResourceIdFromNetworkName(networkName: string) { - return this.pathTemplates.networkPathTemplate.match(networkName).resource_id; + return this.pathTemplates.networkPathTemplate.match(networkName) + .resource_id; } /** @@ -3839,7 +5124,7 @@ export class CrossNetworkAutomationServiceClient { * @param {string} policy_based_route * @returns {string} Resource name string. */ - policyBasedRoutePath(project:string,policyBasedRoute:string) { + policyBasedRoutePath(project: string, policyBasedRoute: string) { return this.pathTemplates.policyBasedRoutePathTemplate.render({ project: project, policy_based_route: policyBasedRoute, @@ -3854,7 +5139,9 @@ export class CrossNetworkAutomationServiceClient { * @returns {string} A string representing the project. */ matchProjectFromPolicyBasedRouteName(policyBasedRouteName: string) { - return this.pathTemplates.policyBasedRoutePathTemplate.match(policyBasedRouteName).project; + return this.pathTemplates.policyBasedRoutePathTemplate.match( + policyBasedRouteName, + ).project; } /** @@ -3865,7 +5152,9 @@ export class CrossNetworkAutomationServiceClient { * @returns {string} A string representing the policy_based_route. */ matchPolicyBasedRouteFromPolicyBasedRouteName(policyBasedRouteName: string) { - return this.pathTemplates.policyBasedRoutePathTemplate.match(policyBasedRouteName).policy_based_route; + return this.pathTemplates.policyBasedRoutePathTemplate.match( + policyBasedRouteName, + ).policy_based_route; } /** @@ -3874,7 +5163,7 @@ export class CrossNetworkAutomationServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -3899,7 +5188,7 @@ export class CrossNetworkAutomationServiceClient { * @param {string} route_table * @returns {string} Resource name string. */ - routeTablePath(project:string,hub:string,routeTable:string) { + routeTablePath(project: string, hub: string, routeTable: string) { return this.pathTemplates.routeTablePathTemplate.render({ project: project, hub: hub, @@ -3915,7 +5204,8 @@ export class CrossNetworkAutomationServiceClient { * @returns {string} A string representing the project. */ matchProjectFromRouteTableName(routeTableName: string) { - return this.pathTemplates.routeTablePathTemplate.match(routeTableName).project; + return this.pathTemplates.routeTablePathTemplate.match(routeTableName) + .project; } /** @@ -3937,7 +5227,8 @@ export class CrossNetworkAutomationServiceClient { * @returns {string} A string representing the route_table. */ matchRouteTableFromRouteTableName(routeTableName: string) { - return this.pathTemplates.routeTablePathTemplate.match(routeTableName).route_table; + return this.pathTemplates.routeTablePathTemplate.match(routeTableName) + .route_table; } /** @@ -3948,7 +5239,7 @@ export class CrossNetworkAutomationServiceClient { * @param {string} service_class * @returns {string} Resource name string. */ - serviceClassPath(project:string,location:string,serviceClass:string) { + serviceClassPath(project: string, location: string, serviceClass: string) { return this.pathTemplates.serviceClassPathTemplate.render({ project: project, location: location, @@ -3964,7 +5255,8 @@ export class CrossNetworkAutomationServiceClient { * @returns {string} A string representing the project. */ matchProjectFromServiceClassName(serviceClassName: string) { - return this.pathTemplates.serviceClassPathTemplate.match(serviceClassName).project; + return this.pathTemplates.serviceClassPathTemplate.match(serviceClassName) + .project; } /** @@ -3975,7 +5267,8 @@ export class CrossNetworkAutomationServiceClient { * @returns {string} A string representing the location. */ matchLocationFromServiceClassName(serviceClassName: string) { - return this.pathTemplates.serviceClassPathTemplate.match(serviceClassName).location; + return this.pathTemplates.serviceClassPathTemplate.match(serviceClassName) + .location; } /** @@ -3986,7 +5279,8 @@ export class CrossNetworkAutomationServiceClient { * @returns {string} A string representing the service_class. */ matchServiceClassFromServiceClassName(serviceClassName: string) { - return this.pathTemplates.serviceClassPathTemplate.match(serviceClassName).service_class; + return this.pathTemplates.serviceClassPathTemplate.match(serviceClassName) + .service_class; } /** @@ -3997,7 +5291,11 @@ export class CrossNetworkAutomationServiceClient { * @param {string} service_connection_map * @returns {string} Resource name string. */ - serviceConnectionMapPath(project:string,location:string,serviceConnectionMap:string) { + serviceConnectionMapPath( + project: string, + location: string, + serviceConnectionMap: string, + ) { return this.pathTemplates.serviceConnectionMapPathTemplate.render({ project: project, location: location, @@ -4013,7 +5311,9 @@ export class CrossNetworkAutomationServiceClient { * @returns {string} A string representing the project. */ matchProjectFromServiceConnectionMapName(serviceConnectionMapName: string) { - return this.pathTemplates.serviceConnectionMapPathTemplate.match(serviceConnectionMapName).project; + return this.pathTemplates.serviceConnectionMapPathTemplate.match( + serviceConnectionMapName, + ).project; } /** @@ -4024,7 +5324,9 @@ export class CrossNetworkAutomationServiceClient { * @returns {string} A string representing the location. */ matchLocationFromServiceConnectionMapName(serviceConnectionMapName: string) { - return this.pathTemplates.serviceConnectionMapPathTemplate.match(serviceConnectionMapName).location; + return this.pathTemplates.serviceConnectionMapPathTemplate.match( + serviceConnectionMapName, + ).location; } /** @@ -4034,8 +5336,12 @@ export class CrossNetworkAutomationServiceClient { * A fully-qualified path representing ServiceConnectionMap resource. * @returns {string} A string representing the service_connection_map. */ - matchServiceConnectionMapFromServiceConnectionMapName(serviceConnectionMapName: string) { - return this.pathTemplates.serviceConnectionMapPathTemplate.match(serviceConnectionMapName).service_connection_map; + matchServiceConnectionMapFromServiceConnectionMapName( + serviceConnectionMapName: string, + ) { + return this.pathTemplates.serviceConnectionMapPathTemplate.match( + serviceConnectionMapName, + ).service_connection_map; } /** @@ -4046,7 +5352,11 @@ export class CrossNetworkAutomationServiceClient { * @param {string} service_connection_policy * @returns {string} Resource name string. */ - serviceConnectionPolicyPath(project:string,location:string,serviceConnectionPolicy:string) { + serviceConnectionPolicyPath( + project: string, + location: string, + serviceConnectionPolicy: string, + ) { return this.pathTemplates.serviceConnectionPolicyPathTemplate.render({ project: project, location: location, @@ -4061,8 +5371,12 @@ export class CrossNetworkAutomationServiceClient { * A fully-qualified path representing ServiceConnectionPolicy resource. * @returns {string} A string representing the project. */ - matchProjectFromServiceConnectionPolicyName(serviceConnectionPolicyName: string) { - return this.pathTemplates.serviceConnectionPolicyPathTemplate.match(serviceConnectionPolicyName).project; + matchProjectFromServiceConnectionPolicyName( + serviceConnectionPolicyName: string, + ) { + return this.pathTemplates.serviceConnectionPolicyPathTemplate.match( + serviceConnectionPolicyName, + ).project; } /** @@ -4072,8 +5386,12 @@ export class CrossNetworkAutomationServiceClient { * A fully-qualified path representing ServiceConnectionPolicy resource. * @returns {string} A string representing the location. */ - matchLocationFromServiceConnectionPolicyName(serviceConnectionPolicyName: string) { - return this.pathTemplates.serviceConnectionPolicyPathTemplate.match(serviceConnectionPolicyName).location; + matchLocationFromServiceConnectionPolicyName( + serviceConnectionPolicyName: string, + ) { + return this.pathTemplates.serviceConnectionPolicyPathTemplate.match( + serviceConnectionPolicyName, + ).location; } /** @@ -4083,8 +5401,12 @@ export class CrossNetworkAutomationServiceClient { * A fully-qualified path representing ServiceConnectionPolicy resource. * @returns {string} A string representing the service_connection_policy. */ - matchServiceConnectionPolicyFromServiceConnectionPolicyName(serviceConnectionPolicyName: string) { - return this.pathTemplates.serviceConnectionPolicyPathTemplate.match(serviceConnectionPolicyName).service_connection_policy; + matchServiceConnectionPolicyFromServiceConnectionPolicyName( + serviceConnectionPolicyName: string, + ) { + return this.pathTemplates.serviceConnectionPolicyPathTemplate.match( + serviceConnectionPolicyName, + ).service_connection_policy; } /** @@ -4095,7 +5417,11 @@ export class CrossNetworkAutomationServiceClient { * @param {string} service_connection_token * @returns {string} Resource name string. */ - serviceConnectionTokenPath(project:string,location:string,serviceConnectionToken:string) { + serviceConnectionTokenPath( + project: string, + location: string, + serviceConnectionToken: string, + ) { return this.pathTemplates.serviceConnectionTokenPathTemplate.render({ project: project, location: location, @@ -4110,8 +5436,12 @@ export class CrossNetworkAutomationServiceClient { * A fully-qualified path representing ServiceConnectionToken resource. * @returns {string} A string representing the project. */ - matchProjectFromServiceConnectionTokenName(serviceConnectionTokenName: string) { - return this.pathTemplates.serviceConnectionTokenPathTemplate.match(serviceConnectionTokenName).project; + matchProjectFromServiceConnectionTokenName( + serviceConnectionTokenName: string, + ) { + return this.pathTemplates.serviceConnectionTokenPathTemplate.match( + serviceConnectionTokenName, + ).project; } /** @@ -4121,8 +5451,12 @@ export class CrossNetworkAutomationServiceClient { * A fully-qualified path representing ServiceConnectionToken resource. * @returns {string} A string representing the location. */ - matchLocationFromServiceConnectionTokenName(serviceConnectionTokenName: string) { - return this.pathTemplates.serviceConnectionTokenPathTemplate.match(serviceConnectionTokenName).location; + matchLocationFromServiceConnectionTokenName( + serviceConnectionTokenName: string, + ) { + return this.pathTemplates.serviceConnectionTokenPathTemplate.match( + serviceConnectionTokenName, + ).location; } /** @@ -4132,8 +5466,12 @@ export class CrossNetworkAutomationServiceClient { * A fully-qualified path representing ServiceConnectionToken resource. * @returns {string} A string representing the service_connection_token. */ - matchServiceConnectionTokenFromServiceConnectionTokenName(serviceConnectionTokenName: string) { - return this.pathTemplates.serviceConnectionTokenPathTemplate.match(serviceConnectionTokenName).service_connection_token; + matchServiceConnectionTokenFromServiceConnectionTokenName( + serviceConnectionTokenName: string, + ) { + return this.pathTemplates.serviceConnectionTokenPathTemplate.match( + serviceConnectionTokenName, + ).service_connection_token; } /** @@ -4144,7 +5482,7 @@ export class CrossNetworkAutomationServiceClient { * @param {string} spoke * @returns {string} Resource name string. */ - spokePath(project:string,location:string,spoke:string) { + spokePath(project: string, location: string, spoke: string) { return this.pathTemplates.spokePathTemplate.render({ project: project, location: location, @@ -4193,15 +5531,19 @@ export class CrossNetworkAutomationServiceClient { */ close(): Promise { if (this.crossNetworkAutomationServiceStub && !this._terminated) { - return this.crossNetworkAutomationServiceStub.then(stub => { + return this.crossNetworkAutomationServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-networkconnectivity/src/v1/data_transfer_service_client.ts b/packages/google-cloud-networkconnectivity/src/v1/data_transfer_service_client.ts index 2dcaa0c53e48..81864c97856a 100644 --- a/packages/google-cloud-networkconnectivity/src/v1/data_transfer_service_client.ts +++ b/packages/google-cloud-networkconnectivity/src/v1/data_transfer_service_client.ts @@ -18,11 +18,24 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -44,7 +57,7 @@ export class DataTransferServiceClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('network-connectivity'); @@ -57,12 +70,12 @@ export class DataTransferServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - dataTransferServiceStub?: Promise<{[name: string]: Function}>; + dataTransferServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of DataTransferServiceClient. @@ -103,21 +116,42 @@ export class DataTransferServiceClient { * const client = new DataTransferServiceClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof DataTransferServiceClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'networkconnectivity.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -142,7 +176,7 @@ export class DataTransferServiceClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -155,18 +189,14 @@ export class DataTransferServiceClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -188,49 +218,51 @@ export class DataTransferServiceClient { // Create useful helper objects for these. this.pathTemplates = { destinationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}/destinations/{destination}' + 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}/destinations/{destination}', ), groupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}/groups/{group}' + 'projects/{project}/locations/global/hubs/{hub}/groups/{group}', ), hubPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}' + 'projects/{project}/locations/global/hubs/{hub}', ), hubRoutePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}/routes/{route}' + 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}/routes/{route}', ), internalRangePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/internalRanges/{internal_range}' + 'projects/{project}/locations/{location}/internalRanges/{internal_range}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - multicloudDataTransferConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}' - ), - multicloudDataTransferSupportedServicePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/multicloudDataTransferSupportedServices/{multicloud_data_transfer_supported_service}' + 'projects/{project}/locations/{location}', ), + multicloudDataTransferConfigPathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}', + ), + multicloudDataTransferSupportedServicePathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/multicloudDataTransferSupportedServices/{multicloud_data_transfer_supported_service}', + ), policyBasedRoutePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/PolicyBasedRoutes/{policy_based_route}' + 'projects/{project}/locations/global/PolicyBasedRoutes/{policy_based_route}', ), routeTablePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}' + 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}', ), serviceClassPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/serviceClasses/{service_class}' + 'projects/{project}/locations/{location}/serviceClasses/{service_class}', ), serviceConnectionMapPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/serviceConnectionMaps/{service_connection_map}' + 'projects/{project}/locations/{location}/serviceConnectionMaps/{service_connection_map}', ), serviceConnectionPolicyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/serviceConnectionPolicies/{service_connection_policy}' + 'projects/{project}/locations/{location}/serviceConnectionPolicies/{service_connection_policy}', ), serviceConnectionTokenPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/serviceConnectionTokens/{service_connection_token}' + 'projects/{project}/locations/{location}/serviceConnectionTokens/{service_connection_token}', ), spokePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/spokes/{spoke}' + 'projects/{project}/locations/{location}/spokes/{spoke}', ), }; @@ -238,12 +270,22 @@ export class DataTransferServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listMulticloudDataTransferConfigs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'multicloudDataTransferConfigs'), - listDestinations: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'destinations'), + listMulticloudDataTransferConfigs: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'multicloudDataTransferConfigs', + ), + listDestinations: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'destinations', + ), listMulticloudDataTransferSupportedServices: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'multicloudDataTransferSupportedServices') + new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'multicloudDataTransferSupportedServices', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -252,72 +294,230 @@ export class DataTransferServiceClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1/{resource=projects/*/locations/global/hubs/*}:getIamPolicy',additional_bindings: [{get: '/v1/{resource=projects/*/locations/global/hubs/*/groups/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/spokes/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/global/policyBasedRoutes/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/serviceConnectionMaps/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/serviceConnectionPolicies/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/serviceClasses/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/internalRanges/*}:getIamPolicy',}], - },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1/{resource=projects/*/locations/global/hubs/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/global/hubs/*/groups/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/spokes/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/global/policyBasedRoutes/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceConnectionMaps/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceConnectionPolicies/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceClasses/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/internalRanges/*}:setIamPolicy',body: '*',}], - },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1/{resource=projects/*/locations/global/hubs/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/global/hubs/*/groups/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/spokes/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/global/policyBasedRoutes/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceConnectionMaps/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceConnectionPolicies/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceClasses/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/internalRanges/*}:testIamPermissions',body: '*',}], - },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1/{resource=projects/*/locations/global/hubs/*}:getIamPolicy', + additional_bindings: [ + { + get: '/v1/{resource=projects/*/locations/global/hubs/*/groups/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/spokes/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/global/policyBasedRoutes/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/serviceConnectionMaps/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/serviceConnectionPolicies/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/serviceClasses/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/internalRanges/*}:getIamPolicy', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1/{resource=projects/*/locations/global/hubs/*}:setIamPolicy', + body: '*', + additional_bindings: [ + { + post: '/v1/{resource=projects/*/locations/global/hubs/*/groups/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/spokes/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/global/policyBasedRoutes/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceConnectionMaps/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceConnectionPolicies/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceClasses/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/internalRanges/*}:setIamPolicy', + body: '*', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1/{resource=projects/*/locations/global/hubs/*}:testIamPermissions', + body: '*', + additional_bindings: [ + { + post: '/v1/{resource=projects/*/locations/global/hubs/*/groups/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/spokes/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/global/policyBasedRoutes/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceConnectionMaps/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceConnectionPolicies/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceClasses/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/internalRanges/*}:testIamPermissions', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createMulticloudDataTransferConfigResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig', + ) as gax.protobuf.Type; const createMulticloudDataTransferConfigMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateMulticloudDataTransferConfigResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig', + ) as gax.protobuf.Type; const updateMulticloudDataTransferConfigMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteMulticloudDataTransferConfigResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteMulticloudDataTransferConfigMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; const createDestinationResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.Destination') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.Destination', + ) as gax.protobuf.Type; const createDestinationMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateDestinationResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.Destination') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.Destination', + ) as gax.protobuf.Type; const updateDestinationMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteDestinationResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteDestinationMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { - createMulticloudDataTransferConfig: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createMulticloudDataTransferConfigResponse.decode.bind(createMulticloudDataTransferConfigResponse), - createMulticloudDataTransferConfigMetadata.decode.bind(createMulticloudDataTransferConfigMetadata)), - updateMulticloudDataTransferConfig: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateMulticloudDataTransferConfigResponse.decode.bind(updateMulticloudDataTransferConfigResponse), - updateMulticloudDataTransferConfigMetadata.decode.bind(updateMulticloudDataTransferConfigMetadata)), - deleteMulticloudDataTransferConfig: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteMulticloudDataTransferConfigResponse.decode.bind(deleteMulticloudDataTransferConfigResponse), - deleteMulticloudDataTransferConfigMetadata.decode.bind(deleteMulticloudDataTransferConfigMetadata)), + createMulticloudDataTransferConfig: + new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createMulticloudDataTransferConfigResponse.decode.bind( + createMulticloudDataTransferConfigResponse, + ), + createMulticloudDataTransferConfigMetadata.decode.bind( + createMulticloudDataTransferConfigMetadata, + ), + ), + updateMulticloudDataTransferConfig: + new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateMulticloudDataTransferConfigResponse.decode.bind( + updateMulticloudDataTransferConfigResponse, + ), + updateMulticloudDataTransferConfigMetadata.decode.bind( + updateMulticloudDataTransferConfigMetadata, + ), + ), + deleteMulticloudDataTransferConfig: + new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteMulticloudDataTransferConfigResponse.decode.bind( + deleteMulticloudDataTransferConfigResponse, + ), + deleteMulticloudDataTransferConfigMetadata.decode.bind( + deleteMulticloudDataTransferConfigMetadata, + ), + ), createDestination: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createDestinationResponse.decode.bind(createDestinationResponse), - createDestinationMetadata.decode.bind(createDestinationMetadata)), + createDestinationMetadata.decode.bind(createDestinationMetadata), + ), updateDestination: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateDestinationResponse.decode.bind(updateDestinationResponse), - updateDestinationMetadata.decode.bind(updateDestinationMetadata)), + updateDestinationMetadata.decode.bind(updateDestinationMetadata), + ), deleteDestination: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteDestinationResponse.decode.bind(deleteDestinationResponse), - deleteDestinationMetadata.decode.bind(deleteDestinationMetadata)) + deleteDestinationMetadata.decode.bind(deleteDestinationMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.networkconnectivity.v1.DataTransferService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.networkconnectivity.v1.DataTransferService', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -348,28 +548,47 @@ export class DataTransferServiceClient { // Put together the "service stub" for // google.cloud.networkconnectivity.v1.DataTransferService. this.dataTransferServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.networkconnectivity.v1.DataTransferService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.networkconnectivity.v1.DataTransferService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.networkconnectivity.v1.DataTransferService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.networkconnectivity.v1 + .DataTransferService, + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const dataTransferServiceStubMethods = - ['listMulticloudDataTransferConfigs', 'getMulticloudDataTransferConfig', 'createMulticloudDataTransferConfig', 'updateMulticloudDataTransferConfig', 'deleteMulticloudDataTransferConfig', 'listDestinations', 'getDestination', 'createDestination', 'updateDestination', 'deleteDestination', 'getMulticloudDataTransferSupportedService', 'listMulticloudDataTransferSupportedServices']; + const dataTransferServiceStubMethods = [ + 'listMulticloudDataTransferConfigs', + 'getMulticloudDataTransferConfig', + 'createMulticloudDataTransferConfig', + 'updateMulticloudDataTransferConfig', + 'deleteMulticloudDataTransferConfig', + 'listDestinations', + 'getDestination', + 'createDestination', + 'updateDestination', + 'deleteDestination', + 'getMulticloudDataTransferSupportedService', + 'listMulticloudDataTransferSupportedServices', + ]; for (const methodName of dataTransferServiceStubMethods) { const callPromise = this.dataTransferServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -379,7 +598,7 @@ export class DataTransferServiceClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -394,8 +613,14 @@ export class DataTransferServiceClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkconnectivity.googleapis.com'; } @@ -406,8 +631,14 @@ export class DataTransferServiceClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkconnectivity.googleapis.com'; } @@ -438,9 +669,7 @@ export class DataTransferServiceClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -449,8 +678,9 @@ export class DataTransferServiceClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -461,1141 +691,1723 @@ export class DataTransferServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets the details of a `MulticloudDataTransferConfig` resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the `MulticloudDataTransferConfig` resource to get. - * @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 {@link protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig|MulticloudDataTransferConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/data_transfer_service.get_multicloud_data_transfer_config.js - * region_tag:networkconnectivity_v1_generated_DataTransferService_GetMulticloudDataTransferConfig_async - */ + /** + * Gets the details of a `MulticloudDataTransferConfig` resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the `MulticloudDataTransferConfig` resource to get. + * @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 {@link protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig|MulticloudDataTransferConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/data_transfer_service.get_multicloud_data_transfer_config.js + * region_tag:networkconnectivity_v1_generated_DataTransferService_GetMulticloudDataTransferConfig_async + */ getMulticloudDataTransferConfig( - request?: protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, - protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferConfigRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferConfigRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, + ( + | protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferConfigRequest + | undefined + ), + {} | undefined, + ] + >; getMulticloudDataTransferConfig( - request: protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, - protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, + | protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getMulticloudDataTransferConfig( - request: protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferConfigRequest, - callback: Callback< - protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, - protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferConfigRequest, + callback: Callback< + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, + | protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getMulticloudDataTransferConfig( - request?: protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, - protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, - protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, - protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferConfigRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, + | protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, + ( + | protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferConfigRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getMulticloudDataTransferConfig request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, - protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferConfigRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, + | protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferConfigRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { - this._log.info('getMulticloudDataTransferConfig response %j', response); + this._log.info( + 'getMulticloudDataTransferConfig response %j', + response, + ); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getMulticloudDataTransferConfig(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, - protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferConfigRequest|undefined, - {}|undefined - ]) => { - this._log.info('getMulticloudDataTransferConfig response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getMulticloudDataTransferConfig(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, + ( + | protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferConfigRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info( + 'getMulticloudDataTransferConfig response %j', + response, + ); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets the details of a `Destination` resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the `Destination` resource to get. - * @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 {@link protos.google.cloud.networkconnectivity.v1.Destination|Destination}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/data_transfer_service.get_destination.js - * region_tag:networkconnectivity_v1_generated_DataTransferService_GetDestination_async - */ + /** + * Gets the details of a `Destination` resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the `Destination` resource to get. + * @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 {@link protos.google.cloud.networkconnectivity.v1.Destination|Destination}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/data_transfer_service.get_destination.js + * region_tag:networkconnectivity_v1_generated_DataTransferService_GetDestination_async + */ getDestination( - request?: protos.google.cloud.networkconnectivity.v1.IGetDestinationRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IDestination, - protos.google.cloud.networkconnectivity.v1.IGetDestinationRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IGetDestinationRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IDestination, + ( + | protos.google.cloud.networkconnectivity.v1.IGetDestinationRequest + | undefined + ), + {} | undefined, + ] + >; getDestination( - request: protos.google.cloud.networkconnectivity.v1.IGetDestinationRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkconnectivity.v1.IDestination, - protos.google.cloud.networkconnectivity.v1.IGetDestinationRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IGetDestinationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkconnectivity.v1.IDestination, + | protos.google.cloud.networkconnectivity.v1.IGetDestinationRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getDestination( - request: protos.google.cloud.networkconnectivity.v1.IGetDestinationRequest, - callback: Callback< - protos.google.cloud.networkconnectivity.v1.IDestination, - protos.google.cloud.networkconnectivity.v1.IGetDestinationRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IGetDestinationRequest, + callback: Callback< + protos.google.cloud.networkconnectivity.v1.IDestination, + | protos.google.cloud.networkconnectivity.v1.IGetDestinationRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getDestination( - request?: protos.google.cloud.networkconnectivity.v1.IGetDestinationRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkconnectivity.v1.IDestination, - protos.google.cloud.networkconnectivity.v1.IGetDestinationRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkconnectivity.v1.IGetDestinationRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkconnectivity.v1.IDestination, - protos.google.cloud.networkconnectivity.v1.IGetDestinationRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IDestination, - protos.google.cloud.networkconnectivity.v1.IGetDestinationRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkconnectivity.v1.IGetDestinationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkconnectivity.v1.IDestination, + | protos.google.cloud.networkconnectivity.v1.IGetDestinationRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IDestination, + ( + | protos.google.cloud.networkconnectivity.v1.IGetDestinationRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getDestination request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkconnectivity.v1.IDestination, - protos.google.cloud.networkconnectivity.v1.IGetDestinationRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkconnectivity.v1.IDestination, + | protos.google.cloud.networkconnectivity.v1.IGetDestinationRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getDestination response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getDestination(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkconnectivity.v1.IDestination, - protos.google.cloud.networkconnectivity.v1.IGetDestinationRequest|undefined, - {}|undefined - ]) => { - this._log.info('getDestination response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getDestination(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkconnectivity.v1.IDestination, + ( + | protos.google.cloud.networkconnectivity.v1.IGetDestinationRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getDestination response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets the details of a service that is supported for Data Transfer - * Essentials. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the service. - * @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 {@link protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService|MulticloudDataTransferSupportedService}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/data_transfer_service.get_multicloud_data_transfer_supported_service.js - * region_tag:networkconnectivity_v1_generated_DataTransferService_GetMulticloudDataTransferSupportedService_async - */ + /** + * Gets the details of a service that is supported for Data Transfer + * Essentials. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the service. + * @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 {@link protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService|MulticloudDataTransferSupportedService}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/data_transfer_service.get_multicloud_data_transfer_supported_service.js + * region_tag:networkconnectivity_v1_generated_DataTransferService_GetMulticloudDataTransferSupportedService_async + */ getMulticloudDataTransferSupportedService( - request?: protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferSupportedServiceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService, - protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferSupportedServiceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferSupportedServiceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService, + ( + | protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferSupportedServiceRequest + | undefined + ), + {} | undefined, + ] + >; getMulticloudDataTransferSupportedService( - request: protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferSupportedServiceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService, - protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferSupportedServiceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferSupportedServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService, + | protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferSupportedServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getMulticloudDataTransferSupportedService( - request: protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferSupportedServiceRequest, - callback: Callback< - protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService, - protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferSupportedServiceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferSupportedServiceRequest, + callback: Callback< + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService, + | protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferSupportedServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getMulticloudDataTransferSupportedService( - request?: protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferSupportedServiceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService, - protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferSupportedServiceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferSupportedServiceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService, - protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferSupportedServiceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService, - protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferSupportedServiceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferSupportedServiceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService, + | protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferSupportedServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService, + ( + | protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferSupportedServiceRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - this._log.info('getMulticloudDataTransferSupportedService request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService, - protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferSupportedServiceRequest|null|undefined, - {}|null|undefined>|undefined = callback + this._log.info( + 'getMulticloudDataTransferSupportedService request %j', + request, + ); + const wrappedCallback: + | Callback< + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService, + | protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferSupportedServiceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { - this._log.info('getMulticloudDataTransferSupportedService response %j', response); + this._log.info( + 'getMulticloudDataTransferSupportedService response %j', + response, + ); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getMulticloudDataTransferSupportedService(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService, - protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferSupportedServiceRequest|undefined, - {}|undefined - ]) => { - this._log.info('getMulticloudDataTransferSupportedService response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getMulticloudDataTransferSupportedService( + request, + options, + wrappedCallback, + ) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService, + ( + | protos.google.cloud.networkconnectivity.v1.IGetMulticloudDataTransferSupportedServiceRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info( + 'getMulticloudDataTransferSupportedService response %j', + response, + ); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a `MulticloudDataTransferConfig` resource in a specified project - * and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent resource. - * @param {string} request.multicloudDataTransferConfigId - * Required. The ID to use for the `MulticloudDataTransferConfig` resource, - * which becomes the final component of the `MulticloudDataTransferConfig` - * resource name. - * @param {google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig} request.multicloudDataTransferConfig - * Required. The `MulticloudDataTransferConfig` resource to create. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server can ignore - * the request if it has already been completed. The server waits - * for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, can ignore the second request. This prevents - * clients from accidentally creating duplicate `MulticloudDataTransferConfig` - * resources. - * - * The request ID must be a valid UUID with the exception that zero UUID - * (00000000-0000-0000-0000-000000000000) isn't supported. - * @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/data_transfer_service.create_multicloud_data_transfer_config.js - * region_tag:networkconnectivity_v1_generated_DataTransferService_CreateMulticloudDataTransferConfig_async - */ + /** + * Creates a `MulticloudDataTransferConfig` resource in a specified project + * and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent resource. + * @param {string} request.multicloudDataTransferConfigId + * Required. The ID to use for the `MulticloudDataTransferConfig` resource, + * which becomes the final component of the `MulticloudDataTransferConfig` + * resource name. + * @param {google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig} request.multicloudDataTransferConfig + * Required. The `MulticloudDataTransferConfig` resource to create. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server can ignore + * the request if it has already been completed. The server waits + * for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, can ignore the second request. This prevents + * clients from accidentally creating duplicate `MulticloudDataTransferConfig` + * resources. + * + * The request ID must be a valid UUID with the exception that zero UUID + * (00000000-0000-0000-0000-000000000000) isn't supported. + * @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/data_transfer_service.create_multicloud_data_transfer_config.js + * region_tag:networkconnectivity_v1_generated_DataTransferService_CreateMulticloudDataTransferConfig_async + */ createMulticloudDataTransferConfig( - request?: protos.google.cloud.networkconnectivity.v1.ICreateMulticloudDataTransferConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.ICreateMulticloudDataTransferConfigRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createMulticloudDataTransferConfig( - request: protos.google.cloud.networkconnectivity.v1.ICreateMulticloudDataTransferConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.ICreateMulticloudDataTransferConfigRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createMulticloudDataTransferConfig( - request: protos.google.cloud.networkconnectivity.v1.ICreateMulticloudDataTransferConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.ICreateMulticloudDataTransferConfigRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createMulticloudDataTransferConfig( - request?: protos.google.cloud.networkconnectivity.v1.ICreateMulticloudDataTransferConfigRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1.ICreateMulticloudDataTransferConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { - this._log.info('createMulticloudDataTransferConfig response %j', rawResponse); + this._log.info( + 'createMulticloudDataTransferConfig response %j', + rawResponse, + ); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createMulticloudDataTransferConfig request %j', request); - return this.innerApiCalls.createMulticloudDataTransferConfig(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createMulticloudDataTransferConfig response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createMulticloudDataTransferConfig(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info( + 'createMulticloudDataTransferConfig response %j', + rawResponse, + ); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createMulticloudDataTransferConfig()`. - * @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/data_transfer_service.create_multicloud_data_transfer_config.js - * region_tag:networkconnectivity_v1_generated_DataTransferService_CreateMulticloudDataTransferConfig_async - */ - async checkCreateMulticloudDataTransferConfigProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createMulticloudDataTransferConfig()`. + * @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/data_transfer_service.create_multicloud_data_transfer_config.js + * region_tag:networkconnectivity_v1_generated_DataTransferService_CreateMulticloudDataTransferConfig_async + */ + async checkCreateMulticloudDataTransferConfigProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('createMulticloudDataTransferConfig long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createMulticloudDataTransferConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createMulticloudDataTransferConfig, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; } -/** - * Updates a `MulticloudDataTransferConfig` resource in a specified project - * and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. `FieldMask` is used to specify the fields in the - * `MulticloudDataTransferConfig` resource to be overwritten by the update. - * The fields specified in `update_mask` are relative to the resource, not - * the full request. A field is overwritten if it is in the mask. If you - * don't specify a mask, all fields are overwritten. - * @param {google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig} request.multicloudDataTransferConfig - * Required. The `MulticloudDataTransferConfig` resource to update. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server can ignore - * the request if it has already been completed. The server waits - * for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, can ignore the second request. This prevents - * clients from accidentally creating duplicate `MulticloudDataTransferConfig` - * resources. - * - * The request ID must be a valid UUID with the exception that zero UUID - * (00000000-0000-0000-0000-000000000000) isn't supported. - * @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/data_transfer_service.update_multicloud_data_transfer_config.js - * region_tag:networkconnectivity_v1_generated_DataTransferService_UpdateMulticloudDataTransferConfig_async - */ + /** + * Updates a `MulticloudDataTransferConfig` resource in a specified project + * and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. `FieldMask` is used to specify the fields in the + * `MulticloudDataTransferConfig` resource to be overwritten by the update. + * The fields specified in `update_mask` are relative to the resource, not + * the full request. A field is overwritten if it is in the mask. If you + * don't specify a mask, all fields are overwritten. + * @param {google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig} request.multicloudDataTransferConfig + * Required. The `MulticloudDataTransferConfig` resource to update. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server can ignore + * the request if it has already been completed. The server waits + * for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, can ignore the second request. This prevents + * clients from accidentally creating duplicate `MulticloudDataTransferConfig` + * resources. + * + * The request ID must be a valid UUID with the exception that zero UUID + * (00000000-0000-0000-0000-000000000000) isn't supported. + * @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/data_transfer_service.update_multicloud_data_transfer_config.js + * region_tag:networkconnectivity_v1_generated_DataTransferService_UpdateMulticloudDataTransferConfig_async + */ updateMulticloudDataTransferConfig( - request?: protos.google.cloud.networkconnectivity.v1.IUpdateMulticloudDataTransferConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IUpdateMulticloudDataTransferConfigRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateMulticloudDataTransferConfig( - request: protos.google.cloud.networkconnectivity.v1.IUpdateMulticloudDataTransferConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IUpdateMulticloudDataTransferConfigRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateMulticloudDataTransferConfig( - request: protos.google.cloud.networkconnectivity.v1.IUpdateMulticloudDataTransferConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IUpdateMulticloudDataTransferConfigRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateMulticloudDataTransferConfig( - request?: protos.google.cloud.networkconnectivity.v1.IUpdateMulticloudDataTransferConfigRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1.IUpdateMulticloudDataTransferConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'multicloud_data_transfer_config.name': request.multicloudDataTransferConfig!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'multicloud_data_transfer_config.name': + request.multicloudDataTransferConfig!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { - this._log.info('updateMulticloudDataTransferConfig response %j', rawResponse); + this._log.info( + 'updateMulticloudDataTransferConfig response %j', + rawResponse, + ); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateMulticloudDataTransferConfig request %j', request); - return this.innerApiCalls.updateMulticloudDataTransferConfig(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateMulticloudDataTransferConfig response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateMulticloudDataTransferConfig(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info( + 'updateMulticloudDataTransferConfig response %j', + rawResponse, + ); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateMulticloudDataTransferConfig()`. - * @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/data_transfer_service.update_multicloud_data_transfer_config.js - * region_tag:networkconnectivity_v1_generated_DataTransferService_UpdateMulticloudDataTransferConfig_async - */ - async checkUpdateMulticloudDataTransferConfigProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateMulticloudDataTransferConfig()`. + * @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/data_transfer_service.update_multicloud_data_transfer_config.js + * region_tag:networkconnectivity_v1_generated_DataTransferService_UpdateMulticloudDataTransferConfig_async + */ + async checkUpdateMulticloudDataTransferConfigProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('updateMulticloudDataTransferConfig long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateMulticloudDataTransferConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateMulticloudDataTransferConfig, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; } -/** - * Deletes a `MulticloudDataTransferConfig` resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the `MulticloudDataTransferConfig` resource to - * delete. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server can ignore - * the request if it has already been completed. The server waits - * for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, can ignore the second request. This prevents - * clients from accidentally creating duplicate `MulticloudDataTransferConfig` - * resources. - * - * The request ID must be a valid UUID with the exception that zero UUID - * (00000000-0000-0000-0000-000000000000) isn't supported. - * @param {string} [request.etag] - * Optional. The etag is computed by the server, and might be sent with update - * and delete requests so that the client has an up-to-date value before - * proceeding. - * @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/data_transfer_service.delete_multicloud_data_transfer_config.js - * region_tag:networkconnectivity_v1_generated_DataTransferService_DeleteMulticloudDataTransferConfig_async - */ + /** + * Deletes a `MulticloudDataTransferConfig` resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the `MulticloudDataTransferConfig` resource to + * delete. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server can ignore + * the request if it has already been completed. The server waits + * for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, can ignore the second request. This prevents + * clients from accidentally creating duplicate `MulticloudDataTransferConfig` + * resources. + * + * The request ID must be a valid UUID with the exception that zero UUID + * (00000000-0000-0000-0000-000000000000) isn't supported. + * @param {string} [request.etag] + * Optional. The etag is computed by the server, and might be sent with update + * and delete requests so that the client has an up-to-date value before + * proceeding. + * @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/data_transfer_service.delete_multicloud_data_transfer_config.js + * region_tag:networkconnectivity_v1_generated_DataTransferService_DeleteMulticloudDataTransferConfig_async + */ deleteMulticloudDataTransferConfig( - request?: protos.google.cloud.networkconnectivity.v1.IDeleteMulticloudDataTransferConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IDeleteMulticloudDataTransferConfigRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteMulticloudDataTransferConfig( - request: protos.google.cloud.networkconnectivity.v1.IDeleteMulticloudDataTransferConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IDeleteMulticloudDataTransferConfigRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteMulticloudDataTransferConfig( - request: protos.google.cloud.networkconnectivity.v1.IDeleteMulticloudDataTransferConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IDeleteMulticloudDataTransferConfigRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteMulticloudDataTransferConfig( - request?: protos.google.cloud.networkconnectivity.v1.IDeleteMulticloudDataTransferConfigRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1.IDeleteMulticloudDataTransferConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { - this._log.info('deleteMulticloudDataTransferConfig response %j', rawResponse); + this._log.info( + 'deleteMulticloudDataTransferConfig response %j', + rawResponse, + ); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteMulticloudDataTransferConfig request %j', request); - return this.innerApiCalls.deleteMulticloudDataTransferConfig(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteMulticloudDataTransferConfig response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteMulticloudDataTransferConfig(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info( + 'deleteMulticloudDataTransferConfig response %j', + rawResponse, + ); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteMulticloudDataTransferConfig()`. - * @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/data_transfer_service.delete_multicloud_data_transfer_config.js - * region_tag:networkconnectivity_v1_generated_DataTransferService_DeleteMulticloudDataTransferConfig_async - */ - async checkDeleteMulticloudDataTransferConfigProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteMulticloudDataTransferConfig()`. + * @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/data_transfer_service.delete_multicloud_data_transfer_config.js + * region_tag:networkconnectivity_v1_generated_DataTransferService_DeleteMulticloudDataTransferConfig_async + */ + async checkDeleteMulticloudDataTransferConfigProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('deleteMulticloudDataTransferConfig long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteMulticloudDataTransferConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteMulticloudDataTransferConfig, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; } -/** - * Creates a `Destination` resource in a specified project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent resource. - * @param {string} request.destinationId - * Required. The ID to use for the `Destination` resource, which becomes the - * final component of the `Destination` resource name. - * @param {google.cloud.networkconnectivity.v1.Destination} request.destination - * Required. The `Destination` resource to create. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server can ignore - * the request if it has already been completed. The server waits - * for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, can ignore the second request. This prevents - * clients from accidentally creating duplicate `Destination` - * resources. - * - * The request ID must be a valid UUID with the exception that zero UUID - * (00000000-0000-0000-0000-000000000000) isn't supported. - * @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/data_transfer_service.create_destination.js - * region_tag:networkconnectivity_v1_generated_DataTransferService_CreateDestination_async - */ + /** + * Creates a `Destination` resource in a specified project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent resource. + * @param {string} request.destinationId + * Required. The ID to use for the `Destination` resource, which becomes the + * final component of the `Destination` resource name. + * @param {google.cloud.networkconnectivity.v1.Destination} request.destination + * Required. The `Destination` resource to create. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server can ignore + * the request if it has already been completed. The server waits + * for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, can ignore the second request. This prevents + * clients from accidentally creating duplicate `Destination` + * resources. + * + * The request ID must be a valid UUID with the exception that zero UUID + * (00000000-0000-0000-0000-000000000000) isn't supported. + * @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/data_transfer_service.create_destination.js + * region_tag:networkconnectivity_v1_generated_DataTransferService_CreateDestination_async + */ createDestination( - request?: protos.google.cloud.networkconnectivity.v1.ICreateDestinationRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.ICreateDestinationRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IDestination, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createDestination( - request: protos.google.cloud.networkconnectivity.v1.ICreateDestinationRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.ICreateDestinationRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IDestination, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createDestination( - request: protos.google.cloud.networkconnectivity.v1.ICreateDestinationRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.ICreateDestinationRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IDestination, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createDestination( - request?: protos.google.cloud.networkconnectivity.v1.ICreateDestinationRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1.ICreateDestinationRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IDestination, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IDestination, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IDestination, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IDestination, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createDestination response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createDestination request %j', request); - return this.innerApiCalls.createDestination(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createDestination response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createDestination(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IDestination, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createDestination response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createDestination()`. - * @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/data_transfer_service.create_destination.js - * region_tag:networkconnectivity_v1_generated_DataTransferService_CreateDestination_async - */ - async checkCreateDestinationProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createDestination()`. + * @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/data_transfer_service.create_destination.js + * region_tag:networkconnectivity_v1_generated_DataTransferService_CreateDestination_async + */ + async checkCreateDestinationProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1.Destination, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('createDestination long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createDestination, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createDestination, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1.Destination, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; } -/** - * Updates a `Destination` resource in a specified project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. `FieldMask is used to specify the fields to be overwritten in the - * `Destination` resource by the update. - * The fields specified in `update_mask` are relative to the resource, not - * the full request. A field is overwritten if it is in the mask. If you - * don't specify a mask, all fields are overwritten. - * @param {google.cloud.networkconnectivity.v1.Destination} request.destination - * Required. The `Destination` resource to update. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server can ignore - * the request if it has already been completed. The server waits - * for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, can ignore the second request. - * - * The request ID must be a valid UUID with the exception that zero UUID - * (00000000-0000-0000-0000-000000000000) isn't supported. - * @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/data_transfer_service.update_destination.js - * region_tag:networkconnectivity_v1_generated_DataTransferService_UpdateDestination_async - */ + /** + * Updates a `Destination` resource in a specified project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. `FieldMask is used to specify the fields to be overwritten in the + * `Destination` resource by the update. + * The fields specified in `update_mask` are relative to the resource, not + * the full request. A field is overwritten if it is in the mask. If you + * don't specify a mask, all fields are overwritten. + * @param {google.cloud.networkconnectivity.v1.Destination} request.destination + * Required. The `Destination` resource to update. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server can ignore + * the request if it has already been completed. The server waits + * for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, can ignore the second request. + * + * The request ID must be a valid UUID with the exception that zero UUID + * (00000000-0000-0000-0000-000000000000) isn't supported. + * @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/data_transfer_service.update_destination.js + * region_tag:networkconnectivity_v1_generated_DataTransferService_UpdateDestination_async + */ updateDestination( - request?: protos.google.cloud.networkconnectivity.v1.IUpdateDestinationRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IUpdateDestinationRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IDestination, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateDestination( - request: protos.google.cloud.networkconnectivity.v1.IUpdateDestinationRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IUpdateDestinationRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IDestination, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateDestination( - request: protos.google.cloud.networkconnectivity.v1.IUpdateDestinationRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IUpdateDestinationRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IDestination, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateDestination( - request?: protos.google.cloud.networkconnectivity.v1.IUpdateDestinationRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1.IUpdateDestinationRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IDestination, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IDestination, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IDestination, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'destination.name': request.destination!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'destination.name': request.destination!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IDestination, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateDestination response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateDestination request %j', request); - return this.innerApiCalls.updateDestination(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateDestination response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateDestination(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IDestination, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateDestination response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateDestination()`. - * @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/data_transfer_service.update_destination.js - * region_tag:networkconnectivity_v1_generated_DataTransferService_UpdateDestination_async - */ - async checkUpdateDestinationProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateDestination()`. + * @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/data_transfer_service.update_destination.js + * region_tag:networkconnectivity_v1_generated_DataTransferService_UpdateDestination_async + */ + async checkUpdateDestinationProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1.Destination, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('updateDestination long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateDestination, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateDestination, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1.Destination, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; } -/** - * Deletes a `Destination` resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the `Destination` resource to delete. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server can ignore - * the request if it has already been completed. The server waits - * for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, can ignore the second request. - * - * The request ID must be a valid UUID with the exception that zero UUID - * (00000000-0000-0000-0000-000000000000) isn't supported. - * @param {string} [request.etag] - * Optional. The etag is computed by the server, and might be sent with update - * and delete requests so that the client has an up-to-date value before - * proceeding. - * @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/data_transfer_service.delete_destination.js - * region_tag:networkconnectivity_v1_generated_DataTransferService_DeleteDestination_async - */ + /** + * Deletes a `Destination` resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the `Destination` resource to delete. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server can ignore + * the request if it has already been completed. The server waits + * for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, can ignore the second request. + * + * The request ID must be a valid UUID with the exception that zero UUID + * (00000000-0000-0000-0000-000000000000) isn't supported. + * @param {string} [request.etag] + * Optional. The etag is computed by the server, and might be sent with update + * and delete requests so that the client has an up-to-date value before + * proceeding. + * @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/data_transfer_service.delete_destination.js + * region_tag:networkconnectivity_v1_generated_DataTransferService_DeleteDestination_async + */ deleteDestination( - request?: protos.google.cloud.networkconnectivity.v1.IDeleteDestinationRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IDeleteDestinationRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteDestination( - request: protos.google.cloud.networkconnectivity.v1.IDeleteDestinationRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IDeleteDestinationRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteDestination( - request: protos.google.cloud.networkconnectivity.v1.IDeleteDestinationRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IDeleteDestinationRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteDestination( - request?: protos.google.cloud.networkconnectivity.v1.IDeleteDestinationRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1.IDeleteDestinationRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteDestination response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteDestination request %j', request); - return this.innerApiCalls.deleteDestination(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteDestination response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteDestination(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteDestination response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteDestination()`. - * @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/data_transfer_service.delete_destination.js - * region_tag:networkconnectivity_v1_generated_DataTransferService_DeleteDestination_async - */ - async checkDeleteDestinationProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteDestination()`. + * @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/data_transfer_service.delete_destination.js + * region_tag:networkconnectivity_v1_generated_DataTransferService_DeleteDestination_async + */ + async checkDeleteDestinationProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('deleteDestination long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteDestination, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists the `MulticloudDataTransferConfig` resources in a specified project - * and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent resource. - * @param {number} [request.pageSize] - * Optional. The maximum number of results listed per page. - * @param {string} [request.pageToken] - * Optional. The page token. - * @param {string} [request.filter] - * Optional. An expression that filters the results listed in the response. - * @param {string} [request.orderBy] - * Optional. The sort order of the results. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If `true`, allows partial responses for multi-regional aggregated - * list requests. - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig|MulticloudDataTransferConfig}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listMulticloudDataTransferConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteDestination, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; + } + /** + * Lists the `MulticloudDataTransferConfig` resources in a specified project + * and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent resource. + * @param {number} [request.pageSize] + * Optional. The maximum number of results listed per page. + * @param {string} [request.pageToken] + * Optional. The page token. + * @param {string} [request.filter] + * Optional. An expression that filters the results listed in the response. + * @param {string} [request.orderBy] + * Optional. The sort order of the results. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If `true`, allows partial responses for multi-regional aggregated + * list requests. + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig|MulticloudDataTransferConfig}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listMulticloudDataTransferConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMulticloudDataTransferConfigs( - request?: protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig[], - protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsRequest|null, - protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig[], + protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsRequest | null, + protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsResponse, + ] + >; listMulticloudDataTransferConfigs( - request: protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsRequest, - protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig>): void; + request: protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsRequest, + | protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig + >, + ): void; listMulticloudDataTransferConfigs( - request: protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsRequest, - protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig>): void; + request: protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsRequest, + | protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig + >, + ): void; listMulticloudDataTransferConfigs( - request?: protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsRequest, - protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsRequest, - protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig>): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig[], - protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsRequest|null, - protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsRequest, + | protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig[], + protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsRequest | null, + protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsRequest, - protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsRequest, + | protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listMulticloudDataTransferConfigs values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1604,210 +2416,244 @@ export class DataTransferServiceClient { this._log.info('listMulticloudDataTransferConfigs request %j', request); return this.innerApiCalls .listMulticloudDataTransferConfigs(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig[], - protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsRequest|null, - protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsResponse - ]) => { - this._log.info('listMulticloudDataTransferConfigs values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig[], + protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsRequest | null, + protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsResponse, + ]) => { + this._log.info( + 'listMulticloudDataTransferConfigs values %j', + response, + ); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listMulticloudDataTransferConfigs`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent resource. - * @param {number} [request.pageSize] - * Optional. The maximum number of results listed per page. - * @param {string} [request.pageToken] - * Optional. The page token. - * @param {string} [request.filter] - * Optional. An expression that filters the results listed in the response. - * @param {string} [request.orderBy] - * Optional. The sort order of the results. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If `true`, allows partial responses for multi-regional aggregated - * list requests. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig|MulticloudDataTransferConfig} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listMulticloudDataTransferConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listMulticloudDataTransferConfigs`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent resource. + * @param {number} [request.pageSize] + * Optional. The maximum number of results listed per page. + * @param {string} [request.pageToken] + * Optional. The page token. + * @param {string} [request.filter] + * Optional. An expression that filters the results listed in the response. + * @param {string} [request.orderBy] + * Optional. The sort order of the results. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If `true`, allows partial responses for multi-regional aggregated + * list requests. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig|MulticloudDataTransferConfig} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listMulticloudDataTransferConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMulticloudDataTransferConfigsStream( - request?: protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listMulticloudDataTransferConfigs']; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = + this._defaults['listMulticloudDataTransferConfigs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listMulticloudDataTransferConfigs stream %j', request); return this.descriptors.page.listMulticloudDataTransferConfigs.createStream( this.innerApiCalls.listMulticloudDataTransferConfigs as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listMulticloudDataTransferConfigs`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent resource. - * @param {number} [request.pageSize] - * Optional. The maximum number of results listed per page. - * @param {string} [request.pageToken] - * Optional. The page token. - * @param {string} [request.filter] - * Optional. An expression that filters the results listed in the response. - * @param {string} [request.orderBy] - * Optional. The sort order of the results. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If `true`, allows partial responses for multi-regional aggregated - * list requests. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig|MulticloudDataTransferConfig}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/data_transfer_service.list_multicloud_data_transfer_configs.js - * region_tag:networkconnectivity_v1_generated_DataTransferService_ListMulticloudDataTransferConfigs_async - */ + /** + * Equivalent to `listMulticloudDataTransferConfigs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent resource. + * @param {number} [request.pageSize] + * Optional. The maximum number of results listed per page. + * @param {string} [request.pageToken] + * Optional. The page token. + * @param {string} [request.filter] + * Optional. An expression that filters the results listed in the response. + * @param {string} [request.orderBy] + * Optional. The sort order of the results. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If `true`, allows partial responses for multi-regional aggregated + * list requests. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig|MulticloudDataTransferConfig}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/data_transfer_service.list_multicloud_data_transfer_configs.js + * region_tag:networkconnectivity_v1_generated_DataTransferService_ListMulticloudDataTransferConfigs_async + */ listMulticloudDataTransferConfigsAsync( - request?: protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferConfigsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listMulticloudDataTransferConfigs']; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = + this._defaults['listMulticloudDataTransferConfigs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listMulticloudDataTransferConfigs iterate %j', request); return this.descriptors.page.listMulticloudDataTransferConfigs.asyncIterate( this.innerApiCalls['listMulticloudDataTransferConfigs'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists the `Destination` resources in a specified project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent resource. - * @param {number} [request.pageSize] - * Optional. The maximum number of results listed per page. - * @param {string} [request.pageToken] - * Optional. The page token. - * @param {string} [request.filter] - * Optional. An expression that filters the results listed in the response. - * @param {string} [request.orderBy] - * Optional. The sort order of the results. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If `true`, allow partial responses for multi-regional aggregated - * list requests. - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.Destination|Destination}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listDestinationsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists the `Destination` resources in a specified project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent resource. + * @param {number} [request.pageSize] + * Optional. The maximum number of results listed per page. + * @param {string} [request.pageToken] + * Optional. The page token. + * @param {string} [request.filter] + * Optional. An expression that filters the results listed in the response. + * @param {string} [request.orderBy] + * Optional. The sort order of the results. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If `true`, allow partial responses for multi-regional aggregated + * list requests. + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.Destination|Destination}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listDestinationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listDestinations( - request?: protos.google.cloud.networkconnectivity.v1.IListDestinationsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IDestination[], - protos.google.cloud.networkconnectivity.v1.IListDestinationsRequest|null, - protos.google.cloud.networkconnectivity.v1.IListDestinationsResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IListDestinationsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IDestination[], + protos.google.cloud.networkconnectivity.v1.IListDestinationsRequest | null, + protos.google.cloud.networkconnectivity.v1.IListDestinationsResponse, + ] + >; listDestinations( - request: protos.google.cloud.networkconnectivity.v1.IListDestinationsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListDestinationsRequest, - protos.google.cloud.networkconnectivity.v1.IListDestinationsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IDestination>): void; + request: protos.google.cloud.networkconnectivity.v1.IListDestinationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListDestinationsRequest, + | protos.google.cloud.networkconnectivity.v1.IListDestinationsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IDestination + >, + ): void; listDestinations( - request: protos.google.cloud.networkconnectivity.v1.IListDestinationsRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListDestinationsRequest, - protos.google.cloud.networkconnectivity.v1.IListDestinationsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IDestination>): void; + request: protos.google.cloud.networkconnectivity.v1.IListDestinationsRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListDestinationsRequest, + | protos.google.cloud.networkconnectivity.v1.IListDestinationsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IDestination + >, + ): void; listDestinations( - request?: protos.google.cloud.networkconnectivity.v1.IListDestinationsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListDestinationsRequest, - protos.google.cloud.networkconnectivity.v1.IListDestinationsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IDestination>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1.IListDestinationsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1.IListDestinationsRequest, - protos.google.cloud.networkconnectivity.v1.IListDestinationsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IDestination>): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IDestination[], - protos.google.cloud.networkconnectivity.v1.IListDestinationsRequest|null, - protos.google.cloud.networkconnectivity.v1.IListDestinationsResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1.IListDestinationsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IDestination + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListDestinationsRequest, + | protos.google.cloud.networkconnectivity.v1.IListDestinationsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IDestination + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IDestination[], + protos.google.cloud.networkconnectivity.v1.IListDestinationsRequest | null, + protos.google.cloud.networkconnectivity.v1.IListDestinationsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListDestinationsRequest, - protos.google.cloud.networkconnectivity.v1.IListDestinationsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IDestination>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListDestinationsRequest, + | protos.google.cloud.networkconnectivity.v1.IListDestinationsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IDestination + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listDestinations values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1816,339 +2662,395 @@ export class DataTransferServiceClient { this._log.info('listDestinations request %j', request); return this.innerApiCalls .listDestinations(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1.IDestination[], - protos.google.cloud.networkconnectivity.v1.IListDestinationsRequest|null, - protos.google.cloud.networkconnectivity.v1.IListDestinationsResponse - ]) => { - this._log.info('listDestinations values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1.IDestination[], + protos.google.cloud.networkconnectivity.v1.IListDestinationsRequest | null, + protos.google.cloud.networkconnectivity.v1.IListDestinationsResponse, + ]) => { + this._log.info('listDestinations values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listDestinations`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent resource. - * @param {number} [request.pageSize] - * Optional. The maximum number of results listed per page. - * @param {string} [request.pageToken] - * Optional. The page token. - * @param {string} [request.filter] - * Optional. An expression that filters the results listed in the response. - * @param {string} [request.orderBy] - * Optional. The sort order of the results. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If `true`, allow partial responses for multi-regional aggregated - * list requests. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.Destination|Destination} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listDestinationsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listDestinations`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent resource. + * @param {number} [request.pageSize] + * Optional. The maximum number of results listed per page. + * @param {string} [request.pageToken] + * Optional. The page token. + * @param {string} [request.filter] + * Optional. An expression that filters the results listed in the response. + * @param {string} [request.orderBy] + * Optional. The sort order of the results. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If `true`, allow partial responses for multi-regional aggregated + * list requests. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.Destination|Destination} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listDestinationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listDestinationsStream( - request?: protos.google.cloud.networkconnectivity.v1.IListDestinationsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1.IListDestinationsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listDestinations']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listDestinations stream %j', request); return this.descriptors.page.listDestinations.createStream( this.innerApiCalls.listDestinations as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listDestinations`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent resource. - * @param {number} [request.pageSize] - * Optional. The maximum number of results listed per page. - * @param {string} [request.pageToken] - * Optional. The page token. - * @param {string} [request.filter] - * Optional. An expression that filters the results listed in the response. - * @param {string} [request.orderBy] - * Optional. The sort order of the results. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If `true`, allow partial responses for multi-regional aggregated - * list requests. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1.Destination|Destination}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/data_transfer_service.list_destinations.js - * region_tag:networkconnectivity_v1_generated_DataTransferService_ListDestinations_async - */ + /** + * Equivalent to `listDestinations`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent resource. + * @param {number} [request.pageSize] + * Optional. The maximum number of results listed per page. + * @param {string} [request.pageToken] + * Optional. The page token. + * @param {string} [request.filter] + * Optional. An expression that filters the results listed in the response. + * @param {string} [request.orderBy] + * Optional. The sort order of the results. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If `true`, allow partial responses for multi-regional aggregated + * list requests. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1.Destination|Destination}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/data_transfer_service.list_destinations.js + * region_tag:networkconnectivity_v1_generated_DataTransferService_ListDestinations_async + */ listDestinationsAsync( - request?: protos.google.cloud.networkconnectivity.v1.IListDestinationsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1.IListDestinationsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listDestinations']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listDestinations iterate %j', request); return this.descriptors.page.listDestinations.asyncIterate( this.innerApiCalls['listDestinations'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists the services in the project for a region that are supported for - * Data Transfer Essentials. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent resource. - * @param {number} [request.pageSize] - * Optional. The maximum number of results listed per page. - * @param {string} [request.pageToken] - * Optional. The page token. - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService|MulticloudDataTransferSupportedService}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listMulticloudDataTransferSupportedServicesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists the services in the project for a region that are supported for + * Data Transfer Essentials. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent resource. + * @param {number} [request.pageSize] + * Optional. The maximum number of results listed per page. + * @param {string} [request.pageToken] + * Optional. The page token. + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService|MulticloudDataTransferSupportedService}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listMulticloudDataTransferSupportedServicesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMulticloudDataTransferSupportedServices( - request?: protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService[], - protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesRequest|null, - protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService[], + protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesRequest | null, + protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesResponse, + ] + >; listMulticloudDataTransferSupportedServices( - request: protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesRequest, - protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService>): void; + request: protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesRequest, + | protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService + >, + ): void; listMulticloudDataTransferSupportedServices( - request: protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesRequest, - protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService>): void; + request: protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesRequest, + | protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService + >, + ): void; listMulticloudDataTransferSupportedServices( - request?: protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesRequest, - protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesRequest, - protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService>): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService[], - protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesRequest|null, - protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesRequest, + | protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService[], + protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesRequest | null, + protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesRequest, - protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesRequest, + | protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { - this._log.info('listMulticloudDataTransferSupportedServices values %j', values); + this._log.info( + 'listMulticloudDataTransferSupportedServices values %j', + values, + ); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. } : undefined; - this._log.info('listMulticloudDataTransferSupportedServices request %j', request); + this._log.info( + 'listMulticloudDataTransferSupportedServices request %j', + request, + ); return this.innerApiCalls - .listMulticloudDataTransferSupportedServices(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService[], - protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesRequest|null, - protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesResponse - ]) => { - this._log.info('listMulticloudDataTransferSupportedServices values %j', response); - return [response, input, output]; - }); + .listMulticloudDataTransferSupportedServices( + request, + options, + wrappedCallback, + ) + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService[], + protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesRequest | null, + protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesResponse, + ]) => { + this._log.info( + 'listMulticloudDataTransferSupportedServices values %j', + response, + ); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listMulticloudDataTransferSupportedServices`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent resource. - * @param {number} [request.pageSize] - * Optional. The maximum number of results listed per page. - * @param {string} [request.pageToken] - * Optional. The page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService|MulticloudDataTransferSupportedService} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listMulticloudDataTransferSupportedServicesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listMulticloudDataTransferSupportedServices`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent resource. + * @param {number} [request.pageSize] + * Optional. The maximum number of results listed per page. + * @param {string} [request.pageToken] + * Optional. The page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService|MulticloudDataTransferSupportedService} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listMulticloudDataTransferSupportedServicesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMulticloudDataTransferSupportedServicesStream( - request?: protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listMulticloudDataTransferSupportedServices']; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = + this._defaults['listMulticloudDataTransferSupportedServices']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); - this._log.info('listMulticloudDataTransferSupportedServices stream %j', request); + this.initialize().catch((err) => { + throw err; + }); + this._log.info( + 'listMulticloudDataTransferSupportedServices stream %j', + request, + ); return this.descriptors.page.listMulticloudDataTransferSupportedServices.createStream( this.innerApiCalls.listMulticloudDataTransferSupportedServices as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listMulticloudDataTransferSupportedServices`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent resource. - * @param {number} [request.pageSize] - * Optional. The maximum number of results listed per page. - * @param {string} [request.pageToken] - * Optional. The page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService|MulticloudDataTransferSupportedService}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/data_transfer_service.list_multicloud_data_transfer_supported_services.js - * region_tag:networkconnectivity_v1_generated_DataTransferService_ListMulticloudDataTransferSupportedServices_async - */ + /** + * Equivalent to `listMulticloudDataTransferSupportedServices`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent resource. + * @param {number} [request.pageSize] + * Optional. The maximum number of results listed per page. + * @param {string} [request.pageToken] + * Optional. The page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService|MulticloudDataTransferSupportedService}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/data_transfer_service.list_multicloud_data_transfer_supported_services.js + * region_tag:networkconnectivity_v1_generated_DataTransferService_ListMulticloudDataTransferSupportedServices_async + */ listMulticloudDataTransferSupportedServicesAsync( - request?: protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1.IListMulticloudDataTransferSupportedServicesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listMulticloudDataTransferSupportedServices']; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = + this._defaults['listMulticloudDataTransferSupportedServices']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); - this._log.info('listMulticloudDataTransferSupportedServices iterate %j', request); + this.initialize().catch((err) => { + throw err; + }); + this._log.info( + 'listMulticloudDataTransferSupportedServices iterate %j', + request, + ); return this.descriptors.page.listMulticloudDataTransferSupportedServices.asyncIterate( - this.innerApiCalls['listMulticloudDataTransferSupportedServices'] as GaxCall, + this.innerApiCalls[ + 'listMulticloudDataTransferSupportedServices' + ] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -2162,40 +3064,40 @@ export class DataTransferServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -2209,41 +3111,41 @@ export class DataTransferServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -2257,12 +3159,12 @@ export class DataTransferServiceClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -2297,12 +3199,11 @@ export class DataTransferServiceClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -2335,12 +3236,12 @@ export class DataTransferServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -2383,22 +3284,22 @@ export class DataTransferServiceClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -2433,15 +3334,15 @@ export class DataTransferServiceClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - 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 ?? '', - }); + 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 ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -2475,7 +3376,7 @@ export class DataTransferServiceClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -2488,25 +3389,24 @@ export class DataTransferServiceClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -2545,22 +3445,22 @@ export class DataTransferServiceClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -2577,7 +3477,12 @@ export class DataTransferServiceClient { * @param {string} destination * @returns {string} Resource name string. */ - destinationPath(project:string,location:string,multicloudDataTransferConfig:string,destination:string) { + destinationPath( + project: string, + location: string, + multicloudDataTransferConfig: string, + destination: string, + ) { return this.pathTemplates.destinationPathTemplate.render({ project: project, location: location, @@ -2594,7 +3499,8 @@ export class DataTransferServiceClient { * @returns {string} A string representing the project. */ matchProjectFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).project; + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .project; } /** @@ -2605,7 +3511,8 @@ export class DataTransferServiceClient { * @returns {string} A string representing the location. */ matchLocationFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).location; + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .location; } /** @@ -2615,8 +3522,11 @@ export class DataTransferServiceClient { * A fully-qualified path representing Destination resource. * @returns {string} A string representing the multicloud_data_transfer_config. */ - matchMulticloudDataTransferConfigFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).multicloud_data_transfer_config; + matchMulticloudDataTransferConfigFromDestinationName( + destinationName: string, + ) { + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .multicloud_data_transfer_config; } /** @@ -2627,7 +3537,8 @@ export class DataTransferServiceClient { * @returns {string} A string representing the destination. */ matchDestinationFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).destination; + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .destination; } /** @@ -2638,7 +3549,7 @@ export class DataTransferServiceClient { * @param {string} group * @returns {string} Resource name string. */ - groupPath(project:string,hub:string,group:string) { + groupPath(project: string, hub: string, group: string) { return this.pathTemplates.groupPathTemplate.render({ project: project, hub: hub, @@ -2686,7 +3597,7 @@ export class DataTransferServiceClient { * @param {string} hub * @returns {string} Resource name string. */ - hubPath(project:string,hub:string) { + hubPath(project: string, hub: string) { return this.pathTemplates.hubPathTemplate.render({ project: project, hub: hub, @@ -2724,7 +3635,12 @@ export class DataTransferServiceClient { * @param {string} route * @returns {string} Resource name string. */ - hubRoutePath(project:string,hub:string,routeTable:string,route:string) { + hubRoutePath( + project: string, + hub: string, + routeTable: string, + route: string, + ) { return this.pathTemplates.hubRoutePathTemplate.render({ project: project, hub: hub, @@ -2763,7 +3679,8 @@ export class DataTransferServiceClient { * @returns {string} A string representing the route_table. */ matchRouteTableFromHubRouteName(hubRouteName: string) { - return this.pathTemplates.hubRoutePathTemplate.match(hubRouteName).route_table; + return this.pathTemplates.hubRoutePathTemplate.match(hubRouteName) + .route_table; } /** @@ -2785,7 +3702,7 @@ export class DataTransferServiceClient { * @param {string} internal_range * @returns {string} Resource name string. */ - internalRangePath(project:string,location:string,internalRange:string) { + internalRangePath(project: string, location: string, internalRange: string) { return this.pathTemplates.internalRangePathTemplate.render({ project: project, location: location, @@ -2801,7 +3718,8 @@ export class DataTransferServiceClient { * @returns {string} A string representing the project. */ matchProjectFromInternalRangeName(internalRangeName: string) { - return this.pathTemplates.internalRangePathTemplate.match(internalRangeName).project; + return this.pathTemplates.internalRangePathTemplate.match(internalRangeName) + .project; } /** @@ -2812,7 +3730,8 @@ export class DataTransferServiceClient { * @returns {string} A string representing the location. */ matchLocationFromInternalRangeName(internalRangeName: string) { - return this.pathTemplates.internalRangePathTemplate.match(internalRangeName).location; + return this.pathTemplates.internalRangePathTemplate.match(internalRangeName) + .location; } /** @@ -2823,7 +3742,8 @@ export class DataTransferServiceClient { * @returns {string} A string representing the internal_range. */ matchInternalRangeFromInternalRangeName(internalRangeName: string) { - return this.pathTemplates.internalRangePathTemplate.match(internalRangeName).internal_range; + return this.pathTemplates.internalRangePathTemplate.match(internalRangeName) + .internal_range; } /** @@ -2833,7 +3753,7 @@ export class DataTransferServiceClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -2870,7 +3790,11 @@ export class DataTransferServiceClient { * @param {string} multicloud_data_transfer_config * @returns {string} Resource name string. */ - multicloudDataTransferConfigPath(project:string,location:string,multicloudDataTransferConfig:string) { + multicloudDataTransferConfigPath( + project: string, + location: string, + multicloudDataTransferConfig: string, + ) { return this.pathTemplates.multicloudDataTransferConfigPathTemplate.render({ project: project, location: location, @@ -2885,8 +3809,12 @@ export class DataTransferServiceClient { * A fully-qualified path representing MulticloudDataTransferConfig resource. * @returns {string} A string representing the project. */ - matchProjectFromMulticloudDataTransferConfigName(multicloudDataTransferConfigName: string) { - return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match(multicloudDataTransferConfigName).project; + matchProjectFromMulticloudDataTransferConfigName( + multicloudDataTransferConfigName: string, + ) { + return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match( + multicloudDataTransferConfigName, + ).project; } /** @@ -2896,8 +3824,12 @@ export class DataTransferServiceClient { * A fully-qualified path representing MulticloudDataTransferConfig resource. * @returns {string} A string representing the location. */ - matchLocationFromMulticloudDataTransferConfigName(multicloudDataTransferConfigName: string) { - return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match(multicloudDataTransferConfigName).location; + matchLocationFromMulticloudDataTransferConfigName( + multicloudDataTransferConfigName: string, + ) { + return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match( + multicloudDataTransferConfigName, + ).location; } /** @@ -2907,8 +3839,12 @@ export class DataTransferServiceClient { * A fully-qualified path representing MulticloudDataTransferConfig resource. * @returns {string} A string representing the multicloud_data_transfer_config. */ - matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName(multicloudDataTransferConfigName: string) { - return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match(multicloudDataTransferConfigName).multicloud_data_transfer_config; + matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName( + multicloudDataTransferConfigName: string, + ) { + return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match( + multicloudDataTransferConfigName, + ).multicloud_data_transfer_config; } /** @@ -2919,12 +3855,19 @@ export class DataTransferServiceClient { * @param {string} multicloud_data_transfer_supported_service * @returns {string} Resource name string. */ - multicloudDataTransferSupportedServicePath(project:string,location:string,multicloudDataTransferSupportedService:string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render({ - project: project, - location: location, - multicloud_data_transfer_supported_service: multicloudDataTransferSupportedService, - }); + multicloudDataTransferSupportedServicePath( + project: string, + location: string, + multicloudDataTransferSupportedService: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render( + { + project: project, + location: location, + multicloud_data_transfer_supported_service: + multicloudDataTransferSupportedService, + }, + ); } /** @@ -2934,8 +3877,12 @@ export class DataTransferServiceClient { * A fully-qualified path representing MulticloudDataTransferSupportedService resource. * @returns {string} A string representing the project. */ - matchProjectFromMulticloudDataTransferSupportedServiceName(multicloudDataTransferSupportedServiceName: string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match(multicloudDataTransferSupportedServiceName).project; + matchProjectFromMulticloudDataTransferSupportedServiceName( + multicloudDataTransferSupportedServiceName: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match( + multicloudDataTransferSupportedServiceName, + ).project; } /** @@ -2945,8 +3892,12 @@ export class DataTransferServiceClient { * A fully-qualified path representing MulticloudDataTransferSupportedService resource. * @returns {string} A string representing the location. */ - matchLocationFromMulticloudDataTransferSupportedServiceName(multicloudDataTransferSupportedServiceName: string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match(multicloudDataTransferSupportedServiceName).location; + matchLocationFromMulticloudDataTransferSupportedServiceName( + multicloudDataTransferSupportedServiceName: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match( + multicloudDataTransferSupportedServiceName, + ).location; } /** @@ -2956,8 +3907,12 @@ export class DataTransferServiceClient { * A fully-qualified path representing MulticloudDataTransferSupportedService resource. * @returns {string} A string representing the multicloud_data_transfer_supported_service. */ - matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName(multicloudDataTransferSupportedServiceName: string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match(multicloudDataTransferSupportedServiceName).multicloud_data_transfer_supported_service; + matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName( + multicloudDataTransferSupportedServiceName: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match( + multicloudDataTransferSupportedServiceName, + ).multicloud_data_transfer_supported_service; } /** @@ -2967,7 +3922,7 @@ export class DataTransferServiceClient { * @param {string} policy_based_route * @returns {string} Resource name string. */ - policyBasedRoutePath(project:string,policyBasedRoute:string) { + policyBasedRoutePath(project: string, policyBasedRoute: string) { return this.pathTemplates.policyBasedRoutePathTemplate.render({ project: project, policy_based_route: policyBasedRoute, @@ -2982,7 +3937,9 @@ export class DataTransferServiceClient { * @returns {string} A string representing the project. */ matchProjectFromPolicyBasedRouteName(policyBasedRouteName: string) { - return this.pathTemplates.policyBasedRoutePathTemplate.match(policyBasedRouteName).project; + return this.pathTemplates.policyBasedRoutePathTemplate.match( + policyBasedRouteName, + ).project; } /** @@ -2993,7 +3950,9 @@ export class DataTransferServiceClient { * @returns {string} A string representing the policy_based_route. */ matchPolicyBasedRouteFromPolicyBasedRouteName(policyBasedRouteName: string) { - return this.pathTemplates.policyBasedRoutePathTemplate.match(policyBasedRouteName).policy_based_route; + return this.pathTemplates.policyBasedRoutePathTemplate.match( + policyBasedRouteName, + ).policy_based_route; } /** @@ -3004,7 +3963,7 @@ export class DataTransferServiceClient { * @param {string} route_table * @returns {string} Resource name string. */ - routeTablePath(project:string,hub:string,routeTable:string) { + routeTablePath(project: string, hub: string, routeTable: string) { return this.pathTemplates.routeTablePathTemplate.render({ project: project, hub: hub, @@ -3020,7 +3979,8 @@ export class DataTransferServiceClient { * @returns {string} A string representing the project. */ matchProjectFromRouteTableName(routeTableName: string) { - return this.pathTemplates.routeTablePathTemplate.match(routeTableName).project; + return this.pathTemplates.routeTablePathTemplate.match(routeTableName) + .project; } /** @@ -3042,7 +4002,8 @@ export class DataTransferServiceClient { * @returns {string} A string representing the route_table. */ matchRouteTableFromRouteTableName(routeTableName: string) { - return this.pathTemplates.routeTablePathTemplate.match(routeTableName).route_table; + return this.pathTemplates.routeTablePathTemplate.match(routeTableName) + .route_table; } /** @@ -3053,7 +4014,7 @@ export class DataTransferServiceClient { * @param {string} service_class * @returns {string} Resource name string. */ - serviceClassPath(project:string,location:string,serviceClass:string) { + serviceClassPath(project: string, location: string, serviceClass: string) { return this.pathTemplates.serviceClassPathTemplate.render({ project: project, location: location, @@ -3069,7 +4030,8 @@ export class DataTransferServiceClient { * @returns {string} A string representing the project. */ matchProjectFromServiceClassName(serviceClassName: string) { - return this.pathTemplates.serviceClassPathTemplate.match(serviceClassName).project; + return this.pathTemplates.serviceClassPathTemplate.match(serviceClassName) + .project; } /** @@ -3080,7 +4042,8 @@ export class DataTransferServiceClient { * @returns {string} A string representing the location. */ matchLocationFromServiceClassName(serviceClassName: string) { - return this.pathTemplates.serviceClassPathTemplate.match(serviceClassName).location; + return this.pathTemplates.serviceClassPathTemplate.match(serviceClassName) + .location; } /** @@ -3091,7 +4054,8 @@ export class DataTransferServiceClient { * @returns {string} A string representing the service_class. */ matchServiceClassFromServiceClassName(serviceClassName: string) { - return this.pathTemplates.serviceClassPathTemplate.match(serviceClassName).service_class; + return this.pathTemplates.serviceClassPathTemplate.match(serviceClassName) + .service_class; } /** @@ -3102,7 +4066,11 @@ export class DataTransferServiceClient { * @param {string} service_connection_map * @returns {string} Resource name string. */ - serviceConnectionMapPath(project:string,location:string,serviceConnectionMap:string) { + serviceConnectionMapPath( + project: string, + location: string, + serviceConnectionMap: string, + ) { return this.pathTemplates.serviceConnectionMapPathTemplate.render({ project: project, location: location, @@ -3118,7 +4086,9 @@ export class DataTransferServiceClient { * @returns {string} A string representing the project. */ matchProjectFromServiceConnectionMapName(serviceConnectionMapName: string) { - return this.pathTemplates.serviceConnectionMapPathTemplate.match(serviceConnectionMapName).project; + return this.pathTemplates.serviceConnectionMapPathTemplate.match( + serviceConnectionMapName, + ).project; } /** @@ -3129,7 +4099,9 @@ export class DataTransferServiceClient { * @returns {string} A string representing the location. */ matchLocationFromServiceConnectionMapName(serviceConnectionMapName: string) { - return this.pathTemplates.serviceConnectionMapPathTemplate.match(serviceConnectionMapName).location; + return this.pathTemplates.serviceConnectionMapPathTemplate.match( + serviceConnectionMapName, + ).location; } /** @@ -3139,8 +4111,12 @@ export class DataTransferServiceClient { * A fully-qualified path representing ServiceConnectionMap resource. * @returns {string} A string representing the service_connection_map. */ - matchServiceConnectionMapFromServiceConnectionMapName(serviceConnectionMapName: string) { - return this.pathTemplates.serviceConnectionMapPathTemplate.match(serviceConnectionMapName).service_connection_map; + matchServiceConnectionMapFromServiceConnectionMapName( + serviceConnectionMapName: string, + ) { + return this.pathTemplates.serviceConnectionMapPathTemplate.match( + serviceConnectionMapName, + ).service_connection_map; } /** @@ -3151,7 +4127,11 @@ export class DataTransferServiceClient { * @param {string} service_connection_policy * @returns {string} Resource name string. */ - serviceConnectionPolicyPath(project:string,location:string,serviceConnectionPolicy:string) { + serviceConnectionPolicyPath( + project: string, + location: string, + serviceConnectionPolicy: string, + ) { return this.pathTemplates.serviceConnectionPolicyPathTemplate.render({ project: project, location: location, @@ -3166,8 +4146,12 @@ export class DataTransferServiceClient { * A fully-qualified path representing ServiceConnectionPolicy resource. * @returns {string} A string representing the project. */ - matchProjectFromServiceConnectionPolicyName(serviceConnectionPolicyName: string) { - return this.pathTemplates.serviceConnectionPolicyPathTemplate.match(serviceConnectionPolicyName).project; + matchProjectFromServiceConnectionPolicyName( + serviceConnectionPolicyName: string, + ) { + return this.pathTemplates.serviceConnectionPolicyPathTemplate.match( + serviceConnectionPolicyName, + ).project; } /** @@ -3177,8 +4161,12 @@ export class DataTransferServiceClient { * A fully-qualified path representing ServiceConnectionPolicy resource. * @returns {string} A string representing the location. */ - matchLocationFromServiceConnectionPolicyName(serviceConnectionPolicyName: string) { - return this.pathTemplates.serviceConnectionPolicyPathTemplate.match(serviceConnectionPolicyName).location; + matchLocationFromServiceConnectionPolicyName( + serviceConnectionPolicyName: string, + ) { + return this.pathTemplates.serviceConnectionPolicyPathTemplate.match( + serviceConnectionPolicyName, + ).location; } /** @@ -3188,8 +4176,12 @@ export class DataTransferServiceClient { * A fully-qualified path representing ServiceConnectionPolicy resource. * @returns {string} A string representing the service_connection_policy. */ - matchServiceConnectionPolicyFromServiceConnectionPolicyName(serviceConnectionPolicyName: string) { - return this.pathTemplates.serviceConnectionPolicyPathTemplate.match(serviceConnectionPolicyName).service_connection_policy; + matchServiceConnectionPolicyFromServiceConnectionPolicyName( + serviceConnectionPolicyName: string, + ) { + return this.pathTemplates.serviceConnectionPolicyPathTemplate.match( + serviceConnectionPolicyName, + ).service_connection_policy; } /** @@ -3200,7 +4192,11 @@ export class DataTransferServiceClient { * @param {string} service_connection_token * @returns {string} Resource name string. */ - serviceConnectionTokenPath(project:string,location:string,serviceConnectionToken:string) { + serviceConnectionTokenPath( + project: string, + location: string, + serviceConnectionToken: string, + ) { return this.pathTemplates.serviceConnectionTokenPathTemplate.render({ project: project, location: location, @@ -3215,8 +4211,12 @@ export class DataTransferServiceClient { * A fully-qualified path representing ServiceConnectionToken resource. * @returns {string} A string representing the project. */ - matchProjectFromServiceConnectionTokenName(serviceConnectionTokenName: string) { - return this.pathTemplates.serviceConnectionTokenPathTemplate.match(serviceConnectionTokenName).project; + matchProjectFromServiceConnectionTokenName( + serviceConnectionTokenName: string, + ) { + return this.pathTemplates.serviceConnectionTokenPathTemplate.match( + serviceConnectionTokenName, + ).project; } /** @@ -3226,8 +4226,12 @@ export class DataTransferServiceClient { * A fully-qualified path representing ServiceConnectionToken resource. * @returns {string} A string representing the location. */ - matchLocationFromServiceConnectionTokenName(serviceConnectionTokenName: string) { - return this.pathTemplates.serviceConnectionTokenPathTemplate.match(serviceConnectionTokenName).location; + matchLocationFromServiceConnectionTokenName( + serviceConnectionTokenName: string, + ) { + return this.pathTemplates.serviceConnectionTokenPathTemplate.match( + serviceConnectionTokenName, + ).location; } /** @@ -3237,8 +4241,12 @@ export class DataTransferServiceClient { * A fully-qualified path representing ServiceConnectionToken resource. * @returns {string} A string representing the service_connection_token. */ - matchServiceConnectionTokenFromServiceConnectionTokenName(serviceConnectionTokenName: string) { - return this.pathTemplates.serviceConnectionTokenPathTemplate.match(serviceConnectionTokenName).service_connection_token; + matchServiceConnectionTokenFromServiceConnectionTokenName( + serviceConnectionTokenName: string, + ) { + return this.pathTemplates.serviceConnectionTokenPathTemplate.match( + serviceConnectionTokenName, + ).service_connection_token; } /** @@ -3249,7 +4257,7 @@ export class DataTransferServiceClient { * @param {string} spoke * @returns {string} Resource name string. */ - spokePath(project:string,location:string,spoke:string) { + spokePath(project: string, location: string, spoke: string) { return this.pathTemplates.spokePathTemplate.render({ project: project, location: location, @@ -3298,15 +4306,19 @@ export class DataTransferServiceClient { */ close(): Promise { if (this.dataTransferServiceStub && !this._terminated) { - return this.dataTransferServiceStub.then(stub => { + return this.dataTransferServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-networkconnectivity/src/v1/hub_service_client.ts b/packages/google-cloud-networkconnectivity/src/v1/hub_service_client.ts index e93630f933a7..02e03b0771fb 100644 --- a/packages/google-cloud-networkconnectivity/src/v1/hub_service_client.ts +++ b/packages/google-cloud-networkconnectivity/src/v1/hub_service_client.ts @@ -18,11 +18,24 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -46,7 +59,7 @@ export class HubServiceClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('network-connectivity'); @@ -59,12 +72,12 @@ export class HubServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - hubServiceStub?: Promise<{[name: string]: Function}>; + hubServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of HubServiceClient. @@ -105,21 +118,42 @@ export class HubServiceClient { * const client = new HubServiceClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof HubServiceClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'networkconnectivity.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -144,7 +178,7 @@ export class HubServiceClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -157,18 +191,14 @@ export class HubServiceClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -190,61 +220,63 @@ export class HubServiceClient { // Create useful helper objects for these. this.pathTemplates = { destinationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}/destinations/{destination}' + 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}/destinations/{destination}', ), groupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}/groups/{group}' + 'projects/{project}/locations/global/hubs/{hub}/groups/{group}', ), hubPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}' + 'projects/{project}/locations/global/hubs/{hub}', ), hubRoutePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}/routes/{route}' + 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}/routes/{route}', ), instancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/zones/{zone}/instances/{instance}' + 'projects/{project}/zones/{zone}/instances/{instance}', ), interconnectAttachmentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/regions/{region}/interconnectAttachments/{resource_id}' + 'projects/{project}/regions/{region}/interconnectAttachments/{resource_id}', ), internalRangePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/internalRanges/{internal_range}' + 'projects/{project}/locations/{location}/internalRanges/{internal_range}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - multicloudDataTransferConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}' - ), - multicloudDataTransferSupportedServicePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/multicloudDataTransferSupportedServices/{multicloud_data_transfer_supported_service}' + 'projects/{project}/locations/{location}', ), + multicloudDataTransferConfigPathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}', + ), + multicloudDataTransferSupportedServicePathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/multicloudDataTransferSupportedServices/{multicloud_data_transfer_supported_service}', + ), networkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/global/networks/{resource_id}' + 'projects/{project}/global/networks/{resource_id}', ), policyBasedRoutePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/PolicyBasedRoutes/{policy_based_route}' + 'projects/{project}/locations/global/PolicyBasedRoutes/{policy_based_route}', ), routeTablePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}' + 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}', ), serviceClassPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/serviceClasses/{service_class}' + 'projects/{project}/locations/{location}/serviceClasses/{service_class}', ), serviceConnectionMapPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/serviceConnectionMaps/{service_connection_map}' + 'projects/{project}/locations/{location}/serviceConnectionMaps/{service_connection_map}', ), serviceConnectionPolicyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/serviceConnectionPolicies/{service_connection_policy}' + 'projects/{project}/locations/{location}/serviceConnectionPolicies/{service_connection_policy}', ), serviceConnectionTokenPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/serviceConnectionTokens/{service_connection_token}' + 'projects/{project}/locations/{location}/serviceConnectionTokens/{service_connection_token}', ), spokePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/spokes/{spoke}' + 'projects/{project}/locations/{location}/spokes/{spoke}', ), vpnTunnelPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/regions/{region}/vpnTunnels/{resource_id}' + 'projects/{project}/regions/{region}/vpnTunnels/{resource_id}', ), }; @@ -252,20 +284,41 @@ export class HubServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listHubs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'hubs'), - listHubSpokes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'spokes'), - queryHubStatus: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'hubStatusEntries'), - listSpokes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'spokes'), - listRoutes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'routes'), - listRouteTables: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'routeTables'), - listGroups: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'groups') + listHubs: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'hubs', + ), + listHubSpokes: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'spokes', + ), + queryHubStatus: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'hubStatusEntries', + ), + listSpokes: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'spokes', + ), + listRoutes: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'routes', + ), + listRouteTables: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'routeTables', + ), + listGroups: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'groups', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -274,112 +327,270 @@ export class HubServiceClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1/{resource=projects/*/locations/global/hubs/*}:getIamPolicy',additional_bindings: [{get: '/v1/{resource=projects/*/locations/global/hubs/*/groups/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/spokes/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/global/policyBasedRoutes/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/serviceConnectionMaps/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/serviceConnectionPolicies/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/serviceClasses/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/internalRanges/*}:getIamPolicy',}], - },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1/{resource=projects/*/locations/global/hubs/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/global/hubs/*/groups/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/spokes/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/global/policyBasedRoutes/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceConnectionMaps/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceConnectionPolicies/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceClasses/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/internalRanges/*}:setIamPolicy',body: '*',}], - },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1/{resource=projects/*/locations/global/hubs/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/global/hubs/*/groups/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/spokes/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/global/policyBasedRoutes/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceConnectionMaps/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceConnectionPolicies/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceClasses/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/internalRanges/*}:testIamPermissions',body: '*',}], - },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1/{resource=projects/*/locations/global/hubs/*}:getIamPolicy', + additional_bindings: [ + { + get: '/v1/{resource=projects/*/locations/global/hubs/*/groups/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/spokes/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/global/policyBasedRoutes/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/serviceConnectionMaps/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/serviceConnectionPolicies/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/serviceClasses/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/internalRanges/*}:getIamPolicy', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1/{resource=projects/*/locations/global/hubs/*}:setIamPolicy', + body: '*', + additional_bindings: [ + { + post: '/v1/{resource=projects/*/locations/global/hubs/*/groups/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/spokes/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/global/policyBasedRoutes/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceConnectionMaps/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceConnectionPolicies/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceClasses/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/internalRanges/*}:setIamPolicy', + body: '*', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1/{resource=projects/*/locations/global/hubs/*}:testIamPermissions', + body: '*', + additional_bindings: [ + { + post: '/v1/{resource=projects/*/locations/global/hubs/*/groups/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/spokes/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/global/policyBasedRoutes/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceConnectionMaps/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceConnectionPolicies/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceClasses/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/internalRanges/*}:testIamPermissions', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createHubResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.Hub') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.Hub', + ) as gax.protobuf.Type; const createHubMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateHubResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.Hub') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.Hub', + ) as gax.protobuf.Type; const updateHubMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteHubResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteHubMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; const createSpokeResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.Spoke') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.Spoke', + ) as gax.protobuf.Type; const createSpokeMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateSpokeResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.Spoke') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.Spoke', + ) as gax.protobuf.Type; const updateSpokeMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; const rejectHubSpokeResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.RejectHubSpokeResponse') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.RejectHubSpokeResponse', + ) as gax.protobuf.Type; const rejectHubSpokeMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; const acceptHubSpokeResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.AcceptHubSpokeResponse') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.AcceptHubSpokeResponse', + ) as gax.protobuf.Type; const acceptHubSpokeMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; const acceptSpokeUpdateResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.AcceptSpokeUpdateResponse') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.AcceptSpokeUpdateResponse', + ) as gax.protobuf.Type; const acceptSpokeUpdateMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; const rejectSpokeUpdateResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.RejectSpokeUpdateResponse') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.RejectSpokeUpdateResponse', + ) as gax.protobuf.Type; const rejectSpokeUpdateMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteSpokeResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteSpokeMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateGroupResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.Group') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.Group', + ) as gax.protobuf.Type; const updateGroupMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createHub: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createHubResponse.decode.bind(createHubResponse), - createHubMetadata.decode.bind(createHubMetadata)), + createHubMetadata.decode.bind(createHubMetadata), + ), updateHub: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateHubResponse.decode.bind(updateHubResponse), - updateHubMetadata.decode.bind(updateHubMetadata)), + updateHubMetadata.decode.bind(updateHubMetadata), + ), deleteHub: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteHubResponse.decode.bind(deleteHubResponse), - deleteHubMetadata.decode.bind(deleteHubMetadata)), + deleteHubMetadata.decode.bind(deleteHubMetadata), + ), createSpoke: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createSpokeResponse.decode.bind(createSpokeResponse), - createSpokeMetadata.decode.bind(createSpokeMetadata)), + createSpokeMetadata.decode.bind(createSpokeMetadata), + ), updateSpoke: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateSpokeResponse.decode.bind(updateSpokeResponse), - updateSpokeMetadata.decode.bind(updateSpokeMetadata)), + updateSpokeMetadata.decode.bind(updateSpokeMetadata), + ), rejectHubSpoke: new this._gaxModule.LongrunningDescriptor( this.operationsClient, rejectHubSpokeResponse.decode.bind(rejectHubSpokeResponse), - rejectHubSpokeMetadata.decode.bind(rejectHubSpokeMetadata)), + rejectHubSpokeMetadata.decode.bind(rejectHubSpokeMetadata), + ), acceptHubSpoke: new this._gaxModule.LongrunningDescriptor( this.operationsClient, acceptHubSpokeResponse.decode.bind(acceptHubSpokeResponse), - acceptHubSpokeMetadata.decode.bind(acceptHubSpokeMetadata)), + acceptHubSpokeMetadata.decode.bind(acceptHubSpokeMetadata), + ), acceptSpokeUpdate: new this._gaxModule.LongrunningDescriptor( this.operationsClient, acceptSpokeUpdateResponse.decode.bind(acceptSpokeUpdateResponse), - acceptSpokeUpdateMetadata.decode.bind(acceptSpokeUpdateMetadata)), + acceptSpokeUpdateMetadata.decode.bind(acceptSpokeUpdateMetadata), + ), rejectSpokeUpdate: new this._gaxModule.LongrunningDescriptor( this.operationsClient, rejectSpokeUpdateResponse.decode.bind(rejectSpokeUpdateResponse), - rejectSpokeUpdateMetadata.decode.bind(rejectSpokeUpdateMetadata)), + rejectSpokeUpdateMetadata.decode.bind(rejectSpokeUpdateMetadata), + ), deleteSpoke: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteSpokeResponse.decode.bind(deleteSpokeResponse), - deleteSpokeMetadata.decode.bind(deleteSpokeMetadata)), + deleteSpokeMetadata.decode.bind(deleteSpokeMetadata), + ), updateGroup: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateGroupResponse.decode.bind(updateGroupResponse), - updateGroupMetadata.decode.bind(updateGroupMetadata)) + updateGroupMetadata.decode.bind(updateGroupMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.networkconnectivity.v1.HubService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.networkconnectivity.v1.HubService', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -410,28 +621,57 @@ export class HubServiceClient { // Put together the "service stub" for // google.cloud.networkconnectivity.v1.HubService. this.hubServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.networkconnectivity.v1.HubService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.networkconnectivity.v1.HubService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.networkconnectivity.v1.HubService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const hubServiceStubMethods = - ['listHubs', 'getHub', 'createHub', 'updateHub', 'deleteHub', 'listHubSpokes', 'queryHubStatus', 'listSpokes', 'getSpoke', 'createSpoke', 'updateSpoke', 'rejectHubSpoke', 'acceptHubSpoke', 'acceptSpokeUpdate', 'rejectSpokeUpdate', 'deleteSpoke', 'getRouteTable', 'getRoute', 'listRoutes', 'listRouteTables', 'getGroup', 'listGroups', 'updateGroup']; + const hubServiceStubMethods = [ + 'listHubs', + 'getHub', + 'createHub', + 'updateHub', + 'deleteHub', + 'listHubSpokes', + 'queryHubStatus', + 'listSpokes', + 'getSpoke', + 'createSpoke', + 'updateSpoke', + 'rejectHubSpoke', + 'acceptHubSpoke', + 'acceptSpokeUpdate', + 'rejectSpokeUpdate', + 'deleteSpoke', + 'getRouteTable', + 'getRoute', + 'listRoutes', + 'listRouteTables', + 'getGroup', + 'listGroups', + 'updateGroup', + ]; for (const methodName of hubServiceStubMethods) { const callPromise = this.hubServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -441,7 +681,7 @@ export class HubServiceClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -456,8 +696,14 @@ export class HubServiceClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkconnectivity.googleapis.com'; } @@ -468,8 +714,14 @@ export class HubServiceClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkconnectivity.googleapis.com'; } @@ -500,9 +752,7 @@ export class HubServiceClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -511,8 +761,9 @@ export class HubServiceClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -523,1951 +774,2876 @@ export class HubServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets details about a Network Connectivity Center hub. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the hub resource to get. - * @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 {@link protos.google.cloud.networkconnectivity.v1.Hub|Hub}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/hub_service.get_hub.js - * region_tag:networkconnectivity_v1_generated_HubService_GetHub_async - */ + /** + * Gets details about a Network Connectivity Center hub. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the hub resource to get. + * @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 {@link protos.google.cloud.networkconnectivity.v1.Hub|Hub}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/hub_service.get_hub.js + * region_tag:networkconnectivity_v1_generated_HubService_GetHub_async + */ getHub( - request?: protos.google.cloud.networkconnectivity.v1.IGetHubRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IHub, - protos.google.cloud.networkconnectivity.v1.IGetHubRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IGetHubRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IHub, + protos.google.cloud.networkconnectivity.v1.IGetHubRequest | undefined, + {} | undefined, + ] + >; getHub( - request: protos.google.cloud.networkconnectivity.v1.IGetHubRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkconnectivity.v1.IHub, - protos.google.cloud.networkconnectivity.v1.IGetHubRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IGetHubRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkconnectivity.v1.IHub, + | protos.google.cloud.networkconnectivity.v1.IGetHubRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getHub( - request: protos.google.cloud.networkconnectivity.v1.IGetHubRequest, - callback: Callback< - protos.google.cloud.networkconnectivity.v1.IHub, - protos.google.cloud.networkconnectivity.v1.IGetHubRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IGetHubRequest, + callback: Callback< + protos.google.cloud.networkconnectivity.v1.IHub, + | protos.google.cloud.networkconnectivity.v1.IGetHubRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getHub( - request?: protos.google.cloud.networkconnectivity.v1.IGetHubRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkconnectivity.v1.IHub, - protos.google.cloud.networkconnectivity.v1.IGetHubRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkconnectivity.v1.IGetHubRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkconnectivity.v1.IHub, - protos.google.cloud.networkconnectivity.v1.IGetHubRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IHub, - protos.google.cloud.networkconnectivity.v1.IGetHubRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkconnectivity.v1.IGetHubRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkconnectivity.v1.IHub, + | protos.google.cloud.networkconnectivity.v1.IGetHubRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IHub, + protos.google.cloud.networkconnectivity.v1.IGetHubRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getHub request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkconnectivity.v1.IHub, - protos.google.cloud.networkconnectivity.v1.IGetHubRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkconnectivity.v1.IHub, + | protos.google.cloud.networkconnectivity.v1.IGetHubRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getHub response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getHub(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkconnectivity.v1.IHub, - protos.google.cloud.networkconnectivity.v1.IGetHubRequest|undefined, - {}|undefined - ]) => { - this._log.info('getHub response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getHub(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkconnectivity.v1.IHub, + protos.google.cloud.networkconnectivity.v1.IGetHubRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getHub response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details about a Network Connectivity Center spoke. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the spoke resource. - * @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 {@link protos.google.cloud.networkconnectivity.v1.Spoke|Spoke}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/hub_service.get_spoke.js - * region_tag:networkconnectivity_v1_generated_HubService_GetSpoke_async - */ + /** + * Gets details about a Network Connectivity Center spoke. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the spoke resource. + * @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 {@link protos.google.cloud.networkconnectivity.v1.Spoke|Spoke}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/hub_service.get_spoke.js + * region_tag:networkconnectivity_v1_generated_HubService_GetSpoke_async + */ getSpoke( - request?: protos.google.cloud.networkconnectivity.v1.IGetSpokeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1.ISpoke, - protos.google.cloud.networkconnectivity.v1.IGetSpokeRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IGetSpokeRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.ISpoke, + protos.google.cloud.networkconnectivity.v1.IGetSpokeRequest | undefined, + {} | undefined, + ] + >; getSpoke( - request: protos.google.cloud.networkconnectivity.v1.IGetSpokeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkconnectivity.v1.ISpoke, - protos.google.cloud.networkconnectivity.v1.IGetSpokeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IGetSpokeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkconnectivity.v1.ISpoke, + | protos.google.cloud.networkconnectivity.v1.IGetSpokeRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getSpoke( - request: protos.google.cloud.networkconnectivity.v1.IGetSpokeRequest, - callback: Callback< - protos.google.cloud.networkconnectivity.v1.ISpoke, - protos.google.cloud.networkconnectivity.v1.IGetSpokeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IGetSpokeRequest, + callback: Callback< + protos.google.cloud.networkconnectivity.v1.ISpoke, + | protos.google.cloud.networkconnectivity.v1.IGetSpokeRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getSpoke( - request?: protos.google.cloud.networkconnectivity.v1.IGetSpokeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkconnectivity.v1.ISpoke, - protos.google.cloud.networkconnectivity.v1.IGetSpokeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkconnectivity.v1.IGetSpokeRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkconnectivity.v1.ISpoke, - protos.google.cloud.networkconnectivity.v1.IGetSpokeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkconnectivity.v1.ISpoke, - protos.google.cloud.networkconnectivity.v1.IGetSpokeRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkconnectivity.v1.IGetSpokeRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkconnectivity.v1.ISpoke, + | protos.google.cloud.networkconnectivity.v1.IGetSpokeRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.ISpoke, + protos.google.cloud.networkconnectivity.v1.IGetSpokeRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getSpoke request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkconnectivity.v1.ISpoke, - protos.google.cloud.networkconnectivity.v1.IGetSpokeRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkconnectivity.v1.ISpoke, + | protos.google.cloud.networkconnectivity.v1.IGetSpokeRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getSpoke response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getSpoke(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkconnectivity.v1.ISpoke, - protos.google.cloud.networkconnectivity.v1.IGetSpokeRequest|undefined, - {}|undefined - ]) => { - this._log.info('getSpoke response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getSpoke(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkconnectivity.v1.ISpoke, + ( + | protos.google.cloud.networkconnectivity.v1.IGetSpokeRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getSpoke response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details about a Network Connectivity Center route table. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the route table resource. - * @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 {@link protos.google.cloud.networkconnectivity.v1.RouteTable|RouteTable}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/hub_service.get_route_table.js - * region_tag:networkconnectivity_v1_generated_HubService_GetRouteTable_async - */ + /** + * Gets details about a Network Connectivity Center route table. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the route table resource. + * @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 {@link protos.google.cloud.networkconnectivity.v1.RouteTable|RouteTable}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/hub_service.get_route_table.js + * region_tag:networkconnectivity_v1_generated_HubService_GetRouteTable_async + */ getRouteTable( - request?: protos.google.cloud.networkconnectivity.v1.IGetRouteTableRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IRouteTable, - protos.google.cloud.networkconnectivity.v1.IGetRouteTableRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IGetRouteTableRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IRouteTable, + ( + | protos.google.cloud.networkconnectivity.v1.IGetRouteTableRequest + | undefined + ), + {} | undefined, + ] + >; getRouteTable( - request: protos.google.cloud.networkconnectivity.v1.IGetRouteTableRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkconnectivity.v1.IRouteTable, - protos.google.cloud.networkconnectivity.v1.IGetRouteTableRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IGetRouteTableRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkconnectivity.v1.IRouteTable, + | protos.google.cloud.networkconnectivity.v1.IGetRouteTableRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getRouteTable( - request: protos.google.cloud.networkconnectivity.v1.IGetRouteTableRequest, - callback: Callback< - protos.google.cloud.networkconnectivity.v1.IRouteTable, - protos.google.cloud.networkconnectivity.v1.IGetRouteTableRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IGetRouteTableRequest, + callback: Callback< + protos.google.cloud.networkconnectivity.v1.IRouteTable, + | protos.google.cloud.networkconnectivity.v1.IGetRouteTableRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getRouteTable( - request?: protos.google.cloud.networkconnectivity.v1.IGetRouteTableRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkconnectivity.v1.IRouteTable, - protos.google.cloud.networkconnectivity.v1.IGetRouteTableRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkconnectivity.v1.IGetRouteTableRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkconnectivity.v1.IRouteTable, - protos.google.cloud.networkconnectivity.v1.IGetRouteTableRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IRouteTable, - protos.google.cloud.networkconnectivity.v1.IGetRouteTableRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkconnectivity.v1.IGetRouteTableRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkconnectivity.v1.IRouteTable, + | protos.google.cloud.networkconnectivity.v1.IGetRouteTableRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IRouteTable, + ( + | protos.google.cloud.networkconnectivity.v1.IGetRouteTableRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getRouteTable request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkconnectivity.v1.IRouteTable, - protos.google.cloud.networkconnectivity.v1.IGetRouteTableRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkconnectivity.v1.IRouteTable, + | protos.google.cloud.networkconnectivity.v1.IGetRouteTableRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getRouteTable response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getRouteTable(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkconnectivity.v1.IRouteTable, - protos.google.cloud.networkconnectivity.v1.IGetRouteTableRequest|undefined, - {}|undefined - ]) => { - this._log.info('getRouteTable response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getRouteTable(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkconnectivity.v1.IRouteTable, + ( + | protos.google.cloud.networkconnectivity.v1.IGetRouteTableRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getRouteTable response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details about the specified route. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the route resource. - * @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 {@link protos.google.cloud.networkconnectivity.v1.Route|Route}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/hub_service.get_route.js - * region_tag:networkconnectivity_v1_generated_HubService_GetRoute_async - */ + /** + * Gets details about the specified route. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the route resource. + * @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 {@link protos.google.cloud.networkconnectivity.v1.Route|Route}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/hub_service.get_route.js + * region_tag:networkconnectivity_v1_generated_HubService_GetRoute_async + */ getRoute( - request?: protos.google.cloud.networkconnectivity.v1.IGetRouteRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IRoute, - protos.google.cloud.networkconnectivity.v1.IGetRouteRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IGetRouteRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IRoute, + protos.google.cloud.networkconnectivity.v1.IGetRouteRequest | undefined, + {} | undefined, + ] + >; getRoute( - request: protos.google.cloud.networkconnectivity.v1.IGetRouteRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkconnectivity.v1.IRoute, - protos.google.cloud.networkconnectivity.v1.IGetRouteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IGetRouteRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkconnectivity.v1.IRoute, + | protos.google.cloud.networkconnectivity.v1.IGetRouteRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getRoute( - request: protos.google.cloud.networkconnectivity.v1.IGetRouteRequest, - callback: Callback< - protos.google.cloud.networkconnectivity.v1.IRoute, - protos.google.cloud.networkconnectivity.v1.IGetRouteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IGetRouteRequest, + callback: Callback< + protos.google.cloud.networkconnectivity.v1.IRoute, + | protos.google.cloud.networkconnectivity.v1.IGetRouteRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getRoute( - request?: protos.google.cloud.networkconnectivity.v1.IGetRouteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkconnectivity.v1.IRoute, - protos.google.cloud.networkconnectivity.v1.IGetRouteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkconnectivity.v1.IGetRouteRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkconnectivity.v1.IRoute, - protos.google.cloud.networkconnectivity.v1.IGetRouteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IRoute, - protos.google.cloud.networkconnectivity.v1.IGetRouteRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkconnectivity.v1.IGetRouteRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkconnectivity.v1.IRoute, + | protos.google.cloud.networkconnectivity.v1.IGetRouteRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IRoute, + protos.google.cloud.networkconnectivity.v1.IGetRouteRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getRoute request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkconnectivity.v1.IRoute, - protos.google.cloud.networkconnectivity.v1.IGetRouteRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkconnectivity.v1.IRoute, + | protos.google.cloud.networkconnectivity.v1.IGetRouteRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getRoute response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getRoute(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkconnectivity.v1.IRoute, - protos.google.cloud.networkconnectivity.v1.IGetRouteRequest|undefined, - {}|undefined - ]) => { - this._log.info('getRoute response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getRoute(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkconnectivity.v1.IRoute, + ( + | protos.google.cloud.networkconnectivity.v1.IGetRouteRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getRoute response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details about a Network Connectivity Center group. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the route table resource. - * @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 {@link protos.google.cloud.networkconnectivity.v1.Group|Group}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/hub_service.get_group.js - * region_tag:networkconnectivity_v1_generated_HubService_GetGroup_async - */ + /** + * Gets details about a Network Connectivity Center group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the route table resource. + * @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 {@link protos.google.cloud.networkconnectivity.v1.Group|Group}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/hub_service.get_group.js + * region_tag:networkconnectivity_v1_generated_HubService_GetGroup_async + */ getGroup( - request?: protos.google.cloud.networkconnectivity.v1.IGetGroupRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IGroup, - protos.google.cloud.networkconnectivity.v1.IGetGroupRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IGetGroupRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IGroup, + protos.google.cloud.networkconnectivity.v1.IGetGroupRequest | undefined, + {} | undefined, + ] + >; getGroup( - request: protos.google.cloud.networkconnectivity.v1.IGetGroupRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkconnectivity.v1.IGroup, - protos.google.cloud.networkconnectivity.v1.IGetGroupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IGetGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkconnectivity.v1.IGroup, + | protos.google.cloud.networkconnectivity.v1.IGetGroupRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getGroup( - request: protos.google.cloud.networkconnectivity.v1.IGetGroupRequest, - callback: Callback< - protos.google.cloud.networkconnectivity.v1.IGroup, - protos.google.cloud.networkconnectivity.v1.IGetGroupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IGetGroupRequest, + callback: Callback< + protos.google.cloud.networkconnectivity.v1.IGroup, + | protos.google.cloud.networkconnectivity.v1.IGetGroupRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getGroup( - request?: protos.google.cloud.networkconnectivity.v1.IGetGroupRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkconnectivity.v1.IGroup, - protos.google.cloud.networkconnectivity.v1.IGetGroupRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkconnectivity.v1.IGetGroupRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkconnectivity.v1.IGroup, - protos.google.cloud.networkconnectivity.v1.IGetGroupRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IGroup, - protos.google.cloud.networkconnectivity.v1.IGetGroupRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; + | protos.google.cloud.networkconnectivity.v1.IGetGroupRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkconnectivity.v1.IGroup, + | protos.google.cloud.networkconnectivity.v1.IGetGroupRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IGroup, + protos.google.cloud.networkconnectivity.v1.IGetGroupRequest | undefined, + {} | undefined, + ] + > | void { + request = request || {}; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getGroup request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkconnectivity.v1.IGroup, - protos.google.cloud.networkconnectivity.v1.IGetGroupRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkconnectivity.v1.IGroup, + | protos.google.cloud.networkconnectivity.v1.IGetGroupRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getGroup response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getGroup(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkconnectivity.v1.IGroup, - protos.google.cloud.networkconnectivity.v1.IGetGroupRequest|undefined, - {}|undefined - ]) => { - this._log.info('getGroup response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getGroup(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkconnectivity.v1.IGroup, + ( + | protos.google.cloud.networkconnectivity.v1.IGetGroupRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getGroup response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a new Network Connectivity Center hub in the specified project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource. - * @param {string} request.hubId - * Required. A unique identifier for the hub. - * @param {google.cloud.networkconnectivity.v1.Hub} request.hub - * Required. The initial values for a new hub. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * The request ID must be a valid UUID, with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/hub_service.create_hub.js - * region_tag:networkconnectivity_v1_generated_HubService_CreateHub_async - */ + /** + * Creates a new Network Connectivity Center hub in the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource. + * @param {string} request.hubId + * Required. A unique identifier for the hub. + * @param {google.cloud.networkconnectivity.v1.Hub} request.hub + * Required. The initial values for a new hub. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID so + * that if you must retry your request, the server knows to ignore the request + * if it has already been completed. The server guarantees that a request + * doesn't result in creation of duplicate commitments for at least 60 + * minutes. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check to see whether the original operation + * was received. If it was, the server ignores the second request. This + * behavior prevents clients from mistakenly creating duplicate commitments. + * + * The request ID must be a valid UUID, with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/hub_service.create_hub.js + * region_tag:networkconnectivity_v1_generated_HubService_CreateHub_async + */ createHub( - request?: protos.google.cloud.networkconnectivity.v1.ICreateHubRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.ICreateHubRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IHub, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createHub( - request: protos.google.cloud.networkconnectivity.v1.ICreateHubRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.ICreateHubRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IHub, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createHub( - request: protos.google.cloud.networkconnectivity.v1.ICreateHubRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.ICreateHubRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IHub, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createHub( - request?: protos.google.cloud.networkconnectivity.v1.ICreateHubRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1.ICreateHubRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IHub, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IHub, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IHub, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IHub, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createHub response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createHub request %j', request); - return this.innerApiCalls.createHub(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createHub response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createHub(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IHub, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createHub response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createHub()`. - * @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/hub_service.create_hub.js - * region_tag:networkconnectivity_v1_generated_HubService_CreateHub_async - */ - async checkCreateHubProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createHub()`. + * @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/hub_service.create_hub.js + * region_tag:networkconnectivity_v1_generated_HubService_CreateHub_async + */ + async checkCreateHubProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1.Hub, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('createHub long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createHub, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createHub, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1.Hub, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; } -/** - * Updates the description and/or labels of a Network Connectivity Center - * hub. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. In the case of an update to an existing hub, field mask is used - * to specify the fields to be overwritten. The fields specified in the - * update_mask are relative to the resource, not the full request. A field is - * overwritten if it is in the mask. If the user does not provide a mask, then - * all fields are overwritten. - * @param {google.cloud.networkconnectivity.v1.Hub} request.hub - * Required. The state that the hub should be in after the update. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * The request ID must be a valid UUID, with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/hub_service.update_hub.js - * region_tag:networkconnectivity_v1_generated_HubService_UpdateHub_async - */ + /** + * Updates the description and/or labels of a Network Connectivity Center + * hub. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. In the case of an update to an existing hub, field mask is used + * to specify the fields to be overwritten. The fields specified in the + * update_mask are relative to the resource, not the full request. A field is + * overwritten if it is in the mask. If the user does not provide a mask, then + * all fields are overwritten. + * @param {google.cloud.networkconnectivity.v1.Hub} request.hub + * Required. The state that the hub should be in after the update. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID so + * that if you must retry your request, the server knows to ignore the request + * if it has already been completed. The server guarantees that a request + * doesn't result in creation of duplicate commitments for at least 60 + * minutes. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check to see whether the original operation + * was received. If it was, the server ignores the second request. This + * behavior prevents clients from mistakenly creating duplicate commitments. + * + * The request ID must be a valid UUID, with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/hub_service.update_hub.js + * region_tag:networkconnectivity_v1_generated_HubService_UpdateHub_async + */ updateHub( - request?: protos.google.cloud.networkconnectivity.v1.IUpdateHubRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IUpdateHubRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IHub, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateHub( - request: protos.google.cloud.networkconnectivity.v1.IUpdateHubRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IUpdateHubRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IHub, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateHub( - request: protos.google.cloud.networkconnectivity.v1.IUpdateHubRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IUpdateHubRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IHub, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateHub( - request?: protos.google.cloud.networkconnectivity.v1.IUpdateHubRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1.IUpdateHubRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IHub, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IHub, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IHub, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'hub.name': request.hub!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'hub.name': request.hub!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IHub, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateHub response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateHub request %j', request); - return this.innerApiCalls.updateHub(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateHub response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateHub(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IHub, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateHub response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateHub()`. - * @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/hub_service.update_hub.js - * region_tag:networkconnectivity_v1_generated_HubService_UpdateHub_async - */ - async checkUpdateHubProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateHub()`. + * @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/hub_service.update_hub.js + * region_tag:networkconnectivity_v1_generated_HubService_UpdateHub_async + */ + async checkUpdateHubProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1.Hub, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('updateHub long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateHub, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateHub, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1.Hub, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; } -/** - * Deletes a Network Connectivity Center hub. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the hub to delete. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * The request ID must be a valid UUID, with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/hub_service.delete_hub.js - * region_tag:networkconnectivity_v1_generated_HubService_DeleteHub_async - */ + /** + * Deletes a Network Connectivity Center hub. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the hub to delete. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID so + * that if you must retry your request, the server knows to ignore the request + * if it has already been completed. The server guarantees that a request + * doesn't result in creation of duplicate commitments for at least 60 + * minutes. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check to see whether the original operation + * was received. If it was, the server ignores the second request. This + * behavior prevents clients from mistakenly creating duplicate commitments. + * + * The request ID must be a valid UUID, with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/hub_service.delete_hub.js + * region_tag:networkconnectivity_v1_generated_HubService_DeleteHub_async + */ deleteHub( - request?: protos.google.cloud.networkconnectivity.v1.IDeleteHubRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IDeleteHubRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteHub( - request: protos.google.cloud.networkconnectivity.v1.IDeleteHubRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IDeleteHubRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteHub( - request: protos.google.cloud.networkconnectivity.v1.IDeleteHubRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IDeleteHubRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteHub( - request?: protos.google.cloud.networkconnectivity.v1.IDeleteHubRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1.IDeleteHubRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteHub response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteHub request %j', request); - return this.innerApiCalls.deleteHub(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteHub response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteHub(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteHub response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteHub()`. - * @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/hub_service.delete_hub.js - * region_tag:networkconnectivity_v1_generated_HubService_DeleteHub_async - */ - async checkDeleteHubProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteHub()`. + * @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/hub_service.delete_hub.js + * region_tag:networkconnectivity_v1_generated_HubService_DeleteHub_async + */ + async checkDeleteHubProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('deleteHub long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteHub, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteHub, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; } -/** - * Creates a Network Connectivity Center spoke. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource. - * @param {string} request.spokeId - * Required. Unique id for the spoke to create. - * @param {google.cloud.networkconnectivity.v1.Spoke} request.spoke - * Required. The initial values for a new spoke. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * The request ID must be a valid UUID, with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/hub_service.create_spoke.js - * region_tag:networkconnectivity_v1_generated_HubService_CreateSpoke_async - */ + /** + * Creates a Network Connectivity Center spoke. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource. + * @param {string} request.spokeId + * Required. Unique id for the spoke to create. + * @param {google.cloud.networkconnectivity.v1.Spoke} request.spoke + * Required. The initial values for a new spoke. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID so + * that if you must retry your request, the server knows to ignore the request + * if it has already been completed. The server guarantees that a request + * doesn't result in creation of duplicate commitments for at least 60 + * minutes. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check to see whether the original operation + * was received. If it was, the server ignores the second request. This + * behavior prevents clients from mistakenly creating duplicate commitments. + * + * The request ID must be a valid UUID, with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/hub_service.create_spoke.js + * region_tag:networkconnectivity_v1_generated_HubService_CreateSpoke_async + */ createSpoke( - request?: protos.google.cloud.networkconnectivity.v1.ICreateSpokeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.ICreateSpokeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.ISpoke, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createSpoke( - request: protos.google.cloud.networkconnectivity.v1.ICreateSpokeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.ICreateSpokeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.ISpoke, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createSpoke( - request: protos.google.cloud.networkconnectivity.v1.ICreateSpokeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.ICreateSpokeRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.ISpoke, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createSpoke( - request?: protos.google.cloud.networkconnectivity.v1.ICreateSpokeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1.ICreateSpokeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.ISpoke, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.ISpoke, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.ISpoke, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.ISpoke, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createSpoke response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createSpoke request %j', request); - return this.innerApiCalls.createSpoke(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createSpoke response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createSpoke(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1.ISpoke, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createSpoke response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createSpoke()`. - * @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/hub_service.create_spoke.js - * region_tag:networkconnectivity_v1_generated_HubService_CreateSpoke_async - */ - async checkCreateSpokeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createSpoke()`. + * @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/hub_service.create_spoke.js + * region_tag:networkconnectivity_v1_generated_HubService_CreateSpoke_async + */ + async checkCreateSpokeProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1.Spoke, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('createSpoke long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createSpoke, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createSpoke, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1.Spoke, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; } -/** - * Updates the parameters of a Network Connectivity Center spoke. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. In the case of an update to an existing spoke, field mask is used - * to specify the fields to be overwritten. The fields specified in the - * update_mask are relative to the resource, not the full request. A field is - * overwritten if it is in the mask. If the user does not provide a mask, then - * all fields are overwritten. - * @param {google.cloud.networkconnectivity.v1.Spoke} request.spoke - * Required. The state that the spoke should be in after the update. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * The request ID must be a valid UUID, with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/hub_service.update_spoke.js - * region_tag:networkconnectivity_v1_generated_HubService_UpdateSpoke_async - */ + /** + * Updates the parameters of a Network Connectivity Center spoke. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. In the case of an update to an existing spoke, field mask is used + * to specify the fields to be overwritten. The fields specified in the + * update_mask are relative to the resource, not the full request. A field is + * overwritten if it is in the mask. If the user does not provide a mask, then + * all fields are overwritten. + * @param {google.cloud.networkconnectivity.v1.Spoke} request.spoke + * Required. The state that the spoke should be in after the update. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID so + * that if you must retry your request, the server knows to ignore the request + * if it has already been completed. The server guarantees that a request + * doesn't result in creation of duplicate commitments for at least 60 + * minutes. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check to see whether the original operation + * was received. If it was, the server ignores the second request. This + * behavior prevents clients from mistakenly creating duplicate commitments. + * + * The request ID must be a valid UUID, with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/hub_service.update_spoke.js + * region_tag:networkconnectivity_v1_generated_HubService_UpdateSpoke_async + */ updateSpoke( - request?: protos.google.cloud.networkconnectivity.v1.IUpdateSpokeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IUpdateSpokeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.ISpoke, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateSpoke( - request: protos.google.cloud.networkconnectivity.v1.IUpdateSpokeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IUpdateSpokeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.ISpoke, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateSpoke( - request: protos.google.cloud.networkconnectivity.v1.IUpdateSpokeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IUpdateSpokeRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.ISpoke, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateSpoke( - request?: protos.google.cloud.networkconnectivity.v1.IUpdateSpokeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1.IUpdateSpokeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.ISpoke, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.ISpoke, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.ISpoke, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'spoke.name': request.spoke!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'spoke.name': request.spoke!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.ISpoke, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateSpoke response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateSpoke request %j', request); - return this.innerApiCalls.updateSpoke(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateSpoke response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateSpoke(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1.ISpoke, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateSpoke response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateSpoke()`. - * @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/hub_service.update_spoke.js - * region_tag:networkconnectivity_v1_generated_HubService_UpdateSpoke_async - */ - async checkUpdateSpokeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateSpoke()`. + * @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/hub_service.update_spoke.js + * region_tag:networkconnectivity_v1_generated_HubService_UpdateSpoke_async + */ + async checkUpdateSpokeProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1.Spoke, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('updateSpoke long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateSpoke, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateSpoke, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1.Spoke, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; } -/** - * Rejects a Network Connectivity Center spoke from being attached to a hub. - * If the spoke was previously in the `ACTIVE` state, it - * transitions to the `INACTIVE` state and is no longer able to - * connect to other spokes that are attached to the hub. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the hub from which to reject the spoke. - * @param {string} request.spokeUri - * Required. The URI of the spoke to reject from the hub. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * 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.details] - * Optional. Additional information provided by the hub administrator. - * @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/hub_service.reject_hub_spoke.js - * region_tag:networkconnectivity_v1_generated_HubService_RejectHubSpoke_async - */ + /** + * Rejects a Network Connectivity Center spoke from being attached to a hub. + * If the spoke was previously in the `ACTIVE` state, it + * transitions to the `INACTIVE` state and is no longer able to + * connect to other spokes that are attached to the hub. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the hub from which to reject the spoke. + * @param {string} request.spokeUri + * Required. The URI of the spoke to reject from the hub. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID so + * that if you must retry your request, the server knows to ignore the request + * if it has already been completed. The server guarantees that a request + * doesn't result in creation of duplicate commitments for at least 60 + * minutes. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check to see whether the original operation + * was received. If it was, the server ignores the second request. This + * behavior prevents clients from mistakenly creating duplicate commitments. + * + * 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.details] + * Optional. Additional information provided by the hub administrator. + * @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/hub_service.reject_hub_spoke.js + * region_tag:networkconnectivity_v1_generated_HubService_RejectHubSpoke_async + */ rejectHubSpoke( - request?: protos.google.cloud.networkconnectivity.v1.IRejectHubSpokeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IRejectHubSpokeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IRejectHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; rejectHubSpoke( - request: protos.google.cloud.networkconnectivity.v1.IRejectHubSpokeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IRejectHubSpokeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IRejectHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; rejectHubSpoke( - request: protos.google.cloud.networkconnectivity.v1.IRejectHubSpokeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IRejectHubSpokeRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IRejectHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; rejectHubSpoke( - request?: protos.google.cloud.networkconnectivity.v1.IRejectHubSpokeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1.IRejectHubSpokeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IRejectHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IRejectHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IRejectHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IRejectHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('rejectHubSpoke response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('rejectHubSpoke request %j', request); - return this.innerApiCalls.rejectHubSpoke(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('rejectHubSpoke response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .rejectHubSpoke(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IRejectHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('rejectHubSpoke response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `rejectHubSpoke()`. - * @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/hub_service.reject_hub_spoke.js - * region_tag:networkconnectivity_v1_generated_HubService_RejectHubSpoke_async - */ - async checkRejectHubSpokeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `rejectHubSpoke()`. + * @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/hub_service.reject_hub_spoke.js + * region_tag:networkconnectivity_v1_generated_HubService_RejectHubSpoke_async + */ + async checkRejectHubSpokeProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1.RejectHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('rejectHubSpoke long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.rejectHubSpoke, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.rejectHubSpoke, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1.RejectHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; } -/** - * Accepts a proposal to attach a Network Connectivity Center spoke - * to a hub. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the hub into which to accept the spoke. - * @param {string} request.spokeUri - * Required. The URI of the spoke to accept into the hub. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * The request ID must be a valid UUID, with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/hub_service.accept_hub_spoke.js - * region_tag:networkconnectivity_v1_generated_HubService_AcceptHubSpoke_async - */ + /** + * Accepts a proposal to attach a Network Connectivity Center spoke + * to a hub. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the hub into which to accept the spoke. + * @param {string} request.spokeUri + * Required. The URI of the spoke to accept into the hub. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID so + * that if you must retry your request, the server knows to ignore the request + * if it has already been completed. The server guarantees that a request + * doesn't result in creation of duplicate commitments for at least 60 + * minutes. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check to see whether the original operation + * was received. If it was, the server ignores the second request. This + * behavior prevents clients from mistakenly creating duplicate commitments. + * + * The request ID must be a valid UUID, with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/hub_service.accept_hub_spoke.js + * region_tag:networkconnectivity_v1_generated_HubService_AcceptHubSpoke_async + */ acceptHubSpoke( - request?: protos.google.cloud.networkconnectivity.v1.IAcceptHubSpokeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IAcceptHubSpokeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IAcceptHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; acceptHubSpoke( - request: protos.google.cloud.networkconnectivity.v1.IAcceptHubSpokeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IAcceptHubSpokeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IAcceptHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; acceptHubSpoke( - request: protos.google.cloud.networkconnectivity.v1.IAcceptHubSpokeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IAcceptHubSpokeRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IAcceptHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; acceptHubSpoke( - request?: protos.google.cloud.networkconnectivity.v1.IAcceptHubSpokeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1.IAcceptHubSpokeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IAcceptHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IAcceptHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IAcceptHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IAcceptHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('acceptHubSpoke response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('acceptHubSpoke request %j', request); - return this.innerApiCalls.acceptHubSpoke(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('acceptHubSpoke response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .acceptHubSpoke(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IAcceptHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('acceptHubSpoke response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `acceptHubSpoke()`. - * @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/hub_service.accept_hub_spoke.js - * region_tag:networkconnectivity_v1_generated_HubService_AcceptHubSpoke_async - */ - async checkAcceptHubSpokeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `acceptHubSpoke()`. + * @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/hub_service.accept_hub_spoke.js + * region_tag:networkconnectivity_v1_generated_HubService_AcceptHubSpoke_async + */ + async checkAcceptHubSpokeProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1.AcceptHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('acceptHubSpoke long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.acceptHubSpoke, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.acceptHubSpoke, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1.AcceptHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; } -/** - * Accepts a proposal to update a Network Connectivity Center spoke in a hub. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the hub to accept spoke update. - * @param {string} request.spokeUri - * Required. The URI of the spoke to accept update. - * @param {string} request.spokeEtag - * Required. The etag of the spoke to accept update. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * The request ID must be a valid UUID, with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/hub_service.accept_spoke_update.js - * region_tag:networkconnectivity_v1_generated_HubService_AcceptSpokeUpdate_async - */ + /** + * Accepts a proposal to update a Network Connectivity Center spoke in a hub. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the hub to accept spoke update. + * @param {string} request.spokeUri + * Required. The URI of the spoke to accept update. + * @param {string} request.spokeEtag + * Required. The etag of the spoke to accept update. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID so + * that if you must retry your request, the server knows to ignore the request + * if it has already been completed. The server guarantees that a request + * doesn't result in creation of duplicate commitments for at least 60 + * minutes. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check to see whether the original operation + * was received. If it was, the server ignores the second request. This + * behavior prevents clients from mistakenly creating duplicate commitments. + * + * The request ID must be a valid UUID, with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/hub_service.accept_spoke_update.js + * region_tag:networkconnectivity_v1_generated_HubService_AcceptSpokeUpdate_async + */ acceptSpokeUpdate( - request?: protos.google.cloud.networkconnectivity.v1.IAcceptSpokeUpdateRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IAcceptSpokeUpdateRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IAcceptSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; acceptSpokeUpdate( - request: protos.google.cloud.networkconnectivity.v1.IAcceptSpokeUpdateRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IAcceptSpokeUpdateRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IAcceptSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; acceptSpokeUpdate( - request: protos.google.cloud.networkconnectivity.v1.IAcceptSpokeUpdateRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IAcceptSpokeUpdateRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IAcceptSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; acceptSpokeUpdate( - request?: protos.google.cloud.networkconnectivity.v1.IAcceptSpokeUpdateRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1.IAcceptSpokeUpdateRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IAcceptSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IAcceptSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IAcceptSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IAcceptSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('acceptSpokeUpdate response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('acceptSpokeUpdate request %j', request); - return this.innerApiCalls.acceptSpokeUpdate(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('acceptSpokeUpdate response %j', rawResponse); - return [response, rawResponse, _]; - }); - } -/** - * Check the status of the long running operation returned by `acceptSpokeUpdate()`. - * @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/hub_service.accept_spoke_update.js - * region_tag:networkconnectivity_v1_generated_HubService_AcceptSpokeUpdate_async - */ - async checkAcceptSpokeUpdateProgress(name: string): Promise>{ + return this.innerApiCalls + .acceptSpokeUpdate(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IAcceptSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('acceptSpokeUpdate response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); + } + /** + * Check the status of the long running operation returned by `acceptSpokeUpdate()`. + * @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/hub_service.accept_spoke_update.js + * region_tag:networkconnectivity_v1_generated_HubService_AcceptSpokeUpdate_async + */ + async checkAcceptSpokeUpdateProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1.AcceptSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('acceptSpokeUpdate long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.acceptSpokeUpdate, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.acceptSpokeUpdate, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1.AcceptSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; } -/** - * Rejects a proposal to update a Network Connectivity Center spoke in a hub. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the hub to reject spoke update. - * @param {string} request.spokeUri - * Required. The URI of the spoke to reject update. - * @param {string} request.spokeEtag - * Required. The etag of the spoke to reject update. - * @param {string} [request.details] - * Optional. Additional information provided by the hub administrator. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * The request ID must be a valid UUID, with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/hub_service.reject_spoke_update.js - * region_tag:networkconnectivity_v1_generated_HubService_RejectSpokeUpdate_async - */ + /** + * Rejects a proposal to update a Network Connectivity Center spoke in a hub. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the hub to reject spoke update. + * @param {string} request.spokeUri + * Required. The URI of the spoke to reject update. + * @param {string} request.spokeEtag + * Required. The etag of the spoke to reject update. + * @param {string} [request.details] + * Optional. Additional information provided by the hub administrator. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID so + * that if you must retry your request, the server knows to ignore the request + * if it has already been completed. The server guarantees that a request + * doesn't result in creation of duplicate commitments for at least 60 + * minutes. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check to see whether the original operation + * was received. If it was, the server ignores the second request. This + * behavior prevents clients from mistakenly creating duplicate commitments. + * + * The request ID must be a valid UUID, with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/hub_service.reject_spoke_update.js + * region_tag:networkconnectivity_v1_generated_HubService_RejectSpokeUpdate_async + */ rejectSpokeUpdate( - request?: protos.google.cloud.networkconnectivity.v1.IRejectSpokeUpdateRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IRejectSpokeUpdateRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IRejectSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; rejectSpokeUpdate( - request: protos.google.cloud.networkconnectivity.v1.IRejectSpokeUpdateRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IRejectSpokeUpdateRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IRejectSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; rejectSpokeUpdate( - request: protos.google.cloud.networkconnectivity.v1.IRejectSpokeUpdateRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IRejectSpokeUpdateRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IRejectSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; rejectSpokeUpdate( - request?: protos.google.cloud.networkconnectivity.v1.IRejectSpokeUpdateRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1.IRejectSpokeUpdateRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IRejectSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IRejectSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IRejectSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IRejectSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('rejectSpokeUpdate response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('rejectSpokeUpdate request %j', request); - return this.innerApiCalls.rejectSpokeUpdate(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('rejectSpokeUpdate response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .rejectSpokeUpdate(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IRejectSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('rejectSpokeUpdate response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `rejectSpokeUpdate()`. - * @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/hub_service.reject_spoke_update.js - * region_tag:networkconnectivity_v1_generated_HubService_RejectSpokeUpdate_async - */ - async checkRejectSpokeUpdateProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `rejectSpokeUpdate()`. + * @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/hub_service.reject_spoke_update.js + * region_tag:networkconnectivity_v1_generated_HubService_RejectSpokeUpdate_async + */ + async checkRejectSpokeUpdateProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1.RejectSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('rejectSpokeUpdate long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.rejectSpokeUpdate, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.rejectSpokeUpdate, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1.RejectSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; } -/** - * Deletes a Network Connectivity Center spoke. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the spoke to delete. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * The request ID must be a valid UUID, with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/hub_service.delete_spoke.js - * region_tag:networkconnectivity_v1_generated_HubService_DeleteSpoke_async - */ + /** + * Deletes a Network Connectivity Center spoke. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the spoke to delete. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID so + * that if you must retry your request, the server knows to ignore the request + * if it has already been completed. The server guarantees that a request + * doesn't result in creation of duplicate commitments for at least 60 + * minutes. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check to see whether the original operation + * was received. If it was, the server ignores the second request. This + * behavior prevents clients from mistakenly creating duplicate commitments. + * + * The request ID must be a valid UUID, with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/hub_service.delete_spoke.js + * region_tag:networkconnectivity_v1_generated_HubService_DeleteSpoke_async + */ deleteSpoke( - request?: protos.google.cloud.networkconnectivity.v1.IDeleteSpokeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IDeleteSpokeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteSpoke( - request: protos.google.cloud.networkconnectivity.v1.IDeleteSpokeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IDeleteSpokeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteSpoke( - request: protos.google.cloud.networkconnectivity.v1.IDeleteSpokeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IDeleteSpokeRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteSpoke( - request?: protos.google.cloud.networkconnectivity.v1.IDeleteSpokeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1.IDeleteSpokeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteSpoke response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteSpoke request %j', request); - return this.innerApiCalls.deleteSpoke(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteSpoke response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteSpoke(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteSpoke response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteSpoke()`. - * @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/hub_service.delete_spoke.js - * region_tag:networkconnectivity_v1_generated_HubService_DeleteSpoke_async - */ - async checkDeleteSpokeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteSpoke()`. + * @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/hub_service.delete_spoke.js + * region_tag:networkconnectivity_v1_generated_HubService_DeleteSpoke_async + */ + async checkDeleteSpokeProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('deleteSpoke long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteSpoke, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteSpoke, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; } -/** - * Updates the parameters of a Network Connectivity Center group. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. In the case of an update to an existing group, field mask is used - * to specify the fields to be overwritten. The fields specified in the - * update_mask are relative to the resource, not the full request. A field is - * overwritten if it is in the mask. If the user does not provide a mask, then - * all fields are overwritten. - * @param {google.cloud.networkconnectivity.v1.Group} request.group - * Required. The state that the group should be in after the update. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * The request ID must be a valid UUID, with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/hub_service.update_group.js - * region_tag:networkconnectivity_v1_generated_HubService_UpdateGroup_async - */ + /** + * Updates the parameters of a Network Connectivity Center group. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. In the case of an update to an existing group, field mask is used + * to specify the fields to be overwritten. The fields specified in the + * update_mask are relative to the resource, not the full request. A field is + * overwritten if it is in the mask. If the user does not provide a mask, then + * all fields are overwritten. + * @param {google.cloud.networkconnectivity.v1.Group} request.group + * Required. The state that the group should be in after the update. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID so + * that if you must retry your request, the server knows to ignore the request + * if it has already been completed. The server guarantees that a request + * doesn't result in creation of duplicate commitments for at least 60 + * minutes. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check to see whether the original operation + * was received. If it was, the server ignores the second request. This + * behavior prevents clients from mistakenly creating duplicate commitments. + * + * The request ID must be a valid UUID, with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/hub_service.update_group.js + * region_tag:networkconnectivity_v1_generated_HubService_UpdateGroup_async + */ updateGroup( - request?: protos.google.cloud.networkconnectivity.v1.IUpdateGroupRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IUpdateGroupRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IGroup, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateGroup( - request: protos.google.cloud.networkconnectivity.v1.IUpdateGroupRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IUpdateGroupRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IGroup, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateGroup( - request: protos.google.cloud.networkconnectivity.v1.IUpdateGroupRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IUpdateGroupRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IGroup, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateGroup( - request?: protos.google.cloud.networkconnectivity.v1.IUpdateGroupRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1.IUpdateGroupRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IGroup, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IGroup, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IGroup, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'group.name': request.group!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'group.name': request.group!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IGroup, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateGroup response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateGroup request %j', request); - return this.innerApiCalls.updateGroup(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateGroup response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateGroup(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IGroup, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateGroup response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateGroup()`. - * @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/hub_service.update_group.js - * region_tag:networkconnectivity_v1_generated_HubService_UpdateGroup_async - */ - async checkUpdateGroupProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateGroup()`. + * @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/hub_service.update_group.js + * region_tag:networkconnectivity_v1_generated_HubService_UpdateGroup_async + */ + async checkUpdateGroupProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1.Group, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('updateGroup long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateGroup, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists the Network Connectivity Center hubs associated with a given project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results per page to return. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.Hub|Hub}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listHubsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateGroup, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1.Group, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; + } + /** + * Lists the Network Connectivity Center hubs associated with a given project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results per page to return. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.Hub|Hub}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listHubsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listHubs( - request?: protos.google.cloud.networkconnectivity.v1.IListHubsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IHub[], - protos.google.cloud.networkconnectivity.v1.IListHubsRequest|null, - protos.google.cloud.networkconnectivity.v1.IListHubsResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IListHubsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IHub[], + protos.google.cloud.networkconnectivity.v1.IListHubsRequest | null, + protos.google.cloud.networkconnectivity.v1.IListHubsResponse, + ] + >; listHubs( - request: protos.google.cloud.networkconnectivity.v1.IListHubsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListHubsRequest, - protos.google.cloud.networkconnectivity.v1.IListHubsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IHub>): void; + request: protos.google.cloud.networkconnectivity.v1.IListHubsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListHubsRequest, + | protos.google.cloud.networkconnectivity.v1.IListHubsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IHub + >, + ): void; listHubs( - request: protos.google.cloud.networkconnectivity.v1.IListHubsRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListHubsRequest, - protos.google.cloud.networkconnectivity.v1.IListHubsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IHub>): void; + request: protos.google.cloud.networkconnectivity.v1.IListHubsRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListHubsRequest, + | protos.google.cloud.networkconnectivity.v1.IListHubsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IHub + >, + ): void; listHubs( - request?: protos.google.cloud.networkconnectivity.v1.IListHubsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListHubsRequest, - protos.google.cloud.networkconnectivity.v1.IListHubsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IHub>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1.IListHubsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1.IListHubsRequest, - protos.google.cloud.networkconnectivity.v1.IListHubsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IHub>): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IHub[], - protos.google.cloud.networkconnectivity.v1.IListHubsRequest|null, - protos.google.cloud.networkconnectivity.v1.IListHubsResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1.IListHubsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IHub + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListHubsRequest, + | protos.google.cloud.networkconnectivity.v1.IListHubsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IHub + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IHub[], + protos.google.cloud.networkconnectivity.v1.IListHubsRequest | null, + protos.google.cloud.networkconnectivity.v1.IListHubsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListHubsRequest, - protos.google.cloud.networkconnectivity.v1.IListHubsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IHub>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListHubsRequest, + | protos.google.cloud.networkconnectivity.v1.IListHubsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IHub + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listHubs values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2476,216 +3652,245 @@ export class HubServiceClient { this._log.info('listHubs request %j', request); return this.innerApiCalls .listHubs(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1.IHub[], - protos.google.cloud.networkconnectivity.v1.IListHubsRequest|null, - protos.google.cloud.networkconnectivity.v1.IListHubsResponse - ]) => { - this._log.info('listHubs values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1.IHub[], + protos.google.cloud.networkconnectivity.v1.IListHubsRequest | null, + protos.google.cloud.networkconnectivity.v1.IListHubsResponse, + ]) => { + this._log.info('listHubs values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listHubs`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results per page to return. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.Hub|Hub} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listHubsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listHubs`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results per page to return. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.Hub|Hub} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listHubsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listHubsStream( - request?: protos.google.cloud.networkconnectivity.v1.IListHubsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1.IListHubsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listHubs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listHubs stream %j', request); return this.descriptors.page.listHubs.createStream( this.innerApiCalls.listHubs as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listHubs`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results per page to return. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1.Hub|Hub}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/hub_service.list_hubs.js - * region_tag:networkconnectivity_v1_generated_HubService_ListHubs_async - */ + /** + * Equivalent to `listHubs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results per page to return. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1.Hub|Hub}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/hub_service.list_hubs.js + * region_tag:networkconnectivity_v1_generated_HubService_ListHubs_async + */ listHubsAsync( - request?: protos.google.cloud.networkconnectivity.v1.IListHubsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1.IListHubsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listHubs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listHubs iterate %j', request); return this.descriptors.page.listHubs.asyncIterate( this.innerApiCalls['listHubs'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists the Network Connectivity Center spokes associated with a - * specified hub and location. The list includes both spokes that are attached - * to the hub and spokes that have been proposed but not yet accepted. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the hub. - * @param {string[]} request.spokeLocations - * A list of locations. - * Specify one of the following: `[global]`, a single region (for - * example, `[us-central1]`), or a combination of - * values (for example, `[global, us-central1, us-west1]`). - * If the spoke_locations field is populated, the list of results - * includes only spokes in the specified location. - * If the spoke_locations field is not populated, the list of results - * includes spokes in all locations. - * @param {number} request.pageSize - * The maximum number of results to return per page. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by name or create_time. - * @param {google.cloud.networkconnectivity.v1.ListHubSpokesRequest.SpokeView} request.view - * The view of the spoke to return. - * The view that you use determines which spoke fields are included in the - * response. - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.Spoke|Spoke}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listHubSpokesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists the Network Connectivity Center spokes associated with a + * specified hub and location. The list includes both spokes that are attached + * to the hub and spokes that have been proposed but not yet accepted. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the hub. + * @param {string[]} request.spokeLocations + * A list of locations. + * Specify one of the following: `[global]`, a single region (for + * example, `[us-central1]`), or a combination of + * values (for example, `[global, us-central1, us-west1]`). + * If the spoke_locations field is populated, the list of results + * includes only spokes in the specified location. + * If the spoke_locations field is not populated, the list of results + * includes spokes in all locations. + * @param {number} request.pageSize + * The maximum number of results to return per page. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by name or create_time. + * @param {google.cloud.networkconnectivity.v1.ListHubSpokesRequest.SpokeView} request.view + * The view of the spoke to return. + * The view that you use determines which spoke fields are included in the + * response. + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.Spoke|Spoke}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listHubSpokesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listHubSpokes( - request?: protos.google.cloud.networkconnectivity.v1.IListHubSpokesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1.ISpoke[], - protos.google.cloud.networkconnectivity.v1.IListHubSpokesRequest|null, - protos.google.cloud.networkconnectivity.v1.IListHubSpokesResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IListHubSpokesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.ISpoke[], + protos.google.cloud.networkconnectivity.v1.IListHubSpokesRequest | null, + protos.google.cloud.networkconnectivity.v1.IListHubSpokesResponse, + ] + >; listHubSpokes( - request: protos.google.cloud.networkconnectivity.v1.IListHubSpokesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListHubSpokesRequest, - protos.google.cloud.networkconnectivity.v1.IListHubSpokesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.ISpoke>): void; + request: protos.google.cloud.networkconnectivity.v1.IListHubSpokesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListHubSpokesRequest, + | protos.google.cloud.networkconnectivity.v1.IListHubSpokesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.ISpoke + >, + ): void; listHubSpokes( - request: protos.google.cloud.networkconnectivity.v1.IListHubSpokesRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListHubSpokesRequest, - protos.google.cloud.networkconnectivity.v1.IListHubSpokesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.ISpoke>): void; + request: protos.google.cloud.networkconnectivity.v1.IListHubSpokesRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListHubSpokesRequest, + | protos.google.cloud.networkconnectivity.v1.IListHubSpokesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.ISpoke + >, + ): void; listHubSpokes( - request?: protos.google.cloud.networkconnectivity.v1.IListHubSpokesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListHubSpokesRequest, - protos.google.cloud.networkconnectivity.v1.IListHubSpokesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.ISpoke>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1.IListHubSpokesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1.IListHubSpokesRequest, - protos.google.cloud.networkconnectivity.v1.IListHubSpokesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.ISpoke>): - Promise<[ - protos.google.cloud.networkconnectivity.v1.ISpoke[], - protos.google.cloud.networkconnectivity.v1.IListHubSpokesRequest|null, - protos.google.cloud.networkconnectivity.v1.IListHubSpokesResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1.IListHubSpokesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.ISpoke + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListHubSpokesRequest, + | protos.google.cloud.networkconnectivity.v1.IListHubSpokesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.ISpoke + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.ISpoke[], + protos.google.cloud.networkconnectivity.v1.IListHubSpokesRequest | null, + protos.google.cloud.networkconnectivity.v1.IListHubSpokesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListHubSpokesRequest, - protos.google.cloud.networkconnectivity.v1.IListHubSpokesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.ISpoke>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListHubSpokesRequest, + | protos.google.cloud.networkconnectivity.v1.IListHubSpokesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.ISpoke + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listHubSpokes values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2694,254 +3899,283 @@ export class HubServiceClient { this._log.info('listHubSpokes request %j', request); return this.innerApiCalls .listHubSpokes(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1.ISpoke[], - protos.google.cloud.networkconnectivity.v1.IListHubSpokesRequest|null, - protos.google.cloud.networkconnectivity.v1.IListHubSpokesResponse - ]) => { - this._log.info('listHubSpokes values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1.ISpoke[], + protos.google.cloud.networkconnectivity.v1.IListHubSpokesRequest | null, + protos.google.cloud.networkconnectivity.v1.IListHubSpokesResponse, + ]) => { + this._log.info('listHubSpokes values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listHubSpokes`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the hub. - * @param {string[]} request.spokeLocations - * A list of locations. - * Specify one of the following: `[global]`, a single region (for - * example, `[us-central1]`), or a combination of - * values (for example, `[global, us-central1, us-west1]`). - * If the spoke_locations field is populated, the list of results - * includes only spokes in the specified location. - * If the spoke_locations field is not populated, the list of results - * includes spokes in all locations. - * @param {number} request.pageSize - * The maximum number of results to return per page. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by name or create_time. - * @param {google.cloud.networkconnectivity.v1.ListHubSpokesRequest.SpokeView} request.view - * The view of the spoke to return. - * The view that you use determines which spoke fields are included in the - * response. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.Spoke|Spoke} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listHubSpokesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listHubSpokes`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the hub. + * @param {string[]} request.spokeLocations + * A list of locations. + * Specify one of the following: `[global]`, a single region (for + * example, `[us-central1]`), or a combination of + * values (for example, `[global, us-central1, us-west1]`). + * If the spoke_locations field is populated, the list of results + * includes only spokes in the specified location. + * If the spoke_locations field is not populated, the list of results + * includes spokes in all locations. + * @param {number} request.pageSize + * The maximum number of results to return per page. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by name or create_time. + * @param {google.cloud.networkconnectivity.v1.ListHubSpokesRequest.SpokeView} request.view + * The view of the spoke to return. + * The view that you use determines which spoke fields are included in the + * response. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.Spoke|Spoke} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listHubSpokesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listHubSpokesStream( - request?: protos.google.cloud.networkconnectivity.v1.IListHubSpokesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1.IListHubSpokesRequest, + options?: CallOptions, + ): Transform { request = request || {}; 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 ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); const defaultCallSettings = this._defaults['listHubSpokes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listHubSpokes stream %j', request); return this.descriptors.page.listHubSpokes.createStream( this.innerApiCalls.listHubSpokes as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listHubSpokes`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the hub. - * @param {string[]} request.spokeLocations - * A list of locations. - * Specify one of the following: `[global]`, a single region (for - * example, `[us-central1]`), or a combination of - * values (for example, `[global, us-central1, us-west1]`). - * If the spoke_locations field is populated, the list of results - * includes only spokes in the specified location. - * If the spoke_locations field is not populated, the list of results - * includes spokes in all locations. - * @param {number} request.pageSize - * The maximum number of results to return per page. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by name or create_time. - * @param {google.cloud.networkconnectivity.v1.ListHubSpokesRequest.SpokeView} request.view - * The view of the spoke to return. - * The view that you use determines which spoke fields are included in the - * response. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1.Spoke|Spoke}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/hub_service.list_hub_spokes.js - * region_tag:networkconnectivity_v1_generated_HubService_ListHubSpokes_async - */ + /** + * Equivalent to `listHubSpokes`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the hub. + * @param {string[]} request.spokeLocations + * A list of locations. + * Specify one of the following: `[global]`, a single region (for + * example, `[us-central1]`), or a combination of + * values (for example, `[global, us-central1, us-west1]`). + * If the spoke_locations field is populated, the list of results + * includes only spokes in the specified location. + * If the spoke_locations field is not populated, the list of results + * includes spokes in all locations. + * @param {number} request.pageSize + * The maximum number of results to return per page. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by name or create_time. + * @param {google.cloud.networkconnectivity.v1.ListHubSpokesRequest.SpokeView} request.view + * The view of the spoke to return. + * The view that you use determines which spoke fields are included in the + * response. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1.Spoke|Spoke}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/hub_service.list_hub_spokes.js + * region_tag:networkconnectivity_v1_generated_HubService_ListHubSpokes_async + */ listHubSpokesAsync( - request?: protos.google.cloud.networkconnectivity.v1.IListHubSpokesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1.IListHubSpokesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; 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 ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); const defaultCallSettings = this._defaults['listHubSpokes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listHubSpokes iterate %j', request); return this.descriptors.page.listHubSpokes.asyncIterate( this.innerApiCalls['listHubSpokes'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Query the Private Service Connect propagation status of a Network - * Connectivity Center hub. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the hub. - * @param {number} [request.pageSize] - * Optional. The maximum number of results to return per page. - * @param {string} [request.pageToken] - * Optional. The page token. - * @param {string} [request.filter] - * Optional. An expression that filters the list of results. - * The filter can be used to filter the results by the following fields: - * * `psc_propagation_status.source_spoke` - * * `psc_propagation_status.source_group` - * * `psc_propagation_status.source_forwarding_rule` - * * `psc_propagation_status.target_spoke` - * * `psc_propagation_status.target_group` - * * `psc_propagation_status.code` - * * `psc_propagation_status.message` - * @param {string} [request.orderBy] - * Optional. Sort the results in ascending order by the specified fields. - * A comma-separated list of any of these fields: - * * `psc_propagation_status.source_spoke` - * * `psc_propagation_status.source_group` - * * `psc_propagation_status.source_forwarding_rule` - * * `psc_propagation_status.target_spoke` - * * `psc_propagation_status.target_group` - * * `psc_propagation_status.code` - * If `group_by` is set, the value of the `order_by` field must be the - * same as or a subset of the `group_by` field. - * @param {string} [request.groupBy] - * Optional. Aggregate the results by the specified fields. - * A comma-separated list of any of these fields: - * * `psc_propagation_status.source_spoke` - * * `psc_propagation_status.source_group` - * * `psc_propagation_status.source_forwarding_rule` - * * `psc_propagation_status.target_spoke` - * * `psc_propagation_status.target_group` - * * `psc_propagation_status.code` - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.HubStatusEntry|HubStatusEntry}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `queryHubStatusAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Query the Private Service Connect propagation status of a Network + * Connectivity Center hub. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the hub. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return per page. + * @param {string} [request.pageToken] + * Optional. The page token. + * @param {string} [request.filter] + * Optional. An expression that filters the list of results. + * The filter can be used to filter the results by the following fields: + * * `psc_propagation_status.source_spoke` + * * `psc_propagation_status.source_group` + * * `psc_propagation_status.source_forwarding_rule` + * * `psc_propagation_status.target_spoke` + * * `psc_propagation_status.target_group` + * * `psc_propagation_status.code` + * * `psc_propagation_status.message` + * @param {string} [request.orderBy] + * Optional. Sort the results in ascending order by the specified fields. + * A comma-separated list of any of these fields: + * * `psc_propagation_status.source_spoke` + * * `psc_propagation_status.source_group` + * * `psc_propagation_status.source_forwarding_rule` + * * `psc_propagation_status.target_spoke` + * * `psc_propagation_status.target_group` + * * `psc_propagation_status.code` + * If `group_by` is set, the value of the `order_by` field must be the + * same as or a subset of the `group_by` field. + * @param {string} [request.groupBy] + * Optional. Aggregate the results by the specified fields. + * A comma-separated list of any of these fields: + * * `psc_propagation_status.source_spoke` + * * `psc_propagation_status.source_group` + * * `psc_propagation_status.source_forwarding_rule` + * * `psc_propagation_status.target_spoke` + * * `psc_propagation_status.target_group` + * * `psc_propagation_status.code` + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.HubStatusEntry|HubStatusEntry}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `queryHubStatusAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ queryHubStatus( - request?: protos.google.cloud.networkconnectivity.v1.IQueryHubStatusRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IHubStatusEntry[], - protos.google.cloud.networkconnectivity.v1.IQueryHubStatusRequest|null, - protos.google.cloud.networkconnectivity.v1.IQueryHubStatusResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IQueryHubStatusRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IHubStatusEntry[], + protos.google.cloud.networkconnectivity.v1.IQueryHubStatusRequest | null, + protos.google.cloud.networkconnectivity.v1.IQueryHubStatusResponse, + ] + >; queryHubStatus( - request: protos.google.cloud.networkconnectivity.v1.IQueryHubStatusRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IQueryHubStatusRequest, - protos.google.cloud.networkconnectivity.v1.IQueryHubStatusResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IHubStatusEntry>): void; + request: protos.google.cloud.networkconnectivity.v1.IQueryHubStatusRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IQueryHubStatusRequest, + | protos.google.cloud.networkconnectivity.v1.IQueryHubStatusResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IHubStatusEntry + >, + ): void; queryHubStatus( - request: protos.google.cloud.networkconnectivity.v1.IQueryHubStatusRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IQueryHubStatusRequest, - protos.google.cloud.networkconnectivity.v1.IQueryHubStatusResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IHubStatusEntry>): void; + request: protos.google.cloud.networkconnectivity.v1.IQueryHubStatusRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IQueryHubStatusRequest, + | protos.google.cloud.networkconnectivity.v1.IQueryHubStatusResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IHubStatusEntry + >, + ): void; queryHubStatus( - request?: protos.google.cloud.networkconnectivity.v1.IQueryHubStatusRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IQueryHubStatusRequest, - protos.google.cloud.networkconnectivity.v1.IQueryHubStatusResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IHubStatusEntry>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1.IQueryHubStatusRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1.IQueryHubStatusRequest, - protos.google.cloud.networkconnectivity.v1.IQueryHubStatusResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IHubStatusEntry>): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IHubStatusEntry[], - protos.google.cloud.networkconnectivity.v1.IQueryHubStatusRequest|null, - protos.google.cloud.networkconnectivity.v1.IQueryHubStatusResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1.IQueryHubStatusResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IHubStatusEntry + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IQueryHubStatusRequest, + | protos.google.cloud.networkconnectivity.v1.IQueryHubStatusResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IHubStatusEntry + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IHubStatusEntry[], + protos.google.cloud.networkconnectivity.v1.IQueryHubStatusRequest | null, + protos.google.cloud.networkconnectivity.v1.IQueryHubStatusResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IQueryHubStatusRequest, - protos.google.cloud.networkconnectivity.v1.IQueryHubStatusResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IHubStatusEntry>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IQueryHubStatusRequest, + | protos.google.cloud.networkconnectivity.v1.IQueryHubStatusResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IHubStatusEntry + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('queryHubStatus values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2950,254 +4184,283 @@ export class HubServiceClient { this._log.info('queryHubStatus request %j', request); return this.innerApiCalls .queryHubStatus(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1.IHubStatusEntry[], - protos.google.cloud.networkconnectivity.v1.IQueryHubStatusRequest|null, - protos.google.cloud.networkconnectivity.v1.IQueryHubStatusResponse - ]) => { - this._log.info('queryHubStatus values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1.IHubStatusEntry[], + protos.google.cloud.networkconnectivity.v1.IQueryHubStatusRequest | null, + protos.google.cloud.networkconnectivity.v1.IQueryHubStatusResponse, + ]) => { + this._log.info('queryHubStatus values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `queryHubStatus`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the hub. - * @param {number} [request.pageSize] - * Optional. The maximum number of results to return per page. - * @param {string} [request.pageToken] - * Optional. The page token. - * @param {string} [request.filter] - * Optional. An expression that filters the list of results. - * The filter can be used to filter the results by the following fields: - * * `psc_propagation_status.source_spoke` - * * `psc_propagation_status.source_group` - * * `psc_propagation_status.source_forwarding_rule` - * * `psc_propagation_status.target_spoke` - * * `psc_propagation_status.target_group` - * * `psc_propagation_status.code` - * * `psc_propagation_status.message` - * @param {string} [request.orderBy] - * Optional. Sort the results in ascending order by the specified fields. - * A comma-separated list of any of these fields: - * * `psc_propagation_status.source_spoke` - * * `psc_propagation_status.source_group` - * * `psc_propagation_status.source_forwarding_rule` - * * `psc_propagation_status.target_spoke` - * * `psc_propagation_status.target_group` - * * `psc_propagation_status.code` - * If `group_by` is set, the value of the `order_by` field must be the - * same as or a subset of the `group_by` field. - * @param {string} [request.groupBy] - * Optional. Aggregate the results by the specified fields. - * A comma-separated list of any of these fields: - * * `psc_propagation_status.source_spoke` - * * `psc_propagation_status.source_group` - * * `psc_propagation_status.source_forwarding_rule` - * * `psc_propagation_status.target_spoke` - * * `psc_propagation_status.target_group` - * * `psc_propagation_status.code` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.HubStatusEntry|HubStatusEntry} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `queryHubStatusAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `queryHubStatus`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the hub. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return per page. + * @param {string} [request.pageToken] + * Optional. The page token. + * @param {string} [request.filter] + * Optional. An expression that filters the list of results. + * The filter can be used to filter the results by the following fields: + * * `psc_propagation_status.source_spoke` + * * `psc_propagation_status.source_group` + * * `psc_propagation_status.source_forwarding_rule` + * * `psc_propagation_status.target_spoke` + * * `psc_propagation_status.target_group` + * * `psc_propagation_status.code` + * * `psc_propagation_status.message` + * @param {string} [request.orderBy] + * Optional. Sort the results in ascending order by the specified fields. + * A comma-separated list of any of these fields: + * * `psc_propagation_status.source_spoke` + * * `psc_propagation_status.source_group` + * * `psc_propagation_status.source_forwarding_rule` + * * `psc_propagation_status.target_spoke` + * * `psc_propagation_status.target_group` + * * `psc_propagation_status.code` + * If `group_by` is set, the value of the `order_by` field must be the + * same as or a subset of the `group_by` field. + * @param {string} [request.groupBy] + * Optional. Aggregate the results by the specified fields. + * A comma-separated list of any of these fields: + * * `psc_propagation_status.source_spoke` + * * `psc_propagation_status.source_group` + * * `psc_propagation_status.source_forwarding_rule` + * * `psc_propagation_status.target_spoke` + * * `psc_propagation_status.target_group` + * * `psc_propagation_status.code` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.HubStatusEntry|HubStatusEntry} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `queryHubStatusAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ queryHubStatusStream( - request?: protos.google.cloud.networkconnectivity.v1.IQueryHubStatusRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1.IQueryHubStatusRequest, + options?: CallOptions, + ): Transform { request = request || {}; 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 ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); const defaultCallSettings = this._defaults['queryHubStatus']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('queryHubStatus stream %j', request); return this.descriptors.page.queryHubStatus.createStream( this.innerApiCalls.queryHubStatus as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `queryHubStatus`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the hub. - * @param {number} [request.pageSize] - * Optional. The maximum number of results to return per page. - * @param {string} [request.pageToken] - * Optional. The page token. - * @param {string} [request.filter] - * Optional. An expression that filters the list of results. - * The filter can be used to filter the results by the following fields: - * * `psc_propagation_status.source_spoke` - * * `psc_propagation_status.source_group` - * * `psc_propagation_status.source_forwarding_rule` - * * `psc_propagation_status.target_spoke` - * * `psc_propagation_status.target_group` - * * `psc_propagation_status.code` - * * `psc_propagation_status.message` - * @param {string} [request.orderBy] - * Optional. Sort the results in ascending order by the specified fields. - * A comma-separated list of any of these fields: - * * `psc_propagation_status.source_spoke` - * * `psc_propagation_status.source_group` - * * `psc_propagation_status.source_forwarding_rule` - * * `psc_propagation_status.target_spoke` - * * `psc_propagation_status.target_group` - * * `psc_propagation_status.code` - * If `group_by` is set, the value of the `order_by` field must be the - * same as or a subset of the `group_by` field. - * @param {string} [request.groupBy] - * Optional. Aggregate the results by the specified fields. - * A comma-separated list of any of these fields: - * * `psc_propagation_status.source_spoke` - * * `psc_propagation_status.source_group` - * * `psc_propagation_status.source_forwarding_rule` - * * `psc_propagation_status.target_spoke` - * * `psc_propagation_status.target_group` - * * `psc_propagation_status.code` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1.HubStatusEntry|HubStatusEntry}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/hub_service.query_hub_status.js - * region_tag:networkconnectivity_v1_generated_HubService_QueryHubStatus_async - */ + /** + * Equivalent to `queryHubStatus`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the hub. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return per page. + * @param {string} [request.pageToken] + * Optional. The page token. + * @param {string} [request.filter] + * Optional. An expression that filters the list of results. + * The filter can be used to filter the results by the following fields: + * * `psc_propagation_status.source_spoke` + * * `psc_propagation_status.source_group` + * * `psc_propagation_status.source_forwarding_rule` + * * `psc_propagation_status.target_spoke` + * * `psc_propagation_status.target_group` + * * `psc_propagation_status.code` + * * `psc_propagation_status.message` + * @param {string} [request.orderBy] + * Optional. Sort the results in ascending order by the specified fields. + * A comma-separated list of any of these fields: + * * `psc_propagation_status.source_spoke` + * * `psc_propagation_status.source_group` + * * `psc_propagation_status.source_forwarding_rule` + * * `psc_propagation_status.target_spoke` + * * `psc_propagation_status.target_group` + * * `psc_propagation_status.code` + * If `group_by` is set, the value of the `order_by` field must be the + * same as or a subset of the `group_by` field. + * @param {string} [request.groupBy] + * Optional. Aggregate the results by the specified fields. + * A comma-separated list of any of these fields: + * * `psc_propagation_status.source_spoke` + * * `psc_propagation_status.source_group` + * * `psc_propagation_status.source_forwarding_rule` + * * `psc_propagation_status.target_spoke` + * * `psc_propagation_status.target_group` + * * `psc_propagation_status.code` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1.HubStatusEntry|HubStatusEntry}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/hub_service.query_hub_status.js + * region_tag:networkconnectivity_v1_generated_HubService_QueryHubStatus_async + */ queryHubStatusAsync( - request?: protos.google.cloud.networkconnectivity.v1.IQueryHubStatusRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1.IQueryHubStatusRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; 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 ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); const defaultCallSettings = this._defaults['queryHubStatus']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('queryHubStatus iterate %j', request); return this.descriptors.page.queryHubStatus.asyncIterate( this.innerApiCalls['queryHubStatus'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists the Network Connectivity Center spokes in a specified project and - * location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource. - * @param {number} request.pageSize - * The maximum number of results to return per page. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.Spoke|Spoke}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listSpokesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists the Network Connectivity Center spokes in a specified project and + * location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource. + * @param {number} request.pageSize + * The maximum number of results to return per page. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.Spoke|Spoke}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listSpokesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listSpokes( - request?: protos.google.cloud.networkconnectivity.v1.IListSpokesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1.ISpoke[], - protos.google.cloud.networkconnectivity.v1.IListSpokesRequest|null, - protos.google.cloud.networkconnectivity.v1.IListSpokesResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IListSpokesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.ISpoke[], + protos.google.cloud.networkconnectivity.v1.IListSpokesRequest | null, + protos.google.cloud.networkconnectivity.v1.IListSpokesResponse, + ] + >; listSpokes( - request: protos.google.cloud.networkconnectivity.v1.IListSpokesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListSpokesRequest, - protos.google.cloud.networkconnectivity.v1.IListSpokesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.ISpoke>): void; + request: protos.google.cloud.networkconnectivity.v1.IListSpokesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListSpokesRequest, + | protos.google.cloud.networkconnectivity.v1.IListSpokesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.ISpoke + >, + ): void; listSpokes( - request: protos.google.cloud.networkconnectivity.v1.IListSpokesRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListSpokesRequest, - protos.google.cloud.networkconnectivity.v1.IListSpokesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.ISpoke>): void; + request: protos.google.cloud.networkconnectivity.v1.IListSpokesRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListSpokesRequest, + | protos.google.cloud.networkconnectivity.v1.IListSpokesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.ISpoke + >, + ): void; listSpokes( - request?: protos.google.cloud.networkconnectivity.v1.IListSpokesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListSpokesRequest, - protos.google.cloud.networkconnectivity.v1.IListSpokesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.ISpoke>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1.IListSpokesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1.IListSpokesRequest, - protos.google.cloud.networkconnectivity.v1.IListSpokesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.ISpoke>): - Promise<[ - protos.google.cloud.networkconnectivity.v1.ISpoke[], - protos.google.cloud.networkconnectivity.v1.IListSpokesRequest|null, - protos.google.cloud.networkconnectivity.v1.IListSpokesResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1.IListSpokesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.ISpoke + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListSpokesRequest, + | protos.google.cloud.networkconnectivity.v1.IListSpokesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.ISpoke + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.ISpoke[], + protos.google.cloud.networkconnectivity.v1.IListSpokesRequest | null, + protos.google.cloud.networkconnectivity.v1.IListSpokesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListSpokesRequest, - protos.google.cloud.networkconnectivity.v1.IListSpokesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.ISpoke>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListSpokesRequest, + | protos.google.cloud.networkconnectivity.v1.IListSpokesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.ISpoke + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listSpokes values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -3206,201 +4469,230 @@ export class HubServiceClient { this._log.info('listSpokes request %j', request); return this.innerApiCalls .listSpokes(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1.ISpoke[], - protos.google.cloud.networkconnectivity.v1.IListSpokesRequest|null, - protos.google.cloud.networkconnectivity.v1.IListSpokesResponse - ]) => { - this._log.info('listSpokes values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1.ISpoke[], + protos.google.cloud.networkconnectivity.v1.IListSpokesRequest | null, + protos.google.cloud.networkconnectivity.v1.IListSpokesResponse, + ]) => { + this._log.info('listSpokes values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listSpokes`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource. - * @param {number} request.pageSize - * The maximum number of results to return per page. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.Spoke|Spoke} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listSpokesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listSpokes`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource. + * @param {number} request.pageSize + * The maximum number of results to return per page. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.Spoke|Spoke} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listSpokesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listSpokesStream( - request?: protos.google.cloud.networkconnectivity.v1.IListSpokesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1.IListSpokesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listSpokes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listSpokes stream %j', request); return this.descriptors.page.listSpokes.createStream( this.innerApiCalls.listSpokes as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listSpokes`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource. - * @param {number} request.pageSize - * The maximum number of results to return per page. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1.Spoke|Spoke}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/hub_service.list_spokes.js - * region_tag:networkconnectivity_v1_generated_HubService_ListSpokes_async - */ + /** + * Equivalent to `listSpokes`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource. + * @param {number} request.pageSize + * The maximum number of results to return per page. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1.Spoke|Spoke}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/hub_service.list_spokes.js + * region_tag:networkconnectivity_v1_generated_HubService_ListSpokes_async + */ listSpokesAsync( - request?: protos.google.cloud.networkconnectivity.v1.IListSpokesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1.IListSpokesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listSpokes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listSpokes iterate %j', request); return this.descriptors.page.listSpokes.asyncIterate( this.innerApiCalls['listSpokes'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists routes in a given route table. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results to return per page. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.Route|Route}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listRoutesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists routes in a given route table. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results to return per page. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.Route|Route}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listRoutesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listRoutes( - request?: protos.google.cloud.networkconnectivity.v1.IListRoutesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IRoute[], - protos.google.cloud.networkconnectivity.v1.IListRoutesRequest|null, - protos.google.cloud.networkconnectivity.v1.IListRoutesResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IListRoutesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IRoute[], + protos.google.cloud.networkconnectivity.v1.IListRoutesRequest | null, + protos.google.cloud.networkconnectivity.v1.IListRoutesResponse, + ] + >; listRoutes( - request: protos.google.cloud.networkconnectivity.v1.IListRoutesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListRoutesRequest, - protos.google.cloud.networkconnectivity.v1.IListRoutesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IRoute>): void; + request: protos.google.cloud.networkconnectivity.v1.IListRoutesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListRoutesRequest, + | protos.google.cloud.networkconnectivity.v1.IListRoutesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IRoute + >, + ): void; listRoutes( - request: protos.google.cloud.networkconnectivity.v1.IListRoutesRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListRoutesRequest, - protos.google.cloud.networkconnectivity.v1.IListRoutesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IRoute>): void; + request: protos.google.cloud.networkconnectivity.v1.IListRoutesRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListRoutesRequest, + | protos.google.cloud.networkconnectivity.v1.IListRoutesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IRoute + >, + ): void; listRoutes( - request?: protos.google.cloud.networkconnectivity.v1.IListRoutesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListRoutesRequest, - protos.google.cloud.networkconnectivity.v1.IListRoutesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IRoute>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1.IListRoutesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1.IListRoutesRequest, - protos.google.cloud.networkconnectivity.v1.IListRoutesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IRoute>): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IRoute[], - protos.google.cloud.networkconnectivity.v1.IListRoutesRequest|null, - protos.google.cloud.networkconnectivity.v1.IListRoutesResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1.IListRoutesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IRoute + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListRoutesRequest, + | protos.google.cloud.networkconnectivity.v1.IListRoutesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IRoute + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IRoute[], + protos.google.cloud.networkconnectivity.v1.IListRoutesRequest | null, + protos.google.cloud.networkconnectivity.v1.IListRoutesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListRoutesRequest, - protos.google.cloud.networkconnectivity.v1.IListRoutesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IRoute>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListRoutesRequest, + | protos.google.cloud.networkconnectivity.v1.IListRoutesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IRoute + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listRoutes values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -3409,201 +4701,230 @@ export class HubServiceClient { this._log.info('listRoutes request %j', request); return this.innerApiCalls .listRoutes(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1.IRoute[], - protos.google.cloud.networkconnectivity.v1.IListRoutesRequest|null, - protos.google.cloud.networkconnectivity.v1.IListRoutesResponse - ]) => { - this._log.info('listRoutes values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1.IRoute[], + protos.google.cloud.networkconnectivity.v1.IListRoutesRequest | null, + protos.google.cloud.networkconnectivity.v1.IListRoutesResponse, + ]) => { + this._log.info('listRoutes values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listRoutes`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results to return per page. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.Route|Route} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listRoutesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listRoutes`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results to return per page. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.Route|Route} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listRoutesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listRoutesStream( - request?: protos.google.cloud.networkconnectivity.v1.IListRoutesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1.IListRoutesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listRoutes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listRoutes stream %j', request); return this.descriptors.page.listRoutes.createStream( this.innerApiCalls.listRoutes as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listRoutes`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results to return per page. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1.Route|Route}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/hub_service.list_routes.js - * region_tag:networkconnectivity_v1_generated_HubService_ListRoutes_async - */ + /** + * Equivalent to `listRoutes`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results to return per page. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1.Route|Route}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/hub_service.list_routes.js + * region_tag:networkconnectivity_v1_generated_HubService_ListRoutes_async + */ listRoutesAsync( - request?: protos.google.cloud.networkconnectivity.v1.IListRoutesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1.IListRoutesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listRoutes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listRoutes iterate %j', request); return this.descriptors.page.listRoutes.asyncIterate( this.innerApiCalls['listRoutes'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists route tables in a given hub. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results to return per page. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.RouteTable|RouteTable}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listRouteTablesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists route tables in a given hub. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results to return per page. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.RouteTable|RouteTable}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listRouteTablesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listRouteTables( - request?: protos.google.cloud.networkconnectivity.v1.IListRouteTablesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IRouteTable[], - protos.google.cloud.networkconnectivity.v1.IListRouteTablesRequest|null, - protos.google.cloud.networkconnectivity.v1.IListRouteTablesResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IListRouteTablesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IRouteTable[], + protos.google.cloud.networkconnectivity.v1.IListRouteTablesRequest | null, + protos.google.cloud.networkconnectivity.v1.IListRouteTablesResponse, + ] + >; listRouteTables( - request: protos.google.cloud.networkconnectivity.v1.IListRouteTablesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListRouteTablesRequest, - protos.google.cloud.networkconnectivity.v1.IListRouteTablesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IRouteTable>): void; + request: protos.google.cloud.networkconnectivity.v1.IListRouteTablesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListRouteTablesRequest, + | protos.google.cloud.networkconnectivity.v1.IListRouteTablesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IRouteTable + >, + ): void; listRouteTables( - request: protos.google.cloud.networkconnectivity.v1.IListRouteTablesRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListRouteTablesRequest, - protos.google.cloud.networkconnectivity.v1.IListRouteTablesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IRouteTable>): void; + request: protos.google.cloud.networkconnectivity.v1.IListRouteTablesRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListRouteTablesRequest, + | protos.google.cloud.networkconnectivity.v1.IListRouteTablesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IRouteTable + >, + ): void; listRouteTables( - request?: protos.google.cloud.networkconnectivity.v1.IListRouteTablesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListRouteTablesRequest, - protos.google.cloud.networkconnectivity.v1.IListRouteTablesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IRouteTable>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1.IListRouteTablesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1.IListRouteTablesRequest, - protos.google.cloud.networkconnectivity.v1.IListRouteTablesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IRouteTable>): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IRouteTable[], - protos.google.cloud.networkconnectivity.v1.IListRouteTablesRequest|null, - protos.google.cloud.networkconnectivity.v1.IListRouteTablesResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1.IListRouteTablesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IRouteTable + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListRouteTablesRequest, + | protos.google.cloud.networkconnectivity.v1.IListRouteTablesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IRouteTable + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IRouteTable[], + protos.google.cloud.networkconnectivity.v1.IListRouteTablesRequest | null, + protos.google.cloud.networkconnectivity.v1.IListRouteTablesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListRouteTablesRequest, - protos.google.cloud.networkconnectivity.v1.IListRouteTablesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IRouteTable>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListRouteTablesRequest, + | protos.google.cloud.networkconnectivity.v1.IListRouteTablesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IRouteTable + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listRouteTables values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -3612,201 +4933,230 @@ export class HubServiceClient { this._log.info('listRouteTables request %j', request); return this.innerApiCalls .listRouteTables(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1.IRouteTable[], - protos.google.cloud.networkconnectivity.v1.IListRouteTablesRequest|null, - protos.google.cloud.networkconnectivity.v1.IListRouteTablesResponse - ]) => { - this._log.info('listRouteTables values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1.IRouteTable[], + protos.google.cloud.networkconnectivity.v1.IListRouteTablesRequest | null, + protos.google.cloud.networkconnectivity.v1.IListRouteTablesResponse, + ]) => { + this._log.info('listRouteTables values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listRouteTables`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results to return per page. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.RouteTable|RouteTable} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listRouteTablesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listRouteTables`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results to return per page. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.RouteTable|RouteTable} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listRouteTablesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listRouteTablesStream( - request?: protos.google.cloud.networkconnectivity.v1.IListRouteTablesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1.IListRouteTablesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listRouteTables']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listRouteTables stream %j', request); return this.descriptors.page.listRouteTables.createStream( this.innerApiCalls.listRouteTables as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listRouteTables`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results to return per page. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1.RouteTable|RouteTable}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/hub_service.list_route_tables.js - * region_tag:networkconnectivity_v1_generated_HubService_ListRouteTables_async - */ + /** + * Equivalent to `listRouteTables`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results to return per page. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1.RouteTable|RouteTable}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/hub_service.list_route_tables.js + * region_tag:networkconnectivity_v1_generated_HubService_ListRouteTables_async + */ listRouteTablesAsync( - request?: protos.google.cloud.networkconnectivity.v1.IListRouteTablesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1.IListRouteTablesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listRouteTables']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listRouteTables iterate %j', request); return this.descriptors.page.listRouteTables.asyncIterate( this.innerApiCalls['listRouteTables'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists groups in a given hub. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results to return per page. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.Group|Group}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listGroupsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists groups in a given hub. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results to return per page. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.Group|Group}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listGroupsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listGroups( - request?: protos.google.cloud.networkconnectivity.v1.IListGroupsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IGroup[], - protos.google.cloud.networkconnectivity.v1.IListGroupsRequest|null, - protos.google.cloud.networkconnectivity.v1.IListGroupsResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IListGroupsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IGroup[], + protos.google.cloud.networkconnectivity.v1.IListGroupsRequest | null, + protos.google.cloud.networkconnectivity.v1.IListGroupsResponse, + ] + >; listGroups( - request: protos.google.cloud.networkconnectivity.v1.IListGroupsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListGroupsRequest, - protos.google.cloud.networkconnectivity.v1.IListGroupsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IGroup>): void; + request: protos.google.cloud.networkconnectivity.v1.IListGroupsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListGroupsRequest, + | protos.google.cloud.networkconnectivity.v1.IListGroupsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IGroup + >, + ): void; listGroups( - request: protos.google.cloud.networkconnectivity.v1.IListGroupsRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListGroupsRequest, - protos.google.cloud.networkconnectivity.v1.IListGroupsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IGroup>): void; + request: protos.google.cloud.networkconnectivity.v1.IListGroupsRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListGroupsRequest, + | protos.google.cloud.networkconnectivity.v1.IListGroupsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IGroup + >, + ): void; listGroups( - request?: protos.google.cloud.networkconnectivity.v1.IListGroupsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListGroupsRequest, - protos.google.cloud.networkconnectivity.v1.IListGroupsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IGroup>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1.IListGroupsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1.IListGroupsRequest, - protos.google.cloud.networkconnectivity.v1.IListGroupsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IGroup>): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IGroup[], - protos.google.cloud.networkconnectivity.v1.IListGroupsRequest|null, - protos.google.cloud.networkconnectivity.v1.IListGroupsResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1.IListGroupsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IGroup + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListGroupsRequest, + | protos.google.cloud.networkconnectivity.v1.IListGroupsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IGroup + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IGroup[], + protos.google.cloud.networkconnectivity.v1.IListGroupsRequest | null, + protos.google.cloud.networkconnectivity.v1.IListGroupsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListGroupsRequest, - protos.google.cloud.networkconnectivity.v1.IListGroupsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IGroup>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListGroupsRequest, + | protos.google.cloud.networkconnectivity.v1.IListGroupsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IGroup + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listGroups values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -3815,141 +5165,145 @@ export class HubServiceClient { this._log.info('listGroups request %j', request); return this.innerApiCalls .listGroups(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1.IGroup[], - protos.google.cloud.networkconnectivity.v1.IListGroupsRequest|null, - protos.google.cloud.networkconnectivity.v1.IListGroupsResponse - ]) => { - this._log.info('listGroups values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1.IGroup[], + protos.google.cloud.networkconnectivity.v1.IListGroupsRequest | null, + protos.google.cloud.networkconnectivity.v1.IListGroupsResponse, + ]) => { + this._log.info('listGroups values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listGroups`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results to return per page. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.Group|Group} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listGroupsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listGroups`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results to return per page. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.Group|Group} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listGroupsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listGroupsStream( - request?: protos.google.cloud.networkconnectivity.v1.IListGroupsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1.IListGroupsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listGroups']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listGroups stream %j', request); return this.descriptors.page.listGroups.createStream( this.innerApiCalls.listGroups as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listGroups`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results to return per page. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1.Group|Group}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/hub_service.list_groups.js - * region_tag:networkconnectivity_v1_generated_HubService_ListGroups_async - */ + /** + * Equivalent to `listGroups`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results to return per page. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1.Group|Group}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/hub_service.list_groups.js + * region_tag:networkconnectivity_v1_generated_HubService_ListGroups_async + */ listGroupsAsync( - request?: protos.google.cloud.networkconnectivity.v1.IListGroupsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1.IListGroupsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listGroups']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listGroups iterate %j', request); return this.descriptors.page.listGroups.asyncIterate( this.innerApiCalls['listGroups'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -3963,40 +5317,40 @@ export class HubServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -4010,41 +5364,41 @@ export class HubServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -4058,12 +5412,12 @@ export class HubServiceClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -4098,12 +5452,11 @@ export class HubServiceClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -4136,12 +5489,12 @@ export class HubServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -4184,22 +5537,22 @@ export class HubServiceClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -4234,15 +5587,15 @@ export class HubServiceClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - 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 ?? '', - }); + 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 ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -4276,7 +5629,7 @@ export class HubServiceClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -4289,25 +5642,24 @@ export class HubServiceClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -4346,22 +5698,22 @@ export class HubServiceClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -4378,7 +5730,12 @@ export class HubServiceClient { * @param {string} destination * @returns {string} Resource name string. */ - destinationPath(project:string,location:string,multicloudDataTransferConfig:string,destination:string) { + destinationPath( + project: string, + location: string, + multicloudDataTransferConfig: string, + destination: string, + ) { return this.pathTemplates.destinationPathTemplate.render({ project: project, location: location, @@ -4395,7 +5752,8 @@ export class HubServiceClient { * @returns {string} A string representing the project. */ matchProjectFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).project; + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .project; } /** @@ -4406,7 +5764,8 @@ export class HubServiceClient { * @returns {string} A string representing the location. */ matchLocationFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).location; + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .location; } /** @@ -4416,8 +5775,11 @@ export class HubServiceClient { * A fully-qualified path representing Destination resource. * @returns {string} A string representing the multicloud_data_transfer_config. */ - matchMulticloudDataTransferConfigFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).multicloud_data_transfer_config; + matchMulticloudDataTransferConfigFromDestinationName( + destinationName: string, + ) { + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .multicloud_data_transfer_config; } /** @@ -4428,7 +5790,8 @@ export class HubServiceClient { * @returns {string} A string representing the destination. */ matchDestinationFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).destination; + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .destination; } /** @@ -4439,7 +5802,7 @@ export class HubServiceClient { * @param {string} group * @returns {string} Resource name string. */ - groupPath(project:string,hub:string,group:string) { + groupPath(project: string, hub: string, group: string) { return this.pathTemplates.groupPathTemplate.render({ project: project, hub: hub, @@ -4487,7 +5850,7 @@ export class HubServiceClient { * @param {string} hub * @returns {string} Resource name string. */ - hubPath(project:string,hub:string) { + hubPath(project: string, hub: string) { return this.pathTemplates.hubPathTemplate.render({ project: project, hub: hub, @@ -4525,7 +5888,12 @@ export class HubServiceClient { * @param {string} route * @returns {string} Resource name string. */ - hubRoutePath(project:string,hub:string,routeTable:string,route:string) { + hubRoutePath( + project: string, + hub: string, + routeTable: string, + route: string, + ) { return this.pathTemplates.hubRoutePathTemplate.render({ project: project, hub: hub, @@ -4564,7 +5932,8 @@ export class HubServiceClient { * @returns {string} A string representing the route_table. */ matchRouteTableFromHubRouteName(hubRouteName: string) { - return this.pathTemplates.hubRoutePathTemplate.match(hubRouteName).route_table; + return this.pathTemplates.hubRoutePathTemplate.match(hubRouteName) + .route_table; } /** @@ -4586,7 +5955,7 @@ export class HubServiceClient { * @param {string} instance * @returns {string} Resource name string. */ - instancePath(project:string,zone:string,instance:string) { + instancePath(project: string, zone: string, instance: string) { return this.pathTemplates.instancePathTemplate.render({ project: project, zone: zone, @@ -4635,7 +6004,11 @@ export class HubServiceClient { * @param {string} resource_id * @returns {string} Resource name string. */ - interconnectAttachmentPath(project:string,region:string,resourceId:string) { + interconnectAttachmentPath( + project: string, + region: string, + resourceId: string, + ) { return this.pathTemplates.interconnectAttachmentPathTemplate.render({ project: project, region: region, @@ -4650,8 +6023,12 @@ export class HubServiceClient { * A fully-qualified path representing InterconnectAttachment resource. * @returns {string} A string representing the project. */ - matchProjectFromInterconnectAttachmentName(interconnectAttachmentName: string) { - return this.pathTemplates.interconnectAttachmentPathTemplate.match(interconnectAttachmentName).project; + matchProjectFromInterconnectAttachmentName( + interconnectAttachmentName: string, + ) { + return this.pathTemplates.interconnectAttachmentPathTemplate.match( + interconnectAttachmentName, + ).project; } /** @@ -4661,8 +6038,12 @@ export class HubServiceClient { * A fully-qualified path representing InterconnectAttachment resource. * @returns {string} A string representing the region. */ - matchRegionFromInterconnectAttachmentName(interconnectAttachmentName: string) { - return this.pathTemplates.interconnectAttachmentPathTemplate.match(interconnectAttachmentName).region; + matchRegionFromInterconnectAttachmentName( + interconnectAttachmentName: string, + ) { + return this.pathTemplates.interconnectAttachmentPathTemplate.match( + interconnectAttachmentName, + ).region; } /** @@ -4672,8 +6053,12 @@ export class HubServiceClient { * A fully-qualified path representing InterconnectAttachment resource. * @returns {string} A string representing the resource_id. */ - matchResourceIdFromInterconnectAttachmentName(interconnectAttachmentName: string) { - return this.pathTemplates.interconnectAttachmentPathTemplate.match(interconnectAttachmentName).resource_id; + matchResourceIdFromInterconnectAttachmentName( + interconnectAttachmentName: string, + ) { + return this.pathTemplates.interconnectAttachmentPathTemplate.match( + interconnectAttachmentName, + ).resource_id; } /** @@ -4684,7 +6069,7 @@ export class HubServiceClient { * @param {string} internal_range * @returns {string} Resource name string. */ - internalRangePath(project:string,location:string,internalRange:string) { + internalRangePath(project: string, location: string, internalRange: string) { return this.pathTemplates.internalRangePathTemplate.render({ project: project, location: location, @@ -4700,7 +6085,8 @@ export class HubServiceClient { * @returns {string} A string representing the project. */ matchProjectFromInternalRangeName(internalRangeName: string) { - return this.pathTemplates.internalRangePathTemplate.match(internalRangeName).project; + return this.pathTemplates.internalRangePathTemplate.match(internalRangeName) + .project; } /** @@ -4711,7 +6097,8 @@ export class HubServiceClient { * @returns {string} A string representing the location. */ matchLocationFromInternalRangeName(internalRangeName: string) { - return this.pathTemplates.internalRangePathTemplate.match(internalRangeName).location; + return this.pathTemplates.internalRangePathTemplate.match(internalRangeName) + .location; } /** @@ -4722,7 +6109,8 @@ export class HubServiceClient { * @returns {string} A string representing the internal_range. */ matchInternalRangeFromInternalRangeName(internalRangeName: string) { - return this.pathTemplates.internalRangePathTemplate.match(internalRangeName).internal_range; + return this.pathTemplates.internalRangePathTemplate.match(internalRangeName) + .internal_range; } /** @@ -4732,7 +6120,7 @@ export class HubServiceClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -4769,7 +6157,11 @@ export class HubServiceClient { * @param {string} multicloud_data_transfer_config * @returns {string} Resource name string. */ - multicloudDataTransferConfigPath(project:string,location:string,multicloudDataTransferConfig:string) { + multicloudDataTransferConfigPath( + project: string, + location: string, + multicloudDataTransferConfig: string, + ) { return this.pathTemplates.multicloudDataTransferConfigPathTemplate.render({ project: project, location: location, @@ -4784,8 +6176,12 @@ export class HubServiceClient { * A fully-qualified path representing MulticloudDataTransferConfig resource. * @returns {string} A string representing the project. */ - matchProjectFromMulticloudDataTransferConfigName(multicloudDataTransferConfigName: string) { - return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match(multicloudDataTransferConfigName).project; + matchProjectFromMulticloudDataTransferConfigName( + multicloudDataTransferConfigName: string, + ) { + return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match( + multicloudDataTransferConfigName, + ).project; } /** @@ -4795,8 +6191,12 @@ export class HubServiceClient { * A fully-qualified path representing MulticloudDataTransferConfig resource. * @returns {string} A string representing the location. */ - matchLocationFromMulticloudDataTransferConfigName(multicloudDataTransferConfigName: string) { - return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match(multicloudDataTransferConfigName).location; + matchLocationFromMulticloudDataTransferConfigName( + multicloudDataTransferConfigName: string, + ) { + return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match( + multicloudDataTransferConfigName, + ).location; } /** @@ -4806,8 +6206,12 @@ export class HubServiceClient { * A fully-qualified path representing MulticloudDataTransferConfig resource. * @returns {string} A string representing the multicloud_data_transfer_config. */ - matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName(multicloudDataTransferConfigName: string) { - return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match(multicloudDataTransferConfigName).multicloud_data_transfer_config; + matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName( + multicloudDataTransferConfigName: string, + ) { + return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match( + multicloudDataTransferConfigName, + ).multicloud_data_transfer_config; } /** @@ -4818,12 +6222,19 @@ export class HubServiceClient { * @param {string} multicloud_data_transfer_supported_service * @returns {string} Resource name string. */ - multicloudDataTransferSupportedServicePath(project:string,location:string,multicloudDataTransferSupportedService:string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render({ - project: project, - location: location, - multicloud_data_transfer_supported_service: multicloudDataTransferSupportedService, - }); + multicloudDataTransferSupportedServicePath( + project: string, + location: string, + multicloudDataTransferSupportedService: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render( + { + project: project, + location: location, + multicloud_data_transfer_supported_service: + multicloudDataTransferSupportedService, + }, + ); } /** @@ -4833,8 +6244,12 @@ export class HubServiceClient { * A fully-qualified path representing MulticloudDataTransferSupportedService resource. * @returns {string} A string representing the project. */ - matchProjectFromMulticloudDataTransferSupportedServiceName(multicloudDataTransferSupportedServiceName: string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match(multicloudDataTransferSupportedServiceName).project; + matchProjectFromMulticloudDataTransferSupportedServiceName( + multicloudDataTransferSupportedServiceName: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match( + multicloudDataTransferSupportedServiceName, + ).project; } /** @@ -4844,8 +6259,12 @@ export class HubServiceClient { * A fully-qualified path representing MulticloudDataTransferSupportedService resource. * @returns {string} A string representing the location. */ - matchLocationFromMulticloudDataTransferSupportedServiceName(multicloudDataTransferSupportedServiceName: string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match(multicloudDataTransferSupportedServiceName).location; + matchLocationFromMulticloudDataTransferSupportedServiceName( + multicloudDataTransferSupportedServiceName: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match( + multicloudDataTransferSupportedServiceName, + ).location; } /** @@ -4855,8 +6274,12 @@ export class HubServiceClient { * A fully-qualified path representing MulticloudDataTransferSupportedService resource. * @returns {string} A string representing the multicloud_data_transfer_supported_service. */ - matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName(multicloudDataTransferSupportedServiceName: string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match(multicloudDataTransferSupportedServiceName).multicloud_data_transfer_supported_service; + matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName( + multicloudDataTransferSupportedServiceName: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match( + multicloudDataTransferSupportedServiceName, + ).multicloud_data_transfer_supported_service; } /** @@ -4866,7 +6289,7 @@ export class HubServiceClient { * @param {string} resource_id * @returns {string} Resource name string. */ - networkPath(project:string,resourceId:string) { + networkPath(project: string, resourceId: string) { return this.pathTemplates.networkPathTemplate.render({ project: project, resource_id: resourceId, @@ -4892,7 +6315,8 @@ export class HubServiceClient { * @returns {string} A string representing the resource_id. */ matchResourceIdFromNetworkName(networkName: string) { - return this.pathTemplates.networkPathTemplate.match(networkName).resource_id; + return this.pathTemplates.networkPathTemplate.match(networkName) + .resource_id; } /** @@ -4902,7 +6326,7 @@ export class HubServiceClient { * @param {string} policy_based_route * @returns {string} Resource name string. */ - policyBasedRoutePath(project:string,policyBasedRoute:string) { + policyBasedRoutePath(project: string, policyBasedRoute: string) { return this.pathTemplates.policyBasedRoutePathTemplate.render({ project: project, policy_based_route: policyBasedRoute, @@ -4917,7 +6341,9 @@ export class HubServiceClient { * @returns {string} A string representing the project. */ matchProjectFromPolicyBasedRouteName(policyBasedRouteName: string) { - return this.pathTemplates.policyBasedRoutePathTemplate.match(policyBasedRouteName).project; + return this.pathTemplates.policyBasedRoutePathTemplate.match( + policyBasedRouteName, + ).project; } /** @@ -4928,7 +6354,9 @@ export class HubServiceClient { * @returns {string} A string representing the policy_based_route. */ matchPolicyBasedRouteFromPolicyBasedRouteName(policyBasedRouteName: string) { - return this.pathTemplates.policyBasedRoutePathTemplate.match(policyBasedRouteName).policy_based_route; + return this.pathTemplates.policyBasedRoutePathTemplate.match( + policyBasedRouteName, + ).policy_based_route; } /** @@ -4939,7 +6367,7 @@ export class HubServiceClient { * @param {string} route_table * @returns {string} Resource name string. */ - routeTablePath(project:string,hub:string,routeTable:string) { + routeTablePath(project: string, hub: string, routeTable: string) { return this.pathTemplates.routeTablePathTemplate.render({ project: project, hub: hub, @@ -4955,7 +6383,8 @@ export class HubServiceClient { * @returns {string} A string representing the project. */ matchProjectFromRouteTableName(routeTableName: string) { - return this.pathTemplates.routeTablePathTemplate.match(routeTableName).project; + return this.pathTemplates.routeTablePathTemplate.match(routeTableName) + .project; } /** @@ -4977,7 +6406,8 @@ export class HubServiceClient { * @returns {string} A string representing the route_table. */ matchRouteTableFromRouteTableName(routeTableName: string) { - return this.pathTemplates.routeTablePathTemplate.match(routeTableName).route_table; + return this.pathTemplates.routeTablePathTemplate.match(routeTableName) + .route_table; } /** @@ -4988,7 +6418,7 @@ export class HubServiceClient { * @param {string} service_class * @returns {string} Resource name string. */ - serviceClassPath(project:string,location:string,serviceClass:string) { + serviceClassPath(project: string, location: string, serviceClass: string) { return this.pathTemplates.serviceClassPathTemplate.render({ project: project, location: location, @@ -5004,7 +6434,8 @@ export class HubServiceClient { * @returns {string} A string representing the project. */ matchProjectFromServiceClassName(serviceClassName: string) { - return this.pathTemplates.serviceClassPathTemplate.match(serviceClassName).project; + return this.pathTemplates.serviceClassPathTemplate.match(serviceClassName) + .project; } /** @@ -5015,7 +6446,8 @@ export class HubServiceClient { * @returns {string} A string representing the location. */ matchLocationFromServiceClassName(serviceClassName: string) { - return this.pathTemplates.serviceClassPathTemplate.match(serviceClassName).location; + return this.pathTemplates.serviceClassPathTemplate.match(serviceClassName) + .location; } /** @@ -5026,7 +6458,8 @@ export class HubServiceClient { * @returns {string} A string representing the service_class. */ matchServiceClassFromServiceClassName(serviceClassName: string) { - return this.pathTemplates.serviceClassPathTemplate.match(serviceClassName).service_class; + return this.pathTemplates.serviceClassPathTemplate.match(serviceClassName) + .service_class; } /** @@ -5037,7 +6470,11 @@ export class HubServiceClient { * @param {string} service_connection_map * @returns {string} Resource name string. */ - serviceConnectionMapPath(project:string,location:string,serviceConnectionMap:string) { + serviceConnectionMapPath( + project: string, + location: string, + serviceConnectionMap: string, + ) { return this.pathTemplates.serviceConnectionMapPathTemplate.render({ project: project, location: location, @@ -5053,7 +6490,9 @@ export class HubServiceClient { * @returns {string} A string representing the project. */ matchProjectFromServiceConnectionMapName(serviceConnectionMapName: string) { - return this.pathTemplates.serviceConnectionMapPathTemplate.match(serviceConnectionMapName).project; + return this.pathTemplates.serviceConnectionMapPathTemplate.match( + serviceConnectionMapName, + ).project; } /** @@ -5064,7 +6503,9 @@ export class HubServiceClient { * @returns {string} A string representing the location. */ matchLocationFromServiceConnectionMapName(serviceConnectionMapName: string) { - return this.pathTemplates.serviceConnectionMapPathTemplate.match(serviceConnectionMapName).location; + return this.pathTemplates.serviceConnectionMapPathTemplate.match( + serviceConnectionMapName, + ).location; } /** @@ -5074,8 +6515,12 @@ export class HubServiceClient { * A fully-qualified path representing ServiceConnectionMap resource. * @returns {string} A string representing the service_connection_map. */ - matchServiceConnectionMapFromServiceConnectionMapName(serviceConnectionMapName: string) { - return this.pathTemplates.serviceConnectionMapPathTemplate.match(serviceConnectionMapName).service_connection_map; + matchServiceConnectionMapFromServiceConnectionMapName( + serviceConnectionMapName: string, + ) { + return this.pathTemplates.serviceConnectionMapPathTemplate.match( + serviceConnectionMapName, + ).service_connection_map; } /** @@ -5086,7 +6531,11 @@ export class HubServiceClient { * @param {string} service_connection_policy * @returns {string} Resource name string. */ - serviceConnectionPolicyPath(project:string,location:string,serviceConnectionPolicy:string) { + serviceConnectionPolicyPath( + project: string, + location: string, + serviceConnectionPolicy: string, + ) { return this.pathTemplates.serviceConnectionPolicyPathTemplate.render({ project: project, location: location, @@ -5101,8 +6550,12 @@ export class HubServiceClient { * A fully-qualified path representing ServiceConnectionPolicy resource. * @returns {string} A string representing the project. */ - matchProjectFromServiceConnectionPolicyName(serviceConnectionPolicyName: string) { - return this.pathTemplates.serviceConnectionPolicyPathTemplate.match(serviceConnectionPolicyName).project; + matchProjectFromServiceConnectionPolicyName( + serviceConnectionPolicyName: string, + ) { + return this.pathTemplates.serviceConnectionPolicyPathTemplate.match( + serviceConnectionPolicyName, + ).project; } /** @@ -5112,8 +6565,12 @@ export class HubServiceClient { * A fully-qualified path representing ServiceConnectionPolicy resource. * @returns {string} A string representing the location. */ - matchLocationFromServiceConnectionPolicyName(serviceConnectionPolicyName: string) { - return this.pathTemplates.serviceConnectionPolicyPathTemplate.match(serviceConnectionPolicyName).location; + matchLocationFromServiceConnectionPolicyName( + serviceConnectionPolicyName: string, + ) { + return this.pathTemplates.serviceConnectionPolicyPathTemplate.match( + serviceConnectionPolicyName, + ).location; } /** @@ -5123,8 +6580,12 @@ export class HubServiceClient { * A fully-qualified path representing ServiceConnectionPolicy resource. * @returns {string} A string representing the service_connection_policy. */ - matchServiceConnectionPolicyFromServiceConnectionPolicyName(serviceConnectionPolicyName: string) { - return this.pathTemplates.serviceConnectionPolicyPathTemplate.match(serviceConnectionPolicyName).service_connection_policy; + matchServiceConnectionPolicyFromServiceConnectionPolicyName( + serviceConnectionPolicyName: string, + ) { + return this.pathTemplates.serviceConnectionPolicyPathTemplate.match( + serviceConnectionPolicyName, + ).service_connection_policy; } /** @@ -5135,7 +6596,11 @@ export class HubServiceClient { * @param {string} service_connection_token * @returns {string} Resource name string. */ - serviceConnectionTokenPath(project:string,location:string,serviceConnectionToken:string) { + serviceConnectionTokenPath( + project: string, + location: string, + serviceConnectionToken: string, + ) { return this.pathTemplates.serviceConnectionTokenPathTemplate.render({ project: project, location: location, @@ -5150,8 +6615,12 @@ export class HubServiceClient { * A fully-qualified path representing ServiceConnectionToken resource. * @returns {string} A string representing the project. */ - matchProjectFromServiceConnectionTokenName(serviceConnectionTokenName: string) { - return this.pathTemplates.serviceConnectionTokenPathTemplate.match(serviceConnectionTokenName).project; + matchProjectFromServiceConnectionTokenName( + serviceConnectionTokenName: string, + ) { + return this.pathTemplates.serviceConnectionTokenPathTemplate.match( + serviceConnectionTokenName, + ).project; } /** @@ -5161,8 +6630,12 @@ export class HubServiceClient { * A fully-qualified path representing ServiceConnectionToken resource. * @returns {string} A string representing the location. */ - matchLocationFromServiceConnectionTokenName(serviceConnectionTokenName: string) { - return this.pathTemplates.serviceConnectionTokenPathTemplate.match(serviceConnectionTokenName).location; + matchLocationFromServiceConnectionTokenName( + serviceConnectionTokenName: string, + ) { + return this.pathTemplates.serviceConnectionTokenPathTemplate.match( + serviceConnectionTokenName, + ).location; } /** @@ -5172,8 +6645,12 @@ export class HubServiceClient { * A fully-qualified path representing ServiceConnectionToken resource. * @returns {string} A string representing the service_connection_token. */ - matchServiceConnectionTokenFromServiceConnectionTokenName(serviceConnectionTokenName: string) { - return this.pathTemplates.serviceConnectionTokenPathTemplate.match(serviceConnectionTokenName).service_connection_token; + matchServiceConnectionTokenFromServiceConnectionTokenName( + serviceConnectionTokenName: string, + ) { + return this.pathTemplates.serviceConnectionTokenPathTemplate.match( + serviceConnectionTokenName, + ).service_connection_token; } /** @@ -5184,7 +6661,7 @@ export class HubServiceClient { * @param {string} spoke * @returns {string} Resource name string. */ - spokePath(project:string,location:string,spoke:string) { + spokePath(project: string, location: string, spoke: string) { return this.pathTemplates.spokePathTemplate.render({ project: project, location: location, @@ -5233,7 +6710,7 @@ export class HubServiceClient { * @param {string} resource_id * @returns {string} Resource name string. */ - vpnTunnelPath(project:string,region:string,resourceId:string) { + vpnTunnelPath(project: string, region: string, resourceId: string) { return this.pathTemplates.vpnTunnelPathTemplate.render({ project: project, region: region, @@ -5249,7 +6726,8 @@ export class HubServiceClient { * @returns {string} A string representing the project. */ matchProjectFromVpnTunnelName(vpnTunnelName: string) { - return this.pathTemplates.vpnTunnelPathTemplate.match(vpnTunnelName).project; + return this.pathTemplates.vpnTunnelPathTemplate.match(vpnTunnelName) + .project; } /** @@ -5271,7 +6749,8 @@ export class HubServiceClient { * @returns {string} A string representing the resource_id. */ matchResourceIdFromVpnTunnelName(vpnTunnelName: string) { - return this.pathTemplates.vpnTunnelPathTemplate.match(vpnTunnelName).resource_id; + return this.pathTemplates.vpnTunnelPathTemplate.match(vpnTunnelName) + .resource_id; } /** @@ -5282,15 +6761,19 @@ export class HubServiceClient { */ close(): Promise { if (this.hubServiceStub && !this._terminated) { - return this.hubServiceStub.then(stub => { + return this.hubServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-networkconnectivity/src/v1/index.ts b/packages/google-cloud-networkconnectivity/src/v1/index.ts index 4f6823df9198..b52ee01d028f 100644 --- a/packages/google-cloud-networkconnectivity/src/v1/index.ts +++ b/packages/google-cloud-networkconnectivity/src/v1/index.ts @@ -16,8 +16,8 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {CrossNetworkAutomationServiceClient} from './cross_network_automation_service_client'; -export {DataTransferServiceClient} from './data_transfer_service_client'; -export {HubServiceClient} from './hub_service_client'; -export {InternalRangeServiceClient} from './internal_range_service_client'; -export {PolicyBasedRoutingServiceClient} from './policy_based_routing_service_client'; +export { CrossNetworkAutomationServiceClient } from './cross_network_automation_service_client'; +export { DataTransferServiceClient } from './data_transfer_service_client'; +export { HubServiceClient } from './hub_service_client'; +export { InternalRangeServiceClient } from './internal_range_service_client'; +export { PolicyBasedRoutingServiceClient } from './policy_based_routing_service_client'; diff --git a/packages/google-cloud-networkconnectivity/src/v1/internal_range_service_client.ts b/packages/google-cloud-networkconnectivity/src/v1/internal_range_service_client.ts index e976c64eea10..5561cbab0658 100644 --- a/packages/google-cloud-networkconnectivity/src/v1/internal_range_service_client.ts +++ b/packages/google-cloud-networkconnectivity/src/v1/internal_range_service_client.ts @@ -18,11 +18,24 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -45,7 +58,7 @@ export class InternalRangeServiceClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('network-connectivity'); @@ -58,12 +71,12 @@ export class InternalRangeServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - internalRangeServiceStub?: Promise<{[name: string]: Function}>; + internalRangeServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of InternalRangeServiceClient. @@ -104,21 +117,42 @@ export class InternalRangeServiceClient { * const client = new InternalRangeServiceClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof InternalRangeServiceClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'networkconnectivity.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -143,7 +177,7 @@ export class InternalRangeServiceClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -156,18 +190,14 @@ export class InternalRangeServiceClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -189,52 +219,54 @@ export class InternalRangeServiceClient { // Create useful helper objects for these. this.pathTemplates = { destinationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}/destinations/{destination}' + 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}/destinations/{destination}', ), groupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}/groups/{group}' + 'projects/{project}/locations/global/hubs/{hub}/groups/{group}', ), hubPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}' + 'projects/{project}/locations/global/hubs/{hub}', ), hubRoutePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}/routes/{route}' + 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}/routes/{route}', ), internalRangePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/internalRanges/{internal_range}' + 'projects/{project}/locations/{location}/internalRanges/{internal_range}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - multicloudDataTransferConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}' - ), - multicloudDataTransferSupportedServicePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/multicloudDataTransferSupportedServices/{multicloud_data_transfer_supported_service}' + 'projects/{project}/locations/{location}', ), + multicloudDataTransferConfigPathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}', + ), + multicloudDataTransferSupportedServicePathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/multicloudDataTransferSupportedServices/{multicloud_data_transfer_supported_service}', + ), policyBasedRoutePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/PolicyBasedRoutes/{policy_based_route}' + 'projects/{project}/locations/global/PolicyBasedRoutes/{policy_based_route}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), routeTablePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}' + 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}', ), serviceClassPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/serviceClasses/{service_class}' + 'projects/{project}/locations/{location}/serviceClasses/{service_class}', ), serviceConnectionMapPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/serviceConnectionMaps/{service_connection_map}' + 'projects/{project}/locations/{location}/serviceConnectionMaps/{service_connection_map}', ), serviceConnectionPolicyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/serviceConnectionPolicies/{service_connection_policy}' + 'projects/{project}/locations/{location}/serviceConnectionPolicies/{service_connection_policy}', ), serviceConnectionTokenPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/serviceConnectionTokens/{service_connection_token}' + 'projects/{project}/locations/{location}/serviceConnectionTokens/{service_connection_token}', ), spokePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/spokes/{spoke}' + 'projects/{project}/locations/{location}/spokes/{spoke}', ), }; @@ -242,8 +274,11 @@ export class InternalRangeServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listInternalRanges: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'internalRanges') + listInternalRanges: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'internalRanges', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -252,48 +287,182 @@ export class InternalRangeServiceClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1/{resource=projects/*/locations/global/hubs/*}:getIamPolicy',additional_bindings: [{get: '/v1/{resource=projects/*/locations/global/hubs/*/groups/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/spokes/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/global/policyBasedRoutes/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/serviceConnectionMaps/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/serviceConnectionPolicies/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/serviceClasses/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/internalRanges/*}:getIamPolicy',}], - },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1/{resource=projects/*/locations/global/hubs/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/global/hubs/*/groups/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/spokes/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/global/policyBasedRoutes/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceConnectionMaps/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceConnectionPolicies/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceClasses/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/internalRanges/*}:setIamPolicy',body: '*',}], - },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1/{resource=projects/*/locations/global/hubs/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/global/hubs/*/groups/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/spokes/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/global/policyBasedRoutes/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceConnectionMaps/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceConnectionPolicies/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceClasses/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/internalRanges/*}:testIamPermissions',body: '*',}], - },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1/{resource=projects/*/locations/global/hubs/*}:getIamPolicy', + additional_bindings: [ + { + get: '/v1/{resource=projects/*/locations/global/hubs/*/groups/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/spokes/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/global/policyBasedRoutes/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/serviceConnectionMaps/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/serviceConnectionPolicies/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/serviceClasses/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/internalRanges/*}:getIamPolicy', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1/{resource=projects/*/locations/global/hubs/*}:setIamPolicy', + body: '*', + additional_bindings: [ + { + post: '/v1/{resource=projects/*/locations/global/hubs/*/groups/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/spokes/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/global/policyBasedRoutes/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceConnectionMaps/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceConnectionPolicies/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceClasses/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/internalRanges/*}:setIamPolicy', + body: '*', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1/{resource=projects/*/locations/global/hubs/*}:testIamPermissions', + body: '*', + additional_bindings: [ + { + post: '/v1/{resource=projects/*/locations/global/hubs/*/groups/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/spokes/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/global/policyBasedRoutes/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceConnectionMaps/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceConnectionPolicies/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceClasses/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/internalRanges/*}:testIamPermissions', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createInternalRangeResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.InternalRange') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.InternalRange', + ) as gax.protobuf.Type; const createInternalRangeMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateInternalRangeResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.InternalRange') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.InternalRange', + ) as gax.protobuf.Type; const updateInternalRangeMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteInternalRangeResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteInternalRangeMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createInternalRange: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createInternalRangeResponse.decode.bind(createInternalRangeResponse), - createInternalRangeMetadata.decode.bind(createInternalRangeMetadata)), + createInternalRangeMetadata.decode.bind(createInternalRangeMetadata), + ), updateInternalRange: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateInternalRangeResponse.decode.bind(updateInternalRangeResponse), - updateInternalRangeMetadata.decode.bind(updateInternalRangeMetadata)), + updateInternalRangeMetadata.decode.bind(updateInternalRangeMetadata), + ), deleteInternalRange: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteInternalRangeResponse.decode.bind(deleteInternalRangeResponse), - deleteInternalRangeMetadata.decode.bind(deleteInternalRangeMetadata)) + deleteInternalRangeMetadata.decode.bind(deleteInternalRangeMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.networkconnectivity.v1.InternalRangeService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.networkconnectivity.v1.InternalRangeService', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -324,28 +493,40 @@ export class InternalRangeServiceClient { // Put together the "service stub" for // google.cloud.networkconnectivity.v1.InternalRangeService. this.internalRangeServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.networkconnectivity.v1.InternalRangeService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.networkconnectivity.v1.InternalRangeService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.networkconnectivity.v1.InternalRangeService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.networkconnectivity.v1 + .InternalRangeService, + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const internalRangeServiceStubMethods = - ['listInternalRanges', 'getInternalRange', 'createInternalRange', 'updateInternalRange', 'deleteInternalRange']; + const internalRangeServiceStubMethods = [ + 'listInternalRanges', + 'getInternalRange', + 'createInternalRange', + 'updateInternalRange', + 'deleteInternalRange', + ]; for (const methodName of internalRangeServiceStubMethods) { const callPromise = this.internalRangeServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -355,7 +536,7 @@ export class InternalRangeServiceClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -370,8 +551,14 @@ export class InternalRangeServiceClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkconnectivity.googleapis.com'; } @@ -382,8 +569,14 @@ export class InternalRangeServiceClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkconnectivity.googleapis.com'; } @@ -414,9 +607,7 @@ export class InternalRangeServiceClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -425,8 +616,9 @@ export class InternalRangeServiceClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -437,562 +629,822 @@ export class InternalRangeServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets details of a single internal range. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the InternalRange to get. - * @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 {@link protos.google.cloud.networkconnectivity.v1.InternalRange|InternalRange}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/internal_range_service.get_internal_range.js - * region_tag:networkconnectivity_v1_generated_InternalRangeService_GetInternalRange_async - */ + /** + * Gets details of a single internal range. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the InternalRange to get. + * @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 {@link protos.google.cloud.networkconnectivity.v1.InternalRange|InternalRange}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/internal_range_service.get_internal_range.js + * region_tag:networkconnectivity_v1_generated_InternalRangeService_GetInternalRange_async + */ getInternalRange( - request?: protos.google.cloud.networkconnectivity.v1.IGetInternalRangeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IInternalRange, - protos.google.cloud.networkconnectivity.v1.IGetInternalRangeRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IGetInternalRangeRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IInternalRange, + ( + | protos.google.cloud.networkconnectivity.v1.IGetInternalRangeRequest + | undefined + ), + {} | undefined, + ] + >; getInternalRange( - request: protos.google.cloud.networkconnectivity.v1.IGetInternalRangeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkconnectivity.v1.IInternalRange, - protos.google.cloud.networkconnectivity.v1.IGetInternalRangeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IGetInternalRangeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkconnectivity.v1.IInternalRange, + | protos.google.cloud.networkconnectivity.v1.IGetInternalRangeRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getInternalRange( - request: protos.google.cloud.networkconnectivity.v1.IGetInternalRangeRequest, - callback: Callback< - protos.google.cloud.networkconnectivity.v1.IInternalRange, - protos.google.cloud.networkconnectivity.v1.IGetInternalRangeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IGetInternalRangeRequest, + callback: Callback< + protos.google.cloud.networkconnectivity.v1.IInternalRange, + | protos.google.cloud.networkconnectivity.v1.IGetInternalRangeRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getInternalRange( - request?: protos.google.cloud.networkconnectivity.v1.IGetInternalRangeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkconnectivity.v1.IInternalRange, - protos.google.cloud.networkconnectivity.v1.IGetInternalRangeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkconnectivity.v1.IGetInternalRangeRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkconnectivity.v1.IInternalRange, - protos.google.cloud.networkconnectivity.v1.IGetInternalRangeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IInternalRange, - protos.google.cloud.networkconnectivity.v1.IGetInternalRangeRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkconnectivity.v1.IGetInternalRangeRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkconnectivity.v1.IInternalRange, + | protos.google.cloud.networkconnectivity.v1.IGetInternalRangeRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IInternalRange, + ( + | protos.google.cloud.networkconnectivity.v1.IGetInternalRangeRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getInternalRange request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkconnectivity.v1.IInternalRange, - protos.google.cloud.networkconnectivity.v1.IGetInternalRangeRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkconnectivity.v1.IInternalRange, + | protos.google.cloud.networkconnectivity.v1.IGetInternalRangeRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getInternalRange response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getInternalRange(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkconnectivity.v1.IInternalRange, - protos.google.cloud.networkconnectivity.v1.IGetInternalRangeRequest|undefined, - {}|undefined - ]) => { - this._log.info('getInternalRange response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getInternalRange(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkconnectivity.v1.IInternalRange, + ( + | protos.google.cloud.networkconnectivity.v1.IGetInternalRangeRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getInternalRange response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a new internal range in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name of the internal range. - * @param {string} [request.internalRangeId] - * Optional. Resource ID - * (i.e. 'foo' in '[...]/projects/p/locations/l/internalRanges/foo') - * See https://google.aip.dev/122#resource-id-segments - * Unique per location. - * @param {google.cloud.networkconnectivity.v1.InternalRange} request.internalRange - * Required. Initial values for a new internal range - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/internal_range_service.create_internal_range.js - * region_tag:networkconnectivity_v1_generated_InternalRangeService_CreateInternalRange_async - */ + /** + * Creates a new internal range in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name of the internal range. + * @param {string} [request.internalRangeId] + * Optional. Resource ID + * (i.e. 'foo' in '[...]/projects/p/locations/l/internalRanges/foo') + * See https://google.aip.dev/122#resource-id-segments + * Unique per location. + * @param {google.cloud.networkconnectivity.v1.InternalRange} request.internalRange + * Required. Initial values for a new internal range + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/internal_range_service.create_internal_range.js + * region_tag:networkconnectivity_v1_generated_InternalRangeService_CreateInternalRange_async + */ createInternalRange( - request?: protos.google.cloud.networkconnectivity.v1.ICreateInternalRangeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.ICreateInternalRangeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IInternalRange, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createInternalRange( - request: protos.google.cloud.networkconnectivity.v1.ICreateInternalRangeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.ICreateInternalRangeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IInternalRange, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createInternalRange( - request: protos.google.cloud.networkconnectivity.v1.ICreateInternalRangeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.ICreateInternalRangeRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IInternalRange, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createInternalRange( - request?: protos.google.cloud.networkconnectivity.v1.ICreateInternalRangeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1.ICreateInternalRangeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IInternalRange, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IInternalRange, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IInternalRange, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IInternalRange, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createInternalRange response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createInternalRange request %j', request); - return this.innerApiCalls.createInternalRange(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createInternalRange response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createInternalRange(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IInternalRange, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createInternalRange response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createInternalRange()`. - * @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/internal_range_service.create_internal_range.js - * region_tag:networkconnectivity_v1_generated_InternalRangeService_CreateInternalRange_async - */ - async checkCreateInternalRangeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createInternalRange()`. + * @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/internal_range_service.create_internal_range.js + * region_tag:networkconnectivity_v1_generated_InternalRangeService_CreateInternalRange_async + */ + async checkCreateInternalRangeProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1.InternalRange, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('createInternalRange long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createInternalRange, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createInternalRange, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1.InternalRange, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; } -/** - * Updates the parameters of a single internal range. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask is used to specify the fields to be overwritten in the - * InternalRange resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - * @param {google.cloud.networkconnectivity.v1.InternalRange} request.internalRange - * Required. New values to be patched into the resource. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/internal_range_service.update_internal_range.js - * region_tag:networkconnectivity_v1_generated_InternalRangeService_UpdateInternalRange_async - */ + /** + * Updates the parameters of a single internal range. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask is used to specify the fields to be overwritten in the + * InternalRange resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @param {google.cloud.networkconnectivity.v1.InternalRange} request.internalRange + * Required. New values to be patched into the resource. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/internal_range_service.update_internal_range.js + * region_tag:networkconnectivity_v1_generated_InternalRangeService_UpdateInternalRange_async + */ updateInternalRange( - request?: protos.google.cloud.networkconnectivity.v1.IUpdateInternalRangeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IUpdateInternalRangeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IInternalRange, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateInternalRange( - request: protos.google.cloud.networkconnectivity.v1.IUpdateInternalRangeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IUpdateInternalRangeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IInternalRange, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateInternalRange( - request: protos.google.cloud.networkconnectivity.v1.IUpdateInternalRangeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IUpdateInternalRangeRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IInternalRange, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateInternalRange( - request?: protos.google.cloud.networkconnectivity.v1.IUpdateInternalRangeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1.IUpdateInternalRangeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IInternalRange, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IInternalRange, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IInternalRange, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'internal_range.name': request.internalRange!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'internal_range.name': request.internalRange!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IInternalRange, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateInternalRange response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateInternalRange request %j', request); - return this.innerApiCalls.updateInternalRange(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateInternalRange response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateInternalRange(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IInternalRange, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateInternalRange response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateInternalRange()`. - * @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/internal_range_service.update_internal_range.js - * region_tag:networkconnectivity_v1_generated_InternalRangeService_UpdateInternalRange_async - */ - async checkUpdateInternalRangeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateInternalRange()`. + * @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/internal_range_service.update_internal_range.js + * region_tag:networkconnectivity_v1_generated_InternalRangeService_UpdateInternalRange_async + */ + async checkUpdateInternalRangeProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1.InternalRange, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('updateInternalRange long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateInternalRange, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateInternalRange, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1.InternalRange, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; } -/** - * Deletes a single internal range. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the internal range to delete. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/internal_range_service.delete_internal_range.js - * region_tag:networkconnectivity_v1_generated_InternalRangeService_DeleteInternalRange_async - */ + /** + * Deletes a single internal range. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the internal range to delete. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/internal_range_service.delete_internal_range.js + * region_tag:networkconnectivity_v1_generated_InternalRangeService_DeleteInternalRange_async + */ deleteInternalRange( - request?: protos.google.cloud.networkconnectivity.v1.IDeleteInternalRangeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IDeleteInternalRangeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteInternalRange( - request: protos.google.cloud.networkconnectivity.v1.IDeleteInternalRangeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IDeleteInternalRangeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteInternalRange( - request: protos.google.cloud.networkconnectivity.v1.IDeleteInternalRangeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IDeleteInternalRangeRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteInternalRange( - request?: protos.google.cloud.networkconnectivity.v1.IDeleteInternalRangeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1.IDeleteInternalRangeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteInternalRange response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteInternalRange request %j', request); - return this.innerApiCalls.deleteInternalRange(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteInternalRange response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteInternalRange(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteInternalRange response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteInternalRange()`. - * @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/internal_range_service.delete_internal_range.js - * region_tag:networkconnectivity_v1_generated_InternalRangeService_DeleteInternalRange_async - */ - async checkDeleteInternalRangeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteInternalRange()`. + * @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/internal_range_service.delete_internal_range.js + * region_tag:networkconnectivity_v1_generated_InternalRangeService_DeleteInternalRange_async + */ + async checkDeleteInternalRangeProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('deleteInternalRange long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteInternalRange, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists internal ranges in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results per page that should be returned. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * A filter expression that filters the results listed in the response. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.InternalRange|InternalRange}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listInternalRangesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteInternalRange, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; + } + /** + * Lists internal ranges in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results per page that should be returned. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * A filter expression that filters the results listed in the response. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.InternalRange|InternalRange}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listInternalRangesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listInternalRanges( - request?: protos.google.cloud.networkconnectivity.v1.IListInternalRangesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IInternalRange[], - protos.google.cloud.networkconnectivity.v1.IListInternalRangesRequest|null, - protos.google.cloud.networkconnectivity.v1.IListInternalRangesResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IListInternalRangesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IInternalRange[], + protos.google.cloud.networkconnectivity.v1.IListInternalRangesRequest | null, + protos.google.cloud.networkconnectivity.v1.IListInternalRangesResponse, + ] + >; listInternalRanges( - request: protos.google.cloud.networkconnectivity.v1.IListInternalRangesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListInternalRangesRequest, - protos.google.cloud.networkconnectivity.v1.IListInternalRangesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IInternalRange>): void; + request: protos.google.cloud.networkconnectivity.v1.IListInternalRangesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListInternalRangesRequest, + | protos.google.cloud.networkconnectivity.v1.IListInternalRangesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IInternalRange + >, + ): void; listInternalRanges( - request: protos.google.cloud.networkconnectivity.v1.IListInternalRangesRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListInternalRangesRequest, - protos.google.cloud.networkconnectivity.v1.IListInternalRangesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IInternalRange>): void; + request: protos.google.cloud.networkconnectivity.v1.IListInternalRangesRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListInternalRangesRequest, + | protos.google.cloud.networkconnectivity.v1.IListInternalRangesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IInternalRange + >, + ): void; listInternalRanges( - request?: protos.google.cloud.networkconnectivity.v1.IListInternalRangesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListInternalRangesRequest, - protos.google.cloud.networkconnectivity.v1.IListInternalRangesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IInternalRange>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1.IListInternalRangesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1.IListInternalRangesRequest, - protos.google.cloud.networkconnectivity.v1.IListInternalRangesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IInternalRange>): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IInternalRange[], - protos.google.cloud.networkconnectivity.v1.IListInternalRangesRequest|null, - protos.google.cloud.networkconnectivity.v1.IListInternalRangesResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1.IListInternalRangesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IInternalRange + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListInternalRangesRequest, + | protos.google.cloud.networkconnectivity.v1.IListInternalRangesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IInternalRange + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IInternalRange[], + protos.google.cloud.networkconnectivity.v1.IListInternalRangesRequest | null, + protos.google.cloud.networkconnectivity.v1.IListInternalRangesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListInternalRangesRequest, - protos.google.cloud.networkconnectivity.v1.IListInternalRangesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IInternalRange>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListInternalRangesRequest, + | protos.google.cloud.networkconnectivity.v1.IListInternalRangesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IInternalRange + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listInternalRanges values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1001,141 +1453,145 @@ export class InternalRangeServiceClient { this._log.info('listInternalRanges request %j', request); return this.innerApiCalls .listInternalRanges(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1.IInternalRange[], - protos.google.cloud.networkconnectivity.v1.IListInternalRangesRequest|null, - protos.google.cloud.networkconnectivity.v1.IListInternalRangesResponse - ]) => { - this._log.info('listInternalRanges values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1.IInternalRange[], + protos.google.cloud.networkconnectivity.v1.IListInternalRangesRequest | null, + protos.google.cloud.networkconnectivity.v1.IListInternalRangesResponse, + ]) => { + this._log.info('listInternalRanges values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listInternalRanges`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results per page that should be returned. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * A filter expression that filters the results listed in the response. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.InternalRange|InternalRange} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listInternalRangesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listInternalRanges`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results per page that should be returned. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * A filter expression that filters the results listed in the response. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.InternalRange|InternalRange} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listInternalRangesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listInternalRangesStream( - request?: protos.google.cloud.networkconnectivity.v1.IListInternalRangesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1.IListInternalRangesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listInternalRanges']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listInternalRanges stream %j', request); return this.descriptors.page.listInternalRanges.createStream( this.innerApiCalls.listInternalRanges as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listInternalRanges`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results per page that should be returned. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * A filter expression that filters the results listed in the response. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1.InternalRange|InternalRange}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/internal_range_service.list_internal_ranges.js - * region_tag:networkconnectivity_v1_generated_InternalRangeService_ListInternalRanges_async - */ + /** + * Equivalent to `listInternalRanges`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results per page that should be returned. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * A filter expression that filters the results listed in the response. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1.InternalRange|InternalRange}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/internal_range_service.list_internal_ranges.js + * region_tag:networkconnectivity_v1_generated_InternalRangeService_ListInternalRanges_async + */ listInternalRangesAsync( - request?: protos.google.cloud.networkconnectivity.v1.IListInternalRangesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1.IListInternalRangesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listInternalRanges']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listInternalRanges iterate %j', request); return this.descriptors.page.listInternalRanges.asyncIterate( this.innerApiCalls['listInternalRanges'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -1149,40 +1605,40 @@ export class InternalRangeServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -1196,41 +1652,41 @@ export class InternalRangeServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -1244,12 +1700,12 @@ export class InternalRangeServiceClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -1284,12 +1740,11 @@ export class InternalRangeServiceClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -1322,12 +1777,12 @@ export class InternalRangeServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -1370,22 +1825,22 @@ export class InternalRangeServiceClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -1420,15 +1875,15 @@ export class InternalRangeServiceClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - 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 ?? '', - }); + 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 ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -1462,7 +1917,7 @@ export class InternalRangeServiceClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -1475,25 +1930,24 @@ export class InternalRangeServiceClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -1532,22 +1986,22 @@ export class InternalRangeServiceClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -1564,7 +2018,12 @@ export class InternalRangeServiceClient { * @param {string} destination * @returns {string} Resource name string. */ - destinationPath(project:string,location:string,multicloudDataTransferConfig:string,destination:string) { + destinationPath( + project: string, + location: string, + multicloudDataTransferConfig: string, + destination: string, + ) { return this.pathTemplates.destinationPathTemplate.render({ project: project, location: location, @@ -1581,7 +2040,8 @@ export class InternalRangeServiceClient { * @returns {string} A string representing the project. */ matchProjectFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).project; + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .project; } /** @@ -1592,7 +2052,8 @@ export class InternalRangeServiceClient { * @returns {string} A string representing the location. */ matchLocationFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).location; + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .location; } /** @@ -1602,8 +2063,11 @@ export class InternalRangeServiceClient { * A fully-qualified path representing Destination resource. * @returns {string} A string representing the multicloud_data_transfer_config. */ - matchMulticloudDataTransferConfigFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).multicloud_data_transfer_config; + matchMulticloudDataTransferConfigFromDestinationName( + destinationName: string, + ) { + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .multicloud_data_transfer_config; } /** @@ -1614,7 +2078,8 @@ export class InternalRangeServiceClient { * @returns {string} A string representing the destination. */ matchDestinationFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).destination; + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .destination; } /** @@ -1625,7 +2090,7 @@ export class InternalRangeServiceClient { * @param {string} group * @returns {string} Resource name string. */ - groupPath(project:string,hub:string,group:string) { + groupPath(project: string, hub: string, group: string) { return this.pathTemplates.groupPathTemplate.render({ project: project, hub: hub, @@ -1673,7 +2138,7 @@ export class InternalRangeServiceClient { * @param {string} hub * @returns {string} Resource name string. */ - hubPath(project:string,hub:string) { + hubPath(project: string, hub: string) { return this.pathTemplates.hubPathTemplate.render({ project: project, hub: hub, @@ -1711,7 +2176,12 @@ export class InternalRangeServiceClient { * @param {string} route * @returns {string} Resource name string. */ - hubRoutePath(project:string,hub:string,routeTable:string,route:string) { + hubRoutePath( + project: string, + hub: string, + routeTable: string, + route: string, + ) { return this.pathTemplates.hubRoutePathTemplate.render({ project: project, hub: hub, @@ -1750,7 +2220,8 @@ export class InternalRangeServiceClient { * @returns {string} A string representing the route_table. */ matchRouteTableFromHubRouteName(hubRouteName: string) { - return this.pathTemplates.hubRoutePathTemplate.match(hubRouteName).route_table; + return this.pathTemplates.hubRoutePathTemplate.match(hubRouteName) + .route_table; } /** @@ -1772,7 +2243,7 @@ export class InternalRangeServiceClient { * @param {string} internal_range * @returns {string} Resource name string. */ - internalRangePath(project:string,location:string,internalRange:string) { + internalRangePath(project: string, location: string, internalRange: string) { return this.pathTemplates.internalRangePathTemplate.render({ project: project, location: location, @@ -1788,7 +2259,8 @@ export class InternalRangeServiceClient { * @returns {string} A string representing the project. */ matchProjectFromInternalRangeName(internalRangeName: string) { - return this.pathTemplates.internalRangePathTemplate.match(internalRangeName).project; + return this.pathTemplates.internalRangePathTemplate.match(internalRangeName) + .project; } /** @@ -1799,7 +2271,8 @@ export class InternalRangeServiceClient { * @returns {string} A string representing the location. */ matchLocationFromInternalRangeName(internalRangeName: string) { - return this.pathTemplates.internalRangePathTemplate.match(internalRangeName).location; + return this.pathTemplates.internalRangePathTemplate.match(internalRangeName) + .location; } /** @@ -1810,7 +2283,8 @@ export class InternalRangeServiceClient { * @returns {string} A string representing the internal_range. */ matchInternalRangeFromInternalRangeName(internalRangeName: string) { - return this.pathTemplates.internalRangePathTemplate.match(internalRangeName).internal_range; + return this.pathTemplates.internalRangePathTemplate.match(internalRangeName) + .internal_range; } /** @@ -1820,7 +2294,7 @@ export class InternalRangeServiceClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -1857,7 +2331,11 @@ export class InternalRangeServiceClient { * @param {string} multicloud_data_transfer_config * @returns {string} Resource name string. */ - multicloudDataTransferConfigPath(project:string,location:string,multicloudDataTransferConfig:string) { + multicloudDataTransferConfigPath( + project: string, + location: string, + multicloudDataTransferConfig: string, + ) { return this.pathTemplates.multicloudDataTransferConfigPathTemplate.render({ project: project, location: location, @@ -1872,8 +2350,12 @@ export class InternalRangeServiceClient { * A fully-qualified path representing MulticloudDataTransferConfig resource. * @returns {string} A string representing the project. */ - matchProjectFromMulticloudDataTransferConfigName(multicloudDataTransferConfigName: string) { - return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match(multicloudDataTransferConfigName).project; + matchProjectFromMulticloudDataTransferConfigName( + multicloudDataTransferConfigName: string, + ) { + return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match( + multicloudDataTransferConfigName, + ).project; } /** @@ -1883,8 +2365,12 @@ export class InternalRangeServiceClient { * A fully-qualified path representing MulticloudDataTransferConfig resource. * @returns {string} A string representing the location. */ - matchLocationFromMulticloudDataTransferConfigName(multicloudDataTransferConfigName: string) { - return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match(multicloudDataTransferConfigName).location; + matchLocationFromMulticloudDataTransferConfigName( + multicloudDataTransferConfigName: string, + ) { + return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match( + multicloudDataTransferConfigName, + ).location; } /** @@ -1894,8 +2380,12 @@ export class InternalRangeServiceClient { * A fully-qualified path representing MulticloudDataTransferConfig resource. * @returns {string} A string representing the multicloud_data_transfer_config. */ - matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName(multicloudDataTransferConfigName: string) { - return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match(multicloudDataTransferConfigName).multicloud_data_transfer_config; + matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName( + multicloudDataTransferConfigName: string, + ) { + return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match( + multicloudDataTransferConfigName, + ).multicloud_data_transfer_config; } /** @@ -1906,12 +2396,19 @@ export class InternalRangeServiceClient { * @param {string} multicloud_data_transfer_supported_service * @returns {string} Resource name string. */ - multicloudDataTransferSupportedServicePath(project:string,location:string,multicloudDataTransferSupportedService:string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render({ - project: project, - location: location, - multicloud_data_transfer_supported_service: multicloudDataTransferSupportedService, - }); + multicloudDataTransferSupportedServicePath( + project: string, + location: string, + multicloudDataTransferSupportedService: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render( + { + project: project, + location: location, + multicloud_data_transfer_supported_service: + multicloudDataTransferSupportedService, + }, + ); } /** @@ -1921,8 +2418,12 @@ export class InternalRangeServiceClient { * A fully-qualified path representing MulticloudDataTransferSupportedService resource. * @returns {string} A string representing the project. */ - matchProjectFromMulticloudDataTransferSupportedServiceName(multicloudDataTransferSupportedServiceName: string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match(multicloudDataTransferSupportedServiceName).project; + matchProjectFromMulticloudDataTransferSupportedServiceName( + multicloudDataTransferSupportedServiceName: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match( + multicloudDataTransferSupportedServiceName, + ).project; } /** @@ -1932,8 +2433,12 @@ export class InternalRangeServiceClient { * A fully-qualified path representing MulticloudDataTransferSupportedService resource. * @returns {string} A string representing the location. */ - matchLocationFromMulticloudDataTransferSupportedServiceName(multicloudDataTransferSupportedServiceName: string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match(multicloudDataTransferSupportedServiceName).location; + matchLocationFromMulticloudDataTransferSupportedServiceName( + multicloudDataTransferSupportedServiceName: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match( + multicloudDataTransferSupportedServiceName, + ).location; } /** @@ -1943,8 +2448,12 @@ export class InternalRangeServiceClient { * A fully-qualified path representing MulticloudDataTransferSupportedService resource. * @returns {string} A string representing the multicloud_data_transfer_supported_service. */ - matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName(multicloudDataTransferSupportedServiceName: string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match(multicloudDataTransferSupportedServiceName).multicloud_data_transfer_supported_service; + matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName( + multicloudDataTransferSupportedServiceName: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match( + multicloudDataTransferSupportedServiceName, + ).multicloud_data_transfer_supported_service; } /** @@ -1954,7 +2463,7 @@ export class InternalRangeServiceClient { * @param {string} policy_based_route * @returns {string} Resource name string. */ - policyBasedRoutePath(project:string,policyBasedRoute:string) { + policyBasedRoutePath(project: string, policyBasedRoute: string) { return this.pathTemplates.policyBasedRoutePathTemplate.render({ project: project, policy_based_route: policyBasedRoute, @@ -1969,7 +2478,9 @@ export class InternalRangeServiceClient { * @returns {string} A string representing the project. */ matchProjectFromPolicyBasedRouteName(policyBasedRouteName: string) { - return this.pathTemplates.policyBasedRoutePathTemplate.match(policyBasedRouteName).project; + return this.pathTemplates.policyBasedRoutePathTemplate.match( + policyBasedRouteName, + ).project; } /** @@ -1980,7 +2491,9 @@ export class InternalRangeServiceClient { * @returns {string} A string representing the policy_based_route. */ matchPolicyBasedRouteFromPolicyBasedRouteName(policyBasedRouteName: string) { - return this.pathTemplates.policyBasedRoutePathTemplate.match(policyBasedRouteName).policy_based_route; + return this.pathTemplates.policyBasedRoutePathTemplate.match( + policyBasedRouteName, + ).policy_based_route; } /** @@ -1989,7 +2502,7 @@ export class InternalRangeServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -2014,7 +2527,7 @@ export class InternalRangeServiceClient { * @param {string} route_table * @returns {string} Resource name string. */ - routeTablePath(project:string,hub:string,routeTable:string) { + routeTablePath(project: string, hub: string, routeTable: string) { return this.pathTemplates.routeTablePathTemplate.render({ project: project, hub: hub, @@ -2030,7 +2543,8 @@ export class InternalRangeServiceClient { * @returns {string} A string representing the project. */ matchProjectFromRouteTableName(routeTableName: string) { - return this.pathTemplates.routeTablePathTemplate.match(routeTableName).project; + return this.pathTemplates.routeTablePathTemplate.match(routeTableName) + .project; } /** @@ -2052,7 +2566,8 @@ export class InternalRangeServiceClient { * @returns {string} A string representing the route_table. */ matchRouteTableFromRouteTableName(routeTableName: string) { - return this.pathTemplates.routeTablePathTemplate.match(routeTableName).route_table; + return this.pathTemplates.routeTablePathTemplate.match(routeTableName) + .route_table; } /** @@ -2063,7 +2578,7 @@ export class InternalRangeServiceClient { * @param {string} service_class * @returns {string} Resource name string. */ - serviceClassPath(project:string,location:string,serviceClass:string) { + serviceClassPath(project: string, location: string, serviceClass: string) { return this.pathTemplates.serviceClassPathTemplate.render({ project: project, location: location, @@ -2079,7 +2594,8 @@ export class InternalRangeServiceClient { * @returns {string} A string representing the project. */ matchProjectFromServiceClassName(serviceClassName: string) { - return this.pathTemplates.serviceClassPathTemplate.match(serviceClassName).project; + return this.pathTemplates.serviceClassPathTemplate.match(serviceClassName) + .project; } /** @@ -2090,7 +2606,8 @@ export class InternalRangeServiceClient { * @returns {string} A string representing the location. */ matchLocationFromServiceClassName(serviceClassName: string) { - return this.pathTemplates.serviceClassPathTemplate.match(serviceClassName).location; + return this.pathTemplates.serviceClassPathTemplate.match(serviceClassName) + .location; } /** @@ -2101,7 +2618,8 @@ export class InternalRangeServiceClient { * @returns {string} A string representing the service_class. */ matchServiceClassFromServiceClassName(serviceClassName: string) { - return this.pathTemplates.serviceClassPathTemplate.match(serviceClassName).service_class; + return this.pathTemplates.serviceClassPathTemplate.match(serviceClassName) + .service_class; } /** @@ -2112,7 +2630,11 @@ export class InternalRangeServiceClient { * @param {string} service_connection_map * @returns {string} Resource name string. */ - serviceConnectionMapPath(project:string,location:string,serviceConnectionMap:string) { + serviceConnectionMapPath( + project: string, + location: string, + serviceConnectionMap: string, + ) { return this.pathTemplates.serviceConnectionMapPathTemplate.render({ project: project, location: location, @@ -2128,7 +2650,9 @@ export class InternalRangeServiceClient { * @returns {string} A string representing the project. */ matchProjectFromServiceConnectionMapName(serviceConnectionMapName: string) { - return this.pathTemplates.serviceConnectionMapPathTemplate.match(serviceConnectionMapName).project; + return this.pathTemplates.serviceConnectionMapPathTemplate.match( + serviceConnectionMapName, + ).project; } /** @@ -2139,7 +2663,9 @@ export class InternalRangeServiceClient { * @returns {string} A string representing the location. */ matchLocationFromServiceConnectionMapName(serviceConnectionMapName: string) { - return this.pathTemplates.serviceConnectionMapPathTemplate.match(serviceConnectionMapName).location; + return this.pathTemplates.serviceConnectionMapPathTemplate.match( + serviceConnectionMapName, + ).location; } /** @@ -2149,8 +2675,12 @@ export class InternalRangeServiceClient { * A fully-qualified path representing ServiceConnectionMap resource. * @returns {string} A string representing the service_connection_map. */ - matchServiceConnectionMapFromServiceConnectionMapName(serviceConnectionMapName: string) { - return this.pathTemplates.serviceConnectionMapPathTemplate.match(serviceConnectionMapName).service_connection_map; + matchServiceConnectionMapFromServiceConnectionMapName( + serviceConnectionMapName: string, + ) { + return this.pathTemplates.serviceConnectionMapPathTemplate.match( + serviceConnectionMapName, + ).service_connection_map; } /** @@ -2161,7 +2691,11 @@ export class InternalRangeServiceClient { * @param {string} service_connection_policy * @returns {string} Resource name string. */ - serviceConnectionPolicyPath(project:string,location:string,serviceConnectionPolicy:string) { + serviceConnectionPolicyPath( + project: string, + location: string, + serviceConnectionPolicy: string, + ) { return this.pathTemplates.serviceConnectionPolicyPathTemplate.render({ project: project, location: location, @@ -2176,8 +2710,12 @@ export class InternalRangeServiceClient { * A fully-qualified path representing ServiceConnectionPolicy resource. * @returns {string} A string representing the project. */ - matchProjectFromServiceConnectionPolicyName(serviceConnectionPolicyName: string) { - return this.pathTemplates.serviceConnectionPolicyPathTemplate.match(serviceConnectionPolicyName).project; + matchProjectFromServiceConnectionPolicyName( + serviceConnectionPolicyName: string, + ) { + return this.pathTemplates.serviceConnectionPolicyPathTemplate.match( + serviceConnectionPolicyName, + ).project; } /** @@ -2187,8 +2725,12 @@ export class InternalRangeServiceClient { * A fully-qualified path representing ServiceConnectionPolicy resource. * @returns {string} A string representing the location. */ - matchLocationFromServiceConnectionPolicyName(serviceConnectionPolicyName: string) { - return this.pathTemplates.serviceConnectionPolicyPathTemplate.match(serviceConnectionPolicyName).location; + matchLocationFromServiceConnectionPolicyName( + serviceConnectionPolicyName: string, + ) { + return this.pathTemplates.serviceConnectionPolicyPathTemplate.match( + serviceConnectionPolicyName, + ).location; } /** @@ -2198,8 +2740,12 @@ export class InternalRangeServiceClient { * A fully-qualified path representing ServiceConnectionPolicy resource. * @returns {string} A string representing the service_connection_policy. */ - matchServiceConnectionPolicyFromServiceConnectionPolicyName(serviceConnectionPolicyName: string) { - return this.pathTemplates.serviceConnectionPolicyPathTemplate.match(serviceConnectionPolicyName).service_connection_policy; + matchServiceConnectionPolicyFromServiceConnectionPolicyName( + serviceConnectionPolicyName: string, + ) { + return this.pathTemplates.serviceConnectionPolicyPathTemplate.match( + serviceConnectionPolicyName, + ).service_connection_policy; } /** @@ -2210,7 +2756,11 @@ export class InternalRangeServiceClient { * @param {string} service_connection_token * @returns {string} Resource name string. */ - serviceConnectionTokenPath(project:string,location:string,serviceConnectionToken:string) { + serviceConnectionTokenPath( + project: string, + location: string, + serviceConnectionToken: string, + ) { return this.pathTemplates.serviceConnectionTokenPathTemplate.render({ project: project, location: location, @@ -2225,8 +2775,12 @@ export class InternalRangeServiceClient { * A fully-qualified path representing ServiceConnectionToken resource. * @returns {string} A string representing the project. */ - matchProjectFromServiceConnectionTokenName(serviceConnectionTokenName: string) { - return this.pathTemplates.serviceConnectionTokenPathTemplate.match(serviceConnectionTokenName).project; + matchProjectFromServiceConnectionTokenName( + serviceConnectionTokenName: string, + ) { + return this.pathTemplates.serviceConnectionTokenPathTemplate.match( + serviceConnectionTokenName, + ).project; } /** @@ -2236,8 +2790,12 @@ export class InternalRangeServiceClient { * A fully-qualified path representing ServiceConnectionToken resource. * @returns {string} A string representing the location. */ - matchLocationFromServiceConnectionTokenName(serviceConnectionTokenName: string) { - return this.pathTemplates.serviceConnectionTokenPathTemplate.match(serviceConnectionTokenName).location; + matchLocationFromServiceConnectionTokenName( + serviceConnectionTokenName: string, + ) { + return this.pathTemplates.serviceConnectionTokenPathTemplate.match( + serviceConnectionTokenName, + ).location; } /** @@ -2247,8 +2805,12 @@ export class InternalRangeServiceClient { * A fully-qualified path representing ServiceConnectionToken resource. * @returns {string} A string representing the service_connection_token. */ - matchServiceConnectionTokenFromServiceConnectionTokenName(serviceConnectionTokenName: string) { - return this.pathTemplates.serviceConnectionTokenPathTemplate.match(serviceConnectionTokenName).service_connection_token; + matchServiceConnectionTokenFromServiceConnectionTokenName( + serviceConnectionTokenName: string, + ) { + return this.pathTemplates.serviceConnectionTokenPathTemplate.match( + serviceConnectionTokenName, + ).service_connection_token; } /** @@ -2259,7 +2821,7 @@ export class InternalRangeServiceClient { * @param {string} spoke * @returns {string} Resource name string. */ - spokePath(project:string,location:string,spoke:string) { + spokePath(project: string, location: string, spoke: string) { return this.pathTemplates.spokePathTemplate.render({ project: project, location: location, @@ -2308,15 +2870,19 @@ export class InternalRangeServiceClient { */ close(): Promise { if (this.internalRangeServiceStub && !this._terminated) { - return this.internalRangeServiceStub.then(stub => { + return this.internalRangeServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-networkconnectivity/src/v1/policy_based_routing_service_client.ts b/packages/google-cloud-networkconnectivity/src/v1/policy_based_routing_service_client.ts index 56c842ef1870..d992cdea147d 100644 --- a/packages/google-cloud-networkconnectivity/src/v1/policy_based_routing_service_client.ts +++ b/packages/google-cloud-networkconnectivity/src/v1/policy_based_routing_service_client.ts @@ -18,11 +18,24 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -45,7 +58,7 @@ export class PolicyBasedRoutingServiceClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('network-connectivity'); @@ -58,12 +71,12 @@ export class PolicyBasedRoutingServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - policyBasedRoutingServiceStub?: Promise<{[name: string]: Function}>; + policyBasedRoutingServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of PolicyBasedRoutingServiceClient. @@ -104,21 +117,43 @@ export class PolicyBasedRoutingServiceClient { * const client = new PolicyBasedRoutingServiceClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof PolicyBasedRoutingServiceClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + const staticMembers = this + .constructor as typeof PolicyBasedRoutingServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'networkconnectivity.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -143,7 +178,7 @@ export class PolicyBasedRoutingServiceClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -156,18 +191,14 @@ export class PolicyBasedRoutingServiceClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -189,52 +220,54 @@ export class PolicyBasedRoutingServiceClient { // Create useful helper objects for these. this.pathTemplates = { destinationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}/destinations/{destination}' + 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}/destinations/{destination}', ), groupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}/groups/{group}' + 'projects/{project}/locations/global/hubs/{hub}/groups/{group}', ), hubPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}' + 'projects/{project}/locations/global/hubs/{hub}', ), hubRoutePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}/routes/{route}' + 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}/routes/{route}', ), internalRangePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/internalRanges/{internal_range}' + 'projects/{project}/locations/{location}/internalRanges/{internal_range}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - multicloudDataTransferConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}' - ), - multicloudDataTransferSupportedServicePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/multicloudDataTransferSupportedServices/{multicloud_data_transfer_supported_service}' + 'projects/{project}/locations/{location}', ), + multicloudDataTransferConfigPathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}', + ), + multicloudDataTransferSupportedServicePathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/multicloudDataTransferSupportedServices/{multicloud_data_transfer_supported_service}', + ), networkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/global/networks/{resource_id}' + 'projects/{project}/global/networks/{resource_id}', ), policyBasedRoutePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/PolicyBasedRoutes/{policy_based_route}' + 'projects/{project}/locations/global/PolicyBasedRoutes/{policy_based_route}', ), routeTablePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}' + 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}', ), serviceClassPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/serviceClasses/{service_class}' + 'projects/{project}/locations/{location}/serviceClasses/{service_class}', ), serviceConnectionMapPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/serviceConnectionMaps/{service_connection_map}' + 'projects/{project}/locations/{location}/serviceConnectionMaps/{service_connection_map}', ), serviceConnectionPolicyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/serviceConnectionPolicies/{service_connection_policy}' + 'projects/{project}/locations/{location}/serviceConnectionPolicies/{service_connection_policy}', ), serviceConnectionTokenPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/serviceConnectionTokens/{service_connection_token}' + 'projects/{project}/locations/{location}/serviceConnectionTokens/{service_connection_token}', ), spokePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/spokes/{spoke}' + 'projects/{project}/locations/{location}/spokes/{spoke}', ), }; @@ -242,8 +275,11 @@ export class PolicyBasedRoutingServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listPolicyBasedRoutes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'policyBasedRoutes') + listPolicyBasedRoutes: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'policyBasedRoutes', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -252,40 +288,179 @@ export class PolicyBasedRoutingServiceClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1/{resource=projects/*/locations/global/hubs/*}:getIamPolicy',additional_bindings: [{get: '/v1/{resource=projects/*/locations/global/hubs/*/groups/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/spokes/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/global/policyBasedRoutes/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/serviceConnectionMaps/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/serviceConnectionPolicies/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/serviceClasses/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/internalRanges/*}:getIamPolicy',}], - },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1/{resource=projects/*/locations/global/hubs/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/global/hubs/*/groups/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/spokes/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/global/policyBasedRoutes/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceConnectionMaps/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceConnectionPolicies/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceClasses/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/internalRanges/*}:setIamPolicy',body: '*',}], - },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1/{resource=projects/*/locations/global/hubs/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/global/hubs/*/groups/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/spokes/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/global/policyBasedRoutes/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceConnectionMaps/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceConnectionPolicies/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceClasses/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/internalRanges/*}:testIamPermissions',body: '*',}], - },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1/{resource=projects/*/locations/global/hubs/*}:getIamPolicy', + additional_bindings: [ + { + get: '/v1/{resource=projects/*/locations/global/hubs/*/groups/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/spokes/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/global/policyBasedRoutes/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/serviceConnectionMaps/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/serviceConnectionPolicies/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/serviceClasses/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/internalRanges/*}:getIamPolicy', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1/{resource=projects/*/locations/global/hubs/*}:setIamPolicy', + body: '*', + additional_bindings: [ + { + post: '/v1/{resource=projects/*/locations/global/hubs/*/groups/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/spokes/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/global/policyBasedRoutes/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceConnectionMaps/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceConnectionPolicies/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceClasses/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/internalRanges/*}:setIamPolicy', + body: '*', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1/{resource=projects/*/locations/global/hubs/*}:testIamPermissions', + body: '*', + additional_bindings: [ + { + post: '/v1/{resource=projects/*/locations/global/hubs/*/groups/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/spokes/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/global/policyBasedRoutes/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceConnectionMaps/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceConnectionPolicies/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceClasses/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/internalRanges/*}:testIamPermissions', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createPolicyBasedRouteResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.PolicyBasedRoute') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.PolicyBasedRoute', + ) as gax.protobuf.Type; const createPolicyBasedRouteMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; const deletePolicyBasedRouteResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deletePolicyBasedRouteMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createPolicyBasedRoute: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - createPolicyBasedRouteResponse.decode.bind(createPolicyBasedRouteResponse), - createPolicyBasedRouteMetadata.decode.bind(createPolicyBasedRouteMetadata)), + createPolicyBasedRouteResponse.decode.bind( + createPolicyBasedRouteResponse, + ), + createPolicyBasedRouteMetadata.decode.bind( + createPolicyBasedRouteMetadata, + ), + ), deletePolicyBasedRoute: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - deletePolicyBasedRouteResponse.decode.bind(deletePolicyBasedRouteResponse), - deletePolicyBasedRouteMetadata.decode.bind(deletePolicyBasedRouteMetadata)) + deletePolicyBasedRouteResponse.decode.bind( + deletePolicyBasedRouteResponse, + ), + deletePolicyBasedRouteMetadata.decode.bind( + deletePolicyBasedRouteMetadata, + ), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.networkconnectivity.v1.PolicyBasedRoutingService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.networkconnectivity.v1.PolicyBasedRoutingService', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -316,28 +491,39 @@ export class PolicyBasedRoutingServiceClient { // Put together the "service stub" for // google.cloud.networkconnectivity.v1.PolicyBasedRoutingService. this.policyBasedRoutingServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.networkconnectivity.v1.PolicyBasedRoutingService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.networkconnectivity.v1.PolicyBasedRoutingService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.networkconnectivity.v1.PolicyBasedRoutingService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.networkconnectivity.v1 + .PolicyBasedRoutingService, + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const policyBasedRoutingServiceStubMethods = - ['listPolicyBasedRoutes', 'getPolicyBasedRoute', 'createPolicyBasedRoute', 'deletePolicyBasedRoute']; + const policyBasedRoutingServiceStubMethods = [ + 'listPolicyBasedRoutes', + 'getPolicyBasedRoute', + 'createPolicyBasedRoute', + 'deletePolicyBasedRoute', + ]; for (const methodName of policyBasedRoutingServiceStubMethods) { const callPromise = this.policyBasedRoutingServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -347,7 +533,7 @@ export class PolicyBasedRoutingServiceClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -362,8 +548,14 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkconnectivity.googleapis.com'; } @@ -374,8 +566,14 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkconnectivity.googleapis.com'; } @@ -406,9 +604,7 @@ export class PolicyBasedRoutingServiceClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -417,8 +613,9 @@ export class PolicyBasedRoutingServiceClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -429,439 +626,637 @@ export class PolicyBasedRoutingServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets details of a single policy-based route. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the PolicyBasedRoute resource to get. - * @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 {@link protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute|PolicyBasedRoute}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/policy_based_routing_service.get_policy_based_route.js - * region_tag:networkconnectivity_v1_generated_PolicyBasedRoutingService_GetPolicyBasedRoute_async - */ + /** + * Gets details of a single policy-based route. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the PolicyBasedRoute resource to get. + * @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 {@link protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute|PolicyBasedRoute}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/policy_based_routing_service.get_policy_based_route.js + * region_tag:networkconnectivity_v1_generated_PolicyBasedRoutingService_GetPolicyBasedRoute_async + */ getPolicyBasedRoute( - request?: protos.google.cloud.networkconnectivity.v1.IGetPolicyBasedRouteRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute, - protos.google.cloud.networkconnectivity.v1.IGetPolicyBasedRouteRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IGetPolicyBasedRouteRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute, + ( + | protos.google.cloud.networkconnectivity.v1.IGetPolicyBasedRouteRequest + | undefined + ), + {} | undefined, + ] + >; getPolicyBasedRoute( - request: protos.google.cloud.networkconnectivity.v1.IGetPolicyBasedRouteRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute, - protos.google.cloud.networkconnectivity.v1.IGetPolicyBasedRouteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IGetPolicyBasedRouteRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute, + | protos.google.cloud.networkconnectivity.v1.IGetPolicyBasedRouteRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getPolicyBasedRoute( - request: protos.google.cloud.networkconnectivity.v1.IGetPolicyBasedRouteRequest, - callback: Callback< - protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute, - protos.google.cloud.networkconnectivity.v1.IGetPolicyBasedRouteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IGetPolicyBasedRouteRequest, + callback: Callback< + protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute, + | protos.google.cloud.networkconnectivity.v1.IGetPolicyBasedRouteRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getPolicyBasedRoute( - request?: protos.google.cloud.networkconnectivity.v1.IGetPolicyBasedRouteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute, - protos.google.cloud.networkconnectivity.v1.IGetPolicyBasedRouteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkconnectivity.v1.IGetPolicyBasedRouteRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute, - protos.google.cloud.networkconnectivity.v1.IGetPolicyBasedRouteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute, - protos.google.cloud.networkconnectivity.v1.IGetPolicyBasedRouteRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkconnectivity.v1.IGetPolicyBasedRouteRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute, + | protos.google.cloud.networkconnectivity.v1.IGetPolicyBasedRouteRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute, + ( + | protos.google.cloud.networkconnectivity.v1.IGetPolicyBasedRouteRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getPolicyBasedRoute request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute, - protos.google.cloud.networkconnectivity.v1.IGetPolicyBasedRouteRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute, + | protos.google.cloud.networkconnectivity.v1.IGetPolicyBasedRouteRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getPolicyBasedRoute response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getPolicyBasedRoute(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute, - protos.google.cloud.networkconnectivity.v1.IGetPolicyBasedRouteRequest|undefined, - {}|undefined - ]) => { - this._log.info('getPolicyBasedRoute response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getPolicyBasedRoute(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute, + ( + | protos.google.cloud.networkconnectivity.v1.IGetPolicyBasedRouteRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getPolicyBasedRoute response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a new policy-based route in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name of the PolicyBasedRoute. - * @param {string} request.policyBasedRouteId - * Required. Unique id for the policy-based route to create. Provided by the - * client when the resource is created. The name must comply with - * https://google.aip.dev/122#resource-id-segments. Specifically, the name - * must be 1-63 characters long and match the regular expression - * [a-z]([a-z0-9-]*[a-z0-9])?. The first character must be a lowercase letter, - * and all following characters (except for the last character) must be a - * dash, lowercase letter, or digit. The last character must be a lowercase - * letter or digit. - * @param {google.cloud.networkconnectivity.v1.PolicyBasedRoute} request.policyBasedRoute - * Required. Initial values for a new policy-based route. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server knows to - * ignore the request if it has already been completed. The server guarantees - * that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, ignores the second request. This prevents clients - * from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/policy_based_routing_service.create_policy_based_route.js - * region_tag:networkconnectivity_v1_generated_PolicyBasedRoutingService_CreatePolicyBasedRoute_async - */ + /** + * Creates a new policy-based route in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name of the PolicyBasedRoute. + * @param {string} request.policyBasedRouteId + * Required. Unique id for the policy-based route to create. Provided by the + * client when the resource is created. The name must comply with + * https://google.aip.dev/122#resource-id-segments. Specifically, the name + * must be 1-63 characters long and match the regular expression + * [a-z]([a-z0-9-]*[a-z0-9])?. The first character must be a lowercase letter, + * and all following characters (except for the last character) must be a + * dash, lowercase letter, or digit. The last character must be a lowercase + * letter or digit. + * @param {google.cloud.networkconnectivity.v1.PolicyBasedRoute} request.policyBasedRoute + * Required. Initial values for a new policy-based route. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server knows to + * ignore the request if it has already been completed. The server guarantees + * that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, ignores the second request. This prevents clients + * from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/policy_based_routing_service.create_policy_based_route.js + * region_tag:networkconnectivity_v1_generated_PolicyBasedRoutingService_CreatePolicyBasedRoute_async + */ createPolicyBasedRoute( - request?: protos.google.cloud.networkconnectivity.v1.ICreatePolicyBasedRouteRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.ICreatePolicyBasedRouteRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createPolicyBasedRoute( - request: protos.google.cloud.networkconnectivity.v1.ICreatePolicyBasedRouteRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.ICreatePolicyBasedRouteRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createPolicyBasedRoute( - request: protos.google.cloud.networkconnectivity.v1.ICreatePolicyBasedRouteRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.ICreatePolicyBasedRouteRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createPolicyBasedRoute( - request?: protos.google.cloud.networkconnectivity.v1.ICreatePolicyBasedRouteRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1.ICreatePolicyBasedRouteRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createPolicyBasedRoute response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createPolicyBasedRoute request %j', request); - return this.innerApiCalls.createPolicyBasedRoute(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createPolicyBasedRoute response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createPolicyBasedRoute(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createPolicyBasedRoute response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createPolicyBasedRoute()`. - * @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/policy_based_routing_service.create_policy_based_route.js - * region_tag:networkconnectivity_v1_generated_PolicyBasedRoutingService_CreatePolicyBasedRoute_async - */ - async checkCreatePolicyBasedRouteProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createPolicyBasedRoute()`. + * @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/policy_based_routing_service.create_policy_based_route.js + * region_tag:networkconnectivity_v1_generated_PolicyBasedRoutingService_CreatePolicyBasedRoute_async + */ + async checkCreatePolicyBasedRouteProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('createPolicyBasedRoute long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createPolicyBasedRoute, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createPolicyBasedRoute, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; } -/** - * Deletes a single policy-based route. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the policy-based route resource to delete. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server knows to - * ignore the request if it has already been completed. The server guarantees - * that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, ignores the second request. This prevents clients - * from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/policy_based_routing_service.delete_policy_based_route.js - * region_tag:networkconnectivity_v1_generated_PolicyBasedRoutingService_DeletePolicyBasedRoute_async - */ + /** + * Deletes a single policy-based route. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the policy-based route resource to delete. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server knows to + * ignore the request if it has already been completed. The server guarantees + * that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, ignores the second request. This prevents clients + * from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/policy_based_routing_service.delete_policy_based_route.js + * region_tag:networkconnectivity_v1_generated_PolicyBasedRoutingService_DeletePolicyBasedRoute_async + */ deletePolicyBasedRoute( - request?: protos.google.cloud.networkconnectivity.v1.IDeletePolicyBasedRouteRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IDeletePolicyBasedRouteRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deletePolicyBasedRoute( - request: protos.google.cloud.networkconnectivity.v1.IDeletePolicyBasedRouteRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IDeletePolicyBasedRouteRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deletePolicyBasedRoute( - request: protos.google.cloud.networkconnectivity.v1.IDeletePolicyBasedRouteRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1.IDeletePolicyBasedRouteRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deletePolicyBasedRoute( - request?: protos.google.cloud.networkconnectivity.v1.IDeletePolicyBasedRouteRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1.IDeletePolicyBasedRouteRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deletePolicyBasedRoute response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deletePolicyBasedRoute request %j', request); - return this.innerApiCalls.deletePolicyBasedRoute(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deletePolicyBasedRoute response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deletePolicyBasedRoute(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deletePolicyBasedRoute response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deletePolicyBasedRoute()`. - * @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/policy_based_routing_service.delete_policy_based_route.js - * region_tag:networkconnectivity_v1_generated_PolicyBasedRoutingService_DeletePolicyBasedRoute_async - */ - async checkDeletePolicyBasedRouteProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deletePolicyBasedRoute()`. + * @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/policy_based_routing_service.delete_policy_based_route.js + * region_tag:networkconnectivity_v1_generated_PolicyBasedRoutingService_DeletePolicyBasedRoute_async + */ + async checkDeletePolicyBasedRouteProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + > + > { this._log.info('deletePolicyBasedRoute long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deletePolicyBasedRoute, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists policy-based routes in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results per page that should be returned. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * A filter expression that filters the results listed in the response. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute|PolicyBasedRoute}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listPolicyBasedRoutesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deletePolicyBasedRoute, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1.OperationMetadata + >; + } + /** + * Lists policy-based routes in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results per page that should be returned. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * A filter expression that filters the results listed in the response. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute|PolicyBasedRoute}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listPolicyBasedRoutesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listPolicyBasedRoutes( - request?: protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute[], - protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesRequest|null, - protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute[], + protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesRequest | null, + protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesResponse, + ] + >; listPolicyBasedRoutes( - request: protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesRequest, - protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute>): void; + request: protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesRequest, + | protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute + >, + ): void; listPolicyBasedRoutes( - request: protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesRequest, - protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute>): void; + request: protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesRequest, + | protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute + >, + ): void; listPolicyBasedRoutes( - request?: protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesRequest, - protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesRequest, - protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute>): - Promise<[ - protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute[], - protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesRequest|null, - protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesRequest, + | protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute[], + protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesRequest | null, + protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesRequest, - protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesRequest, + | protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listPolicyBasedRoutes values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -870,141 +1265,145 @@ export class PolicyBasedRoutingServiceClient { this._log.info('listPolicyBasedRoutes request %j', request); return this.innerApiCalls .listPolicyBasedRoutes(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute[], - protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesRequest|null, - protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesResponse - ]) => { - this._log.info('listPolicyBasedRoutes values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute[], + protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesRequest | null, + protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesResponse, + ]) => { + this._log.info('listPolicyBasedRoutes values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listPolicyBasedRoutes`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results per page that should be returned. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * A filter expression that filters the results listed in the response. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute|PolicyBasedRoute} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listPolicyBasedRoutesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listPolicyBasedRoutes`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results per page that should be returned. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * A filter expression that filters the results listed in the response. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute|PolicyBasedRoute} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listPolicyBasedRoutesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listPolicyBasedRoutesStream( - request?: protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listPolicyBasedRoutes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listPolicyBasedRoutes stream %j', request); return this.descriptors.page.listPolicyBasedRoutes.createStream( this.innerApiCalls.listPolicyBasedRoutes as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listPolicyBasedRoutes`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results per page that should be returned. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * A filter expression that filters the results listed in the response. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute|PolicyBasedRoute}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/policy_based_routing_service.list_policy_based_routes.js - * region_tag:networkconnectivity_v1_generated_PolicyBasedRoutingService_ListPolicyBasedRoutes_async - */ + /** + * Equivalent to `listPolicyBasedRoutes`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results per page that should be returned. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * A filter expression that filters the results listed in the response. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute|PolicyBasedRoute}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/policy_based_routing_service.list_policy_based_routes.js + * region_tag:networkconnectivity_v1_generated_PolicyBasedRoutingService_ListPolicyBasedRoutes_async + */ listPolicyBasedRoutesAsync( - request?: protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1.IListPolicyBasedRoutesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listPolicyBasedRoutes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listPolicyBasedRoutes iterate %j', request); return this.descriptors.page.listPolicyBasedRoutes.asyncIterate( this.innerApiCalls['listPolicyBasedRoutes'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -1018,40 +1417,40 @@ export class PolicyBasedRoutingServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -1065,41 +1464,41 @@ export class PolicyBasedRoutingServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -1113,12 +1512,12 @@ export class PolicyBasedRoutingServiceClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -1153,12 +1552,11 @@ export class PolicyBasedRoutingServiceClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -1191,12 +1589,12 @@ export class PolicyBasedRoutingServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -1239,22 +1637,22 @@ export class PolicyBasedRoutingServiceClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -1289,15 +1687,15 @@ export class PolicyBasedRoutingServiceClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - 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 ?? '', - }); + 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 ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -1331,7 +1729,7 @@ export class PolicyBasedRoutingServiceClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -1344,25 +1742,24 @@ export class PolicyBasedRoutingServiceClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -1401,22 +1798,22 @@ export class PolicyBasedRoutingServiceClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -1433,7 +1830,12 @@ export class PolicyBasedRoutingServiceClient { * @param {string} destination * @returns {string} Resource name string. */ - destinationPath(project:string,location:string,multicloudDataTransferConfig:string,destination:string) { + destinationPath( + project: string, + location: string, + multicloudDataTransferConfig: string, + destination: string, + ) { return this.pathTemplates.destinationPathTemplate.render({ project: project, location: location, @@ -1450,7 +1852,8 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} A string representing the project. */ matchProjectFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).project; + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .project; } /** @@ -1461,7 +1864,8 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} A string representing the location. */ matchLocationFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).location; + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .location; } /** @@ -1471,8 +1875,11 @@ export class PolicyBasedRoutingServiceClient { * A fully-qualified path representing Destination resource. * @returns {string} A string representing the multicloud_data_transfer_config. */ - matchMulticloudDataTransferConfigFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).multicloud_data_transfer_config; + matchMulticloudDataTransferConfigFromDestinationName( + destinationName: string, + ) { + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .multicloud_data_transfer_config; } /** @@ -1483,7 +1890,8 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} A string representing the destination. */ matchDestinationFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).destination; + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .destination; } /** @@ -1494,7 +1902,7 @@ export class PolicyBasedRoutingServiceClient { * @param {string} group * @returns {string} Resource name string. */ - groupPath(project:string,hub:string,group:string) { + groupPath(project: string, hub: string, group: string) { return this.pathTemplates.groupPathTemplate.render({ project: project, hub: hub, @@ -1542,7 +1950,7 @@ export class PolicyBasedRoutingServiceClient { * @param {string} hub * @returns {string} Resource name string. */ - hubPath(project:string,hub:string) { + hubPath(project: string, hub: string) { return this.pathTemplates.hubPathTemplate.render({ project: project, hub: hub, @@ -1580,7 +1988,12 @@ export class PolicyBasedRoutingServiceClient { * @param {string} route * @returns {string} Resource name string. */ - hubRoutePath(project:string,hub:string,routeTable:string,route:string) { + hubRoutePath( + project: string, + hub: string, + routeTable: string, + route: string, + ) { return this.pathTemplates.hubRoutePathTemplate.render({ project: project, hub: hub, @@ -1619,7 +2032,8 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} A string representing the route_table. */ matchRouteTableFromHubRouteName(hubRouteName: string) { - return this.pathTemplates.hubRoutePathTemplate.match(hubRouteName).route_table; + return this.pathTemplates.hubRoutePathTemplate.match(hubRouteName) + .route_table; } /** @@ -1641,7 +2055,7 @@ export class PolicyBasedRoutingServiceClient { * @param {string} internal_range * @returns {string} Resource name string. */ - internalRangePath(project:string,location:string,internalRange:string) { + internalRangePath(project: string, location: string, internalRange: string) { return this.pathTemplates.internalRangePathTemplate.render({ project: project, location: location, @@ -1657,7 +2071,8 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} A string representing the project. */ matchProjectFromInternalRangeName(internalRangeName: string) { - return this.pathTemplates.internalRangePathTemplate.match(internalRangeName).project; + return this.pathTemplates.internalRangePathTemplate.match(internalRangeName) + .project; } /** @@ -1668,7 +2083,8 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} A string representing the location. */ matchLocationFromInternalRangeName(internalRangeName: string) { - return this.pathTemplates.internalRangePathTemplate.match(internalRangeName).location; + return this.pathTemplates.internalRangePathTemplate.match(internalRangeName) + .location; } /** @@ -1679,7 +2095,8 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} A string representing the internal_range. */ matchInternalRangeFromInternalRangeName(internalRangeName: string) { - return this.pathTemplates.internalRangePathTemplate.match(internalRangeName).internal_range; + return this.pathTemplates.internalRangePathTemplate.match(internalRangeName) + .internal_range; } /** @@ -1689,7 +2106,7 @@ export class PolicyBasedRoutingServiceClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -1726,7 +2143,11 @@ export class PolicyBasedRoutingServiceClient { * @param {string} multicloud_data_transfer_config * @returns {string} Resource name string. */ - multicloudDataTransferConfigPath(project:string,location:string,multicloudDataTransferConfig:string) { + multicloudDataTransferConfigPath( + project: string, + location: string, + multicloudDataTransferConfig: string, + ) { return this.pathTemplates.multicloudDataTransferConfigPathTemplate.render({ project: project, location: location, @@ -1741,8 +2162,12 @@ export class PolicyBasedRoutingServiceClient { * A fully-qualified path representing MulticloudDataTransferConfig resource. * @returns {string} A string representing the project. */ - matchProjectFromMulticloudDataTransferConfigName(multicloudDataTransferConfigName: string) { - return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match(multicloudDataTransferConfigName).project; + matchProjectFromMulticloudDataTransferConfigName( + multicloudDataTransferConfigName: string, + ) { + return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match( + multicloudDataTransferConfigName, + ).project; } /** @@ -1752,8 +2177,12 @@ export class PolicyBasedRoutingServiceClient { * A fully-qualified path representing MulticloudDataTransferConfig resource. * @returns {string} A string representing the location. */ - matchLocationFromMulticloudDataTransferConfigName(multicloudDataTransferConfigName: string) { - return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match(multicloudDataTransferConfigName).location; + matchLocationFromMulticloudDataTransferConfigName( + multicloudDataTransferConfigName: string, + ) { + return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match( + multicloudDataTransferConfigName, + ).location; } /** @@ -1763,8 +2192,12 @@ export class PolicyBasedRoutingServiceClient { * A fully-qualified path representing MulticloudDataTransferConfig resource. * @returns {string} A string representing the multicloud_data_transfer_config. */ - matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName(multicloudDataTransferConfigName: string) { - return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match(multicloudDataTransferConfigName).multicloud_data_transfer_config; + matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName( + multicloudDataTransferConfigName: string, + ) { + return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match( + multicloudDataTransferConfigName, + ).multicloud_data_transfer_config; } /** @@ -1775,12 +2208,19 @@ export class PolicyBasedRoutingServiceClient { * @param {string} multicloud_data_transfer_supported_service * @returns {string} Resource name string. */ - multicloudDataTransferSupportedServicePath(project:string,location:string,multicloudDataTransferSupportedService:string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render({ - project: project, - location: location, - multicloud_data_transfer_supported_service: multicloudDataTransferSupportedService, - }); + multicloudDataTransferSupportedServicePath( + project: string, + location: string, + multicloudDataTransferSupportedService: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render( + { + project: project, + location: location, + multicloud_data_transfer_supported_service: + multicloudDataTransferSupportedService, + }, + ); } /** @@ -1790,8 +2230,12 @@ export class PolicyBasedRoutingServiceClient { * A fully-qualified path representing MulticloudDataTransferSupportedService resource. * @returns {string} A string representing the project. */ - matchProjectFromMulticloudDataTransferSupportedServiceName(multicloudDataTransferSupportedServiceName: string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match(multicloudDataTransferSupportedServiceName).project; + matchProjectFromMulticloudDataTransferSupportedServiceName( + multicloudDataTransferSupportedServiceName: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match( + multicloudDataTransferSupportedServiceName, + ).project; } /** @@ -1801,8 +2245,12 @@ export class PolicyBasedRoutingServiceClient { * A fully-qualified path representing MulticloudDataTransferSupportedService resource. * @returns {string} A string representing the location. */ - matchLocationFromMulticloudDataTransferSupportedServiceName(multicloudDataTransferSupportedServiceName: string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match(multicloudDataTransferSupportedServiceName).location; + matchLocationFromMulticloudDataTransferSupportedServiceName( + multicloudDataTransferSupportedServiceName: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match( + multicloudDataTransferSupportedServiceName, + ).location; } /** @@ -1812,8 +2260,12 @@ export class PolicyBasedRoutingServiceClient { * A fully-qualified path representing MulticloudDataTransferSupportedService resource. * @returns {string} A string representing the multicloud_data_transfer_supported_service. */ - matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName(multicloudDataTransferSupportedServiceName: string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match(multicloudDataTransferSupportedServiceName).multicloud_data_transfer_supported_service; + matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName( + multicloudDataTransferSupportedServiceName: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match( + multicloudDataTransferSupportedServiceName, + ).multicloud_data_transfer_supported_service; } /** @@ -1823,7 +2275,7 @@ export class PolicyBasedRoutingServiceClient { * @param {string} resource_id * @returns {string} Resource name string. */ - networkPath(project:string,resourceId:string) { + networkPath(project: string, resourceId: string) { return this.pathTemplates.networkPathTemplate.render({ project: project, resource_id: resourceId, @@ -1849,7 +2301,8 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} A string representing the resource_id. */ matchResourceIdFromNetworkName(networkName: string) { - return this.pathTemplates.networkPathTemplate.match(networkName).resource_id; + return this.pathTemplates.networkPathTemplate.match(networkName) + .resource_id; } /** @@ -1859,7 +2312,7 @@ export class PolicyBasedRoutingServiceClient { * @param {string} policy_based_route * @returns {string} Resource name string. */ - policyBasedRoutePath(project:string,policyBasedRoute:string) { + policyBasedRoutePath(project: string, policyBasedRoute: string) { return this.pathTemplates.policyBasedRoutePathTemplate.render({ project: project, policy_based_route: policyBasedRoute, @@ -1874,7 +2327,9 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} A string representing the project. */ matchProjectFromPolicyBasedRouteName(policyBasedRouteName: string) { - return this.pathTemplates.policyBasedRoutePathTemplate.match(policyBasedRouteName).project; + return this.pathTemplates.policyBasedRoutePathTemplate.match( + policyBasedRouteName, + ).project; } /** @@ -1885,7 +2340,9 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} A string representing the policy_based_route. */ matchPolicyBasedRouteFromPolicyBasedRouteName(policyBasedRouteName: string) { - return this.pathTemplates.policyBasedRoutePathTemplate.match(policyBasedRouteName).policy_based_route; + return this.pathTemplates.policyBasedRoutePathTemplate.match( + policyBasedRouteName, + ).policy_based_route; } /** @@ -1896,7 +2353,7 @@ export class PolicyBasedRoutingServiceClient { * @param {string} route_table * @returns {string} Resource name string. */ - routeTablePath(project:string,hub:string,routeTable:string) { + routeTablePath(project: string, hub: string, routeTable: string) { return this.pathTemplates.routeTablePathTemplate.render({ project: project, hub: hub, @@ -1912,7 +2369,8 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} A string representing the project. */ matchProjectFromRouteTableName(routeTableName: string) { - return this.pathTemplates.routeTablePathTemplate.match(routeTableName).project; + return this.pathTemplates.routeTablePathTemplate.match(routeTableName) + .project; } /** @@ -1934,7 +2392,8 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} A string representing the route_table. */ matchRouteTableFromRouteTableName(routeTableName: string) { - return this.pathTemplates.routeTablePathTemplate.match(routeTableName).route_table; + return this.pathTemplates.routeTablePathTemplate.match(routeTableName) + .route_table; } /** @@ -1945,7 +2404,7 @@ export class PolicyBasedRoutingServiceClient { * @param {string} service_class * @returns {string} Resource name string. */ - serviceClassPath(project:string,location:string,serviceClass:string) { + serviceClassPath(project: string, location: string, serviceClass: string) { return this.pathTemplates.serviceClassPathTemplate.render({ project: project, location: location, @@ -1961,7 +2420,8 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} A string representing the project. */ matchProjectFromServiceClassName(serviceClassName: string) { - return this.pathTemplates.serviceClassPathTemplate.match(serviceClassName).project; + return this.pathTemplates.serviceClassPathTemplate.match(serviceClassName) + .project; } /** @@ -1972,7 +2432,8 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} A string representing the location. */ matchLocationFromServiceClassName(serviceClassName: string) { - return this.pathTemplates.serviceClassPathTemplate.match(serviceClassName).location; + return this.pathTemplates.serviceClassPathTemplate.match(serviceClassName) + .location; } /** @@ -1983,7 +2444,8 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} A string representing the service_class. */ matchServiceClassFromServiceClassName(serviceClassName: string) { - return this.pathTemplates.serviceClassPathTemplate.match(serviceClassName).service_class; + return this.pathTemplates.serviceClassPathTemplate.match(serviceClassName) + .service_class; } /** @@ -1994,7 +2456,11 @@ export class PolicyBasedRoutingServiceClient { * @param {string} service_connection_map * @returns {string} Resource name string. */ - serviceConnectionMapPath(project:string,location:string,serviceConnectionMap:string) { + serviceConnectionMapPath( + project: string, + location: string, + serviceConnectionMap: string, + ) { return this.pathTemplates.serviceConnectionMapPathTemplate.render({ project: project, location: location, @@ -2010,7 +2476,9 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} A string representing the project. */ matchProjectFromServiceConnectionMapName(serviceConnectionMapName: string) { - return this.pathTemplates.serviceConnectionMapPathTemplate.match(serviceConnectionMapName).project; + return this.pathTemplates.serviceConnectionMapPathTemplate.match( + serviceConnectionMapName, + ).project; } /** @@ -2021,7 +2489,9 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} A string representing the location. */ matchLocationFromServiceConnectionMapName(serviceConnectionMapName: string) { - return this.pathTemplates.serviceConnectionMapPathTemplate.match(serviceConnectionMapName).location; + return this.pathTemplates.serviceConnectionMapPathTemplate.match( + serviceConnectionMapName, + ).location; } /** @@ -2031,8 +2501,12 @@ export class PolicyBasedRoutingServiceClient { * A fully-qualified path representing ServiceConnectionMap resource. * @returns {string} A string representing the service_connection_map. */ - matchServiceConnectionMapFromServiceConnectionMapName(serviceConnectionMapName: string) { - return this.pathTemplates.serviceConnectionMapPathTemplate.match(serviceConnectionMapName).service_connection_map; + matchServiceConnectionMapFromServiceConnectionMapName( + serviceConnectionMapName: string, + ) { + return this.pathTemplates.serviceConnectionMapPathTemplate.match( + serviceConnectionMapName, + ).service_connection_map; } /** @@ -2043,7 +2517,11 @@ export class PolicyBasedRoutingServiceClient { * @param {string} service_connection_policy * @returns {string} Resource name string. */ - serviceConnectionPolicyPath(project:string,location:string,serviceConnectionPolicy:string) { + serviceConnectionPolicyPath( + project: string, + location: string, + serviceConnectionPolicy: string, + ) { return this.pathTemplates.serviceConnectionPolicyPathTemplate.render({ project: project, location: location, @@ -2058,8 +2536,12 @@ export class PolicyBasedRoutingServiceClient { * A fully-qualified path representing ServiceConnectionPolicy resource. * @returns {string} A string representing the project. */ - matchProjectFromServiceConnectionPolicyName(serviceConnectionPolicyName: string) { - return this.pathTemplates.serviceConnectionPolicyPathTemplate.match(serviceConnectionPolicyName).project; + matchProjectFromServiceConnectionPolicyName( + serviceConnectionPolicyName: string, + ) { + return this.pathTemplates.serviceConnectionPolicyPathTemplate.match( + serviceConnectionPolicyName, + ).project; } /** @@ -2069,8 +2551,12 @@ export class PolicyBasedRoutingServiceClient { * A fully-qualified path representing ServiceConnectionPolicy resource. * @returns {string} A string representing the location. */ - matchLocationFromServiceConnectionPolicyName(serviceConnectionPolicyName: string) { - return this.pathTemplates.serviceConnectionPolicyPathTemplate.match(serviceConnectionPolicyName).location; + matchLocationFromServiceConnectionPolicyName( + serviceConnectionPolicyName: string, + ) { + return this.pathTemplates.serviceConnectionPolicyPathTemplate.match( + serviceConnectionPolicyName, + ).location; } /** @@ -2080,8 +2566,12 @@ export class PolicyBasedRoutingServiceClient { * A fully-qualified path representing ServiceConnectionPolicy resource. * @returns {string} A string representing the service_connection_policy. */ - matchServiceConnectionPolicyFromServiceConnectionPolicyName(serviceConnectionPolicyName: string) { - return this.pathTemplates.serviceConnectionPolicyPathTemplate.match(serviceConnectionPolicyName).service_connection_policy; + matchServiceConnectionPolicyFromServiceConnectionPolicyName( + serviceConnectionPolicyName: string, + ) { + return this.pathTemplates.serviceConnectionPolicyPathTemplate.match( + serviceConnectionPolicyName, + ).service_connection_policy; } /** @@ -2092,7 +2582,11 @@ export class PolicyBasedRoutingServiceClient { * @param {string} service_connection_token * @returns {string} Resource name string. */ - serviceConnectionTokenPath(project:string,location:string,serviceConnectionToken:string) { + serviceConnectionTokenPath( + project: string, + location: string, + serviceConnectionToken: string, + ) { return this.pathTemplates.serviceConnectionTokenPathTemplate.render({ project: project, location: location, @@ -2107,8 +2601,12 @@ export class PolicyBasedRoutingServiceClient { * A fully-qualified path representing ServiceConnectionToken resource. * @returns {string} A string representing the project. */ - matchProjectFromServiceConnectionTokenName(serviceConnectionTokenName: string) { - return this.pathTemplates.serviceConnectionTokenPathTemplate.match(serviceConnectionTokenName).project; + matchProjectFromServiceConnectionTokenName( + serviceConnectionTokenName: string, + ) { + return this.pathTemplates.serviceConnectionTokenPathTemplate.match( + serviceConnectionTokenName, + ).project; } /** @@ -2118,8 +2616,12 @@ export class PolicyBasedRoutingServiceClient { * A fully-qualified path representing ServiceConnectionToken resource. * @returns {string} A string representing the location. */ - matchLocationFromServiceConnectionTokenName(serviceConnectionTokenName: string) { - return this.pathTemplates.serviceConnectionTokenPathTemplate.match(serviceConnectionTokenName).location; + matchLocationFromServiceConnectionTokenName( + serviceConnectionTokenName: string, + ) { + return this.pathTemplates.serviceConnectionTokenPathTemplate.match( + serviceConnectionTokenName, + ).location; } /** @@ -2129,8 +2631,12 @@ export class PolicyBasedRoutingServiceClient { * A fully-qualified path representing ServiceConnectionToken resource. * @returns {string} A string representing the service_connection_token. */ - matchServiceConnectionTokenFromServiceConnectionTokenName(serviceConnectionTokenName: string) { - return this.pathTemplates.serviceConnectionTokenPathTemplate.match(serviceConnectionTokenName).service_connection_token; + matchServiceConnectionTokenFromServiceConnectionTokenName( + serviceConnectionTokenName: string, + ) { + return this.pathTemplates.serviceConnectionTokenPathTemplate.match( + serviceConnectionTokenName, + ).service_connection_token; } /** @@ -2141,7 +2647,7 @@ export class PolicyBasedRoutingServiceClient { * @param {string} spoke * @returns {string} Resource name string. */ - spokePath(project:string,location:string,spoke:string) { + spokePath(project: string, location: string, spoke: string) { return this.pathTemplates.spokePathTemplate.render({ project: project, location: location, @@ -2190,15 +2696,19 @@ export class PolicyBasedRoutingServiceClient { */ close(): Promise { if (this.policyBasedRoutingServiceStub && !this._terminated) { - return this.policyBasedRoutingServiceStub.then(stub => { + return this.policyBasedRoutingServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-networkconnectivity/src/v1alpha1/hub_service_client.ts b/packages/google-cloud-networkconnectivity/src/v1alpha1/hub_service_client.ts index b0b2d94becba..82a8063d9d9b 100644 --- a/packages/google-cloud-networkconnectivity/src/v1alpha1/hub_service_client.ts +++ b/packages/google-cloud-networkconnectivity/src/v1alpha1/hub_service_client.ts @@ -18,11 +18,20 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -47,7 +56,7 @@ export class HubServiceClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('network-connectivity'); @@ -60,10 +69,10 @@ export class HubServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - hubServiceStub?: Promise<{[name: string]: Function}>; + hubServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of HubServiceClient. @@ -104,21 +113,42 @@ export class HubServiceClient { * const client = new HubServiceClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof HubServiceClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'networkconnectivity.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -143,7 +173,7 @@ export class HubServiceClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -157,10 +187,7 @@ export class HubServiceClient { } // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -182,22 +209,22 @@ export class HubServiceClient { // Create useful helper objects for these. this.pathTemplates = { hubPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}' + 'projects/{project}/locations/global/hubs/{hub}', ), instancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/zones/{zone}/instances/{instance}' + 'projects/{project}/zones/{zone}/instances/{instance}', ), interconnectAttachmentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/regions/{region}/interconnectAttachments/{resource_id}' + 'projects/{project}/regions/{region}/interconnectAttachments/{resource_id}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), spokePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/spokes/{spoke}' + 'projects/{project}/locations/{location}/spokes/{spoke}', ), vpnTunnelPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/regions/{region}/vpnTunnels/{resource_id}' + 'projects/{project}/regions/{region}/vpnTunnels/{resource_id}', ), }; @@ -205,10 +232,16 @@ export class HubServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listHubs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'hubs'), - listSpokes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'spokes') + listHubs: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'hubs', + ), + listSpokes: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'spokes', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -217,72 +250,149 @@ export class HubServiceClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1alpha1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1alpha1/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1alpha1/{resource=projects/*/locations/global/hubs/*}:getIamPolicy',additional_bindings: [{get: '/v1alpha1/{resource=projects/*/locations/*/spokes/*}:getIamPolicy',}], - },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1alpha1/{resource=projects/*/locations/global/hubs/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1alpha1/{resource=projects/*/locations/*/spokes/*}:setIamPolicy',body: '*',}], - },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1alpha1/{resource=projects/*/locations/global/hubs/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1alpha1/{resource=projects/*/locations/*/spokes/*}:testIamPermissions',body: '*',}], - },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1alpha1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1alpha1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1alpha1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1alpha1/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1alpha1/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1alpha1/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1alpha1/{resource=projects/*/locations/global/hubs/*}:getIamPolicy', + additional_bindings: [ + { + get: '/v1alpha1/{resource=projects/*/locations/*/spokes/*}:getIamPolicy', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1alpha1/{resource=projects/*/locations/global/hubs/*}:setIamPolicy', + body: '*', + additional_bindings: [ + { + post: '/v1alpha1/{resource=projects/*/locations/*/spokes/*}:setIamPolicy', + body: '*', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1alpha1/{resource=projects/*/locations/global/hubs/*}:testIamPermissions', + body: '*', + additional_bindings: [ + { + post: '/v1alpha1/{resource=projects/*/locations/*/spokes/*}:testIamPermissions', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1alpha1/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1alpha1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1alpha1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1alpha1/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createHubResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1alpha1.Hub') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1alpha1.Hub', + ) as gax.protobuf.Type; const createHubMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1alpha1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1alpha1.OperationMetadata', + ) as gax.protobuf.Type; const updateHubResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1alpha1.Hub') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1alpha1.Hub', + ) as gax.protobuf.Type; const updateHubMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1alpha1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1alpha1.OperationMetadata', + ) as gax.protobuf.Type; const deleteHubResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteHubMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1alpha1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1alpha1.OperationMetadata', + ) as gax.protobuf.Type; const createSpokeResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1alpha1.Spoke') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1alpha1.Spoke', + ) as gax.protobuf.Type; const createSpokeMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1alpha1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1alpha1.OperationMetadata', + ) as gax.protobuf.Type; const updateSpokeResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1alpha1.Spoke') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1alpha1.Spoke', + ) as gax.protobuf.Type; const updateSpokeMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1alpha1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1alpha1.OperationMetadata', + ) as gax.protobuf.Type; const deleteSpokeResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteSpokeMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1alpha1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1alpha1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createHub: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createHubResponse.decode.bind(createHubResponse), - createHubMetadata.decode.bind(createHubMetadata)), + createHubMetadata.decode.bind(createHubMetadata), + ), updateHub: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateHubResponse.decode.bind(updateHubResponse), - updateHubMetadata.decode.bind(updateHubMetadata)), + updateHubMetadata.decode.bind(updateHubMetadata), + ), deleteHub: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteHubResponse.decode.bind(deleteHubResponse), - deleteHubMetadata.decode.bind(deleteHubMetadata)), + deleteHubMetadata.decode.bind(deleteHubMetadata), + ), createSpoke: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createSpokeResponse.decode.bind(createSpokeResponse), - createSpokeMetadata.decode.bind(createSpokeMetadata)), + createSpokeMetadata.decode.bind(createSpokeMetadata), + ), updateSpoke: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateSpokeResponse.decode.bind(updateSpokeResponse), - updateSpokeMetadata.decode.bind(updateSpokeMetadata)), + updateSpokeMetadata.decode.bind(updateSpokeMetadata), + ), deleteSpoke: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteSpokeResponse.decode.bind(deleteSpokeResponse), - deleteSpokeMetadata.decode.bind(deleteSpokeMetadata)) + deleteSpokeMetadata.decode.bind(deleteSpokeMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.networkconnectivity.v1alpha1.HubService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.networkconnectivity.v1alpha1.HubService', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -313,28 +423,45 @@ export class HubServiceClient { // Put together the "service stub" for // google.cloud.networkconnectivity.v1alpha1.HubService. this.hubServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.networkconnectivity.v1alpha1.HubService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.networkconnectivity.v1alpha1.HubService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.networkconnectivity.v1alpha1.HubService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.networkconnectivity.v1alpha1 + .HubService, + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const hubServiceStubMethods = - ['listHubs', 'getHub', 'createHub', 'updateHub', 'deleteHub', 'listSpokes', 'getSpoke', 'createSpoke', 'updateSpoke', 'deleteSpoke']; + const hubServiceStubMethods = [ + 'listHubs', + 'getHub', + 'createHub', + 'updateHub', + 'deleteHub', + 'listSpokes', + 'getSpoke', + 'createSpoke', + 'updateSpoke', + 'deleteSpoke', + ]; for (const methodName of hubServiceStubMethods) { const callPromise = this.hubServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -344,7 +471,7 @@ export class HubServiceClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -359,8 +486,14 @@ export class HubServiceClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkconnectivity.googleapis.com'; } @@ -371,8 +504,14 @@ export class HubServiceClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkconnectivity.googleapis.com'; } @@ -403,9 +542,7 @@ export class HubServiceClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -414,8 +551,9 @@ export class HubServiceClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -426,1026 +564,1521 @@ export class HubServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets details of a single Hub. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the Hub resource to get. - * @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 {@link protos.google.cloud.networkconnectivity.v1alpha1.Hub|Hub}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha1/hub_service.get_hub.js - * region_tag:networkconnectivity_v1alpha1_generated_HubService_GetHub_async - */ + /** + * Gets details of a single Hub. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the Hub resource to get. + * @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 {@link protos.google.cloud.networkconnectivity.v1alpha1.Hub|Hub}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha1/hub_service.get_hub.js + * region_tag:networkconnectivity_v1alpha1_generated_HubService_GetHub_async + */ getHub( - request?: protos.google.cloud.networkconnectivity.v1alpha1.IGetHubRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1alpha1.IHub, - protos.google.cloud.networkconnectivity.v1alpha1.IGetHubRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1alpha1.IGetHubRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1alpha1.IHub, + ( + | protos.google.cloud.networkconnectivity.v1alpha1.IGetHubRequest + | undefined + ), + {} | undefined, + ] + >; getHub( - request: protos.google.cloud.networkconnectivity.v1alpha1.IGetHubRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkconnectivity.v1alpha1.IHub, - protos.google.cloud.networkconnectivity.v1alpha1.IGetHubRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1alpha1.IGetHubRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkconnectivity.v1alpha1.IHub, + | protos.google.cloud.networkconnectivity.v1alpha1.IGetHubRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getHub( - request: protos.google.cloud.networkconnectivity.v1alpha1.IGetHubRequest, - callback: Callback< - protos.google.cloud.networkconnectivity.v1alpha1.IHub, - protos.google.cloud.networkconnectivity.v1alpha1.IGetHubRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1alpha1.IGetHubRequest, + callback: Callback< + protos.google.cloud.networkconnectivity.v1alpha1.IHub, + | protos.google.cloud.networkconnectivity.v1alpha1.IGetHubRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getHub( - request?: protos.google.cloud.networkconnectivity.v1alpha1.IGetHubRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkconnectivity.v1alpha1.IHub, - protos.google.cloud.networkconnectivity.v1alpha1.IGetHubRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkconnectivity.v1alpha1.IGetHubRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkconnectivity.v1alpha1.IHub, - protos.google.cloud.networkconnectivity.v1alpha1.IGetHubRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkconnectivity.v1alpha1.IHub, - protos.google.cloud.networkconnectivity.v1alpha1.IGetHubRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkconnectivity.v1alpha1.IGetHubRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkconnectivity.v1alpha1.IHub, + | protos.google.cloud.networkconnectivity.v1alpha1.IGetHubRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1alpha1.IHub, + ( + | protos.google.cloud.networkconnectivity.v1alpha1.IGetHubRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getHub request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkconnectivity.v1alpha1.IHub, - protos.google.cloud.networkconnectivity.v1alpha1.IGetHubRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkconnectivity.v1alpha1.IHub, + | protos.google.cloud.networkconnectivity.v1alpha1.IGetHubRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getHub response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getHub(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkconnectivity.v1alpha1.IHub, - protos.google.cloud.networkconnectivity.v1alpha1.IGetHubRequest|undefined, - {}|undefined - ]) => { - this._log.info('getHub response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getHub(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkconnectivity.v1alpha1.IHub, + ( + | protos.google.cloud.networkconnectivity.v1alpha1.IGetHubRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getHub response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single Spoke. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of Spoke resource. - * @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 {@link protos.google.cloud.networkconnectivity.v1alpha1.Spoke|Spoke}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha1/hub_service.get_spoke.js - * region_tag:networkconnectivity_v1alpha1_generated_HubService_GetSpoke_async - */ + /** + * Gets details of a single Spoke. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of Spoke resource. + * @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 {@link protos.google.cloud.networkconnectivity.v1alpha1.Spoke|Spoke}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha1/hub_service.get_spoke.js + * region_tag:networkconnectivity_v1alpha1_generated_HubService_GetSpoke_async + */ getSpoke( - request?: protos.google.cloud.networkconnectivity.v1alpha1.IGetSpokeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, - protos.google.cloud.networkconnectivity.v1alpha1.IGetSpokeRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1alpha1.IGetSpokeRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, + ( + | protos.google.cloud.networkconnectivity.v1alpha1.IGetSpokeRequest + | undefined + ), + {} | undefined, + ] + >; getSpoke( - request: protos.google.cloud.networkconnectivity.v1alpha1.IGetSpokeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, - protos.google.cloud.networkconnectivity.v1alpha1.IGetSpokeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1alpha1.IGetSpokeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, + | protos.google.cloud.networkconnectivity.v1alpha1.IGetSpokeRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getSpoke( - request: protos.google.cloud.networkconnectivity.v1alpha1.IGetSpokeRequest, - callback: Callback< - protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, - protos.google.cloud.networkconnectivity.v1alpha1.IGetSpokeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1alpha1.IGetSpokeRequest, + callback: Callback< + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, + | protos.google.cloud.networkconnectivity.v1alpha1.IGetSpokeRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getSpoke( - request?: protos.google.cloud.networkconnectivity.v1alpha1.IGetSpokeRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.networkconnectivity.v1alpha1.IGetSpokeRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, - protos.google.cloud.networkconnectivity.v1alpha1.IGetSpokeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, - protos.google.cloud.networkconnectivity.v1alpha1.IGetSpokeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, - protos.google.cloud.networkconnectivity.v1alpha1.IGetSpokeRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkconnectivity.v1alpha1.IGetSpokeRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, + | protos.google.cloud.networkconnectivity.v1alpha1.IGetSpokeRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, + ( + | protos.google.cloud.networkconnectivity.v1alpha1.IGetSpokeRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getSpoke request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, - protos.google.cloud.networkconnectivity.v1alpha1.IGetSpokeRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, + | protos.google.cloud.networkconnectivity.v1alpha1.IGetSpokeRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getSpoke response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getSpoke(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, - protos.google.cloud.networkconnectivity.v1alpha1.IGetSpokeRequest|undefined, - {}|undefined - ]) => { - this._log.info('getSpoke response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getSpoke(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, + ( + | protos.google.cloud.networkconnectivity.v1alpha1.IGetSpokeRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getSpoke response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a new Hub in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name of the Hub. - * @param {string} [request.hubId] - * Optional. Unique id for the Hub to create. - * @param {google.cloud.networkconnectivity.v1alpha1.Hub} request.hub - * Required. Initial values for a new Hub. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server will know to ignore - * the request if it has already been completed. The server will guarantee - * that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and t - * he request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1alpha1/hub_service.create_hub.js - * region_tag:networkconnectivity_v1alpha1_generated_HubService_CreateHub_async - */ + /** + * Creates a new Hub in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name of the Hub. + * @param {string} [request.hubId] + * Optional. Unique id for the Hub to create. + * @param {google.cloud.networkconnectivity.v1alpha1.Hub} request.hub + * Required. Initial values for a new Hub. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server will know to ignore + * the request if it has already been completed. The server will guarantee + * that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and t + * he request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1alpha1/hub_service.create_hub.js + * region_tag:networkconnectivity_v1alpha1_generated_HubService_CreateHub_async + */ createHub( - request?: protos.google.cloud.networkconnectivity.v1alpha1.ICreateHubRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1alpha1.ICreateHubRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.IHub, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createHub( - request: protos.google.cloud.networkconnectivity.v1alpha1.ICreateHubRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1alpha1.ICreateHubRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.IHub, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createHub( - request: protos.google.cloud.networkconnectivity.v1alpha1.ICreateHubRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1alpha1.ICreateHubRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.IHub, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createHub( - request?: protos.google.cloud.networkconnectivity.v1alpha1.ICreateHubRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1alpha1.ICreateHubRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.IHub, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.IHub, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.IHub, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.IHub, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createHub response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createHub request %j', request); - return this.innerApiCalls.createHub(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createHub response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createHub(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.IHub, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createHub response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createHub()`. - * @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/v1alpha1/hub_service.create_hub.js - * region_tag:networkconnectivity_v1alpha1_generated_HubService_CreateHub_async - */ - async checkCreateHubProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createHub()`. + * @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/v1alpha1/hub_service.create_hub.js + * region_tag:networkconnectivity_v1alpha1_generated_HubService_CreateHub_async + */ + async checkCreateHubProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.Hub, + protos.google.cloud.networkconnectivity.v1alpha1.OperationMetadata + > + > { this._log.info('createHub long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createHub, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createHub, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.Hub, + protos.google.cloud.networkconnectivity.v1alpha1.OperationMetadata + >; } -/** - * Updates the parameters of a single Hub. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask is used to specify the fields to be overwritten in the - * Hub resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - * @param {google.cloud.networkconnectivity.v1alpha1.Hub} request.hub - * Required. The state that the Hub should be in after the update. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server will know to ignore - * the request if it has already been completed. The server will guarantee - * that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and t - * he request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1alpha1/hub_service.update_hub.js - * region_tag:networkconnectivity_v1alpha1_generated_HubService_UpdateHub_async - */ + /** + * Updates the parameters of a single Hub. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask is used to specify the fields to be overwritten in the + * Hub resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @param {google.cloud.networkconnectivity.v1alpha1.Hub} request.hub + * Required. The state that the Hub should be in after the update. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server will know to ignore + * the request if it has already been completed. The server will guarantee + * that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and t + * he request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1alpha1/hub_service.update_hub.js + * region_tag:networkconnectivity_v1alpha1_generated_HubService_UpdateHub_async + */ updateHub( - request?: protos.google.cloud.networkconnectivity.v1alpha1.IUpdateHubRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1alpha1.IUpdateHubRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.IHub, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateHub( - request: protos.google.cloud.networkconnectivity.v1alpha1.IUpdateHubRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1alpha1.IUpdateHubRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.IHub, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateHub( - request: protos.google.cloud.networkconnectivity.v1alpha1.IUpdateHubRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1alpha1.IUpdateHubRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.IHub, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateHub( - request?: protos.google.cloud.networkconnectivity.v1alpha1.IUpdateHubRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1alpha1.IUpdateHubRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.IHub, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.IHub, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.IHub, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'hub.name': request.hub!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'hub.name': request.hub!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.IHub, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateHub response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateHub request %j', request); - return this.innerApiCalls.updateHub(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateHub response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateHub(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.IHub, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateHub response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateHub()`. - * @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/v1alpha1/hub_service.update_hub.js - * region_tag:networkconnectivity_v1alpha1_generated_HubService_UpdateHub_async - */ - async checkUpdateHubProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateHub()`. + * @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/v1alpha1/hub_service.update_hub.js + * region_tag:networkconnectivity_v1alpha1_generated_HubService_UpdateHub_async + */ + async checkUpdateHubProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.Hub, + protos.google.cloud.networkconnectivity.v1alpha1.OperationMetadata + > + > { this._log.info('updateHub long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateHub, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateHub, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.Hub, + protos.google.cloud.networkconnectivity.v1alpha1.OperationMetadata + >; } -/** - * Deletes a single Hub. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the Hub to delete. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server will know to ignore - * the request if it has already been completed. The server will guarantee - * that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and t - * he request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1alpha1/hub_service.delete_hub.js - * region_tag:networkconnectivity_v1alpha1_generated_HubService_DeleteHub_async - */ + /** + * Deletes a single Hub. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the Hub to delete. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server will know to ignore + * the request if it has already been completed. The server will guarantee + * that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and t + * he request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1alpha1/hub_service.delete_hub.js + * region_tag:networkconnectivity_v1alpha1_generated_HubService_DeleteHub_async + */ deleteHub( - request?: protos.google.cloud.networkconnectivity.v1alpha1.IDeleteHubRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1alpha1.IDeleteHubRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteHub( - request: protos.google.cloud.networkconnectivity.v1alpha1.IDeleteHubRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1alpha1.IDeleteHubRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteHub( - request: protos.google.cloud.networkconnectivity.v1alpha1.IDeleteHubRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1alpha1.IDeleteHubRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteHub( - request?: protos.google.cloud.networkconnectivity.v1alpha1.IDeleteHubRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1alpha1.IDeleteHubRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteHub response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteHub request %j', request); - return this.innerApiCalls.deleteHub(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteHub response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteHub(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteHub response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteHub()`. - * @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/v1alpha1/hub_service.delete_hub.js - * region_tag:networkconnectivity_v1alpha1_generated_HubService_DeleteHub_async - */ - async checkDeleteHubProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteHub()`. + * @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/v1alpha1/hub_service.delete_hub.js + * region_tag:networkconnectivity_v1alpha1_generated_HubService_DeleteHub_async + */ + async checkDeleteHubProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1alpha1.OperationMetadata + > + > { this._log.info('deleteHub long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteHub, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteHub, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1alpha1.OperationMetadata + >; } -/** - * Creates a new Spoke in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent's resource name of the Spoke. - * @param {string} [request.spokeId] - * Optional. Unique id for the Spoke to create. - * @param {google.cloud.networkconnectivity.v1alpha1.Spoke} request.spoke - * Required. Initial values for a new Hub. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server will know to ignore - * the request if it has already been completed. The server will guarantee - * that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and t - * he request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1alpha1/hub_service.create_spoke.js - * region_tag:networkconnectivity_v1alpha1_generated_HubService_CreateSpoke_async - */ + /** + * Creates a new Spoke in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent's resource name of the Spoke. + * @param {string} [request.spokeId] + * Optional. Unique id for the Spoke to create. + * @param {google.cloud.networkconnectivity.v1alpha1.Spoke} request.spoke + * Required. Initial values for a new Hub. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server will know to ignore + * the request if it has already been completed. The server will guarantee + * that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and t + * he request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1alpha1/hub_service.create_spoke.js + * region_tag:networkconnectivity_v1alpha1_generated_HubService_CreateSpoke_async + */ createSpoke( - request?: protos.google.cloud.networkconnectivity.v1alpha1.ICreateSpokeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1alpha1.ICreateSpokeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createSpoke( - request: protos.google.cloud.networkconnectivity.v1alpha1.ICreateSpokeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1alpha1.ICreateSpokeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createSpoke( - request: protos.google.cloud.networkconnectivity.v1alpha1.ICreateSpokeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1alpha1.ICreateSpokeRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createSpoke( - request?: protos.google.cloud.networkconnectivity.v1alpha1.ICreateSpokeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1alpha1.ICreateSpokeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createSpoke response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createSpoke request %j', request); - return this.innerApiCalls.createSpoke(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createSpoke response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createSpoke(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createSpoke response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createSpoke()`. - * @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/v1alpha1/hub_service.create_spoke.js - * region_tag:networkconnectivity_v1alpha1_generated_HubService_CreateSpoke_async - */ - async checkCreateSpokeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createSpoke()`. + * @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/v1alpha1/hub_service.create_spoke.js + * region_tag:networkconnectivity_v1alpha1_generated_HubService_CreateSpoke_async + */ + async checkCreateSpokeProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.Spoke, + protos.google.cloud.networkconnectivity.v1alpha1.OperationMetadata + > + > { this._log.info('createSpoke long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createSpoke, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createSpoke, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.Spoke, + protos.google.cloud.networkconnectivity.v1alpha1.OperationMetadata + >; } -/** - * Updates the parameters of a single Spoke. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask is used to specify the fields to be overwritten in the - * Spoke resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - * @param {google.cloud.networkconnectivity.v1alpha1.Spoke} request.spoke - * Required. The state that the Spoke should be in after the update. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server will know to ignore - * the request if it has already been completed. The server will guarantee - * that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and t - * he request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1alpha1/hub_service.update_spoke.js - * region_tag:networkconnectivity_v1alpha1_generated_HubService_UpdateSpoke_async - */ + /** + * Updates the parameters of a single Spoke. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask is used to specify the fields to be overwritten in the + * Spoke resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @param {google.cloud.networkconnectivity.v1alpha1.Spoke} request.spoke + * Required. The state that the Spoke should be in after the update. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server will know to ignore + * the request if it has already been completed. The server will guarantee + * that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and t + * he request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1alpha1/hub_service.update_spoke.js + * region_tag:networkconnectivity_v1alpha1_generated_HubService_UpdateSpoke_async + */ updateSpoke( - request?: protos.google.cloud.networkconnectivity.v1alpha1.IUpdateSpokeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1alpha1.IUpdateSpokeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateSpoke( - request: protos.google.cloud.networkconnectivity.v1alpha1.IUpdateSpokeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1alpha1.IUpdateSpokeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateSpoke( - request: protos.google.cloud.networkconnectivity.v1alpha1.IUpdateSpokeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1alpha1.IUpdateSpokeRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateSpoke( - request?: protos.google.cloud.networkconnectivity.v1alpha1.IUpdateSpokeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1alpha1.IUpdateSpokeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'spoke.name': request.spoke!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'spoke.name': request.spoke!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateSpoke response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateSpoke request %j', request); - return this.innerApiCalls.updateSpoke(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateSpoke response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateSpoke(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateSpoke response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateSpoke()`. - * @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/v1alpha1/hub_service.update_spoke.js - * region_tag:networkconnectivity_v1alpha1_generated_HubService_UpdateSpoke_async - */ - async checkUpdateSpokeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateSpoke()`. + * @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/v1alpha1/hub_service.update_spoke.js + * region_tag:networkconnectivity_v1alpha1_generated_HubService_UpdateSpoke_async + */ + async checkUpdateSpokeProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.Spoke, + protos.google.cloud.networkconnectivity.v1alpha1.OperationMetadata + > + > { this._log.info('updateSpoke long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateSpoke, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateSpoke, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.Spoke, + protos.google.cloud.networkconnectivity.v1alpha1.OperationMetadata + >; } -/** - * Deletes a single Spoke. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the Spoke to delete. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server will know to ignore - * the request if it has already been completed. The server will guarantee - * that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and t - * he request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1alpha1/hub_service.delete_spoke.js - * region_tag:networkconnectivity_v1alpha1_generated_HubService_DeleteSpoke_async - */ + /** + * Deletes a single Spoke. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the Spoke to delete. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server will know to ignore + * the request if it has already been completed. The server will guarantee + * that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and t + * he request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1alpha1/hub_service.delete_spoke.js + * region_tag:networkconnectivity_v1alpha1_generated_HubService_DeleteSpoke_async + */ deleteSpoke( - request?: protos.google.cloud.networkconnectivity.v1alpha1.IDeleteSpokeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1alpha1.IDeleteSpokeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteSpoke( - request: protos.google.cloud.networkconnectivity.v1alpha1.IDeleteSpokeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1alpha1.IDeleteSpokeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteSpoke( - request: protos.google.cloud.networkconnectivity.v1alpha1.IDeleteSpokeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1alpha1.IDeleteSpokeRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteSpoke( - request?: protos.google.cloud.networkconnectivity.v1alpha1.IDeleteSpokeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1alpha1.IDeleteSpokeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteSpoke response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteSpoke request %j', request); - return this.innerApiCalls.deleteSpoke(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteSpoke response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteSpoke(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteSpoke response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteSpoke()`. - * @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/v1alpha1/hub_service.delete_spoke.js - * region_tag:networkconnectivity_v1alpha1_generated_HubService_DeleteSpoke_async - */ - async checkDeleteSpokeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteSpoke()`. + * @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/v1alpha1/hub_service.delete_spoke.js + * region_tag:networkconnectivity_v1alpha1_generated_HubService_DeleteSpoke_async + */ + async checkDeleteSpokeProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1alpha1.OperationMetadata + > + > { this._log.info('deleteSpoke long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteSpoke, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteSpoke, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1alpha1.OperationMetadata + >; } - /** - * Lists Hubs in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results per page that should be returned. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * A filter expression that filters the results listed in the response. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1alpha1.Hub|Hub}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listHubsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists Hubs in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results per page that should be returned. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * A filter expression that filters the results listed in the response. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1alpha1.Hub|Hub}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listHubsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listHubs( - request?: protos.google.cloud.networkconnectivity.v1alpha1.IListHubsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1alpha1.IHub[], - protos.google.cloud.networkconnectivity.v1alpha1.IListHubsRequest|null, - protos.google.cloud.networkconnectivity.v1alpha1.IListHubsResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1alpha1.IListHubsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1alpha1.IHub[], + protos.google.cloud.networkconnectivity.v1alpha1.IListHubsRequest | null, + protos.google.cloud.networkconnectivity.v1alpha1.IListHubsResponse, + ] + >; listHubs( - request: protos.google.cloud.networkconnectivity.v1alpha1.IListHubsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1alpha1.IListHubsRequest, - protos.google.cloud.networkconnectivity.v1alpha1.IListHubsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1alpha1.IHub>): void; + request: protos.google.cloud.networkconnectivity.v1alpha1.IListHubsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1alpha1.IListHubsRequest, + | protos.google.cloud.networkconnectivity.v1alpha1.IListHubsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1alpha1.IHub + >, + ): void; listHubs( - request: protos.google.cloud.networkconnectivity.v1alpha1.IListHubsRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1alpha1.IListHubsRequest, - protos.google.cloud.networkconnectivity.v1alpha1.IListHubsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1alpha1.IHub>): void; + request: protos.google.cloud.networkconnectivity.v1alpha1.IListHubsRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1alpha1.IListHubsRequest, + | protos.google.cloud.networkconnectivity.v1alpha1.IListHubsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1alpha1.IHub + >, + ): void; listHubs( - request?: protos.google.cloud.networkconnectivity.v1alpha1.IListHubsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1alpha1.IListHubsRequest, - protos.google.cloud.networkconnectivity.v1alpha1.IListHubsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1alpha1.IHub>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1alpha1.IListHubsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1alpha1.IListHubsRequest, - protos.google.cloud.networkconnectivity.v1alpha1.IListHubsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1alpha1.IHub>): - Promise<[ - protos.google.cloud.networkconnectivity.v1alpha1.IHub[], - protos.google.cloud.networkconnectivity.v1alpha1.IListHubsRequest|null, - protos.google.cloud.networkconnectivity.v1alpha1.IListHubsResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1alpha1.IListHubsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1alpha1.IHub + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1alpha1.IListHubsRequest, + | protos.google.cloud.networkconnectivity.v1alpha1.IListHubsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1alpha1.IHub + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1alpha1.IHub[], + protos.google.cloud.networkconnectivity.v1alpha1.IListHubsRequest | null, + protos.google.cloud.networkconnectivity.v1alpha1.IListHubsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1alpha1.IListHubsRequest, - protos.google.cloud.networkconnectivity.v1alpha1.IListHubsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1alpha1.IHub>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1alpha1.IListHubsRequest, + | protos.google.cloud.networkconnectivity.v1alpha1.IListHubsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1alpha1.IHub + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listHubs values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1454,201 +2087,230 @@ export class HubServiceClient { this._log.info('listHubs request %j', request); return this.innerApiCalls .listHubs(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1alpha1.IHub[], - protos.google.cloud.networkconnectivity.v1alpha1.IListHubsRequest|null, - protos.google.cloud.networkconnectivity.v1alpha1.IListHubsResponse - ]) => { - this._log.info('listHubs values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1alpha1.IHub[], + protos.google.cloud.networkconnectivity.v1alpha1.IListHubsRequest | null, + protos.google.cloud.networkconnectivity.v1alpha1.IListHubsResponse, + ]) => { + this._log.info('listHubs values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listHubs`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results per page that should be returned. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * A filter expression that filters the results listed in the response. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1alpha1.Hub|Hub} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listHubsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listHubs`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results per page that should be returned. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * A filter expression that filters the results listed in the response. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1alpha1.Hub|Hub} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listHubsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listHubsStream( - request?: protos.google.cloud.networkconnectivity.v1alpha1.IListHubsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1alpha1.IListHubsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listHubs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listHubs stream %j', request); return this.descriptors.page.listHubs.createStream( this.innerApiCalls.listHubs as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listHubs`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results per page that should be returned. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * A filter expression that filters the results listed in the response. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1alpha1.Hub|Hub}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha1/hub_service.list_hubs.js - * region_tag:networkconnectivity_v1alpha1_generated_HubService_ListHubs_async - */ + /** + * Equivalent to `listHubs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results per page that should be returned. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * A filter expression that filters the results listed in the response. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1alpha1.Hub|Hub}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha1/hub_service.list_hubs.js + * region_tag:networkconnectivity_v1alpha1_generated_HubService_ListHubs_async + */ listHubsAsync( - request?: protos.google.cloud.networkconnectivity.v1alpha1.IListHubsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1alpha1.IListHubsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listHubs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listHubs iterate %j', request); return this.descriptors.page.listHubs.asyncIterate( this.innerApiCalls['listHubs'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists Spokes in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent's resource name. - * @param {number} request.pageSize - * The maximum number of results per page that should be returned. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * A filter expression that filters the results listed in the response. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1alpha1.Spoke|Spoke}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listSpokesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists Spokes in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent's resource name. + * @param {number} request.pageSize + * The maximum number of results per page that should be returned. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * A filter expression that filters the results listed in the response. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1alpha1.Spoke|Spoke}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listSpokesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listSpokes( - request?: protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1alpha1.ISpoke[], - protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesRequest|null, - protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke[], + protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesRequest | null, + protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesResponse, + ] + >; listSpokes( - request: protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesRequest, - protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1alpha1.ISpoke>): void; + request: protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesRequest, + | protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke + >, + ): void; listSpokes( - request: protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesRequest, - protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1alpha1.ISpoke>): void; + request: protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesRequest, + | protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke + >, + ): void; listSpokes( - request?: protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesRequest, - protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1alpha1.ISpoke>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesRequest, - protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1alpha1.ISpoke>): - Promise<[ - protos.google.cloud.networkconnectivity.v1alpha1.ISpoke[], - protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesRequest|null, - protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesRequest, + | protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke[], + protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesRequest | null, + protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesRequest, - protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1alpha1.ISpoke>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesRequest, + | protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listSpokes values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1657,114 +2319,118 @@ export class HubServiceClient { this._log.info('listSpokes request %j', request); return this.innerApiCalls .listSpokes(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1alpha1.ISpoke[], - protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesRequest|null, - protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesResponse - ]) => { - this._log.info('listSpokes values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke[], + protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesRequest | null, + protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesResponse, + ]) => { + this._log.info('listSpokes values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listSpokes`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent's resource name. - * @param {number} request.pageSize - * The maximum number of results per page that should be returned. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * A filter expression that filters the results listed in the response. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1alpha1.Spoke|Spoke} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listSpokesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listSpokes`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent's resource name. + * @param {number} request.pageSize + * The maximum number of results per page that should be returned. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * A filter expression that filters the results listed in the response. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1alpha1.Spoke|Spoke} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listSpokesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listSpokesStream( - request?: protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listSpokes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listSpokes stream %j', request); return this.descriptors.page.listSpokes.createStream( this.innerApiCalls.listSpokes as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listSpokes`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent's resource name. - * @param {number} request.pageSize - * The maximum number of results per page that should be returned. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * A filter expression that filters the results listed in the response. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1alpha1.Spoke|Spoke}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha1/hub_service.list_spokes.js - * region_tag:networkconnectivity_v1alpha1_generated_HubService_ListSpokes_async - */ + /** + * Equivalent to `listSpokes`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent's resource name. + * @param {number} request.pageSize + * The maximum number of results per page that should be returned. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * A filter expression that filters the results listed in the response. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1alpha1.Spoke|Spoke}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha1/hub_service.list_spokes.js + * region_tag:networkconnectivity_v1alpha1_generated_HubService_ListSpokes_async + */ listSpokesAsync( - request?: protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1alpha1.IListSpokesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listSpokes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listSpokes iterate %j', request); return this.descriptors.page.listSpokes.asyncIterate( this.innerApiCalls['listSpokes'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -1778,7 +2444,7 @@ export class HubServiceClient { * @param {string} hub * @returns {string} Resource name string. */ - hubPath(project:string,hub:string) { + hubPath(project: string, hub: string) { return this.pathTemplates.hubPathTemplate.render({ project: project, hub: hub, @@ -1815,7 +2481,7 @@ export class HubServiceClient { * @param {string} instance * @returns {string} Resource name string. */ - instancePath(project:string,zone:string,instance:string) { + instancePath(project: string, zone: string, instance: string) { return this.pathTemplates.instancePathTemplate.render({ project: project, zone: zone, @@ -1864,7 +2530,11 @@ export class HubServiceClient { * @param {string} resource_id * @returns {string} Resource name string. */ - interconnectAttachmentPath(project:string,region:string,resourceId:string) { + interconnectAttachmentPath( + project: string, + region: string, + resourceId: string, + ) { return this.pathTemplates.interconnectAttachmentPathTemplate.render({ project: project, region: region, @@ -1879,8 +2549,12 @@ export class HubServiceClient { * A fully-qualified path representing InterconnectAttachment resource. * @returns {string} A string representing the project. */ - matchProjectFromInterconnectAttachmentName(interconnectAttachmentName: string) { - return this.pathTemplates.interconnectAttachmentPathTemplate.match(interconnectAttachmentName).project; + matchProjectFromInterconnectAttachmentName( + interconnectAttachmentName: string, + ) { + return this.pathTemplates.interconnectAttachmentPathTemplate.match( + interconnectAttachmentName, + ).project; } /** @@ -1890,8 +2564,12 @@ export class HubServiceClient { * A fully-qualified path representing InterconnectAttachment resource. * @returns {string} A string representing the region. */ - matchRegionFromInterconnectAttachmentName(interconnectAttachmentName: string) { - return this.pathTemplates.interconnectAttachmentPathTemplate.match(interconnectAttachmentName).region; + matchRegionFromInterconnectAttachmentName( + interconnectAttachmentName: string, + ) { + return this.pathTemplates.interconnectAttachmentPathTemplate.match( + interconnectAttachmentName, + ).region; } /** @@ -1901,8 +2579,12 @@ export class HubServiceClient { * A fully-qualified path representing InterconnectAttachment resource. * @returns {string} A string representing the resource_id. */ - matchResourceIdFromInterconnectAttachmentName(interconnectAttachmentName: string) { - return this.pathTemplates.interconnectAttachmentPathTemplate.match(interconnectAttachmentName).resource_id; + matchResourceIdFromInterconnectAttachmentName( + interconnectAttachmentName: string, + ) { + return this.pathTemplates.interconnectAttachmentPathTemplate.match( + interconnectAttachmentName, + ).resource_id; } /** @@ -1912,7 +2594,7 @@ export class HubServiceClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -1949,7 +2631,7 @@ export class HubServiceClient { * @param {string} spoke * @returns {string} Resource name string. */ - spokePath(project:string,location:string,spoke:string) { + spokePath(project: string, location: string, spoke: string) { return this.pathTemplates.spokePathTemplate.render({ project: project, location: location, @@ -1998,7 +2680,7 @@ export class HubServiceClient { * @param {string} resource_id * @returns {string} Resource name string. */ - vpnTunnelPath(project:string,region:string,resourceId:string) { + vpnTunnelPath(project: string, region: string, resourceId: string) { return this.pathTemplates.vpnTunnelPathTemplate.render({ project: project, region: region, @@ -2014,7 +2696,8 @@ export class HubServiceClient { * @returns {string} A string representing the project. */ matchProjectFromVpnTunnelName(vpnTunnelName: string) { - return this.pathTemplates.vpnTunnelPathTemplate.match(vpnTunnelName).project; + return this.pathTemplates.vpnTunnelPathTemplate.match(vpnTunnelName) + .project; } /** @@ -2036,7 +2719,8 @@ export class HubServiceClient { * @returns {string} A string representing the resource_id. */ matchResourceIdFromVpnTunnelName(vpnTunnelName: string) { - return this.pathTemplates.vpnTunnelPathTemplate.match(vpnTunnelName).resource_id; + return this.pathTemplates.vpnTunnelPathTemplate.match(vpnTunnelName) + .resource_id; } /** @@ -2047,7 +2731,7 @@ export class HubServiceClient { */ close(): Promise { if (this.hubServiceStub && !this._terminated) { - return this.hubServiceStub.then(stub => { + return this.hubServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -2056,4 +2740,4 @@ export class HubServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-networkconnectivity/src/v1alpha1/index.ts b/packages/google-cloud-networkconnectivity/src/v1alpha1/index.ts index 7bef456c5d5f..d35fc2d7d7a6 100644 --- a/packages/google-cloud-networkconnectivity/src/v1alpha1/index.ts +++ b/packages/google-cloud-networkconnectivity/src/v1alpha1/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {HubServiceClient} from './hub_service_client'; +export { HubServiceClient } from './hub_service_client'; diff --git a/packages/google-cloud-networkconnectivity/src/v1beta/data_transfer_service_client.ts b/packages/google-cloud-networkconnectivity/src/v1beta/data_transfer_service_client.ts index 18d3ca77dbb7..281428e4f223 100644 --- a/packages/google-cloud-networkconnectivity/src/v1beta/data_transfer_service_client.ts +++ b/packages/google-cloud-networkconnectivity/src/v1beta/data_transfer_service_client.ts @@ -18,11 +18,24 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -44,7 +57,7 @@ export class DataTransferServiceClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('networkconnectivity'); @@ -57,12 +70,12 @@ export class DataTransferServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - dataTransferServiceStub?: Promise<{[name: string]: Function}>; + dataTransferServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of DataTransferServiceClient. @@ -103,21 +116,42 @@ export class DataTransferServiceClient { * const client = new DataTransferServiceClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof DataTransferServiceClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'networkconnectivity.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -142,7 +176,7 @@ export class DataTransferServiceClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -155,18 +189,14 @@ export class DataTransferServiceClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -188,43 +218,45 @@ export class DataTransferServiceClient { // Create useful helper objects for these. this.pathTemplates = { destinationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}/destinations/{destination}' + 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}/destinations/{destination}', ), gatewayAdvertisedRoutePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/spokes/{spoke}/gatewayAdvertisedRoutes/{gateway_advertised_route}' + 'projects/{project}/locations/{location}/spokes/{spoke}/gatewayAdvertisedRoutes/{gateway_advertised_route}', ), groupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}/groups/{group}' + 'projects/{project}/locations/global/hubs/{hub}/groups/{group}', ), hubPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}' + 'projects/{project}/locations/global/hubs/{hub}', ), hubRoutePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}/routes/{route}' + 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}/routes/{route}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - multicloudDataTransferConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}' - ), - multicloudDataTransferSupportedServicePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/multicloudDataTransferSupportedServices/{multicloud_data_transfer_supported_service}' + 'projects/{project}/locations/{location}', ), + multicloudDataTransferConfigPathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}', + ), + multicloudDataTransferSupportedServicePathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/multicloudDataTransferSupportedServices/{multicloud_data_transfer_supported_service}', + ), policyBasedRoutePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/PolicyBasedRoutes/{policy_based_route}' + 'projects/{project}/locations/global/PolicyBasedRoutes/{policy_based_route}', ), remoteTransportProfilePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/remoteTransportProfiles/{remote_transport_profile}' + 'projects/{project}/locations/{location}/remoteTransportProfiles/{remote_transport_profile}', ), routeTablePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}' + 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}', ), spokePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/spokes/{spoke}' + 'projects/{project}/locations/{location}/spokes/{spoke}', ), transportPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/transports/{transport}' + 'projects/{project}/locations/{location}/transports/{transport}', ), }; @@ -232,12 +264,22 @@ export class DataTransferServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listMulticloudDataTransferConfigs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'multicloudDataTransferConfigs'), - listDestinations: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'destinations'), + listMulticloudDataTransferConfigs: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'multicloudDataTransferConfigs', + ), + listDestinations: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'destinations', + ), listMulticloudDataTransferSupportedServices: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'multicloudDataTransferSupportedServices') + new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'multicloudDataTransferSupportedServices', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -246,72 +288,186 @@ export class DataTransferServiceClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1beta/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1beta/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1beta/{resource=projects/*/locations/global/hubs/*}:getIamPolicy',additional_bindings: [{get: '/v1beta/{resource=projects/*/locations/global/hubs/*/groups/*}:getIamPolicy',},{get: '/v1beta/{resource=projects/*/locations/*/spokes/*}:getIamPolicy',},{get: '/v1beta/{resource=projects/*/locations/global/policyBasedRoutes/*}:getIamPolicy',}], - },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1beta/{resource=projects/*/locations/global/hubs/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1beta/{resource=projects/*/locations/global/hubs/*/groups/*}:setIamPolicy',body: '*',},{post: '/v1beta/{resource=projects/*/locations/*/spokes/*}:setIamPolicy',body: '*',},{post: '/v1beta/{resource=projects/*/locations/global/policyBasedRoutes/*}:setIamPolicy',body: '*',}], - },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1beta/{resource=projects/*/locations/global/hubs/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1beta/{resource=projects/*/locations/global/hubs/*/groups/*}:testIamPermissions',body: '*',},{post: '/v1beta/{resource=projects/*/locations/*/spokes/*}:testIamPermissions',body: '*',},{post: '/v1beta/{resource=projects/*/locations/global/policyBasedRoutes/*}:testIamPermissions',body: '*',}], - },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1beta/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1beta/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1beta/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1beta/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1beta/{resource=projects/*/locations/global/hubs/*}:getIamPolicy', + additional_bindings: [ + { + get: '/v1beta/{resource=projects/*/locations/global/hubs/*/groups/*}:getIamPolicy', + }, + { + get: '/v1beta/{resource=projects/*/locations/*/spokes/*}:getIamPolicy', + }, + { + get: '/v1beta/{resource=projects/*/locations/global/policyBasedRoutes/*}:getIamPolicy', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1beta/{resource=projects/*/locations/global/hubs/*}:setIamPolicy', + body: '*', + additional_bindings: [ + { + post: '/v1beta/{resource=projects/*/locations/global/hubs/*/groups/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1beta/{resource=projects/*/locations/*/spokes/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1beta/{resource=projects/*/locations/global/policyBasedRoutes/*}:setIamPolicy', + body: '*', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1beta/{resource=projects/*/locations/global/hubs/*}:testIamPermissions', + body: '*', + additional_bindings: [ + { + post: '/v1beta/{resource=projects/*/locations/global/hubs/*/groups/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1beta/{resource=projects/*/locations/*/spokes/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1beta/{resource=projects/*/locations/global/policyBasedRoutes/*}:testIamPermissions', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1beta/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1beta/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1beta/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1beta/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createMulticloudDataTransferConfigResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig', + ) as gax.protobuf.Type; const createMulticloudDataTransferConfigMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const updateMulticloudDataTransferConfigResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig', + ) as gax.protobuf.Type; const updateMulticloudDataTransferConfigMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const deleteMulticloudDataTransferConfigResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteMulticloudDataTransferConfigMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const createDestinationResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.Destination') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.Destination', + ) as gax.protobuf.Type; const createDestinationMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const updateDestinationResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.Destination') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.Destination', + ) as gax.protobuf.Type; const updateDestinationMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const deleteDestinationResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteDestinationMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { - createMulticloudDataTransferConfig: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createMulticloudDataTransferConfigResponse.decode.bind(createMulticloudDataTransferConfigResponse), - createMulticloudDataTransferConfigMetadata.decode.bind(createMulticloudDataTransferConfigMetadata)), - updateMulticloudDataTransferConfig: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateMulticloudDataTransferConfigResponse.decode.bind(updateMulticloudDataTransferConfigResponse), - updateMulticloudDataTransferConfigMetadata.decode.bind(updateMulticloudDataTransferConfigMetadata)), - deleteMulticloudDataTransferConfig: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteMulticloudDataTransferConfigResponse.decode.bind(deleteMulticloudDataTransferConfigResponse), - deleteMulticloudDataTransferConfigMetadata.decode.bind(deleteMulticloudDataTransferConfigMetadata)), + createMulticloudDataTransferConfig: + new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createMulticloudDataTransferConfigResponse.decode.bind( + createMulticloudDataTransferConfigResponse, + ), + createMulticloudDataTransferConfigMetadata.decode.bind( + createMulticloudDataTransferConfigMetadata, + ), + ), + updateMulticloudDataTransferConfig: + new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateMulticloudDataTransferConfigResponse.decode.bind( + updateMulticloudDataTransferConfigResponse, + ), + updateMulticloudDataTransferConfigMetadata.decode.bind( + updateMulticloudDataTransferConfigMetadata, + ), + ), + deleteMulticloudDataTransferConfig: + new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteMulticloudDataTransferConfigResponse.decode.bind( + deleteMulticloudDataTransferConfigResponse, + ), + deleteMulticloudDataTransferConfigMetadata.decode.bind( + deleteMulticloudDataTransferConfigMetadata, + ), + ), createDestination: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createDestinationResponse.decode.bind(createDestinationResponse), - createDestinationMetadata.decode.bind(createDestinationMetadata)), + createDestinationMetadata.decode.bind(createDestinationMetadata), + ), updateDestination: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateDestinationResponse.decode.bind(updateDestinationResponse), - updateDestinationMetadata.decode.bind(updateDestinationMetadata)), + updateDestinationMetadata.decode.bind(updateDestinationMetadata), + ), deleteDestination: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteDestinationResponse.decode.bind(deleteDestinationResponse), - deleteDestinationMetadata.decode.bind(deleteDestinationMetadata)) + deleteDestinationMetadata.decode.bind(deleteDestinationMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.networkconnectivity.v1beta.DataTransferService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.networkconnectivity.v1beta.DataTransferService', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -342,28 +498,47 @@ export class DataTransferServiceClient { // Put together the "service stub" for // google.cloud.networkconnectivity.v1beta.DataTransferService. this.dataTransferServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.networkconnectivity.v1beta.DataTransferService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.networkconnectivity.v1beta.DataTransferService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.networkconnectivity.v1beta.DataTransferService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.networkconnectivity.v1beta + .DataTransferService, + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const dataTransferServiceStubMethods = - ['listMulticloudDataTransferConfigs', 'getMulticloudDataTransferConfig', 'createMulticloudDataTransferConfig', 'updateMulticloudDataTransferConfig', 'deleteMulticloudDataTransferConfig', 'listDestinations', 'getDestination', 'createDestination', 'updateDestination', 'deleteDestination', 'getMulticloudDataTransferSupportedService', 'listMulticloudDataTransferSupportedServices']; + const dataTransferServiceStubMethods = [ + 'listMulticloudDataTransferConfigs', + 'getMulticloudDataTransferConfig', + 'createMulticloudDataTransferConfig', + 'updateMulticloudDataTransferConfig', + 'deleteMulticloudDataTransferConfig', + 'listDestinations', + 'getDestination', + 'createDestination', + 'updateDestination', + 'deleteDestination', + 'getMulticloudDataTransferSupportedService', + 'listMulticloudDataTransferSupportedServices', + ]; for (const methodName of dataTransferServiceStubMethods) { const callPromise = this.dataTransferServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -373,7 +548,7 @@ export class DataTransferServiceClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -388,8 +563,14 @@ export class DataTransferServiceClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkconnectivity.googleapis.com'; } @@ -400,8 +581,14 @@ export class DataTransferServiceClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkconnectivity.googleapis.com'; } @@ -432,9 +619,7 @@ export class DataTransferServiceClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -443,8 +628,9 @@ export class DataTransferServiceClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -455,1141 +641,1723 @@ export class DataTransferServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets the details of a `MulticloudDataTransferConfig` resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the `MulticloudDataTransferConfig` resource to get. - * @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 {@link protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig|MulticloudDataTransferConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/data_transfer_service.get_multicloud_data_transfer_config.js - * region_tag:networkconnectivity_v1beta_generated_DataTransferService_GetMulticloudDataTransferConfig_async - */ + /** + * Gets the details of a `MulticloudDataTransferConfig` resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the `MulticloudDataTransferConfig` resource to get. + * @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 {@link protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig|MulticloudDataTransferConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/data_transfer_service.get_multicloud_data_transfer_config.js + * region_tag:networkconnectivity_v1beta_generated_DataTransferService_GetMulticloudDataTransferConfig_async + */ getMulticloudDataTransferConfig( - request?: protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, - protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferConfigRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferConfigRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferConfigRequest + | undefined + ), + {} | undefined, + ] + >; getMulticloudDataTransferConfig( - request: protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, - protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, + | protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getMulticloudDataTransferConfig( - request: protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferConfigRequest, - callback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, - protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferConfigRequest, + callback: Callback< + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, + | protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getMulticloudDataTransferConfig( - request?: protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, - protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, - protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, - protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferConfigRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, + | protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferConfigRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getMulticloudDataTransferConfig request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, - protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferConfigRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, + | protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferConfigRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { - this._log.info('getMulticloudDataTransferConfig response %j', response); + this._log.info( + 'getMulticloudDataTransferConfig response %j', + response, + ); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getMulticloudDataTransferConfig(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, - protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferConfigRequest|undefined, - {}|undefined - ]) => { - this._log.info('getMulticloudDataTransferConfig response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getMulticloudDataTransferConfig(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferConfigRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info( + 'getMulticloudDataTransferConfig response %j', + response, + ); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets the details of a `Destination` resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the `Destination` resource to get. - * @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 {@link protos.google.cloud.networkconnectivity.v1beta.Destination|Destination}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/data_transfer_service.get_destination.js - * region_tag:networkconnectivity_v1beta_generated_DataTransferService_GetDestination_async - */ + /** + * Gets the details of a `Destination` resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the `Destination` resource to get. + * @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 {@link protos.google.cloud.networkconnectivity.v1beta.Destination|Destination}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/data_transfer_service.get_destination.js + * region_tag:networkconnectivity_v1beta_generated_DataTransferService_GetDestination_async + */ getDestination( - request?: protos.google.cloud.networkconnectivity.v1beta.IGetDestinationRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IDestination, - protos.google.cloud.networkconnectivity.v1beta.IGetDestinationRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IGetDestinationRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IDestination, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetDestinationRequest + | undefined + ), + {} | undefined, + ] + >; getDestination( - request: protos.google.cloud.networkconnectivity.v1beta.IGetDestinationRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IDestination, - protos.google.cloud.networkconnectivity.v1beta.IGetDestinationRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IGetDestinationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkconnectivity.v1beta.IDestination, + | protos.google.cloud.networkconnectivity.v1beta.IGetDestinationRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getDestination( - request: protos.google.cloud.networkconnectivity.v1beta.IGetDestinationRequest, - callback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IDestination, - protos.google.cloud.networkconnectivity.v1beta.IGetDestinationRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IGetDestinationRequest, + callback: Callback< + protos.google.cloud.networkconnectivity.v1beta.IDestination, + | protos.google.cloud.networkconnectivity.v1beta.IGetDestinationRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getDestination( - request?: protos.google.cloud.networkconnectivity.v1beta.IGetDestinationRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkconnectivity.v1beta.IDestination, - protos.google.cloud.networkconnectivity.v1beta.IGetDestinationRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkconnectivity.v1beta.IGetDestinationRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkconnectivity.v1beta.IDestination, - protos.google.cloud.networkconnectivity.v1beta.IGetDestinationRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IDestination, - protos.google.cloud.networkconnectivity.v1beta.IGetDestinationRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkconnectivity.v1beta.IGetDestinationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkconnectivity.v1beta.IDestination, + | protos.google.cloud.networkconnectivity.v1beta.IGetDestinationRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IDestination, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetDestinationRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getDestination request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IDestination, - protos.google.cloud.networkconnectivity.v1beta.IGetDestinationRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkconnectivity.v1beta.IDestination, + | protos.google.cloud.networkconnectivity.v1beta.IGetDestinationRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getDestination response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getDestination(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkconnectivity.v1beta.IDestination, - protos.google.cloud.networkconnectivity.v1beta.IGetDestinationRequest|undefined, - {}|undefined - ]) => { - this._log.info('getDestination response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getDestination(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkconnectivity.v1beta.IDestination, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetDestinationRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getDestination response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets the details of a service that is supported for Data Transfer - * Essentials. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the service. - * @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 {@link protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService|MulticloudDataTransferSupportedService}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/data_transfer_service.get_multicloud_data_transfer_supported_service.js - * region_tag:networkconnectivity_v1beta_generated_DataTransferService_GetMulticloudDataTransferSupportedService_async - */ + /** + * Gets the details of a service that is supported for Data Transfer + * Essentials. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the service. + * @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 {@link protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService|MulticloudDataTransferSupportedService}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/data_transfer_service.get_multicloud_data_transfer_supported_service.js + * region_tag:networkconnectivity_v1beta_generated_DataTransferService_GetMulticloudDataTransferSupportedService_async + */ getMulticloudDataTransferSupportedService( - request?: protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferSupportedServiceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService, - protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferSupportedServiceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferSupportedServiceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferSupportedServiceRequest + | undefined + ), + {} | undefined, + ] + >; getMulticloudDataTransferSupportedService( - request: protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferSupportedServiceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService, - protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferSupportedServiceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferSupportedServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService, + | protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferSupportedServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getMulticloudDataTransferSupportedService( - request: protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferSupportedServiceRequest, - callback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService, - protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferSupportedServiceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferSupportedServiceRequest, + callback: Callback< + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService, + | protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferSupportedServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getMulticloudDataTransferSupportedService( - request?: protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferSupportedServiceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService, - protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferSupportedServiceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferSupportedServiceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService, - protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferSupportedServiceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService, - protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferSupportedServiceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferSupportedServiceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService, + | protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferSupportedServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferSupportedServiceRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - this._log.info('getMulticloudDataTransferSupportedService request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService, - protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferSupportedServiceRequest|null|undefined, - {}|null|undefined>|undefined = callback + this._log.info( + 'getMulticloudDataTransferSupportedService request %j', + request, + ); + const wrappedCallback: + | Callback< + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService, + | protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferSupportedServiceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { - this._log.info('getMulticloudDataTransferSupportedService response %j', response); + this._log.info( + 'getMulticloudDataTransferSupportedService response %j', + response, + ); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getMulticloudDataTransferSupportedService(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService, - protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferSupportedServiceRequest|undefined, - {}|undefined - ]) => { - this._log.info('getMulticloudDataTransferSupportedService response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getMulticloudDataTransferSupportedService( + request, + options, + wrappedCallback, + ) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetMulticloudDataTransferSupportedServiceRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info( + 'getMulticloudDataTransferSupportedService response %j', + response, + ); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a `MulticloudDataTransferConfig` resource in a specified project - * and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent resource. - * @param {string} request.multicloudDataTransferConfigId - * Required. The ID to use for the `MulticloudDataTransferConfig` resource, - * which becomes the final component of the `MulticloudDataTransferConfig` - * resource name. - * @param {google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig} request.multicloudDataTransferConfig - * Required. The `MulticloudDataTransferConfig` resource to create. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server can ignore - * the request if it has already been completed. The server waits - * for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, can ignore the second request. This prevents - * clients from accidentally creating duplicate `MulticloudDataTransferConfig` - * resources. - * - * The request ID must be a valid UUID with the exception that zero UUID - * (00000000-0000-0000-0000-000000000000) isn't supported. - * @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/v1beta/data_transfer_service.create_multicloud_data_transfer_config.js - * region_tag:networkconnectivity_v1beta_generated_DataTransferService_CreateMulticloudDataTransferConfig_async - */ + /** + * Creates a `MulticloudDataTransferConfig` resource in a specified project + * and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent resource. + * @param {string} request.multicloudDataTransferConfigId + * Required. The ID to use for the `MulticloudDataTransferConfig` resource, + * which becomes the final component of the `MulticloudDataTransferConfig` + * resource name. + * @param {google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig} request.multicloudDataTransferConfig + * Required. The `MulticloudDataTransferConfig` resource to create. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server can ignore + * the request if it has already been completed. The server waits + * for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, can ignore the second request. This prevents + * clients from accidentally creating duplicate `MulticloudDataTransferConfig` + * resources. + * + * The request ID must be a valid UUID with the exception that zero UUID + * (00000000-0000-0000-0000-000000000000) isn't supported. + * @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/v1beta/data_transfer_service.create_multicloud_data_transfer_config.js + * region_tag:networkconnectivity_v1beta_generated_DataTransferService_CreateMulticloudDataTransferConfig_async + */ createMulticloudDataTransferConfig( - request?: protos.google.cloud.networkconnectivity.v1beta.ICreateMulticloudDataTransferConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.ICreateMulticloudDataTransferConfigRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createMulticloudDataTransferConfig( - request: protos.google.cloud.networkconnectivity.v1beta.ICreateMulticloudDataTransferConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.ICreateMulticloudDataTransferConfigRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createMulticloudDataTransferConfig( - request: protos.google.cloud.networkconnectivity.v1beta.ICreateMulticloudDataTransferConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.ICreateMulticloudDataTransferConfigRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createMulticloudDataTransferConfig( - request?: protos.google.cloud.networkconnectivity.v1beta.ICreateMulticloudDataTransferConfigRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1beta.ICreateMulticloudDataTransferConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { - this._log.info('createMulticloudDataTransferConfig response %j', rawResponse); + this._log.info( + 'createMulticloudDataTransferConfig response %j', + rawResponse, + ); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createMulticloudDataTransferConfig request %j', request); - return this.innerApiCalls.createMulticloudDataTransferConfig(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createMulticloudDataTransferConfig response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createMulticloudDataTransferConfig(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info( + 'createMulticloudDataTransferConfig response %j', + rawResponse, + ); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createMulticloudDataTransferConfig()`. - * @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/v1beta/data_transfer_service.create_multicloud_data_transfer_config.js - * region_tag:networkconnectivity_v1beta_generated_DataTransferService_CreateMulticloudDataTransferConfig_async - */ - async checkCreateMulticloudDataTransferConfigProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createMulticloudDataTransferConfig()`. + * @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/v1beta/data_transfer_service.create_multicloud_data_transfer_config.js + * region_tag:networkconnectivity_v1beta_generated_DataTransferService_CreateMulticloudDataTransferConfig_async + */ + async checkCreateMulticloudDataTransferConfigProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + > + > { this._log.info('createMulticloudDataTransferConfig long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createMulticloudDataTransferConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createMulticloudDataTransferConfig, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + >; } -/** - * Updates a `MulticloudDataTransferConfig` resource in a specified project - * and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. `FieldMask` is used to specify the fields in the - * `MulticloudDataTransferConfig` resource to be overwritten by the update. - * The fields specified in `update_mask` are relative to the resource, not - * the full request. A field is overwritten if it is in the mask. If you - * don't specify a mask, all fields are overwritten. - * @param {google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig} request.multicloudDataTransferConfig - * Required. The `MulticloudDataTransferConfig` resource to update. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server can ignore - * the request if it has already been completed. The server waits - * for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, can ignore the second request. This prevents - * clients from accidentally creating duplicate `MulticloudDataTransferConfig` - * resources. - * - * The request ID must be a valid UUID with the exception that zero UUID - * (00000000-0000-0000-0000-000000000000) isn't supported. - * @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/v1beta/data_transfer_service.update_multicloud_data_transfer_config.js - * region_tag:networkconnectivity_v1beta_generated_DataTransferService_UpdateMulticloudDataTransferConfig_async - */ + /** + * Updates a `MulticloudDataTransferConfig` resource in a specified project + * and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. `FieldMask` is used to specify the fields in the + * `MulticloudDataTransferConfig` resource to be overwritten by the update. + * The fields specified in `update_mask` are relative to the resource, not + * the full request. A field is overwritten if it is in the mask. If you + * don't specify a mask, all fields are overwritten. + * @param {google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig} request.multicloudDataTransferConfig + * Required. The `MulticloudDataTransferConfig` resource to update. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server can ignore + * the request if it has already been completed. The server waits + * for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, can ignore the second request. This prevents + * clients from accidentally creating duplicate `MulticloudDataTransferConfig` + * resources. + * + * The request ID must be a valid UUID with the exception that zero UUID + * (00000000-0000-0000-0000-000000000000) isn't supported. + * @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/v1beta/data_transfer_service.update_multicloud_data_transfer_config.js + * region_tag:networkconnectivity_v1beta_generated_DataTransferService_UpdateMulticloudDataTransferConfig_async + */ updateMulticloudDataTransferConfig( - request?: protos.google.cloud.networkconnectivity.v1beta.IUpdateMulticloudDataTransferConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IUpdateMulticloudDataTransferConfigRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateMulticloudDataTransferConfig( - request: protos.google.cloud.networkconnectivity.v1beta.IUpdateMulticloudDataTransferConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IUpdateMulticloudDataTransferConfigRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateMulticloudDataTransferConfig( - request: protos.google.cloud.networkconnectivity.v1beta.IUpdateMulticloudDataTransferConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IUpdateMulticloudDataTransferConfigRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateMulticloudDataTransferConfig( - request?: protos.google.cloud.networkconnectivity.v1beta.IUpdateMulticloudDataTransferConfigRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1beta.IUpdateMulticloudDataTransferConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'multicloud_data_transfer_config.name': request.multicloudDataTransferConfig!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'multicloud_data_transfer_config.name': + request.multicloudDataTransferConfig!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { - this._log.info('updateMulticloudDataTransferConfig response %j', rawResponse); + this._log.info( + 'updateMulticloudDataTransferConfig response %j', + rawResponse, + ); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateMulticloudDataTransferConfig request %j', request); - return this.innerApiCalls.updateMulticloudDataTransferConfig(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateMulticloudDataTransferConfig response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateMulticloudDataTransferConfig(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info( + 'updateMulticloudDataTransferConfig response %j', + rawResponse, + ); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateMulticloudDataTransferConfig()`. - * @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/v1beta/data_transfer_service.update_multicloud_data_transfer_config.js - * region_tag:networkconnectivity_v1beta_generated_DataTransferService_UpdateMulticloudDataTransferConfig_async - */ - async checkUpdateMulticloudDataTransferConfigProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateMulticloudDataTransferConfig()`. + * @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/v1beta/data_transfer_service.update_multicloud_data_transfer_config.js + * region_tag:networkconnectivity_v1beta_generated_DataTransferService_UpdateMulticloudDataTransferConfig_async + */ + async checkUpdateMulticloudDataTransferConfigProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + > + > { this._log.info('updateMulticloudDataTransferConfig long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateMulticloudDataTransferConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateMulticloudDataTransferConfig, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + >; } -/** - * Deletes a `MulticloudDataTransferConfig` resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the `MulticloudDataTransferConfig` resource to - * delete. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server can ignore - * the request if it has already been completed. The server waits - * for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, can ignore the second request. This prevents - * clients from accidentally creating duplicate `MulticloudDataTransferConfig` - * resources. - * - * The request ID must be a valid UUID with the exception that zero UUID - * (00000000-0000-0000-0000-000000000000) isn't supported. - * @param {string} [request.etag] - * Optional. The etag is computed by the server, and might be sent with update - * and delete requests so that the client has an up-to-date value before - * proceeding. - * @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/v1beta/data_transfer_service.delete_multicloud_data_transfer_config.js - * region_tag:networkconnectivity_v1beta_generated_DataTransferService_DeleteMulticloudDataTransferConfig_async - */ + /** + * Deletes a `MulticloudDataTransferConfig` resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the `MulticloudDataTransferConfig` resource to + * delete. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server can ignore + * the request if it has already been completed. The server waits + * for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, can ignore the second request. This prevents + * clients from accidentally creating duplicate `MulticloudDataTransferConfig` + * resources. + * + * The request ID must be a valid UUID with the exception that zero UUID + * (00000000-0000-0000-0000-000000000000) isn't supported. + * @param {string} [request.etag] + * Optional. The etag is computed by the server, and might be sent with update + * and delete requests so that the client has an up-to-date value before + * proceeding. + * @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/v1beta/data_transfer_service.delete_multicloud_data_transfer_config.js + * region_tag:networkconnectivity_v1beta_generated_DataTransferService_DeleteMulticloudDataTransferConfig_async + */ deleteMulticloudDataTransferConfig( - request?: protos.google.cloud.networkconnectivity.v1beta.IDeleteMulticloudDataTransferConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IDeleteMulticloudDataTransferConfigRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteMulticloudDataTransferConfig( - request: protos.google.cloud.networkconnectivity.v1beta.IDeleteMulticloudDataTransferConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IDeleteMulticloudDataTransferConfigRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteMulticloudDataTransferConfig( - request: protos.google.cloud.networkconnectivity.v1beta.IDeleteMulticloudDataTransferConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IDeleteMulticloudDataTransferConfigRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteMulticloudDataTransferConfig( - request?: protos.google.cloud.networkconnectivity.v1beta.IDeleteMulticloudDataTransferConfigRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1beta.IDeleteMulticloudDataTransferConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { - this._log.info('deleteMulticloudDataTransferConfig response %j', rawResponse); + this._log.info( + 'deleteMulticloudDataTransferConfig response %j', + rawResponse, + ); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteMulticloudDataTransferConfig request %j', request); - return this.innerApiCalls.deleteMulticloudDataTransferConfig(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteMulticloudDataTransferConfig response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteMulticloudDataTransferConfig(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info( + 'deleteMulticloudDataTransferConfig response %j', + rawResponse, + ); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteMulticloudDataTransferConfig()`. - * @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/v1beta/data_transfer_service.delete_multicloud_data_transfer_config.js - * region_tag:networkconnectivity_v1beta_generated_DataTransferService_DeleteMulticloudDataTransferConfig_async - */ - async checkDeleteMulticloudDataTransferConfigProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteMulticloudDataTransferConfig()`. + * @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/v1beta/data_transfer_service.delete_multicloud_data_transfer_config.js + * region_tag:networkconnectivity_v1beta_generated_DataTransferService_DeleteMulticloudDataTransferConfig_async + */ + async checkDeleteMulticloudDataTransferConfigProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + > + > { this._log.info('deleteMulticloudDataTransferConfig long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteMulticloudDataTransferConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteMulticloudDataTransferConfig, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + >; } -/** - * Creates a `Destination` resource in a specified project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent resource. - * @param {string} request.destinationId - * Required. The ID to use for the `Destination` resource, which becomes the - * final component of the `Destination` resource name. - * @param {google.cloud.networkconnectivity.v1beta.Destination} request.destination - * Required. The `Destination` resource to create. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server can ignore - * the request if it has already been completed. The server waits - * for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, can ignore the second request. This prevents - * clients from accidentally creating duplicate `Destination` - * resources. - * - * The request ID must be a valid UUID with the exception that zero UUID - * (00000000-0000-0000-0000-000000000000) isn't supported. - * @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/v1beta/data_transfer_service.create_destination.js - * region_tag:networkconnectivity_v1beta_generated_DataTransferService_CreateDestination_async - */ + /** + * Creates a `Destination` resource in a specified project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent resource. + * @param {string} request.destinationId + * Required. The ID to use for the `Destination` resource, which becomes the + * final component of the `Destination` resource name. + * @param {google.cloud.networkconnectivity.v1beta.Destination} request.destination + * Required. The `Destination` resource to create. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server can ignore + * the request if it has already been completed. The server waits + * for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, can ignore the second request. This prevents + * clients from accidentally creating duplicate `Destination` + * resources. + * + * The request ID must be a valid UUID with the exception that zero UUID + * (00000000-0000-0000-0000-000000000000) isn't supported. + * @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/v1beta/data_transfer_service.create_destination.js + * region_tag:networkconnectivity_v1beta_generated_DataTransferService_CreateDestination_async + */ createDestination( - request?: protos.google.cloud.networkconnectivity.v1beta.ICreateDestinationRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.ICreateDestinationRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IDestination, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createDestination( - request: protos.google.cloud.networkconnectivity.v1beta.ICreateDestinationRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.ICreateDestinationRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IDestination, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createDestination( - request: protos.google.cloud.networkconnectivity.v1beta.ICreateDestinationRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.ICreateDestinationRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IDestination, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createDestination( - request?: protos.google.cloud.networkconnectivity.v1beta.ICreateDestinationRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1beta.ICreateDestinationRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IDestination, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IDestination, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IDestination, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IDestination, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createDestination response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createDestination request %j', request); - return this.innerApiCalls.createDestination(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createDestination response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createDestination(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IDestination, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createDestination response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createDestination()`. - * @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/v1beta/data_transfer_service.create_destination.js - * region_tag:networkconnectivity_v1beta_generated_DataTransferService_CreateDestination_async - */ - async checkCreateDestinationProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createDestination()`. + * @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/v1beta/data_transfer_service.create_destination.js + * region_tag:networkconnectivity_v1beta_generated_DataTransferService_CreateDestination_async + */ + async checkCreateDestinationProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.Destination, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + > + > { this._log.info('createDestination long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createDestination, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createDestination, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1beta.Destination, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + >; } -/** - * Updates a `Destination` resource in a specified project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. `FieldMask is used to specify the fields to be overwritten in the - * `Destination` resource by the update. - * The fields specified in `update_mask` are relative to the resource, not - * the full request. A field is overwritten if it is in the mask. If you - * don't specify a mask, all fields are overwritten. - * @param {google.cloud.networkconnectivity.v1beta.Destination} request.destination - * Required. The `Destination` resource to update. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server can ignore - * the request if it has already been completed. The server waits - * for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, can ignore the second request. - * - * The request ID must be a valid UUID with the exception that zero UUID - * (00000000-0000-0000-0000-000000000000) isn't supported. - * @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/v1beta/data_transfer_service.update_destination.js - * region_tag:networkconnectivity_v1beta_generated_DataTransferService_UpdateDestination_async - */ + /** + * Updates a `Destination` resource in a specified project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. `FieldMask is used to specify the fields to be overwritten in the + * `Destination` resource by the update. + * The fields specified in `update_mask` are relative to the resource, not + * the full request. A field is overwritten if it is in the mask. If you + * don't specify a mask, all fields are overwritten. + * @param {google.cloud.networkconnectivity.v1beta.Destination} request.destination + * Required. The `Destination` resource to update. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server can ignore + * the request if it has already been completed. The server waits + * for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, can ignore the second request. + * + * The request ID must be a valid UUID with the exception that zero UUID + * (00000000-0000-0000-0000-000000000000) isn't supported. + * @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/v1beta/data_transfer_service.update_destination.js + * region_tag:networkconnectivity_v1beta_generated_DataTransferService_UpdateDestination_async + */ updateDestination( - request?: protos.google.cloud.networkconnectivity.v1beta.IUpdateDestinationRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IUpdateDestinationRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IDestination, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateDestination( - request: protos.google.cloud.networkconnectivity.v1beta.IUpdateDestinationRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IUpdateDestinationRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IDestination, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateDestination( - request: protos.google.cloud.networkconnectivity.v1beta.IUpdateDestinationRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IUpdateDestinationRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IDestination, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateDestination( - request?: protos.google.cloud.networkconnectivity.v1beta.IUpdateDestinationRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1beta.IUpdateDestinationRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IDestination, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IDestination, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IDestination, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'destination.name': request.destination!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'destination.name': request.destination!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IDestination, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateDestination response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateDestination request %j', request); - return this.innerApiCalls.updateDestination(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateDestination response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateDestination(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IDestination, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateDestination response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateDestination()`. - * @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/v1beta/data_transfer_service.update_destination.js - * region_tag:networkconnectivity_v1beta_generated_DataTransferService_UpdateDestination_async - */ - async checkUpdateDestinationProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateDestination()`. + * @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/v1beta/data_transfer_service.update_destination.js + * region_tag:networkconnectivity_v1beta_generated_DataTransferService_UpdateDestination_async + */ + async checkUpdateDestinationProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.Destination, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + > + > { this._log.info('updateDestination long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateDestination, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateDestination, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1beta.Destination, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + >; } -/** - * Deletes a `Destination` resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the `Destination` resource to delete. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server can ignore - * the request if it has already been completed. The server waits - * for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, can ignore the second request. - * - * The request ID must be a valid UUID with the exception that zero UUID - * (00000000-0000-0000-0000-000000000000) isn't supported. - * @param {string} [request.etag] - * Optional. The etag is computed by the server, and might be sent with update - * and delete requests so that the client has an up-to-date value before - * proceeding. - * @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/v1beta/data_transfer_service.delete_destination.js - * region_tag:networkconnectivity_v1beta_generated_DataTransferService_DeleteDestination_async - */ + /** + * Deletes a `Destination` resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the `Destination` resource to delete. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server can ignore + * the request if it has already been completed. The server waits + * for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, can ignore the second request. + * + * The request ID must be a valid UUID with the exception that zero UUID + * (00000000-0000-0000-0000-000000000000) isn't supported. + * @param {string} [request.etag] + * Optional. The etag is computed by the server, and might be sent with update + * and delete requests so that the client has an up-to-date value before + * proceeding. + * @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/v1beta/data_transfer_service.delete_destination.js + * region_tag:networkconnectivity_v1beta_generated_DataTransferService_DeleteDestination_async + */ deleteDestination( - request?: protos.google.cloud.networkconnectivity.v1beta.IDeleteDestinationRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IDeleteDestinationRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteDestination( - request: protos.google.cloud.networkconnectivity.v1beta.IDeleteDestinationRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IDeleteDestinationRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteDestination( - request: protos.google.cloud.networkconnectivity.v1beta.IDeleteDestinationRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IDeleteDestinationRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteDestination( - request?: protos.google.cloud.networkconnectivity.v1beta.IDeleteDestinationRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1beta.IDeleteDestinationRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteDestination response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteDestination request %j', request); - return this.innerApiCalls.deleteDestination(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteDestination response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteDestination(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteDestination response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteDestination()`. - * @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/v1beta/data_transfer_service.delete_destination.js - * region_tag:networkconnectivity_v1beta_generated_DataTransferService_DeleteDestination_async - */ - async checkDeleteDestinationProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteDestination()`. + * @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/v1beta/data_transfer_service.delete_destination.js + * region_tag:networkconnectivity_v1beta_generated_DataTransferService_DeleteDestination_async + */ + async checkDeleteDestinationProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + > + > { this._log.info('deleteDestination long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteDestination, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists the `MulticloudDataTransferConfig` resources in a specified project - * and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent resource. - * @param {number} [request.pageSize] - * Optional. The maximum number of results listed per page. - * @param {string} [request.pageToken] - * Optional. The page token. - * @param {string} [request.filter] - * Optional. An expression that filters the results listed in the response. - * @param {string} [request.orderBy] - * Optional. The sort order of the results. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If `true`, allows partial responses for multi-regional aggregated - * list requests. - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig|MulticloudDataTransferConfig}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listMulticloudDataTransferConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteDestination, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + >; + } + /** + * Lists the `MulticloudDataTransferConfig` resources in a specified project + * and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent resource. + * @param {number} [request.pageSize] + * Optional. The maximum number of results listed per page. + * @param {string} [request.pageToken] + * Optional. The page token. + * @param {string} [request.filter] + * Optional. An expression that filters the results listed in the response. + * @param {string} [request.orderBy] + * Optional. The sort order of the results. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If `true`, allows partial responses for multi-regional aggregated + * list requests. + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig|MulticloudDataTransferConfig}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listMulticloudDataTransferConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMulticloudDataTransferConfigs( - request?: protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig[], - protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig[], + protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsResponse, + ] + >; listMulticloudDataTransferConfigs( - request: protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsRequest, - protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig + >, + ): void; listMulticloudDataTransferConfigs( - request: protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsRequest, - protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig + >, + ): void; listMulticloudDataTransferConfigs( - request?: protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsRequest, - protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsRequest, - protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig>): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig[], - protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig[], + protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsRequest, - protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listMulticloudDataTransferConfigs values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1598,210 +2366,244 @@ export class DataTransferServiceClient { this._log.info('listMulticloudDataTransferConfigs request %j', request); return this.innerApiCalls .listMulticloudDataTransferConfigs(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig[], - protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsResponse - ]) => { - this._log.info('listMulticloudDataTransferConfigs values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig[], + protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsResponse, + ]) => { + this._log.info( + 'listMulticloudDataTransferConfigs values %j', + response, + ); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listMulticloudDataTransferConfigs`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent resource. - * @param {number} [request.pageSize] - * Optional. The maximum number of results listed per page. - * @param {string} [request.pageToken] - * Optional. The page token. - * @param {string} [request.filter] - * Optional. An expression that filters the results listed in the response. - * @param {string} [request.orderBy] - * Optional. The sort order of the results. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If `true`, allows partial responses for multi-regional aggregated - * list requests. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig|MulticloudDataTransferConfig} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listMulticloudDataTransferConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listMulticloudDataTransferConfigs`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent resource. + * @param {number} [request.pageSize] + * Optional. The maximum number of results listed per page. + * @param {string} [request.pageToken] + * Optional. The page token. + * @param {string} [request.filter] + * Optional. An expression that filters the results listed in the response. + * @param {string} [request.orderBy] + * Optional. The sort order of the results. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If `true`, allows partial responses for multi-regional aggregated + * list requests. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig|MulticloudDataTransferConfig} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listMulticloudDataTransferConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMulticloudDataTransferConfigsStream( - request?: protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listMulticloudDataTransferConfigs']; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = + this._defaults['listMulticloudDataTransferConfigs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listMulticloudDataTransferConfigs stream %j', request); return this.descriptors.page.listMulticloudDataTransferConfigs.createStream( this.innerApiCalls.listMulticloudDataTransferConfigs as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listMulticloudDataTransferConfigs`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent resource. - * @param {number} [request.pageSize] - * Optional. The maximum number of results listed per page. - * @param {string} [request.pageToken] - * Optional. The page token. - * @param {string} [request.filter] - * Optional. An expression that filters the results listed in the response. - * @param {string} [request.orderBy] - * Optional. The sort order of the results. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If `true`, allows partial responses for multi-regional aggregated - * list requests. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig|MulticloudDataTransferConfig}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/data_transfer_service.list_multicloud_data_transfer_configs.js - * region_tag:networkconnectivity_v1beta_generated_DataTransferService_ListMulticloudDataTransferConfigs_async - */ + /** + * Equivalent to `listMulticloudDataTransferConfigs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent resource. + * @param {number} [request.pageSize] + * Optional. The maximum number of results listed per page. + * @param {string} [request.pageToken] + * Optional. The page token. + * @param {string} [request.filter] + * Optional. An expression that filters the results listed in the response. + * @param {string} [request.orderBy] + * Optional. The sort order of the results. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If `true`, allows partial responses for multi-regional aggregated + * list requests. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig|MulticloudDataTransferConfig}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/data_transfer_service.list_multicloud_data_transfer_configs.js + * region_tag:networkconnectivity_v1beta_generated_DataTransferService_ListMulticloudDataTransferConfigs_async + */ listMulticloudDataTransferConfigsAsync( - request?: protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferConfigsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listMulticloudDataTransferConfigs']; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = + this._defaults['listMulticloudDataTransferConfigs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listMulticloudDataTransferConfigs iterate %j', request); return this.descriptors.page.listMulticloudDataTransferConfigs.asyncIterate( this.innerApiCalls['listMulticloudDataTransferConfigs'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists the `Destination` resources in a specified project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent resource. - * @param {number} [request.pageSize] - * Optional. The maximum number of results listed per page. - * @param {string} [request.pageToken] - * Optional. The page token. - * @param {string} [request.filter] - * Optional. An expression that filters the results listed in the response. - * @param {string} [request.orderBy] - * Optional. The sort order of the results. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If `true`, allow partial responses for multi-regional aggregated - * list requests. - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1beta.Destination|Destination}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listDestinationsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists the `Destination` resources in a specified project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent resource. + * @param {number} [request.pageSize] + * Optional. The maximum number of results listed per page. + * @param {string} [request.pageToken] + * Optional. The page token. + * @param {string} [request.filter] + * Optional. An expression that filters the results listed in the response. + * @param {string} [request.orderBy] + * Optional. The sort order of the results. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If `true`, allow partial responses for multi-regional aggregated + * list requests. + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1beta.Destination|Destination}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listDestinationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listDestinations( - request?: protos.google.cloud.networkconnectivity.v1beta.IListDestinationsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IDestination[], - protos.google.cloud.networkconnectivity.v1beta.IListDestinationsRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListDestinationsResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IListDestinationsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IDestination[], + protos.google.cloud.networkconnectivity.v1beta.IListDestinationsRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListDestinationsResponse, + ] + >; listDestinations( - request: protos.google.cloud.networkconnectivity.v1beta.IListDestinationsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListDestinationsRequest, - protos.google.cloud.networkconnectivity.v1beta.IListDestinationsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IDestination>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IListDestinationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListDestinationsRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListDestinationsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IDestination + >, + ): void; listDestinations( - request: protos.google.cloud.networkconnectivity.v1beta.IListDestinationsRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListDestinationsRequest, - protos.google.cloud.networkconnectivity.v1beta.IListDestinationsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IDestination>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IListDestinationsRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListDestinationsRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListDestinationsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IDestination + >, + ): void; listDestinations( - request?: protos.google.cloud.networkconnectivity.v1beta.IListDestinationsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListDestinationsRequest, - protos.google.cloud.networkconnectivity.v1beta.IListDestinationsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IDestination>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1beta.IListDestinationsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1beta.IListDestinationsRequest, - protos.google.cloud.networkconnectivity.v1beta.IListDestinationsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IDestination>): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IDestination[], - protos.google.cloud.networkconnectivity.v1beta.IListDestinationsRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListDestinationsResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1beta.IListDestinationsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IDestination + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListDestinationsRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListDestinationsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IDestination + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IDestination[], + protos.google.cloud.networkconnectivity.v1beta.IListDestinationsRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListDestinationsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListDestinationsRequest, - protos.google.cloud.networkconnectivity.v1beta.IListDestinationsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IDestination>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListDestinationsRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListDestinationsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IDestination + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listDestinations values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1810,339 +2612,395 @@ export class DataTransferServiceClient { this._log.info('listDestinations request %j', request); return this.innerApiCalls .listDestinations(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1beta.IDestination[], - protos.google.cloud.networkconnectivity.v1beta.IListDestinationsRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListDestinationsResponse - ]) => { - this._log.info('listDestinations values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1beta.IDestination[], + protos.google.cloud.networkconnectivity.v1beta.IListDestinationsRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListDestinationsResponse, + ]) => { + this._log.info('listDestinations values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listDestinations`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent resource. - * @param {number} [request.pageSize] - * Optional. The maximum number of results listed per page. - * @param {string} [request.pageToken] - * Optional. The page token. - * @param {string} [request.filter] - * Optional. An expression that filters the results listed in the response. - * @param {string} [request.orderBy] - * Optional. The sort order of the results. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If `true`, allow partial responses for multi-regional aggregated - * list requests. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1beta.Destination|Destination} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listDestinationsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listDestinations`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent resource. + * @param {number} [request.pageSize] + * Optional. The maximum number of results listed per page. + * @param {string} [request.pageToken] + * Optional. The page token. + * @param {string} [request.filter] + * Optional. An expression that filters the results listed in the response. + * @param {string} [request.orderBy] + * Optional. The sort order of the results. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If `true`, allow partial responses for multi-regional aggregated + * list requests. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1beta.Destination|Destination} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listDestinationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listDestinationsStream( - request?: protos.google.cloud.networkconnectivity.v1beta.IListDestinationsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1beta.IListDestinationsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listDestinations']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listDestinations stream %j', request); return this.descriptors.page.listDestinations.createStream( this.innerApiCalls.listDestinations as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listDestinations`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent resource. - * @param {number} [request.pageSize] - * Optional. The maximum number of results listed per page. - * @param {string} [request.pageToken] - * Optional. The page token. - * @param {string} [request.filter] - * Optional. An expression that filters the results listed in the response. - * @param {string} [request.orderBy] - * Optional. The sort order of the results. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If `true`, allow partial responses for multi-regional aggregated - * list requests. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1beta.Destination|Destination}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/data_transfer_service.list_destinations.js - * region_tag:networkconnectivity_v1beta_generated_DataTransferService_ListDestinations_async - */ + /** + * Equivalent to `listDestinations`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent resource. + * @param {number} [request.pageSize] + * Optional. The maximum number of results listed per page. + * @param {string} [request.pageToken] + * Optional. The page token. + * @param {string} [request.filter] + * Optional. An expression that filters the results listed in the response. + * @param {string} [request.orderBy] + * Optional. The sort order of the results. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If `true`, allow partial responses for multi-regional aggregated + * list requests. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1beta.Destination|Destination}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/data_transfer_service.list_destinations.js + * region_tag:networkconnectivity_v1beta_generated_DataTransferService_ListDestinations_async + */ listDestinationsAsync( - request?: protos.google.cloud.networkconnectivity.v1beta.IListDestinationsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1beta.IListDestinationsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listDestinations']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listDestinations iterate %j', request); return this.descriptors.page.listDestinations.asyncIterate( this.innerApiCalls['listDestinations'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists the services in the project for a region that are supported for - * Data Transfer Essentials. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent resource. - * @param {number} [request.pageSize] - * Optional. The maximum number of results listed per page. - * @param {string} [request.pageToken] - * Optional. The page token. - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService|MulticloudDataTransferSupportedService}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listMulticloudDataTransferSupportedServicesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists the services in the project for a region that are supported for + * Data Transfer Essentials. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent resource. + * @param {number} [request.pageSize] + * Optional. The maximum number of results listed per page. + * @param {string} [request.pageToken] + * Optional. The page token. + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService|MulticloudDataTransferSupportedService}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listMulticloudDataTransferSupportedServicesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMulticloudDataTransferSupportedServices( - request?: protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService[], - protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService[], + protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesResponse, + ] + >; listMulticloudDataTransferSupportedServices( - request: protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService + >, + ): void; listMulticloudDataTransferSupportedServices( - request: protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService + >, + ): void; listMulticloudDataTransferSupportedServices( - request?: protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService>): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService[], - protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService[], + protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { - this._log.info('listMulticloudDataTransferSupportedServices values %j', values); + this._log.info( + 'listMulticloudDataTransferSupportedServices values %j', + values, + ); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. } : undefined; - this._log.info('listMulticloudDataTransferSupportedServices request %j', request); + this._log.info( + 'listMulticloudDataTransferSupportedServices request %j', + request, + ); return this.innerApiCalls - .listMulticloudDataTransferSupportedServices(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService[], - protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesResponse - ]) => { - this._log.info('listMulticloudDataTransferSupportedServices values %j', response); - return [response, input, output]; - }); + .listMulticloudDataTransferSupportedServices( + request, + options, + wrappedCallback, + ) + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService[], + protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesResponse, + ]) => { + this._log.info( + 'listMulticloudDataTransferSupportedServices values %j', + response, + ); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listMulticloudDataTransferSupportedServices`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent resource. - * @param {number} [request.pageSize] - * Optional. The maximum number of results listed per page. - * @param {string} [request.pageToken] - * Optional. The page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService|MulticloudDataTransferSupportedService} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listMulticloudDataTransferSupportedServicesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listMulticloudDataTransferSupportedServices`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent resource. + * @param {number} [request.pageSize] + * Optional. The maximum number of results listed per page. + * @param {string} [request.pageToken] + * Optional. The page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService|MulticloudDataTransferSupportedService} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listMulticloudDataTransferSupportedServicesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMulticloudDataTransferSupportedServicesStream( - request?: protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listMulticloudDataTransferSupportedServices']; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = + this._defaults['listMulticloudDataTransferSupportedServices']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); - this._log.info('listMulticloudDataTransferSupportedServices stream %j', request); + this.initialize().catch((err) => { + throw err; + }); + this._log.info( + 'listMulticloudDataTransferSupportedServices stream %j', + request, + ); return this.descriptors.page.listMulticloudDataTransferSupportedServices.createStream( this.innerApiCalls.listMulticloudDataTransferSupportedServices as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listMulticloudDataTransferSupportedServices`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent resource. - * @param {number} [request.pageSize] - * Optional. The maximum number of results listed per page. - * @param {string} [request.pageToken] - * Optional. The page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService|MulticloudDataTransferSupportedService}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/data_transfer_service.list_multicloud_data_transfer_supported_services.js - * region_tag:networkconnectivity_v1beta_generated_DataTransferService_ListMulticloudDataTransferSupportedServices_async - */ + /** + * Equivalent to `listMulticloudDataTransferSupportedServices`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent resource. + * @param {number} [request.pageSize] + * Optional. The maximum number of results listed per page. + * @param {string} [request.pageToken] + * Optional. The page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService|MulticloudDataTransferSupportedService}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/data_transfer_service.list_multicloud_data_transfer_supported_services.js + * region_tag:networkconnectivity_v1beta_generated_DataTransferService_ListMulticloudDataTransferSupportedServices_async + */ listMulticloudDataTransferSupportedServicesAsync( - request?: protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1beta.IListMulticloudDataTransferSupportedServicesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listMulticloudDataTransferSupportedServices']; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = + this._defaults['listMulticloudDataTransferSupportedServices']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); - this._log.info('listMulticloudDataTransferSupportedServices iterate %j', request); + this.initialize().catch((err) => { + throw err; + }); + this._log.info( + 'listMulticloudDataTransferSupportedServices iterate %j', + request, + ); return this.descriptors.page.listMulticloudDataTransferSupportedServices.asyncIterate( - this.innerApiCalls['listMulticloudDataTransferSupportedServices'] as GaxCall, + this.innerApiCalls[ + 'listMulticloudDataTransferSupportedServices' + ] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -2156,40 +3014,40 @@ export class DataTransferServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -2203,41 +3061,41 @@ export class DataTransferServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -2251,12 +3109,12 @@ export class DataTransferServiceClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -2291,12 +3149,11 @@ export class DataTransferServiceClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -2329,12 +3186,12 @@ export class DataTransferServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -2377,22 +3234,22 @@ export class DataTransferServiceClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -2427,15 +3284,15 @@ export class DataTransferServiceClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - 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 ?? '', - }); + 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 ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -2469,7 +3326,7 @@ export class DataTransferServiceClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -2482,25 +3339,24 @@ export class DataTransferServiceClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -2539,22 +3395,22 @@ export class DataTransferServiceClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -2571,7 +3427,12 @@ export class DataTransferServiceClient { * @param {string} destination * @returns {string} Resource name string. */ - destinationPath(project:string,location:string,multicloudDataTransferConfig:string,destination:string) { + destinationPath( + project: string, + location: string, + multicloudDataTransferConfig: string, + destination: string, + ) { return this.pathTemplates.destinationPathTemplate.render({ project: project, location: location, @@ -2588,7 +3449,8 @@ export class DataTransferServiceClient { * @returns {string} A string representing the project. */ matchProjectFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).project; + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .project; } /** @@ -2599,7 +3461,8 @@ export class DataTransferServiceClient { * @returns {string} A string representing the location. */ matchLocationFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).location; + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .location; } /** @@ -2609,8 +3472,11 @@ export class DataTransferServiceClient { * A fully-qualified path representing Destination resource. * @returns {string} A string representing the multicloud_data_transfer_config. */ - matchMulticloudDataTransferConfigFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).multicloud_data_transfer_config; + matchMulticloudDataTransferConfigFromDestinationName( + destinationName: string, + ) { + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .multicloud_data_transfer_config; } /** @@ -2621,7 +3487,8 @@ export class DataTransferServiceClient { * @returns {string} A string representing the destination. */ matchDestinationFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).destination; + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .destination; } /** @@ -2633,7 +3500,12 @@ export class DataTransferServiceClient { * @param {string} gateway_advertised_route * @returns {string} Resource name string. */ - gatewayAdvertisedRoutePath(project:string,location:string,spoke:string,gatewayAdvertisedRoute:string) { + gatewayAdvertisedRoutePath( + project: string, + location: string, + spoke: string, + gatewayAdvertisedRoute: string, + ) { return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.render({ project: project, location: location, @@ -2649,8 +3521,12 @@ export class DataTransferServiceClient { * A fully-qualified path representing GatewayAdvertisedRoute resource. * @returns {string} A string representing the project. */ - matchProjectFromGatewayAdvertisedRouteName(gatewayAdvertisedRouteName: string) { - return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match(gatewayAdvertisedRouteName).project; + matchProjectFromGatewayAdvertisedRouteName( + gatewayAdvertisedRouteName: string, + ) { + return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match( + gatewayAdvertisedRouteName, + ).project; } /** @@ -2660,8 +3536,12 @@ export class DataTransferServiceClient { * A fully-qualified path representing GatewayAdvertisedRoute resource. * @returns {string} A string representing the location. */ - matchLocationFromGatewayAdvertisedRouteName(gatewayAdvertisedRouteName: string) { - return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match(gatewayAdvertisedRouteName).location; + matchLocationFromGatewayAdvertisedRouteName( + gatewayAdvertisedRouteName: string, + ) { + return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match( + gatewayAdvertisedRouteName, + ).location; } /** @@ -2672,7 +3552,9 @@ export class DataTransferServiceClient { * @returns {string} A string representing the spoke. */ matchSpokeFromGatewayAdvertisedRouteName(gatewayAdvertisedRouteName: string) { - return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match(gatewayAdvertisedRouteName).spoke; + return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match( + gatewayAdvertisedRouteName, + ).spoke; } /** @@ -2682,8 +3564,12 @@ export class DataTransferServiceClient { * A fully-qualified path representing GatewayAdvertisedRoute resource. * @returns {string} A string representing the gateway_advertised_route. */ - matchGatewayAdvertisedRouteFromGatewayAdvertisedRouteName(gatewayAdvertisedRouteName: string) { - return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match(gatewayAdvertisedRouteName).gateway_advertised_route; + matchGatewayAdvertisedRouteFromGatewayAdvertisedRouteName( + gatewayAdvertisedRouteName: string, + ) { + return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match( + gatewayAdvertisedRouteName, + ).gateway_advertised_route; } /** @@ -2694,7 +3580,7 @@ export class DataTransferServiceClient { * @param {string} group * @returns {string} Resource name string. */ - groupPath(project:string,hub:string,group:string) { + groupPath(project: string, hub: string, group: string) { return this.pathTemplates.groupPathTemplate.render({ project: project, hub: hub, @@ -2742,7 +3628,7 @@ export class DataTransferServiceClient { * @param {string} hub * @returns {string} Resource name string. */ - hubPath(project:string,hub:string) { + hubPath(project: string, hub: string) { return this.pathTemplates.hubPathTemplate.render({ project: project, hub: hub, @@ -2780,7 +3666,12 @@ export class DataTransferServiceClient { * @param {string} route * @returns {string} Resource name string. */ - hubRoutePath(project:string,hub:string,routeTable:string,route:string) { + hubRoutePath( + project: string, + hub: string, + routeTable: string, + route: string, + ) { return this.pathTemplates.hubRoutePathTemplate.render({ project: project, hub: hub, @@ -2819,7 +3710,8 @@ export class DataTransferServiceClient { * @returns {string} A string representing the route_table. */ matchRouteTableFromHubRouteName(hubRouteName: string) { - return this.pathTemplates.hubRoutePathTemplate.match(hubRouteName).route_table; + return this.pathTemplates.hubRoutePathTemplate.match(hubRouteName) + .route_table; } /** @@ -2840,7 +3732,7 @@ export class DataTransferServiceClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -2877,7 +3769,11 @@ export class DataTransferServiceClient { * @param {string} multicloud_data_transfer_config * @returns {string} Resource name string. */ - multicloudDataTransferConfigPath(project:string,location:string,multicloudDataTransferConfig:string) { + multicloudDataTransferConfigPath( + project: string, + location: string, + multicloudDataTransferConfig: string, + ) { return this.pathTemplates.multicloudDataTransferConfigPathTemplate.render({ project: project, location: location, @@ -2892,8 +3788,12 @@ export class DataTransferServiceClient { * A fully-qualified path representing MulticloudDataTransferConfig resource. * @returns {string} A string representing the project. */ - matchProjectFromMulticloudDataTransferConfigName(multicloudDataTransferConfigName: string) { - return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match(multicloudDataTransferConfigName).project; + matchProjectFromMulticloudDataTransferConfigName( + multicloudDataTransferConfigName: string, + ) { + return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match( + multicloudDataTransferConfigName, + ).project; } /** @@ -2903,8 +3803,12 @@ export class DataTransferServiceClient { * A fully-qualified path representing MulticloudDataTransferConfig resource. * @returns {string} A string representing the location. */ - matchLocationFromMulticloudDataTransferConfigName(multicloudDataTransferConfigName: string) { - return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match(multicloudDataTransferConfigName).location; + matchLocationFromMulticloudDataTransferConfigName( + multicloudDataTransferConfigName: string, + ) { + return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match( + multicloudDataTransferConfigName, + ).location; } /** @@ -2914,8 +3818,12 @@ export class DataTransferServiceClient { * A fully-qualified path representing MulticloudDataTransferConfig resource. * @returns {string} A string representing the multicloud_data_transfer_config. */ - matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName(multicloudDataTransferConfigName: string) { - return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match(multicloudDataTransferConfigName).multicloud_data_transfer_config; + matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName( + multicloudDataTransferConfigName: string, + ) { + return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match( + multicloudDataTransferConfigName, + ).multicloud_data_transfer_config; } /** @@ -2926,12 +3834,19 @@ export class DataTransferServiceClient { * @param {string} multicloud_data_transfer_supported_service * @returns {string} Resource name string. */ - multicloudDataTransferSupportedServicePath(project:string,location:string,multicloudDataTransferSupportedService:string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render({ - project: project, - location: location, - multicloud_data_transfer_supported_service: multicloudDataTransferSupportedService, - }); + multicloudDataTransferSupportedServicePath( + project: string, + location: string, + multicloudDataTransferSupportedService: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render( + { + project: project, + location: location, + multicloud_data_transfer_supported_service: + multicloudDataTransferSupportedService, + }, + ); } /** @@ -2941,8 +3856,12 @@ export class DataTransferServiceClient { * A fully-qualified path representing MulticloudDataTransferSupportedService resource. * @returns {string} A string representing the project. */ - matchProjectFromMulticloudDataTransferSupportedServiceName(multicloudDataTransferSupportedServiceName: string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match(multicloudDataTransferSupportedServiceName).project; + matchProjectFromMulticloudDataTransferSupportedServiceName( + multicloudDataTransferSupportedServiceName: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match( + multicloudDataTransferSupportedServiceName, + ).project; } /** @@ -2952,8 +3871,12 @@ export class DataTransferServiceClient { * A fully-qualified path representing MulticloudDataTransferSupportedService resource. * @returns {string} A string representing the location. */ - matchLocationFromMulticloudDataTransferSupportedServiceName(multicloudDataTransferSupportedServiceName: string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match(multicloudDataTransferSupportedServiceName).location; + matchLocationFromMulticloudDataTransferSupportedServiceName( + multicloudDataTransferSupportedServiceName: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match( + multicloudDataTransferSupportedServiceName, + ).location; } /** @@ -2963,8 +3886,12 @@ export class DataTransferServiceClient { * A fully-qualified path representing MulticloudDataTransferSupportedService resource. * @returns {string} A string representing the multicloud_data_transfer_supported_service. */ - matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName(multicloudDataTransferSupportedServiceName: string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match(multicloudDataTransferSupportedServiceName).multicloud_data_transfer_supported_service; + matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName( + multicloudDataTransferSupportedServiceName: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match( + multicloudDataTransferSupportedServiceName, + ).multicloud_data_transfer_supported_service; } /** @@ -2974,7 +3901,7 @@ export class DataTransferServiceClient { * @param {string} policy_based_route * @returns {string} Resource name string. */ - policyBasedRoutePath(project:string,policyBasedRoute:string) { + policyBasedRoutePath(project: string, policyBasedRoute: string) { return this.pathTemplates.policyBasedRoutePathTemplate.render({ project: project, policy_based_route: policyBasedRoute, @@ -2989,7 +3916,9 @@ export class DataTransferServiceClient { * @returns {string} A string representing the project. */ matchProjectFromPolicyBasedRouteName(policyBasedRouteName: string) { - return this.pathTemplates.policyBasedRoutePathTemplate.match(policyBasedRouteName).project; + return this.pathTemplates.policyBasedRoutePathTemplate.match( + policyBasedRouteName, + ).project; } /** @@ -3000,7 +3929,9 @@ export class DataTransferServiceClient { * @returns {string} A string representing the policy_based_route. */ matchPolicyBasedRouteFromPolicyBasedRouteName(policyBasedRouteName: string) { - return this.pathTemplates.policyBasedRoutePathTemplate.match(policyBasedRouteName).policy_based_route; + return this.pathTemplates.policyBasedRoutePathTemplate.match( + policyBasedRouteName, + ).policy_based_route; } /** @@ -3011,7 +3942,11 @@ export class DataTransferServiceClient { * @param {string} remote_transport_profile * @returns {string} Resource name string. */ - remoteTransportProfilePath(project:string,location:string,remoteTransportProfile:string) { + remoteTransportProfilePath( + project: string, + location: string, + remoteTransportProfile: string, + ) { return this.pathTemplates.remoteTransportProfilePathTemplate.render({ project: project, location: location, @@ -3026,8 +3961,12 @@ export class DataTransferServiceClient { * A fully-qualified path representing RemoteTransportProfile resource. * @returns {string} A string representing the project. */ - matchProjectFromRemoteTransportProfileName(remoteTransportProfileName: string) { - return this.pathTemplates.remoteTransportProfilePathTemplate.match(remoteTransportProfileName).project; + matchProjectFromRemoteTransportProfileName( + remoteTransportProfileName: string, + ) { + return this.pathTemplates.remoteTransportProfilePathTemplate.match( + remoteTransportProfileName, + ).project; } /** @@ -3037,8 +3976,12 @@ export class DataTransferServiceClient { * A fully-qualified path representing RemoteTransportProfile resource. * @returns {string} A string representing the location. */ - matchLocationFromRemoteTransportProfileName(remoteTransportProfileName: string) { - return this.pathTemplates.remoteTransportProfilePathTemplate.match(remoteTransportProfileName).location; + matchLocationFromRemoteTransportProfileName( + remoteTransportProfileName: string, + ) { + return this.pathTemplates.remoteTransportProfilePathTemplate.match( + remoteTransportProfileName, + ).location; } /** @@ -3048,8 +3991,12 @@ export class DataTransferServiceClient { * A fully-qualified path representing RemoteTransportProfile resource. * @returns {string} A string representing the remote_transport_profile. */ - matchRemoteTransportProfileFromRemoteTransportProfileName(remoteTransportProfileName: string) { - return this.pathTemplates.remoteTransportProfilePathTemplate.match(remoteTransportProfileName).remote_transport_profile; + matchRemoteTransportProfileFromRemoteTransportProfileName( + remoteTransportProfileName: string, + ) { + return this.pathTemplates.remoteTransportProfilePathTemplate.match( + remoteTransportProfileName, + ).remote_transport_profile; } /** @@ -3060,7 +4007,7 @@ export class DataTransferServiceClient { * @param {string} route_table * @returns {string} Resource name string. */ - routeTablePath(project:string,hub:string,routeTable:string) { + routeTablePath(project: string, hub: string, routeTable: string) { return this.pathTemplates.routeTablePathTemplate.render({ project: project, hub: hub, @@ -3076,7 +4023,8 @@ export class DataTransferServiceClient { * @returns {string} A string representing the project. */ matchProjectFromRouteTableName(routeTableName: string) { - return this.pathTemplates.routeTablePathTemplate.match(routeTableName).project; + return this.pathTemplates.routeTablePathTemplate.match(routeTableName) + .project; } /** @@ -3098,7 +4046,8 @@ export class DataTransferServiceClient { * @returns {string} A string representing the route_table. */ matchRouteTableFromRouteTableName(routeTableName: string) { - return this.pathTemplates.routeTablePathTemplate.match(routeTableName).route_table; + return this.pathTemplates.routeTablePathTemplate.match(routeTableName) + .route_table; } /** @@ -3109,7 +4058,7 @@ export class DataTransferServiceClient { * @param {string} spoke * @returns {string} Resource name string. */ - spokePath(project:string,location:string,spoke:string) { + spokePath(project: string, location: string, spoke: string) { return this.pathTemplates.spokePathTemplate.render({ project: project, location: location, @@ -3158,7 +4107,7 @@ export class DataTransferServiceClient { * @param {string} transport * @returns {string} Resource name string. */ - transportPath(project:string,location:string,transport:string) { + transportPath(project: string, location: string, transport: string) { return this.pathTemplates.transportPathTemplate.render({ project: project, location: location, @@ -3174,7 +4123,8 @@ export class DataTransferServiceClient { * @returns {string} A string representing the project. */ matchProjectFromTransportName(transportName: string) { - return this.pathTemplates.transportPathTemplate.match(transportName).project; + return this.pathTemplates.transportPathTemplate.match(transportName) + .project; } /** @@ -3185,7 +4135,8 @@ export class DataTransferServiceClient { * @returns {string} A string representing the location. */ matchLocationFromTransportName(transportName: string) { - return this.pathTemplates.transportPathTemplate.match(transportName).location; + return this.pathTemplates.transportPathTemplate.match(transportName) + .location; } /** @@ -3196,7 +4147,8 @@ export class DataTransferServiceClient { * @returns {string} A string representing the transport. */ matchTransportFromTransportName(transportName: string) { - return this.pathTemplates.transportPathTemplate.match(transportName).transport; + return this.pathTemplates.transportPathTemplate.match(transportName) + .transport; } /** @@ -3207,15 +4159,19 @@ export class DataTransferServiceClient { */ close(): Promise { if (this.dataTransferServiceStub && !this._terminated) { - return this.dataTransferServiceStub.then(stub => { + return this.dataTransferServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-networkconnectivity/src/v1beta/hub_service_client.ts b/packages/google-cloud-networkconnectivity/src/v1beta/hub_service_client.ts index 7f61462eed08..430b30f3ef13 100644 --- a/packages/google-cloud-networkconnectivity/src/v1beta/hub_service_client.ts +++ b/packages/google-cloud-networkconnectivity/src/v1beta/hub_service_client.ts @@ -18,11 +18,24 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -46,7 +59,7 @@ export class HubServiceClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('networkconnectivity'); @@ -59,12 +72,12 @@ export class HubServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - hubServiceStub?: Promise<{[name: string]: Function}>; + hubServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of HubServiceClient. @@ -105,21 +118,42 @@ export class HubServiceClient { * const client = new HubServiceClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof HubServiceClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'networkconnectivity.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -144,7 +178,7 @@ export class HubServiceClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -157,18 +191,14 @@ export class HubServiceClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -190,58 +220,60 @@ export class HubServiceClient { // Create useful helper objects for these. this.pathTemplates = { destinationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}/destinations/{destination}' + 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}/destinations/{destination}', ), gatewayAdvertisedRoutePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/spokes/{spoke}/gatewayAdvertisedRoutes/{gateway_advertised_route}' + 'projects/{project}/locations/{location}/spokes/{spoke}/gatewayAdvertisedRoutes/{gateway_advertised_route}', ), groupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}/groups/{group}' + 'projects/{project}/locations/global/hubs/{hub}/groups/{group}', ), hubPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}' + 'projects/{project}/locations/global/hubs/{hub}', ), hubRoutePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}/routes/{route}' + 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}/routes/{route}', ), instancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/zones/{zone}/instances/{instance}' + 'projects/{project}/zones/{zone}/instances/{instance}', ), interconnectAttachmentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/regions/{region}/interconnectAttachments/{resource_id}' + 'projects/{project}/regions/{region}/interconnectAttachments/{resource_id}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - multicloudDataTransferConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}' - ), - multicloudDataTransferSupportedServicePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/multicloudDataTransferSupportedServices/{multicloud_data_transfer_supported_service}' + 'projects/{project}/locations/{location}', ), + multicloudDataTransferConfigPathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}', + ), + multicloudDataTransferSupportedServicePathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/multicloudDataTransferSupportedServices/{multicloud_data_transfer_supported_service}', + ), networkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/global/networks/{resource_id}' + 'projects/{project}/global/networks/{resource_id}', ), policyBasedRoutePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/PolicyBasedRoutes/{policy_based_route}' + 'projects/{project}/locations/global/PolicyBasedRoutes/{policy_based_route}', ), remoteTransportProfilePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/remoteTransportProfiles/{remote_transport_profile}' + 'projects/{project}/locations/{location}/remoteTransportProfiles/{remote_transport_profile}', ), routeTablePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}' + 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}', ), sACAttachmentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/sacAttachments/{sac_attachment}' + 'projects/{project}/locations/{location}/sacAttachments/{sac_attachment}', ), spokePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/spokes/{spoke}' + 'projects/{project}/locations/{location}/spokes/{spoke}', ), transportPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/transports/{transport}' + 'projects/{project}/locations/{location}/transports/{transport}', ), vpnTunnelPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/regions/{region}/vpnTunnels/{resource_id}' + 'projects/{project}/regions/{region}/vpnTunnels/{resource_id}', ), }; @@ -249,22 +281,46 @@ export class HubServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listHubs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'hubs'), - listHubSpokes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'spokes'), - queryHubStatus: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'hubStatusEntries'), - listSpokes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'spokes'), - listRoutes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'routes'), - listRouteTables: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'routeTables'), - listGroups: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'groups'), - listGatewayAdvertisedRoutes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'gatewayAdvertisedRoutes') + listHubs: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'hubs', + ), + listHubSpokes: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'spokes', + ), + queryHubStatus: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'hubStatusEntries', + ), + listSpokes: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'spokes', + ), + listRoutes: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'routes', + ), + listRouteTables: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'routeTables', + ), + listGroups: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'groups', + ), + listGatewayAdvertisedRoutes: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'gatewayAdvertisedRoutes', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -273,136 +329,271 @@ export class HubServiceClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1beta/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1beta/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1beta/{resource=projects/*/locations/global/hubs/*}:getIamPolicy',additional_bindings: [{get: '/v1beta/{resource=projects/*/locations/global/hubs/*/groups/*}:getIamPolicy',},{get: '/v1beta/{resource=projects/*/locations/*/spokes/*}:getIamPolicy',},{get: '/v1beta/{resource=projects/*/locations/global/policyBasedRoutes/*}:getIamPolicy',}], - },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1beta/{resource=projects/*/locations/global/hubs/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1beta/{resource=projects/*/locations/global/hubs/*/groups/*}:setIamPolicy',body: '*',},{post: '/v1beta/{resource=projects/*/locations/*/spokes/*}:setIamPolicy',body: '*',},{post: '/v1beta/{resource=projects/*/locations/global/policyBasedRoutes/*}:setIamPolicy',body: '*',}], - },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1beta/{resource=projects/*/locations/global/hubs/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1beta/{resource=projects/*/locations/global/hubs/*/groups/*}:testIamPermissions',body: '*',},{post: '/v1beta/{resource=projects/*/locations/*/spokes/*}:testIamPermissions',body: '*',},{post: '/v1beta/{resource=projects/*/locations/global/policyBasedRoutes/*}:testIamPermissions',body: '*',}], - },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1beta/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1beta/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1beta/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1beta/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1beta/{resource=projects/*/locations/global/hubs/*}:getIamPolicy', + additional_bindings: [ + { + get: '/v1beta/{resource=projects/*/locations/global/hubs/*/groups/*}:getIamPolicy', + }, + { + get: '/v1beta/{resource=projects/*/locations/*/spokes/*}:getIamPolicy', + }, + { + get: '/v1beta/{resource=projects/*/locations/global/policyBasedRoutes/*}:getIamPolicy', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1beta/{resource=projects/*/locations/global/hubs/*}:setIamPolicy', + body: '*', + additional_bindings: [ + { + post: '/v1beta/{resource=projects/*/locations/global/hubs/*/groups/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1beta/{resource=projects/*/locations/*/spokes/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1beta/{resource=projects/*/locations/global/policyBasedRoutes/*}:setIamPolicy', + body: '*', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1beta/{resource=projects/*/locations/global/hubs/*}:testIamPermissions', + body: '*', + additional_bindings: [ + { + post: '/v1beta/{resource=projects/*/locations/global/hubs/*/groups/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1beta/{resource=projects/*/locations/*/spokes/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1beta/{resource=projects/*/locations/global/policyBasedRoutes/*}:testIamPermissions', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1beta/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1beta/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1beta/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1beta/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createHubResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.Hub') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.Hub', + ) as gax.protobuf.Type; const createHubMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const updateHubResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.Hub') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.Hub', + ) as gax.protobuf.Type; const updateHubMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const deleteHubResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteHubMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const createSpokeResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.Spoke') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.Spoke', + ) as gax.protobuf.Type; const createSpokeMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const updateSpokeResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.Spoke') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.Spoke', + ) as gax.protobuf.Type; const updateSpokeMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const rejectHubSpokeResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.RejectHubSpokeResponse') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.RejectHubSpokeResponse', + ) as gax.protobuf.Type; const rejectHubSpokeMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const acceptHubSpokeResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.AcceptHubSpokeResponse') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.AcceptHubSpokeResponse', + ) as gax.protobuf.Type; const acceptHubSpokeMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const acceptSpokeUpdateResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.AcceptSpokeUpdateResponse') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.AcceptSpokeUpdateResponse', + ) as gax.protobuf.Type; const acceptSpokeUpdateMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const rejectSpokeUpdateResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.RejectSpokeUpdateResponse') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.RejectSpokeUpdateResponse', + ) as gax.protobuf.Type; const rejectSpokeUpdateMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const deleteSpokeResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteSpokeMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const updateGroupResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.Group') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.Group', + ) as gax.protobuf.Type; const updateGroupMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const createGatewayAdvertisedRouteResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute', + ) as gax.protobuf.Type; const createGatewayAdvertisedRouteMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const updateGatewayAdvertisedRouteResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute', + ) as gax.protobuf.Type; const updateGatewayAdvertisedRouteMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const deleteGatewayAdvertisedRouteResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteGatewayAdvertisedRouteMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createHub: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createHubResponse.decode.bind(createHubResponse), - createHubMetadata.decode.bind(createHubMetadata)), + createHubMetadata.decode.bind(createHubMetadata), + ), updateHub: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateHubResponse.decode.bind(updateHubResponse), - updateHubMetadata.decode.bind(updateHubMetadata)), + updateHubMetadata.decode.bind(updateHubMetadata), + ), deleteHub: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteHubResponse.decode.bind(deleteHubResponse), - deleteHubMetadata.decode.bind(deleteHubMetadata)), + deleteHubMetadata.decode.bind(deleteHubMetadata), + ), createSpoke: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createSpokeResponse.decode.bind(createSpokeResponse), - createSpokeMetadata.decode.bind(createSpokeMetadata)), + createSpokeMetadata.decode.bind(createSpokeMetadata), + ), updateSpoke: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateSpokeResponse.decode.bind(updateSpokeResponse), - updateSpokeMetadata.decode.bind(updateSpokeMetadata)), + updateSpokeMetadata.decode.bind(updateSpokeMetadata), + ), rejectHubSpoke: new this._gaxModule.LongrunningDescriptor( this.operationsClient, rejectHubSpokeResponse.decode.bind(rejectHubSpokeResponse), - rejectHubSpokeMetadata.decode.bind(rejectHubSpokeMetadata)), + rejectHubSpokeMetadata.decode.bind(rejectHubSpokeMetadata), + ), acceptHubSpoke: new this._gaxModule.LongrunningDescriptor( this.operationsClient, acceptHubSpokeResponse.decode.bind(acceptHubSpokeResponse), - acceptHubSpokeMetadata.decode.bind(acceptHubSpokeMetadata)), + acceptHubSpokeMetadata.decode.bind(acceptHubSpokeMetadata), + ), acceptSpokeUpdate: new this._gaxModule.LongrunningDescriptor( this.operationsClient, acceptSpokeUpdateResponse.decode.bind(acceptSpokeUpdateResponse), - acceptSpokeUpdateMetadata.decode.bind(acceptSpokeUpdateMetadata)), + acceptSpokeUpdateMetadata.decode.bind(acceptSpokeUpdateMetadata), + ), rejectSpokeUpdate: new this._gaxModule.LongrunningDescriptor( this.operationsClient, rejectSpokeUpdateResponse.decode.bind(rejectSpokeUpdateResponse), - rejectSpokeUpdateMetadata.decode.bind(rejectSpokeUpdateMetadata)), + rejectSpokeUpdateMetadata.decode.bind(rejectSpokeUpdateMetadata), + ), deleteSpoke: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteSpokeResponse.decode.bind(deleteSpokeResponse), - deleteSpokeMetadata.decode.bind(deleteSpokeMetadata)), + deleteSpokeMetadata.decode.bind(deleteSpokeMetadata), + ), updateGroup: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateGroupResponse.decode.bind(updateGroupResponse), - updateGroupMetadata.decode.bind(updateGroupMetadata)), + updateGroupMetadata.decode.bind(updateGroupMetadata), + ), createGatewayAdvertisedRoute: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - createGatewayAdvertisedRouteResponse.decode.bind(createGatewayAdvertisedRouteResponse), - createGatewayAdvertisedRouteMetadata.decode.bind(createGatewayAdvertisedRouteMetadata)), + createGatewayAdvertisedRouteResponse.decode.bind( + createGatewayAdvertisedRouteResponse, + ), + createGatewayAdvertisedRouteMetadata.decode.bind( + createGatewayAdvertisedRouteMetadata, + ), + ), updateGatewayAdvertisedRoute: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - updateGatewayAdvertisedRouteResponse.decode.bind(updateGatewayAdvertisedRouteResponse), - updateGatewayAdvertisedRouteMetadata.decode.bind(updateGatewayAdvertisedRouteMetadata)), + updateGatewayAdvertisedRouteResponse.decode.bind( + updateGatewayAdvertisedRouteResponse, + ), + updateGatewayAdvertisedRouteMetadata.decode.bind( + updateGatewayAdvertisedRouteMetadata, + ), + ), deleteGatewayAdvertisedRoute: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - deleteGatewayAdvertisedRouteResponse.decode.bind(deleteGatewayAdvertisedRouteResponse), - deleteGatewayAdvertisedRouteMetadata.decode.bind(deleteGatewayAdvertisedRouteMetadata)) + deleteGatewayAdvertisedRouteResponse.decode.bind( + deleteGatewayAdvertisedRouteResponse, + ), + deleteGatewayAdvertisedRouteMetadata.decode.bind( + deleteGatewayAdvertisedRouteMetadata, + ), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.networkconnectivity.v1beta.HubService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.networkconnectivity.v1beta.HubService', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -433,28 +624,63 @@ export class HubServiceClient { // Put together the "service stub" for // google.cloud.networkconnectivity.v1beta.HubService. this.hubServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.networkconnectivity.v1beta.HubService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.networkconnectivity.v1beta.HubService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.networkconnectivity.v1beta.HubService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.networkconnectivity.v1beta + .HubService, + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const hubServiceStubMethods = - ['listHubs', 'getHub', 'createHub', 'updateHub', 'deleteHub', 'listHubSpokes', 'queryHubStatus', 'listSpokes', 'getSpoke', 'createSpoke', 'updateSpoke', 'rejectHubSpoke', 'acceptHubSpoke', 'acceptSpokeUpdate', 'rejectSpokeUpdate', 'deleteSpoke', 'getRouteTable', 'getRoute', 'listRoutes', 'listRouteTables', 'getGroup', 'listGroups', 'updateGroup', 'createGatewayAdvertisedRoute', 'getGatewayAdvertisedRoute', 'listGatewayAdvertisedRoutes', 'updateGatewayAdvertisedRoute', 'deleteGatewayAdvertisedRoute']; + const hubServiceStubMethods = [ + 'listHubs', + 'getHub', + 'createHub', + 'updateHub', + 'deleteHub', + 'listHubSpokes', + 'queryHubStatus', + 'listSpokes', + 'getSpoke', + 'createSpoke', + 'updateSpoke', + 'rejectHubSpoke', + 'acceptHubSpoke', + 'acceptSpokeUpdate', + 'rejectSpokeUpdate', + 'deleteSpoke', + 'getRouteTable', + 'getRoute', + 'listRoutes', + 'listRouteTables', + 'getGroup', + 'listGroups', + 'updateGroup', + 'createGatewayAdvertisedRoute', + 'getGatewayAdvertisedRoute', + 'listGatewayAdvertisedRoutes', + 'updateGatewayAdvertisedRoute', + 'deleteGatewayAdvertisedRoute', + ]; for (const methodName of hubServiceStubMethods) { const callPromise = this.hubServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -464,7 +690,7 @@ export class HubServiceClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -479,8 +705,14 @@ export class HubServiceClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkconnectivity.googleapis.com'; } @@ -491,8 +723,14 @@ export class HubServiceClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkconnectivity.googleapis.com'; } @@ -523,9 +761,7 @@ export class HubServiceClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -534,8 +770,9 @@ export class HubServiceClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -546,2425 +783,3625 @@ export class HubServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets details about a Network Connectivity Center hub. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the hub resource to get. - * @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 {@link protos.google.cloud.networkconnectivity.v1beta.Hub|Hub}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/hub_service.get_hub.js - * region_tag:networkconnectivity_v1beta_generated_HubService_GetHub_async - */ + /** + * Gets details about a Network Connectivity Center hub. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the hub resource to get. + * @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 {@link protos.google.cloud.networkconnectivity.v1beta.Hub|Hub}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/hub_service.get_hub.js + * region_tag:networkconnectivity_v1beta_generated_HubService_GetHub_async + */ getHub( - request?: protos.google.cloud.networkconnectivity.v1beta.IGetHubRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IHub, - protos.google.cloud.networkconnectivity.v1beta.IGetHubRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IGetHubRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IHub, + protos.google.cloud.networkconnectivity.v1beta.IGetHubRequest | undefined, + {} | undefined, + ] + >; getHub( - request: protos.google.cloud.networkconnectivity.v1beta.IGetHubRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IHub, - protos.google.cloud.networkconnectivity.v1beta.IGetHubRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IGetHubRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkconnectivity.v1beta.IHub, + | protos.google.cloud.networkconnectivity.v1beta.IGetHubRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getHub( - request: protos.google.cloud.networkconnectivity.v1beta.IGetHubRequest, - callback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IHub, - protos.google.cloud.networkconnectivity.v1beta.IGetHubRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IGetHubRequest, + callback: Callback< + protos.google.cloud.networkconnectivity.v1beta.IHub, + | protos.google.cloud.networkconnectivity.v1beta.IGetHubRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getHub( - request?: protos.google.cloud.networkconnectivity.v1beta.IGetHubRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkconnectivity.v1beta.IHub, - protos.google.cloud.networkconnectivity.v1beta.IGetHubRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkconnectivity.v1beta.IGetHubRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkconnectivity.v1beta.IHub, - protos.google.cloud.networkconnectivity.v1beta.IGetHubRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IHub, - protos.google.cloud.networkconnectivity.v1beta.IGetHubRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkconnectivity.v1beta.IGetHubRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkconnectivity.v1beta.IHub, + | protos.google.cloud.networkconnectivity.v1beta.IGetHubRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IHub, + protos.google.cloud.networkconnectivity.v1beta.IGetHubRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getHub request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IHub, - protos.google.cloud.networkconnectivity.v1beta.IGetHubRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkconnectivity.v1beta.IHub, + | protos.google.cloud.networkconnectivity.v1beta.IGetHubRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getHub response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getHub(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkconnectivity.v1beta.IHub, - protos.google.cloud.networkconnectivity.v1beta.IGetHubRequest|undefined, - {}|undefined - ]) => { - this._log.info('getHub response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getHub(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkconnectivity.v1beta.IHub, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetHubRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getHub response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details about a Network Connectivity Center spoke. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the spoke resource. - * @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 {@link protos.google.cloud.networkconnectivity.v1beta.Spoke|Spoke}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/hub_service.get_spoke.js - * region_tag:networkconnectivity_v1beta_generated_HubService_GetSpoke_async - */ + /** + * Gets details about a Network Connectivity Center spoke. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the spoke resource. + * @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 {@link protos.google.cloud.networkconnectivity.v1beta.Spoke|Spoke}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/hub_service.get_spoke.js + * region_tag:networkconnectivity_v1beta_generated_HubService_GetSpoke_async + */ getSpoke( - request?: protos.google.cloud.networkconnectivity.v1beta.IGetSpokeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.ISpoke, - protos.google.cloud.networkconnectivity.v1beta.IGetSpokeRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IGetSpokeRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.ISpoke, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetSpokeRequest + | undefined + ), + {} | undefined, + ] + >; getSpoke( - request: protos.google.cloud.networkconnectivity.v1beta.IGetSpokeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkconnectivity.v1beta.ISpoke, - protos.google.cloud.networkconnectivity.v1beta.IGetSpokeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IGetSpokeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkconnectivity.v1beta.ISpoke, + | protos.google.cloud.networkconnectivity.v1beta.IGetSpokeRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getSpoke( - request: protos.google.cloud.networkconnectivity.v1beta.IGetSpokeRequest, - callback: Callback< - protos.google.cloud.networkconnectivity.v1beta.ISpoke, - protos.google.cloud.networkconnectivity.v1beta.IGetSpokeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IGetSpokeRequest, + callback: Callback< + protos.google.cloud.networkconnectivity.v1beta.ISpoke, + | protos.google.cloud.networkconnectivity.v1beta.IGetSpokeRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getSpoke( - request?: protos.google.cloud.networkconnectivity.v1beta.IGetSpokeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkconnectivity.v1beta.ISpoke, - protos.google.cloud.networkconnectivity.v1beta.IGetSpokeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkconnectivity.v1beta.IGetSpokeRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkconnectivity.v1beta.ISpoke, - protos.google.cloud.networkconnectivity.v1beta.IGetSpokeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.ISpoke, - protos.google.cloud.networkconnectivity.v1beta.IGetSpokeRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkconnectivity.v1beta.IGetSpokeRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkconnectivity.v1beta.ISpoke, + | protos.google.cloud.networkconnectivity.v1beta.IGetSpokeRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.ISpoke, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetSpokeRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getSpoke request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkconnectivity.v1beta.ISpoke, - protos.google.cloud.networkconnectivity.v1beta.IGetSpokeRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkconnectivity.v1beta.ISpoke, + | protos.google.cloud.networkconnectivity.v1beta.IGetSpokeRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getSpoke response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getSpoke(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkconnectivity.v1beta.ISpoke, - protos.google.cloud.networkconnectivity.v1beta.IGetSpokeRequest|undefined, - {}|undefined - ]) => { - this._log.info('getSpoke response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getSpoke(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkconnectivity.v1beta.ISpoke, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetSpokeRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getSpoke response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details about a Network Connectivity Center route table. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the route table resource. - * @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 {@link protos.google.cloud.networkconnectivity.v1beta.RouteTable|RouteTable}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/hub_service.get_route_table.js - * region_tag:networkconnectivity_v1beta_generated_HubService_GetRouteTable_async - */ + /** + * Gets details about a Network Connectivity Center route table. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the route table resource. + * @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 {@link protos.google.cloud.networkconnectivity.v1beta.RouteTable|RouteTable}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/hub_service.get_route_table.js + * region_tag:networkconnectivity_v1beta_generated_HubService_GetRouteTable_async + */ getRouteTable( - request?: protos.google.cloud.networkconnectivity.v1beta.IGetRouteTableRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IRouteTable, - protos.google.cloud.networkconnectivity.v1beta.IGetRouteTableRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IGetRouteTableRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IRouteTable, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetRouteTableRequest + | undefined + ), + {} | undefined, + ] + >; getRouteTable( - request: protos.google.cloud.networkconnectivity.v1beta.IGetRouteTableRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IRouteTable, - protos.google.cloud.networkconnectivity.v1beta.IGetRouteTableRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IGetRouteTableRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkconnectivity.v1beta.IRouteTable, + | protos.google.cloud.networkconnectivity.v1beta.IGetRouteTableRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getRouteTable( - request: protos.google.cloud.networkconnectivity.v1beta.IGetRouteTableRequest, - callback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IRouteTable, - protos.google.cloud.networkconnectivity.v1beta.IGetRouteTableRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IGetRouteTableRequest, + callback: Callback< + protos.google.cloud.networkconnectivity.v1beta.IRouteTable, + | protos.google.cloud.networkconnectivity.v1beta.IGetRouteTableRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getRouteTable( - request?: protos.google.cloud.networkconnectivity.v1beta.IGetRouteTableRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkconnectivity.v1beta.IRouteTable, - protos.google.cloud.networkconnectivity.v1beta.IGetRouteTableRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkconnectivity.v1beta.IGetRouteTableRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkconnectivity.v1beta.IRouteTable, - protos.google.cloud.networkconnectivity.v1beta.IGetRouteTableRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IRouteTable, - protos.google.cloud.networkconnectivity.v1beta.IGetRouteTableRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkconnectivity.v1beta.IGetRouteTableRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkconnectivity.v1beta.IRouteTable, + | protos.google.cloud.networkconnectivity.v1beta.IGetRouteTableRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IRouteTable, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetRouteTableRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getRouteTable request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IRouteTable, - protos.google.cloud.networkconnectivity.v1beta.IGetRouteTableRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkconnectivity.v1beta.IRouteTable, + | protos.google.cloud.networkconnectivity.v1beta.IGetRouteTableRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getRouteTable response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getRouteTable(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkconnectivity.v1beta.IRouteTable, - protos.google.cloud.networkconnectivity.v1beta.IGetRouteTableRequest|undefined, - {}|undefined - ]) => { - this._log.info('getRouteTable response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getRouteTable(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkconnectivity.v1beta.IRouteTable, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetRouteTableRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getRouteTable response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details about the specified route. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the route resource. - * @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 {@link protos.google.cloud.networkconnectivity.v1beta.Route|Route}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/hub_service.get_route.js - * region_tag:networkconnectivity_v1beta_generated_HubService_GetRoute_async - */ + /** + * Gets details about the specified route. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the route resource. + * @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 {@link protos.google.cloud.networkconnectivity.v1beta.Route|Route}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/hub_service.get_route.js + * region_tag:networkconnectivity_v1beta_generated_HubService_GetRoute_async + */ getRoute( - request?: protos.google.cloud.networkconnectivity.v1beta.IGetRouteRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IRoute, - protos.google.cloud.networkconnectivity.v1beta.IGetRouteRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IGetRouteRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IRoute, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetRouteRequest + | undefined + ), + {} | undefined, + ] + >; getRoute( - request: protos.google.cloud.networkconnectivity.v1beta.IGetRouteRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IRoute, - protos.google.cloud.networkconnectivity.v1beta.IGetRouteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IGetRouteRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkconnectivity.v1beta.IRoute, + | protos.google.cloud.networkconnectivity.v1beta.IGetRouteRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getRoute( - request: protos.google.cloud.networkconnectivity.v1beta.IGetRouteRequest, - callback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IRoute, - protos.google.cloud.networkconnectivity.v1beta.IGetRouteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IGetRouteRequest, + callback: Callback< + protos.google.cloud.networkconnectivity.v1beta.IRoute, + | protos.google.cloud.networkconnectivity.v1beta.IGetRouteRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getRoute( - request?: protos.google.cloud.networkconnectivity.v1beta.IGetRouteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkconnectivity.v1beta.IRoute, - protos.google.cloud.networkconnectivity.v1beta.IGetRouteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkconnectivity.v1beta.IGetRouteRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkconnectivity.v1beta.IRoute, - protos.google.cloud.networkconnectivity.v1beta.IGetRouteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IRoute, - protos.google.cloud.networkconnectivity.v1beta.IGetRouteRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkconnectivity.v1beta.IGetRouteRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkconnectivity.v1beta.IRoute, + | protos.google.cloud.networkconnectivity.v1beta.IGetRouteRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IRoute, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetRouteRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getRoute request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IRoute, - protos.google.cloud.networkconnectivity.v1beta.IGetRouteRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkconnectivity.v1beta.IRoute, + | protos.google.cloud.networkconnectivity.v1beta.IGetRouteRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getRoute response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getRoute(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkconnectivity.v1beta.IRoute, - protos.google.cloud.networkconnectivity.v1beta.IGetRouteRequest|undefined, - {}|undefined - ]) => { - this._log.info('getRoute response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getRoute(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkconnectivity.v1beta.IRoute, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetRouteRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getRoute response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details about a Network Connectivity Center group. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the route table resource. - * @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 {@link protos.google.cloud.networkconnectivity.v1beta.Group|Group}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/hub_service.get_group.js - * region_tag:networkconnectivity_v1beta_generated_HubService_GetGroup_async - */ + /** + * Gets details about a Network Connectivity Center group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the route table resource. + * @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 {@link protos.google.cloud.networkconnectivity.v1beta.Group|Group}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/hub_service.get_group.js + * region_tag:networkconnectivity_v1beta_generated_HubService_GetGroup_async + */ getGroup( - request?: protos.google.cloud.networkconnectivity.v1beta.IGetGroupRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IGroup, - protos.google.cloud.networkconnectivity.v1beta.IGetGroupRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IGetGroupRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IGroup, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetGroupRequest + | undefined + ), + {} | undefined, + ] + >; getGroup( - request: protos.google.cloud.networkconnectivity.v1beta.IGetGroupRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IGroup, - protos.google.cloud.networkconnectivity.v1beta.IGetGroupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IGetGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkconnectivity.v1beta.IGroup, + | protos.google.cloud.networkconnectivity.v1beta.IGetGroupRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getGroup( - request: protos.google.cloud.networkconnectivity.v1beta.IGetGroupRequest, - callback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IGroup, - protos.google.cloud.networkconnectivity.v1beta.IGetGroupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IGetGroupRequest, + callback: Callback< + protos.google.cloud.networkconnectivity.v1beta.IGroup, + | protos.google.cloud.networkconnectivity.v1beta.IGetGroupRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getGroup( - request?: protos.google.cloud.networkconnectivity.v1beta.IGetGroupRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkconnectivity.v1beta.IGroup, - protos.google.cloud.networkconnectivity.v1beta.IGetGroupRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkconnectivity.v1beta.IGetGroupRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkconnectivity.v1beta.IGroup, - protos.google.cloud.networkconnectivity.v1beta.IGetGroupRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IGroup, - protos.google.cloud.networkconnectivity.v1beta.IGetGroupRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkconnectivity.v1beta.IGetGroupRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkconnectivity.v1beta.IGroup, + | protos.google.cloud.networkconnectivity.v1beta.IGetGroupRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IGroup, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetGroupRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getGroup request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IGroup, - protos.google.cloud.networkconnectivity.v1beta.IGetGroupRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkconnectivity.v1beta.IGroup, + | protos.google.cloud.networkconnectivity.v1beta.IGetGroupRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getGroup response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getGroup(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkconnectivity.v1beta.IGroup, - protos.google.cloud.networkconnectivity.v1beta.IGetGroupRequest|undefined, - {}|undefined - ]) => { - this._log.info('getGroup response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getGroup(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkconnectivity.v1beta.IGroup, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetGroupRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getGroup response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Get a GatewayAdvertisedRoute - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the gateway advertised route to get. - * @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 {@link protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute|GatewayAdvertisedRoute}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/hub_service.get_gateway_advertised_route.js - * region_tag:networkconnectivity_v1beta_generated_HubService_GetGatewayAdvertisedRoute_async - */ + /** + * Get a GatewayAdvertisedRoute + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the gateway advertised route to get. + * @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 {@link protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute|GatewayAdvertisedRoute}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/hub_service.get_gateway_advertised_route.js + * region_tag:networkconnectivity_v1beta_generated_HubService_GetGatewayAdvertisedRoute_async + */ getGatewayAdvertisedRoute( - request?: protos.google.cloud.networkconnectivity.v1beta.IGetGatewayAdvertisedRouteRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, - protos.google.cloud.networkconnectivity.v1beta.IGetGatewayAdvertisedRouteRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IGetGatewayAdvertisedRouteRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetGatewayAdvertisedRouteRequest + | undefined + ), + {} | undefined, + ] + >; getGatewayAdvertisedRoute( - request: protos.google.cloud.networkconnectivity.v1beta.IGetGatewayAdvertisedRouteRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, - protos.google.cloud.networkconnectivity.v1beta.IGetGatewayAdvertisedRouteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IGetGatewayAdvertisedRouteRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, + | protos.google.cloud.networkconnectivity.v1beta.IGetGatewayAdvertisedRouteRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getGatewayAdvertisedRoute( - request: protos.google.cloud.networkconnectivity.v1beta.IGetGatewayAdvertisedRouteRequest, - callback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, - protos.google.cloud.networkconnectivity.v1beta.IGetGatewayAdvertisedRouteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IGetGatewayAdvertisedRouteRequest, + callback: Callback< + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, + | protos.google.cloud.networkconnectivity.v1beta.IGetGatewayAdvertisedRouteRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getGatewayAdvertisedRoute( - request?: protos.google.cloud.networkconnectivity.v1beta.IGetGatewayAdvertisedRouteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, - protos.google.cloud.networkconnectivity.v1beta.IGetGatewayAdvertisedRouteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkconnectivity.v1beta.IGetGatewayAdvertisedRouteRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, - protos.google.cloud.networkconnectivity.v1beta.IGetGatewayAdvertisedRouteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, - protos.google.cloud.networkconnectivity.v1beta.IGetGatewayAdvertisedRouteRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkconnectivity.v1beta.IGetGatewayAdvertisedRouteRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, + | protos.google.cloud.networkconnectivity.v1beta.IGetGatewayAdvertisedRouteRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetGatewayAdvertisedRouteRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getGatewayAdvertisedRoute request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, - protos.google.cloud.networkconnectivity.v1beta.IGetGatewayAdvertisedRouteRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, + | protos.google.cloud.networkconnectivity.v1beta.IGetGatewayAdvertisedRouteRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getGatewayAdvertisedRoute response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getGatewayAdvertisedRoute(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, - protos.google.cloud.networkconnectivity.v1beta.IGetGatewayAdvertisedRouteRequest|undefined, - {}|undefined - ]) => { - this._log.info('getGatewayAdvertisedRoute response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getGatewayAdvertisedRoute(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetGatewayAdvertisedRouteRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getGatewayAdvertisedRoute response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a new Network Connectivity Center hub in the specified project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource. - * @param {string} request.hubId - * Required. A unique identifier for the hub. - * @param {google.cloud.networkconnectivity.v1beta.Hub} request.hub - * Required. The initial values for a new hub. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * The request ID must be a valid UUID, with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1beta/hub_service.create_hub.js - * region_tag:networkconnectivity_v1beta_generated_HubService_CreateHub_async - */ + /** + * Creates a new Network Connectivity Center hub in the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource. + * @param {string} request.hubId + * Required. A unique identifier for the hub. + * @param {google.cloud.networkconnectivity.v1beta.Hub} request.hub + * Required. The initial values for a new hub. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID so + * that if you must retry your request, the server knows to ignore the request + * if it has already been completed. The server guarantees that a request + * doesn't result in creation of duplicate commitments for at least 60 + * minutes. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check to see whether the original operation + * was received. If it was, the server ignores the second request. This + * behavior prevents clients from mistakenly creating duplicate commitments. + * + * The request ID must be a valid UUID, with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1beta/hub_service.create_hub.js + * region_tag:networkconnectivity_v1beta_generated_HubService_CreateHub_async + */ createHub( - request?: protos.google.cloud.networkconnectivity.v1beta.ICreateHubRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.ICreateHubRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IHub, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createHub( - request: protos.google.cloud.networkconnectivity.v1beta.ICreateHubRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.ICreateHubRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IHub, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createHub( - request: protos.google.cloud.networkconnectivity.v1beta.ICreateHubRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.ICreateHubRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IHub, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createHub( - request?: protos.google.cloud.networkconnectivity.v1beta.ICreateHubRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1beta.ICreateHubRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IHub, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IHub, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IHub, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IHub, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createHub response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createHub request %j', request); - return this.innerApiCalls.createHub(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createHub response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createHub(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IHub, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createHub response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createHub()`. - * @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/v1beta/hub_service.create_hub.js - * region_tag:networkconnectivity_v1beta_generated_HubService_CreateHub_async - */ - async checkCreateHubProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createHub()`. + * @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/v1beta/hub_service.create_hub.js + * region_tag:networkconnectivity_v1beta_generated_HubService_CreateHub_async + */ + async checkCreateHubProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.Hub, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + > + > { this._log.info('createHub long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createHub, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createHub, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1beta.Hub, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + >; } -/** - * Updates the description and/or labels of a Network Connectivity Center - * hub. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. In the case of an update to an existing hub, field mask is used - * to specify the fields to be overwritten. The fields specified in the - * update_mask are relative to the resource, not the full request. A field is - * overwritten if it is in the mask. If the user does not provide a mask, then - * all fields are overwritten. - * @param {google.cloud.networkconnectivity.v1beta.Hub} request.hub - * Required. The state that the hub should be in after the update. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * The request ID must be a valid UUID, with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1beta/hub_service.update_hub.js - * region_tag:networkconnectivity_v1beta_generated_HubService_UpdateHub_async - */ + /** + * Updates the description and/or labels of a Network Connectivity Center + * hub. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. In the case of an update to an existing hub, field mask is used + * to specify the fields to be overwritten. The fields specified in the + * update_mask are relative to the resource, not the full request. A field is + * overwritten if it is in the mask. If the user does not provide a mask, then + * all fields are overwritten. + * @param {google.cloud.networkconnectivity.v1beta.Hub} request.hub + * Required. The state that the hub should be in after the update. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID so + * that if you must retry your request, the server knows to ignore the request + * if it has already been completed. The server guarantees that a request + * doesn't result in creation of duplicate commitments for at least 60 + * minutes. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check to see whether the original operation + * was received. If it was, the server ignores the second request. This + * behavior prevents clients from mistakenly creating duplicate commitments. + * + * The request ID must be a valid UUID, with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1beta/hub_service.update_hub.js + * region_tag:networkconnectivity_v1beta_generated_HubService_UpdateHub_async + */ updateHub( - request?: protos.google.cloud.networkconnectivity.v1beta.IUpdateHubRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IUpdateHubRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IHub, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateHub( - request: protos.google.cloud.networkconnectivity.v1beta.IUpdateHubRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IUpdateHubRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IHub, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateHub( - request: protos.google.cloud.networkconnectivity.v1beta.IUpdateHubRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IUpdateHubRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IHub, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateHub( - request?: protos.google.cloud.networkconnectivity.v1beta.IUpdateHubRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1beta.IUpdateHubRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IHub, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IHub, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IHub, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'hub.name': request.hub!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'hub.name': request.hub!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IHub, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateHub response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateHub request %j', request); - return this.innerApiCalls.updateHub(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateHub response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateHub(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IHub, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateHub response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateHub()`. - * @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/v1beta/hub_service.update_hub.js - * region_tag:networkconnectivity_v1beta_generated_HubService_UpdateHub_async - */ - async checkUpdateHubProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateHub()`. + * @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/v1beta/hub_service.update_hub.js + * region_tag:networkconnectivity_v1beta_generated_HubService_UpdateHub_async + */ + async checkUpdateHubProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.Hub, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + > + > { this._log.info('updateHub long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateHub, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateHub, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1beta.Hub, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + >; } -/** - * Deletes a Network Connectivity Center hub. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the hub to delete. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * The request ID must be a valid UUID, with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1beta/hub_service.delete_hub.js - * region_tag:networkconnectivity_v1beta_generated_HubService_DeleteHub_async - */ + /** + * Deletes a Network Connectivity Center hub. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the hub to delete. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID so + * that if you must retry your request, the server knows to ignore the request + * if it has already been completed. The server guarantees that a request + * doesn't result in creation of duplicate commitments for at least 60 + * minutes. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check to see whether the original operation + * was received. If it was, the server ignores the second request. This + * behavior prevents clients from mistakenly creating duplicate commitments. + * + * The request ID must be a valid UUID, with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1beta/hub_service.delete_hub.js + * region_tag:networkconnectivity_v1beta_generated_HubService_DeleteHub_async + */ deleteHub( - request?: protos.google.cloud.networkconnectivity.v1beta.IDeleteHubRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IDeleteHubRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteHub( - request: protos.google.cloud.networkconnectivity.v1beta.IDeleteHubRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IDeleteHubRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteHub( - request: protos.google.cloud.networkconnectivity.v1beta.IDeleteHubRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IDeleteHubRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteHub( - request?: protos.google.cloud.networkconnectivity.v1beta.IDeleteHubRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1beta.IDeleteHubRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteHub response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteHub request %j', request); - return this.innerApiCalls.deleteHub(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteHub response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteHub(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteHub response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteHub()`. - * @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/v1beta/hub_service.delete_hub.js - * region_tag:networkconnectivity_v1beta_generated_HubService_DeleteHub_async - */ - async checkDeleteHubProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteHub()`. + * @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/v1beta/hub_service.delete_hub.js + * region_tag:networkconnectivity_v1beta_generated_HubService_DeleteHub_async + */ + async checkDeleteHubProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + > + > { this._log.info('deleteHub long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteHub, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteHub, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + >; } -/** - * Creates a Network Connectivity Center spoke. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource. - * @param {string} request.spokeId - * Required. Unique id for the spoke to create. - * @param {google.cloud.networkconnectivity.v1beta.Spoke} request.spoke - * Required. The initial values for a new spoke. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * The request ID must be a valid UUID, with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1beta/hub_service.create_spoke.js - * region_tag:networkconnectivity_v1beta_generated_HubService_CreateSpoke_async - */ + /** + * Creates a Network Connectivity Center spoke. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource. + * @param {string} request.spokeId + * Required. Unique id for the spoke to create. + * @param {google.cloud.networkconnectivity.v1beta.Spoke} request.spoke + * Required. The initial values for a new spoke. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID so + * that if you must retry your request, the server knows to ignore the request + * if it has already been completed. The server guarantees that a request + * doesn't result in creation of duplicate commitments for at least 60 + * minutes. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check to see whether the original operation + * was received. If it was, the server ignores the second request. This + * behavior prevents clients from mistakenly creating duplicate commitments. + * + * The request ID must be a valid UUID, with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1beta/hub_service.create_spoke.js + * region_tag:networkconnectivity_v1beta_generated_HubService_CreateSpoke_async + */ createSpoke( - request?: protos.google.cloud.networkconnectivity.v1beta.ICreateSpokeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.ICreateSpokeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ISpoke, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createSpoke( - request: protos.google.cloud.networkconnectivity.v1beta.ICreateSpokeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.ICreateSpokeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ISpoke, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createSpoke( - request: protos.google.cloud.networkconnectivity.v1beta.ICreateSpokeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.ICreateSpokeRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ISpoke, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createSpoke( - request?: protos.google.cloud.networkconnectivity.v1beta.ICreateSpokeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1beta.ICreateSpokeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ISpoke, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ISpoke, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ISpoke, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ISpoke, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createSpoke response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createSpoke request %j', request); - return this.innerApiCalls.createSpoke(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createSpoke response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createSpoke(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ISpoke, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createSpoke response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createSpoke()`. - * @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/v1beta/hub_service.create_spoke.js - * region_tag:networkconnectivity_v1beta_generated_HubService_CreateSpoke_async - */ - async checkCreateSpokeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createSpoke()`. + * @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/v1beta/hub_service.create_spoke.js + * region_tag:networkconnectivity_v1beta_generated_HubService_CreateSpoke_async + */ + async checkCreateSpokeProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.Spoke, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + > + > { this._log.info('createSpoke long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createSpoke, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createSpoke, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1beta.Spoke, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + >; } -/** - * Updates the parameters of a Network Connectivity Center spoke. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. In the case of an update to an existing spoke, field mask is used - * to specify the fields to be overwritten. The fields specified in the - * update_mask are relative to the resource, not the full request. A field is - * overwritten if it is in the mask. If the user does not provide a mask, then - * all fields are overwritten. - * @param {google.cloud.networkconnectivity.v1beta.Spoke} request.spoke - * Required. The state that the spoke should be in after the update. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * The request ID must be a valid UUID, with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1beta/hub_service.update_spoke.js - * region_tag:networkconnectivity_v1beta_generated_HubService_UpdateSpoke_async - */ + /** + * Updates the parameters of a Network Connectivity Center spoke. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. In the case of an update to an existing spoke, field mask is used + * to specify the fields to be overwritten. The fields specified in the + * update_mask are relative to the resource, not the full request. A field is + * overwritten if it is in the mask. If the user does not provide a mask, then + * all fields are overwritten. + * @param {google.cloud.networkconnectivity.v1beta.Spoke} request.spoke + * Required. The state that the spoke should be in after the update. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID so + * that if you must retry your request, the server knows to ignore the request + * if it has already been completed. The server guarantees that a request + * doesn't result in creation of duplicate commitments for at least 60 + * minutes. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check to see whether the original operation + * was received. If it was, the server ignores the second request. This + * behavior prevents clients from mistakenly creating duplicate commitments. + * + * The request ID must be a valid UUID, with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1beta/hub_service.update_spoke.js + * region_tag:networkconnectivity_v1beta_generated_HubService_UpdateSpoke_async + */ updateSpoke( - request?: protos.google.cloud.networkconnectivity.v1beta.IUpdateSpokeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IUpdateSpokeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ISpoke, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateSpoke( - request: protos.google.cloud.networkconnectivity.v1beta.IUpdateSpokeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IUpdateSpokeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ISpoke, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateSpoke( - request: protos.google.cloud.networkconnectivity.v1beta.IUpdateSpokeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IUpdateSpokeRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ISpoke, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateSpoke( - request?: protos.google.cloud.networkconnectivity.v1beta.IUpdateSpokeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1beta.IUpdateSpokeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ISpoke, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ISpoke, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ISpoke, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'spoke.name': request.spoke!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'spoke.name': request.spoke!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ISpoke, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateSpoke response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateSpoke request %j', request); - return this.innerApiCalls.updateSpoke(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateSpoke response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateSpoke(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ISpoke, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateSpoke response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateSpoke()`. - * @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/v1beta/hub_service.update_spoke.js - * region_tag:networkconnectivity_v1beta_generated_HubService_UpdateSpoke_async - */ - async checkUpdateSpokeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateSpoke()`. + * @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/v1beta/hub_service.update_spoke.js + * region_tag:networkconnectivity_v1beta_generated_HubService_UpdateSpoke_async + */ + async checkUpdateSpokeProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.Spoke, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + > + > { this._log.info('updateSpoke long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateSpoke, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateSpoke, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1beta.Spoke, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + >; } -/** - * Rejects a Network Connectivity Center spoke from being attached to a hub. - * If the spoke was previously in the `ACTIVE` state, it - * transitions to the `INACTIVE` state and is no longer able to - * connect to other spokes that are attached to the hub. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the hub from which to reject the spoke. - * @param {string} request.spokeUri - * Required. The URI of the spoke to reject from the hub. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * 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.details] - * Optional. Additional information provided by the hub administrator. - * @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/v1beta/hub_service.reject_hub_spoke.js - * region_tag:networkconnectivity_v1beta_generated_HubService_RejectHubSpoke_async - */ + /** + * Rejects a Network Connectivity Center spoke from being attached to a hub. + * If the spoke was previously in the `ACTIVE` state, it + * transitions to the `INACTIVE` state and is no longer able to + * connect to other spokes that are attached to the hub. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the hub from which to reject the spoke. + * @param {string} request.spokeUri + * Required. The URI of the spoke to reject from the hub. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID so + * that if you must retry your request, the server knows to ignore the request + * if it has already been completed. The server guarantees that a request + * doesn't result in creation of duplicate commitments for at least 60 + * minutes. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check to see whether the original operation + * was received. If it was, the server ignores the second request. This + * behavior prevents clients from mistakenly creating duplicate commitments. + * + * 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.details] + * Optional. Additional information provided by the hub administrator. + * @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/v1beta/hub_service.reject_hub_spoke.js + * region_tag:networkconnectivity_v1beta_generated_HubService_RejectHubSpoke_async + */ rejectHubSpoke( - request?: protos.google.cloud.networkconnectivity.v1beta.IRejectHubSpokeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IRejectHubSpokeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IRejectHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; rejectHubSpoke( - request: protos.google.cloud.networkconnectivity.v1beta.IRejectHubSpokeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IRejectHubSpokeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IRejectHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; rejectHubSpoke( - request: protos.google.cloud.networkconnectivity.v1beta.IRejectHubSpokeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IRejectHubSpokeRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IRejectHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; rejectHubSpoke( - request?: protos.google.cloud.networkconnectivity.v1beta.IRejectHubSpokeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1beta.IRejectHubSpokeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IRejectHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IRejectHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IRejectHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IRejectHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('rejectHubSpoke response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('rejectHubSpoke request %j', request); - return this.innerApiCalls.rejectHubSpoke(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('rejectHubSpoke response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .rejectHubSpoke(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IRejectHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('rejectHubSpoke response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `rejectHubSpoke()`. - * @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/v1beta/hub_service.reject_hub_spoke.js - * region_tag:networkconnectivity_v1beta_generated_HubService_RejectHubSpoke_async - */ - async checkRejectHubSpokeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `rejectHubSpoke()`. + * @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/v1beta/hub_service.reject_hub_spoke.js + * region_tag:networkconnectivity_v1beta_generated_HubService_RejectHubSpoke_async + */ + async checkRejectHubSpokeProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.RejectHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + > + > { this._log.info('rejectHubSpoke long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.rejectHubSpoke, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.rejectHubSpoke, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1beta.RejectHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + >; } -/** - * Accepts a proposal to attach a Network Connectivity Center spoke - * to a hub. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the hub into which to accept the spoke. - * @param {string} request.spokeUri - * Required. The URI of the spoke to accept into the hub. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * The request ID must be a valid UUID, with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1beta/hub_service.accept_hub_spoke.js - * region_tag:networkconnectivity_v1beta_generated_HubService_AcceptHubSpoke_async - */ + /** + * Accepts a proposal to attach a Network Connectivity Center spoke + * to a hub. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the hub into which to accept the spoke. + * @param {string} request.spokeUri + * Required. The URI of the spoke to accept into the hub. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID so + * that if you must retry your request, the server knows to ignore the request + * if it has already been completed. The server guarantees that a request + * doesn't result in creation of duplicate commitments for at least 60 + * minutes. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check to see whether the original operation + * was received. If it was, the server ignores the second request. This + * behavior prevents clients from mistakenly creating duplicate commitments. + * + * The request ID must be a valid UUID, with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1beta/hub_service.accept_hub_spoke.js + * region_tag:networkconnectivity_v1beta_generated_HubService_AcceptHubSpoke_async + */ acceptHubSpoke( - request?: protos.google.cloud.networkconnectivity.v1beta.IAcceptHubSpokeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IAcceptHubSpokeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IAcceptHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; acceptHubSpoke( - request: protos.google.cloud.networkconnectivity.v1beta.IAcceptHubSpokeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IAcceptHubSpokeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IAcceptHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; acceptHubSpoke( - request: protos.google.cloud.networkconnectivity.v1beta.IAcceptHubSpokeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IAcceptHubSpokeRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IAcceptHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; acceptHubSpoke( - request?: protos.google.cloud.networkconnectivity.v1beta.IAcceptHubSpokeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1beta.IAcceptHubSpokeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IAcceptHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IAcceptHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IAcceptHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IAcceptHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('acceptHubSpoke response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('acceptHubSpoke request %j', request); - return this.innerApiCalls.acceptHubSpoke(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('acceptHubSpoke response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .acceptHubSpoke(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IAcceptHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('acceptHubSpoke response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `acceptHubSpoke()`. - * @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/v1beta/hub_service.accept_hub_spoke.js - * region_tag:networkconnectivity_v1beta_generated_HubService_AcceptHubSpoke_async - */ - async checkAcceptHubSpokeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `acceptHubSpoke()`. + * @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/v1beta/hub_service.accept_hub_spoke.js + * region_tag:networkconnectivity_v1beta_generated_HubService_AcceptHubSpoke_async + */ + async checkAcceptHubSpokeProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.AcceptHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + > + > { this._log.info('acceptHubSpoke long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.acceptHubSpoke, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.acceptHubSpoke, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1beta.AcceptHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + >; } -/** - * Accepts a proposal to update a Network Connectivity Center spoke in a hub. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the hub to accept spoke update. - * @param {string} request.spokeUri - * Required. The URI of the spoke to accept update. - * @param {string} request.spokeEtag - * Required. The etag of the spoke to accept update. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * The request ID must be a valid UUID, with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1beta/hub_service.accept_spoke_update.js - * region_tag:networkconnectivity_v1beta_generated_HubService_AcceptSpokeUpdate_async - */ + /** + * Accepts a proposal to update a Network Connectivity Center spoke in a hub. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the hub to accept spoke update. + * @param {string} request.spokeUri + * Required. The URI of the spoke to accept update. + * @param {string} request.spokeEtag + * Required. The etag of the spoke to accept update. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID so + * that if you must retry your request, the server knows to ignore the request + * if it has already been completed. The server guarantees that a request + * doesn't result in creation of duplicate commitments for at least 60 + * minutes. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check to see whether the original operation + * was received. If it was, the server ignores the second request. This + * behavior prevents clients from mistakenly creating duplicate commitments. + * + * The request ID must be a valid UUID, with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1beta/hub_service.accept_spoke_update.js + * region_tag:networkconnectivity_v1beta_generated_HubService_AcceptSpokeUpdate_async + */ acceptSpokeUpdate( - request?: protos.google.cloud.networkconnectivity.v1beta.IAcceptSpokeUpdateRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IAcceptSpokeUpdateRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IAcceptSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; acceptSpokeUpdate( - request: protos.google.cloud.networkconnectivity.v1beta.IAcceptSpokeUpdateRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IAcceptSpokeUpdateRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IAcceptSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; acceptSpokeUpdate( - request: protos.google.cloud.networkconnectivity.v1beta.IAcceptSpokeUpdateRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IAcceptSpokeUpdateRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IAcceptSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; acceptSpokeUpdate( - request?: protos.google.cloud.networkconnectivity.v1beta.IAcceptSpokeUpdateRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1beta.IAcceptSpokeUpdateRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IAcceptSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IAcceptSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IAcceptSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IAcceptSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('acceptSpokeUpdate response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('acceptSpokeUpdate request %j', request); - return this.innerApiCalls.acceptSpokeUpdate(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('acceptSpokeUpdate response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .acceptSpokeUpdate(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IAcceptSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('acceptSpokeUpdate response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `acceptSpokeUpdate()`. - * @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/v1beta/hub_service.accept_spoke_update.js - * region_tag:networkconnectivity_v1beta_generated_HubService_AcceptSpokeUpdate_async - */ - async checkAcceptSpokeUpdateProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `acceptSpokeUpdate()`. + * @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/v1beta/hub_service.accept_spoke_update.js + * region_tag:networkconnectivity_v1beta_generated_HubService_AcceptSpokeUpdate_async + */ + async checkAcceptSpokeUpdateProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.AcceptSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + > + > { this._log.info('acceptSpokeUpdate long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.acceptSpokeUpdate, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.acceptSpokeUpdate, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1beta.AcceptSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + >; } -/** - * Rejects a proposal to update a Network Connectivity Center spoke in a hub. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the hub to reject spoke update. - * @param {string} request.spokeUri - * Required. The URI of the spoke to reject update. - * @param {string} request.spokeEtag - * Required. The etag of the spoke to reject update. - * @param {string} [request.details] - * Optional. Additional information provided by the hub administrator. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * The request ID must be a valid UUID, with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1beta/hub_service.reject_spoke_update.js - * region_tag:networkconnectivity_v1beta_generated_HubService_RejectSpokeUpdate_async - */ + /** + * Rejects a proposal to update a Network Connectivity Center spoke in a hub. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the hub to reject spoke update. + * @param {string} request.spokeUri + * Required. The URI of the spoke to reject update. + * @param {string} request.spokeEtag + * Required. The etag of the spoke to reject update. + * @param {string} [request.details] + * Optional. Additional information provided by the hub administrator. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID so + * that if you must retry your request, the server knows to ignore the request + * if it has already been completed. The server guarantees that a request + * doesn't result in creation of duplicate commitments for at least 60 + * minutes. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check to see whether the original operation + * was received. If it was, the server ignores the second request. This + * behavior prevents clients from mistakenly creating duplicate commitments. + * + * The request ID must be a valid UUID, with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1beta/hub_service.reject_spoke_update.js + * region_tag:networkconnectivity_v1beta_generated_HubService_RejectSpokeUpdate_async + */ rejectSpokeUpdate( - request?: protos.google.cloud.networkconnectivity.v1beta.IRejectSpokeUpdateRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IRejectSpokeUpdateRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IRejectSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; rejectSpokeUpdate( - request: protos.google.cloud.networkconnectivity.v1beta.IRejectSpokeUpdateRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IRejectSpokeUpdateRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IRejectSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; rejectSpokeUpdate( - request: protos.google.cloud.networkconnectivity.v1beta.IRejectSpokeUpdateRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IRejectSpokeUpdateRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IRejectSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; rejectSpokeUpdate( - request?: protos.google.cloud.networkconnectivity.v1beta.IRejectSpokeUpdateRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1beta.IRejectSpokeUpdateRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IRejectSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IRejectSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IRejectSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IRejectSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('rejectSpokeUpdate response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('rejectSpokeUpdate request %j', request); - return this.innerApiCalls.rejectSpokeUpdate(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('rejectSpokeUpdate response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .rejectSpokeUpdate(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IRejectSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('rejectSpokeUpdate response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `rejectSpokeUpdate()`. - * @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/v1beta/hub_service.reject_spoke_update.js - * region_tag:networkconnectivity_v1beta_generated_HubService_RejectSpokeUpdate_async - */ - async checkRejectSpokeUpdateProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `rejectSpokeUpdate()`. + * @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/v1beta/hub_service.reject_spoke_update.js + * region_tag:networkconnectivity_v1beta_generated_HubService_RejectSpokeUpdate_async + */ + async checkRejectSpokeUpdateProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.RejectSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + > + > { this._log.info('rejectSpokeUpdate long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.rejectSpokeUpdate, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.rejectSpokeUpdate, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1beta.RejectSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + >; } -/** - * Deletes a Network Connectivity Center spoke. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the spoke to delete. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * The request ID must be a valid UUID, with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1beta/hub_service.delete_spoke.js - * region_tag:networkconnectivity_v1beta_generated_HubService_DeleteSpoke_async - */ + /** + * Deletes a Network Connectivity Center spoke. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the spoke to delete. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID so + * that if you must retry your request, the server knows to ignore the request + * if it has already been completed. The server guarantees that a request + * doesn't result in creation of duplicate commitments for at least 60 + * minutes. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check to see whether the original operation + * was received. If it was, the server ignores the second request. This + * behavior prevents clients from mistakenly creating duplicate commitments. + * + * The request ID must be a valid UUID, with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1beta/hub_service.delete_spoke.js + * region_tag:networkconnectivity_v1beta_generated_HubService_DeleteSpoke_async + */ deleteSpoke( - request?: protos.google.cloud.networkconnectivity.v1beta.IDeleteSpokeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IDeleteSpokeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteSpoke( - request: protos.google.cloud.networkconnectivity.v1beta.IDeleteSpokeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IDeleteSpokeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteSpoke( - request: protos.google.cloud.networkconnectivity.v1beta.IDeleteSpokeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IDeleteSpokeRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteSpoke( - request?: protos.google.cloud.networkconnectivity.v1beta.IDeleteSpokeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1beta.IDeleteSpokeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteSpoke response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteSpoke request %j', request); - return this.innerApiCalls.deleteSpoke(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteSpoke response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteSpoke(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteSpoke response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteSpoke()`. - * @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/v1beta/hub_service.delete_spoke.js - * region_tag:networkconnectivity_v1beta_generated_HubService_DeleteSpoke_async - */ - async checkDeleteSpokeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteSpoke()`. + * @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/v1beta/hub_service.delete_spoke.js + * region_tag:networkconnectivity_v1beta_generated_HubService_DeleteSpoke_async + */ + async checkDeleteSpokeProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + > + > { this._log.info('deleteSpoke long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteSpoke, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteSpoke, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + >; } -/** - * Updates the parameters of a Network Connectivity Center group. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. In the case of an update to an existing group, field mask is used - * to specify the fields to be overwritten. The fields specified in the - * update_mask are relative to the resource, not the full request. A field is - * overwritten if it is in the mask. If the user does not provide a mask, then - * all fields are overwritten. - * @param {google.cloud.networkconnectivity.v1beta.Group} request.group - * Required. The state that the group should be in after the update. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * The request ID must be a valid UUID, with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1beta/hub_service.update_group.js - * region_tag:networkconnectivity_v1beta_generated_HubService_UpdateGroup_async - */ + /** + * Updates the parameters of a Network Connectivity Center group. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. In the case of an update to an existing group, field mask is used + * to specify the fields to be overwritten. The fields specified in the + * update_mask are relative to the resource, not the full request. A field is + * overwritten if it is in the mask. If the user does not provide a mask, then + * all fields are overwritten. + * @param {google.cloud.networkconnectivity.v1beta.Group} request.group + * Required. The state that the group should be in after the update. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID so + * that if you must retry your request, the server knows to ignore the request + * if it has already been completed. The server guarantees that a request + * doesn't result in creation of duplicate commitments for at least 60 + * minutes. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check to see whether the original operation + * was received. If it was, the server ignores the second request. This + * behavior prevents clients from mistakenly creating duplicate commitments. + * + * The request ID must be a valid UUID, with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1beta/hub_service.update_group.js + * region_tag:networkconnectivity_v1beta_generated_HubService_UpdateGroup_async + */ updateGroup( - request?: protos.google.cloud.networkconnectivity.v1beta.IUpdateGroupRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IUpdateGroupRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IGroup, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateGroup( - request: protos.google.cloud.networkconnectivity.v1beta.IUpdateGroupRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IUpdateGroupRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IGroup, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateGroup( - request: protos.google.cloud.networkconnectivity.v1beta.IUpdateGroupRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IUpdateGroupRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IGroup, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateGroup( - request?: protos.google.cloud.networkconnectivity.v1beta.IUpdateGroupRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1beta.IUpdateGroupRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IGroup, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IGroup, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IGroup, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'group.name': request.group!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'group.name': request.group!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IGroup, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateGroup response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateGroup request %j', request); - return this.innerApiCalls.updateGroup(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateGroup response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateGroup(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IGroup, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateGroup response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateGroup()`. - * @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/v1beta/hub_service.update_group.js - * region_tag:networkconnectivity_v1beta_generated_HubService_UpdateGroup_async - */ - async checkUpdateGroupProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateGroup()`. + * @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/v1beta/hub_service.update_group.js + * region_tag:networkconnectivity_v1beta_generated_HubService_UpdateGroup_async + */ + async checkUpdateGroupProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.Group, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + > + > { this._log.info('updateGroup long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateGroup, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateGroup, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1beta.Group, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + >; } -/** - * Create a GatewayAdvertisedRoute - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource. - * @param {string} request.gatewayAdvertisedRouteId - * Required. Unique id for the route to create. - * @param {google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute} request.gatewayAdvertisedRoute - * Required. Initial values for the new gateway advertised route. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * The request ID must be a valid UUID, with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1beta/hub_service.create_gateway_advertised_route.js - * region_tag:networkconnectivity_v1beta_generated_HubService_CreateGatewayAdvertisedRoute_async - */ + /** + * Create a GatewayAdvertisedRoute + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource. + * @param {string} request.gatewayAdvertisedRouteId + * Required. Unique id for the route to create. + * @param {google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute} request.gatewayAdvertisedRoute + * Required. Initial values for the new gateway advertised route. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID so + * that if you must retry your request, the server knows to ignore the request + * if it has already been completed. The server guarantees that a request + * doesn't result in creation of duplicate commitments for at least 60 + * minutes. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check to see whether the original operation + * was received. If it was, the server ignores the second request. This + * behavior prevents clients from mistakenly creating duplicate commitments. + * + * The request ID must be a valid UUID, with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1beta/hub_service.create_gateway_advertised_route.js + * region_tag:networkconnectivity_v1beta_generated_HubService_CreateGatewayAdvertisedRoute_async + */ createGatewayAdvertisedRoute( - request?: protos.google.cloud.networkconnectivity.v1beta.ICreateGatewayAdvertisedRouteRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.ICreateGatewayAdvertisedRouteRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createGatewayAdvertisedRoute( - request: protos.google.cloud.networkconnectivity.v1beta.ICreateGatewayAdvertisedRouteRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.ICreateGatewayAdvertisedRouteRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createGatewayAdvertisedRoute( - request: protos.google.cloud.networkconnectivity.v1beta.ICreateGatewayAdvertisedRouteRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.ICreateGatewayAdvertisedRouteRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createGatewayAdvertisedRoute( - request?: protos.google.cloud.networkconnectivity.v1beta.ICreateGatewayAdvertisedRouteRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1beta.ICreateGatewayAdvertisedRouteRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { - this._log.info('createGatewayAdvertisedRoute response %j', rawResponse); + this._log.info( + 'createGatewayAdvertisedRoute response %j', + rawResponse, + ); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createGatewayAdvertisedRoute request %j', request); - return this.innerApiCalls.createGatewayAdvertisedRoute(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createGatewayAdvertisedRoute response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createGatewayAdvertisedRoute(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info( + 'createGatewayAdvertisedRoute response %j', + rawResponse, + ); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createGatewayAdvertisedRoute()`. - * @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/v1beta/hub_service.create_gateway_advertised_route.js - * region_tag:networkconnectivity_v1beta_generated_HubService_CreateGatewayAdvertisedRoute_async - */ - async checkCreateGatewayAdvertisedRouteProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createGatewayAdvertisedRoute()`. + * @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/v1beta/hub_service.create_gateway_advertised_route.js + * region_tag:networkconnectivity_v1beta_generated_HubService_CreateGatewayAdvertisedRoute_async + */ + async checkCreateGatewayAdvertisedRouteProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + > + > { this._log.info('createGatewayAdvertisedRoute long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createGatewayAdvertisedRoute, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createGatewayAdvertisedRoute, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + >; } -/** - * Update a GatewayAdvertisedRoute - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. In the case of an update to an existing group, field mask is used - * to specify the fields to be overwritten. The fields specified in the - * update_mask are relative to the resource, not the full request. A field is - * overwritten if it is in the mask. If the user does not provide a mask, then - * all fields are overwritten. - * @param {google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute} request.gatewayAdvertisedRoute - * Required. The gateway advertised route to update. - * - * The gateway advertised route's `name` field is used to identify the gateway - * advertised route to update. Format: - * `projects/{project}/locations/{location}/spokes/{spoke}/gatewayAdvertisedRoutes/{gatewayAdvertisedRoute}` - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * The request ID must be a valid UUID, with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1beta/hub_service.update_gateway_advertised_route.js - * region_tag:networkconnectivity_v1beta_generated_HubService_UpdateGatewayAdvertisedRoute_async - */ + /** + * Update a GatewayAdvertisedRoute + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. In the case of an update to an existing group, field mask is used + * to specify the fields to be overwritten. The fields specified in the + * update_mask are relative to the resource, not the full request. A field is + * overwritten if it is in the mask. If the user does not provide a mask, then + * all fields are overwritten. + * @param {google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute} request.gatewayAdvertisedRoute + * Required. The gateway advertised route to update. + * + * The gateway advertised route's `name` field is used to identify the gateway + * advertised route to update. Format: + * `projects/{project}/locations/{location}/spokes/{spoke}/gatewayAdvertisedRoutes/{gatewayAdvertisedRoute}` + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID so + * that if you must retry your request, the server knows to ignore the request + * if it has already been completed. The server guarantees that a request + * doesn't result in creation of duplicate commitments for at least 60 + * minutes. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check to see whether the original operation + * was received. If it was, the server ignores the second request. This + * behavior prevents clients from mistakenly creating duplicate commitments. + * + * The request ID must be a valid UUID, with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1beta/hub_service.update_gateway_advertised_route.js + * region_tag:networkconnectivity_v1beta_generated_HubService_UpdateGatewayAdvertisedRoute_async + */ updateGatewayAdvertisedRoute( - request?: protos.google.cloud.networkconnectivity.v1beta.IUpdateGatewayAdvertisedRouteRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IUpdateGatewayAdvertisedRouteRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateGatewayAdvertisedRoute( - request: protos.google.cloud.networkconnectivity.v1beta.IUpdateGatewayAdvertisedRouteRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IUpdateGatewayAdvertisedRouteRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateGatewayAdvertisedRoute( - request: protos.google.cloud.networkconnectivity.v1beta.IUpdateGatewayAdvertisedRouteRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IUpdateGatewayAdvertisedRouteRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateGatewayAdvertisedRoute( - request?: protos.google.cloud.networkconnectivity.v1beta.IUpdateGatewayAdvertisedRouteRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1beta.IUpdateGatewayAdvertisedRouteRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'gateway_advertised_route.name': request.gatewayAdvertisedRoute!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'gateway_advertised_route.name': + request.gatewayAdvertisedRoute!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { - this._log.info('updateGatewayAdvertisedRoute response %j', rawResponse); + this._log.info( + 'updateGatewayAdvertisedRoute response %j', + rawResponse, + ); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateGatewayAdvertisedRoute request %j', request); - return this.innerApiCalls.updateGatewayAdvertisedRoute(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateGatewayAdvertisedRoute response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateGatewayAdvertisedRoute(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info( + 'updateGatewayAdvertisedRoute response %j', + rawResponse, + ); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateGatewayAdvertisedRoute()`. - * @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/v1beta/hub_service.update_gateway_advertised_route.js - * region_tag:networkconnectivity_v1beta_generated_HubService_UpdateGatewayAdvertisedRoute_async - */ - async checkUpdateGatewayAdvertisedRouteProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateGatewayAdvertisedRoute()`. + * @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/v1beta/hub_service.update_gateway_advertised_route.js + * region_tag:networkconnectivity_v1beta_generated_HubService_UpdateGatewayAdvertisedRoute_async + */ + async checkUpdateGatewayAdvertisedRouteProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + > + > { this._log.info('updateGatewayAdvertisedRoute long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateGatewayAdvertisedRoute, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateGatewayAdvertisedRoute, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + >; } -/** - * Delete a GatewayAdvertisedRoute - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the gateway advertised route to delete. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * The request ID must be a valid UUID, with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1beta/hub_service.delete_gateway_advertised_route.js - * region_tag:networkconnectivity_v1beta_generated_HubService_DeleteGatewayAdvertisedRoute_async - */ + /** + * Delete a GatewayAdvertisedRoute + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the gateway advertised route to delete. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID so + * that if you must retry your request, the server knows to ignore the request + * if it has already been completed. The server guarantees that a request + * doesn't result in creation of duplicate commitments for at least 60 + * minutes. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check to see whether the original operation + * was received. If it was, the server ignores the second request. This + * behavior prevents clients from mistakenly creating duplicate commitments. + * + * The request ID must be a valid UUID, with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1beta/hub_service.delete_gateway_advertised_route.js + * region_tag:networkconnectivity_v1beta_generated_HubService_DeleteGatewayAdvertisedRoute_async + */ deleteGatewayAdvertisedRoute( - request?: protos.google.cloud.networkconnectivity.v1beta.IDeleteGatewayAdvertisedRouteRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IDeleteGatewayAdvertisedRouteRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteGatewayAdvertisedRoute( - request: protos.google.cloud.networkconnectivity.v1beta.IDeleteGatewayAdvertisedRouteRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IDeleteGatewayAdvertisedRouteRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteGatewayAdvertisedRoute( - request: protos.google.cloud.networkconnectivity.v1beta.IDeleteGatewayAdvertisedRouteRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IDeleteGatewayAdvertisedRouteRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteGatewayAdvertisedRoute( - request?: protos.google.cloud.networkconnectivity.v1beta.IDeleteGatewayAdvertisedRouteRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1beta.IDeleteGatewayAdvertisedRouteRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { - this._log.info('deleteGatewayAdvertisedRoute response %j', rawResponse); + this._log.info( + 'deleteGatewayAdvertisedRoute response %j', + rawResponse, + ); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteGatewayAdvertisedRoute request %j', request); - return this.innerApiCalls.deleteGatewayAdvertisedRoute(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteGatewayAdvertisedRoute response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteGatewayAdvertisedRoute(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info( + 'deleteGatewayAdvertisedRoute response %j', + rawResponse, + ); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteGatewayAdvertisedRoute()`. - * @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/v1beta/hub_service.delete_gateway_advertised_route.js - * region_tag:networkconnectivity_v1beta_generated_HubService_DeleteGatewayAdvertisedRoute_async - */ - async checkDeleteGatewayAdvertisedRouteProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteGatewayAdvertisedRoute()`. + * @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/v1beta/hub_service.delete_gateway_advertised_route.js + * region_tag:networkconnectivity_v1beta_generated_HubService_DeleteGatewayAdvertisedRoute_async + */ + async checkDeleteGatewayAdvertisedRouteProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + > + > { this._log.info('deleteGatewayAdvertisedRoute long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteGatewayAdvertisedRoute, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists the Network Connectivity Center hubs associated with a given project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results per page to return. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1beta.Hub|Hub}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listHubsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteGatewayAdvertisedRoute, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + >; + } + /** + * Lists the Network Connectivity Center hubs associated with a given project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results per page to return. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1beta.Hub|Hub}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listHubsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listHubs( - request?: protos.google.cloud.networkconnectivity.v1beta.IListHubsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IHub[], - protos.google.cloud.networkconnectivity.v1beta.IListHubsRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListHubsResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IListHubsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IHub[], + protos.google.cloud.networkconnectivity.v1beta.IListHubsRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListHubsResponse, + ] + >; listHubs( - request: protos.google.cloud.networkconnectivity.v1beta.IListHubsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListHubsRequest, - protos.google.cloud.networkconnectivity.v1beta.IListHubsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IHub>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IListHubsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListHubsRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListHubsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IHub + >, + ): void; listHubs( - request: protos.google.cloud.networkconnectivity.v1beta.IListHubsRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListHubsRequest, - protos.google.cloud.networkconnectivity.v1beta.IListHubsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IHub>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IListHubsRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListHubsRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListHubsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IHub + >, + ): void; listHubs( - request?: protos.google.cloud.networkconnectivity.v1beta.IListHubsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListHubsRequest, - protos.google.cloud.networkconnectivity.v1beta.IListHubsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IHub>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1beta.IListHubsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1beta.IListHubsRequest, - protos.google.cloud.networkconnectivity.v1beta.IListHubsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IHub>): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IHub[], - protos.google.cloud.networkconnectivity.v1beta.IListHubsRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListHubsResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1beta.IListHubsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IHub + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListHubsRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListHubsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IHub + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IHub[], + protos.google.cloud.networkconnectivity.v1beta.IListHubsRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListHubsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListHubsRequest, - protos.google.cloud.networkconnectivity.v1beta.IListHubsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IHub>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListHubsRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListHubsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IHub + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listHubs values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2973,216 +4410,245 @@ export class HubServiceClient { this._log.info('listHubs request %j', request); return this.innerApiCalls .listHubs(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1beta.IHub[], - protos.google.cloud.networkconnectivity.v1beta.IListHubsRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListHubsResponse - ]) => { - this._log.info('listHubs values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1beta.IHub[], + protos.google.cloud.networkconnectivity.v1beta.IListHubsRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListHubsResponse, + ]) => { + this._log.info('listHubs values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listHubs`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results per page to return. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1beta.Hub|Hub} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listHubsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listHubs`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results per page to return. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1beta.Hub|Hub} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listHubsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listHubsStream( - request?: protos.google.cloud.networkconnectivity.v1beta.IListHubsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1beta.IListHubsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listHubs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listHubs stream %j', request); return this.descriptors.page.listHubs.createStream( this.innerApiCalls.listHubs as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listHubs`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results per page to return. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1beta.Hub|Hub}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/hub_service.list_hubs.js - * region_tag:networkconnectivity_v1beta_generated_HubService_ListHubs_async - */ + /** + * Equivalent to `listHubs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results per page to return. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1beta.Hub|Hub}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/hub_service.list_hubs.js + * region_tag:networkconnectivity_v1beta_generated_HubService_ListHubs_async + */ listHubsAsync( - request?: protos.google.cloud.networkconnectivity.v1beta.IListHubsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1beta.IListHubsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listHubs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listHubs iterate %j', request); return this.descriptors.page.listHubs.asyncIterate( this.innerApiCalls['listHubs'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists the Network Connectivity Center spokes associated with a - * specified hub and location. The list includes both spokes that are attached - * to the hub and spokes that have been proposed but not yet accepted. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the hub. - * @param {string[]} request.spokeLocations - * A list of locations. - * Specify one of the following: `[global]`, a single region (for - * example, `[us-central1]`), or a combination of - * values (for example, `[global, us-central1, us-west1]`). - * If the spoke_locations field is populated, the list of results - * includes only spokes in the specified location. - * If the spoke_locations field is not populated, the list of results - * includes spokes in all locations. - * @param {number} request.pageSize - * The maximum number of results to return per page. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by name or create_time. - * @param {google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest.SpokeView} request.view - * The view of the spoke to return. - * The view that you use determines which spoke fields are included in the - * response. - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1beta.Spoke|Spoke}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listHubSpokesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists the Network Connectivity Center spokes associated with a + * specified hub and location. The list includes both spokes that are attached + * to the hub and spokes that have been proposed but not yet accepted. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the hub. + * @param {string[]} request.spokeLocations + * A list of locations. + * Specify one of the following: `[global]`, a single region (for + * example, `[us-central1]`), or a combination of + * values (for example, `[global, us-central1, us-west1]`). + * If the spoke_locations field is populated, the list of results + * includes only spokes in the specified location. + * If the spoke_locations field is not populated, the list of results + * includes spokes in all locations. + * @param {number} request.pageSize + * The maximum number of results to return per page. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by name or create_time. + * @param {google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest.SpokeView} request.view + * The view of the spoke to return. + * The view that you use determines which spoke fields are included in the + * response. + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1beta.Spoke|Spoke}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listHubSpokesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listHubSpokes( - request?: protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.ISpoke[], - protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.ISpoke[], + protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesResponse, + ] + >; listHubSpokes( - request: protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.ISpoke>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.ISpoke + >, + ): void; listHubSpokes( - request: protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.ISpoke>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.ISpoke + >, + ): void; listHubSpokes( - request?: protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.ISpoke>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.ISpoke>): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.ISpoke[], - protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.ISpoke + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.ISpoke + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.ISpoke[], + protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.ISpoke>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.ISpoke + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listHubSpokes values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -3191,254 +4657,283 @@ export class HubServiceClient { this._log.info('listHubSpokes request %j', request); return this.innerApiCalls .listHubSpokes(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1beta.ISpoke[], - protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesResponse - ]) => { - this._log.info('listHubSpokes values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1beta.ISpoke[], + protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesResponse, + ]) => { + this._log.info('listHubSpokes values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listHubSpokes`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the hub. - * @param {string[]} request.spokeLocations - * A list of locations. - * Specify one of the following: `[global]`, a single region (for - * example, `[us-central1]`), or a combination of - * values (for example, `[global, us-central1, us-west1]`). - * If the spoke_locations field is populated, the list of results - * includes only spokes in the specified location. - * If the spoke_locations field is not populated, the list of results - * includes spokes in all locations. - * @param {number} request.pageSize - * The maximum number of results to return per page. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by name or create_time. - * @param {google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest.SpokeView} request.view - * The view of the spoke to return. - * The view that you use determines which spoke fields are included in the - * response. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1beta.Spoke|Spoke} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listHubSpokesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listHubSpokes`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the hub. + * @param {string[]} request.spokeLocations + * A list of locations. + * Specify one of the following: `[global]`, a single region (for + * example, `[us-central1]`), or a combination of + * values (for example, `[global, us-central1, us-west1]`). + * If the spoke_locations field is populated, the list of results + * includes only spokes in the specified location. + * If the spoke_locations field is not populated, the list of results + * includes spokes in all locations. + * @param {number} request.pageSize + * The maximum number of results to return per page. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by name or create_time. + * @param {google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest.SpokeView} request.view + * The view of the spoke to return. + * The view that you use determines which spoke fields are included in the + * response. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1beta.Spoke|Spoke} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listHubSpokesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listHubSpokesStream( - request?: protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesRequest, + options?: CallOptions, + ): Transform { request = request || {}; 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 ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); const defaultCallSettings = this._defaults['listHubSpokes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listHubSpokes stream %j', request); return this.descriptors.page.listHubSpokes.createStream( this.innerApiCalls.listHubSpokes as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listHubSpokes`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the hub. - * @param {string[]} request.spokeLocations - * A list of locations. - * Specify one of the following: `[global]`, a single region (for - * example, `[us-central1]`), or a combination of - * values (for example, `[global, us-central1, us-west1]`). - * If the spoke_locations field is populated, the list of results - * includes only spokes in the specified location. - * If the spoke_locations field is not populated, the list of results - * includes spokes in all locations. - * @param {number} request.pageSize - * The maximum number of results to return per page. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by name or create_time. - * @param {google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest.SpokeView} request.view - * The view of the spoke to return. - * The view that you use determines which spoke fields are included in the - * response. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1beta.Spoke|Spoke}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/hub_service.list_hub_spokes.js - * region_tag:networkconnectivity_v1beta_generated_HubService_ListHubSpokes_async - */ + /** + * Equivalent to `listHubSpokes`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the hub. + * @param {string[]} request.spokeLocations + * A list of locations. + * Specify one of the following: `[global]`, a single region (for + * example, `[us-central1]`), or a combination of + * values (for example, `[global, us-central1, us-west1]`). + * If the spoke_locations field is populated, the list of results + * includes only spokes in the specified location. + * If the spoke_locations field is not populated, the list of results + * includes spokes in all locations. + * @param {number} request.pageSize + * The maximum number of results to return per page. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by name or create_time. + * @param {google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest.SpokeView} request.view + * The view of the spoke to return. + * The view that you use determines which spoke fields are included in the + * response. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1beta.Spoke|Spoke}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/hub_service.list_hub_spokes.js + * region_tag:networkconnectivity_v1beta_generated_HubService_ListHubSpokes_async + */ listHubSpokesAsync( - request?: protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1beta.IListHubSpokesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; 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 ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); const defaultCallSettings = this._defaults['listHubSpokes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listHubSpokes iterate %j', request); return this.descriptors.page.listHubSpokes.asyncIterate( this.innerApiCalls['listHubSpokes'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Query the Private Service Connect propagation status of a Network - * Connectivity Center hub. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the hub. - * @param {number} [request.pageSize] - * Optional. The maximum number of results to return per page. - * @param {string} [request.pageToken] - * Optional. The page token. - * @param {string} [request.filter] - * Optional. An expression that filters the list of results. - * The filter can be used to filter the results by the following fields: - * * `psc_propagation_status.source_spoke` - * * `psc_propagation_status.source_group` - * * `psc_propagation_status.source_forwarding_rule` - * * `psc_propagation_status.target_spoke` - * * `psc_propagation_status.target_group` - * * `psc_propagation_status.code` - * * `psc_propagation_status.message` - * @param {string} [request.orderBy] - * Optional. Sort the results in ascending order by the specified fields. - * A comma-separated list of any of these fields: - * * `psc_propagation_status.source_spoke` - * * `psc_propagation_status.source_group` - * * `psc_propagation_status.source_forwarding_rule` - * * `psc_propagation_status.target_spoke` - * * `psc_propagation_status.target_group` - * * `psc_propagation_status.code` - * If `group_by` is set, the value of the `order_by` field must be the - * same as or a subset of the `group_by` field. - * @param {string} [request.groupBy] - * Optional. Aggregate the results by the specified fields. - * A comma-separated list of any of these fields: - * * `psc_propagation_status.source_spoke` - * * `psc_propagation_status.source_group` - * * `psc_propagation_status.source_forwarding_rule` - * * `psc_propagation_status.target_spoke` - * * `psc_propagation_status.target_group` - * * `psc_propagation_status.code` - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry|HubStatusEntry}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `queryHubStatusAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Query the Private Service Connect propagation status of a Network + * Connectivity Center hub. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the hub. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return per page. + * @param {string} [request.pageToken] + * Optional. The page token. + * @param {string} [request.filter] + * Optional. An expression that filters the list of results. + * The filter can be used to filter the results by the following fields: + * * `psc_propagation_status.source_spoke` + * * `psc_propagation_status.source_group` + * * `psc_propagation_status.source_forwarding_rule` + * * `psc_propagation_status.target_spoke` + * * `psc_propagation_status.target_group` + * * `psc_propagation_status.code` + * * `psc_propagation_status.message` + * @param {string} [request.orderBy] + * Optional. Sort the results in ascending order by the specified fields. + * A comma-separated list of any of these fields: + * * `psc_propagation_status.source_spoke` + * * `psc_propagation_status.source_group` + * * `psc_propagation_status.source_forwarding_rule` + * * `psc_propagation_status.target_spoke` + * * `psc_propagation_status.target_group` + * * `psc_propagation_status.code` + * If `group_by` is set, the value of the `order_by` field must be the + * same as or a subset of the `group_by` field. + * @param {string} [request.groupBy] + * Optional. Aggregate the results by the specified fields. + * A comma-separated list of any of these fields: + * * `psc_propagation_status.source_spoke` + * * `psc_propagation_status.source_group` + * * `psc_propagation_status.source_forwarding_rule` + * * `psc_propagation_status.target_spoke` + * * `psc_propagation_status.target_group` + * * `psc_propagation_status.code` + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry|HubStatusEntry}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `queryHubStatusAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ queryHubStatus( - request?: protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IHubStatusEntry[], - protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IHubStatusEntry[], + protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusResponse, + ] + >; queryHubStatus( - request: protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusRequest, - protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IHubStatusEntry>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusRequest, + | protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IHubStatusEntry + >, + ): void; queryHubStatus( - request: protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusRequest, - protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IHubStatusEntry>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusRequest, + | protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IHubStatusEntry + >, + ): void; queryHubStatus( - request?: protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusRequest, - protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IHubStatusEntry>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusRequest, - protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IHubStatusEntry>): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IHubStatusEntry[], - protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IHubStatusEntry + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusRequest, + | protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IHubStatusEntry + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IHubStatusEntry[], + protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusRequest, - protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IHubStatusEntry>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusRequest, + | protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IHubStatusEntry + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('queryHubStatus values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -3447,254 +4942,283 @@ export class HubServiceClient { this._log.info('queryHubStatus request %j', request); return this.innerApiCalls .queryHubStatus(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1beta.IHubStatusEntry[], - protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusResponse - ]) => { - this._log.info('queryHubStatus values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1beta.IHubStatusEntry[], + protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusResponse, + ]) => { + this._log.info('queryHubStatus values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `queryHubStatus`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the hub. - * @param {number} [request.pageSize] - * Optional. The maximum number of results to return per page. - * @param {string} [request.pageToken] - * Optional. The page token. - * @param {string} [request.filter] - * Optional. An expression that filters the list of results. - * The filter can be used to filter the results by the following fields: - * * `psc_propagation_status.source_spoke` - * * `psc_propagation_status.source_group` - * * `psc_propagation_status.source_forwarding_rule` - * * `psc_propagation_status.target_spoke` - * * `psc_propagation_status.target_group` - * * `psc_propagation_status.code` - * * `psc_propagation_status.message` - * @param {string} [request.orderBy] - * Optional. Sort the results in ascending order by the specified fields. - * A comma-separated list of any of these fields: - * * `psc_propagation_status.source_spoke` - * * `psc_propagation_status.source_group` - * * `psc_propagation_status.source_forwarding_rule` - * * `psc_propagation_status.target_spoke` - * * `psc_propagation_status.target_group` - * * `psc_propagation_status.code` - * If `group_by` is set, the value of the `order_by` field must be the - * same as or a subset of the `group_by` field. - * @param {string} [request.groupBy] - * Optional. Aggregate the results by the specified fields. - * A comma-separated list of any of these fields: - * * `psc_propagation_status.source_spoke` - * * `psc_propagation_status.source_group` - * * `psc_propagation_status.source_forwarding_rule` - * * `psc_propagation_status.target_spoke` - * * `psc_propagation_status.target_group` - * * `psc_propagation_status.code` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry|HubStatusEntry} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `queryHubStatusAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `queryHubStatus`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the hub. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return per page. + * @param {string} [request.pageToken] + * Optional. The page token. + * @param {string} [request.filter] + * Optional. An expression that filters the list of results. + * The filter can be used to filter the results by the following fields: + * * `psc_propagation_status.source_spoke` + * * `psc_propagation_status.source_group` + * * `psc_propagation_status.source_forwarding_rule` + * * `psc_propagation_status.target_spoke` + * * `psc_propagation_status.target_group` + * * `psc_propagation_status.code` + * * `psc_propagation_status.message` + * @param {string} [request.orderBy] + * Optional. Sort the results in ascending order by the specified fields. + * A comma-separated list of any of these fields: + * * `psc_propagation_status.source_spoke` + * * `psc_propagation_status.source_group` + * * `psc_propagation_status.source_forwarding_rule` + * * `psc_propagation_status.target_spoke` + * * `psc_propagation_status.target_group` + * * `psc_propagation_status.code` + * If `group_by` is set, the value of the `order_by` field must be the + * same as or a subset of the `group_by` field. + * @param {string} [request.groupBy] + * Optional. Aggregate the results by the specified fields. + * A comma-separated list of any of these fields: + * * `psc_propagation_status.source_spoke` + * * `psc_propagation_status.source_group` + * * `psc_propagation_status.source_forwarding_rule` + * * `psc_propagation_status.target_spoke` + * * `psc_propagation_status.target_group` + * * `psc_propagation_status.code` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry|HubStatusEntry} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `queryHubStatusAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ queryHubStatusStream( - request?: protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusRequest, + options?: CallOptions, + ): Transform { request = request || {}; 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 ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); const defaultCallSettings = this._defaults['queryHubStatus']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('queryHubStatus stream %j', request); return this.descriptors.page.queryHubStatus.createStream( this.innerApiCalls.queryHubStatus as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `queryHubStatus`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the hub. - * @param {number} [request.pageSize] - * Optional. The maximum number of results to return per page. - * @param {string} [request.pageToken] - * Optional. The page token. - * @param {string} [request.filter] - * Optional. An expression that filters the list of results. - * The filter can be used to filter the results by the following fields: - * * `psc_propagation_status.source_spoke` - * * `psc_propagation_status.source_group` - * * `psc_propagation_status.source_forwarding_rule` - * * `psc_propagation_status.target_spoke` - * * `psc_propagation_status.target_group` - * * `psc_propagation_status.code` - * * `psc_propagation_status.message` - * @param {string} [request.orderBy] - * Optional. Sort the results in ascending order by the specified fields. - * A comma-separated list of any of these fields: - * * `psc_propagation_status.source_spoke` - * * `psc_propagation_status.source_group` - * * `psc_propagation_status.source_forwarding_rule` - * * `psc_propagation_status.target_spoke` - * * `psc_propagation_status.target_group` - * * `psc_propagation_status.code` - * If `group_by` is set, the value of the `order_by` field must be the - * same as or a subset of the `group_by` field. - * @param {string} [request.groupBy] - * Optional. Aggregate the results by the specified fields. - * A comma-separated list of any of these fields: - * * `psc_propagation_status.source_spoke` - * * `psc_propagation_status.source_group` - * * `psc_propagation_status.source_forwarding_rule` - * * `psc_propagation_status.target_spoke` - * * `psc_propagation_status.target_group` - * * `psc_propagation_status.code` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry|HubStatusEntry}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/hub_service.query_hub_status.js - * region_tag:networkconnectivity_v1beta_generated_HubService_QueryHubStatus_async - */ + /** + * Equivalent to `queryHubStatus`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the hub. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return per page. + * @param {string} [request.pageToken] + * Optional. The page token. + * @param {string} [request.filter] + * Optional. An expression that filters the list of results. + * The filter can be used to filter the results by the following fields: + * * `psc_propagation_status.source_spoke` + * * `psc_propagation_status.source_group` + * * `psc_propagation_status.source_forwarding_rule` + * * `psc_propagation_status.target_spoke` + * * `psc_propagation_status.target_group` + * * `psc_propagation_status.code` + * * `psc_propagation_status.message` + * @param {string} [request.orderBy] + * Optional. Sort the results in ascending order by the specified fields. + * A comma-separated list of any of these fields: + * * `psc_propagation_status.source_spoke` + * * `psc_propagation_status.source_group` + * * `psc_propagation_status.source_forwarding_rule` + * * `psc_propagation_status.target_spoke` + * * `psc_propagation_status.target_group` + * * `psc_propagation_status.code` + * If `group_by` is set, the value of the `order_by` field must be the + * same as or a subset of the `group_by` field. + * @param {string} [request.groupBy] + * Optional. Aggregate the results by the specified fields. + * A comma-separated list of any of these fields: + * * `psc_propagation_status.source_spoke` + * * `psc_propagation_status.source_group` + * * `psc_propagation_status.source_forwarding_rule` + * * `psc_propagation_status.target_spoke` + * * `psc_propagation_status.target_group` + * * `psc_propagation_status.code` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry|HubStatusEntry}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/hub_service.query_hub_status.js + * region_tag:networkconnectivity_v1beta_generated_HubService_QueryHubStatus_async + */ queryHubStatusAsync( - request?: protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1beta.IQueryHubStatusRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; 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 ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); const defaultCallSettings = this._defaults['queryHubStatus']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('queryHubStatus iterate %j', request); return this.descriptors.page.queryHubStatus.asyncIterate( this.innerApiCalls['queryHubStatus'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists the Network Connectivity Center spokes in a specified project and - * location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource. - * @param {number} request.pageSize - * The maximum number of results to return per page. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1beta.Spoke|Spoke}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listSpokesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists the Network Connectivity Center spokes in a specified project and + * location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource. + * @param {number} request.pageSize + * The maximum number of results to return per page. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1beta.Spoke|Spoke}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listSpokesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listSpokes( - request?: protos.google.cloud.networkconnectivity.v1beta.IListSpokesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.ISpoke[], - protos.google.cloud.networkconnectivity.v1beta.IListSpokesRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListSpokesResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IListSpokesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.ISpoke[], + protos.google.cloud.networkconnectivity.v1beta.IListSpokesRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListSpokesResponse, + ] + >; listSpokes( - request: protos.google.cloud.networkconnectivity.v1beta.IListSpokesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListSpokesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListSpokesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.ISpoke>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IListSpokesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListSpokesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListSpokesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.ISpoke + >, + ): void; listSpokes( - request: protos.google.cloud.networkconnectivity.v1beta.IListSpokesRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListSpokesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListSpokesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.ISpoke>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IListSpokesRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListSpokesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListSpokesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.ISpoke + >, + ): void; listSpokes( - request?: protos.google.cloud.networkconnectivity.v1beta.IListSpokesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListSpokesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListSpokesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.ISpoke>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1beta.IListSpokesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1beta.IListSpokesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListSpokesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.ISpoke>): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.ISpoke[], - protos.google.cloud.networkconnectivity.v1beta.IListSpokesRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListSpokesResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1beta.IListSpokesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.ISpoke + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListSpokesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListSpokesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.ISpoke + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.ISpoke[], + protos.google.cloud.networkconnectivity.v1beta.IListSpokesRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListSpokesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListSpokesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListSpokesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.ISpoke>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListSpokesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListSpokesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.ISpoke + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listSpokes values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -3703,201 +5227,230 @@ export class HubServiceClient { this._log.info('listSpokes request %j', request); return this.innerApiCalls .listSpokes(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1beta.ISpoke[], - protos.google.cloud.networkconnectivity.v1beta.IListSpokesRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListSpokesResponse - ]) => { - this._log.info('listSpokes values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1beta.ISpoke[], + protos.google.cloud.networkconnectivity.v1beta.IListSpokesRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListSpokesResponse, + ]) => { + this._log.info('listSpokes values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listSpokes`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource. - * @param {number} request.pageSize - * The maximum number of results to return per page. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1beta.Spoke|Spoke} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listSpokesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listSpokes`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource. + * @param {number} request.pageSize + * The maximum number of results to return per page. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1beta.Spoke|Spoke} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listSpokesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listSpokesStream( - request?: protos.google.cloud.networkconnectivity.v1beta.IListSpokesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1beta.IListSpokesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listSpokes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listSpokes stream %j', request); return this.descriptors.page.listSpokes.createStream( this.innerApiCalls.listSpokes as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listSpokes`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource. - * @param {number} request.pageSize - * The maximum number of results to return per page. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1beta.Spoke|Spoke}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/hub_service.list_spokes.js - * region_tag:networkconnectivity_v1beta_generated_HubService_ListSpokes_async - */ + /** + * Equivalent to `listSpokes`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource. + * @param {number} request.pageSize + * The maximum number of results to return per page. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1beta.Spoke|Spoke}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/hub_service.list_spokes.js + * region_tag:networkconnectivity_v1beta_generated_HubService_ListSpokes_async + */ listSpokesAsync( - request?: protos.google.cloud.networkconnectivity.v1beta.IListSpokesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1beta.IListSpokesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listSpokes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listSpokes iterate %j', request); return this.descriptors.page.listSpokes.asyncIterate( this.innerApiCalls['listSpokes'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists routes in a given route table. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results to return per page. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1beta.Route|Route}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listRoutesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists routes in a given route table. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results to return per page. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1beta.Route|Route}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listRoutesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listRoutes( - request?: protos.google.cloud.networkconnectivity.v1beta.IListRoutesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IRoute[], - protos.google.cloud.networkconnectivity.v1beta.IListRoutesRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListRoutesResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IListRoutesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IRoute[], + protos.google.cloud.networkconnectivity.v1beta.IListRoutesRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListRoutesResponse, + ] + >; listRoutes( - request: protos.google.cloud.networkconnectivity.v1beta.IListRoutesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListRoutesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListRoutesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IRoute>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IListRoutesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListRoutesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListRoutesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IRoute + >, + ): void; listRoutes( - request: protos.google.cloud.networkconnectivity.v1beta.IListRoutesRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListRoutesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListRoutesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IRoute>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IListRoutesRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListRoutesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListRoutesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IRoute + >, + ): void; listRoutes( - request?: protos.google.cloud.networkconnectivity.v1beta.IListRoutesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListRoutesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListRoutesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IRoute>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1beta.IListRoutesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1beta.IListRoutesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListRoutesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IRoute>): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IRoute[], - protos.google.cloud.networkconnectivity.v1beta.IListRoutesRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListRoutesResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1beta.IListRoutesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IRoute + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListRoutesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListRoutesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IRoute + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IRoute[], + protos.google.cloud.networkconnectivity.v1beta.IListRoutesRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListRoutesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListRoutesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListRoutesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IRoute>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListRoutesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListRoutesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IRoute + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listRoutes values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -3906,201 +5459,230 @@ export class HubServiceClient { this._log.info('listRoutes request %j', request); return this.innerApiCalls .listRoutes(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1beta.IRoute[], - protos.google.cloud.networkconnectivity.v1beta.IListRoutesRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListRoutesResponse - ]) => { - this._log.info('listRoutes values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1beta.IRoute[], + protos.google.cloud.networkconnectivity.v1beta.IListRoutesRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListRoutesResponse, + ]) => { + this._log.info('listRoutes values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listRoutes`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results to return per page. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1beta.Route|Route} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listRoutesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listRoutes`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results to return per page. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1beta.Route|Route} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listRoutesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listRoutesStream( - request?: protos.google.cloud.networkconnectivity.v1beta.IListRoutesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1beta.IListRoutesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listRoutes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listRoutes stream %j', request); return this.descriptors.page.listRoutes.createStream( this.innerApiCalls.listRoutes as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listRoutes`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results to return per page. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1beta.Route|Route}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/hub_service.list_routes.js - * region_tag:networkconnectivity_v1beta_generated_HubService_ListRoutes_async - */ + /** + * Equivalent to `listRoutes`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results to return per page. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1beta.Route|Route}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/hub_service.list_routes.js + * region_tag:networkconnectivity_v1beta_generated_HubService_ListRoutes_async + */ listRoutesAsync( - request?: protos.google.cloud.networkconnectivity.v1beta.IListRoutesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1beta.IListRoutesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listRoutes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listRoutes iterate %j', request); return this.descriptors.page.listRoutes.asyncIterate( this.innerApiCalls['listRoutes'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists route tables in a given hub. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results to return per page. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1beta.RouteTable|RouteTable}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listRouteTablesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists route tables in a given hub. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results to return per page. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1beta.RouteTable|RouteTable}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listRouteTablesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listRouteTables( - request?: protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IRouteTable[], - protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IRouteTable[], + protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesResponse, + ] + >; listRouteTables( - request: protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IRouteTable>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IRouteTable + >, + ): void; listRouteTables( - request: protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IRouteTable>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IRouteTable + >, + ): void; listRouteTables( - request?: protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IRouteTable>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IRouteTable>): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IRouteTable[], - protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IRouteTable + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IRouteTable + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IRouteTable[], + protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IRouteTable>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IRouteTable + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listRouteTables values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -4109,201 +5691,230 @@ export class HubServiceClient { this._log.info('listRouteTables request %j', request); return this.innerApiCalls .listRouteTables(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1beta.IRouteTable[], - protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesResponse - ]) => { - this._log.info('listRouteTables values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1beta.IRouteTable[], + protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesResponse, + ]) => { + this._log.info('listRouteTables values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listRouteTables`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results to return per page. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1beta.RouteTable|RouteTable} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listRouteTablesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listRouteTables`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results to return per page. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1beta.RouteTable|RouteTable} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listRouteTablesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listRouteTablesStream( - request?: protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listRouteTables']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listRouteTables stream %j', request); return this.descriptors.page.listRouteTables.createStream( this.innerApiCalls.listRouteTables as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listRouteTables`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results to return per page. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1beta.RouteTable|RouteTable}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/hub_service.list_route_tables.js - * region_tag:networkconnectivity_v1beta_generated_HubService_ListRouteTables_async - */ + /** + * Equivalent to `listRouteTables`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results to return per page. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1beta.RouteTable|RouteTable}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/hub_service.list_route_tables.js + * region_tag:networkconnectivity_v1beta_generated_HubService_ListRouteTables_async + */ listRouteTablesAsync( - request?: protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1beta.IListRouteTablesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listRouteTables']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listRouteTables iterate %j', request); return this.descriptors.page.listRouteTables.asyncIterate( this.innerApiCalls['listRouteTables'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists groups in a given hub. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results to return per page. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1beta.Group|Group}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listGroupsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists groups in a given hub. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results to return per page. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1beta.Group|Group}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listGroupsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listGroups( - request?: protos.google.cloud.networkconnectivity.v1beta.IListGroupsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IGroup[], - protos.google.cloud.networkconnectivity.v1beta.IListGroupsRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListGroupsResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IListGroupsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IGroup[], + protos.google.cloud.networkconnectivity.v1beta.IListGroupsRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListGroupsResponse, + ] + >; listGroups( - request: protos.google.cloud.networkconnectivity.v1beta.IListGroupsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListGroupsRequest, - protos.google.cloud.networkconnectivity.v1beta.IListGroupsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IGroup>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IListGroupsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListGroupsRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListGroupsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IGroup + >, + ): void; listGroups( - request: protos.google.cloud.networkconnectivity.v1beta.IListGroupsRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListGroupsRequest, - protos.google.cloud.networkconnectivity.v1beta.IListGroupsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IGroup>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IListGroupsRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListGroupsRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListGroupsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IGroup + >, + ): void; listGroups( - request?: protos.google.cloud.networkconnectivity.v1beta.IListGroupsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListGroupsRequest, - protos.google.cloud.networkconnectivity.v1beta.IListGroupsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IGroup>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1beta.IListGroupsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1beta.IListGroupsRequest, - protos.google.cloud.networkconnectivity.v1beta.IListGroupsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IGroup>): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IGroup[], - protos.google.cloud.networkconnectivity.v1beta.IListGroupsRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListGroupsResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1beta.IListGroupsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IGroup + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListGroupsRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListGroupsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IGroup + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IGroup[], + protos.google.cloud.networkconnectivity.v1beta.IListGroupsRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListGroupsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListGroupsRequest, - protos.google.cloud.networkconnectivity.v1beta.IListGroupsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IGroup>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListGroupsRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListGroupsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IGroup + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listGroups values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -4312,207 +5923,236 @@ export class HubServiceClient { this._log.info('listGroups request %j', request); return this.innerApiCalls .listGroups(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1beta.IGroup[], - protos.google.cloud.networkconnectivity.v1beta.IListGroupsRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListGroupsResponse - ]) => { - this._log.info('listGroups values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1beta.IGroup[], + protos.google.cloud.networkconnectivity.v1beta.IListGroupsRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListGroupsResponse, + ]) => { + this._log.info('listGroups values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listGroups`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results to return per page. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1beta.Group|Group} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listGroupsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listGroups`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results to return per page. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1beta.Group|Group} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listGroupsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listGroupsStream( - request?: protos.google.cloud.networkconnectivity.v1beta.IListGroupsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1beta.IListGroupsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listGroups']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listGroups stream %j', request); return this.descriptors.page.listGroups.createStream( this.innerApiCalls.listGroups as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listGroups`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results to return per page. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1beta.Group|Group}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/hub_service.list_groups.js - * region_tag:networkconnectivity_v1beta_generated_HubService_ListGroups_async - */ + /** + * Equivalent to `listGroups`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results to return per page. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1beta.Group|Group}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/hub_service.list_groups.js + * region_tag:networkconnectivity_v1beta_generated_HubService_ListGroups_async + */ listGroupsAsync( - request?: protos.google.cloud.networkconnectivity.v1beta.IListGroupsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1beta.IListGroupsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listGroups']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listGroups iterate %j', request); return this.descriptors.page.listGroups.asyncIterate( this.innerApiCalls['listGroups'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * List GatewayAdvertisedRoutes - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} [request.pageSize] - * Optional. The maximum number of results per page that should be returned. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * `ListGatewayAdvertisedRoutes` call. Provide this to retrieve the subsequent - * page. - * - * When paginating, all other parameters provided to - * `ListGatewayAdvertisedRoutes` must match the call that provided the page - * token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute|GatewayAdvertisedRoute}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listGatewayAdvertisedRoutesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * List GatewayAdvertisedRoutes + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} [request.pageSize] + * Optional. The maximum number of results per page that should be returned. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * `ListGatewayAdvertisedRoutes` call. Provide this to retrieve the subsequent + * page. + * + * When paginating, all other parameters provided to + * `ListGatewayAdvertisedRoutes` must match the call that provided the page + * token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute|GatewayAdvertisedRoute}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listGatewayAdvertisedRoutesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listGatewayAdvertisedRoutes( - request?: protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute[], - protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute[], + protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesResponse, + ] + >; listGatewayAdvertisedRoutes( - request: protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute + >, + ): void; listGatewayAdvertisedRoutes( - request: protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute + >, + ): void; listGatewayAdvertisedRoutes( - request?: protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute>): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute[], - protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute[], + protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listGatewayAdvertisedRoutes values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -4521,153 +6161,157 @@ export class HubServiceClient { this._log.info('listGatewayAdvertisedRoutes request %j', request); return this.innerApiCalls .listGatewayAdvertisedRoutes(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute[], - protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesResponse - ]) => { - this._log.info('listGatewayAdvertisedRoutes values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute[], + protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesResponse, + ]) => { + this._log.info('listGatewayAdvertisedRoutes values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listGatewayAdvertisedRoutes`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} [request.pageSize] - * Optional. The maximum number of results per page that should be returned. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * `ListGatewayAdvertisedRoutes` call. Provide this to retrieve the subsequent - * page. - * - * When paginating, all other parameters provided to - * `ListGatewayAdvertisedRoutes` must match the call that provided the page - * token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute|GatewayAdvertisedRoute} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listGatewayAdvertisedRoutesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listGatewayAdvertisedRoutes`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} [request.pageSize] + * Optional. The maximum number of results per page that should be returned. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * `ListGatewayAdvertisedRoutes` call. Provide this to retrieve the subsequent + * page. + * + * When paginating, all other parameters provided to + * `ListGatewayAdvertisedRoutes` must match the call that provided the page + * token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute|GatewayAdvertisedRoute} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listGatewayAdvertisedRoutesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listGatewayAdvertisedRoutesStream( - request?: protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listGatewayAdvertisedRoutes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listGatewayAdvertisedRoutes stream %j', request); return this.descriptors.page.listGatewayAdvertisedRoutes.createStream( this.innerApiCalls.listGatewayAdvertisedRoutes as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listGatewayAdvertisedRoutes`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} [request.pageSize] - * Optional. The maximum number of results per page that should be returned. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * `ListGatewayAdvertisedRoutes` call. Provide this to retrieve the subsequent - * page. - * - * When paginating, all other parameters provided to - * `ListGatewayAdvertisedRoutes` must match the call that provided the page - * token. - * @param {string} request.filter - * An expression that filters the list of results. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute|GatewayAdvertisedRoute}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/hub_service.list_gateway_advertised_routes.js - * region_tag:networkconnectivity_v1beta_generated_HubService_ListGatewayAdvertisedRoutes_async - */ + /** + * Equivalent to `listGatewayAdvertisedRoutes`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} [request.pageSize] + * Optional. The maximum number of results per page that should be returned. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * `ListGatewayAdvertisedRoutes` call. Provide this to retrieve the subsequent + * page. + * + * When paginating, all other parameters provided to + * `ListGatewayAdvertisedRoutes` must match the call that provided the page + * token. + * @param {string} request.filter + * An expression that filters the list of results. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute|GatewayAdvertisedRoute}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/hub_service.list_gateway_advertised_routes.js + * region_tag:networkconnectivity_v1beta_generated_HubService_ListGatewayAdvertisedRoutes_async + */ listGatewayAdvertisedRoutesAsync( - request?: protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1beta.IListGatewayAdvertisedRoutesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listGatewayAdvertisedRoutes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listGatewayAdvertisedRoutes iterate %j', request); return this.descriptors.page.listGatewayAdvertisedRoutes.asyncIterate( this.innerApiCalls['listGatewayAdvertisedRoutes'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -4681,40 +6325,40 @@ export class HubServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -4728,41 +6372,41 @@ export class HubServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -4776,12 +6420,12 @@ export class HubServiceClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -4816,12 +6460,11 @@ export class HubServiceClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -4854,12 +6497,12 @@ export class HubServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -4902,22 +6545,22 @@ export class HubServiceClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -4952,15 +6595,15 @@ export class HubServiceClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - 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 ?? '', - }); + 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 ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -4994,7 +6637,7 @@ export class HubServiceClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -5007,25 +6650,24 @@ export class HubServiceClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -5064,22 +6706,22 @@ export class HubServiceClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -5096,7 +6738,12 @@ export class HubServiceClient { * @param {string} destination * @returns {string} Resource name string. */ - destinationPath(project:string,location:string,multicloudDataTransferConfig:string,destination:string) { + destinationPath( + project: string, + location: string, + multicloudDataTransferConfig: string, + destination: string, + ) { return this.pathTemplates.destinationPathTemplate.render({ project: project, location: location, @@ -5113,7 +6760,8 @@ export class HubServiceClient { * @returns {string} A string representing the project. */ matchProjectFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).project; + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .project; } /** @@ -5124,7 +6772,8 @@ export class HubServiceClient { * @returns {string} A string representing the location. */ matchLocationFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).location; + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .location; } /** @@ -5134,8 +6783,11 @@ export class HubServiceClient { * A fully-qualified path representing Destination resource. * @returns {string} A string representing the multicloud_data_transfer_config. */ - matchMulticloudDataTransferConfigFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).multicloud_data_transfer_config; + matchMulticloudDataTransferConfigFromDestinationName( + destinationName: string, + ) { + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .multicloud_data_transfer_config; } /** @@ -5146,7 +6798,8 @@ export class HubServiceClient { * @returns {string} A string representing the destination. */ matchDestinationFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).destination; + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .destination; } /** @@ -5158,7 +6811,12 @@ export class HubServiceClient { * @param {string} gateway_advertised_route * @returns {string} Resource name string. */ - gatewayAdvertisedRoutePath(project:string,location:string,spoke:string,gatewayAdvertisedRoute:string) { + gatewayAdvertisedRoutePath( + project: string, + location: string, + spoke: string, + gatewayAdvertisedRoute: string, + ) { return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.render({ project: project, location: location, @@ -5174,8 +6832,12 @@ export class HubServiceClient { * A fully-qualified path representing GatewayAdvertisedRoute resource. * @returns {string} A string representing the project. */ - matchProjectFromGatewayAdvertisedRouteName(gatewayAdvertisedRouteName: string) { - return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match(gatewayAdvertisedRouteName).project; + matchProjectFromGatewayAdvertisedRouteName( + gatewayAdvertisedRouteName: string, + ) { + return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match( + gatewayAdvertisedRouteName, + ).project; } /** @@ -5185,8 +6847,12 @@ export class HubServiceClient { * A fully-qualified path representing GatewayAdvertisedRoute resource. * @returns {string} A string representing the location. */ - matchLocationFromGatewayAdvertisedRouteName(gatewayAdvertisedRouteName: string) { - return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match(gatewayAdvertisedRouteName).location; + matchLocationFromGatewayAdvertisedRouteName( + gatewayAdvertisedRouteName: string, + ) { + return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match( + gatewayAdvertisedRouteName, + ).location; } /** @@ -5197,7 +6863,9 @@ export class HubServiceClient { * @returns {string} A string representing the spoke. */ matchSpokeFromGatewayAdvertisedRouteName(gatewayAdvertisedRouteName: string) { - return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match(gatewayAdvertisedRouteName).spoke; + return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match( + gatewayAdvertisedRouteName, + ).spoke; } /** @@ -5207,8 +6875,12 @@ export class HubServiceClient { * A fully-qualified path representing GatewayAdvertisedRoute resource. * @returns {string} A string representing the gateway_advertised_route. */ - matchGatewayAdvertisedRouteFromGatewayAdvertisedRouteName(gatewayAdvertisedRouteName: string) { - return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match(gatewayAdvertisedRouteName).gateway_advertised_route; + matchGatewayAdvertisedRouteFromGatewayAdvertisedRouteName( + gatewayAdvertisedRouteName: string, + ) { + return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match( + gatewayAdvertisedRouteName, + ).gateway_advertised_route; } /** @@ -5219,7 +6891,7 @@ export class HubServiceClient { * @param {string} group * @returns {string} Resource name string. */ - groupPath(project:string,hub:string,group:string) { + groupPath(project: string, hub: string, group: string) { return this.pathTemplates.groupPathTemplate.render({ project: project, hub: hub, @@ -5267,7 +6939,7 @@ export class HubServiceClient { * @param {string} hub * @returns {string} Resource name string. */ - hubPath(project:string,hub:string) { + hubPath(project: string, hub: string) { return this.pathTemplates.hubPathTemplate.render({ project: project, hub: hub, @@ -5305,7 +6977,12 @@ export class HubServiceClient { * @param {string} route * @returns {string} Resource name string. */ - hubRoutePath(project:string,hub:string,routeTable:string,route:string) { + hubRoutePath( + project: string, + hub: string, + routeTable: string, + route: string, + ) { return this.pathTemplates.hubRoutePathTemplate.render({ project: project, hub: hub, @@ -5344,7 +7021,8 @@ export class HubServiceClient { * @returns {string} A string representing the route_table. */ matchRouteTableFromHubRouteName(hubRouteName: string) { - return this.pathTemplates.hubRoutePathTemplate.match(hubRouteName).route_table; + return this.pathTemplates.hubRoutePathTemplate.match(hubRouteName) + .route_table; } /** @@ -5366,7 +7044,7 @@ export class HubServiceClient { * @param {string} instance * @returns {string} Resource name string. */ - instancePath(project:string,zone:string,instance:string) { + instancePath(project: string, zone: string, instance: string) { return this.pathTemplates.instancePathTemplate.render({ project: project, zone: zone, @@ -5415,7 +7093,11 @@ export class HubServiceClient { * @param {string} resource_id * @returns {string} Resource name string. */ - interconnectAttachmentPath(project:string,region:string,resourceId:string) { + interconnectAttachmentPath( + project: string, + region: string, + resourceId: string, + ) { return this.pathTemplates.interconnectAttachmentPathTemplate.render({ project: project, region: region, @@ -5430,8 +7112,12 @@ export class HubServiceClient { * A fully-qualified path representing InterconnectAttachment resource. * @returns {string} A string representing the project. */ - matchProjectFromInterconnectAttachmentName(interconnectAttachmentName: string) { - return this.pathTemplates.interconnectAttachmentPathTemplate.match(interconnectAttachmentName).project; + matchProjectFromInterconnectAttachmentName( + interconnectAttachmentName: string, + ) { + return this.pathTemplates.interconnectAttachmentPathTemplate.match( + interconnectAttachmentName, + ).project; } /** @@ -5441,8 +7127,12 @@ export class HubServiceClient { * A fully-qualified path representing InterconnectAttachment resource. * @returns {string} A string representing the region. */ - matchRegionFromInterconnectAttachmentName(interconnectAttachmentName: string) { - return this.pathTemplates.interconnectAttachmentPathTemplate.match(interconnectAttachmentName).region; + matchRegionFromInterconnectAttachmentName( + interconnectAttachmentName: string, + ) { + return this.pathTemplates.interconnectAttachmentPathTemplate.match( + interconnectAttachmentName, + ).region; } /** @@ -5452,8 +7142,12 @@ export class HubServiceClient { * A fully-qualified path representing InterconnectAttachment resource. * @returns {string} A string representing the resource_id. */ - matchResourceIdFromInterconnectAttachmentName(interconnectAttachmentName: string) { - return this.pathTemplates.interconnectAttachmentPathTemplate.match(interconnectAttachmentName).resource_id; + matchResourceIdFromInterconnectAttachmentName( + interconnectAttachmentName: string, + ) { + return this.pathTemplates.interconnectAttachmentPathTemplate.match( + interconnectAttachmentName, + ).resource_id; } /** @@ -5463,7 +7157,7 @@ export class HubServiceClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -5500,7 +7194,11 @@ export class HubServiceClient { * @param {string} multicloud_data_transfer_config * @returns {string} Resource name string. */ - multicloudDataTransferConfigPath(project:string,location:string,multicloudDataTransferConfig:string) { + multicloudDataTransferConfigPath( + project: string, + location: string, + multicloudDataTransferConfig: string, + ) { return this.pathTemplates.multicloudDataTransferConfigPathTemplate.render({ project: project, location: location, @@ -5515,8 +7213,12 @@ export class HubServiceClient { * A fully-qualified path representing MulticloudDataTransferConfig resource. * @returns {string} A string representing the project. */ - matchProjectFromMulticloudDataTransferConfigName(multicloudDataTransferConfigName: string) { - return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match(multicloudDataTransferConfigName).project; + matchProjectFromMulticloudDataTransferConfigName( + multicloudDataTransferConfigName: string, + ) { + return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match( + multicloudDataTransferConfigName, + ).project; } /** @@ -5526,8 +7228,12 @@ export class HubServiceClient { * A fully-qualified path representing MulticloudDataTransferConfig resource. * @returns {string} A string representing the location. */ - matchLocationFromMulticloudDataTransferConfigName(multicloudDataTransferConfigName: string) { - return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match(multicloudDataTransferConfigName).location; + matchLocationFromMulticloudDataTransferConfigName( + multicloudDataTransferConfigName: string, + ) { + return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match( + multicloudDataTransferConfigName, + ).location; } /** @@ -5537,8 +7243,12 @@ export class HubServiceClient { * A fully-qualified path representing MulticloudDataTransferConfig resource. * @returns {string} A string representing the multicloud_data_transfer_config. */ - matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName(multicloudDataTransferConfigName: string) { - return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match(multicloudDataTransferConfigName).multicloud_data_transfer_config; + matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName( + multicloudDataTransferConfigName: string, + ) { + return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match( + multicloudDataTransferConfigName, + ).multicloud_data_transfer_config; } /** @@ -5549,12 +7259,19 @@ export class HubServiceClient { * @param {string} multicloud_data_transfer_supported_service * @returns {string} Resource name string. */ - multicloudDataTransferSupportedServicePath(project:string,location:string,multicloudDataTransferSupportedService:string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render({ - project: project, - location: location, - multicloud_data_transfer_supported_service: multicloudDataTransferSupportedService, - }); + multicloudDataTransferSupportedServicePath( + project: string, + location: string, + multicloudDataTransferSupportedService: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render( + { + project: project, + location: location, + multicloud_data_transfer_supported_service: + multicloudDataTransferSupportedService, + }, + ); } /** @@ -5564,8 +7281,12 @@ export class HubServiceClient { * A fully-qualified path representing MulticloudDataTransferSupportedService resource. * @returns {string} A string representing the project. */ - matchProjectFromMulticloudDataTransferSupportedServiceName(multicloudDataTransferSupportedServiceName: string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match(multicloudDataTransferSupportedServiceName).project; + matchProjectFromMulticloudDataTransferSupportedServiceName( + multicloudDataTransferSupportedServiceName: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match( + multicloudDataTransferSupportedServiceName, + ).project; } /** @@ -5575,8 +7296,12 @@ export class HubServiceClient { * A fully-qualified path representing MulticloudDataTransferSupportedService resource. * @returns {string} A string representing the location. */ - matchLocationFromMulticloudDataTransferSupportedServiceName(multicloudDataTransferSupportedServiceName: string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match(multicloudDataTransferSupportedServiceName).location; + matchLocationFromMulticloudDataTransferSupportedServiceName( + multicloudDataTransferSupportedServiceName: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match( + multicloudDataTransferSupportedServiceName, + ).location; } /** @@ -5586,8 +7311,12 @@ export class HubServiceClient { * A fully-qualified path representing MulticloudDataTransferSupportedService resource. * @returns {string} A string representing the multicloud_data_transfer_supported_service. */ - matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName(multicloudDataTransferSupportedServiceName: string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match(multicloudDataTransferSupportedServiceName).multicloud_data_transfer_supported_service; + matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName( + multicloudDataTransferSupportedServiceName: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match( + multicloudDataTransferSupportedServiceName, + ).multicloud_data_transfer_supported_service; } /** @@ -5597,7 +7326,7 @@ export class HubServiceClient { * @param {string} resource_id * @returns {string} Resource name string. */ - networkPath(project:string,resourceId:string) { + networkPath(project: string, resourceId: string) { return this.pathTemplates.networkPathTemplate.render({ project: project, resource_id: resourceId, @@ -5623,7 +7352,8 @@ export class HubServiceClient { * @returns {string} A string representing the resource_id. */ matchResourceIdFromNetworkName(networkName: string) { - return this.pathTemplates.networkPathTemplate.match(networkName).resource_id; + return this.pathTemplates.networkPathTemplate.match(networkName) + .resource_id; } /** @@ -5633,7 +7363,7 @@ export class HubServiceClient { * @param {string} policy_based_route * @returns {string} Resource name string. */ - policyBasedRoutePath(project:string,policyBasedRoute:string) { + policyBasedRoutePath(project: string, policyBasedRoute: string) { return this.pathTemplates.policyBasedRoutePathTemplate.render({ project: project, policy_based_route: policyBasedRoute, @@ -5648,7 +7378,9 @@ export class HubServiceClient { * @returns {string} A string representing the project. */ matchProjectFromPolicyBasedRouteName(policyBasedRouteName: string) { - return this.pathTemplates.policyBasedRoutePathTemplate.match(policyBasedRouteName).project; + return this.pathTemplates.policyBasedRoutePathTemplate.match( + policyBasedRouteName, + ).project; } /** @@ -5659,7 +7391,9 @@ export class HubServiceClient { * @returns {string} A string representing the policy_based_route. */ matchPolicyBasedRouteFromPolicyBasedRouteName(policyBasedRouteName: string) { - return this.pathTemplates.policyBasedRoutePathTemplate.match(policyBasedRouteName).policy_based_route; + return this.pathTemplates.policyBasedRoutePathTemplate.match( + policyBasedRouteName, + ).policy_based_route; } /** @@ -5670,7 +7404,11 @@ export class HubServiceClient { * @param {string} remote_transport_profile * @returns {string} Resource name string. */ - remoteTransportProfilePath(project:string,location:string,remoteTransportProfile:string) { + remoteTransportProfilePath( + project: string, + location: string, + remoteTransportProfile: string, + ) { return this.pathTemplates.remoteTransportProfilePathTemplate.render({ project: project, location: location, @@ -5685,8 +7423,12 @@ export class HubServiceClient { * A fully-qualified path representing RemoteTransportProfile resource. * @returns {string} A string representing the project. */ - matchProjectFromRemoteTransportProfileName(remoteTransportProfileName: string) { - return this.pathTemplates.remoteTransportProfilePathTemplate.match(remoteTransportProfileName).project; + matchProjectFromRemoteTransportProfileName( + remoteTransportProfileName: string, + ) { + return this.pathTemplates.remoteTransportProfilePathTemplate.match( + remoteTransportProfileName, + ).project; } /** @@ -5696,8 +7438,12 @@ export class HubServiceClient { * A fully-qualified path representing RemoteTransportProfile resource. * @returns {string} A string representing the location. */ - matchLocationFromRemoteTransportProfileName(remoteTransportProfileName: string) { - return this.pathTemplates.remoteTransportProfilePathTemplate.match(remoteTransportProfileName).location; + matchLocationFromRemoteTransportProfileName( + remoteTransportProfileName: string, + ) { + return this.pathTemplates.remoteTransportProfilePathTemplate.match( + remoteTransportProfileName, + ).location; } /** @@ -5707,8 +7453,12 @@ export class HubServiceClient { * A fully-qualified path representing RemoteTransportProfile resource. * @returns {string} A string representing the remote_transport_profile. */ - matchRemoteTransportProfileFromRemoteTransportProfileName(remoteTransportProfileName: string) { - return this.pathTemplates.remoteTransportProfilePathTemplate.match(remoteTransportProfileName).remote_transport_profile; + matchRemoteTransportProfileFromRemoteTransportProfileName( + remoteTransportProfileName: string, + ) { + return this.pathTemplates.remoteTransportProfilePathTemplate.match( + remoteTransportProfileName, + ).remote_transport_profile; } /** @@ -5719,7 +7469,7 @@ export class HubServiceClient { * @param {string} route_table * @returns {string} Resource name string. */ - routeTablePath(project:string,hub:string,routeTable:string) { + routeTablePath(project: string, hub: string, routeTable: string) { return this.pathTemplates.routeTablePathTemplate.render({ project: project, hub: hub, @@ -5735,7 +7485,8 @@ export class HubServiceClient { * @returns {string} A string representing the project. */ matchProjectFromRouteTableName(routeTableName: string) { - return this.pathTemplates.routeTablePathTemplate.match(routeTableName).project; + return this.pathTemplates.routeTablePathTemplate.match(routeTableName) + .project; } /** @@ -5757,7 +7508,8 @@ export class HubServiceClient { * @returns {string} A string representing the route_table. */ matchRouteTableFromRouteTableName(routeTableName: string) { - return this.pathTemplates.routeTablePathTemplate.match(routeTableName).route_table; + return this.pathTemplates.routeTablePathTemplate.match(routeTableName) + .route_table; } /** @@ -5768,7 +7520,7 @@ export class HubServiceClient { * @param {string} sac_attachment * @returns {string} Resource name string. */ - sACAttachmentPath(project:string,location:string,sacAttachment:string) { + sACAttachmentPath(project: string, location: string, sacAttachment: string) { return this.pathTemplates.sACAttachmentPathTemplate.render({ project: project, location: location, @@ -5784,7 +7536,8 @@ export class HubServiceClient { * @returns {string} A string representing the project. */ matchProjectFromSACAttachmentName(sACAttachmentName: string) { - return this.pathTemplates.sACAttachmentPathTemplate.match(sACAttachmentName).project; + return this.pathTemplates.sACAttachmentPathTemplate.match(sACAttachmentName) + .project; } /** @@ -5795,7 +7548,8 @@ export class HubServiceClient { * @returns {string} A string representing the location. */ matchLocationFromSACAttachmentName(sACAttachmentName: string) { - return this.pathTemplates.sACAttachmentPathTemplate.match(sACAttachmentName).location; + return this.pathTemplates.sACAttachmentPathTemplate.match(sACAttachmentName) + .location; } /** @@ -5806,7 +7560,8 @@ export class HubServiceClient { * @returns {string} A string representing the sac_attachment. */ matchSacAttachmentFromSACAttachmentName(sACAttachmentName: string) { - return this.pathTemplates.sACAttachmentPathTemplate.match(sACAttachmentName).sac_attachment; + return this.pathTemplates.sACAttachmentPathTemplate.match(sACAttachmentName) + .sac_attachment; } /** @@ -5817,7 +7572,7 @@ export class HubServiceClient { * @param {string} spoke * @returns {string} Resource name string. */ - spokePath(project:string,location:string,spoke:string) { + spokePath(project: string, location: string, spoke: string) { return this.pathTemplates.spokePathTemplate.render({ project: project, location: location, @@ -5866,7 +7621,7 @@ export class HubServiceClient { * @param {string} transport * @returns {string} Resource name string. */ - transportPath(project:string,location:string,transport:string) { + transportPath(project: string, location: string, transport: string) { return this.pathTemplates.transportPathTemplate.render({ project: project, location: location, @@ -5882,7 +7637,8 @@ export class HubServiceClient { * @returns {string} A string representing the project. */ matchProjectFromTransportName(transportName: string) { - return this.pathTemplates.transportPathTemplate.match(transportName).project; + return this.pathTemplates.transportPathTemplate.match(transportName) + .project; } /** @@ -5893,7 +7649,8 @@ export class HubServiceClient { * @returns {string} A string representing the location. */ matchLocationFromTransportName(transportName: string) { - return this.pathTemplates.transportPathTemplate.match(transportName).location; + return this.pathTemplates.transportPathTemplate.match(transportName) + .location; } /** @@ -5904,7 +7661,8 @@ export class HubServiceClient { * @returns {string} A string representing the transport. */ matchTransportFromTransportName(transportName: string) { - return this.pathTemplates.transportPathTemplate.match(transportName).transport; + return this.pathTemplates.transportPathTemplate.match(transportName) + .transport; } /** @@ -5915,7 +7673,7 @@ export class HubServiceClient { * @param {string} resource_id * @returns {string} Resource name string. */ - vpnTunnelPath(project:string,region:string,resourceId:string) { + vpnTunnelPath(project: string, region: string, resourceId: string) { return this.pathTemplates.vpnTunnelPathTemplate.render({ project: project, region: region, @@ -5931,7 +7689,8 @@ export class HubServiceClient { * @returns {string} A string representing the project. */ matchProjectFromVpnTunnelName(vpnTunnelName: string) { - return this.pathTemplates.vpnTunnelPathTemplate.match(vpnTunnelName).project; + return this.pathTemplates.vpnTunnelPathTemplate.match(vpnTunnelName) + .project; } /** @@ -5953,7 +7712,8 @@ export class HubServiceClient { * @returns {string} A string representing the resource_id. */ matchResourceIdFromVpnTunnelName(vpnTunnelName: string) { - return this.pathTemplates.vpnTunnelPathTemplate.match(vpnTunnelName).resource_id; + return this.pathTemplates.vpnTunnelPathTemplate.match(vpnTunnelName) + .resource_id; } /** @@ -5964,15 +7724,19 @@ export class HubServiceClient { */ close(): Promise { if (this.hubServiceStub && !this._terminated) { - return this.hubServiceStub.then(stub => { + return this.hubServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-networkconnectivity/src/v1beta/index.ts b/packages/google-cloud-networkconnectivity/src/v1beta/index.ts index 2ef22e3006b3..1f1863ede3de 100644 --- a/packages/google-cloud-networkconnectivity/src/v1beta/index.ts +++ b/packages/google-cloud-networkconnectivity/src/v1beta/index.ts @@ -16,7 +16,7 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {DataTransferServiceClient} from './data_transfer_service_client'; -export {HubServiceClient} from './hub_service_client'; -export {PolicyBasedRoutingServiceClient} from './policy_based_routing_service_client'; -export {TransportManagerClient} from './transport_manager_client'; +export { DataTransferServiceClient } from './data_transfer_service_client'; +export { HubServiceClient } from './hub_service_client'; +export { PolicyBasedRoutingServiceClient } from './policy_based_routing_service_client'; +export { TransportManagerClient } from './transport_manager_client'; diff --git a/packages/google-cloud-networkconnectivity/src/v1beta/policy_based_routing_service_client.ts b/packages/google-cloud-networkconnectivity/src/v1beta/policy_based_routing_service_client.ts index 28585ee034aa..5f7a759d51b8 100644 --- a/packages/google-cloud-networkconnectivity/src/v1beta/policy_based_routing_service_client.ts +++ b/packages/google-cloud-networkconnectivity/src/v1beta/policy_based_routing_service_client.ts @@ -18,11 +18,24 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -45,7 +58,7 @@ export class PolicyBasedRoutingServiceClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('networkconnectivity'); @@ -58,12 +71,12 @@ export class PolicyBasedRoutingServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - policyBasedRoutingServiceStub?: Promise<{[name: string]: Function}>; + policyBasedRoutingServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of PolicyBasedRoutingServiceClient. @@ -104,21 +117,43 @@ export class PolicyBasedRoutingServiceClient { * const client = new PolicyBasedRoutingServiceClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof PolicyBasedRoutingServiceClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + const staticMembers = this + .constructor as typeof PolicyBasedRoutingServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'networkconnectivity.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -143,7 +178,7 @@ export class PolicyBasedRoutingServiceClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -156,18 +191,14 @@ export class PolicyBasedRoutingServiceClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -189,46 +220,48 @@ export class PolicyBasedRoutingServiceClient { // Create useful helper objects for these. this.pathTemplates = { destinationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}/destinations/{destination}' + 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}/destinations/{destination}', ), gatewayAdvertisedRoutePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/spokes/{spoke}/gatewayAdvertisedRoutes/{gateway_advertised_route}' + 'projects/{project}/locations/{location}/spokes/{spoke}/gatewayAdvertisedRoutes/{gateway_advertised_route}', ), groupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}/groups/{group}' + 'projects/{project}/locations/global/hubs/{hub}/groups/{group}', ), hubPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}' + 'projects/{project}/locations/global/hubs/{hub}', ), hubRoutePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}/routes/{route}' + 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}/routes/{route}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - multicloudDataTransferConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}' - ), - multicloudDataTransferSupportedServicePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/multicloudDataTransferSupportedServices/{multicloud_data_transfer_supported_service}' + 'projects/{project}/locations/{location}', ), + multicloudDataTransferConfigPathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}', + ), + multicloudDataTransferSupportedServicePathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/multicloudDataTransferSupportedServices/{multicloud_data_transfer_supported_service}', + ), networkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/global/networks/{resource_id}' + 'projects/{project}/global/networks/{resource_id}', ), policyBasedRoutePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/PolicyBasedRoutes/{policy_based_route}' + 'projects/{project}/locations/global/PolicyBasedRoutes/{policy_based_route}', ), remoteTransportProfilePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/remoteTransportProfiles/{remote_transport_profile}' + 'projects/{project}/locations/{location}/remoteTransportProfiles/{remote_transport_profile}', ), routeTablePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}' + 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}', ), spokePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/spokes/{spoke}' + 'projects/{project}/locations/{location}/spokes/{spoke}', ), transportPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/transports/{transport}' + 'projects/{project}/locations/{location}/transports/{transport}', ), }; @@ -236,8 +269,11 @@ export class PolicyBasedRoutingServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listPolicyBasedRoutes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'policyBasedRoutes') + listPolicyBasedRoutes: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'policyBasedRoutes', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -246,40 +282,135 @@ export class PolicyBasedRoutingServiceClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1beta/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1beta/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1beta/{resource=projects/*/locations/global/hubs/*}:getIamPolicy',additional_bindings: [{get: '/v1beta/{resource=projects/*/locations/global/hubs/*/groups/*}:getIamPolicy',},{get: '/v1beta/{resource=projects/*/locations/*/spokes/*}:getIamPolicy',},{get: '/v1beta/{resource=projects/*/locations/global/policyBasedRoutes/*}:getIamPolicy',}], - },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1beta/{resource=projects/*/locations/global/hubs/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1beta/{resource=projects/*/locations/global/hubs/*/groups/*}:setIamPolicy',body: '*',},{post: '/v1beta/{resource=projects/*/locations/*/spokes/*}:setIamPolicy',body: '*',},{post: '/v1beta/{resource=projects/*/locations/global/policyBasedRoutes/*}:setIamPolicy',body: '*',}], - },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1beta/{resource=projects/*/locations/global/hubs/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1beta/{resource=projects/*/locations/global/hubs/*/groups/*}:testIamPermissions',body: '*',},{post: '/v1beta/{resource=projects/*/locations/*/spokes/*}:testIamPermissions',body: '*',},{post: '/v1beta/{resource=projects/*/locations/global/policyBasedRoutes/*}:testIamPermissions',body: '*',}], - },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1beta/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1beta/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1beta/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1beta/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1beta/{resource=projects/*/locations/global/hubs/*}:getIamPolicy', + additional_bindings: [ + { + get: '/v1beta/{resource=projects/*/locations/global/hubs/*/groups/*}:getIamPolicy', + }, + { + get: '/v1beta/{resource=projects/*/locations/*/spokes/*}:getIamPolicy', + }, + { + get: '/v1beta/{resource=projects/*/locations/global/policyBasedRoutes/*}:getIamPolicy', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1beta/{resource=projects/*/locations/global/hubs/*}:setIamPolicy', + body: '*', + additional_bindings: [ + { + post: '/v1beta/{resource=projects/*/locations/global/hubs/*/groups/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1beta/{resource=projects/*/locations/*/spokes/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1beta/{resource=projects/*/locations/global/policyBasedRoutes/*}:setIamPolicy', + body: '*', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1beta/{resource=projects/*/locations/global/hubs/*}:testIamPermissions', + body: '*', + additional_bindings: [ + { + post: '/v1beta/{resource=projects/*/locations/global/hubs/*/groups/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1beta/{resource=projects/*/locations/*/spokes/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1beta/{resource=projects/*/locations/global/policyBasedRoutes/*}:testIamPermissions', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1beta/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1beta/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1beta/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1beta/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createPolicyBasedRouteResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute', + ) as gax.protobuf.Type; const createPolicyBasedRouteMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const deletePolicyBasedRouteResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deletePolicyBasedRouteMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createPolicyBasedRoute: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - createPolicyBasedRouteResponse.decode.bind(createPolicyBasedRouteResponse), - createPolicyBasedRouteMetadata.decode.bind(createPolicyBasedRouteMetadata)), + createPolicyBasedRouteResponse.decode.bind( + createPolicyBasedRouteResponse, + ), + createPolicyBasedRouteMetadata.decode.bind( + createPolicyBasedRouteMetadata, + ), + ), deletePolicyBasedRoute: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - deletePolicyBasedRouteResponse.decode.bind(deletePolicyBasedRouteResponse), - deletePolicyBasedRouteMetadata.decode.bind(deletePolicyBasedRouteMetadata)) + deletePolicyBasedRouteResponse.decode.bind( + deletePolicyBasedRouteResponse, + ), + deletePolicyBasedRouteMetadata.decode.bind( + deletePolicyBasedRouteMetadata, + ), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.networkconnectivity.v1beta.PolicyBasedRoutingService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.networkconnectivity.v1beta.PolicyBasedRoutingService', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -310,28 +441,39 @@ export class PolicyBasedRoutingServiceClient { // Put together the "service stub" for // google.cloud.networkconnectivity.v1beta.PolicyBasedRoutingService. this.policyBasedRoutingServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.networkconnectivity.v1beta.PolicyBasedRoutingService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.networkconnectivity.v1beta.PolicyBasedRoutingService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.networkconnectivity.v1beta.PolicyBasedRoutingService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.networkconnectivity.v1beta + .PolicyBasedRoutingService, + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const policyBasedRoutingServiceStubMethods = - ['listPolicyBasedRoutes', 'getPolicyBasedRoute', 'createPolicyBasedRoute', 'deletePolicyBasedRoute']; + const policyBasedRoutingServiceStubMethods = [ + 'listPolicyBasedRoutes', + 'getPolicyBasedRoute', + 'createPolicyBasedRoute', + 'deletePolicyBasedRoute', + ]; for (const methodName of policyBasedRoutingServiceStubMethods) { const callPromise = this.policyBasedRoutingServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -341,7 +483,7 @@ export class PolicyBasedRoutingServiceClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -356,8 +498,14 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkconnectivity.googleapis.com'; } @@ -368,8 +516,14 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkconnectivity.googleapis.com'; } @@ -400,9 +554,7 @@ export class PolicyBasedRoutingServiceClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -411,8 +563,9 @@ export class PolicyBasedRoutingServiceClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -423,439 +576,637 @@ export class PolicyBasedRoutingServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets details of a single policy-based route. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the PolicyBasedRoute resource to get. - * @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 {@link protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute|PolicyBasedRoute}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/policy_based_routing_service.get_policy_based_route.js - * region_tag:networkconnectivity_v1beta_generated_PolicyBasedRoutingService_GetPolicyBasedRoute_async - */ + /** + * Gets details of a single policy-based route. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the PolicyBasedRoute resource to get. + * @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 {@link protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute|PolicyBasedRoute}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/policy_based_routing_service.get_policy_based_route.js + * region_tag:networkconnectivity_v1beta_generated_PolicyBasedRoutingService_GetPolicyBasedRoute_async + */ getPolicyBasedRoute( - request?: protos.google.cloud.networkconnectivity.v1beta.IGetPolicyBasedRouteRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute, - protos.google.cloud.networkconnectivity.v1beta.IGetPolicyBasedRouteRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IGetPolicyBasedRouteRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetPolicyBasedRouteRequest + | undefined + ), + {} | undefined, + ] + >; getPolicyBasedRoute( - request: protos.google.cloud.networkconnectivity.v1beta.IGetPolicyBasedRouteRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute, - protos.google.cloud.networkconnectivity.v1beta.IGetPolicyBasedRouteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IGetPolicyBasedRouteRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute, + | protos.google.cloud.networkconnectivity.v1beta.IGetPolicyBasedRouteRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getPolicyBasedRoute( - request: protos.google.cloud.networkconnectivity.v1beta.IGetPolicyBasedRouteRequest, - callback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute, - protos.google.cloud.networkconnectivity.v1beta.IGetPolicyBasedRouteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IGetPolicyBasedRouteRequest, + callback: Callback< + protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute, + | protos.google.cloud.networkconnectivity.v1beta.IGetPolicyBasedRouteRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getPolicyBasedRoute( - request?: protos.google.cloud.networkconnectivity.v1beta.IGetPolicyBasedRouteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute, - protos.google.cloud.networkconnectivity.v1beta.IGetPolicyBasedRouteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkconnectivity.v1beta.IGetPolicyBasedRouteRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute, - protos.google.cloud.networkconnectivity.v1beta.IGetPolicyBasedRouteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute, - protos.google.cloud.networkconnectivity.v1beta.IGetPolicyBasedRouteRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkconnectivity.v1beta.IGetPolicyBasedRouteRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute, + | protos.google.cloud.networkconnectivity.v1beta.IGetPolicyBasedRouteRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetPolicyBasedRouteRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getPolicyBasedRoute request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute, - protos.google.cloud.networkconnectivity.v1beta.IGetPolicyBasedRouteRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute, + | protos.google.cloud.networkconnectivity.v1beta.IGetPolicyBasedRouteRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getPolicyBasedRoute response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getPolicyBasedRoute(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute, - protos.google.cloud.networkconnectivity.v1beta.IGetPolicyBasedRouteRequest|undefined, - {}|undefined - ]) => { - this._log.info('getPolicyBasedRoute response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getPolicyBasedRoute(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetPolicyBasedRouteRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getPolicyBasedRoute response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a new policy-based route in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name of the PolicyBasedRoute. - * @param {string} request.policyBasedRouteId - * Required. Unique id for the policy-based route to create. Provided by the - * client when the resource is created. The name must comply with - * https://google.aip.dev/122#resource-id-segments. Specifically, the name - * must be 1-63 characters long and match the regular expression - * [a-z]([a-z0-9-]*[a-z0-9])?. The first character must be a lowercase letter, - * and all following characters (except for the last character) must be a - * dash, lowercase letter, or digit. The last character must be a lowercase - * letter or digit. - * @param {google.cloud.networkconnectivity.v1beta.PolicyBasedRoute} request.policyBasedRoute - * Required. Initial values for a new policy-based route. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server knows to - * ignore the request if it has already been completed. The server guarantees - * that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, ignores the second request. This prevents clients - * from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1beta/policy_based_routing_service.create_policy_based_route.js - * region_tag:networkconnectivity_v1beta_generated_PolicyBasedRoutingService_CreatePolicyBasedRoute_async - */ + /** + * Creates a new policy-based route in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name of the PolicyBasedRoute. + * @param {string} request.policyBasedRouteId + * Required. Unique id for the policy-based route to create. Provided by the + * client when the resource is created. The name must comply with + * https://google.aip.dev/122#resource-id-segments. Specifically, the name + * must be 1-63 characters long and match the regular expression + * [a-z]([a-z0-9-]*[a-z0-9])?. The first character must be a lowercase letter, + * and all following characters (except for the last character) must be a + * dash, lowercase letter, or digit. The last character must be a lowercase + * letter or digit. + * @param {google.cloud.networkconnectivity.v1beta.PolicyBasedRoute} request.policyBasedRoute + * Required. Initial values for a new policy-based route. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server knows to + * ignore the request if it has already been completed. The server guarantees + * that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, ignores the second request. This prevents clients + * from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1beta/policy_based_routing_service.create_policy_based_route.js + * region_tag:networkconnectivity_v1beta_generated_PolicyBasedRoutingService_CreatePolicyBasedRoute_async + */ createPolicyBasedRoute( - request?: protos.google.cloud.networkconnectivity.v1beta.ICreatePolicyBasedRouteRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.ICreatePolicyBasedRouteRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createPolicyBasedRoute( - request: protos.google.cloud.networkconnectivity.v1beta.ICreatePolicyBasedRouteRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.ICreatePolicyBasedRouteRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createPolicyBasedRoute( - request: protos.google.cloud.networkconnectivity.v1beta.ICreatePolicyBasedRouteRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.ICreatePolicyBasedRouteRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createPolicyBasedRoute( - request?: protos.google.cloud.networkconnectivity.v1beta.ICreatePolicyBasedRouteRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1beta.ICreatePolicyBasedRouteRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createPolicyBasedRoute response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createPolicyBasedRoute request %j', request); - return this.innerApiCalls.createPolicyBasedRoute(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createPolicyBasedRoute response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createPolicyBasedRoute(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createPolicyBasedRoute response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createPolicyBasedRoute()`. - * @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/v1beta/policy_based_routing_service.create_policy_based_route.js - * region_tag:networkconnectivity_v1beta_generated_PolicyBasedRoutingService_CreatePolicyBasedRoute_async - */ - async checkCreatePolicyBasedRouteProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createPolicyBasedRoute()`. + * @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/v1beta/policy_based_routing_service.create_policy_based_route.js + * region_tag:networkconnectivity_v1beta_generated_PolicyBasedRoutingService_CreatePolicyBasedRoute_async + */ + async checkCreatePolicyBasedRouteProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + > + > { this._log.info('createPolicyBasedRoute long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createPolicyBasedRoute, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createPolicyBasedRoute, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + >; } -/** - * Deletes a single policy-based route. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the policy-based route resource to delete. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server knows to - * ignore the request if it has already been completed. The server guarantees - * that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, ignores the second request. This prevents clients - * from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1beta/policy_based_routing_service.delete_policy_based_route.js - * region_tag:networkconnectivity_v1beta_generated_PolicyBasedRoutingService_DeletePolicyBasedRoute_async - */ + /** + * Deletes a single policy-based route. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the policy-based route resource to delete. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server knows to + * ignore the request if it has already been completed. The server guarantees + * that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, ignores the second request. This prevents clients + * from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1beta/policy_based_routing_service.delete_policy_based_route.js + * region_tag:networkconnectivity_v1beta_generated_PolicyBasedRoutingService_DeletePolicyBasedRoute_async + */ deletePolicyBasedRoute( - request?: protos.google.cloud.networkconnectivity.v1beta.IDeletePolicyBasedRouteRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IDeletePolicyBasedRouteRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deletePolicyBasedRoute( - request: protos.google.cloud.networkconnectivity.v1beta.IDeletePolicyBasedRouteRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IDeletePolicyBasedRouteRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deletePolicyBasedRoute( - request: protos.google.cloud.networkconnectivity.v1beta.IDeletePolicyBasedRouteRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IDeletePolicyBasedRouteRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deletePolicyBasedRoute( - request?: protos.google.cloud.networkconnectivity.v1beta.IDeletePolicyBasedRouteRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1beta.IDeletePolicyBasedRouteRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deletePolicyBasedRoute response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deletePolicyBasedRoute request %j', request); - return this.innerApiCalls.deletePolicyBasedRoute(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deletePolicyBasedRoute response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deletePolicyBasedRoute(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deletePolicyBasedRoute response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deletePolicyBasedRoute()`. - * @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/v1beta/policy_based_routing_service.delete_policy_based_route.js - * region_tag:networkconnectivity_v1beta_generated_PolicyBasedRoutingService_DeletePolicyBasedRoute_async - */ - async checkDeletePolicyBasedRouteProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deletePolicyBasedRoute()`. + * @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/v1beta/policy_based_routing_service.delete_policy_based_route.js + * region_tag:networkconnectivity_v1beta_generated_PolicyBasedRoutingService_DeletePolicyBasedRoute_async + */ + async checkDeletePolicyBasedRouteProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + > + > { this._log.info('deletePolicyBasedRoute long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deletePolicyBasedRoute, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists policy-based routes in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results per page that should be returned. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * A filter expression that filters the results listed in the response. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute|PolicyBasedRoute}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listPolicyBasedRoutesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deletePolicyBasedRoute, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + >; + } + /** + * Lists policy-based routes in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results per page that should be returned. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * A filter expression that filters the results listed in the response. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute|PolicyBasedRoute}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listPolicyBasedRoutesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listPolicyBasedRoutes( - request?: protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute[], - protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute[], + protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesResponse, + ] + >; listPolicyBasedRoutes( - request: protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute + >, + ): void; listPolicyBasedRoutes( - request: protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute + >, + ): void; listPolicyBasedRoutes( - request?: protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute>): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute[], - protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute[], + protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listPolicyBasedRoutes values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -864,141 +1215,145 @@ export class PolicyBasedRoutingServiceClient { this._log.info('listPolicyBasedRoutes request %j', request); return this.innerApiCalls .listPolicyBasedRoutes(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute[], - protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesResponse - ]) => { - this._log.info('listPolicyBasedRoutes values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute[], + protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesResponse, + ]) => { + this._log.info('listPolicyBasedRoutes values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listPolicyBasedRoutes`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results per page that should be returned. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * A filter expression that filters the results listed in the response. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute|PolicyBasedRoute} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listPolicyBasedRoutesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listPolicyBasedRoutes`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results per page that should be returned. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * A filter expression that filters the results listed in the response. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute|PolicyBasedRoute} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listPolicyBasedRoutesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listPolicyBasedRoutesStream( - request?: protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listPolicyBasedRoutes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listPolicyBasedRoutes stream %j', request); return this.descriptors.page.listPolicyBasedRoutes.createStream( this.innerApiCalls.listPolicyBasedRoutes as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listPolicyBasedRoutes`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource's name. - * @param {number} request.pageSize - * The maximum number of results per page that should be returned. - * @param {string} request.pageToken - * The page token. - * @param {string} request.filter - * A filter expression that filters the results listed in the response. - * @param {string} request.orderBy - * Sort the results by a certain order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute|PolicyBasedRoute}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/policy_based_routing_service.list_policy_based_routes.js - * region_tag:networkconnectivity_v1beta_generated_PolicyBasedRoutingService_ListPolicyBasedRoutes_async - */ + /** + * Equivalent to `listPolicyBasedRoutes`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource's name. + * @param {number} request.pageSize + * The maximum number of results per page that should be returned. + * @param {string} request.pageToken + * The page token. + * @param {string} request.filter + * A filter expression that filters the results listed in the response. + * @param {string} request.orderBy + * Sort the results by a certain order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute|PolicyBasedRoute}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/policy_based_routing_service.list_policy_based_routes.js + * region_tag:networkconnectivity_v1beta_generated_PolicyBasedRoutingService_ListPolicyBasedRoutes_async + */ listPolicyBasedRoutesAsync( - request?: protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1beta.IListPolicyBasedRoutesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listPolicyBasedRoutes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listPolicyBasedRoutes iterate %j', request); return this.descriptors.page.listPolicyBasedRoutes.asyncIterate( this.innerApiCalls['listPolicyBasedRoutes'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -1012,40 +1367,40 @@ export class PolicyBasedRoutingServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -1059,41 +1414,41 @@ export class PolicyBasedRoutingServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -1107,12 +1462,12 @@ export class PolicyBasedRoutingServiceClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -1147,12 +1502,11 @@ export class PolicyBasedRoutingServiceClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -1185,12 +1539,12 @@ export class PolicyBasedRoutingServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -1233,22 +1587,22 @@ export class PolicyBasedRoutingServiceClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -1283,15 +1637,15 @@ export class PolicyBasedRoutingServiceClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - 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 ?? '', - }); + 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 ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -1325,7 +1679,7 @@ export class PolicyBasedRoutingServiceClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -1338,25 +1692,24 @@ export class PolicyBasedRoutingServiceClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -1395,22 +1748,22 @@ export class PolicyBasedRoutingServiceClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -1427,7 +1780,12 @@ export class PolicyBasedRoutingServiceClient { * @param {string} destination * @returns {string} Resource name string. */ - destinationPath(project:string,location:string,multicloudDataTransferConfig:string,destination:string) { + destinationPath( + project: string, + location: string, + multicloudDataTransferConfig: string, + destination: string, + ) { return this.pathTemplates.destinationPathTemplate.render({ project: project, location: location, @@ -1444,7 +1802,8 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} A string representing the project. */ matchProjectFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).project; + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .project; } /** @@ -1455,7 +1814,8 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} A string representing the location. */ matchLocationFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).location; + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .location; } /** @@ -1465,8 +1825,11 @@ export class PolicyBasedRoutingServiceClient { * A fully-qualified path representing Destination resource. * @returns {string} A string representing the multicloud_data_transfer_config. */ - matchMulticloudDataTransferConfigFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).multicloud_data_transfer_config; + matchMulticloudDataTransferConfigFromDestinationName( + destinationName: string, + ) { + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .multicloud_data_transfer_config; } /** @@ -1477,7 +1840,8 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} A string representing the destination. */ matchDestinationFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).destination; + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .destination; } /** @@ -1489,7 +1853,12 @@ export class PolicyBasedRoutingServiceClient { * @param {string} gateway_advertised_route * @returns {string} Resource name string. */ - gatewayAdvertisedRoutePath(project:string,location:string,spoke:string,gatewayAdvertisedRoute:string) { + gatewayAdvertisedRoutePath( + project: string, + location: string, + spoke: string, + gatewayAdvertisedRoute: string, + ) { return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.render({ project: project, location: location, @@ -1505,8 +1874,12 @@ export class PolicyBasedRoutingServiceClient { * A fully-qualified path representing GatewayAdvertisedRoute resource. * @returns {string} A string representing the project. */ - matchProjectFromGatewayAdvertisedRouteName(gatewayAdvertisedRouteName: string) { - return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match(gatewayAdvertisedRouteName).project; + matchProjectFromGatewayAdvertisedRouteName( + gatewayAdvertisedRouteName: string, + ) { + return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match( + gatewayAdvertisedRouteName, + ).project; } /** @@ -1516,8 +1889,12 @@ export class PolicyBasedRoutingServiceClient { * A fully-qualified path representing GatewayAdvertisedRoute resource. * @returns {string} A string representing the location. */ - matchLocationFromGatewayAdvertisedRouteName(gatewayAdvertisedRouteName: string) { - return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match(gatewayAdvertisedRouteName).location; + matchLocationFromGatewayAdvertisedRouteName( + gatewayAdvertisedRouteName: string, + ) { + return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match( + gatewayAdvertisedRouteName, + ).location; } /** @@ -1528,7 +1905,9 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} A string representing the spoke. */ matchSpokeFromGatewayAdvertisedRouteName(gatewayAdvertisedRouteName: string) { - return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match(gatewayAdvertisedRouteName).spoke; + return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match( + gatewayAdvertisedRouteName, + ).spoke; } /** @@ -1538,8 +1917,12 @@ export class PolicyBasedRoutingServiceClient { * A fully-qualified path representing GatewayAdvertisedRoute resource. * @returns {string} A string representing the gateway_advertised_route. */ - matchGatewayAdvertisedRouteFromGatewayAdvertisedRouteName(gatewayAdvertisedRouteName: string) { - return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match(gatewayAdvertisedRouteName).gateway_advertised_route; + matchGatewayAdvertisedRouteFromGatewayAdvertisedRouteName( + gatewayAdvertisedRouteName: string, + ) { + return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match( + gatewayAdvertisedRouteName, + ).gateway_advertised_route; } /** @@ -1550,7 +1933,7 @@ export class PolicyBasedRoutingServiceClient { * @param {string} group * @returns {string} Resource name string. */ - groupPath(project:string,hub:string,group:string) { + groupPath(project: string, hub: string, group: string) { return this.pathTemplates.groupPathTemplate.render({ project: project, hub: hub, @@ -1598,7 +1981,7 @@ export class PolicyBasedRoutingServiceClient { * @param {string} hub * @returns {string} Resource name string. */ - hubPath(project:string,hub:string) { + hubPath(project: string, hub: string) { return this.pathTemplates.hubPathTemplate.render({ project: project, hub: hub, @@ -1636,7 +2019,12 @@ export class PolicyBasedRoutingServiceClient { * @param {string} route * @returns {string} Resource name string. */ - hubRoutePath(project:string,hub:string,routeTable:string,route:string) { + hubRoutePath( + project: string, + hub: string, + routeTable: string, + route: string, + ) { return this.pathTemplates.hubRoutePathTemplate.render({ project: project, hub: hub, @@ -1675,7 +2063,8 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} A string representing the route_table. */ matchRouteTableFromHubRouteName(hubRouteName: string) { - return this.pathTemplates.hubRoutePathTemplate.match(hubRouteName).route_table; + return this.pathTemplates.hubRoutePathTemplate.match(hubRouteName) + .route_table; } /** @@ -1696,7 +2085,7 @@ export class PolicyBasedRoutingServiceClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -1733,7 +2122,11 @@ export class PolicyBasedRoutingServiceClient { * @param {string} multicloud_data_transfer_config * @returns {string} Resource name string. */ - multicloudDataTransferConfigPath(project:string,location:string,multicloudDataTransferConfig:string) { + multicloudDataTransferConfigPath( + project: string, + location: string, + multicloudDataTransferConfig: string, + ) { return this.pathTemplates.multicloudDataTransferConfigPathTemplate.render({ project: project, location: location, @@ -1748,8 +2141,12 @@ export class PolicyBasedRoutingServiceClient { * A fully-qualified path representing MulticloudDataTransferConfig resource. * @returns {string} A string representing the project. */ - matchProjectFromMulticloudDataTransferConfigName(multicloudDataTransferConfigName: string) { - return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match(multicloudDataTransferConfigName).project; + matchProjectFromMulticloudDataTransferConfigName( + multicloudDataTransferConfigName: string, + ) { + return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match( + multicloudDataTransferConfigName, + ).project; } /** @@ -1759,8 +2156,12 @@ export class PolicyBasedRoutingServiceClient { * A fully-qualified path representing MulticloudDataTransferConfig resource. * @returns {string} A string representing the location. */ - matchLocationFromMulticloudDataTransferConfigName(multicloudDataTransferConfigName: string) { - return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match(multicloudDataTransferConfigName).location; + matchLocationFromMulticloudDataTransferConfigName( + multicloudDataTransferConfigName: string, + ) { + return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match( + multicloudDataTransferConfigName, + ).location; } /** @@ -1770,8 +2171,12 @@ export class PolicyBasedRoutingServiceClient { * A fully-qualified path representing MulticloudDataTransferConfig resource. * @returns {string} A string representing the multicloud_data_transfer_config. */ - matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName(multicloudDataTransferConfigName: string) { - return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match(multicloudDataTransferConfigName).multicloud_data_transfer_config; + matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName( + multicloudDataTransferConfigName: string, + ) { + return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match( + multicloudDataTransferConfigName, + ).multicloud_data_transfer_config; } /** @@ -1782,12 +2187,19 @@ export class PolicyBasedRoutingServiceClient { * @param {string} multicloud_data_transfer_supported_service * @returns {string} Resource name string. */ - multicloudDataTransferSupportedServicePath(project:string,location:string,multicloudDataTransferSupportedService:string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render({ - project: project, - location: location, - multicloud_data_transfer_supported_service: multicloudDataTransferSupportedService, - }); + multicloudDataTransferSupportedServicePath( + project: string, + location: string, + multicloudDataTransferSupportedService: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render( + { + project: project, + location: location, + multicloud_data_transfer_supported_service: + multicloudDataTransferSupportedService, + }, + ); } /** @@ -1797,8 +2209,12 @@ export class PolicyBasedRoutingServiceClient { * A fully-qualified path representing MulticloudDataTransferSupportedService resource. * @returns {string} A string representing the project. */ - matchProjectFromMulticloudDataTransferSupportedServiceName(multicloudDataTransferSupportedServiceName: string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match(multicloudDataTransferSupportedServiceName).project; + matchProjectFromMulticloudDataTransferSupportedServiceName( + multicloudDataTransferSupportedServiceName: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match( + multicloudDataTransferSupportedServiceName, + ).project; } /** @@ -1808,8 +2224,12 @@ export class PolicyBasedRoutingServiceClient { * A fully-qualified path representing MulticloudDataTransferSupportedService resource. * @returns {string} A string representing the location. */ - matchLocationFromMulticloudDataTransferSupportedServiceName(multicloudDataTransferSupportedServiceName: string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match(multicloudDataTransferSupportedServiceName).location; + matchLocationFromMulticloudDataTransferSupportedServiceName( + multicloudDataTransferSupportedServiceName: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match( + multicloudDataTransferSupportedServiceName, + ).location; } /** @@ -1819,8 +2239,12 @@ export class PolicyBasedRoutingServiceClient { * A fully-qualified path representing MulticloudDataTransferSupportedService resource. * @returns {string} A string representing the multicloud_data_transfer_supported_service. */ - matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName(multicloudDataTransferSupportedServiceName: string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match(multicloudDataTransferSupportedServiceName).multicloud_data_transfer_supported_service; + matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName( + multicloudDataTransferSupportedServiceName: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match( + multicloudDataTransferSupportedServiceName, + ).multicloud_data_transfer_supported_service; } /** @@ -1830,7 +2254,7 @@ export class PolicyBasedRoutingServiceClient { * @param {string} resource_id * @returns {string} Resource name string. */ - networkPath(project:string,resourceId:string) { + networkPath(project: string, resourceId: string) { return this.pathTemplates.networkPathTemplate.render({ project: project, resource_id: resourceId, @@ -1856,7 +2280,8 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} A string representing the resource_id. */ matchResourceIdFromNetworkName(networkName: string) { - return this.pathTemplates.networkPathTemplate.match(networkName).resource_id; + return this.pathTemplates.networkPathTemplate.match(networkName) + .resource_id; } /** @@ -1866,7 +2291,7 @@ export class PolicyBasedRoutingServiceClient { * @param {string} policy_based_route * @returns {string} Resource name string. */ - policyBasedRoutePath(project:string,policyBasedRoute:string) { + policyBasedRoutePath(project: string, policyBasedRoute: string) { return this.pathTemplates.policyBasedRoutePathTemplate.render({ project: project, policy_based_route: policyBasedRoute, @@ -1881,7 +2306,9 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} A string representing the project. */ matchProjectFromPolicyBasedRouteName(policyBasedRouteName: string) { - return this.pathTemplates.policyBasedRoutePathTemplate.match(policyBasedRouteName).project; + return this.pathTemplates.policyBasedRoutePathTemplate.match( + policyBasedRouteName, + ).project; } /** @@ -1892,7 +2319,9 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} A string representing the policy_based_route. */ matchPolicyBasedRouteFromPolicyBasedRouteName(policyBasedRouteName: string) { - return this.pathTemplates.policyBasedRoutePathTemplate.match(policyBasedRouteName).policy_based_route; + return this.pathTemplates.policyBasedRoutePathTemplate.match( + policyBasedRouteName, + ).policy_based_route; } /** @@ -1903,7 +2332,11 @@ export class PolicyBasedRoutingServiceClient { * @param {string} remote_transport_profile * @returns {string} Resource name string. */ - remoteTransportProfilePath(project:string,location:string,remoteTransportProfile:string) { + remoteTransportProfilePath( + project: string, + location: string, + remoteTransportProfile: string, + ) { return this.pathTemplates.remoteTransportProfilePathTemplate.render({ project: project, location: location, @@ -1918,8 +2351,12 @@ export class PolicyBasedRoutingServiceClient { * A fully-qualified path representing RemoteTransportProfile resource. * @returns {string} A string representing the project. */ - matchProjectFromRemoteTransportProfileName(remoteTransportProfileName: string) { - return this.pathTemplates.remoteTransportProfilePathTemplate.match(remoteTransportProfileName).project; + matchProjectFromRemoteTransportProfileName( + remoteTransportProfileName: string, + ) { + return this.pathTemplates.remoteTransportProfilePathTemplate.match( + remoteTransportProfileName, + ).project; } /** @@ -1929,8 +2366,12 @@ export class PolicyBasedRoutingServiceClient { * A fully-qualified path representing RemoteTransportProfile resource. * @returns {string} A string representing the location. */ - matchLocationFromRemoteTransportProfileName(remoteTransportProfileName: string) { - return this.pathTemplates.remoteTransportProfilePathTemplate.match(remoteTransportProfileName).location; + matchLocationFromRemoteTransportProfileName( + remoteTransportProfileName: string, + ) { + return this.pathTemplates.remoteTransportProfilePathTemplate.match( + remoteTransportProfileName, + ).location; } /** @@ -1940,8 +2381,12 @@ export class PolicyBasedRoutingServiceClient { * A fully-qualified path representing RemoteTransportProfile resource. * @returns {string} A string representing the remote_transport_profile. */ - matchRemoteTransportProfileFromRemoteTransportProfileName(remoteTransportProfileName: string) { - return this.pathTemplates.remoteTransportProfilePathTemplate.match(remoteTransportProfileName).remote_transport_profile; + matchRemoteTransportProfileFromRemoteTransportProfileName( + remoteTransportProfileName: string, + ) { + return this.pathTemplates.remoteTransportProfilePathTemplate.match( + remoteTransportProfileName, + ).remote_transport_profile; } /** @@ -1952,7 +2397,7 @@ export class PolicyBasedRoutingServiceClient { * @param {string} route_table * @returns {string} Resource name string. */ - routeTablePath(project:string,hub:string,routeTable:string) { + routeTablePath(project: string, hub: string, routeTable: string) { return this.pathTemplates.routeTablePathTemplate.render({ project: project, hub: hub, @@ -1968,7 +2413,8 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} A string representing the project. */ matchProjectFromRouteTableName(routeTableName: string) { - return this.pathTemplates.routeTablePathTemplate.match(routeTableName).project; + return this.pathTemplates.routeTablePathTemplate.match(routeTableName) + .project; } /** @@ -1990,7 +2436,8 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} A string representing the route_table. */ matchRouteTableFromRouteTableName(routeTableName: string) { - return this.pathTemplates.routeTablePathTemplate.match(routeTableName).route_table; + return this.pathTemplates.routeTablePathTemplate.match(routeTableName) + .route_table; } /** @@ -2001,7 +2448,7 @@ export class PolicyBasedRoutingServiceClient { * @param {string} spoke * @returns {string} Resource name string. */ - spokePath(project:string,location:string,spoke:string) { + spokePath(project: string, location: string, spoke: string) { return this.pathTemplates.spokePathTemplate.render({ project: project, location: location, @@ -2050,7 +2497,7 @@ export class PolicyBasedRoutingServiceClient { * @param {string} transport * @returns {string} Resource name string. */ - transportPath(project:string,location:string,transport:string) { + transportPath(project: string, location: string, transport: string) { return this.pathTemplates.transportPathTemplate.render({ project: project, location: location, @@ -2066,7 +2513,8 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} A string representing the project. */ matchProjectFromTransportName(transportName: string) { - return this.pathTemplates.transportPathTemplate.match(transportName).project; + return this.pathTemplates.transportPathTemplate.match(transportName) + .project; } /** @@ -2077,7 +2525,8 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} A string representing the location. */ matchLocationFromTransportName(transportName: string) { - return this.pathTemplates.transportPathTemplate.match(transportName).location; + return this.pathTemplates.transportPathTemplate.match(transportName) + .location; } /** @@ -2088,7 +2537,8 @@ export class PolicyBasedRoutingServiceClient { * @returns {string} A string representing the transport. */ matchTransportFromTransportName(transportName: string) { - return this.pathTemplates.transportPathTemplate.match(transportName).transport; + return this.pathTemplates.transportPathTemplate.match(transportName) + .transport; } /** @@ -2099,15 +2549,19 @@ export class PolicyBasedRoutingServiceClient { */ close(): Promise { if (this.policyBasedRoutingServiceStub && !this._terminated) { - return this.policyBasedRoutingServiceStub.then(stub => { + return this.policyBasedRoutingServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-networkconnectivity/src/v1beta/transport_manager_client.ts b/packages/google-cloud-networkconnectivity/src/v1beta/transport_manager_client.ts index 7e5f026a7483..621d9cc865e8 100644 --- a/packages/google-cloud-networkconnectivity/src/v1beta/transport_manager_client.ts +++ b/packages/google-cloud-networkconnectivity/src/v1beta/transport_manager_client.ts @@ -18,11 +18,24 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -44,7 +57,7 @@ export class TransportManagerClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('networkconnectivity'); @@ -57,12 +70,12 @@ export class TransportManagerClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - transportManagerStub?: Promise<{[name: string]: Function}>; + transportManagerStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of TransportManagerClient. @@ -103,21 +116,42 @@ export class TransportManagerClient { * const client = new TransportManagerClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof TransportManagerClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'networkconnectivity.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -142,7 +176,7 @@ export class TransportManagerClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -155,18 +189,14 @@ export class TransportManagerClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -188,49 +218,51 @@ export class TransportManagerClient { // Create useful helper objects for these. this.pathTemplates = { destinationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}/destinations/{destination}' + 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}/destinations/{destination}', ), gatewayAdvertisedRoutePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/spokes/{spoke}/gatewayAdvertisedRoutes/{gateway_advertised_route}' + 'projects/{project}/locations/{location}/spokes/{spoke}/gatewayAdvertisedRoutes/{gateway_advertised_route}', ), groupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}/groups/{group}' + 'projects/{project}/locations/global/hubs/{hub}/groups/{group}', ), hubPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}' + 'projects/{project}/locations/global/hubs/{hub}', ), hubRoutePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}/routes/{route}' + 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}/routes/{route}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - multicloudDataTransferConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}' - ), - multicloudDataTransferSupportedServicePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/multicloudDataTransferSupportedServices/{multicloud_data_transfer_supported_service}' + 'projects/{project}/locations/{location}', ), + multicloudDataTransferConfigPathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/multicloudDataTransferConfigs/{multicloud_data_transfer_config}', + ), + multicloudDataTransferSupportedServicePathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/multicloudDataTransferSupportedServices/{multicloud_data_transfer_supported_service}', + ), networkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/global/networks/{resource_id}' + 'projects/{project}/global/networks/{resource_id}', ), policyBasedRoutePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/PolicyBasedRoutes/{policy_based_route}' + 'projects/{project}/locations/global/PolicyBasedRoutes/{policy_based_route}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), remoteTransportProfilePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/remoteTransportProfiles/{remote_transport_profile}' + 'projects/{project}/locations/{location}/remoteTransportProfiles/{remote_transport_profile}', ), routeTablePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}' + 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}', ), spokePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/spokes/{spoke}' + 'projects/{project}/locations/{location}/spokes/{spoke}', ), transportPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/transports/{transport}' + 'projects/{project}/locations/{location}/transports/{transport}', ), }; @@ -238,10 +270,16 @@ export class TransportManagerClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listRemoteTransportProfiles: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'remoteTransportProfiles'), - listTransports: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'transports') + listRemoteTransportProfiles: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'remoteTransportProfiles', + ), + listTransports: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'transports', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -250,48 +288,138 @@ export class TransportManagerClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1beta/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1beta/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1beta/{resource=projects/*/locations/global/hubs/*}:getIamPolicy',additional_bindings: [{get: '/v1beta/{resource=projects/*/locations/global/hubs/*/groups/*}:getIamPolicy',},{get: '/v1beta/{resource=projects/*/locations/*/spokes/*}:getIamPolicy',},{get: '/v1beta/{resource=projects/*/locations/global/policyBasedRoutes/*}:getIamPolicy',}], - },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1beta/{resource=projects/*/locations/global/hubs/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1beta/{resource=projects/*/locations/global/hubs/*/groups/*}:setIamPolicy',body: '*',},{post: '/v1beta/{resource=projects/*/locations/*/spokes/*}:setIamPolicy',body: '*',},{post: '/v1beta/{resource=projects/*/locations/global/policyBasedRoutes/*}:setIamPolicy',body: '*',}], - },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1beta/{resource=projects/*/locations/global/hubs/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1beta/{resource=projects/*/locations/global/hubs/*/groups/*}:testIamPermissions',body: '*',},{post: '/v1beta/{resource=projects/*/locations/*/spokes/*}:testIamPermissions',body: '*',},{post: '/v1beta/{resource=projects/*/locations/global/policyBasedRoutes/*}:testIamPermissions',body: '*',}], - },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1beta/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1beta/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1beta/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1beta/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1beta/{resource=projects/*/locations/global/hubs/*}:getIamPolicy', + additional_bindings: [ + { + get: '/v1beta/{resource=projects/*/locations/global/hubs/*/groups/*}:getIamPolicy', + }, + { + get: '/v1beta/{resource=projects/*/locations/*/spokes/*}:getIamPolicy', + }, + { + get: '/v1beta/{resource=projects/*/locations/global/policyBasedRoutes/*}:getIamPolicy', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1beta/{resource=projects/*/locations/global/hubs/*}:setIamPolicy', + body: '*', + additional_bindings: [ + { + post: '/v1beta/{resource=projects/*/locations/global/hubs/*/groups/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1beta/{resource=projects/*/locations/*/spokes/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1beta/{resource=projects/*/locations/global/policyBasedRoutes/*}:setIamPolicy', + body: '*', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1beta/{resource=projects/*/locations/global/hubs/*}:testIamPermissions', + body: '*', + additional_bindings: [ + { + post: '/v1beta/{resource=projects/*/locations/global/hubs/*/groups/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1beta/{resource=projects/*/locations/*/spokes/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1beta/{resource=projects/*/locations/global/policyBasedRoutes/*}:testIamPermissions', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1beta/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1beta/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1beta/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1beta/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createTransportResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.Transport') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.Transport', + ) as gax.protobuf.Type; const createTransportMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const updateTransportResponse = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.Transport') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.Transport', + ) as gax.protobuf.Type; const updateTransportMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const deleteTransportResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteTransportMetadata = protoFilesRoot.lookup( - '.google.cloud.networkconnectivity.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkconnectivity.v1beta.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createTransport: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createTransportResponse.decode.bind(createTransportResponse), - createTransportMetadata.decode.bind(createTransportMetadata)), + createTransportMetadata.decode.bind(createTransportMetadata), + ), updateTransport: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateTransportResponse.decode.bind(updateTransportResponse), - updateTransportMetadata.decode.bind(updateTransportMetadata)), + updateTransportMetadata.decode.bind(updateTransportMetadata), + ), deleteTransport: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteTransportResponse.decode.bind(deleteTransportResponse), - deleteTransportMetadata.decode.bind(deleteTransportMetadata)) + deleteTransportMetadata.decode.bind(deleteTransportMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.networkconnectivity.v1beta.TransportManager', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.networkconnectivity.v1beta.TransportManager', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -322,28 +450,43 @@ export class TransportManagerClient { // Put together the "service stub" for // google.cloud.networkconnectivity.v1beta.TransportManager. this.transportManagerStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.networkconnectivity.v1beta.TransportManager') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.networkconnectivity.v1beta.TransportManager, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.networkconnectivity.v1beta.TransportManager', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.networkconnectivity.v1beta + .TransportManager, + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const transportManagerStubMethods = - ['listRemoteTransportProfiles', 'getRemoteTransportProfile', 'listTransports', 'getTransport', 'getStatus', 'createTransport', 'updateTransport', 'deleteTransport']; + const transportManagerStubMethods = [ + 'listRemoteTransportProfiles', + 'getRemoteTransportProfile', + 'listTransports', + 'getTransport', + 'getStatus', + 'createTransport', + 'updateTransport', + 'deleteTransport', + ]; for (const methodName of transportManagerStubMethods) { const callPromise = this.transportManagerStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -353,7 +496,7 @@ export class TransportManagerClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -368,8 +511,14 @@ export class TransportManagerClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkconnectivity.googleapis.com'; } @@ -380,8 +529,14 @@ export class TransportManagerClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkconnectivity.googleapis.com'; } @@ -412,9 +567,7 @@ export class TransportManagerClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -423,8 +576,9 @@ export class TransportManagerClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -435,749 +589,1107 @@ export class TransportManagerClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets details of a single RemoteTransportProfile. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource. - * @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 {@link protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile|RemoteTransportProfile}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/transport_manager.get_remote_transport_profile.js - * region_tag:networkconnectivity_v1beta_generated_TransportManager_GetRemoteTransportProfile_async - */ + /** + * Gets details of a single RemoteTransportProfile. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource. + * @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 {@link protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile|RemoteTransportProfile}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/transport_manager.get_remote_transport_profile.js + * region_tag:networkconnectivity_v1beta_generated_TransportManager_GetRemoteTransportProfile_async + */ getRemoteTransportProfile( - request?: protos.google.cloud.networkconnectivity.v1beta.IGetRemoteTransportProfileRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile, - protos.google.cloud.networkconnectivity.v1beta.IGetRemoteTransportProfileRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IGetRemoteTransportProfileRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetRemoteTransportProfileRequest + | undefined + ), + {} | undefined, + ] + >; getRemoteTransportProfile( - request: protos.google.cloud.networkconnectivity.v1beta.IGetRemoteTransportProfileRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile, - protos.google.cloud.networkconnectivity.v1beta.IGetRemoteTransportProfileRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IGetRemoteTransportProfileRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile, + | protos.google.cloud.networkconnectivity.v1beta.IGetRemoteTransportProfileRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getRemoteTransportProfile( - request: protos.google.cloud.networkconnectivity.v1beta.IGetRemoteTransportProfileRequest, - callback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile, - protos.google.cloud.networkconnectivity.v1beta.IGetRemoteTransportProfileRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IGetRemoteTransportProfileRequest, + callback: Callback< + protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile, + | protos.google.cloud.networkconnectivity.v1beta.IGetRemoteTransportProfileRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getRemoteTransportProfile( - request?: protos.google.cloud.networkconnectivity.v1beta.IGetRemoteTransportProfileRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile, - protos.google.cloud.networkconnectivity.v1beta.IGetRemoteTransportProfileRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkconnectivity.v1beta.IGetRemoteTransportProfileRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile, - protos.google.cloud.networkconnectivity.v1beta.IGetRemoteTransportProfileRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile, - protos.google.cloud.networkconnectivity.v1beta.IGetRemoteTransportProfileRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkconnectivity.v1beta.IGetRemoteTransportProfileRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile, + | protos.google.cloud.networkconnectivity.v1beta.IGetRemoteTransportProfileRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetRemoteTransportProfileRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getRemoteTransportProfile request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile, - protos.google.cloud.networkconnectivity.v1beta.IGetRemoteTransportProfileRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile, + | protos.google.cloud.networkconnectivity.v1beta.IGetRemoteTransportProfileRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getRemoteTransportProfile response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getRemoteTransportProfile(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile, - protos.google.cloud.networkconnectivity.v1beta.IGetRemoteTransportProfileRequest|undefined, - {}|undefined - ]) => { - this._log.info('getRemoteTransportProfile response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getRemoteTransportProfile(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetRemoteTransportProfileRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getRemoteTransportProfile response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single Transport. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource. - * @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 {@link protos.google.cloud.networkconnectivity.v1beta.Transport|Transport}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/transport_manager.get_transport.js - * region_tag:networkconnectivity_v1beta_generated_TransportManager_GetTransport_async - */ + /** + * Gets details of a single Transport. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource. + * @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 {@link protos.google.cloud.networkconnectivity.v1beta.Transport|Transport}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/transport_manager.get_transport.js + * region_tag:networkconnectivity_v1beta_generated_TransportManager_GetTransport_async + */ getTransport( - request?: protos.google.cloud.networkconnectivity.v1beta.IGetTransportRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.ITransport, - protos.google.cloud.networkconnectivity.v1beta.IGetTransportRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IGetTransportRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.ITransport, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetTransportRequest + | undefined + ), + {} | undefined, + ] + >; getTransport( - request: protos.google.cloud.networkconnectivity.v1beta.IGetTransportRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkconnectivity.v1beta.ITransport, - protos.google.cloud.networkconnectivity.v1beta.IGetTransportRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IGetTransportRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkconnectivity.v1beta.ITransport, + | protos.google.cloud.networkconnectivity.v1beta.IGetTransportRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getTransport( - request: protos.google.cloud.networkconnectivity.v1beta.IGetTransportRequest, - callback: Callback< - protos.google.cloud.networkconnectivity.v1beta.ITransport, - protos.google.cloud.networkconnectivity.v1beta.IGetTransportRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IGetTransportRequest, + callback: Callback< + protos.google.cloud.networkconnectivity.v1beta.ITransport, + | protos.google.cloud.networkconnectivity.v1beta.IGetTransportRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getTransport( - request?: protos.google.cloud.networkconnectivity.v1beta.IGetTransportRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkconnectivity.v1beta.ITransport, - protos.google.cloud.networkconnectivity.v1beta.IGetTransportRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkconnectivity.v1beta.IGetTransportRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkconnectivity.v1beta.ITransport, - protos.google.cloud.networkconnectivity.v1beta.IGetTransportRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.ITransport, - protos.google.cloud.networkconnectivity.v1beta.IGetTransportRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkconnectivity.v1beta.IGetTransportRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkconnectivity.v1beta.ITransport, + | protos.google.cloud.networkconnectivity.v1beta.IGetTransportRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.ITransport, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetTransportRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getTransport request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkconnectivity.v1beta.ITransport, - protos.google.cloud.networkconnectivity.v1beta.IGetTransportRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkconnectivity.v1beta.ITransport, + | protos.google.cloud.networkconnectivity.v1beta.IGetTransportRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getTransport response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getTransport(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkconnectivity.v1beta.ITransport, - protos.google.cloud.networkconnectivity.v1beta.IGetTransportRequest|undefined, - {}|undefined - ]) => { - this._log.info('getTransport response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getTransport(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkconnectivity.v1beta.ITransport, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetTransportRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getTransport response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets the operational status of a single Transport. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource. - * @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 {@link protos.google.cloud.networkconnectivity.v1beta.GetStatusResponse|GetStatusResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/transport_manager.get_status.js - * region_tag:networkconnectivity_v1beta_generated_TransportManager_GetStatus_async - */ + /** + * Gets the operational status of a single Transport. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource. + * @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 {@link protos.google.cloud.networkconnectivity.v1beta.GetStatusResponse|GetStatusResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/transport_manager.get_status.js + * region_tag:networkconnectivity_v1beta_generated_TransportManager_GetStatus_async + */ getStatus( - request?: protos.google.cloud.networkconnectivity.v1beta.IGetStatusRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IGetStatusResponse, - protos.google.cloud.networkconnectivity.v1beta.IGetStatusRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IGetStatusRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IGetStatusResponse, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetStatusRequest + | undefined + ), + {} | undefined, + ] + >; getStatus( - request: protos.google.cloud.networkconnectivity.v1beta.IGetStatusRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IGetStatusResponse, - protos.google.cloud.networkconnectivity.v1beta.IGetStatusRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IGetStatusRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkconnectivity.v1beta.IGetStatusResponse, + | protos.google.cloud.networkconnectivity.v1beta.IGetStatusRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getStatus( - request: protos.google.cloud.networkconnectivity.v1beta.IGetStatusRequest, - callback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IGetStatusResponse, - protos.google.cloud.networkconnectivity.v1beta.IGetStatusRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IGetStatusRequest, + callback: Callback< + protos.google.cloud.networkconnectivity.v1beta.IGetStatusResponse, + | protos.google.cloud.networkconnectivity.v1beta.IGetStatusRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getStatus( - request?: protos.google.cloud.networkconnectivity.v1beta.IGetStatusRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkconnectivity.v1beta.IGetStatusResponse, - protos.google.cloud.networkconnectivity.v1beta.IGetStatusRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkconnectivity.v1beta.IGetStatusRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkconnectivity.v1beta.IGetStatusResponse, - protos.google.cloud.networkconnectivity.v1beta.IGetStatusRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IGetStatusResponse, - protos.google.cloud.networkconnectivity.v1beta.IGetStatusRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkconnectivity.v1beta.IGetStatusRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkconnectivity.v1beta.IGetStatusResponse, + | protos.google.cloud.networkconnectivity.v1beta.IGetStatusRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IGetStatusResponse, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetStatusRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getStatus request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkconnectivity.v1beta.IGetStatusResponse, - protos.google.cloud.networkconnectivity.v1beta.IGetStatusRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkconnectivity.v1beta.IGetStatusResponse, + | protos.google.cloud.networkconnectivity.v1beta.IGetStatusRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getStatus response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getStatus(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkconnectivity.v1beta.IGetStatusResponse, - protos.google.cloud.networkconnectivity.v1beta.IGetStatusRequest|undefined, - {}|undefined - ]) => { - this._log.info('getStatus response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getStatus(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkconnectivity.v1beta.IGetStatusResponse, + ( + | protos.google.cloud.networkconnectivity.v1beta.IGetStatusRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getStatus response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a new Transport in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Value for parent. - * @param {string} request.transportId - * Required. Id of the requesting object - * @param {google.cloud.networkconnectivity.v1beta.Transport} request.transport - * Required. The resource being created - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1beta/transport_manager.create_transport.js - * region_tag:networkconnectivity_v1beta_generated_TransportManager_CreateTransport_async - */ + /** + * Creates a new Transport in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Value for parent. + * @param {string} request.transportId + * Required. Id of the requesting object + * @param {google.cloud.networkconnectivity.v1beta.Transport} request.transport + * Required. The resource being created + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1beta/transport_manager.create_transport.js + * region_tag:networkconnectivity_v1beta_generated_TransportManager_CreateTransport_async + */ createTransport( - request?: protos.google.cloud.networkconnectivity.v1beta.ICreateTransportRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.ICreateTransportRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ITransport, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createTransport( - request: protos.google.cloud.networkconnectivity.v1beta.ICreateTransportRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.ICreateTransportRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ITransport, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createTransport( - request: protos.google.cloud.networkconnectivity.v1beta.ICreateTransportRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.ICreateTransportRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ITransport, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createTransport( - request?: protos.google.cloud.networkconnectivity.v1beta.ICreateTransportRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1beta.ICreateTransportRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ITransport, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ITransport, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ITransport, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ITransport, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createTransport response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createTransport request %j', request); - return this.innerApiCalls.createTransport(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createTransport response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createTransport(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ITransport, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createTransport response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createTransport()`. - * @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/v1beta/transport_manager.create_transport.js - * region_tag:networkconnectivity_v1beta_generated_TransportManager_CreateTransport_async - */ - async checkCreateTransportProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createTransport()`. + * @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/v1beta/transport_manager.create_transport.js + * region_tag:networkconnectivity_v1beta_generated_TransportManager_CreateTransport_async + */ + async checkCreateTransportProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.Transport, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + > + > { this._log.info('createTransport long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createTransport, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createTransport, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1beta.Transport, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + >; } -/** - * Updates the parameters of a single Transport. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask is used to specify the fields to be overwritten in the - * Transport resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields present in the request will be - * overwritten. - * @param {google.cloud.networkconnectivity.v1beta.Transport} request.transport - * Required. The resource being updated. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1beta/transport_manager.update_transport.js - * region_tag:networkconnectivity_v1beta_generated_TransportManager_UpdateTransport_async - */ + /** + * Updates the parameters of a single Transport. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask is used to specify the fields to be overwritten in the + * Transport resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields present in the request will be + * overwritten. + * @param {google.cloud.networkconnectivity.v1beta.Transport} request.transport + * Required. The resource being updated. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1beta/transport_manager.update_transport.js + * region_tag:networkconnectivity_v1beta_generated_TransportManager_UpdateTransport_async + */ updateTransport( - request?: protos.google.cloud.networkconnectivity.v1beta.IUpdateTransportRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IUpdateTransportRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ITransport, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateTransport( - request: protos.google.cloud.networkconnectivity.v1beta.IUpdateTransportRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IUpdateTransportRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ITransport, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateTransport( - request: protos.google.cloud.networkconnectivity.v1beta.IUpdateTransportRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IUpdateTransportRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ITransport, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateTransport( - request?: protos.google.cloud.networkconnectivity.v1beta.IUpdateTransportRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1beta.IUpdateTransportRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ITransport, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ITransport, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ITransport, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'transport.name': request.transport!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'transport.name': request.transport!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ITransport, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateTransport response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateTransport request %j', request); - return this.innerApiCalls.updateTransport(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateTransport response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateTransport(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkconnectivity.v1beta.ITransport, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateTransport response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateTransport()`. - * @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/v1beta/transport_manager.update_transport.js - * region_tag:networkconnectivity_v1beta_generated_TransportManager_UpdateTransport_async - */ - async checkUpdateTransportProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateTransport()`. + * @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/v1beta/transport_manager.update_transport.js + * region_tag:networkconnectivity_v1beta_generated_TransportManager_UpdateTransport_async + */ + async checkUpdateTransportProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkconnectivity.v1beta.Transport, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + > + > { this._log.info('updateTransport long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateTransport, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateTransport, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkconnectivity.v1beta.Transport, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + >; } -/** - * Deletes a single Transport. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1beta/transport_manager.delete_transport.js - * region_tag:networkconnectivity_v1beta_generated_TransportManager_DeleteTransport_async - */ + /** + * Deletes a single Transport. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1beta/transport_manager.delete_transport.js + * region_tag:networkconnectivity_v1beta_generated_TransportManager_DeleteTransport_async + */ deleteTransport( - request?: protos.google.cloud.networkconnectivity.v1beta.IDeleteTransportRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IDeleteTransportRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteTransport( - request: protos.google.cloud.networkconnectivity.v1beta.IDeleteTransportRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IDeleteTransportRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteTransport( - request: protos.google.cloud.networkconnectivity.v1beta.IDeleteTransportRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IDeleteTransportRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteTransport( - request?: protos.google.cloud.networkconnectivity.v1beta.IDeleteTransportRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkconnectivity.v1beta.IDeleteTransportRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteTransport response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteTransport request %j', request); - return this.innerApiCalls.deleteTransport(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteTransport response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteTransport(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteTransport response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteTransport()`. - * @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/v1beta/transport_manager.delete_transport.js - * region_tag:networkconnectivity_v1beta_generated_TransportManager_DeleteTransport_async - */ - async checkDeleteTransportProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteTransport()`. + * @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/v1beta/transport_manager.delete_transport.js + * region_tag:networkconnectivity_v1beta_generated_TransportManager_DeleteTransport_async + */ + async checkDeleteTransportProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + > + > { this._log.info('deleteTransport long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteTransport, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists RemoteTransportProfiles in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListRemoteTransportProfilesRequest. - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Filtering results. - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results. - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile|RemoteTransportProfile}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listRemoteTransportProfilesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteTransport, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkconnectivity.v1beta.OperationMetadata + >; + } + /** + * Lists RemoteTransportProfiles in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListRemoteTransportProfilesRequest. + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Filtering results. + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results. + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile|RemoteTransportProfile}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listRemoteTransportProfilesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listRemoteTransportProfiles( - request?: protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile[], - protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile[], + protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesResponse, + ] + >; listRemoteTransportProfiles( - request: protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile + >, + ): void; listRemoteTransportProfiles( - request: protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile + >, + ): void; listRemoteTransportProfiles( - request?: protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile>): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile[], - protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile[], + protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesRequest, - protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listRemoteTransportProfiles values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1186,204 +1698,233 @@ export class TransportManagerClient { this._log.info('listRemoteTransportProfiles request %j', request); return this.innerApiCalls .listRemoteTransportProfiles(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile[], - protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesResponse - ]) => { - this._log.info('listRemoteTransportProfiles values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile[], + protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesResponse, + ]) => { + this._log.info('listRemoteTransportProfiles values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listRemoteTransportProfiles`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListRemoteTransportProfilesRequest. - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Filtering results. - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile|RemoteTransportProfile} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listRemoteTransportProfilesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listRemoteTransportProfiles`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListRemoteTransportProfilesRequest. + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Filtering results. + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile|RemoteTransportProfile} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listRemoteTransportProfilesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listRemoteTransportProfilesStream( - request?: protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listRemoteTransportProfiles']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listRemoteTransportProfiles stream %j', request); return this.descriptors.page.listRemoteTransportProfiles.createStream( this.innerApiCalls.listRemoteTransportProfiles as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listRemoteTransportProfiles`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListRemoteTransportProfilesRequest. - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Filtering results. - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile|RemoteTransportProfile}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/transport_manager.list_remote_transport_profiles.js - * region_tag:networkconnectivity_v1beta_generated_TransportManager_ListRemoteTransportProfiles_async - */ + /** + * Equivalent to `listRemoteTransportProfiles`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListRemoteTransportProfilesRequest. + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Filtering results. + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile|RemoteTransportProfile}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/transport_manager.list_remote_transport_profiles.js + * region_tag:networkconnectivity_v1beta_generated_TransportManager_ListRemoteTransportProfiles_async + */ listRemoteTransportProfilesAsync( - request?: protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1beta.IListRemoteTransportProfilesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listRemoteTransportProfiles']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listRemoteTransportProfiles iterate %j', request); return this.descriptors.page.listRemoteTransportProfiles.asyncIterate( this.innerApiCalls['listRemoteTransportProfiles'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists Transports in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListTransportsRequest. - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Filtering results. - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results. - * @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 Array of {@link protos.google.cloud.networkconnectivity.v1beta.Transport|Transport}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listTransportsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists Transports in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListTransportsRequest. + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Filtering results. + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results. + * @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 Array of {@link protos.google.cloud.networkconnectivity.v1beta.Transport|Transport}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listTransportsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listTransports( - request?: protos.google.cloud.networkconnectivity.v1beta.IListTransportsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.ITransport[], - protos.google.cloud.networkconnectivity.v1beta.IListTransportsRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListTransportsResponse - ]>; + request?: protos.google.cloud.networkconnectivity.v1beta.IListTransportsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.ITransport[], + protos.google.cloud.networkconnectivity.v1beta.IListTransportsRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListTransportsResponse, + ] + >; listTransports( - request: protos.google.cloud.networkconnectivity.v1beta.IListTransportsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListTransportsRequest, - protos.google.cloud.networkconnectivity.v1beta.IListTransportsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.ITransport>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IListTransportsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListTransportsRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListTransportsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.ITransport + >, + ): void; listTransports( - request: protos.google.cloud.networkconnectivity.v1beta.IListTransportsRequest, - callback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListTransportsRequest, - protos.google.cloud.networkconnectivity.v1beta.IListTransportsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.ITransport>): void; + request: protos.google.cloud.networkconnectivity.v1beta.IListTransportsRequest, + callback: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListTransportsRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListTransportsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.ITransport + >, + ): void; listTransports( - request?: protos.google.cloud.networkconnectivity.v1beta.IListTransportsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListTransportsRequest, - protos.google.cloud.networkconnectivity.v1beta.IListTransportsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.ITransport>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkconnectivity.v1beta.IListTransportsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkconnectivity.v1beta.IListTransportsRequest, - protos.google.cloud.networkconnectivity.v1beta.IListTransportsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.ITransport>): - Promise<[ - protos.google.cloud.networkconnectivity.v1beta.ITransport[], - protos.google.cloud.networkconnectivity.v1beta.IListTransportsRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListTransportsResponse - ]>|void { + | protos.google.cloud.networkconnectivity.v1beta.IListTransportsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.ITransport + >, + callback?: PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListTransportsRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListTransportsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.ITransport + >, + ): Promise< + [ + protos.google.cloud.networkconnectivity.v1beta.ITransport[], + protos.google.cloud.networkconnectivity.v1beta.IListTransportsRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListTransportsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkconnectivity.v1beta.IListTransportsRequest, - protos.google.cloud.networkconnectivity.v1beta.IListTransportsResponse|null|undefined, - protos.google.cloud.networkconnectivity.v1beta.ITransport>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkconnectivity.v1beta.IListTransportsRequest, + | protos.google.cloud.networkconnectivity.v1beta.IListTransportsResponse + | null + | undefined, + protos.google.cloud.networkconnectivity.v1beta.ITransport + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listTransports values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1392,143 +1933,147 @@ export class TransportManagerClient { this._log.info('listTransports request %j', request); return this.innerApiCalls .listTransports(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkconnectivity.v1beta.ITransport[], - protos.google.cloud.networkconnectivity.v1beta.IListTransportsRequest|null, - protos.google.cloud.networkconnectivity.v1beta.IListTransportsResponse - ]) => { - this._log.info('listTransports values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkconnectivity.v1beta.ITransport[], + protos.google.cloud.networkconnectivity.v1beta.IListTransportsRequest | null, + protos.google.cloud.networkconnectivity.v1beta.IListTransportsResponse, + ]) => { + this._log.info('listTransports values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listTransports`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListTransportsRequest. - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Filtering results. - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1beta.Transport|Transport} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listTransportsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listTransports`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListTransportsRequest. + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Filtering results. + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkconnectivity.v1beta.Transport|Transport} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listTransportsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listTransportsStream( - request?: protos.google.cloud.networkconnectivity.v1beta.IListTransportsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkconnectivity.v1beta.IListTransportsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listTransports']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listTransports stream %j', request); return this.descriptors.page.listTransports.createStream( this.innerApiCalls.listTransports as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listTransports`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListTransportsRequest. - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Filtering results. - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkconnectivity.v1beta.Transport|Transport}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/transport_manager.list_transports.js - * region_tag:networkconnectivity_v1beta_generated_TransportManager_ListTransports_async - */ + /** + * Equivalent to `listTransports`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListTransportsRequest. + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Filtering results. + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkconnectivity.v1beta.Transport|Transport}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/transport_manager.list_transports.js + * region_tag:networkconnectivity_v1beta_generated_TransportManager_ListTransports_async + */ listTransportsAsync( - request?: protos.google.cloud.networkconnectivity.v1beta.IListTransportsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkconnectivity.v1beta.IListTransportsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listTransports']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listTransports iterate %j', request); return this.descriptors.page.listTransports.asyncIterate( this.innerApiCalls['listTransports'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -1542,40 +2087,40 @@ export class TransportManagerClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -1589,41 +2134,41 @@ export class TransportManagerClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -1637,12 +2182,12 @@ export class TransportManagerClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -1677,12 +2222,11 @@ export class TransportManagerClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -1715,12 +2259,12 @@ export class TransportManagerClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -1763,22 +2307,22 @@ export class TransportManagerClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -1813,15 +2357,15 @@ export class TransportManagerClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - 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 ?? '', - }); + 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 ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -1855,7 +2399,7 @@ export class TransportManagerClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -1868,25 +2412,24 @@ export class TransportManagerClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -1925,22 +2468,22 @@ export class TransportManagerClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -1957,7 +2500,12 @@ export class TransportManagerClient { * @param {string} destination * @returns {string} Resource name string. */ - destinationPath(project:string,location:string,multicloudDataTransferConfig:string,destination:string) { + destinationPath( + project: string, + location: string, + multicloudDataTransferConfig: string, + destination: string, + ) { return this.pathTemplates.destinationPathTemplate.render({ project: project, location: location, @@ -1974,7 +2522,8 @@ export class TransportManagerClient { * @returns {string} A string representing the project. */ matchProjectFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).project; + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .project; } /** @@ -1985,7 +2534,8 @@ export class TransportManagerClient { * @returns {string} A string representing the location. */ matchLocationFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).location; + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .location; } /** @@ -1995,8 +2545,11 @@ export class TransportManagerClient { * A fully-qualified path representing Destination resource. * @returns {string} A string representing the multicloud_data_transfer_config. */ - matchMulticloudDataTransferConfigFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).multicloud_data_transfer_config; + matchMulticloudDataTransferConfigFromDestinationName( + destinationName: string, + ) { + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .multicloud_data_transfer_config; } /** @@ -2007,7 +2560,8 @@ export class TransportManagerClient { * @returns {string} A string representing the destination. */ matchDestinationFromDestinationName(destinationName: string) { - return this.pathTemplates.destinationPathTemplate.match(destinationName).destination; + return this.pathTemplates.destinationPathTemplate.match(destinationName) + .destination; } /** @@ -2019,7 +2573,12 @@ export class TransportManagerClient { * @param {string} gateway_advertised_route * @returns {string} Resource name string. */ - gatewayAdvertisedRoutePath(project:string,location:string,spoke:string,gatewayAdvertisedRoute:string) { + gatewayAdvertisedRoutePath( + project: string, + location: string, + spoke: string, + gatewayAdvertisedRoute: string, + ) { return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.render({ project: project, location: location, @@ -2035,8 +2594,12 @@ export class TransportManagerClient { * A fully-qualified path representing GatewayAdvertisedRoute resource. * @returns {string} A string representing the project. */ - matchProjectFromGatewayAdvertisedRouteName(gatewayAdvertisedRouteName: string) { - return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match(gatewayAdvertisedRouteName).project; + matchProjectFromGatewayAdvertisedRouteName( + gatewayAdvertisedRouteName: string, + ) { + return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match( + gatewayAdvertisedRouteName, + ).project; } /** @@ -2046,8 +2609,12 @@ export class TransportManagerClient { * A fully-qualified path representing GatewayAdvertisedRoute resource. * @returns {string} A string representing the location. */ - matchLocationFromGatewayAdvertisedRouteName(gatewayAdvertisedRouteName: string) { - return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match(gatewayAdvertisedRouteName).location; + matchLocationFromGatewayAdvertisedRouteName( + gatewayAdvertisedRouteName: string, + ) { + return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match( + gatewayAdvertisedRouteName, + ).location; } /** @@ -2058,7 +2625,9 @@ export class TransportManagerClient { * @returns {string} A string representing the spoke. */ matchSpokeFromGatewayAdvertisedRouteName(gatewayAdvertisedRouteName: string) { - return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match(gatewayAdvertisedRouteName).spoke; + return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match( + gatewayAdvertisedRouteName, + ).spoke; } /** @@ -2068,8 +2637,12 @@ export class TransportManagerClient { * A fully-qualified path representing GatewayAdvertisedRoute resource. * @returns {string} A string representing the gateway_advertised_route. */ - matchGatewayAdvertisedRouteFromGatewayAdvertisedRouteName(gatewayAdvertisedRouteName: string) { - return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match(gatewayAdvertisedRouteName).gateway_advertised_route; + matchGatewayAdvertisedRouteFromGatewayAdvertisedRouteName( + gatewayAdvertisedRouteName: string, + ) { + return this.pathTemplates.gatewayAdvertisedRoutePathTemplate.match( + gatewayAdvertisedRouteName, + ).gateway_advertised_route; } /** @@ -2080,7 +2653,7 @@ export class TransportManagerClient { * @param {string} group * @returns {string} Resource name string. */ - groupPath(project:string,hub:string,group:string) { + groupPath(project: string, hub: string, group: string) { return this.pathTemplates.groupPathTemplate.render({ project: project, hub: hub, @@ -2128,7 +2701,7 @@ export class TransportManagerClient { * @param {string} hub * @returns {string} Resource name string. */ - hubPath(project:string,hub:string) { + hubPath(project: string, hub: string) { return this.pathTemplates.hubPathTemplate.render({ project: project, hub: hub, @@ -2166,7 +2739,12 @@ export class TransportManagerClient { * @param {string} route * @returns {string} Resource name string. */ - hubRoutePath(project:string,hub:string,routeTable:string,route:string) { + hubRoutePath( + project: string, + hub: string, + routeTable: string, + route: string, + ) { return this.pathTemplates.hubRoutePathTemplate.render({ project: project, hub: hub, @@ -2205,7 +2783,8 @@ export class TransportManagerClient { * @returns {string} A string representing the route_table. */ matchRouteTableFromHubRouteName(hubRouteName: string) { - return this.pathTemplates.hubRoutePathTemplate.match(hubRouteName).route_table; + return this.pathTemplates.hubRoutePathTemplate.match(hubRouteName) + .route_table; } /** @@ -2226,7 +2805,7 @@ export class TransportManagerClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -2263,7 +2842,11 @@ export class TransportManagerClient { * @param {string} multicloud_data_transfer_config * @returns {string} Resource name string. */ - multicloudDataTransferConfigPath(project:string,location:string,multicloudDataTransferConfig:string) { + multicloudDataTransferConfigPath( + project: string, + location: string, + multicloudDataTransferConfig: string, + ) { return this.pathTemplates.multicloudDataTransferConfigPathTemplate.render({ project: project, location: location, @@ -2278,8 +2861,12 @@ export class TransportManagerClient { * A fully-qualified path representing MulticloudDataTransferConfig resource. * @returns {string} A string representing the project. */ - matchProjectFromMulticloudDataTransferConfigName(multicloudDataTransferConfigName: string) { - return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match(multicloudDataTransferConfigName).project; + matchProjectFromMulticloudDataTransferConfigName( + multicloudDataTransferConfigName: string, + ) { + return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match( + multicloudDataTransferConfigName, + ).project; } /** @@ -2289,8 +2876,12 @@ export class TransportManagerClient { * A fully-qualified path representing MulticloudDataTransferConfig resource. * @returns {string} A string representing the location. */ - matchLocationFromMulticloudDataTransferConfigName(multicloudDataTransferConfigName: string) { - return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match(multicloudDataTransferConfigName).location; + matchLocationFromMulticloudDataTransferConfigName( + multicloudDataTransferConfigName: string, + ) { + return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match( + multicloudDataTransferConfigName, + ).location; } /** @@ -2300,8 +2891,12 @@ export class TransportManagerClient { * A fully-qualified path representing MulticloudDataTransferConfig resource. * @returns {string} A string representing the multicloud_data_transfer_config. */ - matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName(multicloudDataTransferConfigName: string) { - return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match(multicloudDataTransferConfigName).multicloud_data_transfer_config; + matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName( + multicloudDataTransferConfigName: string, + ) { + return this.pathTemplates.multicloudDataTransferConfigPathTemplate.match( + multicloudDataTransferConfigName, + ).multicloud_data_transfer_config; } /** @@ -2312,12 +2907,19 @@ export class TransportManagerClient { * @param {string} multicloud_data_transfer_supported_service * @returns {string} Resource name string. */ - multicloudDataTransferSupportedServicePath(project:string,location:string,multicloudDataTransferSupportedService:string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render({ - project: project, - location: location, - multicloud_data_transfer_supported_service: multicloudDataTransferSupportedService, - }); + multicloudDataTransferSupportedServicePath( + project: string, + location: string, + multicloudDataTransferSupportedService: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render( + { + project: project, + location: location, + multicloud_data_transfer_supported_service: + multicloudDataTransferSupportedService, + }, + ); } /** @@ -2327,8 +2929,12 @@ export class TransportManagerClient { * A fully-qualified path representing MulticloudDataTransferSupportedService resource. * @returns {string} A string representing the project. */ - matchProjectFromMulticloudDataTransferSupportedServiceName(multicloudDataTransferSupportedServiceName: string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match(multicloudDataTransferSupportedServiceName).project; + matchProjectFromMulticloudDataTransferSupportedServiceName( + multicloudDataTransferSupportedServiceName: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match( + multicloudDataTransferSupportedServiceName, + ).project; } /** @@ -2338,8 +2944,12 @@ export class TransportManagerClient { * A fully-qualified path representing MulticloudDataTransferSupportedService resource. * @returns {string} A string representing the location. */ - matchLocationFromMulticloudDataTransferSupportedServiceName(multicloudDataTransferSupportedServiceName: string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match(multicloudDataTransferSupportedServiceName).location; + matchLocationFromMulticloudDataTransferSupportedServiceName( + multicloudDataTransferSupportedServiceName: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match( + multicloudDataTransferSupportedServiceName, + ).location; } /** @@ -2349,8 +2959,12 @@ export class TransportManagerClient { * A fully-qualified path representing MulticloudDataTransferSupportedService resource. * @returns {string} A string representing the multicloud_data_transfer_supported_service. */ - matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName(multicloudDataTransferSupportedServiceName: string) { - return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match(multicloudDataTransferSupportedServiceName).multicloud_data_transfer_supported_service; + matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName( + multicloudDataTransferSupportedServiceName: string, + ) { + return this.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match( + multicloudDataTransferSupportedServiceName, + ).multicloud_data_transfer_supported_service; } /** @@ -2360,7 +2974,7 @@ export class TransportManagerClient { * @param {string} resource_id * @returns {string} Resource name string. */ - networkPath(project:string,resourceId:string) { + networkPath(project: string, resourceId: string) { return this.pathTemplates.networkPathTemplate.render({ project: project, resource_id: resourceId, @@ -2386,7 +3000,8 @@ export class TransportManagerClient { * @returns {string} A string representing the resource_id. */ matchResourceIdFromNetworkName(networkName: string) { - return this.pathTemplates.networkPathTemplate.match(networkName).resource_id; + return this.pathTemplates.networkPathTemplate.match(networkName) + .resource_id; } /** @@ -2396,7 +3011,7 @@ export class TransportManagerClient { * @param {string} policy_based_route * @returns {string} Resource name string. */ - policyBasedRoutePath(project:string,policyBasedRoute:string) { + policyBasedRoutePath(project: string, policyBasedRoute: string) { return this.pathTemplates.policyBasedRoutePathTemplate.render({ project: project, policy_based_route: policyBasedRoute, @@ -2411,7 +3026,9 @@ export class TransportManagerClient { * @returns {string} A string representing the project. */ matchProjectFromPolicyBasedRouteName(policyBasedRouteName: string) { - return this.pathTemplates.policyBasedRoutePathTemplate.match(policyBasedRouteName).project; + return this.pathTemplates.policyBasedRoutePathTemplate.match( + policyBasedRouteName, + ).project; } /** @@ -2422,7 +3039,9 @@ export class TransportManagerClient { * @returns {string} A string representing the policy_based_route. */ matchPolicyBasedRouteFromPolicyBasedRouteName(policyBasedRouteName: string) { - return this.pathTemplates.policyBasedRoutePathTemplate.match(policyBasedRouteName).policy_based_route; + return this.pathTemplates.policyBasedRoutePathTemplate.match( + policyBasedRouteName, + ).policy_based_route; } /** @@ -2431,7 +3050,7 @@ export class TransportManagerClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -2456,7 +3075,11 @@ export class TransportManagerClient { * @param {string} remote_transport_profile * @returns {string} Resource name string. */ - remoteTransportProfilePath(project:string,location:string,remoteTransportProfile:string) { + remoteTransportProfilePath( + project: string, + location: string, + remoteTransportProfile: string, + ) { return this.pathTemplates.remoteTransportProfilePathTemplate.render({ project: project, location: location, @@ -2471,8 +3094,12 @@ export class TransportManagerClient { * A fully-qualified path representing RemoteTransportProfile resource. * @returns {string} A string representing the project. */ - matchProjectFromRemoteTransportProfileName(remoteTransportProfileName: string) { - return this.pathTemplates.remoteTransportProfilePathTemplate.match(remoteTransportProfileName).project; + matchProjectFromRemoteTransportProfileName( + remoteTransportProfileName: string, + ) { + return this.pathTemplates.remoteTransportProfilePathTemplate.match( + remoteTransportProfileName, + ).project; } /** @@ -2482,8 +3109,12 @@ export class TransportManagerClient { * A fully-qualified path representing RemoteTransportProfile resource. * @returns {string} A string representing the location. */ - matchLocationFromRemoteTransportProfileName(remoteTransportProfileName: string) { - return this.pathTemplates.remoteTransportProfilePathTemplate.match(remoteTransportProfileName).location; + matchLocationFromRemoteTransportProfileName( + remoteTransportProfileName: string, + ) { + return this.pathTemplates.remoteTransportProfilePathTemplate.match( + remoteTransportProfileName, + ).location; } /** @@ -2493,8 +3124,12 @@ export class TransportManagerClient { * A fully-qualified path representing RemoteTransportProfile resource. * @returns {string} A string representing the remote_transport_profile. */ - matchRemoteTransportProfileFromRemoteTransportProfileName(remoteTransportProfileName: string) { - return this.pathTemplates.remoteTransportProfilePathTemplate.match(remoteTransportProfileName).remote_transport_profile; + matchRemoteTransportProfileFromRemoteTransportProfileName( + remoteTransportProfileName: string, + ) { + return this.pathTemplates.remoteTransportProfilePathTemplate.match( + remoteTransportProfileName, + ).remote_transport_profile; } /** @@ -2505,7 +3140,7 @@ export class TransportManagerClient { * @param {string} route_table * @returns {string} Resource name string. */ - routeTablePath(project:string,hub:string,routeTable:string) { + routeTablePath(project: string, hub: string, routeTable: string) { return this.pathTemplates.routeTablePathTemplate.render({ project: project, hub: hub, @@ -2521,7 +3156,8 @@ export class TransportManagerClient { * @returns {string} A string representing the project. */ matchProjectFromRouteTableName(routeTableName: string) { - return this.pathTemplates.routeTablePathTemplate.match(routeTableName).project; + return this.pathTemplates.routeTablePathTemplate.match(routeTableName) + .project; } /** @@ -2543,7 +3179,8 @@ export class TransportManagerClient { * @returns {string} A string representing the route_table. */ matchRouteTableFromRouteTableName(routeTableName: string) { - return this.pathTemplates.routeTablePathTemplate.match(routeTableName).route_table; + return this.pathTemplates.routeTablePathTemplate.match(routeTableName) + .route_table; } /** @@ -2554,7 +3191,7 @@ export class TransportManagerClient { * @param {string} spoke * @returns {string} Resource name string. */ - spokePath(project:string,location:string,spoke:string) { + spokePath(project: string, location: string, spoke: string) { return this.pathTemplates.spokePathTemplate.render({ project: project, location: location, @@ -2603,7 +3240,7 @@ export class TransportManagerClient { * @param {string} transport * @returns {string} Resource name string. */ - transportPath(project:string,location:string,transport:string) { + transportPath(project: string, location: string, transport: string) { return this.pathTemplates.transportPathTemplate.render({ project: project, location: location, @@ -2619,7 +3256,8 @@ export class TransportManagerClient { * @returns {string} A string representing the project. */ matchProjectFromTransportName(transportName: string) { - return this.pathTemplates.transportPathTemplate.match(transportName).project; + return this.pathTemplates.transportPathTemplate.match(transportName) + .project; } /** @@ -2630,7 +3268,8 @@ export class TransportManagerClient { * @returns {string} A string representing the location. */ matchLocationFromTransportName(transportName: string) { - return this.pathTemplates.transportPathTemplate.match(transportName).location; + return this.pathTemplates.transportPathTemplate.match(transportName) + .location; } /** @@ -2641,7 +3280,8 @@ export class TransportManagerClient { * @returns {string} A string representing the transport. */ matchTransportFromTransportName(transportName: string) { - return this.pathTemplates.transportPathTemplate.match(transportName).transport; + return this.pathTemplates.transportPathTemplate.match(transportName) + .transport; } /** @@ -2652,15 +3292,19 @@ export class TransportManagerClient { */ close(): Promise { if (this.transportManagerStub && !this._terminated) { - return this.transportManagerStub.then(stub => { + return this.transportManagerStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-networkconnectivity/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-networkconnectivity/system-test/fixtures/sample/src/index.ts index 84fff8c7a069..47ab64353067 100644 --- a/packages/google-cloud-networkconnectivity/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-networkconnectivity/system-test/fixtures/sample/src/index.ts @@ -16,29 +16,46 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {CrossNetworkAutomationServiceClient, DataTransferServiceClient, HubServiceClient, InternalRangeServiceClient, PolicyBasedRoutingServiceClient} from '@google-cloud/network-connectivity'; +import { + CrossNetworkAutomationServiceClient, + DataTransferServiceClient, + HubServiceClient, + InternalRangeServiceClient, + PolicyBasedRoutingServiceClient, +} from '@google-cloud/network-connectivity'; // check that the client class type name can be used -function doStuffWithCrossNetworkAutomationServiceClient(client: CrossNetworkAutomationServiceClient) { +function doStuffWithCrossNetworkAutomationServiceClient( + client: CrossNetworkAutomationServiceClient, +) { client.close(); } -function doStuffWithDataTransferServiceClient(client: DataTransferServiceClient) { +function doStuffWithDataTransferServiceClient( + client: DataTransferServiceClient, +) { client.close(); } function doStuffWithHubServiceClient(client: HubServiceClient) { client.close(); } -function doStuffWithInternalRangeServiceClient(client: InternalRangeServiceClient) { +function doStuffWithInternalRangeServiceClient( + client: InternalRangeServiceClient, +) { client.close(); } -function doStuffWithPolicyBasedRoutingServiceClient(client: PolicyBasedRoutingServiceClient) { +function doStuffWithPolicyBasedRoutingServiceClient( + client: PolicyBasedRoutingServiceClient, +) { client.close(); } function main() { // check that the client instance can be created - const crossNetworkAutomationServiceClient = new CrossNetworkAutomationServiceClient(); - doStuffWithCrossNetworkAutomationServiceClient(crossNetworkAutomationServiceClient); + const crossNetworkAutomationServiceClient = + new CrossNetworkAutomationServiceClient(); + doStuffWithCrossNetworkAutomationServiceClient( + crossNetworkAutomationServiceClient, + ); // check that the client instance can be created const dataTransferServiceClient = new DataTransferServiceClient(); doStuffWithDataTransferServiceClient(dataTransferServiceClient); diff --git a/packages/google-cloud-networkconnectivity/system-test/install.ts b/packages/google-cloud-networkconnectivity/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-networkconnectivity/system-test/install.ts +++ b/packages/google-cloud-networkconnectivity/system-test/install.ts @@ -16,34 +16,36 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {packNTest} from 'pack-n-play'; -import {readFileSync} from 'fs'; -import {describe, it} from 'mocha'; +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; +import { describe, it } from 'mocha'; describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { + it('TypeScript code', async function () { this.timeout(300000); const options = { packageDir: process.cwd(), sample: { description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } + ts: readFileSync( + './system-test/fixtures/sample/src/index.ts', + ).toString(), + }, }; await packNTest(options); }); - it('JavaScript code', async function() { + it('JavaScript code', async function () { this.timeout(300000); const options = { packageDir: process.cwd(), sample: { description: 'JavaScript user can use the library', - cjs: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } + cjs: readFileSync( + './system-test/fixtures/sample/src/index.js', + ).toString(), + }, }; await packNTest(options); }); - }); diff --git a/packages/google-cloud-networkconnectivity/test/gapic_cross_network_automation_service_v1.ts b/packages/google-cloud-networkconnectivity/test/gapic_cross_network_automation_service_v1.ts index 026bc56127b0..461b9858b4e7 100644 --- a/packages/google-cloud-networkconnectivity/test/gapic_cross_network_automation_service_v1.ts +++ b/packages/google-cloud-networkconnectivity/test/gapic_cross_network_automation_service_v1.ts @@ -19,4673 +19,6744 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as crossnetworkautomationserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + IamProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1.CrossNetworkAutomationServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient.servicePath; - assert.strictEqual(servicePath, 'networkconnectivity.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.example.com'); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + crossnetworkautomationserviceModule.v1 + .CrossNetworkAutomationServiceClient.servicePath; + assert.strictEqual(servicePath, 'networkconnectivity.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + crossnetworkautomationserviceModule.v1 + .CrossNetworkAutomationServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { universeDomain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkconnectivity.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { universe_domain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkconnectivity.example.com'); + }); - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkconnectivity.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { universeDomain: 'configured.example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'networkconnectivity.configured.example.com', + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { universe_domain: 'example.com', universeDomain: 'example.net' }, + ); + }); + }); - it('has port', () => { - const port = crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); + it('has port', () => { + const port = + crossnetworkautomationserviceModule.v1 + .CrossNetworkAutomationServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('should create a client with no option', () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient(); - assert(client); - }); + it('should create a client with no option', () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient(); + assert(client); + }); - it('should create a client with gRPC fallback', () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - fallback: true, - }); - assert(client); - }); + it('should create a client with gRPC fallback', () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + fallback: true, + }, + ); + assert(client); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.crossNetworkAutomationServiceStub, undefined); - await client.initialize(); - assert(client.crossNetworkAutomationServiceStub); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.crossNetworkAutomationServiceStub, undefined); + await client.initialize(); + assert(client.crossNetworkAutomationServiceStub); + }); - it('has close method for the initialized client', done => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.crossNetworkAutomationServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the initialized client', (done) => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.initialize().catch((err) => { + throw err; + }); + assert(client.crossNetworkAutomationServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has close method for the non-initialized client', done => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.crossNetworkAutomationServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the non-initialized client', (done) => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.crossNetworkAutomationServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getServiceConnectionMap', () => { + it('invokes getServiceConnectionMap without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetServiceConnectionMapRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetServiceConnectionMapRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap(), + ); + client.innerApiCalls.getServiceConnectionMap = + stubSimpleCall(expectedResponse); + const [response] = await client.getServiceConnectionMap(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getServiceConnectionMap as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getServiceConnectionMap as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getServiceConnectionMap', () => { - it('invokes getServiceConnectionMap without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetServiceConnectionMapRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetServiceConnectionMapRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap() - ); - client.innerApiCalls.getServiceConnectionMap = stubSimpleCall(expectedResponse); - const [response] = await client.getServiceConnectionMap(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getServiceConnectionMap as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServiceConnectionMap as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getServiceConnectionMap without error using callback', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetServiceConnectionMapRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetServiceConnectionMapRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap(), + ); + client.innerApiCalls.getServiceConnectionMap = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getServiceConnectionMap( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getServiceConnectionMap as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getServiceConnectionMap as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getServiceConnectionMap without error using callback', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetServiceConnectionMapRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetServiceConnectionMapRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap() - ); - client.innerApiCalls.getServiceConnectionMap = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getServiceConnectionMap( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getServiceConnectionMap as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServiceConnectionMap as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getServiceConnectionMap with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetServiceConnectionMapRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetServiceConnectionMapRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getServiceConnectionMap = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getServiceConnectionMap(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.getServiceConnectionMap as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getServiceConnectionMap as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getServiceConnectionMap with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetServiceConnectionMapRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetServiceConnectionMapRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getServiceConnectionMap = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getServiceConnectionMap(request), expectedError); - const actualRequest = (client.innerApiCalls.getServiceConnectionMap as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServiceConnectionMap as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getServiceConnectionMap with closed client', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetServiceConnectionMapRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetServiceConnectionMapRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.getServiceConnectionMap(request), + expectedError, + ); + }); + }); + + describe('getServiceConnectionPolicy', () => { + it('invokes getServiceConnectionPolicy without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetServiceConnectionPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetServiceConnectionPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy(), + ); + client.innerApiCalls.getServiceConnectionPolicy = + stubSimpleCall(expectedResponse); + const [response] = await client.getServiceConnectionPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getServiceConnectionPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getServiceConnectionPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getServiceConnectionMap with closed client', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetServiceConnectionMapRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetServiceConnectionMapRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getServiceConnectionMap(request), expectedError); - }); + it('invokes getServiceConnectionPolicy without error using callback', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetServiceConnectionPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetServiceConnectionPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy(), + ); + client.innerApiCalls.getServiceConnectionPolicy = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getServiceConnectionPolicy( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getServiceConnectionPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getServiceConnectionPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getServiceConnectionPolicy', () => { - it('invokes getServiceConnectionPolicy without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetServiceConnectionPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetServiceConnectionPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy() - ); - client.innerApiCalls.getServiceConnectionPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getServiceConnectionPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getServiceConnectionPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServiceConnectionPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getServiceConnectionPolicy with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetServiceConnectionPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetServiceConnectionPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getServiceConnectionPolicy = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getServiceConnectionPolicy(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.getServiceConnectionPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getServiceConnectionPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getServiceConnectionPolicy without error using callback', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetServiceConnectionPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetServiceConnectionPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy() - ); - client.innerApiCalls.getServiceConnectionPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getServiceConnectionPolicy( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getServiceConnectionPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServiceConnectionPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getServiceConnectionPolicy with closed client', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetServiceConnectionPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetServiceConnectionPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.getServiceConnectionPolicy(request), + expectedError, + ); + }); + }); + + describe('getServiceClass', () => { + it('invokes getServiceClass without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetServiceClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetServiceClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceClass(), + ); + client.innerApiCalls.getServiceClass = stubSimpleCall(expectedResponse); + const [response] = await client.getServiceClass(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getServiceClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getServiceClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getServiceConnectionPolicy with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetServiceConnectionPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetServiceConnectionPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getServiceConnectionPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getServiceConnectionPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.getServiceConnectionPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServiceConnectionPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getServiceClass without error using callback', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetServiceClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetServiceClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceClass(), + ); + client.innerApiCalls.getServiceClass = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getServiceClass( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1.IServiceClass | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getServiceClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getServiceClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getServiceConnectionPolicy with closed client', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetServiceConnectionPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetServiceConnectionPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getServiceConnectionPolicy(request), expectedError); - }); + it('invokes getServiceClass with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetServiceClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetServiceClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getServiceClass = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getServiceClass(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getServiceClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getServiceClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getServiceClass', () => { - it('invokes getServiceClass without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetServiceClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetServiceClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ServiceClass() - ); - client.innerApiCalls.getServiceClass = stubSimpleCall(expectedResponse); - const [response] = await client.getServiceClass(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getServiceClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServiceClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getServiceClass with closed client', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetServiceClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetServiceClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getServiceClass(request), expectedError); + }); + }); + + describe('getServiceConnectionToken', () => { + it('invokes getServiceConnectionToken without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetServiceConnectionTokenRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetServiceConnectionTokenRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken(), + ); + client.innerApiCalls.getServiceConnectionToken = + stubSimpleCall(expectedResponse); + const [response] = await client.getServiceConnectionToken(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getServiceConnectionToken as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getServiceConnectionToken as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getServiceClass without error using callback', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetServiceClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetServiceClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ServiceClass() - ); - client.innerApiCalls.getServiceClass = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getServiceClass( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1.IServiceClass|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getServiceClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServiceClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getServiceConnectionToken without error using callback', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetServiceConnectionTokenRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetServiceConnectionTokenRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken(), + ); + client.innerApiCalls.getServiceConnectionToken = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getServiceConnectionToken( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getServiceConnectionToken as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getServiceConnectionToken as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getServiceClass with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetServiceClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetServiceClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getServiceClass = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getServiceClass(request), expectedError); - const actualRequest = (client.innerApiCalls.getServiceClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServiceClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getServiceConnectionToken with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetServiceConnectionTokenRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetServiceConnectionTokenRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getServiceConnectionToken = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getServiceConnectionToken(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.getServiceConnectionToken as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getServiceConnectionToken as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getServiceClass with closed client', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetServiceClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetServiceClassRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getServiceClass(request), expectedError); - }); + it('invokes getServiceConnectionToken with closed client', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetServiceConnectionTokenRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetServiceConnectionTokenRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.getServiceConnectionToken(request), + expectedError, + ); + }); + }); + + describe('createServiceConnectionMap', () => { + it('invokes createServiceConnectionMap without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateServiceConnectionMapRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateServiceConnectionMapRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createServiceConnectionMap = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createServiceConnectionMap(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createServiceConnectionMap as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createServiceConnectionMap as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getServiceConnectionToken', () => { - it('invokes getServiceConnectionToken without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetServiceConnectionTokenRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetServiceConnectionTokenRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken() - ); - client.innerApiCalls.getServiceConnectionToken = stubSimpleCall(expectedResponse); - const [response] = await client.getServiceConnectionToken(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getServiceConnectionToken as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServiceConnectionToken as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createServiceConnectionMap without error using callback', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateServiceConnectionMapRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateServiceConnectionMapRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createServiceConnectionMap = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createServiceConnectionMap( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createServiceConnectionMap as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createServiceConnectionMap as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getServiceConnectionToken without error using callback', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetServiceConnectionTokenRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetServiceConnectionTokenRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken() - ); - client.innerApiCalls.getServiceConnectionToken = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getServiceConnectionToken( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getServiceConnectionToken as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServiceConnectionToken as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createServiceConnectionMap with call error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateServiceConnectionMapRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateServiceConnectionMapRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createServiceConnectionMap = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.createServiceConnectionMap(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createServiceConnectionMap as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createServiceConnectionMap as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getServiceConnectionToken with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetServiceConnectionTokenRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetServiceConnectionTokenRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getServiceConnectionToken = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getServiceConnectionToken(request), expectedError); - const actualRequest = (client.innerApiCalls.getServiceConnectionToken as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServiceConnectionToken as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createServiceConnectionMap with LRO error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateServiceConnectionMapRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateServiceConnectionMapRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createServiceConnectionMap = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createServiceConnectionMap(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createServiceConnectionMap as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createServiceConnectionMap as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getServiceConnectionToken with closed client', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetServiceConnectionTokenRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetServiceConnectionTokenRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getServiceConnectionToken(request), expectedError); - }); + it('invokes checkCreateServiceConnectionMapProgress without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkCreateServiceConnectionMapProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('createServiceConnectionMap', () => { - it('invokes createServiceConnectionMap without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateServiceConnectionMapRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateServiceConnectionMapRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createServiceConnectionMap = stubLongRunningCall(expectedResponse); - const [operation] = await client.createServiceConnectionMap(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createServiceConnectionMap as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServiceConnectionMap as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateServiceConnectionMapProgress with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateServiceConnectionMapProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateServiceConnectionMap', () => { + it('invokes updateServiceConnectionMap without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateServiceConnectionMapRequest(), + ); + request.serviceConnectionMap ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateServiceConnectionMapRequest', + ['serviceConnectionMap', 'name'], + ); + request.serviceConnectionMap.name = defaultValue1; + const expectedHeaderRequestParams = `service_connection_map.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateServiceConnectionMap = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateServiceConnectionMap(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateServiceConnectionMap as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateServiceConnectionMap as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createServiceConnectionMap without error using callback', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateServiceConnectionMapRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateServiceConnectionMapRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createServiceConnectionMap = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createServiceConnectionMap( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createServiceConnectionMap as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServiceConnectionMap as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateServiceConnectionMap without error using callback', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateServiceConnectionMapRequest(), + ); + request.serviceConnectionMap ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateServiceConnectionMapRequest', + ['serviceConnectionMap', 'name'], + ); + request.serviceConnectionMap.name = defaultValue1; + const expectedHeaderRequestParams = `service_connection_map.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateServiceConnectionMap = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateServiceConnectionMap( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateServiceConnectionMap as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateServiceConnectionMap as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createServiceConnectionMap with call error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateServiceConnectionMapRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateServiceConnectionMapRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createServiceConnectionMap = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createServiceConnectionMap(request), expectedError); - const actualRequest = (client.innerApiCalls.createServiceConnectionMap as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServiceConnectionMap as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateServiceConnectionMap with call error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateServiceConnectionMapRequest(), + ); + request.serviceConnectionMap ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateServiceConnectionMapRequest', + ['serviceConnectionMap', 'name'], + ); + request.serviceConnectionMap.name = defaultValue1; + const expectedHeaderRequestParams = `service_connection_map.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateServiceConnectionMap = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.updateServiceConnectionMap(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.updateServiceConnectionMap as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateServiceConnectionMap as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createServiceConnectionMap with LRO error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateServiceConnectionMapRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateServiceConnectionMapRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createServiceConnectionMap = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createServiceConnectionMap(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createServiceConnectionMap as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServiceConnectionMap as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateServiceConnectionMap with LRO error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateServiceConnectionMapRequest(), + ); + request.serviceConnectionMap ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateServiceConnectionMapRequest', + ['serviceConnectionMap', 'name'], + ); + request.serviceConnectionMap.name = defaultValue1; + const expectedHeaderRequestParams = `service_connection_map.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateServiceConnectionMap = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateServiceConnectionMap(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateServiceConnectionMap as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateServiceConnectionMap as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateServiceConnectionMapProgress without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateServiceConnectionMapProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateServiceConnectionMapProgress without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkUpdateServiceConnectionMapProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkCreateServiceConnectionMapProgress with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateServiceConnectionMapProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpdateServiceConnectionMapProgress with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateServiceConnectionMapProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteServiceConnectionMap', () => { + it('invokes deleteServiceConnectionMap without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteServiceConnectionMapRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteServiceConnectionMapRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteServiceConnectionMap = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteServiceConnectionMap(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteServiceConnectionMap as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServiceConnectionMap as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateServiceConnectionMap', () => { - it('invokes updateServiceConnectionMap without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateServiceConnectionMapRequest() - ); - request.serviceConnectionMap ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateServiceConnectionMapRequest', ['serviceConnectionMap', 'name']); - request.serviceConnectionMap.name = defaultValue1; - const expectedHeaderRequestParams = `service_connection_map.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateServiceConnectionMap = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateServiceConnectionMap(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateServiceConnectionMap as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServiceConnectionMap as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteServiceConnectionMap without error using callback', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteServiceConnectionMapRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteServiceConnectionMapRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteServiceConnectionMap = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteServiceConnectionMap( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteServiceConnectionMap as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServiceConnectionMap as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateServiceConnectionMap without error using callback', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateServiceConnectionMapRequest() - ); - request.serviceConnectionMap ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateServiceConnectionMapRequest', ['serviceConnectionMap', 'name']); - request.serviceConnectionMap.name = defaultValue1; - const expectedHeaderRequestParams = `service_connection_map.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateServiceConnectionMap = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateServiceConnectionMap( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateServiceConnectionMap as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServiceConnectionMap as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteServiceConnectionMap with call error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteServiceConnectionMapRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteServiceConnectionMapRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteServiceConnectionMap = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.deleteServiceConnectionMap(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteServiceConnectionMap as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServiceConnectionMap as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateServiceConnectionMap with call error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateServiceConnectionMapRequest() - ); - request.serviceConnectionMap ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateServiceConnectionMapRequest', ['serviceConnectionMap', 'name']); - request.serviceConnectionMap.name = defaultValue1; - const expectedHeaderRequestParams = `service_connection_map.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateServiceConnectionMap = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateServiceConnectionMap(request), expectedError); - const actualRequest = (client.innerApiCalls.updateServiceConnectionMap as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServiceConnectionMap as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteServiceConnectionMap with LRO error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteServiceConnectionMapRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteServiceConnectionMapRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteServiceConnectionMap = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteServiceConnectionMap(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteServiceConnectionMap as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServiceConnectionMap as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateServiceConnectionMap with LRO error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateServiceConnectionMapRequest() - ); - request.serviceConnectionMap ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateServiceConnectionMapRequest', ['serviceConnectionMap', 'name']); - request.serviceConnectionMap.name = defaultValue1; - const expectedHeaderRequestParams = `service_connection_map.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateServiceConnectionMap = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateServiceConnectionMap(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateServiceConnectionMap as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServiceConnectionMap as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteServiceConnectionMapProgress without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkDeleteServiceConnectionMapProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkUpdateServiceConnectionMapProgress without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateServiceConnectionMapProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkDeleteServiceConnectionMapProgress with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteServiceConnectionMapProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createServiceConnectionPolicy', () => { + it('invokes createServiceConnectionPolicy without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateServiceConnectionPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateServiceConnectionPolicyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createServiceConnectionPolicy = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createServiceConnectionPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createServiceConnectionPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createServiceConnectionPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateServiceConnectionMapProgress with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateServiceConnectionMapProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createServiceConnectionPolicy without error using callback', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateServiceConnectionPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateServiceConnectionPolicyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createServiceConnectionPolicy = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createServiceConnectionPolicy( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createServiceConnectionPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createServiceConnectionPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteServiceConnectionMap', () => { - it('invokes deleteServiceConnectionMap without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteServiceConnectionMapRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteServiceConnectionMapRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteServiceConnectionMap = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteServiceConnectionMap(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteServiceConnectionMap as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServiceConnectionMap as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createServiceConnectionPolicy with call error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateServiceConnectionPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateServiceConnectionPolicyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createServiceConnectionPolicy = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.createServiceConnectionPolicy(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createServiceConnectionPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createServiceConnectionPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteServiceConnectionMap without error using callback', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteServiceConnectionMapRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteServiceConnectionMapRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteServiceConnectionMap = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteServiceConnectionMap( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteServiceConnectionMap as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServiceConnectionMap as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createServiceConnectionPolicy with LRO error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateServiceConnectionPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateServiceConnectionPolicyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createServiceConnectionPolicy = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createServiceConnectionPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createServiceConnectionPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createServiceConnectionPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteServiceConnectionMap with call error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteServiceConnectionMapRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteServiceConnectionMapRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteServiceConnectionMap = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteServiceConnectionMap(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteServiceConnectionMap as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServiceConnectionMap as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateServiceConnectionPolicyProgress without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkCreateServiceConnectionPolicyProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteServiceConnectionMap with LRO error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteServiceConnectionMapRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteServiceConnectionMapRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteServiceConnectionMap = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteServiceConnectionMap(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteServiceConnectionMap as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServiceConnectionMap as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateServiceConnectionPolicyProgress with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateServiceConnectionPolicyProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateServiceConnectionPolicy', () => { + it('invokes updateServiceConnectionPolicy without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateServiceConnectionPolicyRequest(), + ); + request.serviceConnectionPolicy ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateServiceConnectionPolicyRequest', + ['serviceConnectionPolicy', 'name'], + ); + request.serviceConnectionPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `service_connection_policy.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateServiceConnectionPolicy = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateServiceConnectionPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateServiceConnectionPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateServiceConnectionPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteServiceConnectionMapProgress without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteServiceConnectionMapProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateServiceConnectionPolicy without error using callback', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateServiceConnectionPolicyRequest(), + ); + request.serviceConnectionPolicy ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateServiceConnectionPolicyRequest', + ['serviceConnectionPolicy', 'name'], + ); + request.serviceConnectionPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `service_connection_policy.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateServiceConnectionPolicy = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateServiceConnectionPolicy( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateServiceConnectionPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateServiceConnectionPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteServiceConnectionMapProgress with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteServiceConnectionMapProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateServiceConnectionPolicy with call error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateServiceConnectionPolicyRequest(), + ); + request.serviceConnectionPolicy ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateServiceConnectionPolicyRequest', + ['serviceConnectionPolicy', 'name'], + ); + request.serviceConnectionPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `service_connection_policy.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateServiceConnectionPolicy = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.updateServiceConnectionPolicy(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.updateServiceConnectionPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateServiceConnectionPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createServiceConnectionPolicy', () => { - it('invokes createServiceConnectionPolicy without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateServiceConnectionPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateServiceConnectionPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createServiceConnectionPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.createServiceConnectionPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createServiceConnectionPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServiceConnectionPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateServiceConnectionPolicy with LRO error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateServiceConnectionPolicyRequest(), + ); + request.serviceConnectionPolicy ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateServiceConnectionPolicyRequest', + ['serviceConnectionPolicy', 'name'], + ); + request.serviceConnectionPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `service_connection_policy.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateServiceConnectionPolicy = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateServiceConnectionPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateServiceConnectionPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateServiceConnectionPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createServiceConnectionPolicy without error using callback', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateServiceConnectionPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateServiceConnectionPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createServiceConnectionPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createServiceConnectionPolicy( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createServiceConnectionPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServiceConnectionPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateServiceConnectionPolicyProgress without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkUpdateServiceConnectionPolicyProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createServiceConnectionPolicy with call error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateServiceConnectionPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateServiceConnectionPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createServiceConnectionPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createServiceConnectionPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.createServiceConnectionPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServiceConnectionPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateServiceConnectionPolicyProgress with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateServiceConnectionPolicyProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteServiceConnectionPolicy', () => { + it('invokes deleteServiceConnectionPolicy without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteServiceConnectionPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteServiceConnectionPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteServiceConnectionPolicy = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteServiceConnectionPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteServiceConnectionPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServiceConnectionPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createServiceConnectionPolicy with LRO error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateServiceConnectionPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateServiceConnectionPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createServiceConnectionPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createServiceConnectionPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createServiceConnectionPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServiceConnectionPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteServiceConnectionPolicy without error using callback', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteServiceConnectionPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteServiceConnectionPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteServiceConnectionPolicy = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteServiceConnectionPolicy( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteServiceConnectionPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServiceConnectionPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateServiceConnectionPolicyProgress without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateServiceConnectionPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteServiceConnectionPolicy with call error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteServiceConnectionPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteServiceConnectionPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteServiceConnectionPolicy = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.deleteServiceConnectionPolicy(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteServiceConnectionPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServiceConnectionPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateServiceConnectionPolicyProgress with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateServiceConnectionPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteServiceConnectionPolicy with LRO error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteServiceConnectionPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteServiceConnectionPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteServiceConnectionPolicy = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteServiceConnectionPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteServiceConnectionPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServiceConnectionPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateServiceConnectionPolicy', () => { - it('invokes updateServiceConnectionPolicy without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateServiceConnectionPolicyRequest() - ); - request.serviceConnectionPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateServiceConnectionPolicyRequest', ['serviceConnectionPolicy', 'name']); - request.serviceConnectionPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `service_connection_policy.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateServiceConnectionPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateServiceConnectionPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateServiceConnectionPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServiceConnectionPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteServiceConnectionPolicyProgress without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkDeleteServiceConnectionPolicyProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateServiceConnectionPolicy without error using callback', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateServiceConnectionPolicyRequest() - ); - request.serviceConnectionPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateServiceConnectionPolicyRequest', ['serviceConnectionPolicy', 'name']); - request.serviceConnectionPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `service_connection_policy.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateServiceConnectionPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateServiceConnectionPolicy( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateServiceConnectionPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServiceConnectionPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteServiceConnectionPolicyProgress with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteServiceConnectionPolicyProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateServiceClass', () => { + it('invokes updateServiceClass without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateServiceClassRequest(), + ); + request.serviceClass ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateServiceClassRequest', + ['serviceClass', 'name'], + ); + request.serviceClass.name = defaultValue1; + const expectedHeaderRequestParams = `service_class.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateServiceClass = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateServiceClass(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateServiceClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateServiceClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateServiceConnectionPolicy with call error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateServiceConnectionPolicyRequest() - ); - request.serviceConnectionPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateServiceConnectionPolicyRequest', ['serviceConnectionPolicy', 'name']); - request.serviceConnectionPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `service_connection_policy.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateServiceConnectionPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateServiceConnectionPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.updateServiceConnectionPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServiceConnectionPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateServiceClass without error using callback', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateServiceClassRequest(), + ); + request.serviceClass ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateServiceClassRequest', + ['serviceClass', 'name'], + ); + request.serviceClass.name = defaultValue1; + const expectedHeaderRequestParams = `service_class.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateServiceClass = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateServiceClass( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceClass, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceClass, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateServiceClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateServiceClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateServiceConnectionPolicy with LRO error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateServiceConnectionPolicyRequest() - ); - request.serviceConnectionPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateServiceConnectionPolicyRequest', ['serviceConnectionPolicy', 'name']); - request.serviceConnectionPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `service_connection_policy.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateServiceConnectionPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateServiceConnectionPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateServiceConnectionPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServiceConnectionPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateServiceClass with call error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateServiceClassRequest(), + ); + request.serviceClass ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateServiceClassRequest', + ['serviceClass', 'name'], + ); + request.serviceClass.name = defaultValue1; + const expectedHeaderRequestParams = `service_class.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateServiceClass = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateServiceClass(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateServiceClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateServiceClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateServiceConnectionPolicyProgress without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateServiceConnectionPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateServiceClass with LRO error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateServiceClassRequest(), + ); + request.serviceClass ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateServiceClassRequest', + ['serviceClass', 'name'], + ); + request.serviceClass.name = defaultValue1; + const expectedHeaderRequestParams = `service_class.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateServiceClass = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateServiceClass(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateServiceClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateServiceClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateServiceConnectionPolicyProgress with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateServiceConnectionPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpdateServiceClassProgress without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkUpdateServiceClassProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('deleteServiceConnectionPolicy', () => { - it('invokes deleteServiceConnectionPolicy without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteServiceConnectionPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteServiceConnectionPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteServiceConnectionPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteServiceConnectionPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteServiceConnectionPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServiceConnectionPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateServiceClassProgress with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateServiceClassProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteServiceClass', () => { + it('invokes deleteServiceClass without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteServiceClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteServiceClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteServiceClass = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteServiceClass(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteServiceClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServiceClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteServiceConnectionPolicy without error using callback', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteServiceConnectionPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteServiceConnectionPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteServiceConnectionPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteServiceConnectionPolicy( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteServiceConnectionPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServiceConnectionPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteServiceClass without error using callback', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteServiceClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteServiceClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteServiceClass = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteServiceClass( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteServiceClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServiceClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteServiceConnectionPolicy with call error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteServiceConnectionPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteServiceConnectionPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteServiceConnectionPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteServiceConnectionPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteServiceConnectionPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServiceConnectionPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteServiceClass with call error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteServiceClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteServiceClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteServiceClass = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteServiceClass(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteServiceClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServiceClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteServiceConnectionPolicy with LRO error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteServiceConnectionPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteServiceConnectionPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteServiceConnectionPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteServiceConnectionPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteServiceConnectionPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServiceConnectionPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteServiceClass with LRO error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteServiceClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteServiceClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteServiceClass = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteServiceClass(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteServiceClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServiceClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteServiceConnectionPolicyProgress without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteServiceConnectionPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkDeleteServiceClassProgress without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkDeleteServiceClassProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteServiceConnectionPolicyProgress with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteServiceConnectionPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteServiceClassProgress with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteServiceClassProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createServiceConnectionToken', () => { + it('invokes createServiceConnectionToken without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateServiceConnectionTokenRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateServiceConnectionTokenRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createServiceConnectionToken = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createServiceConnectionToken(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createServiceConnectionToken as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createServiceConnectionToken as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateServiceClass', () => { - it('invokes updateServiceClass without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateServiceClassRequest() - ); - request.serviceClass ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateServiceClassRequest', ['serviceClass', 'name']); - request.serviceClass.name = defaultValue1; - const expectedHeaderRequestParams = `service_class.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateServiceClass = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateServiceClass(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateServiceClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServiceClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createServiceConnectionToken without error using callback', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateServiceConnectionTokenRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateServiceConnectionTokenRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createServiceConnectionToken = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createServiceConnectionToken( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createServiceConnectionToken as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createServiceConnectionToken as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateServiceClass without error using callback', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateServiceClassRequest() - ); - request.serviceClass ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateServiceClassRequest', ['serviceClass', 'name']); - request.serviceClass.name = defaultValue1; - const expectedHeaderRequestParams = `service_class.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateServiceClass = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateServiceClass( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateServiceClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServiceClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createServiceConnectionToken with call error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateServiceConnectionTokenRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateServiceConnectionTokenRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createServiceConnectionToken = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.createServiceConnectionToken(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createServiceConnectionToken as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createServiceConnectionToken as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateServiceClass with call error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateServiceClassRequest() - ); - request.serviceClass ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateServiceClassRequest', ['serviceClass', 'name']); - request.serviceClass.name = defaultValue1; - const expectedHeaderRequestParams = `service_class.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateServiceClass = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateServiceClass(request), expectedError); - const actualRequest = (client.innerApiCalls.updateServiceClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServiceClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createServiceConnectionToken with LRO error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateServiceConnectionTokenRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateServiceConnectionTokenRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createServiceConnectionToken = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createServiceConnectionToken(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createServiceConnectionToken as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createServiceConnectionToken as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateServiceClass with LRO error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateServiceClassRequest() - ); - request.serviceClass ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateServiceClassRequest', ['serviceClass', 'name']); - request.serviceClass.name = defaultValue1; - const expectedHeaderRequestParams = `service_class.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateServiceClass = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateServiceClass(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateServiceClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServiceClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateServiceConnectionTokenProgress without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkCreateServiceConnectionTokenProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkUpdateServiceClassProgress without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateServiceClassProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkCreateServiceConnectionTokenProgress with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateServiceConnectionTokenProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteServiceConnectionToken', () => { + it('invokes deleteServiceConnectionToken without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteServiceConnectionTokenRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteServiceConnectionTokenRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteServiceConnectionToken = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteServiceConnectionToken(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteServiceConnectionToken as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServiceConnectionToken as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateServiceClassProgress with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateServiceClassProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteServiceConnectionToken without error using callback', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteServiceConnectionTokenRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteServiceConnectionTokenRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteServiceConnectionToken = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteServiceConnectionToken( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteServiceConnectionToken as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServiceConnectionToken as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteServiceClass', () => { - it('invokes deleteServiceClass without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteServiceClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteServiceClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteServiceClass = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteServiceClass(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteServiceClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServiceClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteServiceConnectionToken with call error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteServiceConnectionTokenRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteServiceConnectionTokenRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteServiceConnectionToken = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.deleteServiceConnectionToken(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteServiceConnectionToken as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServiceConnectionToken as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteServiceClass without error using callback', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteServiceClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteServiceClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteServiceClass = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteServiceClass( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteServiceClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServiceClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteServiceConnectionToken with LRO error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteServiceConnectionTokenRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteServiceConnectionTokenRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteServiceConnectionToken = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteServiceConnectionToken(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteServiceConnectionToken as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServiceConnectionToken as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteServiceClass with call error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteServiceClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteServiceClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteServiceClass = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteServiceClass(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteServiceClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServiceClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteServiceConnectionTokenProgress without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkDeleteServiceConnectionTokenProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteServiceClass with LRO error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteServiceClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteServiceClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteServiceClass = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteServiceClass(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteServiceClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServiceClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteServiceConnectionTokenProgress with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteServiceConnectionTokenProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listServiceConnectionMaps', () => { + it('invokes listServiceConnectionMaps without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionMapsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListServiceConnectionMapsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap(), + ), + ]; + client.innerApiCalls.listServiceConnectionMaps = + stubSimpleCall(expectedResponse); + const [response] = await client.listServiceConnectionMaps(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServiceConnectionMaps as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServiceConnectionMaps as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteServiceClassProgress without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteServiceClassProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteServiceClassProgress with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteServiceClassProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes listServiceConnectionMaps without error using callback', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionMapsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListServiceConnectionMapsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap(), + ), + ]; + client.innerApiCalls.listServiceConnectionMaps = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listServiceConnectionMaps( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServiceConnectionMaps as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServiceConnectionMaps as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createServiceConnectionToken', () => { - it('invokes createServiceConnectionToken without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateServiceConnectionTokenRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateServiceConnectionTokenRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createServiceConnectionToken = stubLongRunningCall(expectedResponse); - const [operation] = await client.createServiceConnectionToken(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createServiceConnectionToken as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServiceConnectionToken as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createServiceConnectionToken without error using callback', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateServiceConnectionTokenRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateServiceConnectionTokenRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createServiceConnectionToken = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createServiceConnectionToken( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createServiceConnectionToken as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServiceConnectionToken as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createServiceConnectionToken with call error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateServiceConnectionTokenRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateServiceConnectionTokenRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createServiceConnectionToken = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createServiceConnectionToken(request), expectedError); - const actualRequest = (client.innerApiCalls.createServiceConnectionToken as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServiceConnectionToken as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createServiceConnectionToken with LRO error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateServiceConnectionTokenRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateServiceConnectionTokenRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createServiceConnectionToken = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createServiceConnectionToken(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createServiceConnectionToken as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServiceConnectionToken as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateServiceConnectionTokenProgress without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateServiceConnectionTokenProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateServiceConnectionTokenProgress with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateServiceConnectionTokenProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes listServiceConnectionMaps with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionMapsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListServiceConnectionMapsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listServiceConnectionMaps = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listServiceConnectionMaps(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listServiceConnectionMaps as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServiceConnectionMaps as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteServiceConnectionToken', () => { - it('invokes deleteServiceConnectionToken without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteServiceConnectionTokenRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteServiceConnectionTokenRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteServiceConnectionToken = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteServiceConnectionToken(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteServiceConnectionToken as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServiceConnectionToken as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteServiceConnectionToken without error using callback', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteServiceConnectionTokenRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteServiceConnectionTokenRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteServiceConnectionToken = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteServiceConnectionToken( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteServiceConnectionToken as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServiceConnectionToken as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteServiceConnectionToken with call error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteServiceConnectionTokenRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteServiceConnectionTokenRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteServiceConnectionToken = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteServiceConnectionToken(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteServiceConnectionToken as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServiceConnectionToken as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteServiceConnectionToken with LRO error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteServiceConnectionTokenRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteServiceConnectionTokenRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteServiceConnectionToken = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteServiceConnectionToken(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteServiceConnectionToken as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServiceConnectionToken as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteServiceConnectionTokenProgress without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteServiceConnectionTokenProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteServiceConnectionTokenProgress with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteServiceConnectionTokenProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes listServiceConnectionMapsStream without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionMapsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListServiceConnectionMapsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap(), + ), + ]; + client.descriptors.page.listServiceConnectionMaps.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listServiceConnectionMapsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listServiceConnectionMaps + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listServiceConnectionMaps, request), + ); + assert( + ( + client.descriptors.page.listServiceConnectionMaps + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - describe('listServiceConnectionMaps', () => { - it('invokes listServiceConnectionMaps without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionMapsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListServiceConnectionMapsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap()), - ]; - client.innerApiCalls.listServiceConnectionMaps = stubSimpleCall(expectedResponse); - const [response] = await client.listServiceConnectionMaps(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServiceConnectionMaps as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServiceConnectionMaps as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listServiceConnectionMaps without error using callback', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionMapsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListServiceConnectionMapsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap()), - ]; - client.innerApiCalls.listServiceConnectionMaps = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listServiceConnectionMaps( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServiceConnectionMaps as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServiceConnectionMaps as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listServiceConnectionMaps with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionMapsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListServiceConnectionMapsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listServiceConnectionMaps = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listServiceConnectionMaps(request), expectedError); - const actualRequest = (client.innerApiCalls.listServiceConnectionMaps as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServiceConnectionMaps as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listServiceConnectionMapsStream with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionMapsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListServiceConnectionMapsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listServiceConnectionMaps.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listServiceConnectionMapsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listServiceConnectionMaps + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listServiceConnectionMaps, request), + ); + assert( + ( + client.descriptors.page.listServiceConnectionMaps + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listServiceConnectionMapsStream without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionMapsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListServiceConnectionMapsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap()), - ]; - client.descriptors.page.listServiceConnectionMaps.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listServiceConnectionMapsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listServiceConnectionMaps.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServiceConnectionMaps, request)); - assert( - (client.descriptors.page.listServiceConnectionMaps.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listServiceConnectionMaps without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionMapsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListServiceConnectionMapsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap(), + ), + ]; + client.descriptors.page.listServiceConnectionMaps.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap[] = + []; + const iterable = client.listServiceConnectionMapsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listServiceConnectionMaps + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listServiceConnectionMaps + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listServiceConnectionMapsStream with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionMapsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListServiceConnectionMapsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listServiceConnectionMaps.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listServiceConnectionMapsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listServiceConnectionMaps.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServiceConnectionMaps, request)); - assert( - (client.descriptors.page.listServiceConnectionMaps.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listServiceConnectionMaps with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionMapsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListServiceConnectionMapsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listServiceConnectionMaps.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listServiceConnectionMapsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listServiceConnectionMaps + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listServiceConnectionMaps + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('listServiceConnectionPolicies', () => { + it('invokes listServiceConnectionPolicies without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListServiceConnectionPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy(), + ), + ]; + client.innerApiCalls.listServiceConnectionPolicies = + stubSimpleCall(expectedResponse); + const [response] = await client.listServiceConnectionPolicies(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServiceConnectionPolicies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServiceConnectionPolicies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listServiceConnectionMaps without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionMapsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListServiceConnectionMapsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionMap()), - ]; - client.descriptors.page.listServiceConnectionMaps.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap[] = []; - const iterable = client.listServiceConnectionMapsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listServiceConnectionPolicies without error using callback', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListServiceConnectionPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy(), + ), + ]; + client.innerApiCalls.listServiceConnectionPolicies = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listServiceConnectionPolicies( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listServiceConnectionMaps.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listServiceConnectionMaps.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listServiceConnectionMaps with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionMapsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListServiceConnectionMapsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listServiceConnectionMaps.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listServiceConnectionMapsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1.IServiceConnectionMap[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listServiceConnectionMaps.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listServiceConnectionMaps.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServiceConnectionPolicies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServiceConnectionPolicies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listServiceConnectionPolicies', () => { - it('invokes listServiceConnectionPolicies without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListServiceConnectionPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy()), - ]; - client.innerApiCalls.listServiceConnectionPolicies = stubSimpleCall(expectedResponse); - const [response] = await client.listServiceConnectionPolicies(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServiceConnectionPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServiceConnectionPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listServiceConnectionPolicies with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListServiceConnectionPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listServiceConnectionPolicies = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listServiceConnectionPolicies(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listServiceConnectionPolicies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServiceConnectionPolicies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listServiceConnectionPolicies without error using callback', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListServiceConnectionPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy()), - ]; - client.innerApiCalls.listServiceConnectionPolicies = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listServiceConnectionPolicies( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServiceConnectionPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServiceConnectionPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listServiceConnectionPoliciesStream without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListServiceConnectionPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy(), + ), + ]; + client.descriptors.page.listServiceConnectionPolicies.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listServiceConnectionPoliciesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listServiceConnectionPolicies + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listServiceConnectionPolicies, + request, + ), + ); + assert( + ( + client.descriptors.page.listServiceConnectionPolicies + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listServiceConnectionPolicies with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListServiceConnectionPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listServiceConnectionPolicies = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listServiceConnectionPolicies(request), expectedError); - const actualRequest = (client.innerApiCalls.listServiceConnectionPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServiceConnectionPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listServiceConnectionPoliciesStream with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListServiceConnectionPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listServiceConnectionPolicies.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listServiceConnectionPoliciesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listServiceConnectionPolicies + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listServiceConnectionPolicies, + request, + ), + ); + assert( + ( + client.descriptors.page.listServiceConnectionPolicies + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listServiceConnectionPoliciesStream without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListServiceConnectionPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy()), - ]; - client.descriptors.page.listServiceConnectionPolicies.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listServiceConnectionPoliciesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listServiceConnectionPolicies.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServiceConnectionPolicies, request)); - assert( - (client.descriptors.page.listServiceConnectionPolicies.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listServiceConnectionPolicies without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListServiceConnectionPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy(), + ), + ]; + client.descriptors.page.listServiceConnectionPolicies.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy[] = + []; + const iterable = client.listServiceConnectionPoliciesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listServiceConnectionPolicies + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listServiceConnectionPolicies + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listServiceConnectionPoliciesStream with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListServiceConnectionPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listServiceConnectionPolicies.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listServiceConnectionPoliciesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listServiceConnectionPolicies.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServiceConnectionPolicies, request)); - assert( - (client.descriptors.page.listServiceConnectionPolicies.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listServiceConnectionPolicies with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListServiceConnectionPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listServiceConnectionPolicies.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listServiceConnectionPoliciesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listServiceConnectionPolicies + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listServiceConnectionPolicies + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('listServiceClasses', () => { + it('invokes listServiceClasses without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListServiceClassesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListServiceClassesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceClass(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceClass(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceClass(), + ), + ]; + client.innerApiCalls.listServiceClasses = + stubSimpleCall(expectedResponse); + const [response] = await client.listServiceClasses(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServiceClasses as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServiceClasses as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listServiceConnectionPolicies without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListServiceConnectionPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionPolicy()), - ]; - client.descriptors.page.listServiceConnectionPolicies.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy[] = []; - const iterable = client.listServiceConnectionPoliciesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listServiceClasses without error using callback', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListServiceClassesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListServiceClassesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceClass(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceClass(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceClass(), + ), + ]; + client.innerApiCalls.listServiceClasses = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listServiceClasses( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkconnectivity.v1.IServiceClass[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listServiceConnectionPolicies.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listServiceConnectionPolicies.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listServiceConnectionPolicies with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListServiceConnectionPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listServiceConnectionPolicies.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listServiceConnectionPoliciesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1.IServiceConnectionPolicy[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listServiceConnectionPolicies.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listServiceConnectionPolicies.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServiceClasses as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServiceClasses as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listServiceClasses', () => { - it('invokes listServiceClasses without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListServiceClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListServiceClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceClass()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceClass()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceClass()), - ]; - client.innerApiCalls.listServiceClasses = stubSimpleCall(expectedResponse); - const [response] = await client.listServiceClasses(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServiceClasses as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServiceClasses as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listServiceClasses with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListServiceClassesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListServiceClassesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listServiceClasses = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listServiceClasses(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listServiceClasses as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServiceClasses as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listServiceClasses without error using callback', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListServiceClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListServiceClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceClass()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceClass()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceClass()), - ]; - client.innerApiCalls.listServiceClasses = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listServiceClasses( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1.IServiceClass[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServiceClasses as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServiceClasses as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listServiceClassesStream without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListServiceClassesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListServiceClassesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceClass(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceClass(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceClass(), + ), + ]; + client.descriptors.page.listServiceClasses.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listServiceClassesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.ServiceClass[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1.ServiceClass, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listServiceClasses.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listServiceClasses, request), + ); + assert( + (client.descriptors.page.listServiceClasses.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listServiceClasses with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListServiceClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListServiceClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listServiceClasses = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listServiceClasses(request), expectedError); - const actualRequest = (client.innerApiCalls.listServiceClasses as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServiceClasses as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listServiceClassesStream with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListServiceClassesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListServiceClassesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listServiceClasses.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listServiceClassesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.ServiceClass[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1.ServiceClass, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listServiceClasses.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listServiceClasses, request), + ); + assert( + (client.descriptors.page.listServiceClasses.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listServiceClassesStream without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListServiceClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListServiceClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceClass()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceClass()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceClass()), - ]; - client.descriptors.page.listServiceClasses.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listServiceClassesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.ServiceClass[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.ServiceClass) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listServiceClasses.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServiceClasses, request)); - assert( - (client.descriptors.page.listServiceClasses.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listServiceClasses without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListServiceClassesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListServiceClassesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceClass(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceClass(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceClass(), + ), + ]; + client.descriptors.page.listServiceClasses.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1.IServiceClass[] = + []; + const iterable = client.listServiceClassesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listServiceClasses.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listServiceClasses.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listServiceClassesStream with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListServiceClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListServiceClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listServiceClasses.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listServiceClassesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.ServiceClass[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.ServiceClass) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listServiceClasses.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServiceClasses, request)); - assert( - (client.descriptors.page.listServiceClasses.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listServiceClasses with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListServiceClassesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListServiceClassesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listServiceClasses.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listServiceClassesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1.IServiceClass[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listServiceClasses.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listServiceClasses.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listServiceConnectionTokens', () => { + it('invokes listServiceConnectionTokens without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionTokensRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListServiceConnectionTokensRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken(), + ), + ]; + client.innerApiCalls.listServiceConnectionTokens = + stubSimpleCall(expectedResponse); + const [response] = await client.listServiceConnectionTokens(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServiceConnectionTokens as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServiceConnectionTokens as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listServiceClasses without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListServiceClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListServiceClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceClass()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceClass()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceClass()), - ]; - client.descriptors.page.listServiceClasses.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1.IServiceClass[] = []; - const iterable = client.listServiceClassesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listServiceConnectionTokens without error using callback', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionTokensRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListServiceConnectionTokensRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken(), + ), + ]; + client.innerApiCalls.listServiceConnectionTokens = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listServiceConnectionTokens( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listServiceClasses.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listServiceClasses.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listServiceClasses with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListServiceClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListServiceClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listServiceClasses.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listServiceClassesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1.IServiceClass[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listServiceClasses.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listServiceClasses.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServiceConnectionTokens as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServiceConnectionTokens as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listServiceConnectionTokens', () => { - it('invokes listServiceConnectionTokens without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionTokensRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListServiceConnectionTokensRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken()), - ]; - client.innerApiCalls.listServiceConnectionTokens = stubSimpleCall(expectedResponse); - const [response] = await client.listServiceConnectionTokens(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServiceConnectionTokens as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServiceConnectionTokens as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listServiceConnectionTokens without error using callback', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionTokensRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListServiceConnectionTokensRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken()), - ]; - client.innerApiCalls.listServiceConnectionTokens = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listServiceConnectionTokens( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServiceConnectionTokens as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServiceConnectionTokens as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listServiceConnectionTokens with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionTokensRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListServiceConnectionTokensRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listServiceConnectionTokens = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listServiceConnectionTokens(request), expectedError); - const actualRequest = (client.innerApiCalls.listServiceConnectionTokens as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServiceConnectionTokens as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listServiceConnectionTokens with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionTokensRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListServiceConnectionTokensRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listServiceConnectionTokens = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listServiceConnectionTokens(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listServiceConnectionTokens as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServiceConnectionTokens as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listServiceConnectionTokensStream without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionTokensRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListServiceConnectionTokensRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken()), - ]; - client.descriptors.page.listServiceConnectionTokens.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listServiceConnectionTokensStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listServiceConnectionTokens.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServiceConnectionTokens, request)); - assert( - (client.descriptors.page.listServiceConnectionTokens.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listServiceConnectionTokensStream without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionTokensRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListServiceConnectionTokensRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken(), + ), + ]; + client.descriptors.page.listServiceConnectionTokens.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listServiceConnectionTokensStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listServiceConnectionTokens + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listServiceConnectionTokens, + request, + ), + ); + assert( + ( + client.descriptors.page.listServiceConnectionTokens + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listServiceConnectionTokensStream with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionTokensRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListServiceConnectionTokensRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listServiceConnectionTokens.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listServiceConnectionTokensStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listServiceConnectionTokens.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServiceConnectionTokens, request)); - assert( - (client.descriptors.page.listServiceConnectionTokens.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listServiceConnectionTokensStream with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionTokensRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListServiceConnectionTokensRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listServiceConnectionTokens.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listServiceConnectionTokensStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listServiceConnectionTokens + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listServiceConnectionTokens, + request, + ), + ); + assert( + ( + client.descriptors.page.listServiceConnectionTokens + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('uses async iteration with listServiceConnectionTokens without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionTokensRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListServiceConnectionTokensRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken()), - ]; - client.descriptors.page.listServiceConnectionTokens.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken[] = []; - const iterable = client.listServiceConnectionTokensAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listServiceConnectionTokens.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listServiceConnectionTokens.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listServiceConnectionTokens without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionTokensRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListServiceConnectionTokensRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ServiceConnectionToken(), + ), + ]; + client.descriptors.page.listServiceConnectionTokens.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken[] = + []; + const iterable = client.listServiceConnectionTokensAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listServiceConnectionTokens + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listServiceConnectionTokens + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('uses async iteration with listServiceConnectionTokens with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionTokensRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListServiceConnectionTokensRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listServiceConnectionTokens.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listServiceConnectionTokensAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listServiceConnectionTokens.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listServiceConnectionTokens.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listServiceConnectionTokens with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListServiceConnectionTokensRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListServiceConnectionTokensRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listServiceConnectionTokens.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listServiceConnectionTokensAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1.IServiceConnectionToken[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listServiceConnectionTokens + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listServiceConnectionTokens + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy without error using callback', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes setIamPolicy without error using callback', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes setIamPolicy with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes testIamPermissions without error using callback', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes testIamPermissions with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('destination', async () => { + const fakePath = '/rendered/path/destination'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + multicloud_data_transfer_config: 'multicloudDataTransferConfigValue', + destination: 'destinationValue', + }; + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.destinationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.destinationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('destinationPath', () => { + const result = client.destinationPath( + 'projectValue', + 'locationValue', + 'multicloudDataTransferConfigValue', + 'destinationValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.destinationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromDestinationName', () => { + const result = client.matchProjectFromDestinationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromDestinationName', () => { + const result = client.matchLocationFromDestinationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMulticloudDataTransferConfigFromDestinationName', () => { + const result = + client.matchMulticloudDataTransferConfigFromDestinationName(fakePath); + assert.strictEqual(result, 'multicloudDataTransferConfigValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchDestinationFromDestinationName', () => { + const result = client.matchDestinationFromDestinationName(fakePath); + assert.strictEqual(result, 'destinationValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('destination', async () => { - const fakePath = "/rendered/path/destination"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - multicloud_data_transfer_config: "multicloudDataTransferConfigValue", - destination: "destinationValue", - }; - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.destinationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.destinationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('destinationPath', () => { - const result = client.destinationPath("projectValue", "locationValue", "multicloudDataTransferConfigValue", "destinationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.destinationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDestinationName', () => { - const result = client.matchProjectFromDestinationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromDestinationName', () => { - const result = client.matchLocationFromDestinationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMulticloudDataTransferConfigFromDestinationName', () => { - const result = client.matchMulticloudDataTransferConfigFromDestinationName(fakePath); - assert.strictEqual(result, "multicloudDataTransferConfigValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDestinationFromDestinationName', () => { - const result = client.matchDestinationFromDestinationName(fakePath); - assert.strictEqual(result, "destinationValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('group', async () => { - const fakePath = "/rendered/path/group"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - group: "groupValue", - }; - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.groupPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.groupPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('groupPath', () => { - const result = client.groupPath("projectValue", "hubValue", "groupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.groupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromGroupName', () => { - const result = client.matchProjectFromGroupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.groupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHubFromGroupName', () => { - const result = client.matchHubFromGroupName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.groupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchGroupFromGroupName', () => { - const result = client.matchGroupFromGroupName(fakePath); - assert.strictEqual(result, "groupValue"); - assert((client.pathTemplates.groupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('group', async () => { + const fakePath = '/rendered/path/group'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + group: 'groupValue', + }; + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.groupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.groupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('groupPath', () => { + const result = client.groupPath( + 'projectValue', + 'hubValue', + 'groupValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.groupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromGroupName', () => { + const result = client.matchProjectFromGroupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.groupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromGroupName', () => { + const result = client.matchHubFromGroupName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.groupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchGroupFromGroupName', () => { + const result = client.matchGroupFromGroupName(fakePath); + assert.strictEqual(result, 'groupValue'); + assert( + (client.pathTemplates.groupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('hub', async () => { - const fakePath = "/rendered/path/hub"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - }; - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.hubPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.hubPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('hubPath', () => { - const result = client.hubPath("projectValue", "hubValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.hubPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromHubName', () => { - const result = client.matchProjectFromHubName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.hubPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHubFromHubName', () => { - const result = client.matchHubFromHubName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.hubPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('hub', async () => { + const fakePath = '/rendered/path/hub'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + }; + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.hubPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.hubPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('hubPath', () => { + const result = client.hubPath('projectValue', 'hubValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.hubPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromHubName', () => { + const result = client.matchProjectFromHubName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.hubPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromHubName', () => { + const result = client.matchHubFromHubName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.hubPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('hubRoute', async () => { - const fakePath = "/rendered/path/hubRoute"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - route_table: "routeTableValue", - route: "routeValue", - }; - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.hubRoutePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.hubRoutePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('hubRoutePath', () => { - const result = client.hubRoutePath("projectValue", "hubValue", "routeTableValue", "routeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.hubRoutePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromHubRouteName', () => { - const result = client.matchProjectFromHubRouteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHubFromHubRouteName', () => { - const result = client.matchHubFromHubRouteName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRouteTableFromHubRouteName', () => { - const result = client.matchRouteTableFromHubRouteName(fakePath); - assert.strictEqual(result, "routeTableValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRouteFromHubRouteName', () => { - const result = client.matchRouteFromHubRouteName(fakePath); - assert.strictEqual(result, "routeValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('hubRoute', async () => { + const fakePath = '/rendered/path/hubRoute'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + route_table: 'routeTableValue', + route: 'routeValue', + }; + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.hubRoutePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.hubRoutePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('hubRoutePath', () => { + const result = client.hubRoutePath( + 'projectValue', + 'hubValue', + 'routeTableValue', + 'routeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.hubRoutePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromHubRouteName', () => { + const result = client.matchProjectFromHubRouteName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromHubRouteName', () => { + const result = client.matchHubFromHubRouteName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRouteTableFromHubRouteName', () => { + const result = client.matchRouteTableFromHubRouteName(fakePath); + assert.strictEqual(result, 'routeTableValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRouteFromHubRouteName', () => { + const result = client.matchRouteFromHubRouteName(fakePath); + assert.strictEqual(result, 'routeValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('internalRange', async () => { - const fakePath = "/rendered/path/internalRange"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - internal_range: "internalRangeValue", - }; - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.internalRangePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.internalRangePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('internalRangePath', () => { - const result = client.internalRangePath("projectValue", "locationValue", "internalRangeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.internalRangePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInternalRangeName', () => { - const result = client.matchProjectFromInternalRangeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.internalRangePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromInternalRangeName', () => { - const result = client.matchLocationFromInternalRangeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.internalRangePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInternalRangeFromInternalRangeName', () => { - const result = client.matchInternalRangeFromInternalRangeName(fakePath); - assert.strictEqual(result, "internalRangeValue"); - assert((client.pathTemplates.internalRangePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('internalRange', async () => { + const fakePath = '/rendered/path/internalRange'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + internal_range: 'internalRangeValue', + }; + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.internalRangePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.internalRangePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('internalRangePath', () => { + const result = client.internalRangePath( + 'projectValue', + 'locationValue', + 'internalRangeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.internalRangePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromInternalRangeName', () => { + const result = client.matchProjectFromInternalRangeName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.internalRangePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromInternalRangeName', () => { + const result = client.matchLocationFromInternalRangeName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.internalRangePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchInternalRangeFromInternalRangeName', () => { + const result = client.matchInternalRangeFromInternalRangeName(fakePath); + assert.strictEqual(result, 'internalRangeValue'); + assert( + (client.pathTemplates.internalRangePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('multicloudDataTransferConfig', async () => { - const fakePath = "/rendered/path/multicloudDataTransferConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - multicloud_data_transfer_config: "multicloudDataTransferConfigValue", - }; - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.multicloudDataTransferConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.multicloudDataTransferConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('multicloudDataTransferConfigPath', () => { - const result = client.multicloudDataTransferConfigPath("projectValue", "locationValue", "multicloudDataTransferConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMulticloudDataTransferConfigName', () => { - const result = client.matchProjectFromMulticloudDataTransferConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMulticloudDataTransferConfigName', () => { - const result = client.matchLocationFromMulticloudDataTransferConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName', () => { - const result = client.matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName(fakePath); - assert.strictEqual(result, "multicloudDataTransferConfigValue"); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('multicloudDataTransferConfig', async () => { + const fakePath = '/rendered/path/multicloudDataTransferConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + multicloud_data_transfer_config: 'multicloudDataTransferConfigValue', + }; + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.multicloudDataTransferConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.multicloudDataTransferConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('multicloudDataTransferConfigPath', () => { + const result = client.multicloudDataTransferConfigPath( + 'projectValue', + 'locationValue', + 'multicloudDataTransferConfigValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMulticloudDataTransferConfigName', () => { + const result = + client.matchProjectFromMulticloudDataTransferConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMulticloudDataTransferConfigName', () => { + const result = + client.matchLocationFromMulticloudDataTransferConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName', () => { + const result = + client.matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName( + fakePath, + ); + assert.strictEqual(result, 'multicloudDataTransferConfigValue'); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('multicloudDataTransferSupportedService', async () => { - const fakePath = "/rendered/path/multicloudDataTransferSupportedService"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - multicloud_data_transfer_supported_service: "multicloudDataTransferSupportedServiceValue", - }; - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('multicloudDataTransferSupportedServicePath', () => { - const result = client.multicloudDataTransferSupportedServicePath("projectValue", "locationValue", "multicloudDataTransferSupportedServiceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMulticloudDataTransferSupportedServiceName', () => { - const result = client.matchProjectFromMulticloudDataTransferSupportedServiceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMulticloudDataTransferSupportedServiceName', () => { - const result = client.matchLocationFromMulticloudDataTransferSupportedServiceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName', () => { - const result = client.matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName(fakePath); - assert.strictEqual(result, "multicloudDataTransferSupportedServiceValue"); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('multicloudDataTransferSupportedService', async () => { + const fakePath = '/rendered/path/multicloudDataTransferSupportedService'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + multicloud_data_transfer_supported_service: + 'multicloudDataTransferSupportedServiceValue', + }; + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('multicloudDataTransferSupportedServicePath', () => { + const result = client.multicloudDataTransferSupportedServicePath( + 'projectValue', + 'locationValue', + 'multicloudDataTransferSupportedServiceValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMulticloudDataTransferSupportedServiceName', () => { + const result = + client.matchProjectFromMulticloudDataTransferSupportedServiceName( + fakePath, + ); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMulticloudDataTransferSupportedServiceName', () => { + const result = + client.matchLocationFromMulticloudDataTransferSupportedServiceName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName', () => { + const result = + client.matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName( + fakePath, + ); + assert.strictEqual( + result, + 'multicloudDataTransferSupportedServiceValue', + ); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('network', async () => { - const fakePath = "/rendered/path/network"; - const expectedParameters = { - project: "projectValue", - resource_id: "resourceIdValue", - }; - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.networkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.networkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('networkPath', () => { - const result = client.networkPath("projectValue", "resourceIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.networkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromNetworkName', () => { - const result = client.matchProjectFromNetworkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.networkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchResourceIdFromNetworkName', () => { - const result = client.matchResourceIdFromNetworkName(fakePath); - assert.strictEqual(result, "resourceIdValue"); - assert((client.pathTemplates.networkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('network', async () => { + const fakePath = '/rendered/path/network'; + const expectedParameters = { + project: 'projectValue', + resource_id: 'resourceIdValue', + }; + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.networkPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.networkPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('networkPath', () => { + const result = client.networkPath('projectValue', 'resourceIdValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.networkPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromNetworkName', () => { + const result = client.matchProjectFromNetworkName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.networkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchResourceIdFromNetworkName', () => { + const result = client.matchResourceIdFromNetworkName(fakePath); + assert.strictEqual(result, 'resourceIdValue'); + assert( + (client.pathTemplates.networkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('policyBasedRoute', async () => { - const fakePath = "/rendered/path/policyBasedRoute"; - const expectedParameters = { - project: "projectValue", - policy_based_route: "policyBasedRouteValue", - }; - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.policyBasedRoutePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.policyBasedRoutePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('policyBasedRoutePath', () => { - const result = client.policyBasedRoutePath("projectValue", "policyBasedRouteValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.policyBasedRoutePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromPolicyBasedRouteName', () => { - const result = client.matchProjectFromPolicyBasedRouteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchPolicyBasedRouteFromPolicyBasedRouteName', () => { - const result = client.matchPolicyBasedRouteFromPolicyBasedRouteName(fakePath); - assert.strictEqual(result, "policyBasedRouteValue"); - assert((client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('policyBasedRoute', async () => { + const fakePath = '/rendered/path/policyBasedRoute'; + const expectedParameters = { + project: 'projectValue', + policy_based_route: 'policyBasedRouteValue', + }; + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.policyBasedRoutePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.policyBasedRoutePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('policyBasedRoutePath', () => { + const result = client.policyBasedRoutePath( + 'projectValue', + 'policyBasedRouteValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.policyBasedRoutePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromPolicyBasedRouteName', () => { + const result = client.matchProjectFromPolicyBasedRouteName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchPolicyBasedRouteFromPolicyBasedRouteName', () => { + const result = + client.matchPolicyBasedRouteFromPolicyBasedRouteName(fakePath); + assert.strictEqual(result, 'policyBasedRouteValue'); + assert( + (client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.projectPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('routeTable', async () => { - const fakePath = "/rendered/path/routeTable"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - route_table: "routeTableValue", - }; - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.routeTablePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.routeTablePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('routeTablePath', () => { - const result = client.routeTablePath("projectValue", "hubValue", "routeTableValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.routeTablePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRouteTableName', () => { - const result = client.matchProjectFromRouteTableName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.routeTablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHubFromRouteTableName', () => { - const result = client.matchHubFromRouteTableName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.routeTablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRouteTableFromRouteTableName', () => { - const result = client.matchRouteTableFromRouteTableName(fakePath); - assert.strictEqual(result, "routeTableValue"); - assert((client.pathTemplates.routeTablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('routeTable', async () => { + const fakePath = '/rendered/path/routeTable'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + route_table: 'routeTableValue', + }; + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.routeTablePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.routeTablePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('routeTablePath', () => { + const result = client.routeTablePath( + 'projectValue', + 'hubValue', + 'routeTableValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.routeTablePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromRouteTableName', () => { + const result = client.matchProjectFromRouteTableName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.routeTablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromRouteTableName', () => { + const result = client.matchHubFromRouteTableName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.routeTablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRouteTableFromRouteTableName', () => { + const result = client.matchRouteTableFromRouteTableName(fakePath); + assert.strictEqual(result, 'routeTableValue'); + assert( + (client.pathTemplates.routeTablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('serviceClass', async () => { - const fakePath = "/rendered/path/serviceClass"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service_class: "serviceClassValue", - }; - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.serviceClassPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.serviceClassPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('serviceClassPath', () => { - const result = client.serviceClassPath("projectValue", "locationValue", "serviceClassValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.serviceClassPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceClassName', () => { - const result = client.matchProjectFromServiceClassName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.serviceClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServiceClassName', () => { - const result = client.matchLocationFromServiceClassName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.serviceClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceClassFromServiceClassName', () => { - const result = client.matchServiceClassFromServiceClassName(fakePath); - assert.strictEqual(result, "serviceClassValue"); - assert((client.pathTemplates.serviceClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('serviceClass', async () => { + const fakePath = '/rendered/path/serviceClass'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service_class: 'serviceClassValue', + }; + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.serviceClassPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.serviceClassPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('serviceClassPath', () => { + const result = client.serviceClassPath( + 'projectValue', + 'locationValue', + 'serviceClassValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.serviceClassPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceClassName', () => { + const result = client.matchProjectFromServiceClassName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.serviceClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromServiceClassName', () => { + const result = client.matchLocationFromServiceClassName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.serviceClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceClassFromServiceClassName', () => { + const result = client.matchServiceClassFromServiceClassName(fakePath); + assert.strictEqual(result, 'serviceClassValue'); + assert( + (client.pathTemplates.serviceClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('serviceConnectionMap', async () => { - const fakePath = "/rendered/path/serviceConnectionMap"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service_connection_map: "serviceConnectionMapValue", - }; - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.serviceConnectionMapPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.serviceConnectionMapPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('serviceConnectionMapPath', () => { - const result = client.serviceConnectionMapPath("projectValue", "locationValue", "serviceConnectionMapValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.serviceConnectionMapPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceConnectionMapName', () => { - const result = client.matchProjectFromServiceConnectionMapName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.serviceConnectionMapPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServiceConnectionMapName', () => { - const result = client.matchLocationFromServiceConnectionMapName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.serviceConnectionMapPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceConnectionMapFromServiceConnectionMapName', () => { - const result = client.matchServiceConnectionMapFromServiceConnectionMapName(fakePath); - assert.strictEqual(result, "serviceConnectionMapValue"); - assert((client.pathTemplates.serviceConnectionMapPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('serviceConnectionMap', async () => { + const fakePath = '/rendered/path/serviceConnectionMap'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service_connection_map: 'serviceConnectionMapValue', + }; + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.serviceConnectionMapPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.serviceConnectionMapPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('serviceConnectionMapPath', () => { + const result = client.serviceConnectionMapPath( + 'projectValue', + 'locationValue', + 'serviceConnectionMapValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.serviceConnectionMapPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceConnectionMapName', () => { + const result = + client.matchProjectFromServiceConnectionMapName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.serviceConnectionMapPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromServiceConnectionMapName', () => { + const result = + client.matchLocationFromServiceConnectionMapName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.serviceConnectionMapPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceConnectionMapFromServiceConnectionMapName', () => { + const result = + client.matchServiceConnectionMapFromServiceConnectionMapName( + fakePath, + ); + assert.strictEqual(result, 'serviceConnectionMapValue'); + assert( + ( + client.pathTemplates.serviceConnectionMapPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('serviceConnectionPolicy', async () => { - const fakePath = "/rendered/path/serviceConnectionPolicy"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service_connection_policy: "serviceConnectionPolicyValue", - }; - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.serviceConnectionPolicyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.serviceConnectionPolicyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('serviceConnectionPolicyPath', () => { - const result = client.serviceConnectionPolicyPath("projectValue", "locationValue", "serviceConnectionPolicyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.serviceConnectionPolicyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceConnectionPolicyName', () => { - const result = client.matchProjectFromServiceConnectionPolicyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.serviceConnectionPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServiceConnectionPolicyName', () => { - const result = client.matchLocationFromServiceConnectionPolicyName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.serviceConnectionPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceConnectionPolicyFromServiceConnectionPolicyName', () => { - const result = client.matchServiceConnectionPolicyFromServiceConnectionPolicyName(fakePath); - assert.strictEqual(result, "serviceConnectionPolicyValue"); - assert((client.pathTemplates.serviceConnectionPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('serviceConnectionPolicy', async () => { + const fakePath = '/rendered/path/serviceConnectionPolicy'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service_connection_policy: 'serviceConnectionPolicyValue', + }; + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.serviceConnectionPolicyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.serviceConnectionPolicyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('serviceConnectionPolicyPath', () => { + const result = client.serviceConnectionPolicyPath( + 'projectValue', + 'locationValue', + 'serviceConnectionPolicyValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.serviceConnectionPolicyPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceConnectionPolicyName', () => { + const result = + client.matchProjectFromServiceConnectionPolicyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.serviceConnectionPolicyPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromServiceConnectionPolicyName', () => { + const result = + client.matchLocationFromServiceConnectionPolicyName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.serviceConnectionPolicyPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceConnectionPolicyFromServiceConnectionPolicyName', () => { + const result = + client.matchServiceConnectionPolicyFromServiceConnectionPolicyName( + fakePath, + ); + assert.strictEqual(result, 'serviceConnectionPolicyValue'); + assert( + ( + client.pathTemplates.serviceConnectionPolicyPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('serviceConnectionToken', async () => { - const fakePath = "/rendered/path/serviceConnectionToken"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service_connection_token: "serviceConnectionTokenValue", - }; - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.serviceConnectionTokenPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.serviceConnectionTokenPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('serviceConnectionTokenPath', () => { - const result = client.serviceConnectionTokenPath("projectValue", "locationValue", "serviceConnectionTokenValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.serviceConnectionTokenPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceConnectionTokenName', () => { - const result = client.matchProjectFromServiceConnectionTokenName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.serviceConnectionTokenPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServiceConnectionTokenName', () => { - const result = client.matchLocationFromServiceConnectionTokenName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.serviceConnectionTokenPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceConnectionTokenFromServiceConnectionTokenName', () => { - const result = client.matchServiceConnectionTokenFromServiceConnectionTokenName(fakePath); - assert.strictEqual(result, "serviceConnectionTokenValue"); - assert((client.pathTemplates.serviceConnectionTokenPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('serviceConnectionToken', async () => { + const fakePath = '/rendered/path/serviceConnectionToken'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service_connection_token: 'serviceConnectionTokenValue', + }; + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.serviceConnectionTokenPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.serviceConnectionTokenPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('serviceConnectionTokenPath', () => { + const result = client.serviceConnectionTokenPath( + 'projectValue', + 'locationValue', + 'serviceConnectionTokenValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.serviceConnectionTokenPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceConnectionTokenName', () => { + const result = + client.matchProjectFromServiceConnectionTokenName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.serviceConnectionTokenPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromServiceConnectionTokenName', () => { + const result = + client.matchLocationFromServiceConnectionTokenName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.serviceConnectionTokenPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceConnectionTokenFromServiceConnectionTokenName', () => { + const result = + client.matchServiceConnectionTokenFromServiceConnectionTokenName( + fakePath, + ); + assert.strictEqual(result, 'serviceConnectionTokenValue'); + assert( + ( + client.pathTemplates.serviceConnectionTokenPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('spoke', async () => { - const fakePath = "/rendered/path/spoke"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - spoke: "spokeValue", - }; - const client = new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.spokePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.spokePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('spokePath', () => { - const result = client.spokePath("projectValue", "locationValue", "spokeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.spokePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromSpokeName', () => { - const result = client.matchProjectFromSpokeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.spokePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromSpokeName', () => { - const result = client.matchLocationFromSpokeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.spokePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSpokeFromSpokeName', () => { - const result = client.matchSpokeFromSpokeName(fakePath); - assert.strictEqual(result, "spokeValue"); - assert((client.pathTemplates.spokePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('spoke', async () => { + const fakePath = '/rendered/path/spoke'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + spoke: 'spokeValue', + }; + const client = + new crossnetworkautomationserviceModule.v1.CrossNetworkAutomationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.spokePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.spokePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('spokePath', () => { + const result = client.spokePath( + 'projectValue', + 'locationValue', + 'spokeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.spokePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromSpokeName', () => { + const result = client.matchProjectFromSpokeName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.spokePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromSpokeName', () => { + const result = client.matchLocationFromSpokeName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.spokePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchSpokeFromSpokeName', () => { + const result = client.matchSpokeFromSpokeName(fakePath); + assert.strictEqual(result, 'spokeValue'); + assert( + (client.pathTemplates.spokePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-networkconnectivity/test/gapic_data_transfer_service_v1.ts b/packages/google-cloud-networkconnectivity/test/gapic_data_transfer_service_v1.ts index 18b5479c0afe..a4d47cdf8308 100644 --- a/packages/google-cloud-networkconnectivity/test/gapic_data_transfer_service_v1.ts +++ b/packages/google-cloud-networkconnectivity/test/gapic_data_transfer_service_v1.ts @@ -19,3632 +19,5133 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as datatransferserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + IamProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1.DataTransferServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = datatransferserviceModule.v1.DataTransferServiceClient.servicePath; - assert.strictEqual(servicePath, 'networkconnectivity.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = datatransferserviceModule.v1.DataTransferServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new datatransferserviceModule.v1.DataTransferServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new datatransferserviceModule.v1.DataTransferServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new datatransferserviceModule.v1.DataTransferServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = datatransferserviceModule.v1.DataTransferServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient(); - assert(client); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new datatransferserviceModule.v1.DataTransferServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - fallback: true, - }); - assert(client); - }); + it('has universeDomain', () => { + const client = + new datatransferserviceModule.v1.DataTransferServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.dataTransferServiceStub, undefined); - await client.initialize(); - assert(client.dataTransferServiceStub); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + datatransferserviceModule.v1.DataTransferServiceClient.servicePath; + assert.strictEqual(servicePath, 'networkconnectivity.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + datatransferserviceModule.v1.DataTransferServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { universeDomain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkconnectivity.example.com'); + }); - it('has close method for the initialized client', done => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.dataTransferServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { universe_domain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkconnectivity.example.com'); + }); - it('has close method for the non-initialized client', done => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.dataTransferServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new datatransferserviceModule.v1.DataTransferServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkconnectivity.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new datatransferserviceModule.v1.DataTransferServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'networkconnectivity.configured.example.com', + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new datatransferserviceModule.v1.DataTransferServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); }); - describe('getMulticloudDataTransferConfig', () => { - it('invokes getMulticloudDataTransferConfig without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig() - ); - client.innerApiCalls.getMulticloudDataTransferConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getMulticloudDataTransferConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getMulticloudDataTransferConfig without error using callback', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig() - ); - client.innerApiCalls.getMulticloudDataTransferConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getMulticloudDataTransferConfig( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has port', () => { + const port = datatransferserviceModule.v1.DataTransferServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('invokes getMulticloudDataTransferConfig with error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getMulticloudDataTransferConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getMulticloudDataTransferConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.getMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('should create a client with no option', () => { + const client = + new datatransferserviceModule.v1.DataTransferServiceClient(); + assert(client); + }); - it('invokes getMulticloudDataTransferConfig with closed client', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferConfigRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getMulticloudDataTransferConfig(request), expectedError); - }); + it('should create a client with gRPC fallback', () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + fallback: true, + }, + ); + assert(client); }); - describe('getDestination', () => { - it('invokes getDestination without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetDestinationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetDestinationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.Destination() - ); - client.innerApiCalls.getDestination = stubSimpleCall(expectedResponse); - const [response] = await client.getDestination(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDestination as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDestination as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.dataTransferServiceStub, undefined); + await client.initialize(); + assert(client.dataTransferServiceStub); + }); - it('invokes getDestination without error using callback', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetDestinationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetDestinationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.Destination() - ); - client.innerApiCalls.getDestination = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getDestination( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1.IDestination|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDestination as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDestination as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the initialized client', (done) => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.initialize().catch((err) => { + throw err; + }); + assert(client.dataTransferServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getDestination with error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetDestinationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetDestinationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getDestination = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDestination(request), expectedError); - const actualRequest = (client.innerApiCalls.getDestination as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDestination as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getDestination with closed client', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetDestinationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetDestinationRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getDestination(request), expectedError); + it('has close method for the non-initialized client', (done) => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.dataTransferServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('getMulticloudDataTransferSupportedService', () => { - it('invokes getMulticloudDataTransferSupportedService without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferSupportedServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferSupportedServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService() - ); - client.innerApiCalls.getMulticloudDataTransferSupportedService = stubSimpleCall(expectedResponse); - const [response] = await client.getMulticloudDataTransferSupportedService(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMulticloudDataTransferSupportedService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMulticloudDataTransferSupportedService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('invokes getMulticloudDataTransferSupportedService without error using callback', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferSupportedServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferSupportedServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService() - ); - client.innerApiCalls.getMulticloudDataTransferSupportedService = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getMulticloudDataTransferSupportedService( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMulticloudDataTransferSupportedService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMulticloudDataTransferSupportedService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getMulticloudDataTransferConfig', () => { + it('invokes getMulticloudDataTransferConfig without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig(), + ); + client.innerApiCalls.getMulticloudDataTransferConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.getMulticloudDataTransferConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getMulticloudDataTransferSupportedService with error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferSupportedServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferSupportedServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getMulticloudDataTransferSupportedService = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getMulticloudDataTransferSupportedService(request), expectedError); - const actualRequest = (client.innerApiCalls.getMulticloudDataTransferSupportedService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMulticloudDataTransferSupportedService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getMulticloudDataTransferConfig without error using callback', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig(), + ); + client.innerApiCalls.getMulticloudDataTransferConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getMulticloudDataTransferConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getMulticloudDataTransferSupportedService with closed client', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferSupportedServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferSupportedServiceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getMulticloudDataTransferSupportedService(request), expectedError); - }); + it('invokes getMulticloudDataTransferConfig with error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getMulticloudDataTransferConfig = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getMulticloudDataTransferConfig(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.getMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createMulticloudDataTransferConfig', () => { - it('invokes createMulticloudDataTransferConfig without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateMulticloudDataTransferConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateMulticloudDataTransferConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createMulticloudDataTransferConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.createMulticloudDataTransferConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getMulticloudDataTransferConfig with closed client', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.getMulticloudDataTransferConfig(request), + expectedError, + ); + }); + }); + + describe('getDestination', () => { + it('invokes getDestination without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetDestinationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetDestinationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Destination(), + ); + client.innerApiCalls.getDestination = stubSimpleCall(expectedResponse); + const [response] = await client.getDestination(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getDestination as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDestination as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createMulticloudDataTransferConfig without error using callback', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateMulticloudDataTransferConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateMulticloudDataTransferConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createMulticloudDataTransferConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createMulticloudDataTransferConfig( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getDestination without error using callback', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetDestinationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetDestinationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Destination(), + ); + client.innerApiCalls.getDestination = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDestination( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1.IDestination | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getDestination as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDestination as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createMulticloudDataTransferConfig with call error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateMulticloudDataTransferConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateMulticloudDataTransferConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createMulticloudDataTransferConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createMulticloudDataTransferConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getDestination with error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetDestinationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetDestinationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getDestination = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getDestination(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getDestination as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDestination as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createMulticloudDataTransferConfig with LRO error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateMulticloudDataTransferConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateMulticloudDataTransferConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createMulticloudDataTransferConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createMulticloudDataTransferConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getDestination with closed client', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetDestinationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetDestinationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getDestination(request), expectedError); + }); + }); + + describe('getMulticloudDataTransferSupportedService', () => { + it('invokes getMulticloudDataTransferSupportedService without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferSupportedServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferSupportedServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService(), + ); + client.innerApiCalls.getMulticloudDataTransferSupportedService = + stubSimpleCall(expectedResponse); + const [response] = + await client.getMulticloudDataTransferSupportedService(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls + .getMulticloudDataTransferSupportedService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls + .getMulticloudDataTransferSupportedService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateMulticloudDataTransferConfigProgress without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateMulticloudDataTransferConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes getMulticloudDataTransferSupportedService without error using callback', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferSupportedServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferSupportedServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService(), + ); + client.innerApiCalls.getMulticloudDataTransferSupportedService = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getMulticloudDataTransferSupportedService( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls + .getMulticloudDataTransferSupportedService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls + .getMulticloudDataTransferSupportedService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateMulticloudDataTransferConfigProgress with error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes getMulticloudDataTransferSupportedService with error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferSupportedServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferSupportedServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getMulticloudDataTransferSupportedService = + stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getMulticloudDataTransferSupportedService(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls + .getMulticloudDataTransferSupportedService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls + .getMulticloudDataTransferSupportedService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateMulticloudDataTransferConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes getMulticloudDataTransferSupportedService with closed client', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferSupportedServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetMulticloudDataTransferSupportedServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.getMulticloudDataTransferSupportedService(request), + expectedError, + ); + }); + }); + + describe('createMulticloudDataTransferConfig', () => { + it('invokes createMulticloudDataTransferConfig without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateMulticloudDataTransferConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateMulticloudDataTransferConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createMulticloudDataTransferConfig = + stubLongRunningCall(expectedResponse); + const [operation] = + await client.createMulticloudDataTransferConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateMulticloudDataTransferConfig', () => { - it('invokes updateMulticloudDataTransferConfig without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateMulticloudDataTransferConfigRequest() - ); - request.multicloudDataTransferConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateMulticloudDataTransferConfigRequest', ['multicloudDataTransferConfig', 'name']); - request.multicloudDataTransferConfig.name = defaultValue1; - const expectedHeaderRequestParams = `multicloud_data_transfer_config.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateMulticloudDataTransferConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateMulticloudDataTransferConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createMulticloudDataTransferConfig without error using callback', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateMulticloudDataTransferConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateMulticloudDataTransferConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createMulticloudDataTransferConfig = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createMulticloudDataTransferConfig( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateMulticloudDataTransferConfig without error using callback', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateMulticloudDataTransferConfigRequest() - ); - request.multicloudDataTransferConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateMulticloudDataTransferConfigRequest', ['multicloudDataTransferConfig', 'name']); - request.multicloudDataTransferConfig.name = defaultValue1; - const expectedHeaderRequestParams = `multicloud_data_transfer_config.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateMulticloudDataTransferConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateMulticloudDataTransferConfig( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createMulticloudDataTransferConfig with call error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateMulticloudDataTransferConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateMulticloudDataTransferConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createMulticloudDataTransferConfig = + stubLongRunningCall(undefined, expectedError); + await assert.rejects( + client.createMulticloudDataTransferConfig(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateMulticloudDataTransferConfig with call error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateMulticloudDataTransferConfigRequest() - ); - request.multicloudDataTransferConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateMulticloudDataTransferConfigRequest', ['multicloudDataTransferConfig', 'name']); - request.multicloudDataTransferConfig.name = defaultValue1; - const expectedHeaderRequestParams = `multicloud_data_transfer_config.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateMulticloudDataTransferConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateMulticloudDataTransferConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createMulticloudDataTransferConfig with LRO error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateMulticloudDataTransferConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateMulticloudDataTransferConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createMulticloudDataTransferConfig = + stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = + await client.createMulticloudDataTransferConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateMulticloudDataTransferConfig with LRO error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateMulticloudDataTransferConfigRequest() - ); - request.multicloudDataTransferConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateMulticloudDataTransferConfigRequest', ['multicloudDataTransferConfig', 'name']); - request.multicloudDataTransferConfig.name = defaultValue1; - const expectedHeaderRequestParams = `multicloud_data_transfer_config.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateMulticloudDataTransferConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateMulticloudDataTransferConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateMulticloudDataTransferConfigProgress without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkCreateMulticloudDataTransferConfigProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkUpdateMulticloudDataTransferConfigProgress without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateMulticloudDataTransferConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkCreateMulticloudDataTransferConfigProgress with error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateMulticloudDataTransferConfigProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateMulticloudDataTransferConfig', () => { + it('invokes updateMulticloudDataTransferConfig without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateMulticloudDataTransferConfigRequest(), + ); + request.multicloudDataTransferConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateMulticloudDataTransferConfigRequest', + ['multicloudDataTransferConfig', 'name'], + ); + request.multicloudDataTransferConfig.name = defaultValue1; + const expectedHeaderRequestParams = `multicloud_data_transfer_config.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateMulticloudDataTransferConfig = + stubLongRunningCall(expectedResponse); + const [operation] = + await client.updateMulticloudDataTransferConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateMulticloudDataTransferConfigProgress with error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes updateMulticloudDataTransferConfig without error using callback', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateMulticloudDataTransferConfigRequest(), + ); + request.multicloudDataTransferConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateMulticloudDataTransferConfigRequest', + ['multicloudDataTransferConfig', 'name'], + ); + request.multicloudDataTransferConfig.name = defaultValue1; + const expectedHeaderRequestParams = `multicloud_data_transfer_config.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateMulticloudDataTransferConfig = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateMulticloudDataTransferConfig( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateMulticloudDataTransferConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateMulticloudDataTransferConfig with call error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateMulticloudDataTransferConfigRequest(), + ); + request.multicloudDataTransferConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateMulticloudDataTransferConfigRequest', + ['multicloudDataTransferConfig', 'name'], + ); + request.multicloudDataTransferConfig.name = defaultValue1; + const expectedHeaderRequestParams = `multicloud_data_transfer_config.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateMulticloudDataTransferConfig = + stubLongRunningCall(undefined, expectedError); + await assert.rejects( + client.updateMulticloudDataTransferConfig(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteMulticloudDataTransferConfig', () => { - it('invokes deleteMulticloudDataTransferConfig without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteMulticloudDataTransferConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteMulticloudDataTransferConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteMulticloudDataTransferConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteMulticloudDataTransferConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateMulticloudDataTransferConfig with LRO error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateMulticloudDataTransferConfigRequest(), + ); + request.multicloudDataTransferConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateMulticloudDataTransferConfigRequest', + ['multicloudDataTransferConfig', 'name'], + ); + request.multicloudDataTransferConfig.name = defaultValue1; + const expectedHeaderRequestParams = `multicloud_data_transfer_config.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateMulticloudDataTransferConfig = + stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = + await client.updateMulticloudDataTransferConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteMulticloudDataTransferConfig without error using callback', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteMulticloudDataTransferConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteMulticloudDataTransferConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteMulticloudDataTransferConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteMulticloudDataTransferConfig( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateMulticloudDataTransferConfigProgress without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkUpdateMulticloudDataTransferConfigProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteMulticloudDataTransferConfig with call error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteMulticloudDataTransferConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteMulticloudDataTransferConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteMulticloudDataTransferConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteMulticloudDataTransferConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateMulticloudDataTransferConfigProgress with error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateMulticloudDataTransferConfigProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteMulticloudDataTransferConfig', () => { + it('invokes deleteMulticloudDataTransferConfig without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteMulticloudDataTransferConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteMulticloudDataTransferConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteMulticloudDataTransferConfig = + stubLongRunningCall(expectedResponse); + const [operation] = + await client.deleteMulticloudDataTransferConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteMulticloudDataTransferConfig with LRO error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteMulticloudDataTransferConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteMulticloudDataTransferConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteMulticloudDataTransferConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteMulticloudDataTransferConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteMulticloudDataTransferConfig without error using callback', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteMulticloudDataTransferConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteMulticloudDataTransferConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteMulticloudDataTransferConfig = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteMulticloudDataTransferConfig( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteMulticloudDataTransferConfigProgress without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteMulticloudDataTransferConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteMulticloudDataTransferConfig with call error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteMulticloudDataTransferConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteMulticloudDataTransferConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteMulticloudDataTransferConfig = + stubLongRunningCall(undefined, expectedError); + await assert.rejects( + client.deleteMulticloudDataTransferConfig(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteMulticloudDataTransferConfigProgress with error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes deleteMulticloudDataTransferConfig with LRO error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteMulticloudDataTransferConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteMulticloudDataTransferConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteMulticloudDataTransferConfig = + stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = + await client.deleteMulticloudDataTransferConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteMulticloudDataTransferConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteMulticloudDataTransferConfigProgress without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkDeleteMulticloudDataTransferConfigProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('createDestination', () => { - it('invokes createDestination without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateDestinationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateDestinationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createDestination = stubLongRunningCall(expectedResponse); - const [operation] = await client.createDestination(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createDestination as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDestination as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteMulticloudDataTransferConfigProgress with error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteMulticloudDataTransferConfigProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createDestination', () => { + it('invokes createDestination without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateDestinationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateDestinationRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createDestination = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createDestination(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createDestination as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDestination as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createDestination without error using callback', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateDestinationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateDestinationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createDestination = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createDestination( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createDestination as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDestination as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createDestination without error using callback', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateDestinationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateDestinationRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createDestination = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createDestination( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1.IDestination, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1.IDestination, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createDestination as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDestination as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createDestination with call error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateDestinationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateDestinationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createDestination = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createDestination(request), expectedError); - const actualRequest = (client.innerApiCalls.createDestination as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDestination as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createDestination with call error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateDestinationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateDestinationRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createDestination = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createDestination(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createDestination as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDestination as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createDestination with LRO error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateDestinationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateDestinationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createDestination = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createDestination(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createDestination as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDestination as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createDestination with LRO error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateDestinationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateDestinationRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createDestination = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createDestination(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createDestination as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDestination as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateDestinationProgress without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateDestinationProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkCreateDestinationProgress without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkCreateDestinationProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkCreateDestinationProgress with error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes checkCreateDestinationProgress with error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateDestinationProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateDestination', () => { + it('invokes updateDestination without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateDestinationRequest(), + ); + request.destination ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateDestinationRequest', + ['destination', 'name'], + ); + request.destination.name = defaultValue1; + const expectedHeaderRequestParams = `destination.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateDestination = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateDestination(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateDestination as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateDestination as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateDestinationProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateDestination without error using callback', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateDestinationRequest(), + ); + request.destination ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateDestinationRequest', + ['destination', 'name'], + ); + request.destination.name = defaultValue1; + const expectedHeaderRequestParams = `destination.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateDestination = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateDestination( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1.IDestination, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1.IDestination, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateDestination as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateDestination as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateDestination', () => { - it('invokes updateDestination without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateDestinationRequest() - ); - request.destination ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateDestinationRequest', ['destination', 'name']); - request.destination.name = defaultValue1; - const expectedHeaderRequestParams = `destination.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateDestination = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateDestination(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateDestination as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDestination as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateDestination with call error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateDestinationRequest(), + ); + request.destination ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateDestinationRequest', + ['destination', 'name'], + ); + request.destination.name = defaultValue1; + const expectedHeaderRequestParams = `destination.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDestination = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateDestination(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateDestination as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateDestination as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateDestination without error using callback', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateDestinationRequest() - ); - request.destination ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateDestinationRequest', ['destination', 'name']); - request.destination.name = defaultValue1; - const expectedHeaderRequestParams = `destination.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateDestination = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateDestination( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateDestination as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDestination as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateDestination with LRO error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateDestinationRequest(), + ); + request.destination ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateDestinationRequest', + ['destination', 'name'], + ); + request.destination.name = defaultValue1; + const expectedHeaderRequestParams = `destination.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDestination = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateDestination(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateDestination as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateDestination as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateDestination with call error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateDestinationRequest() - ); - request.destination ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateDestinationRequest', ['destination', 'name']); - request.destination.name = defaultValue1; - const expectedHeaderRequestParams = `destination.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateDestination = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateDestination(request), expectedError); - const actualRequest = (client.innerApiCalls.updateDestination as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDestination as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateDestinationProgress without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkUpdateDestinationProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateDestination with LRO error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateDestinationRequest() - ); - request.destination ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateDestinationRequest', ['destination', 'name']); - request.destination.name = defaultValue1; - const expectedHeaderRequestParams = `destination.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateDestination = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateDestination(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateDestination as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDestination as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateDestinationProgress with error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateDestinationProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteDestination', () => { + it('invokes deleteDestination without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteDestinationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteDestinationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteDestination = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteDestination(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteDestination as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDestination as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateDestinationProgress without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateDestinationProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteDestination without error using callback', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteDestinationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteDestinationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteDestination = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteDestination( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteDestination as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDestination as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateDestinationProgress with error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes deleteDestination with call error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteDestinationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteDestinationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteDestination = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteDestination(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteDestination as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDestination as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateDestinationProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteDestination with LRO error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteDestinationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteDestinationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteDestination = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteDestination(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteDestination as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDestination as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteDestination', () => { - it('invokes deleteDestination without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteDestinationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteDestinationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteDestination = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteDestination(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteDestination as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDestination as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteDestinationProgress without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkDeleteDestinationProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteDestination without error using callback', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteDestinationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteDestinationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteDestination = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteDestination( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteDestination as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDestination as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteDestinationProgress with error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteDestinationProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listMulticloudDataTransferConfigs', () => { + it('invokes listMulticloudDataTransferConfigs without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig(), + ), + ]; + client.innerApiCalls.listMulticloudDataTransferConfigs = + stubSimpleCall(expectedResponse); + const [response] = + await client.listMulticloudDataTransferConfigs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listMulticloudDataTransferConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMulticloudDataTransferConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteDestination with call error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteDestinationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteDestinationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteDestination = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteDestination(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteDestination as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDestination as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listMulticloudDataTransferConfigs without error using callback', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig(), + ), + ]; + client.innerApiCalls.listMulticloudDataTransferConfigs = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listMulticloudDataTransferConfigs( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listMulticloudDataTransferConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMulticloudDataTransferConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteDestination with LRO error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteDestinationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteDestinationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteDestination = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteDestination(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteDestination as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDestination as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listMulticloudDataTransferConfigs with error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listMulticloudDataTransferConfigs = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listMulticloudDataTransferConfigs(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listMulticloudDataTransferConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMulticloudDataTransferConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteDestinationProgress without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteDestinationProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + it('invokes listMulticloudDataTransferConfigsStream without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig(), + ), + ]; + client.descriptors.page.listMulticloudDataTransferConfigs.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listMulticloudDataTransferConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes checkDeleteDestinationProgress with error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteDestinationProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); + stream.on('error', (err: Error) => { + reject(err); }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listMulticloudDataTransferConfigs + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listMulticloudDataTransferConfigs, + request, + ), + ); + assert( + ( + client.descriptors.page.listMulticloudDataTransferConfigs + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - describe('listMulticloudDataTransferConfigs', () => { - it('invokes listMulticloudDataTransferConfigs without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig()), - ]; - client.innerApiCalls.listMulticloudDataTransferConfigs = stubSimpleCall(expectedResponse); - const [response] = await client.listMulticloudDataTransferConfigs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMulticloudDataTransferConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMulticloudDataTransferConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listMulticloudDataTransferConfigs without error using callback', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig()), - ]; - client.innerApiCalls.listMulticloudDataTransferConfigs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listMulticloudDataTransferConfigs( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMulticloudDataTransferConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMulticloudDataTransferConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listMulticloudDataTransferConfigsStream with error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMulticloudDataTransferConfigs.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listMulticloudDataTransferConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listMulticloudDataTransferConfigs with error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listMulticloudDataTransferConfigs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listMulticloudDataTransferConfigs(request), expectedError); - const actualRequest = (client.innerApiCalls.listMulticloudDataTransferConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMulticloudDataTransferConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + stream.on('error', (err: Error) => { + reject(err); }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listMulticloudDataTransferConfigs + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listMulticloudDataTransferConfigs, + request, + ), + ); + assert( + ( + client.descriptors.page.listMulticloudDataTransferConfigs + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listMulticloudDataTransferConfigsStream without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig()), - ]; - client.descriptors.page.listMulticloudDataTransferConfigs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listMulticloudDataTransferConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listMulticloudDataTransferConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMulticloudDataTransferConfigs, request)); - assert( - (client.descriptors.page.listMulticloudDataTransferConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listMulticloudDataTransferConfigs without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig(), + ), + ]; + client.descriptors.page.listMulticloudDataTransferConfigs.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig[] = + []; + const iterable = client.listMulticloudDataTransferConfigsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listMulticloudDataTransferConfigs + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listMulticloudDataTransferConfigs + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listMulticloudDataTransferConfigsStream with error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMulticloudDataTransferConfigs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listMulticloudDataTransferConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listMulticloudDataTransferConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMulticloudDataTransferConfigs, request)); - assert( - (client.descriptors.page.listMulticloudDataTransferConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listMulticloudDataTransferConfigs with error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMulticloudDataTransferConfigs.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listMulticloudDataTransferConfigsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listMulticloudDataTransferConfigs + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listMulticloudDataTransferConfigs + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('listDestinations', () => { + it('invokes listDestinations without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListDestinationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListDestinationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Destination(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Destination(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Destination(), + ), + ]; + client.innerApiCalls.listDestinations = stubSimpleCall(expectedResponse); + const [response] = await client.listDestinations(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDestinations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDestinations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listMulticloudDataTransferConfigs without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferConfig()), - ]; - client.descriptors.page.listMulticloudDataTransferConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig[] = []; - const iterable = client.listMulticloudDataTransferConfigsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listDestinations without error using callback', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListDestinationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListDestinationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Destination(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Destination(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Destination(), + ), + ]; + client.innerApiCalls.listDestinations = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listDestinations( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkconnectivity.v1.IDestination[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listMulticloudDataTransferConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMulticloudDataTransferConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDestinations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDestinations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listMulticloudDataTransferConfigs with error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMulticloudDataTransferConfigs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listMulticloudDataTransferConfigsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferConfig[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listMulticloudDataTransferConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMulticloudDataTransferConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listDestinations with error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListDestinationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListDestinationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listDestinations = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listDestinations(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listDestinations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDestinations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listDestinations', () => { - it('invokes listDestinations without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListDestinationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListDestinationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Destination()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Destination()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Destination()), - ]; - client.innerApiCalls.listDestinations = stubSimpleCall(expectedResponse); - const [response] = await client.listDestinations(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDestinations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDestinations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listDestinationsStream without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListDestinationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListDestinationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Destination(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Destination(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Destination(), + ), + ]; + client.descriptors.page.listDestinations.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listDestinationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.Destination[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1.Destination, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listDestinations without error using callback', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListDestinationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListDestinationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Destination()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Destination()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Destination()), - ]; - client.innerApiCalls.listDestinations = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listDestinations( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1.IDestination[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDestinations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDestinations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + stream.on('error', (err: Error) => { + reject(err); }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listDestinations.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listDestinations, request), + ); + assert( + (client.descriptors.page.listDestinations.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listDestinations with error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListDestinationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListDestinationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listDestinations = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDestinations(request), expectedError); - const actualRequest = (client.innerApiCalls.listDestinations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDestinations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listDestinationsStream with error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListDestinationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListDestinationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDestinations.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listDestinationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.Destination[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1.Destination, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listDestinationsStream without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListDestinationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListDestinationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Destination()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Destination()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Destination()), - ]; - client.descriptors.page.listDestinations.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listDestinationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.Destination[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.Destination) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listDestinations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDestinations, request)); - assert( - (client.descriptors.page.listDestinations.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + stream.on('error', (err: Error) => { + reject(err); }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listDestinations.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listDestinations, request), + ); + assert( + (client.descriptors.page.listDestinations.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listDestinationsStream with error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListDestinationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListDestinationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listDestinations.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listDestinationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.Destination[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.Destination) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listDestinations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDestinations, request)); - assert( - (client.descriptors.page.listDestinations.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listDestinations without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListDestinationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListDestinationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Destination(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Destination(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Destination(), + ), + ]; + client.descriptors.page.listDestinations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1.IDestination[] = + []; + const iterable = client.listDestinationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listDestinations.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listDestinations.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listDestinations without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListDestinationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListDestinationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Destination()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Destination()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Destination()), - ]; - client.descriptors.page.listDestinations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1.IDestination[] = []; - const iterable = client.listDestinationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listDestinations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDestinations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listDestinations with error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListDestinationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListDestinationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDestinations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listDestinationsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1.IDestination[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listDestinations.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listDestinations.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listMulticloudDataTransferSupportedServices', () => { + it('invokes listMulticloudDataTransferSupportedServices without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferSupportedServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferSupportedServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService(), + ), + ]; + client.innerApiCalls.listMulticloudDataTransferSupportedServices = + stubSimpleCall(expectedResponse); + const [response] = + await client.listMulticloudDataTransferSupportedServices(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls + .listMulticloudDataTransferSupportedServices as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls + .listMulticloudDataTransferSupportedServices as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listDestinations with error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListDestinationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListDestinationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listDestinations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listDestinationsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1.IDestination[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listDestinations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDestinations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listMulticloudDataTransferSupportedServices without error using callback', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferSupportedServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferSupportedServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService(), + ), + ]; + client.innerApiCalls.listMulticloudDataTransferSupportedServices = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listMulticloudDataTransferSupportedServices( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls + .listMulticloudDataTransferSupportedServices as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls + .listMulticloudDataTransferSupportedServices as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listMulticloudDataTransferSupportedServices', () => { - it('invokes listMulticloudDataTransferSupportedServices without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferSupportedServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferSupportedServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService()), - ]; - client.innerApiCalls.listMulticloudDataTransferSupportedServices = stubSimpleCall(expectedResponse); - const [response] = await client.listMulticloudDataTransferSupportedServices(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMulticloudDataTransferSupportedServices as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMulticloudDataTransferSupportedServices as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listMulticloudDataTransferSupportedServices with error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferSupportedServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferSupportedServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listMulticloudDataTransferSupportedServices = + stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.listMulticloudDataTransferSupportedServices(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls + .listMulticloudDataTransferSupportedServices as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls + .listMulticloudDataTransferSupportedServices as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listMulticloudDataTransferSupportedServices without error using callback', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferSupportedServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferSupportedServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService()), - ]; - client.innerApiCalls.listMulticloudDataTransferSupportedServices = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listMulticloudDataTransferSupportedServices( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMulticloudDataTransferSupportedServices as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMulticloudDataTransferSupportedServices as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listMulticloudDataTransferSupportedServicesStream without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferSupportedServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferSupportedServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService(), + ), + ]; + client.descriptors.page.listMulticloudDataTransferSupportedServices.createStream = + stubPageStreamingCall(expectedResponse); + const stream = + client.listMulticloudDataTransferSupportedServicesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listMulticloudDataTransferSupportedServices with error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferSupportedServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferSupportedServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listMulticloudDataTransferSupportedServices = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listMulticloudDataTransferSupportedServices(request), expectedError); - const actualRequest = (client.innerApiCalls.listMulticloudDataTransferSupportedServices as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMulticloudDataTransferSupportedServices as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + stream.on('error', (err: Error) => { + reject(err); }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listMulticloudDataTransferSupportedServices + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listMulticloudDataTransferSupportedServices, + request, + ), + ); + assert( + ( + client.descriptors.page.listMulticloudDataTransferSupportedServices + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listMulticloudDataTransferSupportedServicesStream without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferSupportedServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferSupportedServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService()), - ]; - client.descriptors.page.listMulticloudDataTransferSupportedServices.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listMulticloudDataTransferSupportedServicesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listMulticloudDataTransferSupportedServices.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMulticloudDataTransferSupportedServices, request)); - assert( - (client.descriptors.page.listMulticloudDataTransferSupportedServices.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('invokes listMulticloudDataTransferSupportedServicesStream with error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferSupportedServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferSupportedServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMulticloudDataTransferSupportedServices.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = + client.listMulticloudDataTransferSupportedServicesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listMulticloudDataTransferSupportedServicesStream with error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferSupportedServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferSupportedServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMulticloudDataTransferSupportedServices.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listMulticloudDataTransferSupportedServicesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listMulticloudDataTransferSupportedServices.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMulticloudDataTransferSupportedServices, request)); - assert( - (client.descriptors.page.listMulticloudDataTransferSupportedServices.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + stream.on('error', (err: Error) => { + reject(err); }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listMulticloudDataTransferSupportedServices + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listMulticloudDataTransferSupportedServices, + request, + ), + ); + assert( + ( + client.descriptors.page.listMulticloudDataTransferSupportedServices + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('uses async iteration with listMulticloudDataTransferSupportedServices without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferSupportedServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferSupportedServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService()), - ]; - client.descriptors.page.listMulticloudDataTransferSupportedServices.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService[] = []; - const iterable = client.listMulticloudDataTransferSupportedServicesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listMulticloudDataTransferSupportedServices.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMulticloudDataTransferSupportedServices.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listMulticloudDataTransferSupportedServices without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferSupportedServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferSupportedServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.MulticloudDataTransferSupportedService(), + ), + ]; + client.descriptors.page.listMulticloudDataTransferSupportedServices.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService[] = + []; + const iterable = + client.listMulticloudDataTransferSupportedServicesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listMulticloudDataTransferSupportedServices + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listMulticloudDataTransferSupportedServices + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('uses async iteration with listMulticloudDataTransferSupportedServices with error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferSupportedServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferSupportedServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMulticloudDataTransferSupportedServices.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listMulticloudDataTransferSupportedServicesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listMulticloudDataTransferSupportedServices.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMulticloudDataTransferSupportedServices.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listMulticloudDataTransferSupportedServices with error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferSupportedServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListMulticloudDataTransferSupportedServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMulticloudDataTransferSupportedServices.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = + client.listMulticloudDataTransferSupportedServicesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1.IMulticloudDataTransferSupportedService[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listMulticloudDataTransferSupportedServices + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listMulticloudDataTransferSupportedServices + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy without error using callback', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy with error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes setIamPolicy with error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes testIamPermissions with error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('destination', async () => { + const fakePath = '/rendered/path/destination'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + multicloud_data_transfer_config: 'multicloudDataTransferConfigValue', + destination: 'destinationValue', + }; + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.destinationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.destinationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('destinationPath', () => { + const result = client.destinationPath( + 'projectValue', + 'locationValue', + 'multicloudDataTransferConfigValue', + 'destinationValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.destinationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromDestinationName', () => { + const result = client.matchProjectFromDestinationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromDestinationName', () => { + const result = client.matchLocationFromDestinationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMulticloudDataTransferConfigFromDestinationName', () => { + const result = + client.matchMulticloudDataTransferConfigFromDestinationName(fakePath); + assert.strictEqual(result, 'multicloudDataTransferConfigValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchDestinationFromDestinationName', () => { + const result = client.matchDestinationFromDestinationName(fakePath); + assert.strictEqual(result, 'destinationValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('destination', async () => { - const fakePath = "/rendered/path/destination"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - multicloud_data_transfer_config: "multicloudDataTransferConfigValue", - destination: "destinationValue", - }; - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.destinationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.destinationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('destinationPath', () => { - const result = client.destinationPath("projectValue", "locationValue", "multicloudDataTransferConfigValue", "destinationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.destinationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDestinationName', () => { - const result = client.matchProjectFromDestinationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromDestinationName', () => { - const result = client.matchLocationFromDestinationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMulticloudDataTransferConfigFromDestinationName', () => { - const result = client.matchMulticloudDataTransferConfigFromDestinationName(fakePath); - assert.strictEqual(result, "multicloudDataTransferConfigValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDestinationFromDestinationName', () => { - const result = client.matchDestinationFromDestinationName(fakePath); - assert.strictEqual(result, "destinationValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('group', async () => { - const fakePath = "/rendered/path/group"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - group: "groupValue", - }; - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.groupPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.groupPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('groupPath', () => { - const result = client.groupPath("projectValue", "hubValue", "groupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.groupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromGroupName', () => { - const result = client.matchProjectFromGroupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.groupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHubFromGroupName', () => { - const result = client.matchHubFromGroupName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.groupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchGroupFromGroupName', () => { - const result = client.matchGroupFromGroupName(fakePath); - assert.strictEqual(result, "groupValue"); - assert((client.pathTemplates.groupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('hub', async () => { - const fakePath = "/rendered/path/hub"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - }; - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.hubPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.hubPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('hubPath', () => { - const result = client.hubPath("projectValue", "hubValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.hubPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromHubName', () => { - const result = client.matchProjectFromHubName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.hubPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHubFromHubName', () => { - const result = client.matchHubFromHubName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.hubPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('hubRoute', async () => { - const fakePath = "/rendered/path/hubRoute"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - route_table: "routeTableValue", - route: "routeValue", - }; - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.hubRoutePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.hubRoutePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('hubRoutePath', () => { - const result = client.hubRoutePath("projectValue", "hubValue", "routeTableValue", "routeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.hubRoutePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromHubRouteName', () => { - const result = client.matchProjectFromHubRouteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHubFromHubRouteName', () => { - const result = client.matchHubFromHubRouteName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRouteTableFromHubRouteName', () => { - const result = client.matchRouteTableFromHubRouteName(fakePath); - assert.strictEqual(result, "routeTableValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRouteFromHubRouteName', () => { - const result = client.matchRouteFromHubRouteName(fakePath); - assert.strictEqual(result, "routeValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('internalRange', async () => { - const fakePath = "/rendered/path/internalRange"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - internal_range: "internalRangeValue", - }; - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.internalRangePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.internalRangePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('internalRangePath', () => { - const result = client.internalRangePath("projectValue", "locationValue", "internalRangeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.internalRangePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInternalRangeName', () => { - const result = client.matchProjectFromInternalRangeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.internalRangePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromInternalRangeName', () => { - const result = client.matchLocationFromInternalRangeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.internalRangePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInternalRangeFromInternalRangeName', () => { - const result = client.matchInternalRangeFromInternalRangeName(fakePath); - assert.strictEqual(result, "internalRangeValue"); - assert((client.pathTemplates.internalRangePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('multicloudDataTransferConfig', async () => { - const fakePath = "/rendered/path/multicloudDataTransferConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - multicloud_data_transfer_config: "multicloudDataTransferConfigValue", - }; - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.multicloudDataTransferConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.multicloudDataTransferConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('multicloudDataTransferConfigPath', () => { - const result = client.multicloudDataTransferConfigPath("projectValue", "locationValue", "multicloudDataTransferConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMulticloudDataTransferConfigName', () => { - const result = client.matchProjectFromMulticloudDataTransferConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMulticloudDataTransferConfigName', () => { - const result = client.matchLocationFromMulticloudDataTransferConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName', () => { - const result = client.matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName(fakePath); - assert.strictEqual(result, "multicloudDataTransferConfigValue"); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('multicloudDataTransferSupportedService', async () => { - const fakePath = "/rendered/path/multicloudDataTransferSupportedService"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - multicloud_data_transfer_supported_service: "multicloudDataTransferSupportedServiceValue", - }; - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('multicloudDataTransferSupportedServicePath', () => { - const result = client.multicloudDataTransferSupportedServicePath("projectValue", "locationValue", "multicloudDataTransferSupportedServiceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMulticloudDataTransferSupportedServiceName', () => { - const result = client.matchProjectFromMulticloudDataTransferSupportedServiceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMulticloudDataTransferSupportedServiceName', () => { - const result = client.matchLocationFromMulticloudDataTransferSupportedServiceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName', () => { - const result = client.matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName(fakePath); - assert.strictEqual(result, "multicloudDataTransferSupportedServiceValue"); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('policyBasedRoute', async () => { - const fakePath = "/rendered/path/policyBasedRoute"; - const expectedParameters = { - project: "projectValue", - policy_based_route: "policyBasedRouteValue", - }; - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.policyBasedRoutePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.policyBasedRoutePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('policyBasedRoutePath', () => { - const result = client.policyBasedRoutePath("projectValue", "policyBasedRouteValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.policyBasedRoutePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromPolicyBasedRouteName', () => { - const result = client.matchProjectFromPolicyBasedRouteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchPolicyBasedRouteFromPolicyBasedRouteName', () => { - const result = client.matchPolicyBasedRouteFromPolicyBasedRouteName(fakePath); - assert.strictEqual(result, "policyBasedRouteValue"); - assert((client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('routeTable', async () => { - const fakePath = "/rendered/path/routeTable"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - route_table: "routeTableValue", - }; - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.routeTablePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.routeTablePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('routeTablePath', () => { - const result = client.routeTablePath("projectValue", "hubValue", "routeTableValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.routeTablePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRouteTableName', () => { - const result = client.matchProjectFromRouteTableName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.routeTablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHubFromRouteTableName', () => { - const result = client.matchHubFromRouteTableName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.routeTablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRouteTableFromRouteTableName', () => { - const result = client.matchRouteTableFromRouteTableName(fakePath); - assert.strictEqual(result, "routeTableValue"); - assert((client.pathTemplates.routeTablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('serviceClass', async () => { - const fakePath = "/rendered/path/serviceClass"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service_class: "serviceClassValue", - }; - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.serviceClassPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.serviceClassPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('serviceClassPath', () => { - const result = client.serviceClassPath("projectValue", "locationValue", "serviceClassValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.serviceClassPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceClassName', () => { - const result = client.matchProjectFromServiceClassName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.serviceClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServiceClassName', () => { - const result = client.matchLocationFromServiceClassName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.serviceClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceClassFromServiceClassName', () => { - const result = client.matchServiceClassFromServiceClassName(fakePath); - assert.strictEqual(result, "serviceClassValue"); - assert((client.pathTemplates.serviceClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('serviceConnectionMap', async () => { - const fakePath = "/rendered/path/serviceConnectionMap"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service_connection_map: "serviceConnectionMapValue", - }; - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.serviceConnectionMapPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.serviceConnectionMapPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('serviceConnectionMapPath', () => { - const result = client.serviceConnectionMapPath("projectValue", "locationValue", "serviceConnectionMapValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.serviceConnectionMapPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceConnectionMapName', () => { - const result = client.matchProjectFromServiceConnectionMapName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.serviceConnectionMapPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServiceConnectionMapName', () => { - const result = client.matchLocationFromServiceConnectionMapName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.serviceConnectionMapPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('group', async () => { + const fakePath = '/rendered/path/group'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + group: 'groupValue', + }; + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.groupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.groupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('groupPath', () => { + const result = client.groupPath( + 'projectValue', + 'hubValue', + 'groupValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.groupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromGroupName', () => { + const result = client.matchProjectFromGroupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.groupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromGroupName', () => { + const result = client.matchHubFromGroupName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.groupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchGroupFromGroupName', () => { + const result = client.matchGroupFromGroupName(fakePath); + assert.strictEqual(result, 'groupValue'); + assert( + (client.pathTemplates.groupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchServiceConnectionMapFromServiceConnectionMapName', () => { - const result = client.matchServiceConnectionMapFromServiceConnectionMapName(fakePath); - assert.strictEqual(result, "serviceConnectionMapValue"); - assert((client.pathTemplates.serviceConnectionMapPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('hub', async () => { + const fakePath = '/rendered/path/hub'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + }; + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.hubPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.hubPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('hubPath', () => { + const result = client.hubPath('projectValue', 'hubValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.hubPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromHubName', () => { + const result = client.matchProjectFromHubName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.hubPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromHubName', () => { + const result = client.matchHubFromHubName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.hubPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('serviceConnectionPolicy', async () => { - const fakePath = "/rendered/path/serviceConnectionPolicy"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service_connection_policy: "serviceConnectionPolicyValue", - }; - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.serviceConnectionPolicyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.serviceConnectionPolicyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('serviceConnectionPolicyPath', () => { - const result = client.serviceConnectionPolicyPath("projectValue", "locationValue", "serviceConnectionPolicyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.serviceConnectionPolicyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('hubRoute', async () => { + const fakePath = '/rendered/path/hubRoute'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + route_table: 'routeTableValue', + route: 'routeValue', + }; + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.hubRoutePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.hubRoutePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('hubRoutePath', () => { + const result = client.hubRoutePath( + 'projectValue', + 'hubValue', + 'routeTableValue', + 'routeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.hubRoutePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromHubRouteName', () => { + const result = client.matchProjectFromHubRouteName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromHubRouteName', () => { + const result = client.matchHubFromHubRouteName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRouteTableFromHubRouteName', () => { + const result = client.matchRouteTableFromHubRouteName(fakePath); + assert.strictEqual(result, 'routeTableValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRouteFromHubRouteName', () => { + const result = client.matchRouteFromHubRouteName(fakePath); + assert.strictEqual(result, 'routeValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromServiceConnectionPolicyName', () => { - const result = client.matchProjectFromServiceConnectionPolicyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.serviceConnectionPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('internalRange', async () => { + const fakePath = '/rendered/path/internalRange'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + internal_range: 'internalRangeValue', + }; + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.internalRangePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.internalRangePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('internalRangePath', () => { + const result = client.internalRangePath( + 'projectValue', + 'locationValue', + 'internalRangeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.internalRangePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromInternalRangeName', () => { + const result = client.matchProjectFromInternalRangeName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.internalRangePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromInternalRangeName', () => { + const result = client.matchLocationFromInternalRangeName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.internalRangePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchInternalRangeFromInternalRangeName', () => { + const result = client.matchInternalRangeFromInternalRangeName(fakePath); + assert.strictEqual(result, 'internalRangeValue'); + assert( + (client.pathTemplates.internalRangePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchLocationFromServiceConnectionPolicyName', () => { - const result = client.matchLocationFromServiceConnectionPolicyName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.serviceConnectionPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchServiceConnectionPolicyFromServiceConnectionPolicyName', () => { - const result = client.matchServiceConnectionPolicyFromServiceConnectionPolicyName(fakePath); - assert.strictEqual(result, "serviceConnectionPolicyValue"); - assert((client.pathTemplates.serviceConnectionPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('multicloudDataTransferConfig', async () => { + const fakePath = '/rendered/path/multicloudDataTransferConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + multicloud_data_transfer_config: 'multicloudDataTransferConfigValue', + }; + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.multicloudDataTransferConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.multicloudDataTransferConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('multicloudDataTransferConfigPath', () => { + const result = client.multicloudDataTransferConfigPath( + 'projectValue', + 'locationValue', + 'multicloudDataTransferConfigValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMulticloudDataTransferConfigName', () => { + const result = + client.matchProjectFromMulticloudDataTransferConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMulticloudDataTransferConfigName', () => { + const result = + client.matchLocationFromMulticloudDataTransferConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName', () => { + const result = + client.matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName( + fakePath, + ); + assert.strictEqual(result, 'multicloudDataTransferConfigValue'); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('serviceConnectionToken', async () => { - const fakePath = "/rendered/path/serviceConnectionToken"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service_connection_token: "serviceConnectionTokenValue", - }; - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.serviceConnectionTokenPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.serviceConnectionTokenPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('serviceConnectionTokenPath', () => { - const result = client.serviceConnectionTokenPath("projectValue", "locationValue", "serviceConnectionTokenValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.serviceConnectionTokenPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('multicloudDataTransferSupportedService', async () => { + const fakePath = '/rendered/path/multicloudDataTransferSupportedService'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + multicloud_data_transfer_supported_service: + 'multicloudDataTransferSupportedServiceValue', + }; + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('multicloudDataTransferSupportedServicePath', () => { + const result = client.multicloudDataTransferSupportedServicePath( + 'projectValue', + 'locationValue', + 'multicloudDataTransferSupportedServiceValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMulticloudDataTransferSupportedServiceName', () => { + const result = + client.matchProjectFromMulticloudDataTransferSupportedServiceName( + fakePath, + ); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMulticloudDataTransferSupportedServiceName', () => { + const result = + client.matchLocationFromMulticloudDataTransferSupportedServiceName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName', () => { + const result = + client.matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName( + fakePath, + ); + assert.strictEqual( + result, + 'multicloudDataTransferSupportedServiceValue', + ); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromServiceConnectionTokenName', () => { - const result = client.matchProjectFromServiceConnectionTokenName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.serviceConnectionTokenPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('policyBasedRoute', async () => { + const fakePath = '/rendered/path/policyBasedRoute'; + const expectedParameters = { + project: 'projectValue', + policy_based_route: 'policyBasedRouteValue', + }; + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.policyBasedRoutePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.policyBasedRoutePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('policyBasedRoutePath', () => { + const result = client.policyBasedRoutePath( + 'projectValue', + 'policyBasedRouteValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.policyBasedRoutePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromPolicyBasedRouteName', () => { + const result = client.matchProjectFromPolicyBasedRouteName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchPolicyBasedRouteFromPolicyBasedRouteName', () => { + const result = + client.matchPolicyBasedRouteFromPolicyBasedRouteName(fakePath); + assert.strictEqual(result, 'policyBasedRouteValue'); + assert( + (client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchLocationFromServiceConnectionTokenName', () => { - const result = client.matchLocationFromServiceConnectionTokenName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.serviceConnectionTokenPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('routeTable', async () => { + const fakePath = '/rendered/path/routeTable'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + route_table: 'routeTableValue', + }; + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.routeTablePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.routeTablePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('routeTablePath', () => { + const result = client.routeTablePath( + 'projectValue', + 'hubValue', + 'routeTableValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.routeTablePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromRouteTableName', () => { + const result = client.matchProjectFromRouteTableName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.routeTablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromRouteTableName', () => { + const result = client.matchHubFromRouteTableName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.routeTablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRouteTableFromRouteTableName', () => { + const result = client.matchRouteTableFromRouteTableName(fakePath); + assert.strictEqual(result, 'routeTableValue'); + assert( + (client.pathTemplates.routeTablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchServiceConnectionTokenFromServiceConnectionTokenName', () => { - const result = client.matchServiceConnectionTokenFromServiceConnectionTokenName(fakePath); - assert.strictEqual(result, "serviceConnectionTokenValue"); - assert((client.pathTemplates.serviceConnectionTokenPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('serviceClass', async () => { + const fakePath = '/rendered/path/serviceClass'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service_class: 'serviceClassValue', + }; + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.serviceClassPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.serviceClassPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('serviceClassPath', () => { + const result = client.serviceClassPath( + 'projectValue', + 'locationValue', + 'serviceClassValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.serviceClassPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceClassName', () => { + const result = client.matchProjectFromServiceClassName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.serviceClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromServiceClassName', () => { + const result = client.matchLocationFromServiceClassName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.serviceClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceClassFromServiceClassName', () => { + const result = client.matchServiceClassFromServiceClassName(fakePath); + assert.strictEqual(result, 'serviceClassValue'); + assert( + (client.pathTemplates.serviceClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('spoke', async () => { - const fakePath = "/rendered/path/spoke"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - spoke: "spokeValue", - }; - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.spokePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.spokePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('spokePath', () => { - const result = client.spokePath("projectValue", "locationValue", "spokeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.spokePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('serviceConnectionMap', async () => { + const fakePath = '/rendered/path/serviceConnectionMap'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service_connection_map: 'serviceConnectionMapValue', + }; + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.serviceConnectionMapPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.serviceConnectionMapPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('serviceConnectionMapPath', () => { + const result = client.serviceConnectionMapPath( + 'projectValue', + 'locationValue', + 'serviceConnectionMapValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.serviceConnectionMapPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceConnectionMapName', () => { + const result = + client.matchProjectFromServiceConnectionMapName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.serviceConnectionMapPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromServiceConnectionMapName', () => { + const result = + client.matchLocationFromServiceConnectionMapName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.serviceConnectionMapPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceConnectionMapFromServiceConnectionMapName', () => { + const result = + client.matchServiceConnectionMapFromServiceConnectionMapName( + fakePath, + ); + assert.strictEqual(result, 'serviceConnectionMapValue'); + assert( + ( + client.pathTemplates.serviceConnectionMapPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromSpokeName', () => { - const result = client.matchProjectFromSpokeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.spokePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('serviceConnectionPolicy', async () => { + const fakePath = '/rendered/path/serviceConnectionPolicy'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service_connection_policy: 'serviceConnectionPolicyValue', + }; + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.serviceConnectionPolicyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.serviceConnectionPolicyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('serviceConnectionPolicyPath', () => { + const result = client.serviceConnectionPolicyPath( + 'projectValue', + 'locationValue', + 'serviceConnectionPolicyValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.serviceConnectionPolicyPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceConnectionPolicyName', () => { + const result = + client.matchProjectFromServiceConnectionPolicyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.serviceConnectionPolicyPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromServiceConnectionPolicyName', () => { + const result = + client.matchLocationFromServiceConnectionPolicyName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.serviceConnectionPolicyPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceConnectionPolicyFromServiceConnectionPolicyName', () => { + const result = + client.matchServiceConnectionPolicyFromServiceConnectionPolicyName( + fakePath, + ); + assert.strictEqual(result, 'serviceConnectionPolicyValue'); + assert( + ( + client.pathTemplates.serviceConnectionPolicyPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchLocationFromSpokeName', () => { - const result = client.matchLocationFromSpokeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.spokePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('serviceConnectionToken', async () => { + const fakePath = '/rendered/path/serviceConnectionToken'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service_connection_token: 'serviceConnectionTokenValue', + }; + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.serviceConnectionTokenPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.serviceConnectionTokenPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('serviceConnectionTokenPath', () => { + const result = client.serviceConnectionTokenPath( + 'projectValue', + 'locationValue', + 'serviceConnectionTokenValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.serviceConnectionTokenPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceConnectionTokenName', () => { + const result = + client.matchProjectFromServiceConnectionTokenName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.serviceConnectionTokenPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromServiceConnectionTokenName', () => { + const result = + client.matchLocationFromServiceConnectionTokenName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.serviceConnectionTokenPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceConnectionTokenFromServiceConnectionTokenName', () => { + const result = + client.matchServiceConnectionTokenFromServiceConnectionTokenName( + fakePath, + ); + assert.strictEqual(result, 'serviceConnectionTokenValue'); + assert( + ( + client.pathTemplates.serviceConnectionTokenPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchSpokeFromSpokeName', () => { - const result = client.matchSpokeFromSpokeName(fakePath); - assert.strictEqual(result, "spokeValue"); - assert((client.pathTemplates.spokePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('spoke', async () => { + const fakePath = '/rendered/path/spoke'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + spoke: 'spokeValue', + }; + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.spokePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.spokePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('spokePath', () => { + const result = client.spokePath( + 'projectValue', + 'locationValue', + 'spokeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.spokePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromSpokeName', () => { + const result = client.matchProjectFromSpokeName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.spokePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromSpokeName', () => { + const result = client.matchLocationFromSpokeName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.spokePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchSpokeFromSpokeName', () => { + const result = client.matchSpokeFromSpokeName(fakePath); + assert.strictEqual(result, 'spokeValue'); + assert( + (client.pathTemplates.spokePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-networkconnectivity/test/gapic_data_transfer_service_v1beta.ts b/packages/google-cloud-networkconnectivity/test/gapic_data_transfer_service_v1beta.ts index 067cd6e9355e..682aa3793e3f 100644 --- a/packages/google-cloud-networkconnectivity/test/gapic_data_transfer_service_v1beta.ts +++ b/packages/google-cloud-networkconnectivity/test/gapic_data_transfer_service_v1beta.ts @@ -19,3548 +19,4892 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as datatransferserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + IamProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1beta.DataTransferServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = datatransferserviceModule.v1beta.DataTransferServiceClient.servicePath; - assert.strictEqual(servicePath, 'networkconnectivity.googleapis.com'); - assert(stub.called); - stub.restore(); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = datatransferserviceModule.v1beta.DataTransferServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new datatransferserviceModule.v1beta.DataTransferServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); + it('has universeDomain', () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + datatransferserviceModule.v1beta.DataTransferServiceClient + .servicePath; + assert.strictEqual(servicePath, 'networkconnectivity.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + datatransferserviceModule.v1beta.DataTransferServiceClient + .apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + universeDomain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkconnectivity.example.com'); + }); - it('has port', () => { - const port = datatransferserviceModule.v1beta.DataTransferServiceClient.port; - assert(port); - assert(typeof port === 'number'); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + universe_domain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkconnectivity.example.com'); + }); - it('should create a client with no option', () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient(); - assert(client); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkconnectivity.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('should create a client with gRPC fallback', () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - fallback: true, - }); - assert(client); + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'networkconnectivity.configured.example.com', + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.dataTransferServiceStub, undefined); - await client.initialize(); - assert(client.dataTransferServiceStub); + it('has port', () => { + const port = + datatransferserviceModule.v1beta.DataTransferServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + fallback: true, }); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.dataTransferServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has initialize method and supports deferred initialization', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.dataTransferServiceStub, undefined); + await client.initialize(); + assert(client.dataTransferServiceStub); + }); - it('has close method for the non-initialized client', done => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.dataTransferServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the initialized client', (done) => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.dataTransferServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; + }); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + it('has close method for the non-initialized client', (done) => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.dataTransferServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); }); - describe('getMulticloudDataTransferConfig', () => { - it('invokes getMulticloudDataTransferConfig without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig() - ); - client.innerApiCalls.getMulticloudDataTransferConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getMulticloudDataTransferConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getMulticloudDataTransferConfig without error using callback', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig() - ); - client.innerApiCalls.getMulticloudDataTransferConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getMulticloudDataTransferConfig( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getMulticloudDataTransferConfig with error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getMulticloudDataTransferConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getMulticloudDataTransferConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.getMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getMulticloudDataTransferConfig with closed client', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferConfigRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getMulticloudDataTransferConfig(request), expectedError); - }); - }); - - describe('getDestination', () => { - it('invokes getDestination without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetDestinationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetDestinationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.Destination() - ); - client.innerApiCalls.getDestination = stubSimpleCall(expectedResponse); - const [response] = await client.getDestination(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDestination as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDestination as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getDestination without error using callback', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetDestinationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetDestinationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.Destination() - ); - client.innerApiCalls.getDestination = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getDestination( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1beta.IDestination|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDestination as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDestination as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getDestination with error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetDestinationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetDestinationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getDestination = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDestination(request), expectedError); - const actualRequest = (client.innerApiCalls.getDestination as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDestination as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getDestination with closed client', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetDestinationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetDestinationRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getDestination(request), expectedError); - }); - }); - - describe('getMulticloudDataTransferSupportedService', () => { - it('invokes getMulticloudDataTransferSupportedService without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferSupportedServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferSupportedServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService() - ); - client.innerApiCalls.getMulticloudDataTransferSupportedService = stubSimpleCall(expectedResponse); - const [response] = await client.getMulticloudDataTransferSupportedService(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMulticloudDataTransferSupportedService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMulticloudDataTransferSupportedService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getMulticloudDataTransferSupportedService without error using callback', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferSupportedServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferSupportedServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService() - ); - client.innerApiCalls.getMulticloudDataTransferSupportedService = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getMulticloudDataTransferSupportedService( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMulticloudDataTransferSupportedService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMulticloudDataTransferSupportedService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getMulticloudDataTransferSupportedService with error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferSupportedServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferSupportedServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getMulticloudDataTransferSupportedService = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getMulticloudDataTransferSupportedService(request), expectedError); - const actualRequest = (client.innerApiCalls.getMulticloudDataTransferSupportedService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMulticloudDataTransferSupportedService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getMulticloudDataTransferSupportedService with closed client', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferSupportedServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferSupportedServiceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getMulticloudDataTransferSupportedService(request), expectedError); - }); - }); - - describe('createMulticloudDataTransferConfig', () => { - it('invokes createMulticloudDataTransferConfig without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.CreateMulticloudDataTransferConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.CreateMulticloudDataTransferConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createMulticloudDataTransferConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.createMulticloudDataTransferConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createMulticloudDataTransferConfig without error using callback', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.CreateMulticloudDataTransferConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.CreateMulticloudDataTransferConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createMulticloudDataTransferConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createMulticloudDataTransferConfig( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createMulticloudDataTransferConfig with call error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.CreateMulticloudDataTransferConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.CreateMulticloudDataTransferConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createMulticloudDataTransferConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createMulticloudDataTransferConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createMulticloudDataTransferConfig with LRO error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.CreateMulticloudDataTransferConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.CreateMulticloudDataTransferConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createMulticloudDataTransferConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createMulticloudDataTransferConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateMulticloudDataTransferConfigProgress without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateMulticloudDataTransferConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateMulticloudDataTransferConfigProgress with error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getMulticloudDataTransferConfig', () => { + it('invokes getMulticloudDataTransferConfig without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig(), + ); + client.innerApiCalls.getMulticloudDataTransferConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.getMulticloudDataTransferConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateMulticloudDataTransferConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); + it('invokes getMulticloudDataTransferConfig without error using callback', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig(), + ); + client.innerApiCalls.getMulticloudDataTransferConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getMulticloudDataTransferConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateMulticloudDataTransferConfig', () => { - it('invokes updateMulticloudDataTransferConfig without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.UpdateMulticloudDataTransferConfigRequest() - ); - request.multicloudDataTransferConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.UpdateMulticloudDataTransferConfigRequest', ['multicloudDataTransferConfig', 'name']); - request.multicloudDataTransferConfig.name = defaultValue1; - const expectedHeaderRequestParams = `multicloud_data_transfer_config.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateMulticloudDataTransferConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateMulticloudDataTransferConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateMulticloudDataTransferConfig without error using callback', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.UpdateMulticloudDataTransferConfigRequest() - ); - request.multicloudDataTransferConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.UpdateMulticloudDataTransferConfigRequest', ['multicloudDataTransferConfig', 'name']); - request.multicloudDataTransferConfig.name = defaultValue1; - const expectedHeaderRequestParams = `multicloud_data_transfer_config.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateMulticloudDataTransferConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateMulticloudDataTransferConfig( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateMulticloudDataTransferConfig with call error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.UpdateMulticloudDataTransferConfigRequest() - ); - request.multicloudDataTransferConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.UpdateMulticloudDataTransferConfigRequest', ['multicloudDataTransferConfig', 'name']); - request.multicloudDataTransferConfig.name = defaultValue1; - const expectedHeaderRequestParams = `multicloud_data_transfer_config.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateMulticloudDataTransferConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateMulticloudDataTransferConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateMulticloudDataTransferConfig with LRO error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.UpdateMulticloudDataTransferConfigRequest() - ); - request.multicloudDataTransferConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.UpdateMulticloudDataTransferConfigRequest', ['multicloudDataTransferConfig', 'name']); - request.multicloudDataTransferConfig.name = defaultValue1; - const expectedHeaderRequestParams = `multicloud_data_transfer_config.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateMulticloudDataTransferConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateMulticloudDataTransferConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateMulticloudDataTransferConfigProgress without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateMulticloudDataTransferConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateMulticloudDataTransferConfigProgress with error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes getMulticloudDataTransferConfig with error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getMulticloudDataTransferConfig = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getMulticloudDataTransferConfig(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.getMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateMulticloudDataTransferConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); + it('invokes getMulticloudDataTransferConfig with closed client', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.getMulticloudDataTransferConfig(request), + expectedError, + ); + }); + }); + + describe('getDestination', () => { + it('invokes getDestination without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetDestinationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetDestinationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Destination(), + ); + client.innerApiCalls.getDestination = stubSimpleCall(expectedResponse); + const [response] = await client.getDestination(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getDestination as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDestination as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteMulticloudDataTransferConfig', () => { - it('invokes deleteMulticloudDataTransferConfig without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.DeleteMulticloudDataTransferConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.DeleteMulticloudDataTransferConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteMulticloudDataTransferConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteMulticloudDataTransferConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteMulticloudDataTransferConfig without error using callback', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.DeleteMulticloudDataTransferConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.DeleteMulticloudDataTransferConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteMulticloudDataTransferConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteMulticloudDataTransferConfig( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteMulticloudDataTransferConfig with call error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.DeleteMulticloudDataTransferConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.DeleteMulticloudDataTransferConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteMulticloudDataTransferConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteMulticloudDataTransferConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteMulticloudDataTransferConfig with LRO error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.DeleteMulticloudDataTransferConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.DeleteMulticloudDataTransferConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteMulticloudDataTransferConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteMulticloudDataTransferConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteMulticloudDataTransferConfigProgress without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteMulticloudDataTransferConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteMulticloudDataTransferConfigProgress with error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes getDestination without error using callback', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetDestinationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetDestinationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Destination(), + ); + client.innerApiCalls.getDestination = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDestination( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1beta.IDestination | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getDestination as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDestination as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteMulticloudDataTransferConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); + it('invokes getDestination with error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetDestinationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetDestinationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getDestination = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getDestination(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getDestination as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDestination as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createDestination', () => { - it('invokes createDestination without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.CreateDestinationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.CreateDestinationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createDestination = stubLongRunningCall(expectedResponse); - const [operation] = await client.createDestination(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createDestination as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDestination as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createDestination without error using callback', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.CreateDestinationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.CreateDestinationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createDestination = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createDestination( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createDestination as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDestination as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createDestination with call error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.CreateDestinationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.CreateDestinationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createDestination = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createDestination(request), expectedError); - const actualRequest = (client.innerApiCalls.createDestination as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDestination as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createDestination with LRO error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.CreateDestinationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.CreateDestinationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createDestination = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createDestination(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createDestination as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDestination as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateDestinationProgress without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateDestinationProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateDestinationProgress with error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes getDestination with closed client', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetDestinationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetDestinationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getDestination(request), expectedError); + }); + }); + + describe('getMulticloudDataTransferSupportedService', () => { + it('invokes getMulticloudDataTransferSupportedService without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferSupportedServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferSupportedServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService(), + ); + client.innerApiCalls.getMulticloudDataTransferSupportedService = + stubSimpleCall(expectedResponse); + const [response] = + await client.getMulticloudDataTransferSupportedService(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls + .getMulticloudDataTransferSupportedService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls + .getMulticloudDataTransferSupportedService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateDestinationProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); + it('invokes getMulticloudDataTransferSupportedService without error using callback', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferSupportedServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferSupportedServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService(), + ); + client.innerApiCalls.getMulticloudDataTransferSupportedService = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getMulticloudDataTransferSupportedService( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls + .getMulticloudDataTransferSupportedService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls + .getMulticloudDataTransferSupportedService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateDestination', () => { - it('invokes updateDestination without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.UpdateDestinationRequest() - ); - request.destination ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.UpdateDestinationRequest', ['destination', 'name']); - request.destination.name = defaultValue1; - const expectedHeaderRequestParams = `destination.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateDestination = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateDestination(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateDestination as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDestination as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateDestination without error using callback', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.UpdateDestinationRequest() - ); - request.destination ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.UpdateDestinationRequest', ['destination', 'name']); - request.destination.name = defaultValue1; - const expectedHeaderRequestParams = `destination.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateDestination = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateDestination( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateDestination as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDestination as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateDestination with call error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.UpdateDestinationRequest() - ); - request.destination ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.UpdateDestinationRequest', ['destination', 'name']); - request.destination.name = defaultValue1; - const expectedHeaderRequestParams = `destination.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateDestination = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateDestination(request), expectedError); - const actualRequest = (client.innerApiCalls.updateDestination as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDestination as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateDestination with LRO error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.UpdateDestinationRequest() - ); - request.destination ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.UpdateDestinationRequest', ['destination', 'name']); - request.destination.name = defaultValue1; - const expectedHeaderRequestParams = `destination.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateDestination = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateDestination(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateDestination as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDestination as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateDestinationProgress without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateDestinationProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateDestinationProgress with error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes getMulticloudDataTransferSupportedService with error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferSupportedServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferSupportedServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getMulticloudDataTransferSupportedService = + stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getMulticloudDataTransferSupportedService(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls + .getMulticloudDataTransferSupportedService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls + .getMulticloudDataTransferSupportedService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateDestinationProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); + it('invokes getMulticloudDataTransferSupportedService with closed client', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferSupportedServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetMulticloudDataTransferSupportedServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.getMulticloudDataTransferSupportedService(request), + expectedError, + ); + }); + }); + + describe('createMulticloudDataTransferConfig', () => { + it('invokes createMulticloudDataTransferConfig without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.CreateMulticloudDataTransferConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.CreateMulticloudDataTransferConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createMulticloudDataTransferConfig = + stubLongRunningCall(expectedResponse); + const [operation] = + await client.createMulticloudDataTransferConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteDestination', () => { - it('invokes deleteDestination without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.DeleteDestinationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.DeleteDestinationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteDestination = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteDestination(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteDestination as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDestination as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteDestination without error using callback', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.DeleteDestinationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.DeleteDestinationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteDestination = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteDestination( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteDestination as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDestination as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteDestination with call error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.DeleteDestinationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.DeleteDestinationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteDestination = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteDestination(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteDestination as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDestination as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteDestination with LRO error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.DeleteDestinationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.DeleteDestinationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteDestination = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteDestination(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteDestination as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDestination as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteDestinationProgress without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteDestinationProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteDestinationProgress with error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes createMulticloudDataTransferConfig without error using callback', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.CreateMulticloudDataTransferConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.CreateMulticloudDataTransferConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createMulticloudDataTransferConfig = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createMulticloudDataTransferConfig( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteDestinationProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); + it('invokes createMulticloudDataTransferConfig with call error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.CreateMulticloudDataTransferConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.CreateMulticloudDataTransferConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createMulticloudDataTransferConfig = + stubLongRunningCall(undefined, expectedError); + await assert.rejects( + client.createMulticloudDataTransferConfig(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listMulticloudDataTransferConfigs', () => { - it('invokes listMulticloudDataTransferConfigs without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig()), - ]; - client.innerApiCalls.listMulticloudDataTransferConfigs = stubSimpleCall(expectedResponse); - const [response] = await client.listMulticloudDataTransferConfigs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMulticloudDataTransferConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMulticloudDataTransferConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listMulticloudDataTransferConfigs without error using callback', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig()), - ]; - client.innerApiCalls.listMulticloudDataTransferConfigs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listMulticloudDataTransferConfigs( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMulticloudDataTransferConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMulticloudDataTransferConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listMulticloudDataTransferConfigs with error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listMulticloudDataTransferConfigs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listMulticloudDataTransferConfigs(request), expectedError); - const actualRequest = (client.innerApiCalls.listMulticloudDataTransferConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMulticloudDataTransferConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listMulticloudDataTransferConfigsStream without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig()), - ]; - client.descriptors.page.listMulticloudDataTransferConfigs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listMulticloudDataTransferConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listMulticloudDataTransferConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMulticloudDataTransferConfigs, request)); - assert( - (client.descriptors.page.listMulticloudDataTransferConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listMulticloudDataTransferConfigsStream with error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMulticloudDataTransferConfigs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listMulticloudDataTransferConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listMulticloudDataTransferConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMulticloudDataTransferConfigs, request)); - assert( - (client.descriptors.page.listMulticloudDataTransferConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listMulticloudDataTransferConfigs without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig()), - ]; - client.descriptors.page.listMulticloudDataTransferConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig[] = []; - const iterable = client.listMulticloudDataTransferConfigsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listMulticloudDataTransferConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMulticloudDataTransferConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listMulticloudDataTransferConfigs with error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMulticloudDataTransferConfigs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listMulticloudDataTransferConfigsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listMulticloudDataTransferConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMulticloudDataTransferConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listDestinations', () => { - it('invokes listDestinations without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListDestinationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListDestinationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Destination()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Destination()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Destination()), - ]; - client.innerApiCalls.listDestinations = stubSimpleCall(expectedResponse); - const [response] = await client.listDestinations(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDestinations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDestinations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDestinations without error using callback', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListDestinationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListDestinationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Destination()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Destination()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Destination()), - ]; - client.innerApiCalls.listDestinations = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listDestinations( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1beta.IDestination[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDestinations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDestinations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDestinations with error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListDestinationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListDestinationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listDestinations = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDestinations(request), expectedError); - const actualRequest = (client.innerApiCalls.listDestinations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDestinations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDestinationsStream without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListDestinationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListDestinationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Destination()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Destination()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Destination()), - ]; - client.descriptors.page.listDestinations.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listDestinationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1beta.Destination[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1beta.Destination) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listDestinations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDestinations, request)); - assert( - (client.descriptors.page.listDestinations.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listDestinationsStream with error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListDestinationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListDestinationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listDestinations.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listDestinationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1beta.Destination[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1beta.Destination) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listDestinations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDestinations, request)); - assert( - (client.descriptors.page.listDestinations.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listDestinations without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListDestinationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListDestinationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Destination()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Destination()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Destination()), - ]; - client.descriptors.page.listDestinations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1beta.IDestination[] = []; - const iterable = client.listDestinationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listDestinations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDestinations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listDestinations with error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListDestinationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListDestinationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listDestinations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listDestinationsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1beta.IDestination[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listDestinations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDestinations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listMulticloudDataTransferSupportedServices', () => { - it('invokes listMulticloudDataTransferSupportedServices without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferSupportedServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferSupportedServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService()), - ]; - client.innerApiCalls.listMulticloudDataTransferSupportedServices = stubSimpleCall(expectedResponse); - const [response] = await client.listMulticloudDataTransferSupportedServices(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMulticloudDataTransferSupportedServices as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMulticloudDataTransferSupportedServices as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listMulticloudDataTransferSupportedServices without error using callback', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferSupportedServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferSupportedServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService()), - ]; - client.innerApiCalls.listMulticloudDataTransferSupportedServices = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listMulticloudDataTransferSupportedServices( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMulticloudDataTransferSupportedServices as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMulticloudDataTransferSupportedServices as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listMulticloudDataTransferSupportedServices with error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferSupportedServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferSupportedServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listMulticloudDataTransferSupportedServices = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listMulticloudDataTransferSupportedServices(request), expectedError); - const actualRequest = (client.innerApiCalls.listMulticloudDataTransferSupportedServices as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMulticloudDataTransferSupportedServices as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listMulticloudDataTransferSupportedServicesStream without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferSupportedServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferSupportedServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService()), - ]; - client.descriptors.page.listMulticloudDataTransferSupportedServices.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listMulticloudDataTransferSupportedServicesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listMulticloudDataTransferSupportedServices.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMulticloudDataTransferSupportedServices, request)); - assert( - (client.descriptors.page.listMulticloudDataTransferSupportedServices.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listMulticloudDataTransferSupportedServicesStream with error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferSupportedServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferSupportedServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMulticloudDataTransferSupportedServices.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listMulticloudDataTransferSupportedServicesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listMulticloudDataTransferSupportedServices.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMulticloudDataTransferSupportedServices, request)); - assert( - (client.descriptors.page.listMulticloudDataTransferSupportedServices.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listMulticloudDataTransferSupportedServices without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferSupportedServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferSupportedServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService()), - ]; - client.descriptors.page.listMulticloudDataTransferSupportedServices.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService[] = []; - const iterable = client.listMulticloudDataTransferSupportedServicesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listMulticloudDataTransferSupportedServices.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMulticloudDataTransferSupportedServices.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listMulticloudDataTransferSupportedServices with error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferSupportedServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferSupportedServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMulticloudDataTransferSupportedServices.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listMulticloudDataTransferSupportedServicesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listMulticloudDataTransferSupportedServices.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMulticloudDataTransferSupportedServices.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes createMulticloudDataTransferConfig with LRO error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.CreateMulticloudDataTransferConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.CreateMulticloudDataTransferConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createMulticloudDataTransferConfig = + stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = + await client.createMulticloudDataTransferConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateMulticloudDataTransferConfigProgress without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateMulticloudDataTransferConfigProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateMulticloudDataTransferConfigProgress with error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateMulticloudDataTransferConfigProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateMulticloudDataTransferConfig', () => { + it('invokes updateMulticloudDataTransferConfig without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.UpdateMulticloudDataTransferConfigRequest(), + ); + request.multicloudDataTransferConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.UpdateMulticloudDataTransferConfigRequest', + ['multicloudDataTransferConfig', 'name'], + ); + request.multicloudDataTransferConfig.name = defaultValue1; + const expectedHeaderRequestParams = `multicloud_data_transfer_config.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateMulticloudDataTransferConfig = + stubLongRunningCall(expectedResponse); + const [operation] = + await client.updateMulticloudDataTransferConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateMulticloudDataTransferConfig without error using callback', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.UpdateMulticloudDataTransferConfigRequest(), + ); + request.multicloudDataTransferConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.UpdateMulticloudDataTransferConfigRequest', + ['multicloudDataTransferConfig', 'name'], + ); + request.multicloudDataTransferConfig.name = defaultValue1; + const expectedHeaderRequestParams = `multicloud_data_transfer_config.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateMulticloudDataTransferConfig = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateMulticloudDataTransferConfig( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateMulticloudDataTransferConfig with call error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.UpdateMulticloudDataTransferConfigRequest(), + ); + request.multicloudDataTransferConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.UpdateMulticloudDataTransferConfigRequest', + ['multicloudDataTransferConfig', 'name'], + ); + request.multicloudDataTransferConfig.name = defaultValue1; + const expectedHeaderRequestParams = `multicloud_data_transfer_config.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateMulticloudDataTransferConfig = + stubLongRunningCall(undefined, expectedError); + await assert.rejects( + client.updateMulticloudDataTransferConfig(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('Path templates', () => { + it('invokes updateMulticloudDataTransferConfig with LRO error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.UpdateMulticloudDataTransferConfigRequest(), + ); + request.multicloudDataTransferConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.UpdateMulticloudDataTransferConfigRequest', + ['multicloudDataTransferConfig', 'name'], + ); + request.multicloudDataTransferConfig.name = defaultValue1; + const expectedHeaderRequestParams = `multicloud_data_transfer_config.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateMulticloudDataTransferConfig = + stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = + await client.updateMulticloudDataTransferConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('destination', async () => { - const fakePath = "/rendered/path/destination"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - multicloud_data_transfer_config: "multicloudDataTransferConfigValue", - destination: "destinationValue", - }; - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.destinationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.destinationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('destinationPath', () => { - const result = client.destinationPath("projectValue", "locationValue", "multicloudDataTransferConfigValue", "destinationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.destinationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes checkUpdateMulticloudDataTransferConfigProgress without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateMulticloudDataTransferConfigProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('matchProjectFromDestinationName', () => { - const result = client.matchProjectFromDestinationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkUpdateMulticloudDataTransferConfigProgress with error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateMulticloudDataTransferConfigProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteMulticloudDataTransferConfig', () => { + it('invokes deleteMulticloudDataTransferConfig without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.DeleteMulticloudDataTransferConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.DeleteMulticloudDataTransferConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteMulticloudDataTransferConfig = + stubLongRunningCall(expectedResponse); + const [operation] = + await client.deleteMulticloudDataTransferConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromDestinationName', () => { - const result = client.matchLocationFromDestinationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes deleteMulticloudDataTransferConfig without error using callback', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.DeleteMulticloudDataTransferConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.DeleteMulticloudDataTransferConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteMulticloudDataTransferConfig = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteMulticloudDataTransferConfig( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchMulticloudDataTransferConfigFromDestinationName', () => { - const result = client.matchMulticloudDataTransferConfigFromDestinationName(fakePath); - assert.strictEqual(result, "multicloudDataTransferConfigValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes deleteMulticloudDataTransferConfig with call error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.DeleteMulticloudDataTransferConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.DeleteMulticloudDataTransferConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteMulticloudDataTransferConfig = + stubLongRunningCall(undefined, expectedError); + await assert.rejects( + client.deleteMulticloudDataTransferConfig(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchDestinationFromDestinationName', () => { - const result = client.matchDestinationFromDestinationName(fakePath); - assert.strictEqual(result, "destinationValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes deleteMulticloudDataTransferConfig with LRO error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.DeleteMulticloudDataTransferConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.DeleteMulticloudDataTransferConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteMulticloudDataTransferConfig = + stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = + await client.deleteMulticloudDataTransferConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMulticloudDataTransferConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('gatewayAdvertisedRoute', async () => { - const fakePath = "/rendered/path/gatewayAdvertisedRoute"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - spoke: "spokeValue", - gateway_advertised_route: "gatewayAdvertisedRouteValue", - }; - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.gatewayAdvertisedRoutePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.gatewayAdvertisedRoutePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('gatewayAdvertisedRoutePath', () => { - const result = client.gatewayAdvertisedRoutePath("projectValue", "locationValue", "spokeValue", "gatewayAdvertisedRouteValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.gatewayAdvertisedRoutePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes checkDeleteMulticloudDataTransferConfigProgress without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteMulticloudDataTransferConfigProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('matchProjectFromGatewayAdvertisedRouteName', () => { - const result = client.matchProjectFromGatewayAdvertisedRouteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.gatewayAdvertisedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkDeleteMulticloudDataTransferConfigProgress with error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteMulticloudDataTransferConfigProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createDestination', () => { + it('invokes createDestination without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.CreateDestinationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.CreateDestinationRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createDestination = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createDestination(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createDestination as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDestination as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromGatewayAdvertisedRouteName', () => { - const result = client.matchLocationFromGatewayAdvertisedRouteName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.gatewayAdvertisedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes createDestination without error using callback', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.CreateDestinationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.CreateDestinationRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createDestination = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createDestination( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1beta.IDestination, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1beta.IDestination, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createDestination as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDestination as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchSpokeFromGatewayAdvertisedRouteName', () => { - const result = client.matchSpokeFromGatewayAdvertisedRouteName(fakePath); - assert.strictEqual(result, "spokeValue"); - assert((client.pathTemplates.gatewayAdvertisedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes createDestination with call error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.CreateDestinationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.CreateDestinationRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createDestination = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createDestination(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createDestination as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDestination as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchGatewayAdvertisedRouteFromGatewayAdvertisedRouteName', () => { - const result = client.matchGatewayAdvertisedRouteFromGatewayAdvertisedRouteName(fakePath); - assert.strictEqual(result, "gatewayAdvertisedRouteValue"); - assert((client.pathTemplates.gatewayAdvertisedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes createDestination with LRO error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.CreateDestinationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.CreateDestinationRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createDestination = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createDestination(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createDestination as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDestination as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('group', async () => { - const fakePath = "/rendered/path/group"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - group: "groupValue", - }; - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.groupPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.groupPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('groupPath', () => { - const result = client.groupPath("projectValue", "hubValue", "groupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.groupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes checkCreateDestinationProgress without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateDestinationProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('matchProjectFromGroupName', () => { - const result = client.matchProjectFromGroupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.groupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkCreateDestinationProgress with error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateDestinationProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateDestination', () => { + it('invokes updateDestination without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.UpdateDestinationRequest(), + ); + request.destination ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.UpdateDestinationRequest', + ['destination', 'name'], + ); + request.destination.name = defaultValue1; + const expectedHeaderRequestParams = `destination.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateDestination = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateDestination(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateDestination as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateDestination as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchHubFromGroupName', () => { - const result = client.matchHubFromGroupName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.groupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes updateDestination without error using callback', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.UpdateDestinationRequest(), + ); + request.destination ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.UpdateDestinationRequest', + ['destination', 'name'], + ); + request.destination.name = defaultValue1; + const expectedHeaderRequestParams = `destination.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateDestination = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateDestination( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1beta.IDestination, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1beta.IDestination, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateDestination as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateDestination as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchGroupFromGroupName', () => { - const result = client.matchGroupFromGroupName(fakePath); - assert.strictEqual(result, "groupValue"); - assert((client.pathTemplates.groupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes updateDestination with call error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.UpdateDestinationRequest(), + ); + request.destination ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.UpdateDestinationRequest', + ['destination', 'name'], + ); + request.destination.name = defaultValue1; + const expectedHeaderRequestParams = `destination.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDestination = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateDestination(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateDestination as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateDestination as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('hub', async () => { - const fakePath = "/rendered/path/hub"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - }; - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.hubPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.hubPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('hubPath', () => { - const result = client.hubPath("projectValue", "hubValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.hubPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes updateDestination with LRO error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.UpdateDestinationRequest(), + ); + request.destination ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.UpdateDestinationRequest', + ['destination', 'name'], + ); + request.destination.name = defaultValue1; + const expectedHeaderRequestParams = `destination.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDestination = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateDestination(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateDestination as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateDestination as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromHubName', () => { - const result = client.matchProjectFromHubName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.hubPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkUpdateDestinationProgress without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateDestinationProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('matchHubFromHubName', () => { - const result = client.matchHubFromHubName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.hubPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkUpdateDestinationProgress with error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateDestinationProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteDestination', () => { + it('invokes deleteDestination without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.DeleteDestinationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.DeleteDestinationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteDestination = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteDestination(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteDestination as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDestination as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('hubRoute', async () => { - const fakePath = "/rendered/path/hubRoute"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - route_table: "routeTableValue", - route: "routeValue", - }; - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.hubRoutePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.hubRoutePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('hubRoutePath', () => { - const result = client.hubRoutePath("projectValue", "hubValue", "routeTableValue", "routeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.hubRoutePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes deleteDestination without error using callback', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.DeleteDestinationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.DeleteDestinationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteDestination = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteDestination( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteDestination as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDestination as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromHubRouteName', () => { - const result = client.matchProjectFromHubRouteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes deleteDestination with call error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.DeleteDestinationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.DeleteDestinationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteDestination = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteDestination(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteDestination as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDestination as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchHubFromHubRouteName', () => { - const result = client.matchHubFromHubRouteName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes deleteDestination with LRO error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.DeleteDestinationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.DeleteDestinationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteDestination = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteDestination(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteDestination as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDestination as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchRouteTableFromHubRouteName', () => { - const result = client.matchRouteTableFromHubRouteName(fakePath); - assert.strictEqual(result, "routeTableValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkDeleteDestinationProgress without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteDestinationProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('matchRouteFromHubRouteName', () => { - const result = client.matchRouteFromHubRouteName(fakePath); - assert.strictEqual(result, "routeValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkDeleteDestinationProgress with error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteDestinationProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listMulticloudDataTransferConfigs', () => { + it('invokes listMulticloudDataTransferConfigs without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig(), + ), + ]; + client.innerApiCalls.listMulticloudDataTransferConfigs = + stubSimpleCall(expectedResponse); + const [response] = + await client.listMulticloudDataTransferConfigs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listMulticloudDataTransferConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMulticloudDataTransferConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes listMulticloudDataTransferConfigs without error using callback', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig(), + ), + ]; + client.innerApiCalls.listMulticloudDataTransferConfigs = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listMulticloudDataTransferConfigs( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listMulticloudDataTransferConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMulticloudDataTransferConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listMulticloudDataTransferConfigs with error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listMulticloudDataTransferConfigs = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listMulticloudDataTransferConfigs(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listMulticloudDataTransferConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMulticloudDataTransferConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listMulticloudDataTransferConfigsStream without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig(), + ), + ]; + client.descriptors.page.listMulticloudDataTransferConfigs.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listMulticloudDataTransferConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listMulticloudDataTransferConfigs + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listMulticloudDataTransferConfigs, + request, + ), + ); + assert( + ( + client.descriptors.page.listMulticloudDataTransferConfigs + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - describe('multicloudDataTransferConfig', async () => { - const fakePath = "/rendered/path/multicloudDataTransferConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - multicloud_data_transfer_config: "multicloudDataTransferConfigValue", - }; - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.multicloudDataTransferConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.multicloudDataTransferConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('multicloudDataTransferConfigPath', () => { - const result = client.multicloudDataTransferConfigPath("projectValue", "locationValue", "multicloudDataTransferConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes listMulticloudDataTransferConfigsStream with error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMulticloudDataTransferConfigs.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listMulticloudDataTransferConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listMulticloudDataTransferConfigs + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listMulticloudDataTransferConfigs, + request, + ), + ); + assert( + ( + client.descriptors.page.listMulticloudDataTransferConfigs + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('matchProjectFromMulticloudDataTransferConfigName', () => { - const result = client.matchProjectFromMulticloudDataTransferConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('uses async iteration with listMulticloudDataTransferConfigs without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferConfig(), + ), + ]; + client.descriptors.page.listMulticloudDataTransferConfigs.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig[] = + []; + const iterable = client.listMulticloudDataTransferConfigsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listMulticloudDataTransferConfigs + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listMulticloudDataTransferConfigs + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('matchLocationFromMulticloudDataTransferConfigName', () => { - const result = client.matchLocationFromMulticloudDataTransferConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('uses async iteration with listMulticloudDataTransferConfigs with error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMulticloudDataTransferConfigs.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listMulticloudDataTransferConfigsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferConfig[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listMulticloudDataTransferConfigs + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listMulticloudDataTransferConfigs + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('listDestinations', () => { + it('invokes listDestinations without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListDestinationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListDestinationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Destination(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Destination(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Destination(), + ), + ]; + client.innerApiCalls.listDestinations = stubSimpleCall(expectedResponse); + const [response] = await client.listDestinations(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDestinations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDestinations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName', () => { - const result = client.matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName(fakePath); - assert.strictEqual(result, "multicloudDataTransferConfigValue"); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listDestinations without error using callback', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListDestinationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListDestinationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Destination(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Destination(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Destination(), + ), + ]; + client.innerApiCalls.listDestinations = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listDestinations( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkconnectivity.v1beta.IDestination[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDestinations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDestinations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('multicloudDataTransferSupportedService', async () => { - const fakePath = "/rendered/path/multicloudDataTransferSupportedService"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - multicloud_data_transfer_supported_service: "multicloudDataTransferSupportedServiceValue", - }; - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('multicloudDataTransferSupportedServicePath', () => { - const result = client.multicloudDataTransferSupportedServicePath("projectValue", "locationValue", "multicloudDataTransferSupportedServiceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes listDestinations with error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListDestinationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListDestinationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listDestinations = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listDestinations(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listDestinations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDestinations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromMulticloudDataTransferSupportedServiceName', () => { - const result = client.matchProjectFromMulticloudDataTransferSupportedServiceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listDestinationsStream without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListDestinationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListDestinationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Destination(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Destination(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Destination(), + ), + ]; + client.descriptors.page.listDestinations.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listDestinationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1beta.Destination[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1beta.Destination, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listDestinations.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listDestinations, request), + ); + assert( + (client.descriptors.page.listDestinations.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('matchLocationFromMulticloudDataTransferSupportedServiceName', () => { - const result = client.matchLocationFromMulticloudDataTransferSupportedServiceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listDestinationsStream with error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListDestinationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListDestinationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDestinations.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listDestinationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1beta.Destination[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1beta.Destination, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listDestinations.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listDestinations, request), + ); + assert( + (client.descriptors.page.listDestinations.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName', () => { - const result = client.matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName(fakePath); - assert.strictEqual(result, "multicloudDataTransferSupportedServiceValue"); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('uses async iteration with listDestinations without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListDestinationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListDestinationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Destination(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Destination(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Destination(), + ), + ]; + client.descriptors.page.listDestinations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1beta.IDestination[] = + []; + const iterable = client.listDestinationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listDestinations.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listDestinations.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - describe('policyBasedRoute', async () => { - const fakePath = "/rendered/path/policyBasedRoute"; - const expectedParameters = { - project: "projectValue", - policy_based_route: "policyBasedRouteValue", - }; - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.policyBasedRoutePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.policyBasedRoutePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('policyBasedRoutePath', () => { - const result = client.policyBasedRoutePath("projectValue", "policyBasedRouteValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.policyBasedRoutePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('uses async iteration with listDestinations with error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListDestinationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListDestinationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDestinations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listDestinationsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1beta.IDestination[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listDestinations.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listDestinations.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listMulticloudDataTransferSupportedServices', () => { + it('invokes listMulticloudDataTransferSupportedServices without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferSupportedServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferSupportedServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService(), + ), + ]; + client.innerApiCalls.listMulticloudDataTransferSupportedServices = + stubSimpleCall(expectedResponse); + const [response] = + await client.listMulticloudDataTransferSupportedServices(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls + .listMulticloudDataTransferSupportedServices as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls + .listMulticloudDataTransferSupportedServices as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromPolicyBasedRouteName', () => { - const result = client.matchProjectFromPolicyBasedRouteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listMulticloudDataTransferSupportedServices without error using callback', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferSupportedServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferSupportedServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService(), + ), + ]; + client.innerApiCalls.listMulticloudDataTransferSupportedServices = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listMulticloudDataTransferSupportedServices( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls + .listMulticloudDataTransferSupportedServices as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls + .listMulticloudDataTransferSupportedServices as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchPolicyBasedRouteFromPolicyBasedRouteName', () => { - const result = client.matchPolicyBasedRouteFromPolicyBasedRouteName(fakePath); - assert.strictEqual(result, "policyBasedRouteValue"); - assert((client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listMulticloudDataTransferSupportedServices with error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferSupportedServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferSupportedServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listMulticloudDataTransferSupportedServices = + stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.listMulticloudDataTransferSupportedServices(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls + .listMulticloudDataTransferSupportedServices as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls + .listMulticloudDataTransferSupportedServices as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('remoteTransportProfile', async () => { - const fakePath = "/rendered/path/remoteTransportProfile"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - remote_transport_profile: "remoteTransportProfileValue", - }; - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.remoteTransportProfilePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.remoteTransportProfilePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('remoteTransportProfilePath', () => { - const result = client.remoteTransportProfilePath("projectValue", "locationValue", "remoteTransportProfileValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.remoteTransportProfilePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes listMulticloudDataTransferSupportedServicesStream without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferSupportedServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferSupportedServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService(), + ), + ]; + client.descriptors.page.listMulticloudDataTransferSupportedServices.createStream = + stubPageStreamingCall(expectedResponse); + const stream = + client.listMulticloudDataTransferSupportedServicesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listMulticloudDataTransferSupportedServices + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listMulticloudDataTransferSupportedServices, + request, + ), + ); + assert( + ( + client.descriptors.page.listMulticloudDataTransferSupportedServices + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('matchProjectFromRemoteTransportProfileName', () => { - const result = client.matchProjectFromRemoteTransportProfileName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.remoteTransportProfilePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listMulticloudDataTransferSupportedServicesStream with error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferSupportedServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferSupportedServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMulticloudDataTransferSupportedServices.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = + client.listMulticloudDataTransferSupportedServicesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listMulticloudDataTransferSupportedServices + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listMulticloudDataTransferSupportedServices, + request, + ), + ); + assert( + ( + client.descriptors.page.listMulticloudDataTransferSupportedServices + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('matchLocationFromRemoteTransportProfileName', () => { - const result = client.matchLocationFromRemoteTransportProfileName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.remoteTransportProfilePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('uses async iteration with listMulticloudDataTransferSupportedServices without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferSupportedServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferSupportedServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.MulticloudDataTransferSupportedService(), + ), + ]; + client.descriptors.page.listMulticloudDataTransferSupportedServices.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService[] = + []; + const iterable = + client.listMulticloudDataTransferSupportedServicesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listMulticloudDataTransferSupportedServices + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listMulticloudDataTransferSupportedServices + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('matchRemoteTransportProfileFromRemoteTransportProfileName', () => { - const result = client.matchRemoteTransportProfileFromRemoteTransportProfileName(fakePath); - assert.strictEqual(result, "remoteTransportProfileValue"); - assert((client.pathTemplates.remoteTransportProfilePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('uses async iteration with listMulticloudDataTransferSupportedServices with error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferSupportedServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListMulticloudDataTransferSupportedServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMulticloudDataTransferSupportedServices.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = + client.listMulticloudDataTransferSupportedServicesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1beta.IMulticloudDataTransferSupportedService[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listMulticloudDataTransferSupportedServices + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listMulticloudDataTransferSupportedServices + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getIamPolicy without error using callback', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); + }); + it('invokes getIamPolicy with error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes setIamPolicy without error using callback', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); + }); + it('invokes setIamPolicy with error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes testIamPermissions without error using callback', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); + }); + it('invokes testIamPermissions with error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('destination', async () => { + const fakePath = '/rendered/path/destination'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + multicloud_data_transfer_config: 'multicloudDataTransferConfigValue', + destination: 'destinationValue', + }; + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.destinationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.destinationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('destinationPath', () => { + const result = client.destinationPath( + 'projectValue', + 'locationValue', + 'multicloudDataTransferConfigValue', + 'destinationValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.destinationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromDestinationName', () => { + const result = client.matchProjectFromDestinationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromDestinationName', () => { + const result = client.matchLocationFromDestinationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMulticloudDataTransferConfigFromDestinationName', () => { + const result = + client.matchMulticloudDataTransferConfigFromDestinationName(fakePath); + assert.strictEqual(result, 'multicloudDataTransferConfigValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchDestinationFromDestinationName', () => { + const result = client.matchDestinationFromDestinationName(fakePath); + assert.strictEqual(result, 'destinationValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('routeTable', async () => { - const fakePath = "/rendered/path/routeTable"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - route_table: "routeTableValue", - }; - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.routeTablePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.routeTablePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('routeTablePath', () => { - const result = client.routeTablePath("projectValue", "hubValue", "routeTableValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.routeTablePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('gatewayAdvertisedRoute', async () => { + const fakePath = '/rendered/path/gatewayAdvertisedRoute'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + spoke: 'spokeValue', + gateway_advertised_route: 'gatewayAdvertisedRouteValue', + }; + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.gatewayAdvertisedRoutePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.gatewayAdvertisedRoutePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('gatewayAdvertisedRoutePath', () => { + const result = client.gatewayAdvertisedRoutePath( + 'projectValue', + 'locationValue', + 'spokeValue', + 'gatewayAdvertisedRouteValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.gatewayAdvertisedRoutePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromGatewayAdvertisedRouteName', () => { + const result = + client.matchProjectFromGatewayAdvertisedRouteName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.gatewayAdvertisedRoutePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromGatewayAdvertisedRouteName', () => { + const result = + client.matchLocationFromGatewayAdvertisedRouteName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.gatewayAdvertisedRoutePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchSpokeFromGatewayAdvertisedRouteName', () => { + const result = + client.matchSpokeFromGatewayAdvertisedRouteName(fakePath); + assert.strictEqual(result, 'spokeValue'); + assert( + ( + client.pathTemplates.gatewayAdvertisedRoutePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchGatewayAdvertisedRouteFromGatewayAdvertisedRouteName', () => { + const result = + client.matchGatewayAdvertisedRouteFromGatewayAdvertisedRouteName( + fakePath, + ); + assert.strictEqual(result, 'gatewayAdvertisedRouteValue'); + assert( + ( + client.pathTemplates.gatewayAdvertisedRoutePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromRouteTableName', () => { - const result = client.matchProjectFromRouteTableName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.routeTablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('group', async () => { + const fakePath = '/rendered/path/group'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + group: 'groupValue', + }; + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.groupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.groupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('groupPath', () => { + const result = client.groupPath( + 'projectValue', + 'hubValue', + 'groupValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.groupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromGroupName', () => { + const result = client.matchProjectFromGroupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.groupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromGroupName', () => { + const result = client.matchHubFromGroupName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.groupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchGroupFromGroupName', () => { + const result = client.matchGroupFromGroupName(fakePath); + assert.strictEqual(result, 'groupValue'); + assert( + (client.pathTemplates.groupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchHubFromRouteTableName', () => { - const result = client.matchHubFromRouteTableName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.routeTablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('hub', async () => { + const fakePath = '/rendered/path/hub'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + }; + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.hubPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.hubPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('hubPath', () => { + const result = client.hubPath('projectValue', 'hubValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.hubPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromHubName', () => { + const result = client.matchProjectFromHubName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.hubPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromHubName', () => { + const result = client.matchHubFromHubName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.hubPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchRouteTableFromRouteTableName', () => { - const result = client.matchRouteTableFromRouteTableName(fakePath); - assert.strictEqual(result, "routeTableValue"); - assert((client.pathTemplates.routeTablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('hubRoute', async () => { + const fakePath = '/rendered/path/hubRoute'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + route_table: 'routeTableValue', + route: 'routeValue', + }; + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + client.pathTemplates.hubRoutePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.hubRoutePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('hubRoutePath', () => { + const result = client.hubRoutePath( + 'projectValue', + 'hubValue', + 'routeTableValue', + 'routeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.hubRoutePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromHubRouteName', () => { + const result = client.matchProjectFromHubRouteName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromHubRouteName', () => { + const result = client.matchHubFromHubRouteName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRouteTableFromHubRouteName', () => { + const result = client.matchRouteTableFromHubRouteName(fakePath); + assert.strictEqual(result, 'routeTableValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRouteFromHubRouteName', () => { + const result = client.matchRouteFromHubRouteName(fakePath); + assert.strictEqual(result, 'routeValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('spoke', async () => { - const fakePath = "/rendered/path/spoke"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - spoke: "spokeValue", - }; - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.spokePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.spokePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('spokePath', () => { - const result = client.spokePath("projectValue", "locationValue", "spokeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.spokePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromSpokeName', () => { - const result = client.matchProjectFromSpokeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.spokePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('multicloudDataTransferConfig', async () => { + const fakePath = '/rendered/path/multicloudDataTransferConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + multicloud_data_transfer_config: 'multicloudDataTransferConfigValue', + }; + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.multicloudDataTransferConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.multicloudDataTransferConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('multicloudDataTransferConfigPath', () => { + const result = client.multicloudDataTransferConfigPath( + 'projectValue', + 'locationValue', + 'multicloudDataTransferConfigValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMulticloudDataTransferConfigName', () => { + const result = + client.matchProjectFromMulticloudDataTransferConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMulticloudDataTransferConfigName', () => { + const result = + client.matchLocationFromMulticloudDataTransferConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName', () => { + const result = + client.matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName( + fakePath, + ); + assert.strictEqual(result, 'multicloudDataTransferConfigValue'); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchLocationFromSpokeName', () => { - const result = client.matchLocationFromSpokeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.spokePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('multicloudDataTransferSupportedService', async () => { + const fakePath = '/rendered/path/multicloudDataTransferSupportedService'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + multicloud_data_transfer_supported_service: + 'multicloudDataTransferSupportedServiceValue', + }; + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('multicloudDataTransferSupportedServicePath', () => { + const result = client.multicloudDataTransferSupportedServicePath( + 'projectValue', + 'locationValue', + 'multicloudDataTransferSupportedServiceValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMulticloudDataTransferSupportedServiceName', () => { + const result = + client.matchProjectFromMulticloudDataTransferSupportedServiceName( + fakePath, + ); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMulticloudDataTransferSupportedServiceName', () => { + const result = + client.matchLocationFromMulticloudDataTransferSupportedServiceName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName', () => { + const result = + client.matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName( + fakePath, + ); + assert.strictEqual( + result, + 'multicloudDataTransferSupportedServiceValue', + ); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchSpokeFromSpokeName', () => { - const result = client.matchSpokeFromSpokeName(fakePath); - assert.strictEqual(result, "spokeValue"); - assert((client.pathTemplates.spokePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('policyBasedRoute', async () => { + const fakePath = '/rendered/path/policyBasedRoute'; + const expectedParameters = { + project: 'projectValue', + policy_based_route: 'policyBasedRouteValue', + }; + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + client.pathTemplates.policyBasedRoutePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.policyBasedRoutePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('policyBasedRoutePath', () => { + const result = client.policyBasedRoutePath( + 'projectValue', + 'policyBasedRouteValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.policyBasedRoutePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromPolicyBasedRouteName', () => { + const result = client.matchProjectFromPolicyBasedRouteName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchPolicyBasedRouteFromPolicyBasedRouteName', () => { + const result = + client.matchPolicyBasedRouteFromPolicyBasedRouteName(fakePath); + assert.strictEqual(result, 'policyBasedRouteValue'); + assert( + (client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('transport', async () => { - const fakePath = "/rendered/path/transport"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - transport: "transportValue", - }; - const client = new datatransferserviceModule.v1beta.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.transportPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.transportPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('transportPath', () => { - const result = client.transportPath("projectValue", "locationValue", "transportValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.transportPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('remoteTransportProfile', async () => { + const fakePath = '/rendered/path/remoteTransportProfile'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + remote_transport_profile: 'remoteTransportProfileValue', + }; + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.remoteTransportProfilePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.remoteTransportProfilePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('remoteTransportProfilePath', () => { + const result = client.remoteTransportProfilePath( + 'projectValue', + 'locationValue', + 'remoteTransportProfileValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.remoteTransportProfilePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromRemoteTransportProfileName', () => { + const result = + client.matchProjectFromRemoteTransportProfileName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.remoteTransportProfilePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromRemoteTransportProfileName', () => { + const result = + client.matchLocationFromRemoteTransportProfileName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.remoteTransportProfilePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRemoteTransportProfileFromRemoteTransportProfileName', () => { + const result = + client.matchRemoteTransportProfileFromRemoteTransportProfileName( + fakePath, + ); + assert.strictEqual(result, 'remoteTransportProfileValue'); + assert( + ( + client.pathTemplates.remoteTransportProfilePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromTransportName', () => { - const result = client.matchProjectFromTransportName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.transportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('routeTable', async () => { + const fakePath = '/rendered/path/routeTable'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + route_table: 'routeTableValue', + }; + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.routeTablePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.routeTablePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('routeTablePath', () => { + const result = client.routeTablePath( + 'projectValue', + 'hubValue', + 'routeTableValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.routeTablePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromRouteTableName', () => { + const result = client.matchProjectFromRouteTableName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.routeTablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromRouteTableName', () => { + const result = client.matchHubFromRouteTableName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.routeTablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRouteTableFromRouteTableName', () => { + const result = client.matchRouteTableFromRouteTableName(fakePath); + assert.strictEqual(result, 'routeTableValue'); + assert( + (client.pathTemplates.routeTablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchLocationFromTransportName', () => { - const result = client.matchLocationFromTransportName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.transportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('spoke', async () => { + const fakePath = '/rendered/path/spoke'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + spoke: 'spokeValue', + }; + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.spokePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.spokePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('spokePath', () => { + const result = client.spokePath( + 'projectValue', + 'locationValue', + 'spokeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.spokePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromSpokeName', () => { + const result = client.matchProjectFromSpokeName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.spokePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromSpokeName', () => { + const result = client.matchLocationFromSpokeName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.spokePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchSpokeFromSpokeName', () => { + const result = client.matchSpokeFromSpokeName(fakePath); + assert.strictEqual(result, 'spokeValue'); + assert( + (client.pathTemplates.spokePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchTransportFromTransportName', () => { - const result = client.matchTransportFromTransportName(fakePath); - assert.strictEqual(result, "transportValue"); - assert((client.pathTemplates.transportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('transport', async () => { + const fakePath = '/rendered/path/transport'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + transport: 'transportValue', + }; + const client = + new datatransferserviceModule.v1beta.DataTransferServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + client.pathTemplates.transportPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.transportPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('transportPath', () => { + const result = client.transportPath( + 'projectValue', + 'locationValue', + 'transportValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.transportPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromTransportName', () => { + const result = client.matchProjectFromTransportName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.transportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromTransportName', () => { + const result = client.matchLocationFromTransportName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.transportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTransportFromTransportName', () => { + const result = client.matchTransportFromTransportName(fakePath); + assert.strictEqual(result, 'transportValue'); + assert( + (client.pathTemplates.transportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-networkconnectivity/test/gapic_hub_service_v1.ts b/packages/google-cloud-networkconnectivity/test/gapic_hub_service_v1.ts index e89108cbd2bb..f9007e9ac55d 100644 --- a/packages/google-cloud-networkconnectivity/test/gapic_hub_service_v1.ts +++ b/packages/google-cloud-networkconnectivity/test/gapic_hub_service_v1.ts @@ -19,5778 +19,7567 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as hubserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + IamProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1.HubServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new hubserviceModule.v1.HubServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new hubserviceModule.v1.HubServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = hubserviceModule.v1.HubServiceClient.servicePath; - assert.strictEqual(servicePath, 'networkconnectivity.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = hubserviceModule.v1.HubServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new hubserviceModule.v1.HubServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new hubserviceModule.v1.HubServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new hubserviceModule.v1.HubServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new hubserviceModule.v1.HubServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new hubserviceModule.v1.HubServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = hubserviceModule.v1.HubServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new hubserviceModule.v1.HubServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new hubserviceModule.v1.HubServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.hubServiceStub, undefined); - await client.initialize(); - assert(client.hubServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.hubServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has close method for the non-initialized client', done => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.hubServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new hubserviceModule.v1.HubServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); }); - describe('getHub', () => { - it('invokes getHub without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetHubRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.Hub() - ); - client.innerApiCalls.getHub = stubSimpleCall(expectedResponse); - const [response] = await client.getHub(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getHub without error using callback', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetHubRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.Hub() - ); - client.innerApiCalls.getHub = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getHub( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1.IHub|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getHub with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetHubRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getHub = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getHub(request), expectedError); - const actualRequest = (client.innerApiCalls.getHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getHub with closed client', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetHubRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getHub(request), expectedError); - }); + it('has universeDomain', () => { + const client = new hubserviceModule.v1.HubServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); }); - describe('getSpoke', () => { - it('invokes getSpoke without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.Spoke() - ); - client.innerApiCalls.getSpoke = stubSimpleCall(expectedResponse); - const [response] = await client.getSpoke(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = hubserviceModule.v1.HubServiceClient.servicePath; + assert.strictEqual(servicePath, 'networkconnectivity.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = hubserviceModule.v1.HubServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new hubserviceModule.v1.HubServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkconnectivity.example.com'); + }); - it('invokes getSpoke without error using callback', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.Spoke() - ); - client.innerApiCalls.getSpoke = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getSpoke( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1.ISpoke|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new hubserviceModule.v1.HubServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkconnectivity.example.com'); + }); - it('invokes getSpoke with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getSpoke = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getSpoke(request), expectedError); - const actualRequest = (client.innerApiCalls.getSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new hubserviceModule.v1.HubServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkconnectivity.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new hubserviceModule.v1.HubServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'networkconnectivity.configured.example.com', + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new hubserviceModule.v1.HubServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('invokes getSpoke with closed client', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getSpoke(request), expectedError); - }); + it('has port', () => { + const port = hubserviceModule.v1.HubServiceClient.port; + assert(port); + assert(typeof port === 'number'); }); - describe('getRouteTable', () => { - it('invokes getRouteTable without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetRouteTableRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetRouteTableRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.RouteTable() - ); - client.innerApiCalls.getRouteTable = stubSimpleCall(expectedResponse); - const [response] = await client.getRouteTable(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRouteTable as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRouteTable as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('should create a client with no option', () => { + const client = new hubserviceModule.v1.HubServiceClient(); + assert(client); + }); - it('invokes getRouteTable without error using callback', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetRouteTableRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetRouteTableRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.RouteTable() - ); - client.innerApiCalls.getRouteTable = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getRouteTable( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1.IRouteTable|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRouteTable as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRouteTable as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('should create a client with gRPC fallback', () => { + const client = new hubserviceModule.v1.HubServiceClient({ + fallback: true, + }); + assert(client); + }); - it('invokes getRouteTable with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetRouteTableRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetRouteTableRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getRouteTable = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getRouteTable(request), expectedError); - const actualRequest = (client.innerApiCalls.getRouteTable as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRouteTable as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.hubServiceStub, undefined); + await client.initialize(); + assert(client.hubServiceStub); + }); - it('invokes getRouteTable with closed client', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetRouteTableRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetRouteTableRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getRouteTable(request), expectedError); + it('has close method for the initialized client', (done) => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.hubServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('getRoute', () => { - it('invokes getRoute without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.Route() - ); - client.innerApiCalls.getRoute = stubSimpleCall(expectedResponse); - const [response] = await client.getRoute(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the non-initialized client', (done) => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.hubServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getRoute without error using callback', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.Route() - ); - client.innerApiCalls.getRoute = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getRoute( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1.IRoute|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('invokes getRoute with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getRoute = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getRoute(request), expectedError); - const actualRequest = (client.innerApiCalls.getRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getHub', () => { + it('invokes getHub without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetHubRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Hub(), + ); + client.innerApiCalls.getHub = stubSimpleCall(expectedResponse); + const [response] = await client.getHub(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getHub as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getRoute with closed client', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetRouteRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getRoute(request), expectedError); - }); + it('invokes getHub without error using callback', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetHubRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Hub(), + ); + client.innerApiCalls.getHub = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getHub( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1.IHub | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getHub as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getGroup', () => { - it('invokes getGroup without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetGroupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.Group() - ); - client.innerApiCalls.getGroup = stubSimpleCall(expectedResponse); - const [response] = await client.getGroup(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getHub with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetHubRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getHub = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getHub(request), expectedError); + const actualRequest = (client.innerApiCalls.getHub as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getGroup without error using callback', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetGroupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.Group() - ); - client.innerApiCalls.getGroup = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getGroup( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1.IGroup|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getHub with closed client', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetHubRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getHub(request), expectedError); + }); + }); + + describe('getSpoke', () => { + it('invokes getSpoke without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Spoke(), + ); + client.innerApiCalls.getSpoke = stubSimpleCall(expectedResponse); + const [response] = await client.getSpoke(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getGroup with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetGroupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getGroup = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getGroup(request), expectedError); - const actualRequest = (client.innerApiCalls.getGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getSpoke without error using callback', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Spoke(), + ); + client.innerApiCalls.getSpoke = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getSpoke( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1.ISpoke | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getGroup with closed client', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetGroupRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getGroup(request), expectedError); - }); + it('invokes getSpoke with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getSpoke = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getSpoke(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createHub', () => { - it('invokes createHub without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateHubRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createHub = stubLongRunningCall(expectedResponse); - const [operation] = await client.createHub(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getSpoke with closed client', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getSpoke(request), expectedError); + }); + }); + + describe('getRouteTable', () => { + it('invokes getRouteTable without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetRouteTableRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetRouteTableRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.RouteTable(), + ); + client.innerApiCalls.getRouteTable = stubSimpleCall(expectedResponse); + const [response] = await client.getRouteTable(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getRouteTable as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getRouteTable as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createHub without error using callback', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateHubRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createHub = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createHub( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getRouteTable without error using callback', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetRouteTableRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetRouteTableRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.RouteTable(), + ); + client.innerApiCalls.getRouteTable = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getRouteTable( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1.IRouteTable | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getRouteTable as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getRouteTable as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createHub with call error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateHubRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createHub = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createHub(request), expectedError); - const actualRequest = (client.innerApiCalls.createHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getRouteTable with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetRouteTableRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetRouteTableRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getRouteTable = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getRouteTable(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getRouteTable as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getRouteTable as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createHub with LRO error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateHubRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createHub = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createHub(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getRouteTable with closed client', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetRouteTableRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetRouteTableRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getRouteTable(request), expectedError); + }); + }); + + describe('getRoute', () => { + it('invokes getRoute without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Route(), + ); + client.innerApiCalls.getRoute = stubSimpleCall(expectedResponse); + const [response] = await client.getRoute(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateHubProgress without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateHubProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes getRoute without error using callback', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Route(), + ); + client.innerApiCalls.getRoute = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getRoute( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1.IRoute | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateHubProgress with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateHubProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes getRoute with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getRoute = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getRoute(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateHub', () => { - it('invokes updateHub without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateHubRequest() - ); - request.hub ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateHubRequest', ['hub', 'name']); - request.hub.name = defaultValue1; - const expectedHeaderRequestParams = `hub.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateHub = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateHub(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getRoute with closed client', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getRoute(request), expectedError); + }); + }); + + describe('getGroup', () => { + it('invokes getGroup without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Group(), + ); + client.innerApiCalls.getGroup = stubSimpleCall(expectedResponse); + const [response] = await client.getGroup(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateHub without error using callback', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateHubRequest() - ); - request.hub ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateHubRequest', ['hub', 'name']); - request.hub.name = defaultValue1; - const expectedHeaderRequestParams = `hub.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateHub = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateHub( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getGroup without error using callback', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Group(), + ); + client.innerApiCalls.getGroup = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getGroup( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1.IGroup | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateHub with call error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateHubRequest() - ); - request.hub ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateHubRequest', ['hub', 'name']); - request.hub.name = defaultValue1; - const expectedHeaderRequestParams = `hub.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateHub = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateHub(request), expectedError); - const actualRequest = (client.innerApiCalls.updateHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getGroup with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getGroup = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getGroup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateHub with LRO error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateHubRequest() - ); - request.hub ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateHubRequest', ['hub', 'name']); - request.hub.name = defaultValue1; - const expectedHeaderRequestParams = `hub.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateHub = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateHub(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getGroup with closed client', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getGroup(request), expectedError); + }); + }); + + describe('createHub', () => { + it('invokes createHub without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateHubRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createHub = stubLongRunningCall(expectedResponse); + const [operation] = await client.createHub(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateHubProgress without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateHubProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createHub without error using callback', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateHubRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createHub = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createHub( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1.IHub, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1.IHub, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateHubProgress with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateHubProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createHub with call error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateHubRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createHub = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createHub(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteHub', () => { - it('invokes deleteHub without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteHubRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteHub = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteHub(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createHub with LRO error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateHubRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createHub = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createHub(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteHub without error using callback', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteHubRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteHub = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteHub( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateHubProgress without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateHubProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteHub with call error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteHubRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteHub = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteHub(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateHubProgress with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkCreateHubProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateHub', () => { + it('invokes updateHub without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateHubRequest(), + ); + request.hub ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateHubRequest', + ['hub', 'name'], + ); + request.hub.name = defaultValue1; + const expectedHeaderRequestParams = `hub.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateHub = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateHub(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteHub with LRO error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteHubRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteHub = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteHub(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateHub without error using callback', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateHubRequest(), + ); + request.hub ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateHubRequest', + ['hub', 'name'], + ); + request.hub.name = defaultValue1; + const expectedHeaderRequestParams = `hub.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateHub = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateHub( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1.IHub, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1.IHub, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteHubProgress without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteHubProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateHub with call error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateHubRequest(), + ); + request.hub ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateHubRequest', + ['hub', 'name'], + ); + request.hub.name = defaultValue1; + const expectedHeaderRequestParams = `hub.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateHub = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateHub(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteHubProgress with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteHubProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateHub with LRO error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateHubRequest(), + ); + request.hub ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateHubRequest', + ['hub', 'name'], + ); + request.hub.name = defaultValue1; + const expectedHeaderRequestParams = `hub.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateHub = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateHub(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createSpoke', () => { - it('invokes createSpoke without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateSpokeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createSpoke = stubLongRunningCall(expectedResponse); - const [operation] = await client.createSpoke(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateHubProgress without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateHubProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createSpoke without error using callback', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateSpokeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createSpoke = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createSpoke( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateHubProgress with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkUpdateHubProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteHub', () => { + it('invokes deleteHub without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteHubRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteHub = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteHub(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createSpoke with call error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateSpokeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createSpoke = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createSpoke(request), expectedError); - const actualRequest = (client.innerApiCalls.createSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteHub without error using callback', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteHubRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteHub = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteHub( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createSpoke with LRO error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateSpokeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createSpoke = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createSpoke(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteHub with call error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteHubRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteHub = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteHub(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateSpokeProgress without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateSpokeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteHub with LRO error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteHubRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteHub = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteHub(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateSpokeProgress with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateSpokeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteHubProgress without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteHubProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('updateSpoke', () => { - it('invokes updateSpoke without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateSpokeRequest() - ); - request.spoke ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateSpokeRequest', ['spoke', 'name']); - request.spoke.name = defaultValue1; - const expectedHeaderRequestParams = `spoke.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateSpoke = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateSpoke(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteHubProgress with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkDeleteHubProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createSpoke', () => { + it('invokes createSpoke without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateSpokeRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createSpoke = stubLongRunningCall(expectedResponse); + const [operation] = await client.createSpoke(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateSpoke without error using callback', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateSpokeRequest() - ); - request.spoke ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateSpokeRequest', ['spoke', 'name']); - request.spoke.name = defaultValue1; - const expectedHeaderRequestParams = `spoke.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateSpoke = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateSpoke( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createSpoke without error using callback', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateSpokeRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createSpoke = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createSpoke( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1.ISpoke, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1.ISpoke, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateSpoke with call error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateSpokeRequest() - ); - request.spoke ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateSpokeRequest', ['spoke', 'name']); - request.spoke.name = defaultValue1; - const expectedHeaderRequestParams = `spoke.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateSpoke = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateSpoke(request), expectedError); - const actualRequest = (client.innerApiCalls.updateSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createSpoke with call error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateSpokeRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createSpoke = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createSpoke(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateSpoke with LRO error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateSpokeRequest() - ); - request.spoke ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateSpokeRequest', ['spoke', 'name']); - request.spoke.name = defaultValue1; - const expectedHeaderRequestParams = `spoke.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateSpoke = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateSpoke(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createSpoke with LRO error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateSpokeRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createSpoke = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createSpoke(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateSpokeProgress without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateSpokeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkCreateSpokeProgress without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateSpokeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkUpdateSpokeProgress with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateSpokeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateSpokeProgress with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkCreateSpokeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateSpoke', () => { + it('invokes updateSpoke without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateSpokeRequest(), + ); + request.spoke ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateSpokeRequest', + ['spoke', 'name'], + ); + request.spoke.name = defaultValue1; + const expectedHeaderRequestParams = `spoke.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateSpoke = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateSpoke(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('rejectHubSpoke', () => { - it('invokes rejectHubSpoke without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.RejectHubSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.RejectHubSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.rejectHubSpoke = stubLongRunningCall(expectedResponse); - const [operation] = await client.rejectHubSpoke(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rejectHubSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rejectHubSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateSpoke without error using callback', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateSpokeRequest(), + ); + request.spoke ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateSpokeRequest', + ['spoke', 'name'], + ); + request.spoke.name = defaultValue1; + const expectedHeaderRequestParams = `spoke.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateSpoke = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateSpoke( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1.ISpoke, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1.ISpoke, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes rejectHubSpoke without error using callback', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.RejectHubSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.RejectHubSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.rejectHubSpoke = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rejectHubSpoke( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rejectHubSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rejectHubSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateSpoke with call error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateSpokeRequest(), + ); + request.spoke ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateSpokeRequest', + ['spoke', 'name'], + ); + request.spoke.name = defaultValue1; + const expectedHeaderRequestParams = `spoke.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateSpoke = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateSpoke(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes rejectHubSpoke with call error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.RejectHubSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.RejectHubSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rejectHubSpoke = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.rejectHubSpoke(request), expectedError); - const actualRequest = (client.innerApiCalls.rejectHubSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rejectHubSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateSpoke with LRO error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateSpokeRequest(), + ); + request.spoke ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateSpokeRequest', + ['spoke', 'name'], + ); + request.spoke.name = defaultValue1; + const expectedHeaderRequestParams = `spoke.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateSpoke = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateSpoke(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes rejectHubSpoke with LRO error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.RejectHubSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.RejectHubSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rejectHubSpoke = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.rejectHubSpoke(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.rejectHubSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rejectHubSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateSpokeProgress without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateSpokeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkRejectHubSpokeProgress without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkRejectHubSpokeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateSpokeProgress with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkUpdateSpokeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('rejectHubSpoke', () => { + it('invokes rejectHubSpoke without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.RejectHubSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.RejectHubSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.rejectHubSpoke = + stubLongRunningCall(expectedResponse); + const [operation] = await client.rejectHubSpoke(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rejectHubSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rejectHubSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRejectHubSpokeProgress with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRejectHubSpokeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes rejectHubSpoke without error using callback', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.RejectHubSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.RejectHubSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.rejectHubSpoke = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rejectHubSpoke( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1.IRejectHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1.IRejectHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rejectHubSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rejectHubSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('acceptHubSpoke', () => { - it('invokes acceptHubSpoke without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.AcceptHubSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.AcceptHubSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.acceptHubSpoke = stubLongRunningCall(expectedResponse); - const [operation] = await client.acceptHubSpoke(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.acceptHubSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.acceptHubSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes rejectHubSpoke with call error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.RejectHubSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.RejectHubSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rejectHubSpoke = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.rejectHubSpoke(request), expectedError); + const actualRequest = ( + client.innerApiCalls.rejectHubSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rejectHubSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes acceptHubSpoke without error using callback', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.AcceptHubSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.AcceptHubSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.acceptHubSpoke = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.acceptHubSpoke( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.acceptHubSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.acceptHubSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes rejectHubSpoke with LRO error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.RejectHubSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.RejectHubSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rejectHubSpoke = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.rejectHubSpoke(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.rejectHubSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rejectHubSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes acceptHubSpoke with call error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.AcceptHubSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.AcceptHubSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.acceptHubSpoke = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.acceptHubSpoke(request), expectedError); - const actualRequest = (client.innerApiCalls.acceptHubSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.acceptHubSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRejectHubSpokeProgress without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkRejectHubSpokeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes acceptHubSpoke with LRO error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.AcceptHubSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.AcceptHubSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.acceptHubSpoke = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.acceptHubSpoke(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.acceptHubSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.acceptHubSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRejectHubSpokeProgress with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkRejectHubSpokeProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('acceptHubSpoke', () => { + it('invokes acceptHubSpoke without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.AcceptHubSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.AcceptHubSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.acceptHubSpoke = + stubLongRunningCall(expectedResponse); + const [operation] = await client.acceptHubSpoke(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.acceptHubSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.acceptHubSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkAcceptHubSpokeProgress without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkAcceptHubSpokeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes acceptHubSpoke without error using callback', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.AcceptHubSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.AcceptHubSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.acceptHubSpoke = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.acceptHubSpoke( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1.IAcceptHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1.IAcceptHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.acceptHubSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.acceptHubSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkAcceptHubSpokeProgress with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkAcceptHubSpokeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes acceptHubSpoke with call error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.AcceptHubSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.AcceptHubSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.acceptHubSpoke = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.acceptHubSpoke(request), expectedError); + const actualRequest = ( + client.innerApiCalls.acceptHubSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.acceptHubSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('acceptSpokeUpdate', () => { - it('invokes acceptSpokeUpdate without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.AcceptSpokeUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.AcceptSpokeUpdateRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.acceptSpokeUpdate = stubLongRunningCall(expectedResponse); - const [operation] = await client.acceptSpokeUpdate(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.acceptSpokeUpdate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.acceptSpokeUpdate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes acceptHubSpoke with LRO error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.AcceptHubSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.AcceptHubSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.acceptHubSpoke = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.acceptHubSpoke(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.acceptHubSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.acceptHubSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes acceptSpokeUpdate without error using callback', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.AcceptSpokeUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.AcceptSpokeUpdateRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.acceptSpokeUpdate = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.acceptSpokeUpdate( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.acceptSpokeUpdate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.acceptSpokeUpdate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkAcceptHubSpokeProgress without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkAcceptHubSpokeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes acceptSpokeUpdate with call error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.AcceptSpokeUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.AcceptSpokeUpdateRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.acceptSpokeUpdate = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.acceptSpokeUpdate(request), expectedError); - const actualRequest = (client.innerApiCalls.acceptSpokeUpdate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.acceptSpokeUpdate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkAcceptHubSpokeProgress with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkAcceptHubSpokeProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('acceptSpokeUpdate', () => { + it('invokes acceptSpokeUpdate without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.AcceptSpokeUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.AcceptSpokeUpdateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.acceptSpokeUpdate = + stubLongRunningCall(expectedResponse); + const [operation] = await client.acceptSpokeUpdate(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.acceptSpokeUpdate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.acceptSpokeUpdate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes acceptSpokeUpdate with LRO error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.AcceptSpokeUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.AcceptSpokeUpdateRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.acceptSpokeUpdate = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.acceptSpokeUpdate(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.acceptSpokeUpdate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.acceptSpokeUpdate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes acceptSpokeUpdate without error using callback', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.AcceptSpokeUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.AcceptSpokeUpdateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.acceptSpokeUpdate = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.acceptSpokeUpdate( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1.IAcceptSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1.IAcceptSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.acceptSpokeUpdate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.acceptSpokeUpdate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkAcceptSpokeUpdateProgress without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkAcceptSpokeUpdateProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes acceptSpokeUpdate with call error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.AcceptSpokeUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.AcceptSpokeUpdateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.acceptSpokeUpdate = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.acceptSpokeUpdate(request), expectedError); + const actualRequest = ( + client.innerApiCalls.acceptSpokeUpdate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.acceptSpokeUpdate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkAcceptSpokeUpdateProgress with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkAcceptSpokeUpdateProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes acceptSpokeUpdate with LRO error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.AcceptSpokeUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.AcceptSpokeUpdateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.acceptSpokeUpdate = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.acceptSpokeUpdate(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.acceptSpokeUpdate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.acceptSpokeUpdate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('rejectSpokeUpdate', () => { - it('invokes rejectSpokeUpdate without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.RejectSpokeUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.RejectSpokeUpdateRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.rejectSpokeUpdate = stubLongRunningCall(expectedResponse); - const [operation] = await client.rejectSpokeUpdate(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rejectSpokeUpdate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rejectSpokeUpdate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkAcceptSpokeUpdateProgress without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkAcceptSpokeUpdateProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes rejectSpokeUpdate without error using callback', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.RejectSpokeUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.RejectSpokeUpdateRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.rejectSpokeUpdate = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rejectSpokeUpdate( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rejectSpokeUpdate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rejectSpokeUpdate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkAcceptSpokeUpdateProgress with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkAcceptSpokeUpdateProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('rejectSpokeUpdate', () => { + it('invokes rejectSpokeUpdate without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.RejectSpokeUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.RejectSpokeUpdateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.rejectSpokeUpdate = + stubLongRunningCall(expectedResponse); + const [operation] = await client.rejectSpokeUpdate(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rejectSpokeUpdate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rejectSpokeUpdate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes rejectSpokeUpdate with call error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.RejectSpokeUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.RejectSpokeUpdateRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rejectSpokeUpdate = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.rejectSpokeUpdate(request), expectedError); - const actualRequest = (client.innerApiCalls.rejectSpokeUpdate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rejectSpokeUpdate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes rejectSpokeUpdate without error using callback', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.RejectSpokeUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.RejectSpokeUpdateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.rejectSpokeUpdate = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rejectSpokeUpdate( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1.IRejectSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1.IRejectSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rejectSpokeUpdate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rejectSpokeUpdate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes rejectSpokeUpdate with LRO error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.RejectSpokeUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.RejectSpokeUpdateRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rejectSpokeUpdate = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.rejectSpokeUpdate(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.rejectSpokeUpdate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rejectSpokeUpdate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes rejectSpokeUpdate with call error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.RejectSpokeUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.RejectSpokeUpdateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rejectSpokeUpdate = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.rejectSpokeUpdate(request), expectedError); + const actualRequest = ( + client.innerApiCalls.rejectSpokeUpdate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rejectSpokeUpdate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRejectSpokeUpdateProgress without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkRejectSpokeUpdateProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes rejectSpokeUpdate with LRO error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.RejectSpokeUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.RejectSpokeUpdateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rejectSpokeUpdate = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.rejectSpokeUpdate(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.rejectSpokeUpdate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rejectSpokeUpdate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRejectSpokeUpdateProgress with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRejectSpokeUpdateProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkRejectSpokeUpdateProgress without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkRejectSpokeUpdateProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('deleteSpoke', () => { - it('invokes deleteSpoke without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteSpoke = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteSpoke(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRejectSpokeUpdateProgress with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkRejectSpokeUpdateProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteSpoke', () => { + it('invokes deleteSpoke without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteSpoke = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteSpoke(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteSpoke without error using callback', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteSpoke = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteSpoke( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteSpoke without error using callback', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteSpoke = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteSpoke( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteSpoke with call error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteSpoke = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteSpoke(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteSpoke with call error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteSpoke = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteSpoke(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteSpoke with LRO error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteSpoke = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteSpoke(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteSpoke with LRO error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteSpoke = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteSpoke(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteSpokeProgress without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteSpokeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkDeleteSpokeProgress without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteSpokeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteSpokeProgress with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteSpokeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteSpokeProgress with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkDeleteSpokeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateGroup', () => { + it('invokes updateGroup without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateGroupRequest(), + ); + request.group ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateGroupRequest', + ['group', 'name'], + ); + request.group.name = defaultValue1; + const expectedHeaderRequestParams = `group.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateGroup = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateGroup(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateGroup', () => { - it('invokes updateGroup without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateGroupRequest() - ); - request.group ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateGroupRequest', ['group', 'name']); - request.group.name = defaultValue1; - const expectedHeaderRequestParams = `group.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateGroup = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateGroup(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateGroup without error using callback', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateGroupRequest(), + ); + request.group ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateGroupRequest', + ['group', 'name'], + ); + request.group.name = defaultValue1; + const expectedHeaderRequestParams = `group.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateGroup = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateGroup( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1.IGroup, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1.IGroup, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateGroup without error using callback', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateGroupRequest() - ); - request.group ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateGroupRequest', ['group', 'name']); - request.group.name = defaultValue1; - const expectedHeaderRequestParams = `group.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateGroup = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateGroup( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateGroup with call error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateGroupRequest(), + ); + request.group ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateGroupRequest', + ['group', 'name'], + ); + request.group.name = defaultValue1; + const expectedHeaderRequestParams = `group.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateGroup = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateGroup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateGroup with call error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateGroupRequest() - ); - request.group ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateGroupRequest', ['group', 'name']); - request.group.name = defaultValue1; - const expectedHeaderRequestParams = `group.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateGroup = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateGroup(request), expectedError); - const actualRequest = (client.innerApiCalls.updateGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateGroup with LRO error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateGroupRequest(), + ); + request.group ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateGroupRequest', + ['group', 'name'], + ); + request.group.name = defaultValue1; + const expectedHeaderRequestParams = `group.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateGroup = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateGroup(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateGroup with LRO error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateGroupRequest() - ); - request.group ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateGroupRequest', ['group', 'name']); - request.group.name = defaultValue1; - const expectedHeaderRequestParams = `group.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateGroup = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateGroup(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateGroupProgress without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateGroupProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkUpdateGroupProgress without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateGroupProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateGroupProgress with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkUpdateGroupProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listHubs', () => { + it('invokes listHubs without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListHubsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListHubsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Hub(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Hub(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Hub(), + ), + ]; + client.innerApiCalls.listHubs = stubSimpleCall(expectedResponse); + const [response] = await client.listHubs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listHubs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listHubs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateGroupProgress with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateGroupProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes listHubs without error using callback', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListHubsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListHubsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Hub(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Hub(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Hub(), + ), + ]; + client.innerApiCalls.listHubs = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listHubs( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1.IHub[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listHubs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listHubs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listHubs', () => { - it('invokes listHubs without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListHubsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListHubsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Hub()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Hub()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Hub()), - ]; - client.innerApiCalls.listHubs = stubSimpleCall(expectedResponse); - const [response] = await client.listHubs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listHubs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listHubs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listHubs with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListHubsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListHubsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listHubs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listHubs(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listHubs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listHubs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listHubs without error using callback', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListHubsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListHubsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Hub()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Hub()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Hub()), - ]; - client.innerApiCalls.listHubs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listHubs( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1.IHub[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listHubs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listHubs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listHubsStream without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListHubsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListHubsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Hub(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Hub(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Hub(), + ), + ]; + client.descriptors.page.listHubs.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listHubsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.Hub[] = []; + stream.on( + 'data', + (response: protos.google.cloud.networkconnectivity.v1.Hub) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listHubs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listHubs, request), + ); + assert( + (client.descriptors.page.listHubs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listHubs with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListHubsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListHubsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listHubs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listHubs(request), expectedError); - const actualRequest = (client.innerApiCalls.listHubs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listHubs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listHubsStream with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListHubsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListHubsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listHubs.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listHubsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.Hub[] = []; + stream.on( + 'data', + (response: protos.google.cloud.networkconnectivity.v1.Hub) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listHubs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listHubs, request), + ); + assert( + (client.descriptors.page.listHubs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listHubsStream without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListHubsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListHubsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Hub()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Hub()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Hub()), - ]; - client.descriptors.page.listHubs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listHubsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.Hub[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.Hub) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listHubs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listHubs, request)); - assert( - (client.descriptors.page.listHubs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listHubs without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListHubsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListHubsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Hub(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Hub(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Hub(), + ), + ]; + client.descriptors.page.listHubs.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1.IHub[] = []; + const iterable = client.listHubsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listHubs.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.listHubs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listHubsStream with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListHubsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListHubsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listHubs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listHubsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.Hub[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.Hub) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listHubs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listHubs, request)); - assert( - (client.descriptors.page.listHubs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listHubs with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListHubsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListHubsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listHubs.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listHubsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1.IHub[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listHubs.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.listHubs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listHubSpokes', () => { + it('invokes listHubSpokes without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListHubSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListHubSpokesRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Spoke(), + ), + ]; + client.innerApiCalls.listHubSpokes = stubSimpleCall(expectedResponse); + const [response] = await client.listHubSpokes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listHubSpokes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listHubSpokes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listHubs without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListHubsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListHubsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Hub()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Hub()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Hub()), - ]; - client.descriptors.page.listHubs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1.IHub[] = []; - const iterable = client.listHubsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listHubSpokes without error using callback', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListHubSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListHubSpokesRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Spoke(), + ), + ]; + client.innerApiCalls.listHubSpokes = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listHubSpokes( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1.ISpoke[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listHubs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listHubs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listHubs with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListHubsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListHubsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listHubs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listHubsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1.IHub[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listHubs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listHubs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listHubSpokes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listHubSpokes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listHubSpokes', () => { - it('invokes listHubSpokes without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListHubSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListHubSpokesRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Spoke()), - ]; - client.innerApiCalls.listHubSpokes = stubSimpleCall(expectedResponse); - const [response] = await client.listHubSpokes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listHubSpokes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listHubSpokes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listHubSpokes with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListHubSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListHubSpokesRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listHubSpokes = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listHubSpokes(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listHubSpokes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listHubSpokes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listHubSpokes without error using callback', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListHubSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListHubSpokesRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Spoke()), - ]; - client.innerApiCalls.listHubSpokes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listHubSpokes( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1.ISpoke[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listHubSpokes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listHubSpokes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listHubSpokesStream without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListHubSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListHubSpokesRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Spoke(), + ), + ]; + client.descriptors.page.listHubSpokes.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listHubSpokesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.Spoke[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkconnectivity.v1.Spoke) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listHubSpokes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listHubSpokes, request), + ); + assert( + (client.descriptors.page.listHubSpokes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listHubSpokes with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListHubSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListHubSpokesRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listHubSpokes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listHubSpokes(request), expectedError); - const actualRequest = (client.innerApiCalls.listHubSpokes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listHubSpokes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listHubSpokesStream with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListHubSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListHubSpokesRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listHubSpokes.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listHubSpokesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.Spoke[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkconnectivity.v1.Spoke) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listHubSpokes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listHubSpokes, request), + ); + assert( + (client.descriptors.page.listHubSpokes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listHubSpokesStream without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListHubSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListHubSpokesRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Spoke()), - ]; - client.descriptors.page.listHubSpokes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listHubSpokesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.Spoke[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.Spoke) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listHubSpokes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listHubSpokes, request)); - assert( - (client.descriptors.page.listHubSpokes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listHubSpokes without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListHubSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListHubSpokesRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Spoke(), + ), + ]; + client.descriptors.page.listHubSpokes.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1.ISpoke[] = []; + const iterable = client.listHubSpokesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listHubSpokes.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listHubSpokes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listHubSpokesStream with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListHubSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListHubSpokesRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listHubSpokes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listHubSpokesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.Spoke[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.Spoke) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listHubSpokes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listHubSpokes, request)); - assert( - (client.descriptors.page.listHubSpokes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listHubSpokes with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListHubSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListHubSpokesRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listHubSpokes.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listHubSpokesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1.ISpoke[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listHubSpokes.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listHubSpokes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('queryHubStatus', () => { + it('invokes queryHubStatus without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.QueryHubStatusRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.QueryHubStatusRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.HubStatusEntry(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.HubStatusEntry(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.HubStatusEntry(), + ), + ]; + client.innerApiCalls.queryHubStatus = stubSimpleCall(expectedResponse); + const [response] = await client.queryHubStatus(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.queryHubStatus as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryHubStatus as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listHubSpokes without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListHubSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListHubSpokesRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Spoke()), - ]; - client.descriptors.page.listHubSpokes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1.ISpoke[] = []; - const iterable = client.listHubSpokesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes queryHubStatus without error using callback', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.QueryHubStatusRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.QueryHubStatusRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.HubStatusEntry(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.HubStatusEntry(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.HubStatusEntry(), + ), + ]; + client.innerApiCalls.queryHubStatus = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.queryHubStatus( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkconnectivity.v1.IHubStatusEntry[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listHubSpokes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listHubSpokes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listHubSpokes with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListHubSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListHubSpokesRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listHubSpokes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listHubSpokesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1.ISpoke[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listHubSpokes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listHubSpokes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.queryHubStatus as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryHubStatus as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('queryHubStatus', () => { - it('invokes queryHubStatus without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.QueryHubStatusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.QueryHubStatusRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.HubStatusEntry()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.HubStatusEntry()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.HubStatusEntry()), - ]; - client.innerApiCalls.queryHubStatus = stubSimpleCall(expectedResponse); - const [response] = await client.queryHubStatus(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.queryHubStatus as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.queryHubStatus as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes queryHubStatus with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.QueryHubStatusRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.QueryHubStatusRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.queryHubStatus = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.queryHubStatus(request), expectedError); + const actualRequest = ( + client.innerApiCalls.queryHubStatus as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryHubStatus as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes queryHubStatus without error using callback', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.QueryHubStatusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.QueryHubStatusRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.HubStatusEntry()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.HubStatusEntry()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.HubStatusEntry()), - ]; - client.innerApiCalls.queryHubStatus = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.queryHubStatus( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1.IHubStatusEntry[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.queryHubStatus as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.queryHubStatus as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes queryHubStatusStream without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.QueryHubStatusRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.QueryHubStatusRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.HubStatusEntry(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.HubStatusEntry(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.HubStatusEntry(), + ), + ]; + client.descriptors.page.queryHubStatus.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.queryHubStatusStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.HubStatusEntry[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1.HubStatusEntry, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.queryHubStatus.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.queryHubStatus, request), + ); + assert( + (client.descriptors.page.queryHubStatus.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes queryHubStatus with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.QueryHubStatusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.QueryHubStatusRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.queryHubStatus = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.queryHubStatus(request), expectedError); - const actualRequest = (client.innerApiCalls.queryHubStatus as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.queryHubStatus as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes queryHubStatusStream with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.QueryHubStatusRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.QueryHubStatusRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.queryHubStatus.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.queryHubStatusStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.HubStatusEntry[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1.HubStatusEntry, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.queryHubStatus.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.queryHubStatus, request), + ); + assert( + (client.descriptors.page.queryHubStatus.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes queryHubStatusStream without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.QueryHubStatusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.QueryHubStatusRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.HubStatusEntry()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.HubStatusEntry()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.HubStatusEntry()), - ]; - client.descriptors.page.queryHubStatus.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.queryHubStatusStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.HubStatusEntry[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.HubStatusEntry) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.queryHubStatus.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.queryHubStatus, request)); - assert( - (client.descriptors.page.queryHubStatus.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with queryHubStatus without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.QueryHubStatusRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.QueryHubStatusRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.HubStatusEntry(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.HubStatusEntry(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.HubStatusEntry(), + ), + ]; + client.descriptors.page.queryHubStatus.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1.IHubStatusEntry[] = + []; + const iterable = client.queryHubStatusAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.queryHubStatus.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.queryHubStatus.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes queryHubStatusStream with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.QueryHubStatusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.QueryHubStatusRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.queryHubStatus.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.queryHubStatusStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.HubStatusEntry[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.HubStatusEntry) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.queryHubStatus.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.queryHubStatus, request)); - assert( - (client.descriptors.page.queryHubStatus.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with queryHubStatus with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.QueryHubStatusRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.QueryHubStatusRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.queryHubStatus.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.queryHubStatusAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1.IHubStatusEntry[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.queryHubStatus.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.queryHubStatus.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listSpokes', () => { + it('invokes listSpokes without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListSpokesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Spoke(), + ), + ]; + client.innerApiCalls.listSpokes = stubSimpleCall(expectedResponse); + const [response] = await client.listSpokes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listSpokes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSpokes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with queryHubStatus without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.QueryHubStatusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.QueryHubStatusRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.HubStatusEntry()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.HubStatusEntry()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.HubStatusEntry()), - ]; - client.descriptors.page.queryHubStatus.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1.IHubStatusEntry[] = []; - const iterable = client.queryHubStatusAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listSpokes without error using callback', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListSpokesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Spoke(), + ), + ]; + client.innerApiCalls.listSpokes = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listSpokes( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1.ISpoke[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.queryHubStatus.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.queryHubStatus.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with queryHubStatus with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.QueryHubStatusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.QueryHubStatusRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.queryHubStatus.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.queryHubStatusAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1.IHubStatusEntry[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.queryHubStatus.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.queryHubStatus.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listSpokes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSpokes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listSpokes', () => { - it('invokes listSpokes without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListSpokesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Spoke()), - ]; - client.innerApiCalls.listSpokes = stubSimpleCall(expectedResponse); - const [response] = await client.listSpokes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSpokes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSpokes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listSpokes with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListSpokesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listSpokes = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listSpokes(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listSpokes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSpokes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listSpokes without error using callback', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListSpokesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Spoke()), - ]; - client.innerApiCalls.listSpokes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listSpokes( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1.ISpoke[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSpokes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSpokes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listSpokesStream without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListSpokesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Spoke(), + ), + ]; + client.descriptors.page.listSpokes.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listSpokesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.Spoke[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkconnectivity.v1.Spoke) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listSpokes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listSpokes, request), + ); + assert( + (client.descriptors.page.listSpokes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listSpokes with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListSpokesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listSpokes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listSpokes(request), expectedError); - const actualRequest = (client.innerApiCalls.listSpokes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSpokes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listSpokesStream with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListSpokesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSpokes.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listSpokesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.Spoke[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkconnectivity.v1.Spoke) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listSpokes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listSpokes, request), + ); + assert( + (client.descriptors.page.listSpokes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listSpokesStream without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListSpokesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Spoke()), - ]; - client.descriptors.page.listSpokes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listSpokesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.Spoke[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.Spoke) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listSpokes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSpokes, request)); - assert( - (client.descriptors.page.listSpokes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listSpokes without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListSpokesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Spoke(), + ), + ]; + client.descriptors.page.listSpokes.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1.ISpoke[] = []; + const iterable = client.listSpokesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listSpokes.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listSpokes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listSpokesStream with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListSpokesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listSpokes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listSpokesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.Spoke[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.Spoke) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listSpokes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSpokes, request)); - assert( - (client.descriptors.page.listSpokes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listSpokes with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListSpokesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSpokes.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listSpokesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1.ISpoke[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listSpokes.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listSpokes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listRoutes', () => { + it('invokes listRoutes without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Route(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Route(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Route(), + ), + ]; + client.innerApiCalls.listRoutes = stubSimpleCall(expectedResponse); + const [response] = await client.listRoutes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listRoutes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listRoutes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listSpokes without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListSpokesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Spoke()), - ]; - client.descriptors.page.listSpokes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1.ISpoke[] = []; - const iterable = client.listSpokesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listRoutes without error using callback', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Route(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Route(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Route(), + ), + ]; + client.innerApiCalls.listRoutes = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listRoutes( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1.IRoute[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listSpokes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSpokes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listSpokes with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListSpokesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listSpokes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listSpokesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1.ISpoke[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listSpokes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSpokes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listRoutes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listRoutes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listRoutes', () => { - it('invokes listRoutes without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Route()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Route()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Route()), - ]; - client.innerApiCalls.listRoutes = stubSimpleCall(expectedResponse); - const [response] = await client.listRoutes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRoutes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRoutes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listRoutes with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listRoutes = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listRoutes(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listRoutes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listRoutes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listRoutes without error using callback', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Route()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Route()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Route()), - ]; - client.innerApiCalls.listRoutes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listRoutes( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1.IRoute[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRoutes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRoutes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listRoutesStream without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Route(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Route(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Route(), + ), + ]; + client.descriptors.page.listRoutes.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listRoutesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.Route[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkconnectivity.v1.Route) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listRoutes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listRoutes, request), + ); + assert( + (client.descriptors.page.listRoutes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listRoutes with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listRoutes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listRoutes(request), expectedError); - const actualRequest = (client.innerApiCalls.listRoutes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRoutes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listRoutesStream with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRoutes.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listRoutesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.Route[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkconnectivity.v1.Route) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listRoutes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listRoutes, request), + ); + assert( + (client.descriptors.page.listRoutes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listRoutesStream without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Route()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Route()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Route()), - ]; - client.descriptors.page.listRoutes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listRoutesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.Route[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.Route) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listRoutes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRoutes, request)); - assert( - (client.descriptors.page.listRoutes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listRoutes without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Route(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Route(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Route(), + ), + ]; + client.descriptors.page.listRoutes.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1.IRoute[] = []; + const iterable = client.listRoutesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listRoutes.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listRoutes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listRoutesStream with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listRoutes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listRoutesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.Route[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.Route) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listRoutes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRoutes, request)); - assert( - (client.descriptors.page.listRoutes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listRoutes with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRoutes.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listRoutesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1.IRoute[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listRoutes.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listRoutes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listRouteTables', () => { + it('invokes listRouteTables without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListRouteTablesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListRouteTablesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.RouteTable(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.RouteTable(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.RouteTable(), + ), + ]; + client.innerApiCalls.listRouteTables = stubSimpleCall(expectedResponse); + const [response] = await client.listRouteTables(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listRouteTables as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listRouteTables as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listRoutes without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Route()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Route()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Route()), - ]; - client.descriptors.page.listRoutes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1.IRoute[] = []; - const iterable = client.listRoutesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listRouteTables without error using callback', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListRouteTablesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListRouteTablesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.RouteTable(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.RouteTable(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.RouteTable(), + ), + ]; + client.innerApiCalls.listRouteTables = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listRouteTables( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkconnectivity.v1.IRouteTable[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listRoutes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRoutes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listRoutes with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listRoutes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listRoutesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1.IRoute[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listRoutes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRoutes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listRouteTables as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listRouteTables as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listRouteTables', () => { - it('invokes listRouteTables without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListRouteTablesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListRouteTablesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.RouteTable()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.RouteTable()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.RouteTable()), - ]; - client.innerApiCalls.listRouteTables = stubSimpleCall(expectedResponse); - const [response] = await client.listRouteTables(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRouteTables as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRouteTables as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listRouteTables with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListRouteTablesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListRouteTablesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listRouteTables = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listRouteTables(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listRouteTables as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listRouteTables as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listRouteTables without error using callback', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListRouteTablesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListRouteTablesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.RouteTable()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.RouteTable()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.RouteTable()), - ]; - client.innerApiCalls.listRouteTables = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listRouteTables( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1.IRouteTable[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRouteTables as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRouteTables as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listRouteTablesStream without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListRouteTablesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListRouteTablesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.RouteTable(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.RouteTable(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.RouteTable(), + ), + ]; + client.descriptors.page.listRouteTables.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listRouteTablesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.RouteTable[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkconnectivity.v1.RouteTable) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listRouteTables.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listRouteTables, request), + ); + assert( + (client.descriptors.page.listRouteTables.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listRouteTables with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListRouteTablesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListRouteTablesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listRouteTables = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listRouteTables(request), expectedError); - const actualRequest = (client.innerApiCalls.listRouteTables as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRouteTables as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listRouteTablesStream with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListRouteTablesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListRouteTablesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRouteTables.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listRouteTablesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.RouteTable[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkconnectivity.v1.RouteTable) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listRouteTables.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listRouteTables, request), + ); + assert( + (client.descriptors.page.listRouteTables.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listRouteTablesStream without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListRouteTablesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListRouteTablesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.RouteTable()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.RouteTable()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.RouteTable()), - ]; - client.descriptors.page.listRouteTables.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listRouteTablesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.RouteTable[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.RouteTable) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listRouteTables.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRouteTables, request)); - assert( - (client.descriptors.page.listRouteTables.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listRouteTables without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListRouteTablesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListRouteTablesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.RouteTable(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.RouteTable(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.RouteTable(), + ), + ]; + client.descriptors.page.listRouteTables.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1.IRouteTable[] = + []; + const iterable = client.listRouteTablesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listRouteTables.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listRouteTables.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listRouteTablesStream with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListRouteTablesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListRouteTablesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listRouteTables.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listRouteTablesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.RouteTable[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.RouteTable) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listRouteTables.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRouteTables, request)); - assert( - (client.descriptors.page.listRouteTables.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listRouteTables with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListRouteTablesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListRouteTablesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRouteTables.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listRouteTablesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1.IRouteTable[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listRouteTables.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listRouteTables.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listGroups', () => { + it('invokes listGroups without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Group(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Group(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Group(), + ), + ]; + client.innerApiCalls.listGroups = stubSimpleCall(expectedResponse); + const [response] = await client.listGroups(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listGroups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listGroups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listRouteTables without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListRouteTablesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListRouteTablesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.RouteTable()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.RouteTable()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.RouteTable()), - ]; - client.descriptors.page.listRouteTables.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1.IRouteTable[] = []; - const iterable = client.listRouteTablesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listGroups without error using callback', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Group(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Group(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Group(), + ), + ]; + client.innerApiCalls.listGroups = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listGroups( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1.IGroup[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listRouteTables.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRouteTables.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listRouteTables with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListRouteTablesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListRouteTablesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listRouteTables.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listRouteTablesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1.IRouteTable[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listRouteTables.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRouteTables.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listGroups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listGroups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listGroups', () => { - it('invokes listGroups without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Group()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Group()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Group()), - ]; - client.innerApiCalls.listGroups = stubSimpleCall(expectedResponse); - const [response] = await client.listGroups(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listGroups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listGroups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listGroups without error using callback', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Group()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Group()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Group()), - ]; - client.innerApiCalls.listGroups = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listGroups( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1.IGroup[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listGroups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listGroups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listGroups with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listGroups = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listGroups(request), expectedError); - const actualRequest = (client.innerApiCalls.listGroups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listGroups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listGroups with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listGroups = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listGroups(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listGroups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listGroups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listGroupsStream without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Group()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Group()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Group()), - ]; - client.descriptors.page.listGroups.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listGroupsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.Group[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.Group) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listGroups.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listGroups, request)); - assert( - (client.descriptors.page.listGroups.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listGroupsStream without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Group(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Group(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Group(), + ), + ]; + client.descriptors.page.listGroups.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listGroupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.Group[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkconnectivity.v1.Group) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listGroups.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listGroups, request), + ); + assert( + (client.descriptors.page.listGroups.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listGroupsStream with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listGroups.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listGroupsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.Group[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.Group) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listGroups.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listGroups, request)); - assert( - (client.descriptors.page.listGroups.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listGroupsStream with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listGroups.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listGroupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.Group[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkconnectivity.v1.Group) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listGroups.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listGroups, request), + ); + assert( + (client.descriptors.page.listGroups.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listGroups without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Group()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Group()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.Group()), - ]; - client.descriptors.page.listGroups.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1.IGroup[] = []; - const iterable = client.listGroupsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listGroups.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listGroups.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listGroups without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Group(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Group(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.Group(), + ), + ]; + client.descriptors.page.listGroups.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1.IGroup[] = []; + const iterable = client.listGroupsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listGroups.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listGroups.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listGroups with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listGroups.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listGroupsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1.IGroup[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listGroups.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listGroups.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listGroups with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listGroups.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listGroupsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1.IGroup[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listGroups.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listGroups.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy without error using callback', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes setIamPolicy with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); + }); + it('invokes testIamPermissions with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('destination', async () => { + const fakePath = '/rendered/path/destination'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + multicloud_data_transfer_config: 'multicloudDataTransferConfigValue', + destination: 'destinationValue', + }; + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.destinationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.destinationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('destinationPath', () => { + const result = client.destinationPath( + 'projectValue', + 'locationValue', + 'multicloudDataTransferConfigValue', + 'destinationValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.destinationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromDestinationName', () => { + const result = client.matchProjectFromDestinationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromDestinationName', () => { + const result = client.matchLocationFromDestinationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMulticloudDataTransferConfigFromDestinationName', () => { + const result = + client.matchMulticloudDataTransferConfigFromDestinationName(fakePath); + assert.strictEqual(result, 'multicloudDataTransferConfigValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchDestinationFromDestinationName', () => { + const result = client.matchDestinationFromDestinationName(fakePath); + assert.strictEqual(result, 'destinationValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('destination', async () => { - const fakePath = "/rendered/path/destination"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - multicloud_data_transfer_config: "multicloudDataTransferConfigValue", - destination: "destinationValue", - }; - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.destinationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.destinationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('destinationPath', () => { - const result = client.destinationPath("projectValue", "locationValue", "multicloudDataTransferConfigValue", "destinationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.destinationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDestinationName', () => { - const result = client.matchProjectFromDestinationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromDestinationName', () => { - const result = client.matchLocationFromDestinationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMulticloudDataTransferConfigFromDestinationName', () => { - const result = client.matchMulticloudDataTransferConfigFromDestinationName(fakePath); - assert.strictEqual(result, "multicloudDataTransferConfigValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDestinationFromDestinationName', () => { - const result = client.matchDestinationFromDestinationName(fakePath); - assert.strictEqual(result, "destinationValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('group', async () => { - const fakePath = "/rendered/path/group"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - group: "groupValue", - }; - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.groupPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.groupPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('groupPath', () => { - const result = client.groupPath("projectValue", "hubValue", "groupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.groupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromGroupName', () => { - const result = client.matchProjectFromGroupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.groupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHubFromGroupName', () => { - const result = client.matchHubFromGroupName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.groupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchGroupFromGroupName', () => { - const result = client.matchGroupFromGroupName(fakePath); - assert.strictEqual(result, "groupValue"); - assert((client.pathTemplates.groupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('group', async () => { + const fakePath = '/rendered/path/group'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + group: 'groupValue', + }; + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.groupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.groupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('groupPath', () => { + const result = client.groupPath( + 'projectValue', + 'hubValue', + 'groupValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.groupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromGroupName', () => { + const result = client.matchProjectFromGroupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.groupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromGroupName', () => { + const result = client.matchHubFromGroupName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.groupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchGroupFromGroupName', () => { + const result = client.matchGroupFromGroupName(fakePath); + assert.strictEqual(result, 'groupValue'); + assert( + (client.pathTemplates.groupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('hub', async () => { - const fakePath = "/rendered/path/hub"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - }; - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.hubPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.hubPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('hubPath', () => { - const result = client.hubPath("projectValue", "hubValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.hubPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromHubName', () => { - const result = client.matchProjectFromHubName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.hubPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHubFromHubName', () => { - const result = client.matchHubFromHubName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.hubPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('hub', async () => { + const fakePath = '/rendered/path/hub'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + }; + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.hubPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.hubPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('hubPath', () => { + const result = client.hubPath('projectValue', 'hubValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.hubPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromHubName', () => { + const result = client.matchProjectFromHubName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.hubPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromHubName', () => { + const result = client.matchHubFromHubName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.hubPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('hubRoute', async () => { - const fakePath = "/rendered/path/hubRoute"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - route_table: "routeTableValue", - route: "routeValue", - }; - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.hubRoutePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.hubRoutePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('hubRoutePath', () => { - const result = client.hubRoutePath("projectValue", "hubValue", "routeTableValue", "routeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.hubRoutePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromHubRouteName', () => { - const result = client.matchProjectFromHubRouteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHubFromHubRouteName', () => { - const result = client.matchHubFromHubRouteName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRouteTableFromHubRouteName', () => { - const result = client.matchRouteTableFromHubRouteName(fakePath); - assert.strictEqual(result, "routeTableValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRouteFromHubRouteName', () => { - const result = client.matchRouteFromHubRouteName(fakePath); - assert.strictEqual(result, "routeValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('hubRoute', async () => { + const fakePath = '/rendered/path/hubRoute'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + route_table: 'routeTableValue', + route: 'routeValue', + }; + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.hubRoutePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.hubRoutePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('hubRoutePath', () => { + const result = client.hubRoutePath( + 'projectValue', + 'hubValue', + 'routeTableValue', + 'routeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.hubRoutePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromHubRouteName', () => { + const result = client.matchProjectFromHubRouteName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromHubRouteName', () => { + const result = client.matchHubFromHubRouteName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRouteTableFromHubRouteName', () => { + const result = client.matchRouteTableFromHubRouteName(fakePath); + assert.strictEqual(result, 'routeTableValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRouteFromHubRouteName', () => { + const result = client.matchRouteFromHubRouteName(fakePath); + assert.strictEqual(result, 'routeValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('instance', async () => { - const fakePath = "/rendered/path/instance"; - const expectedParameters = { - project: "projectValue", - zone: "zoneValue", - instance: "instanceValue", - }; - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.instancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.instancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('instancePath', () => { - const result = client.instancePath("projectValue", "zoneValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.instancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInstanceName', () => { - const result = client.matchProjectFromInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchZoneFromInstanceName', () => { - const result = client.matchZoneFromInstanceName(fakePath); - assert.strictEqual(result, "zoneValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromInstanceName', () => { - const result = client.matchInstanceFromInstanceName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('instance', async () => { + const fakePath = '/rendered/path/instance'; + const expectedParameters = { + project: 'projectValue', + zone: 'zoneValue', + instance: 'instanceValue', + }; + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.instancePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.instancePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('instancePath', () => { + const result = client.instancePath( + 'projectValue', + 'zoneValue', + 'instanceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.instancePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromInstanceName', () => { + const result = client.matchProjectFromInstanceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchZoneFromInstanceName', () => { + const result = client.matchZoneFromInstanceName(fakePath); + assert.strictEqual(result, 'zoneValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchInstanceFromInstanceName', () => { + const result = client.matchInstanceFromInstanceName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('interconnectAttachment', async () => { - const fakePath = "/rendered/path/interconnectAttachment"; - const expectedParameters = { - project: "projectValue", - region: "regionValue", - resource_id: "resourceIdValue", - }; - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.interconnectAttachmentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.interconnectAttachmentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('interconnectAttachmentPath', () => { - const result = client.interconnectAttachmentPath("projectValue", "regionValue", "resourceIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.interconnectAttachmentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInterconnectAttachmentName', () => { - const result = client.matchProjectFromInterconnectAttachmentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.interconnectAttachmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRegionFromInterconnectAttachmentName', () => { - const result = client.matchRegionFromInterconnectAttachmentName(fakePath); - assert.strictEqual(result, "regionValue"); - assert((client.pathTemplates.interconnectAttachmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchResourceIdFromInterconnectAttachmentName', () => { - const result = client.matchResourceIdFromInterconnectAttachmentName(fakePath); - assert.strictEqual(result, "resourceIdValue"); - assert((client.pathTemplates.interconnectAttachmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('interconnectAttachment', async () => { + const fakePath = '/rendered/path/interconnectAttachment'; + const expectedParameters = { + project: 'projectValue', + region: 'regionValue', + resource_id: 'resourceIdValue', + }; + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.interconnectAttachmentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.interconnectAttachmentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('interconnectAttachmentPath', () => { + const result = client.interconnectAttachmentPath( + 'projectValue', + 'regionValue', + 'resourceIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.interconnectAttachmentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromInterconnectAttachmentName', () => { + const result = + client.matchProjectFromInterconnectAttachmentName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.interconnectAttachmentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRegionFromInterconnectAttachmentName', () => { + const result = + client.matchRegionFromInterconnectAttachmentName(fakePath); + assert.strictEqual(result, 'regionValue'); + assert( + ( + client.pathTemplates.interconnectAttachmentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchResourceIdFromInterconnectAttachmentName', () => { + const result = + client.matchResourceIdFromInterconnectAttachmentName(fakePath); + assert.strictEqual(result, 'resourceIdValue'); + assert( + ( + client.pathTemplates.interconnectAttachmentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('internalRange', async () => { - const fakePath = "/rendered/path/internalRange"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - internal_range: "internalRangeValue", - }; - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.internalRangePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.internalRangePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('internalRangePath', () => { - const result = client.internalRangePath("projectValue", "locationValue", "internalRangeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.internalRangePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInternalRangeName', () => { - const result = client.matchProjectFromInternalRangeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.internalRangePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromInternalRangeName', () => { - const result = client.matchLocationFromInternalRangeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.internalRangePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInternalRangeFromInternalRangeName', () => { - const result = client.matchInternalRangeFromInternalRangeName(fakePath); - assert.strictEqual(result, "internalRangeValue"); - assert((client.pathTemplates.internalRangePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('internalRange', async () => { + const fakePath = '/rendered/path/internalRange'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + internal_range: 'internalRangeValue', + }; + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.internalRangePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.internalRangePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('internalRangePath', () => { + const result = client.internalRangePath( + 'projectValue', + 'locationValue', + 'internalRangeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.internalRangePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromInternalRangeName', () => { + const result = client.matchProjectFromInternalRangeName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.internalRangePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromInternalRangeName', () => { + const result = client.matchLocationFromInternalRangeName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.internalRangePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchInternalRangeFromInternalRangeName', () => { + const result = client.matchInternalRangeFromInternalRangeName(fakePath); + assert.strictEqual(result, 'internalRangeValue'); + assert( + (client.pathTemplates.internalRangePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('multicloudDataTransferConfig', async () => { - const fakePath = "/rendered/path/multicloudDataTransferConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - multicloud_data_transfer_config: "multicloudDataTransferConfigValue", - }; - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.multicloudDataTransferConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.multicloudDataTransferConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('multicloudDataTransferConfigPath', () => { - const result = client.multicloudDataTransferConfigPath("projectValue", "locationValue", "multicloudDataTransferConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMulticloudDataTransferConfigName', () => { - const result = client.matchProjectFromMulticloudDataTransferConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMulticloudDataTransferConfigName', () => { - const result = client.matchLocationFromMulticloudDataTransferConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName', () => { - const result = client.matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName(fakePath); - assert.strictEqual(result, "multicloudDataTransferConfigValue"); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('multicloudDataTransferConfig', async () => { + const fakePath = '/rendered/path/multicloudDataTransferConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + multicloud_data_transfer_config: 'multicloudDataTransferConfigValue', + }; + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.multicloudDataTransferConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.multicloudDataTransferConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('multicloudDataTransferConfigPath', () => { + const result = client.multicloudDataTransferConfigPath( + 'projectValue', + 'locationValue', + 'multicloudDataTransferConfigValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMulticloudDataTransferConfigName', () => { + const result = + client.matchProjectFromMulticloudDataTransferConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMulticloudDataTransferConfigName', () => { + const result = + client.matchLocationFromMulticloudDataTransferConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName', () => { + const result = + client.matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName( + fakePath, + ); + assert.strictEqual(result, 'multicloudDataTransferConfigValue'); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('multicloudDataTransferSupportedService', async () => { - const fakePath = "/rendered/path/multicloudDataTransferSupportedService"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - multicloud_data_transfer_supported_service: "multicloudDataTransferSupportedServiceValue", - }; - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('multicloudDataTransferSupportedServicePath', () => { - const result = client.multicloudDataTransferSupportedServicePath("projectValue", "locationValue", "multicloudDataTransferSupportedServiceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMulticloudDataTransferSupportedServiceName', () => { - const result = client.matchProjectFromMulticloudDataTransferSupportedServiceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMulticloudDataTransferSupportedServiceName', () => { - const result = client.matchLocationFromMulticloudDataTransferSupportedServiceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName', () => { - const result = client.matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName(fakePath); - assert.strictEqual(result, "multicloudDataTransferSupportedServiceValue"); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('multicloudDataTransferSupportedService', async () => { + const fakePath = '/rendered/path/multicloudDataTransferSupportedService'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + multicloud_data_transfer_supported_service: + 'multicloudDataTransferSupportedServiceValue', + }; + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('multicloudDataTransferSupportedServicePath', () => { + const result = client.multicloudDataTransferSupportedServicePath( + 'projectValue', + 'locationValue', + 'multicloudDataTransferSupportedServiceValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMulticloudDataTransferSupportedServiceName', () => { + const result = + client.matchProjectFromMulticloudDataTransferSupportedServiceName( + fakePath, + ); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMulticloudDataTransferSupportedServiceName', () => { + const result = + client.matchLocationFromMulticloudDataTransferSupportedServiceName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName', () => { + const result = + client.matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName( + fakePath, + ); + assert.strictEqual( + result, + 'multicloudDataTransferSupportedServiceValue', + ); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('network', async () => { - const fakePath = "/rendered/path/network"; - const expectedParameters = { - project: "projectValue", - resource_id: "resourceIdValue", - }; - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.networkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.networkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('networkPath', () => { - const result = client.networkPath("projectValue", "resourceIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.networkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromNetworkName', () => { - const result = client.matchProjectFromNetworkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.networkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchResourceIdFromNetworkName', () => { - const result = client.matchResourceIdFromNetworkName(fakePath); - assert.strictEqual(result, "resourceIdValue"); - assert((client.pathTemplates.networkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('network', async () => { + const fakePath = '/rendered/path/network'; + const expectedParameters = { + project: 'projectValue', + resource_id: 'resourceIdValue', + }; + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.networkPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.networkPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('networkPath', () => { + const result = client.networkPath('projectValue', 'resourceIdValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.networkPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromNetworkName', () => { + const result = client.matchProjectFromNetworkName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.networkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchResourceIdFromNetworkName', () => { + const result = client.matchResourceIdFromNetworkName(fakePath); + assert.strictEqual(result, 'resourceIdValue'); + assert( + (client.pathTemplates.networkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('policyBasedRoute', async () => { - const fakePath = "/rendered/path/policyBasedRoute"; - const expectedParameters = { - project: "projectValue", - policy_based_route: "policyBasedRouteValue", - }; - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.policyBasedRoutePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.policyBasedRoutePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('policyBasedRoutePath', () => { - const result = client.policyBasedRoutePath("projectValue", "policyBasedRouteValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.policyBasedRoutePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromPolicyBasedRouteName', () => { - const result = client.matchProjectFromPolicyBasedRouteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchPolicyBasedRouteFromPolicyBasedRouteName', () => { - const result = client.matchPolicyBasedRouteFromPolicyBasedRouteName(fakePath); - assert.strictEqual(result, "policyBasedRouteValue"); - assert((client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('policyBasedRoute', async () => { + const fakePath = '/rendered/path/policyBasedRoute'; + const expectedParameters = { + project: 'projectValue', + policy_based_route: 'policyBasedRouteValue', + }; + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.policyBasedRoutePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.policyBasedRoutePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('policyBasedRoutePath', () => { + const result = client.policyBasedRoutePath( + 'projectValue', + 'policyBasedRouteValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.policyBasedRoutePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromPolicyBasedRouteName', () => { + const result = client.matchProjectFromPolicyBasedRouteName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchPolicyBasedRouteFromPolicyBasedRouteName', () => { + const result = + client.matchPolicyBasedRouteFromPolicyBasedRouteName(fakePath); + assert.strictEqual(result, 'policyBasedRouteValue'); + assert( + (client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('routeTable', async () => { - const fakePath = "/rendered/path/routeTable"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - route_table: "routeTableValue", - }; - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.routeTablePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.routeTablePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('routeTablePath', () => { - const result = client.routeTablePath("projectValue", "hubValue", "routeTableValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.routeTablePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRouteTableName', () => { - const result = client.matchProjectFromRouteTableName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.routeTablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHubFromRouteTableName', () => { - const result = client.matchHubFromRouteTableName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.routeTablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRouteTableFromRouteTableName', () => { - const result = client.matchRouteTableFromRouteTableName(fakePath); - assert.strictEqual(result, "routeTableValue"); - assert((client.pathTemplates.routeTablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('routeTable', async () => { + const fakePath = '/rendered/path/routeTable'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + route_table: 'routeTableValue', + }; + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.routeTablePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.routeTablePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('routeTablePath', () => { + const result = client.routeTablePath( + 'projectValue', + 'hubValue', + 'routeTableValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.routeTablePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromRouteTableName', () => { + const result = client.matchProjectFromRouteTableName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.routeTablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromRouteTableName', () => { + const result = client.matchHubFromRouteTableName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.routeTablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRouteTableFromRouteTableName', () => { + const result = client.matchRouteTableFromRouteTableName(fakePath); + assert.strictEqual(result, 'routeTableValue'); + assert( + (client.pathTemplates.routeTablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('serviceClass', async () => { - const fakePath = "/rendered/path/serviceClass"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service_class: "serviceClassValue", - }; - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.serviceClassPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.serviceClassPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('serviceClassPath', () => { - const result = client.serviceClassPath("projectValue", "locationValue", "serviceClassValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.serviceClassPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceClassName', () => { - const result = client.matchProjectFromServiceClassName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.serviceClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServiceClassName', () => { - const result = client.matchLocationFromServiceClassName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.serviceClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceClassFromServiceClassName', () => { - const result = client.matchServiceClassFromServiceClassName(fakePath); - assert.strictEqual(result, "serviceClassValue"); - assert((client.pathTemplates.serviceClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('serviceClass', async () => { + const fakePath = '/rendered/path/serviceClass'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service_class: 'serviceClassValue', + }; + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.serviceClassPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.serviceClassPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('serviceClassPath', () => { + const result = client.serviceClassPath( + 'projectValue', + 'locationValue', + 'serviceClassValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.serviceClassPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceClassName', () => { + const result = client.matchProjectFromServiceClassName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.serviceClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromServiceClassName', () => { + const result = client.matchLocationFromServiceClassName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.serviceClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceClassFromServiceClassName', () => { + const result = client.matchServiceClassFromServiceClassName(fakePath); + assert.strictEqual(result, 'serviceClassValue'); + assert( + (client.pathTemplates.serviceClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('serviceConnectionMap', async () => { - const fakePath = "/rendered/path/serviceConnectionMap"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service_connection_map: "serviceConnectionMapValue", - }; - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.serviceConnectionMapPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.serviceConnectionMapPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('serviceConnectionMapPath', () => { - const result = client.serviceConnectionMapPath("projectValue", "locationValue", "serviceConnectionMapValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.serviceConnectionMapPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceConnectionMapName', () => { - const result = client.matchProjectFromServiceConnectionMapName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.serviceConnectionMapPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServiceConnectionMapName', () => { - const result = client.matchLocationFromServiceConnectionMapName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.serviceConnectionMapPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceConnectionMapFromServiceConnectionMapName', () => { - const result = client.matchServiceConnectionMapFromServiceConnectionMapName(fakePath); - assert.strictEqual(result, "serviceConnectionMapValue"); - assert((client.pathTemplates.serviceConnectionMapPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('serviceConnectionMap', async () => { + const fakePath = '/rendered/path/serviceConnectionMap'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service_connection_map: 'serviceConnectionMapValue', + }; + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.serviceConnectionMapPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.serviceConnectionMapPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('serviceConnectionMapPath', () => { + const result = client.serviceConnectionMapPath( + 'projectValue', + 'locationValue', + 'serviceConnectionMapValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.serviceConnectionMapPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceConnectionMapName', () => { + const result = + client.matchProjectFromServiceConnectionMapName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.serviceConnectionMapPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromServiceConnectionMapName', () => { + const result = + client.matchLocationFromServiceConnectionMapName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.serviceConnectionMapPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceConnectionMapFromServiceConnectionMapName', () => { + const result = + client.matchServiceConnectionMapFromServiceConnectionMapName( + fakePath, + ); + assert.strictEqual(result, 'serviceConnectionMapValue'); + assert( + ( + client.pathTemplates.serviceConnectionMapPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('serviceConnectionPolicy', async () => { - const fakePath = "/rendered/path/serviceConnectionPolicy"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service_connection_policy: "serviceConnectionPolicyValue", - }; - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.serviceConnectionPolicyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.serviceConnectionPolicyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('serviceConnectionPolicyPath', () => { - const result = client.serviceConnectionPolicyPath("projectValue", "locationValue", "serviceConnectionPolicyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.serviceConnectionPolicyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceConnectionPolicyName', () => { - const result = client.matchProjectFromServiceConnectionPolicyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.serviceConnectionPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServiceConnectionPolicyName', () => { - const result = client.matchLocationFromServiceConnectionPolicyName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.serviceConnectionPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceConnectionPolicyFromServiceConnectionPolicyName', () => { - const result = client.matchServiceConnectionPolicyFromServiceConnectionPolicyName(fakePath); - assert.strictEqual(result, "serviceConnectionPolicyValue"); - assert((client.pathTemplates.serviceConnectionPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('serviceConnectionPolicy', async () => { + const fakePath = '/rendered/path/serviceConnectionPolicy'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service_connection_policy: 'serviceConnectionPolicyValue', + }; + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.serviceConnectionPolicyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.serviceConnectionPolicyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('serviceConnectionPolicyPath', () => { + const result = client.serviceConnectionPolicyPath( + 'projectValue', + 'locationValue', + 'serviceConnectionPolicyValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.serviceConnectionPolicyPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceConnectionPolicyName', () => { + const result = + client.matchProjectFromServiceConnectionPolicyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.serviceConnectionPolicyPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromServiceConnectionPolicyName', () => { + const result = + client.matchLocationFromServiceConnectionPolicyName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.serviceConnectionPolicyPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceConnectionPolicyFromServiceConnectionPolicyName', () => { + const result = + client.matchServiceConnectionPolicyFromServiceConnectionPolicyName( + fakePath, + ); + assert.strictEqual(result, 'serviceConnectionPolicyValue'); + assert( + ( + client.pathTemplates.serviceConnectionPolicyPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('serviceConnectionToken', async () => { - const fakePath = "/rendered/path/serviceConnectionToken"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service_connection_token: "serviceConnectionTokenValue", - }; - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.serviceConnectionTokenPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.serviceConnectionTokenPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('serviceConnectionTokenPath', () => { - const result = client.serviceConnectionTokenPath("projectValue", "locationValue", "serviceConnectionTokenValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.serviceConnectionTokenPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceConnectionTokenName', () => { - const result = client.matchProjectFromServiceConnectionTokenName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.serviceConnectionTokenPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServiceConnectionTokenName', () => { - const result = client.matchLocationFromServiceConnectionTokenName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.serviceConnectionTokenPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceConnectionTokenFromServiceConnectionTokenName', () => { - const result = client.matchServiceConnectionTokenFromServiceConnectionTokenName(fakePath); - assert.strictEqual(result, "serviceConnectionTokenValue"); - assert((client.pathTemplates.serviceConnectionTokenPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('serviceConnectionToken', async () => { + const fakePath = '/rendered/path/serviceConnectionToken'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service_connection_token: 'serviceConnectionTokenValue', + }; + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.serviceConnectionTokenPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.serviceConnectionTokenPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('serviceConnectionTokenPath', () => { + const result = client.serviceConnectionTokenPath( + 'projectValue', + 'locationValue', + 'serviceConnectionTokenValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.serviceConnectionTokenPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceConnectionTokenName', () => { + const result = + client.matchProjectFromServiceConnectionTokenName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.serviceConnectionTokenPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromServiceConnectionTokenName', () => { + const result = + client.matchLocationFromServiceConnectionTokenName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.serviceConnectionTokenPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceConnectionTokenFromServiceConnectionTokenName', () => { + const result = + client.matchServiceConnectionTokenFromServiceConnectionTokenName( + fakePath, + ); + assert.strictEqual(result, 'serviceConnectionTokenValue'); + assert( + ( + client.pathTemplates.serviceConnectionTokenPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('spoke', async () => { - const fakePath = "/rendered/path/spoke"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - spoke: "spokeValue", - }; - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.spokePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.spokePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('spokePath', () => { - const result = client.spokePath("projectValue", "locationValue", "spokeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.spokePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromSpokeName', () => { - const result = client.matchProjectFromSpokeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.spokePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromSpokeName', () => { - const result = client.matchLocationFromSpokeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.spokePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSpokeFromSpokeName', () => { - const result = client.matchSpokeFromSpokeName(fakePath); - assert.strictEqual(result, "spokeValue"); - assert((client.pathTemplates.spokePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('spoke', async () => { + const fakePath = '/rendered/path/spoke'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + spoke: 'spokeValue', + }; + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.spokePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.spokePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('spokePath', () => { + const result = client.spokePath( + 'projectValue', + 'locationValue', + 'spokeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.spokePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromSpokeName', () => { + const result = client.matchProjectFromSpokeName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.spokePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromSpokeName', () => { + const result = client.matchLocationFromSpokeName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.spokePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchSpokeFromSpokeName', () => { + const result = client.matchSpokeFromSpokeName(fakePath); + assert.strictEqual(result, 'spokeValue'); + assert( + (client.pathTemplates.spokePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('vpnTunnel', async () => { - const fakePath = "/rendered/path/vpnTunnel"; - const expectedParameters = { - project: "projectValue", - region: "regionValue", - resource_id: "resourceIdValue", - }; - const client = new hubserviceModule.v1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.vpnTunnelPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.vpnTunnelPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('vpnTunnelPath', () => { - const result = client.vpnTunnelPath("projectValue", "regionValue", "resourceIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.vpnTunnelPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromVpnTunnelName', () => { - const result = client.matchProjectFromVpnTunnelName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.vpnTunnelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRegionFromVpnTunnelName', () => { - const result = client.matchRegionFromVpnTunnelName(fakePath); - assert.strictEqual(result, "regionValue"); - assert((client.pathTemplates.vpnTunnelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchResourceIdFromVpnTunnelName', () => { - const result = client.matchResourceIdFromVpnTunnelName(fakePath); - assert.strictEqual(result, "resourceIdValue"); - assert((client.pathTemplates.vpnTunnelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('vpnTunnel', async () => { + const fakePath = '/rendered/path/vpnTunnel'; + const expectedParameters = { + project: 'projectValue', + region: 'regionValue', + resource_id: 'resourceIdValue', + }; + const client = new hubserviceModule.v1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.vpnTunnelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.vpnTunnelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('vpnTunnelPath', () => { + const result = client.vpnTunnelPath( + 'projectValue', + 'regionValue', + 'resourceIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.vpnTunnelPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromVpnTunnelName', () => { + const result = client.matchProjectFromVpnTunnelName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.vpnTunnelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRegionFromVpnTunnelName', () => { + const result = client.matchRegionFromVpnTunnelName(fakePath); + assert.strictEqual(result, 'regionValue'); + assert( + (client.pathTemplates.vpnTunnelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchResourceIdFromVpnTunnelName', () => { + const result = client.matchResourceIdFromVpnTunnelName(fakePath); + assert.strictEqual(result, 'resourceIdValue'); + assert( + (client.pathTemplates.vpnTunnelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-networkconnectivity/test/gapic_hub_service_v1alpha1.ts b/packages/google-cloud-networkconnectivity/test/gapic_hub_service_v1alpha1.ts index 6326dd013dbf..d74c0dcc474b 100644 --- a/packages/google-cloud-networkconnectivity/test/gapic_hub_service_v1alpha1.ts +++ b/packages/google-cloud-networkconnectivity/test/gapic_hub_service_v1alpha1.ts @@ -19,2160 +19,2782 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as hubserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos} from 'google-gax'; +import { protobuf, LROperation, operationsProtos } from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1alpha1.HubServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = hubserviceModule.v1alpha1.HubServiceClient.servicePath; - assert.strictEqual(servicePath, 'networkconnectivity.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = hubserviceModule.v1alpha1.HubServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new hubserviceModule.v1alpha1.HubServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new hubserviceModule.v1alpha1.HubServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new hubserviceModule.v1alpha1.HubServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = hubserviceModule.v1alpha1.HubServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - fallback: true, - }); - assert(client); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.hubServiceStub, undefined); - await client.initialize(); - assert(client.hubServiceStub); - }); + it('has universeDomain', () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has close method for the initialized client', done => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.hubServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + hubserviceModule.v1alpha1.HubServiceClient.servicePath; + assert.strictEqual(servicePath, 'networkconnectivity.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + hubserviceModule.v1alpha1.HubServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkconnectivity.example.com'); + }); - it('has close method for the non-initialized client', done => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.hubServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkconnectivity.example.com'); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new hubserviceModule.v1alpha1.HubServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkconnectivity.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'networkconnectivity.configured.example.com', + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new hubserviceModule.v1alpha1.HubServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); + it('has port', () => { + const port = hubserviceModule.v1alpha1.HubServiceClient.port; + assert(port); + assert(typeof port === 'number'); }); - describe('getHub', () => { - it('invokes getHub without error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.GetHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.GetHubRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.Hub() - ); - client.innerApiCalls.getHub = stubSimpleCall(expectedResponse); - const [response] = await client.getHub(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('should create a client with no option', () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient(); + assert(client); + }); - it('invokes getHub without error using callback', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.GetHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.GetHubRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.Hub() - ); - client.innerApiCalls.getHub = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getHub( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1alpha1.IHub|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('should create a client with gRPC fallback', () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + fallback: true, + }); + assert(client); + }); - it('invokes getHub with error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.GetHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.GetHubRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getHub = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getHub(request), expectedError); - const actualRequest = (client.innerApiCalls.getHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.hubServiceStub, undefined); + await client.initialize(); + assert(client.hubServiceStub); + }); - it('invokes getHub with closed client', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.GetHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.GetHubRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getHub(request), expectedError); + it('has close method for the initialized client', (done) => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.hubServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('getSpoke', () => { - it('invokes getSpoke without error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.GetSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.GetSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.Spoke() - ); - client.innerApiCalls.getSpoke = stubSimpleCall(expectedResponse); - const [response] = await client.getSpoke(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the non-initialized client', (done) => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.hubServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getSpoke without error using callback', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.GetSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.GetSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.Spoke() - ); - client.innerApiCalls.getSpoke = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getSpoke( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1alpha1.ISpoke|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('invokes getSpoke with error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.GetSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.GetSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getSpoke = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getSpoke(request), expectedError); - const actualRequest = (client.innerApiCalls.getSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getHub', () => { + it('invokes getHub without error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.GetHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.GetHubRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.Hub(), + ); + client.innerApiCalls.getHub = stubSimpleCall(expectedResponse); + const [response] = await client.getHub(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getHub as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getSpoke with closed client', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.GetSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.GetSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getSpoke(request), expectedError); - }); + it('invokes getHub without error using callback', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.GetHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.GetHubRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.Hub(), + ); + client.innerApiCalls.getHub = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getHub( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1alpha1.IHub | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getHub as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createHub', () => { - it('invokes createHub without error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.CreateHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.CreateHubRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createHub = stubLongRunningCall(expectedResponse); - const [operation] = await client.createHub(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getHub with error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.GetHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.GetHubRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getHub = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getHub(request), expectedError); + const actualRequest = (client.innerApiCalls.getHub as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createHub without error using callback', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.CreateHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.CreateHubRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createHub = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createHub( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getHub with closed client', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.GetHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.GetHubRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getHub(request), expectedError); + }); + }); + + describe('getSpoke', () => { + it('invokes getSpoke without error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.GetSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.GetSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.Spoke(), + ); + client.innerApiCalls.getSpoke = stubSimpleCall(expectedResponse); + const [response] = await client.getSpoke(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createHub with call error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.CreateHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.CreateHubRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createHub = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createHub(request), expectedError); - const actualRequest = (client.innerApiCalls.createHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getSpoke without error using callback', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.GetSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.GetSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.Spoke(), + ); + client.innerApiCalls.getSpoke = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getSpoke( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1alpha1.ISpoke | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createHub with LRO error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.CreateHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.CreateHubRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createHub = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createHub(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getSpoke with error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.GetSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.GetSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getSpoke = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getSpoke(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateHubProgress without error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateHubProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes getSpoke with closed client', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.GetSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.GetSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getSpoke(request), expectedError); + }); + }); + + describe('createHub', () => { + it('invokes createHub without error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.CreateHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.CreateHubRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createHub = stubLongRunningCall(expectedResponse); + const [operation] = await client.createHub(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateHubProgress with error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateHubProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createHub without error using callback', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.CreateHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.CreateHubRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createHub = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createHub( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.IHub, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.IHub, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateHub', () => { - it('invokes updateHub without error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.UpdateHubRequest() - ); - request.hub ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.UpdateHubRequest', ['hub', 'name']); - request.hub.name = defaultValue1; - const expectedHeaderRequestParams = `hub.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateHub = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateHub(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createHub with call error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.CreateHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.CreateHubRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createHub = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createHub(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateHub without error using callback', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.UpdateHubRequest() - ); - request.hub ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.UpdateHubRequest', ['hub', 'name']); - request.hub.name = defaultValue1; - const expectedHeaderRequestParams = `hub.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateHub = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateHub( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createHub with LRO error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.CreateHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.CreateHubRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createHub = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createHub(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateHub with call error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.UpdateHubRequest() - ); - request.hub ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.UpdateHubRequest', ['hub', 'name']); - request.hub.name = defaultValue1; - const expectedHeaderRequestParams = `hub.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateHub = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateHub(request), expectedError); - const actualRequest = (client.innerApiCalls.updateHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateHubProgress without error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateHubProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateHub with LRO error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.UpdateHubRequest() - ); - request.hub ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.UpdateHubRequest', ['hub', 'name']); - request.hub.name = defaultValue1; - const expectedHeaderRequestParams = `hub.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateHub = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateHub(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateHubProgress with error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkCreateHubProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateHub', () => { + it('invokes updateHub without error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.UpdateHubRequest(), + ); + request.hub ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.UpdateHubRequest', + ['hub', 'name'], + ); + request.hub.name = defaultValue1; + const expectedHeaderRequestParams = `hub.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateHub = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateHub(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateHubProgress without error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateHubProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateHub without error using callback', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.UpdateHubRequest(), + ); + request.hub ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.UpdateHubRequest', + ['hub', 'name'], + ); + request.hub.name = defaultValue1; + const expectedHeaderRequestParams = `hub.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateHub = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateHub( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.IHub, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.IHub, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateHubProgress with error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateHubProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateHub with call error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.UpdateHubRequest(), + ); + request.hub ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.UpdateHubRequest', + ['hub', 'name'], + ); + request.hub.name = defaultValue1; + const expectedHeaderRequestParams = `hub.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateHub = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateHub(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteHub', () => { - it('invokes deleteHub without error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.DeleteHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.DeleteHubRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteHub = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteHub(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateHub with LRO error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.UpdateHubRequest(), + ); + request.hub ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.UpdateHubRequest', + ['hub', 'name'], + ); + request.hub.name = defaultValue1; + const expectedHeaderRequestParams = `hub.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateHub = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateHub(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteHub without error using callback', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.DeleteHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.DeleteHubRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteHub = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteHub( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateHubProgress without error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateHubProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteHub with call error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.DeleteHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.DeleteHubRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteHub = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteHub(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateHubProgress with error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkUpdateHubProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteHub', () => { + it('invokes deleteHub without error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.DeleteHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.DeleteHubRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteHub = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteHub(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteHub with LRO error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.DeleteHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.DeleteHubRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteHub = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteHub(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteHub without error using callback', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.DeleteHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.DeleteHubRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteHub = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteHub( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteHubProgress without error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteHubProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteHub with call error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.DeleteHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.DeleteHubRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteHub = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteHub(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteHubProgress with error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteHubProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteHub with LRO error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.DeleteHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.DeleteHubRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteHub = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteHub(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createSpoke', () => { - it('invokes createSpoke without error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.CreateSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.CreateSpokeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createSpoke = stubLongRunningCall(expectedResponse); - const [operation] = await client.createSpoke(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteHubProgress without error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteHubProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createSpoke without error using callback', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.CreateSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.CreateSpokeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createSpoke = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createSpoke( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteHubProgress with error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkDeleteHubProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createSpoke', () => { + it('invokes createSpoke without error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.CreateSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.CreateSpokeRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createSpoke = stubLongRunningCall(expectedResponse); + const [operation] = await client.createSpoke(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createSpoke with call error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.CreateSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.CreateSpokeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createSpoke = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createSpoke(request), expectedError); - const actualRequest = (client.innerApiCalls.createSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createSpoke without error using callback', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.CreateSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.CreateSpokeRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createSpoke = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createSpoke( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createSpoke with LRO error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.CreateSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.CreateSpokeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createSpoke = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createSpoke(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createSpoke with call error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.CreateSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.CreateSpokeRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createSpoke = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createSpoke(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateSpokeProgress without error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateSpokeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createSpoke with LRO error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.CreateSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.CreateSpokeRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createSpoke = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createSpoke(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateSpokeProgress with error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateSpokeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateSpokeProgress without error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateSpokeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('updateSpoke', () => { - it('invokes updateSpoke without error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.UpdateSpokeRequest() - ); - request.spoke ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.UpdateSpokeRequest', ['spoke', 'name']); - request.spoke.name = defaultValue1; - const expectedHeaderRequestParams = `spoke.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateSpoke = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateSpoke(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateSpokeProgress with error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkCreateSpokeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateSpoke', () => { + it('invokes updateSpoke without error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.UpdateSpokeRequest(), + ); + request.spoke ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.UpdateSpokeRequest', + ['spoke', 'name'], + ); + request.spoke.name = defaultValue1; + const expectedHeaderRequestParams = `spoke.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateSpoke = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateSpoke(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateSpoke without error using callback', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.UpdateSpokeRequest() - ); - request.spoke ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.UpdateSpokeRequest', ['spoke', 'name']); - request.spoke.name = defaultValue1; - const expectedHeaderRequestParams = `spoke.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateSpoke = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateSpoke( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateSpoke without error using callback', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.UpdateSpokeRequest(), + ); + request.spoke ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.UpdateSpokeRequest', + ['spoke', 'name'], + ); + request.spoke.name = defaultValue1; + const expectedHeaderRequestParams = `spoke.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateSpoke = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateSpoke( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1alpha1.ISpoke, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateSpoke with call error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.UpdateSpokeRequest() - ); - request.spoke ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.UpdateSpokeRequest', ['spoke', 'name']); - request.spoke.name = defaultValue1; - const expectedHeaderRequestParams = `spoke.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateSpoke = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateSpoke(request), expectedError); - const actualRequest = (client.innerApiCalls.updateSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateSpoke with call error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.UpdateSpokeRequest(), + ); + request.spoke ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.UpdateSpokeRequest', + ['spoke', 'name'], + ); + request.spoke.name = defaultValue1; + const expectedHeaderRequestParams = `spoke.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateSpoke = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateSpoke(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateSpoke with LRO error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.UpdateSpokeRequest() - ); - request.spoke ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.UpdateSpokeRequest', ['spoke', 'name']); - request.spoke.name = defaultValue1; - const expectedHeaderRequestParams = `spoke.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateSpoke = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateSpoke(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateSpoke with LRO error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.UpdateSpokeRequest(), + ); + request.spoke ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.UpdateSpokeRequest', + ['spoke', 'name'], + ); + request.spoke.name = defaultValue1; + const expectedHeaderRequestParams = `spoke.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateSpoke = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateSpoke(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateSpokeProgress without error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateSpokeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateSpokeProgress without error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateSpokeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkUpdateSpokeProgress with error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateSpokeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpdateSpokeProgress with error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkUpdateSpokeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteSpoke', () => { + it('invokes deleteSpoke without error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.DeleteSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.DeleteSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteSpoke = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteSpoke(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteSpoke', () => { - it('invokes deleteSpoke without error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.DeleteSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.DeleteSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteSpoke = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteSpoke(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteSpoke without error using callback', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.DeleteSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.DeleteSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteSpoke = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteSpoke( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1alpha1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteSpoke without error using callback', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.DeleteSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.DeleteSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteSpoke = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteSpoke( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteSpoke with call error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.DeleteSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.DeleteSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteSpoke = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteSpoke(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteSpoke with call error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.DeleteSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.DeleteSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteSpoke = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteSpoke(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteSpoke with LRO error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.DeleteSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.DeleteSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteSpoke = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteSpoke(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteSpoke with LRO error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.DeleteSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.DeleteSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteSpoke = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteSpoke(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteSpokeProgress without error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteSpokeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteSpokeProgress without error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteSpokeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkDeleteSpokeProgress with error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkDeleteSpokeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listHubs', () => { + it('invokes listHubs without error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.ListHubsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.ListHubsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.Hub(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.Hub(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.Hub(), + ), + ]; + client.innerApiCalls.listHubs = stubSimpleCall(expectedResponse); + const [response] = await client.listHubs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listHubs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listHubs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteSpokeProgress with error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteSpokeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes listHubs without error using callback', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.ListHubsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.ListHubsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.Hub(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.Hub(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.Hub(), + ), + ]; + client.innerApiCalls.listHubs = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listHubs( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkconnectivity.v1alpha1.IHub[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listHubs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listHubs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listHubs', () => { - it('invokes listHubs without error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.ListHubsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.ListHubsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1alpha1.Hub()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1alpha1.Hub()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1alpha1.Hub()), - ]; - client.innerApiCalls.listHubs = stubSimpleCall(expectedResponse); - const [response] = await client.listHubs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listHubs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listHubs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listHubs with error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.ListHubsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.ListHubsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listHubs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listHubs(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listHubs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listHubs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listHubs without error using callback', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.ListHubsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.ListHubsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1alpha1.Hub()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1alpha1.Hub()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1alpha1.Hub()), - ]; - client.innerApiCalls.listHubs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listHubs( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1alpha1.IHub[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listHubs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listHubs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listHubsStream without error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.ListHubsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.ListHubsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.Hub(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.Hub(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.Hub(), + ), + ]; + client.descriptors.page.listHubs.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listHubsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1alpha1.Hub[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkconnectivity.v1alpha1.Hub) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listHubs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listHubs, request), + ); + assert( + (client.descriptors.page.listHubs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listHubs with error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.ListHubsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.ListHubsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listHubs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listHubs(request), expectedError); - const actualRequest = (client.innerApiCalls.listHubs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listHubs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listHubsStream with error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.ListHubsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.ListHubsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listHubs.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listHubsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1alpha1.Hub[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkconnectivity.v1alpha1.Hub) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listHubs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listHubs, request), + ); + assert( + (client.descriptors.page.listHubs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listHubsStream without error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.ListHubsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.ListHubsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1alpha1.Hub()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1alpha1.Hub()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1alpha1.Hub()), - ]; - client.descriptors.page.listHubs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listHubsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1alpha1.Hub[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1alpha1.Hub) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listHubs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listHubs, request)); - assert( - (client.descriptors.page.listHubs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listHubs without error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.ListHubsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.ListHubsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.Hub(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.Hub(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.Hub(), + ), + ]; + client.descriptors.page.listHubs.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1alpha1.IHub[] = + []; + const iterable = client.listHubsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listHubs.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.listHubs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listHubsStream with error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.ListHubsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.ListHubsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listHubs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listHubsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1alpha1.Hub[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1alpha1.Hub) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listHubs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listHubs, request)); - assert( - (client.descriptors.page.listHubs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listHubs with error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.ListHubsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.ListHubsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listHubs.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listHubsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1alpha1.IHub[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listHubs.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.listHubs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listSpokes', () => { + it('invokes listSpokes without error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.ListSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.ListSpokesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.Spoke(), + ), + ]; + client.innerApiCalls.listSpokes = stubSimpleCall(expectedResponse); + const [response] = await client.listSpokes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listSpokes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSpokes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listHubs without error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.ListHubsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.ListHubsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1alpha1.Hub()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1alpha1.Hub()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1alpha1.Hub()), - ]; - client.descriptors.page.listHubs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1alpha1.IHub[] = []; - const iterable = client.listHubsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listSpokes without error using callback', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.ListSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.ListSpokesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.Spoke(), + ), + ]; + client.innerApiCalls.listSpokes = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listSpokes( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkconnectivity.v1alpha1.ISpoke[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listHubs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listHubs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listHubs with error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.ListHubsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.ListHubsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listHubs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listHubsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1alpha1.IHub[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listHubs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listHubs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listSpokes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSpokes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listSpokes', () => { - it('invokes listSpokes without error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.ListSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.ListSpokesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1alpha1.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1alpha1.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1alpha1.Spoke()), - ]; - client.innerApiCalls.listSpokes = stubSimpleCall(expectedResponse); - const [response] = await client.listSpokes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSpokes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSpokes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listSpokes without error using callback', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.ListSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.ListSpokesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1alpha1.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1alpha1.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1alpha1.Spoke()), - ]; - client.innerApiCalls.listSpokes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listSpokes( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1alpha1.ISpoke[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSpokes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSpokes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listSpokes with error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.ListSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.ListSpokesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listSpokes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listSpokes(request), expectedError); - const actualRequest = (client.innerApiCalls.listSpokes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSpokes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listSpokesStream without error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.ListSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.ListSpokesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1alpha1.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1alpha1.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1alpha1.Spoke()), - ]; - client.descriptors.page.listSpokes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listSpokesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1alpha1.Spoke[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1alpha1.Spoke) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listSpokes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSpokes, request)); - assert( - (client.descriptors.page.listSpokes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listSpokes with error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.ListSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.ListSpokesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listSpokes = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listSpokes(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listSpokes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSpokes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listSpokesStream with error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.ListSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.ListSpokesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listSpokes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listSpokesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1alpha1.Spoke[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1alpha1.Spoke) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listSpokes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSpokes, request)); - assert( - (client.descriptors.page.listSpokes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listSpokesStream without error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.ListSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.ListSpokesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.Spoke(), + ), + ]; + client.descriptors.page.listSpokes.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listSpokesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1alpha1.Spoke[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1alpha1.Spoke, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listSpokes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listSpokes, request), + ); + assert( + (client.descriptors.page.listSpokes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listSpokes without error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.ListSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.ListSpokesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1alpha1.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1alpha1.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1alpha1.Spoke()), - ]; - client.descriptors.page.listSpokes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1alpha1.ISpoke[] = []; - const iterable = client.listSpokesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listSpokes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSpokes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listSpokesStream with error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.ListSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.ListSpokesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSpokes.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listSpokesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1alpha1.Spoke[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1alpha1.Spoke, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listSpokes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listSpokes, request), + ); + assert( + (client.descriptors.page.listSpokes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listSpokes with error', async () => { - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1alpha1.ListSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1alpha1.ListSpokesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listSpokes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listSpokesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1alpha1.ISpoke[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listSpokes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSpokes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listSpokes without error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.ListSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.ListSpokesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.Spoke(), + ), + ]; + client.descriptors.page.listSpokes.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1alpha1.ISpoke[] = + []; + const iterable = client.listSpokesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listSpokes.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listSpokes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('Path templates', () => { - - describe('hub', async () => { - const fakePath = "/rendered/path/hub"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - }; - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.hubPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.hubPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('hubPath', () => { - const result = client.hubPath("projectValue", "hubValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.hubPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromHubName', () => { - const result = client.matchProjectFromHubName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.hubPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHubFromHubName', () => { - const result = client.matchHubFromHubName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.hubPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with listSpokes with error', async () => { + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1alpha1.ListSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1alpha1.ListSpokesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSpokes.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listSpokesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1alpha1.ISpoke[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listSpokes.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listSpokes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('Path templates', () => { + describe('hub', async () => { + const fakePath = '/rendered/path/hub'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + }; + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.hubPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.hubPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('hubPath', () => { + const result = client.hubPath('projectValue', 'hubValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.hubPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromHubName', () => { + const result = client.matchProjectFromHubName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.hubPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromHubName', () => { + const result = client.matchHubFromHubName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.hubPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('instance', async () => { - const fakePath = "/rendered/path/instance"; - const expectedParameters = { - project: "projectValue", - zone: "zoneValue", - instance: "instanceValue", - }; - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.instancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.instancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('instancePath', () => { - const result = client.instancePath("projectValue", "zoneValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.instancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInstanceName', () => { - const result = client.matchProjectFromInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchZoneFromInstanceName', () => { - const result = client.matchZoneFromInstanceName(fakePath); - assert.strictEqual(result, "zoneValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromInstanceName', () => { - const result = client.matchInstanceFromInstanceName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('instance', async () => { + const fakePath = '/rendered/path/instance'; + const expectedParameters = { + project: 'projectValue', + zone: 'zoneValue', + instance: 'instanceValue', + }; + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.instancePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.instancePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('instancePath', () => { + const result = client.instancePath( + 'projectValue', + 'zoneValue', + 'instanceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.instancePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromInstanceName', () => { + const result = client.matchProjectFromInstanceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchZoneFromInstanceName', () => { + const result = client.matchZoneFromInstanceName(fakePath); + assert.strictEqual(result, 'zoneValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchInstanceFromInstanceName', () => { + const result = client.matchInstanceFromInstanceName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('interconnectAttachment', async () => { - const fakePath = "/rendered/path/interconnectAttachment"; - const expectedParameters = { - project: "projectValue", - region: "regionValue", - resource_id: "resourceIdValue", - }; - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.interconnectAttachmentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.interconnectAttachmentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('interconnectAttachmentPath', () => { - const result = client.interconnectAttachmentPath("projectValue", "regionValue", "resourceIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.interconnectAttachmentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInterconnectAttachmentName', () => { - const result = client.matchProjectFromInterconnectAttachmentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.interconnectAttachmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRegionFromInterconnectAttachmentName', () => { - const result = client.matchRegionFromInterconnectAttachmentName(fakePath); - assert.strictEqual(result, "regionValue"); - assert((client.pathTemplates.interconnectAttachmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchResourceIdFromInterconnectAttachmentName', () => { - const result = client.matchResourceIdFromInterconnectAttachmentName(fakePath); - assert.strictEqual(result, "resourceIdValue"); - assert((client.pathTemplates.interconnectAttachmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('interconnectAttachment', async () => { + const fakePath = '/rendered/path/interconnectAttachment'; + const expectedParameters = { + project: 'projectValue', + region: 'regionValue', + resource_id: 'resourceIdValue', + }; + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.interconnectAttachmentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.interconnectAttachmentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('interconnectAttachmentPath', () => { + const result = client.interconnectAttachmentPath( + 'projectValue', + 'regionValue', + 'resourceIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.interconnectAttachmentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromInterconnectAttachmentName', () => { + const result = + client.matchProjectFromInterconnectAttachmentName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.interconnectAttachmentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRegionFromInterconnectAttachmentName', () => { + const result = + client.matchRegionFromInterconnectAttachmentName(fakePath); + assert.strictEqual(result, 'regionValue'); + assert( + ( + client.pathTemplates.interconnectAttachmentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchResourceIdFromInterconnectAttachmentName', () => { + const result = + client.matchResourceIdFromInterconnectAttachmentName(fakePath); + assert.strictEqual(result, 'resourceIdValue'); + assert( + ( + client.pathTemplates.interconnectAttachmentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('spoke', async () => { - const fakePath = "/rendered/path/spoke"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - spoke: "spokeValue", - }; - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.spokePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.spokePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('spokePath', () => { - const result = client.spokePath("projectValue", "locationValue", "spokeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.spokePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromSpokeName', () => { - const result = client.matchProjectFromSpokeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.spokePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromSpokeName', () => { - const result = client.matchLocationFromSpokeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.spokePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSpokeFromSpokeName', () => { - const result = client.matchSpokeFromSpokeName(fakePath); - assert.strictEqual(result, "spokeValue"); - assert((client.pathTemplates.spokePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('spoke', async () => { + const fakePath = '/rendered/path/spoke'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + spoke: 'spokeValue', + }; + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.spokePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.spokePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('spokePath', () => { + const result = client.spokePath( + 'projectValue', + 'locationValue', + 'spokeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.spokePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromSpokeName', () => { + const result = client.matchProjectFromSpokeName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.spokePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromSpokeName', () => { + const result = client.matchLocationFromSpokeName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.spokePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchSpokeFromSpokeName', () => { + const result = client.matchSpokeFromSpokeName(fakePath); + assert.strictEqual(result, 'spokeValue'); + assert( + (client.pathTemplates.spokePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('vpnTunnel', async () => { - const fakePath = "/rendered/path/vpnTunnel"; - const expectedParameters = { - project: "projectValue", - region: "regionValue", - resource_id: "resourceIdValue", - }; - const client = new hubserviceModule.v1alpha1.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.vpnTunnelPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.vpnTunnelPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('vpnTunnelPath', () => { - const result = client.vpnTunnelPath("projectValue", "regionValue", "resourceIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.vpnTunnelPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromVpnTunnelName', () => { - const result = client.matchProjectFromVpnTunnelName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.vpnTunnelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRegionFromVpnTunnelName', () => { - const result = client.matchRegionFromVpnTunnelName(fakePath); - assert.strictEqual(result, "regionValue"); - assert((client.pathTemplates.vpnTunnelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchResourceIdFromVpnTunnelName', () => { - const result = client.matchResourceIdFromVpnTunnelName(fakePath); - assert.strictEqual(result, "resourceIdValue"); - assert((client.pathTemplates.vpnTunnelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('vpnTunnel', async () => { + const fakePath = '/rendered/path/vpnTunnel'; + const expectedParameters = { + project: 'projectValue', + region: 'regionValue', + resource_id: 'resourceIdValue', + }; + const client = new hubserviceModule.v1alpha1.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.vpnTunnelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.vpnTunnelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('vpnTunnelPath', () => { + const result = client.vpnTunnelPath( + 'projectValue', + 'regionValue', + 'resourceIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.vpnTunnelPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromVpnTunnelName', () => { + const result = client.matchProjectFromVpnTunnelName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.vpnTunnelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRegionFromVpnTunnelName', () => { + const result = client.matchRegionFromVpnTunnelName(fakePath); + assert.strictEqual(result, 'regionValue'); + assert( + (client.pathTemplates.vpnTunnelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchResourceIdFromVpnTunnelName', () => { + const result = client.matchResourceIdFromVpnTunnelName(fakePath); + assert.strictEqual(result, 'resourceIdValue'); + assert( + (client.pathTemplates.vpnTunnelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-networkconnectivity/test/gapic_hub_service_v1beta.ts b/packages/google-cloud-networkconnectivity/test/gapic_hub_service_v1beta.ts index 14dbe8cb5d9e..4d3dfde14589 100644 --- a/packages/google-cloud-networkconnectivity/test/gapic_hub_service_v1beta.ts +++ b/packages/google-cloud-networkconnectivity/test/gapic_hub_service_v1beta.ts @@ -19,6559 +19,8628 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as hubserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + IamProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1beta.HubServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new hubserviceModule.v1beta.HubServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new hubserviceModule.v1beta.HubServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = hubserviceModule.v1beta.HubServiceClient.servicePath; - assert.strictEqual(servicePath, 'networkconnectivity.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = hubserviceModule.v1beta.HubServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new hubserviceModule.v1beta.HubServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new hubserviceModule.v1beta.HubServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new hubserviceModule.v1beta.HubServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new hubserviceModule.v1beta.HubServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new hubserviceModule.v1beta.HubServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = hubserviceModule.v1beta.HubServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new hubserviceModule.v1beta.HubServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.hubServiceStub, undefined); - await client.initialize(); - assert(client.hubServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.hubServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has close method for the non-initialized client', done => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.hubServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new hubserviceModule.v1beta.HubServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); }); - describe('getHub', () => { - it('invokes getHub without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetHubRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.Hub() - ); - client.innerApiCalls.getHub = stubSimpleCall(expectedResponse); - const [response] = await client.getHub(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getHub without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetHubRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.Hub() - ); - client.innerApiCalls.getHub = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getHub( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1beta.IHub|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getHub with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetHubRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getHub = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getHub(request), expectedError); - const actualRequest = (client.innerApiCalls.getHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getHub with closed client', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetHubRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getHub(request), expectedError); - }); + it('has universeDomain', () => { + const client = new hubserviceModule.v1beta.HubServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); }); - describe('getSpoke', () => { - it('invokes getSpoke without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.Spoke() - ); - client.innerApiCalls.getSpoke = stubSimpleCall(expectedResponse); - const [response] = await client.getSpoke(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getSpoke without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.Spoke() - ); - client.innerApiCalls.getSpoke = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getSpoke( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1beta.ISpoke|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getSpoke with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getSpoke = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getSpoke(request), expectedError); - const actualRequest = (client.innerApiCalls.getSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getSpoke with closed client', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getSpoke(request), expectedError); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + hubserviceModule.v1beta.HubServiceClient.servicePath; + assert.strictEqual(servicePath, 'networkconnectivity.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + hubserviceModule.v1beta.HubServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkconnectivity.example.com'); }); - describe('getRouteTable', () => { - it('invokes getRouteTable without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetRouteTableRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetRouteTableRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.RouteTable() - ); - client.innerApiCalls.getRouteTable = stubSimpleCall(expectedResponse); - const [response] = await client.getRouteTable(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRouteTable as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRouteTable as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRouteTable without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetRouteTableRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetRouteTableRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.RouteTable() - ); - client.innerApiCalls.getRouteTable = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getRouteTable( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1beta.IRouteTable|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRouteTable as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRouteTable as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkconnectivity.example.com'); + }); - it('invokes getRouteTable with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetRouteTableRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetRouteTableRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getRouteTable = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getRouteTable(request), expectedError); - const actualRequest = (client.innerApiCalls.getRouteTable as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRouteTable as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new hubserviceModule.v1beta.HubServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkconnectivity.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new hubserviceModule.v1beta.HubServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'networkconnectivity.configured.example.com', + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new hubserviceModule.v1beta.HubServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('invokes getRouteTable with closed client', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetRouteTableRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetRouteTableRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getRouteTable(request), expectedError); - }); + it('has port', () => { + const port = hubserviceModule.v1beta.HubServiceClient.port; + assert(port); + assert(typeof port === 'number'); }); - describe('getRoute', () => { - it('invokes getRoute without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.Route() - ); - client.innerApiCalls.getRoute = stubSimpleCall(expectedResponse); - const [response] = await client.getRoute(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('should create a client with no option', () => { + const client = new hubserviceModule.v1beta.HubServiceClient(); + assert(client); + }); - it('invokes getRoute without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.Route() - ); - client.innerApiCalls.getRoute = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getRoute( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1beta.IRoute|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('should create a client with gRPC fallback', () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + fallback: true, + }); + assert(client); + }); - it('invokes getRoute with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getRoute = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getRoute(request), expectedError); - const actualRequest = (client.innerApiCalls.getRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.hubServiceStub, undefined); + await client.initialize(); + assert(client.hubServiceStub); + }); - it('invokes getRoute with closed client', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetRouteRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getRoute(request), expectedError); + it('has close method for the initialized client', (done) => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.hubServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('getGroup', () => { - it('invokes getGroup without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetGroupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.Group() - ); - client.innerApiCalls.getGroup = stubSimpleCall(expectedResponse); - const [response] = await client.getGroup(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the non-initialized client', (done) => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.hubServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getGroup without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetGroupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.Group() - ); - client.innerApiCalls.getGroup = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getGroup( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1beta.IGroup|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('invokes getGroup with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetGroupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getGroup = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getGroup(request), expectedError); - const actualRequest = (client.innerApiCalls.getGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getHub', () => { + it('invokes getHub without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetHubRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Hub(), + ); + client.innerApiCalls.getHub = stubSimpleCall(expectedResponse); + const [response] = await client.getHub(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getHub as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getGroup with closed client', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetGroupRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getGroup(request), expectedError); - }); + it('invokes getHub without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetHubRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Hub(), + ); + client.innerApiCalls.getHub = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getHub( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1beta.IHub | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getHub as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getGatewayAdvertisedRoute', () => { - it('invokes getGatewayAdvertisedRoute without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetGatewayAdvertisedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetGatewayAdvertisedRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute() - ); - client.innerApiCalls.getGatewayAdvertisedRoute = stubSimpleCall(expectedResponse); - const [response] = await client.getGatewayAdvertisedRoute(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getGatewayAdvertisedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getGatewayAdvertisedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getHub with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetHubRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getHub = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getHub(request), expectedError); + const actualRequest = (client.innerApiCalls.getHub as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getGatewayAdvertisedRoute without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetGatewayAdvertisedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetGatewayAdvertisedRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute() - ); - client.innerApiCalls.getGatewayAdvertisedRoute = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getGatewayAdvertisedRoute( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getGatewayAdvertisedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getGatewayAdvertisedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getHub with closed client', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetHubRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getHub(request), expectedError); + }); + }); + + describe('getSpoke', () => { + it('invokes getSpoke without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Spoke(), + ); + client.innerApiCalls.getSpoke = stubSimpleCall(expectedResponse); + const [response] = await client.getSpoke(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getGatewayAdvertisedRoute with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetGatewayAdvertisedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetGatewayAdvertisedRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getGatewayAdvertisedRoute = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getGatewayAdvertisedRoute(request), expectedError); - const actualRequest = (client.innerApiCalls.getGatewayAdvertisedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getGatewayAdvertisedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getSpoke without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Spoke(), + ); + client.innerApiCalls.getSpoke = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getSpoke( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1beta.ISpoke | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getGatewayAdvertisedRoute with closed client', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetGatewayAdvertisedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetGatewayAdvertisedRouteRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getGatewayAdvertisedRoute(request), expectedError); - }); + it('invokes getSpoke with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getSpoke = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getSpoke(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createHub', () => { - it('invokes createHub without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.CreateHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.CreateHubRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createHub = stubLongRunningCall(expectedResponse); - const [operation] = await client.createHub(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getSpoke with closed client', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getSpoke(request), expectedError); + }); + }); + + describe('getRouteTable', () => { + it('invokes getRouteTable without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetRouteTableRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetRouteTableRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RouteTable(), + ); + client.innerApiCalls.getRouteTable = stubSimpleCall(expectedResponse); + const [response] = await client.getRouteTable(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getRouteTable as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getRouteTable as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createHub without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.CreateHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.CreateHubRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createHub = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createHub( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getRouteTable without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetRouteTableRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetRouteTableRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RouteTable(), + ); + client.innerApiCalls.getRouteTable = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getRouteTable( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1beta.IRouteTable | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getRouteTable as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getRouteTable as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createHub with call error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.CreateHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.CreateHubRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createHub = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createHub(request), expectedError); - const actualRequest = (client.innerApiCalls.createHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getRouteTable with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetRouteTableRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetRouteTableRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getRouteTable = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getRouteTable(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getRouteTable as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getRouteTable as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createHub with LRO error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.CreateHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.CreateHubRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createHub = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createHub(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getRouteTable with closed client', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetRouteTableRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetRouteTableRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getRouteTable(request), expectedError); + }); + }); + + describe('getRoute', () => { + it('invokes getRoute without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Route(), + ); + client.innerApiCalls.getRoute = stubSimpleCall(expectedResponse); + const [response] = await client.getRoute(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateHubProgress without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateHubProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes getRoute without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Route(), + ); + client.innerApiCalls.getRoute = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getRoute( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1beta.IRoute | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateHubProgress with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateHubProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes getRoute with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getRoute = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getRoute(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateHub', () => { - it('invokes updateHub without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.UpdateHubRequest() - ); - request.hub ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.UpdateHubRequest', ['hub', 'name']); - request.hub.name = defaultValue1; - const expectedHeaderRequestParams = `hub.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateHub = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateHub(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getRoute with closed client', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getRoute(request), expectedError); + }); + }); + + describe('getGroup', () => { + it('invokes getGroup without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Group(), + ); + client.innerApiCalls.getGroup = stubSimpleCall(expectedResponse); + const [response] = await client.getGroup(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateHub without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.UpdateHubRequest() - ); - request.hub ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.UpdateHubRequest', ['hub', 'name']); - request.hub.name = defaultValue1; - const expectedHeaderRequestParams = `hub.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateHub = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateHub( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getGroup without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Group(), + ); + client.innerApiCalls.getGroup = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getGroup( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1beta.IGroup | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateHub with call error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.UpdateHubRequest() - ); - request.hub ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.UpdateHubRequest', ['hub', 'name']); - request.hub.name = defaultValue1; - const expectedHeaderRequestParams = `hub.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateHub = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateHub(request), expectedError); - const actualRequest = (client.innerApiCalls.updateHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getGroup with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getGroup = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getGroup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateHub with LRO error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.UpdateHubRequest() - ); - request.hub ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.UpdateHubRequest', ['hub', 'name']); - request.hub.name = defaultValue1; - const expectedHeaderRequestParams = `hub.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateHub = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateHub(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getGroup with closed client', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getGroup(request), expectedError); + }); + }); + + describe('getGatewayAdvertisedRoute', () => { + it('invokes getGatewayAdvertisedRoute without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetGatewayAdvertisedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetGatewayAdvertisedRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute(), + ); + client.innerApiCalls.getGatewayAdvertisedRoute = + stubSimpleCall(expectedResponse); + const [response] = await client.getGatewayAdvertisedRoute(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getGatewayAdvertisedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getGatewayAdvertisedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateHubProgress without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateHubProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes getGatewayAdvertisedRoute without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetGatewayAdvertisedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetGatewayAdvertisedRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute(), + ); + client.innerApiCalls.getGatewayAdvertisedRoute = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getGatewayAdvertisedRoute( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getGatewayAdvertisedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getGatewayAdvertisedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateHubProgress with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateHubProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes getGatewayAdvertisedRoute with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetGatewayAdvertisedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetGatewayAdvertisedRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getGatewayAdvertisedRoute = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getGatewayAdvertisedRoute(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.getGatewayAdvertisedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getGatewayAdvertisedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteHub', () => { - it('invokes deleteHub without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.DeleteHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.DeleteHubRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteHub = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteHub(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getGatewayAdvertisedRoute with closed client', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetGatewayAdvertisedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetGatewayAdvertisedRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.getGatewayAdvertisedRoute(request), + expectedError, + ); + }); + }); + + describe('createHub', () => { + it('invokes createHub without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.CreateHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.CreateHubRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createHub = stubLongRunningCall(expectedResponse); + const [operation] = await client.createHub(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteHub without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.DeleteHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.DeleteHubRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteHub = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteHub( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createHub without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.CreateHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.CreateHubRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createHub = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createHub( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1beta.IHub, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1beta.IHub, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteHub with call error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.DeleteHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.DeleteHubRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteHub = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteHub(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createHub with call error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.CreateHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.CreateHubRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createHub = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createHub(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteHub with LRO error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.DeleteHubRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.DeleteHubRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteHub = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteHub(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteHub as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteHub as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createHub with LRO error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.CreateHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.CreateHubRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createHub = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createHub(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteHubProgress without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteHubProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkCreateHubProgress without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateHubProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteHubProgress with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteHubProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateHubProgress with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkCreateHubProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateHub', () => { + it('invokes updateHub without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.UpdateHubRequest(), + ); + request.hub ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.UpdateHubRequest', + ['hub', 'name'], + ); + request.hub.name = defaultValue1; + const expectedHeaderRequestParams = `hub.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateHub = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateHub(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createSpoke', () => { - it('invokes createSpoke without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.CreateSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.CreateSpokeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createSpoke = stubLongRunningCall(expectedResponse); - const [operation] = await client.createSpoke(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateHub without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.UpdateHubRequest(), + ); + request.hub ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.UpdateHubRequest', + ['hub', 'name'], + ); + request.hub.name = defaultValue1; + const expectedHeaderRequestParams = `hub.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateHub = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateHub( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1beta.IHub, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1beta.IHub, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createSpoke without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.CreateSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.CreateSpokeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createSpoke = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createSpoke( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateHub with call error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.UpdateHubRequest(), + ); + request.hub ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.UpdateHubRequest', + ['hub', 'name'], + ); + request.hub.name = defaultValue1; + const expectedHeaderRequestParams = `hub.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateHub = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateHub(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createSpoke with call error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.CreateSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.CreateSpokeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createSpoke = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createSpoke(request), expectedError); - const actualRequest = (client.innerApiCalls.createSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateHub with LRO error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.UpdateHubRequest(), + ); + request.hub ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.UpdateHubRequest', + ['hub', 'name'], + ); + request.hub.name = defaultValue1; + const expectedHeaderRequestParams = `hub.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateHub = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateHub(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createSpoke with LRO error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.CreateSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.CreateSpokeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createSpoke = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createSpoke(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateHubProgress without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateHubProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkCreateSpokeProgress without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateSpokeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateHubProgress with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkUpdateHubProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteHub', () => { + it('invokes deleteHub without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.DeleteHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.DeleteHubRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteHub = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteHub(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateSpokeProgress with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateSpokeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteHub without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.DeleteHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.DeleteHubRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteHub = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteHub( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateSpoke', () => { - it('invokes updateSpoke without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.UpdateSpokeRequest() - ); - request.spoke ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.UpdateSpokeRequest', ['spoke', 'name']); - request.spoke.name = defaultValue1; - const expectedHeaderRequestParams = `spoke.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateSpoke = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateSpoke(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteHub with call error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.DeleteHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.DeleteHubRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteHub = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteHub(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateSpoke without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.UpdateSpokeRequest() - ); - request.spoke ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.UpdateSpokeRequest', ['spoke', 'name']); - request.spoke.name = defaultValue1; - const expectedHeaderRequestParams = `spoke.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateSpoke = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateSpoke( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteHub with LRO error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.DeleteHubRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.DeleteHubRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteHub = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteHub(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteHub as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteHub as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateSpoke with call error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.UpdateSpokeRequest() - ); - request.spoke ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.UpdateSpokeRequest', ['spoke', 'name']); - request.spoke.name = defaultValue1; - const expectedHeaderRequestParams = `spoke.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateSpoke = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateSpoke(request), expectedError); - const actualRequest = (client.innerApiCalls.updateSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteHubProgress without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteHubProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateSpoke with LRO error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.UpdateSpokeRequest() - ); - request.spoke ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.UpdateSpokeRequest', ['spoke', 'name']); - request.spoke.name = defaultValue1; - const expectedHeaderRequestParams = `spoke.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateSpoke = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateSpoke(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteHubProgress with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkDeleteHubProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createSpoke', () => { + it('invokes createSpoke without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.CreateSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.CreateSpokeRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createSpoke = stubLongRunningCall(expectedResponse); + const [operation] = await client.createSpoke(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateSpokeProgress without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateSpokeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createSpoke without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.CreateSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.CreateSpokeRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createSpoke = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createSpoke( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1beta.ISpoke, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1beta.ISpoke, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateSpokeProgress with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateSpokeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createSpoke with call error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.CreateSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.CreateSpokeRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createSpoke = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createSpoke(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('rejectHubSpoke', () => { - it('invokes rejectHubSpoke without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.RejectHubSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.RejectHubSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.rejectHubSpoke = stubLongRunningCall(expectedResponse); - const [operation] = await client.rejectHubSpoke(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rejectHubSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rejectHubSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createSpoke with LRO error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.CreateSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.CreateSpokeRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createSpoke = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createSpoke(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes rejectHubSpoke without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.RejectHubSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.RejectHubSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.rejectHubSpoke = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rejectHubSpoke( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rejectHubSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rejectHubSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateSpokeProgress without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateSpokeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes rejectHubSpoke with call error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.RejectHubSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.RejectHubSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rejectHubSpoke = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.rejectHubSpoke(request), expectedError); - const actualRequest = (client.innerApiCalls.rejectHubSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rejectHubSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateSpokeProgress with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkCreateSpokeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateSpoke', () => { + it('invokes updateSpoke without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.UpdateSpokeRequest(), + ); + request.spoke ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.UpdateSpokeRequest', + ['spoke', 'name'], + ); + request.spoke.name = defaultValue1; + const expectedHeaderRequestParams = `spoke.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateSpoke = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateSpoke(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes rejectHubSpoke with LRO error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.RejectHubSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.RejectHubSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rejectHubSpoke = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.rejectHubSpoke(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.rejectHubSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rejectHubSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateSpoke without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.UpdateSpokeRequest(), + ); + request.spoke ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.UpdateSpokeRequest', + ['spoke', 'name'], + ); + request.spoke.name = defaultValue1; + const expectedHeaderRequestParams = `spoke.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateSpoke = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateSpoke( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1beta.ISpoke, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1beta.ISpoke, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRejectHubSpokeProgress without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkRejectHubSpokeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateSpoke with call error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.UpdateSpokeRequest(), + ); + request.spoke ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.UpdateSpokeRequest', + ['spoke', 'name'], + ); + request.spoke.name = defaultValue1; + const expectedHeaderRequestParams = `spoke.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateSpoke = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateSpoke(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRejectHubSpokeProgress with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRejectHubSpokeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateSpoke with LRO error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.UpdateSpokeRequest(), + ); + request.spoke ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.UpdateSpokeRequest', + ['spoke', 'name'], + ); + request.spoke.name = defaultValue1; + const expectedHeaderRequestParams = `spoke.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateSpoke = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateSpoke(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('acceptHubSpoke', () => { - it('invokes acceptHubSpoke without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.AcceptHubSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.AcceptHubSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.acceptHubSpoke = stubLongRunningCall(expectedResponse); - const [operation] = await client.acceptHubSpoke(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.acceptHubSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.acceptHubSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateSpokeProgress without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateSpokeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes acceptHubSpoke without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.AcceptHubSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.AcceptHubSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.acceptHubSpoke = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.acceptHubSpoke( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.acceptHubSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.acceptHubSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateSpokeProgress with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkUpdateSpokeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('rejectHubSpoke', () => { + it('invokes rejectHubSpoke without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RejectHubSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.RejectHubSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.rejectHubSpoke = + stubLongRunningCall(expectedResponse); + const [operation] = await client.rejectHubSpoke(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rejectHubSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rejectHubSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes acceptHubSpoke with call error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.AcceptHubSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.AcceptHubSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.acceptHubSpoke = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.acceptHubSpoke(request), expectedError); - const actualRequest = (client.innerApiCalls.acceptHubSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.acceptHubSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes rejectHubSpoke without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RejectHubSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.RejectHubSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.rejectHubSpoke = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rejectHubSpoke( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1beta.IRejectHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1beta.IRejectHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rejectHubSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rejectHubSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes acceptHubSpoke with LRO error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.AcceptHubSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.AcceptHubSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.acceptHubSpoke = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.acceptHubSpoke(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.acceptHubSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.acceptHubSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes rejectHubSpoke with call error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RejectHubSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.RejectHubSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rejectHubSpoke = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.rejectHubSpoke(request), expectedError); + const actualRequest = ( + client.innerApiCalls.rejectHubSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rejectHubSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkAcceptHubSpokeProgress without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkAcceptHubSpokeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes rejectHubSpoke with LRO error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RejectHubSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.RejectHubSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rejectHubSpoke = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.rejectHubSpoke(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.rejectHubSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rejectHubSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkAcceptHubSpokeProgress with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkAcceptHubSpokeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkRejectHubSpokeProgress without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkRejectHubSpokeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('acceptSpokeUpdate', () => { - it('invokes acceptSpokeUpdate without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.AcceptSpokeUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.AcceptSpokeUpdateRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.acceptSpokeUpdate = stubLongRunningCall(expectedResponse); - const [operation] = await client.acceptSpokeUpdate(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.acceptSpokeUpdate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.acceptSpokeUpdate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRejectHubSpokeProgress with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkRejectHubSpokeProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('acceptHubSpoke', () => { + it('invokes acceptHubSpoke without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.AcceptHubSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.AcceptHubSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.acceptHubSpoke = + stubLongRunningCall(expectedResponse); + const [operation] = await client.acceptHubSpoke(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.acceptHubSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.acceptHubSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes acceptSpokeUpdate without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.AcceptSpokeUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.AcceptSpokeUpdateRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.acceptSpokeUpdate = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.acceptSpokeUpdate( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.acceptSpokeUpdate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.acceptSpokeUpdate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes acceptHubSpoke without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.AcceptHubSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.AcceptHubSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.acceptHubSpoke = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.acceptHubSpoke( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1beta.IAcceptHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1beta.IAcceptHubSpokeResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.acceptHubSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.acceptHubSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes acceptSpokeUpdate with call error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.AcceptSpokeUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.AcceptSpokeUpdateRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.acceptSpokeUpdate = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.acceptSpokeUpdate(request), expectedError); - const actualRequest = (client.innerApiCalls.acceptSpokeUpdate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.acceptSpokeUpdate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes acceptHubSpoke with call error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.AcceptHubSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.AcceptHubSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.acceptHubSpoke = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.acceptHubSpoke(request), expectedError); + const actualRequest = ( + client.innerApiCalls.acceptHubSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.acceptHubSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes acceptSpokeUpdate with LRO error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.AcceptSpokeUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.AcceptSpokeUpdateRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.acceptSpokeUpdate = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.acceptSpokeUpdate(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.acceptSpokeUpdate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.acceptSpokeUpdate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes acceptHubSpoke with LRO error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.AcceptHubSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.AcceptHubSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.acceptHubSpoke = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.acceptHubSpoke(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.acceptHubSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.acceptHubSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkAcceptSpokeUpdateProgress without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkAcceptSpokeUpdateProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkAcceptHubSpokeProgress without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkAcceptHubSpokeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkAcceptSpokeUpdateProgress with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkAcceptSpokeUpdateProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkAcceptHubSpokeProgress with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkAcceptHubSpokeProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('acceptSpokeUpdate', () => { + it('invokes acceptSpokeUpdate without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.AcceptSpokeUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.AcceptSpokeUpdateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.acceptSpokeUpdate = + stubLongRunningCall(expectedResponse); + const [operation] = await client.acceptSpokeUpdate(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.acceptSpokeUpdate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.acceptSpokeUpdate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('rejectSpokeUpdate', () => { - it('invokes rejectSpokeUpdate without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.RejectSpokeUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.RejectSpokeUpdateRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.rejectSpokeUpdate = stubLongRunningCall(expectedResponse); - const [operation] = await client.rejectSpokeUpdate(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rejectSpokeUpdate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rejectSpokeUpdate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes acceptSpokeUpdate without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.AcceptSpokeUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.AcceptSpokeUpdateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.acceptSpokeUpdate = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.acceptSpokeUpdate( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1beta.IAcceptSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1beta.IAcceptSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.acceptSpokeUpdate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.acceptSpokeUpdate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes rejectSpokeUpdate without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.RejectSpokeUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.RejectSpokeUpdateRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.rejectSpokeUpdate = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rejectSpokeUpdate( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rejectSpokeUpdate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rejectSpokeUpdate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes acceptSpokeUpdate with call error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.AcceptSpokeUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.AcceptSpokeUpdateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.acceptSpokeUpdate = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.acceptSpokeUpdate(request), expectedError); + const actualRequest = ( + client.innerApiCalls.acceptSpokeUpdate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.acceptSpokeUpdate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes rejectSpokeUpdate with call error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.RejectSpokeUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.RejectSpokeUpdateRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rejectSpokeUpdate = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.rejectSpokeUpdate(request), expectedError); - const actualRequest = (client.innerApiCalls.rejectSpokeUpdate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rejectSpokeUpdate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes acceptSpokeUpdate with LRO error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.AcceptSpokeUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.AcceptSpokeUpdateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.acceptSpokeUpdate = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.acceptSpokeUpdate(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.acceptSpokeUpdate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.acceptSpokeUpdate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes rejectSpokeUpdate with LRO error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.RejectSpokeUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.RejectSpokeUpdateRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rejectSpokeUpdate = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.rejectSpokeUpdate(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.rejectSpokeUpdate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rejectSpokeUpdate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkAcceptSpokeUpdateProgress without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkAcceptSpokeUpdateProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkRejectSpokeUpdateProgress without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkRejectSpokeUpdateProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkAcceptSpokeUpdateProgress with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkAcceptSpokeUpdateProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('rejectSpokeUpdate', () => { + it('invokes rejectSpokeUpdate without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RejectSpokeUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.RejectSpokeUpdateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.rejectSpokeUpdate = + stubLongRunningCall(expectedResponse); + const [operation] = await client.rejectSpokeUpdate(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rejectSpokeUpdate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rejectSpokeUpdate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRejectSpokeUpdateProgress with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRejectSpokeUpdateProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes rejectSpokeUpdate without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RejectSpokeUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.RejectSpokeUpdateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.rejectSpokeUpdate = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rejectSpokeUpdate( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1beta.IRejectSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1beta.IRejectSpokeUpdateResponse, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rejectSpokeUpdate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rejectSpokeUpdate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteSpoke', () => { - it('invokes deleteSpoke without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.DeleteSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.DeleteSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteSpoke = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteSpoke(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes rejectSpokeUpdate with call error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RejectSpokeUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.RejectSpokeUpdateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rejectSpokeUpdate = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.rejectSpokeUpdate(request), expectedError); + const actualRequest = ( + client.innerApiCalls.rejectSpokeUpdate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rejectSpokeUpdate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteSpoke without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.DeleteSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.DeleteSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteSpoke = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteSpoke( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes rejectSpokeUpdate with LRO error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RejectSpokeUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.RejectSpokeUpdateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rejectSpokeUpdate = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.rejectSpokeUpdate(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.rejectSpokeUpdate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rejectSpokeUpdate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteSpoke with call error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.DeleteSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.DeleteSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteSpoke = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteSpoke(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRejectSpokeUpdateProgress without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkRejectSpokeUpdateProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteSpoke with LRO error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.DeleteSpokeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.DeleteSpokeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteSpoke = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteSpoke(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteSpoke as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSpoke as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRejectSpokeUpdateProgress with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkRejectSpokeUpdateProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteSpoke', () => { + it('invokes deleteSpoke without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.DeleteSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.DeleteSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteSpoke = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteSpoke(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteSpokeProgress without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteSpokeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteSpoke without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.DeleteSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.DeleteSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteSpoke = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteSpoke( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteSpokeProgress with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteSpokeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteSpoke with call error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.DeleteSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.DeleteSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteSpoke = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteSpoke(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateGroup', () => { - it('invokes updateGroup without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.UpdateGroupRequest() - ); - request.group ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.UpdateGroupRequest', ['group', 'name']); - request.group.name = defaultValue1; - const expectedHeaderRequestParams = `group.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateGroup = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateGroup(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteSpoke with LRO error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.DeleteSpokeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.DeleteSpokeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteSpoke = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteSpoke(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteSpoke as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSpoke as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateGroup without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.UpdateGroupRequest() - ); - request.group ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.UpdateGroupRequest', ['group', 'name']); - request.group.name = defaultValue1; - const expectedHeaderRequestParams = `group.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateGroup = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateGroup( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteSpokeProgress without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteSpokeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateGroup with call error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.UpdateGroupRequest() - ); - request.group ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.UpdateGroupRequest', ['group', 'name']); - request.group.name = defaultValue1; - const expectedHeaderRequestParams = `group.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateGroup = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateGroup(request), expectedError); - const actualRequest = (client.innerApiCalls.updateGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteSpokeProgress with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkDeleteSpokeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateGroup', () => { + it('invokes updateGroup without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.UpdateGroupRequest(), + ); + request.group ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.UpdateGroupRequest', + ['group', 'name'], + ); + request.group.name = defaultValue1; + const expectedHeaderRequestParams = `group.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateGroup = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateGroup(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateGroup with LRO error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.UpdateGroupRequest() - ); - request.group ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.UpdateGroupRequest', ['group', 'name']); - request.group.name = defaultValue1; - const expectedHeaderRequestParams = `group.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateGroup = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateGroup(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateGroup without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.UpdateGroupRequest(), + ); + request.group ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.UpdateGroupRequest', + ['group', 'name'], + ); + request.group.name = defaultValue1; + const expectedHeaderRequestParams = `group.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateGroup = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateGroup( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1beta.IGroup, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1beta.IGroup, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateGroupProgress without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateGroupProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateGroup with call error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.UpdateGroupRequest(), + ); + request.group ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.UpdateGroupRequest', + ['group', 'name'], + ); + request.group.name = defaultValue1; + const expectedHeaderRequestParams = `group.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateGroup = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateGroup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateGroupProgress with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateGroupProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateGroup with LRO error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.UpdateGroupRequest(), + ); + request.group ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.UpdateGroupRequest', + ['group', 'name'], + ); + request.group.name = defaultValue1; + const expectedHeaderRequestParams = `group.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateGroup = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateGroup(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createGatewayAdvertisedRoute', () => { - it('invokes createGatewayAdvertisedRoute without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.CreateGatewayAdvertisedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.CreateGatewayAdvertisedRouteRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createGatewayAdvertisedRoute = stubLongRunningCall(expectedResponse); - const [operation] = await client.createGatewayAdvertisedRoute(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createGatewayAdvertisedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createGatewayAdvertisedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateGroupProgress without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateGroupProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createGatewayAdvertisedRoute without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.CreateGatewayAdvertisedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.CreateGatewayAdvertisedRouteRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createGatewayAdvertisedRoute = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createGatewayAdvertisedRoute( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createGatewayAdvertisedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createGatewayAdvertisedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateGroupProgress with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkUpdateGroupProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createGatewayAdvertisedRoute', () => { + it('invokes createGatewayAdvertisedRoute without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.CreateGatewayAdvertisedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.CreateGatewayAdvertisedRouteRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createGatewayAdvertisedRoute = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createGatewayAdvertisedRoute(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createGatewayAdvertisedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createGatewayAdvertisedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createGatewayAdvertisedRoute with call error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.CreateGatewayAdvertisedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.CreateGatewayAdvertisedRouteRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createGatewayAdvertisedRoute = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createGatewayAdvertisedRoute(request), expectedError); - const actualRequest = (client.innerApiCalls.createGatewayAdvertisedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createGatewayAdvertisedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createGatewayAdvertisedRoute without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.CreateGatewayAdvertisedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.CreateGatewayAdvertisedRouteRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createGatewayAdvertisedRoute = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createGatewayAdvertisedRoute( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createGatewayAdvertisedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createGatewayAdvertisedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createGatewayAdvertisedRoute with LRO error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.CreateGatewayAdvertisedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.CreateGatewayAdvertisedRouteRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createGatewayAdvertisedRoute = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createGatewayAdvertisedRoute(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createGatewayAdvertisedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createGatewayAdvertisedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createGatewayAdvertisedRoute with call error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.CreateGatewayAdvertisedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.CreateGatewayAdvertisedRouteRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createGatewayAdvertisedRoute = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.createGatewayAdvertisedRoute(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createGatewayAdvertisedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createGatewayAdvertisedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateGatewayAdvertisedRouteProgress without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateGatewayAdvertisedRouteProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createGatewayAdvertisedRoute with LRO error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.CreateGatewayAdvertisedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.CreateGatewayAdvertisedRouteRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createGatewayAdvertisedRoute = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createGatewayAdvertisedRoute(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createGatewayAdvertisedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createGatewayAdvertisedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateGatewayAdvertisedRouteProgress with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateGatewayAdvertisedRouteProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateGatewayAdvertisedRouteProgress without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateGatewayAdvertisedRouteProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('updateGatewayAdvertisedRoute', () => { - it('invokes updateGatewayAdvertisedRoute without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.UpdateGatewayAdvertisedRouteRequest() - ); - request.gatewayAdvertisedRoute ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.UpdateGatewayAdvertisedRouteRequest', ['gatewayAdvertisedRoute', 'name']); - request.gatewayAdvertisedRoute.name = defaultValue1; - const expectedHeaderRequestParams = `gateway_advertised_route.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateGatewayAdvertisedRoute = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateGatewayAdvertisedRoute(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateGatewayAdvertisedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateGatewayAdvertisedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateGatewayAdvertisedRouteProgress with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateGatewayAdvertisedRouteProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateGatewayAdvertisedRoute', () => { + it('invokes updateGatewayAdvertisedRoute without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.UpdateGatewayAdvertisedRouteRequest(), + ); + request.gatewayAdvertisedRoute ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.UpdateGatewayAdvertisedRouteRequest', + ['gatewayAdvertisedRoute', 'name'], + ); + request.gatewayAdvertisedRoute.name = defaultValue1; + const expectedHeaderRequestParams = `gateway_advertised_route.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateGatewayAdvertisedRoute = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateGatewayAdvertisedRoute(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateGatewayAdvertisedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateGatewayAdvertisedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateGatewayAdvertisedRoute without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.UpdateGatewayAdvertisedRouteRequest() - ); - request.gatewayAdvertisedRoute ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.UpdateGatewayAdvertisedRouteRequest', ['gatewayAdvertisedRoute', 'name']); - request.gatewayAdvertisedRoute.name = defaultValue1; - const expectedHeaderRequestParams = `gateway_advertised_route.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateGatewayAdvertisedRoute = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateGatewayAdvertisedRoute( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateGatewayAdvertisedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateGatewayAdvertisedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateGatewayAdvertisedRoute without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.UpdateGatewayAdvertisedRouteRequest(), + ); + request.gatewayAdvertisedRoute ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.UpdateGatewayAdvertisedRouteRequest', + ['gatewayAdvertisedRoute', 'name'], + ); + request.gatewayAdvertisedRoute.name = defaultValue1; + const expectedHeaderRequestParams = `gateway_advertised_route.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateGatewayAdvertisedRoute = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateGatewayAdvertisedRoute( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateGatewayAdvertisedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateGatewayAdvertisedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateGatewayAdvertisedRoute with call error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.UpdateGatewayAdvertisedRouteRequest() - ); - request.gatewayAdvertisedRoute ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.UpdateGatewayAdvertisedRouteRequest', ['gatewayAdvertisedRoute', 'name']); - request.gatewayAdvertisedRoute.name = defaultValue1; - const expectedHeaderRequestParams = `gateway_advertised_route.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateGatewayAdvertisedRoute = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateGatewayAdvertisedRoute(request), expectedError); - const actualRequest = (client.innerApiCalls.updateGatewayAdvertisedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateGatewayAdvertisedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateGatewayAdvertisedRoute with call error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.UpdateGatewayAdvertisedRouteRequest(), + ); + request.gatewayAdvertisedRoute ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.UpdateGatewayAdvertisedRouteRequest', + ['gatewayAdvertisedRoute', 'name'], + ); + request.gatewayAdvertisedRoute.name = defaultValue1; + const expectedHeaderRequestParams = `gateway_advertised_route.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateGatewayAdvertisedRoute = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.updateGatewayAdvertisedRoute(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.updateGatewayAdvertisedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateGatewayAdvertisedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateGatewayAdvertisedRoute with LRO error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.UpdateGatewayAdvertisedRouteRequest() - ); - request.gatewayAdvertisedRoute ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.UpdateGatewayAdvertisedRouteRequest', ['gatewayAdvertisedRoute', 'name']); - request.gatewayAdvertisedRoute.name = defaultValue1; - const expectedHeaderRequestParams = `gateway_advertised_route.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateGatewayAdvertisedRoute = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateGatewayAdvertisedRoute(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateGatewayAdvertisedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateGatewayAdvertisedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateGatewayAdvertisedRoute with LRO error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.UpdateGatewayAdvertisedRouteRequest(), + ); + request.gatewayAdvertisedRoute ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.UpdateGatewayAdvertisedRouteRequest', + ['gatewayAdvertisedRoute', 'name'], + ); + request.gatewayAdvertisedRoute.name = defaultValue1; + const expectedHeaderRequestParams = `gateway_advertised_route.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateGatewayAdvertisedRoute = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateGatewayAdvertisedRoute(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateGatewayAdvertisedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateGatewayAdvertisedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateGatewayAdvertisedRouteProgress without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateGatewayAdvertisedRouteProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateGatewayAdvertisedRouteProgress without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateGatewayAdvertisedRouteProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkUpdateGatewayAdvertisedRouteProgress with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateGatewayAdvertisedRouteProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpdateGatewayAdvertisedRouteProgress with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateGatewayAdvertisedRouteProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteGatewayAdvertisedRoute', () => { + it('invokes deleteGatewayAdvertisedRoute without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.DeleteGatewayAdvertisedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.DeleteGatewayAdvertisedRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteGatewayAdvertisedRoute = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteGatewayAdvertisedRoute(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteGatewayAdvertisedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteGatewayAdvertisedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteGatewayAdvertisedRoute', () => { - it('invokes deleteGatewayAdvertisedRoute without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.DeleteGatewayAdvertisedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.DeleteGatewayAdvertisedRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteGatewayAdvertisedRoute = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteGatewayAdvertisedRoute(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteGatewayAdvertisedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteGatewayAdvertisedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteGatewayAdvertisedRoute without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.DeleteGatewayAdvertisedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.DeleteGatewayAdvertisedRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteGatewayAdvertisedRoute = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteGatewayAdvertisedRoute( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteGatewayAdvertisedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteGatewayAdvertisedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteGatewayAdvertisedRoute without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.DeleteGatewayAdvertisedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.DeleteGatewayAdvertisedRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteGatewayAdvertisedRoute = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteGatewayAdvertisedRoute( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteGatewayAdvertisedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteGatewayAdvertisedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteGatewayAdvertisedRoute with call error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.DeleteGatewayAdvertisedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.DeleteGatewayAdvertisedRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteGatewayAdvertisedRoute = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.deleteGatewayAdvertisedRoute(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteGatewayAdvertisedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteGatewayAdvertisedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteGatewayAdvertisedRoute with call error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.DeleteGatewayAdvertisedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.DeleteGatewayAdvertisedRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteGatewayAdvertisedRoute = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteGatewayAdvertisedRoute(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteGatewayAdvertisedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteGatewayAdvertisedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteGatewayAdvertisedRoute with LRO error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.DeleteGatewayAdvertisedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.DeleteGatewayAdvertisedRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteGatewayAdvertisedRoute = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteGatewayAdvertisedRoute(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteGatewayAdvertisedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteGatewayAdvertisedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteGatewayAdvertisedRoute with LRO error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.DeleteGatewayAdvertisedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.DeleteGatewayAdvertisedRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteGatewayAdvertisedRoute = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteGatewayAdvertisedRoute(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteGatewayAdvertisedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteGatewayAdvertisedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteGatewayAdvertisedRouteProgress without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteGatewayAdvertisedRouteProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteGatewayAdvertisedRouteProgress without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteGatewayAdvertisedRouteProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkDeleteGatewayAdvertisedRouteProgress with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteGatewayAdvertisedRouteProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listHubs', () => { + it('invokes listHubs without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListHubsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListHubsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Hub(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Hub(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Hub(), + ), + ]; + client.innerApiCalls.listHubs = stubSimpleCall(expectedResponse); + const [response] = await client.listHubs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listHubs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listHubs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteGatewayAdvertisedRouteProgress with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteGatewayAdvertisedRouteProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes listHubs without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListHubsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListHubsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Hub(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Hub(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Hub(), + ), + ]; + client.innerApiCalls.listHubs = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listHubs( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkconnectivity.v1beta.IHub[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listHubs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listHubs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listHubs', () => { - it('invokes listHubs without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListHubsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListHubsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Hub()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Hub()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Hub()), - ]; - client.innerApiCalls.listHubs = stubSimpleCall(expectedResponse); - const [response] = await client.listHubs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listHubs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listHubs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listHubs with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListHubsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListHubsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listHubs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listHubs(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listHubs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listHubs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listHubs without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListHubsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListHubsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Hub()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Hub()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Hub()), - ]; - client.innerApiCalls.listHubs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listHubs( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1beta.IHub[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listHubs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listHubs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listHubsStream without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListHubsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListHubsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Hub(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Hub(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Hub(), + ), + ]; + client.descriptors.page.listHubs.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listHubsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1beta.Hub[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkconnectivity.v1beta.Hub) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listHubs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listHubs, request), + ); + assert( + (client.descriptors.page.listHubs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listHubs with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListHubsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListHubsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listHubs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listHubs(request), expectedError); - const actualRequest = (client.innerApiCalls.listHubs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listHubs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listHubsStream with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListHubsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListHubsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listHubs.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listHubsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1beta.Hub[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkconnectivity.v1beta.Hub) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listHubs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listHubs, request), + ); + assert( + (client.descriptors.page.listHubs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listHubsStream without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListHubsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListHubsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Hub()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Hub()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Hub()), - ]; - client.descriptors.page.listHubs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listHubsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1beta.Hub[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1beta.Hub) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listHubs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listHubs, request)); - assert( - (client.descriptors.page.listHubs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listHubs without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListHubsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListHubsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Hub(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Hub(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Hub(), + ), + ]; + client.descriptors.page.listHubs.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1beta.IHub[] = + []; + const iterable = client.listHubsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listHubs.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.listHubs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listHubsStream with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListHubsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListHubsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listHubs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listHubsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1beta.Hub[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1beta.Hub) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listHubs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listHubs, request)); - assert( - (client.descriptors.page.listHubs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listHubs with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListHubsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListHubsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listHubs.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listHubsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1beta.IHub[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listHubs.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.listHubs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listHubSpokes', () => { + it('invokes listHubSpokes without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Spoke(), + ), + ]; + client.innerApiCalls.listHubSpokes = stubSimpleCall(expectedResponse); + const [response] = await client.listHubSpokes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listHubSpokes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listHubSpokes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listHubs without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListHubsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListHubsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Hub()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Hub()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Hub()), - ]; - client.descriptors.page.listHubs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1beta.IHub[] = []; - const iterable = client.listHubsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listHubSpokes without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Spoke(), + ), + ]; + client.innerApiCalls.listHubSpokes = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listHubSpokes( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkconnectivity.v1beta.ISpoke[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listHubs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listHubs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listHubs with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListHubsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListHubsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listHubs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listHubsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1beta.IHub[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listHubs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listHubs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listHubSpokes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listHubSpokes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listHubSpokes', () => { - it('invokes listHubSpokes without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Spoke()), - ]; - client.innerApiCalls.listHubSpokes = stubSimpleCall(expectedResponse); - const [response] = await client.listHubSpokes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listHubSpokes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listHubSpokes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listHubSpokes with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listHubSpokes = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listHubSpokes(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listHubSpokes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listHubSpokes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listHubSpokes without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Spoke()), - ]; - client.innerApiCalls.listHubSpokes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listHubSpokes( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1beta.ISpoke[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listHubSpokes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listHubSpokes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listHubSpokesStream without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Spoke(), + ), + ]; + client.descriptors.page.listHubSpokes.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listHubSpokesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1beta.Spoke[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkconnectivity.v1beta.Spoke) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listHubSpokes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listHubSpokes, request), + ); + assert( + (client.descriptors.page.listHubSpokes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listHubSpokes with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listHubSpokes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listHubSpokes(request), expectedError); - const actualRequest = (client.innerApiCalls.listHubSpokes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listHubSpokes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listHubSpokesStream with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listHubSpokes.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listHubSpokesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1beta.Spoke[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkconnectivity.v1beta.Spoke) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listHubSpokes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listHubSpokes, request), + ); + assert( + (client.descriptors.page.listHubSpokes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listHubSpokesStream without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Spoke()), - ]; - client.descriptors.page.listHubSpokes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listHubSpokesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1beta.Spoke[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1beta.Spoke) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listHubSpokes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listHubSpokes, request)); - assert( - (client.descriptors.page.listHubSpokes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listHubSpokes without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Spoke(), + ), + ]; + client.descriptors.page.listHubSpokes.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1beta.ISpoke[] = + []; + const iterable = client.listHubSpokesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listHubSpokes.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listHubSpokes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listHubSpokesStream with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listHubSpokes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listHubSpokesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1beta.Spoke[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1beta.Spoke) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listHubSpokes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listHubSpokes, request)); - assert( - (client.descriptors.page.listHubSpokes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listHubSpokes with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listHubSpokes.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listHubSpokesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1beta.ISpoke[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listHubSpokes.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listHubSpokes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('queryHubStatus', () => { + it('invokes queryHubStatus without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.QueryHubStatusRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.QueryHubStatusRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry(), + ), + ]; + client.innerApiCalls.queryHubStatus = stubSimpleCall(expectedResponse); + const [response] = await client.queryHubStatus(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.queryHubStatus as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryHubStatus as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listHubSpokes without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Spoke()), - ]; - client.descriptors.page.listHubSpokes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1beta.ISpoke[] = []; - const iterable = client.listHubSpokesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes queryHubStatus without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.QueryHubStatusRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.QueryHubStatusRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry(), + ), + ]; + client.innerApiCalls.queryHubStatus = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.queryHubStatus( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkconnectivity.v1beta.IHubStatusEntry[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listHubSpokes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listHubSpokes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listHubSpokes with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListHubSpokesRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listHubSpokes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listHubSpokesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1beta.ISpoke[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listHubSpokes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listHubSpokes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.queryHubStatus as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryHubStatus as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('queryHubStatus', () => { - it('invokes queryHubStatus without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.QueryHubStatusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.QueryHubStatusRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry()), - ]; - client.innerApiCalls.queryHubStatus = stubSimpleCall(expectedResponse); - const [response] = await client.queryHubStatus(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.queryHubStatus as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.queryHubStatus as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes queryHubStatus with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.QueryHubStatusRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.QueryHubStatusRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.queryHubStatus = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.queryHubStatus(request), expectedError); + const actualRequest = ( + client.innerApiCalls.queryHubStatus as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryHubStatus as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes queryHubStatus without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.QueryHubStatusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.QueryHubStatusRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry()), - ]; - client.innerApiCalls.queryHubStatus = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.queryHubStatus( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1beta.IHubStatusEntry[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.queryHubStatus as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.queryHubStatus as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes queryHubStatusStream without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.QueryHubStatusRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.QueryHubStatusRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry(), + ), + ]; + client.descriptors.page.queryHubStatus.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.queryHubStatusStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.queryHubStatus.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.queryHubStatus, request), + ); + assert( + (client.descriptors.page.queryHubStatus.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes queryHubStatus with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.QueryHubStatusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.QueryHubStatusRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.queryHubStatus = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.queryHubStatus(request), expectedError); - const actualRequest = (client.innerApiCalls.queryHubStatus as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.queryHubStatus as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes queryHubStatusStream with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.QueryHubStatusRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.QueryHubStatusRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.queryHubStatus.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.queryHubStatusStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.queryHubStatus.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.queryHubStatus, request), + ); + assert( + (client.descriptors.page.queryHubStatus.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes queryHubStatusStream without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.QueryHubStatusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.QueryHubStatusRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry()), - ]; - client.descriptors.page.queryHubStatus.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.queryHubStatusStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.queryHubStatus.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.queryHubStatus, request)); - assert( - (client.descriptors.page.queryHubStatus.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with queryHubStatus without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.QueryHubStatusRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.QueryHubStatusRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry(), + ), + ]; + client.descriptors.page.queryHubStatus.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1beta.IHubStatusEntry[] = + []; + const iterable = client.queryHubStatusAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.queryHubStatus.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.queryHubStatus.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes queryHubStatusStream with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.QueryHubStatusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.QueryHubStatusRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.queryHubStatus.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.queryHubStatusStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.queryHubStatus.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.queryHubStatus, request)); - assert( - (client.descriptors.page.queryHubStatus.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with queryHubStatus with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.QueryHubStatusRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.QueryHubStatusRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.queryHubStatus.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.queryHubStatusAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1beta.IHubStatusEntry[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.queryHubStatus.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.queryHubStatus.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listSpokes', () => { + it('invokes listSpokes without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListSpokesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Spoke(), + ), + ]; + client.innerApiCalls.listSpokes = stubSimpleCall(expectedResponse); + const [response] = await client.listSpokes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listSpokes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSpokes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with queryHubStatus without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.QueryHubStatusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.QueryHubStatusRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.HubStatusEntry()), - ]; - client.descriptors.page.queryHubStatus.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1beta.IHubStatusEntry[] = []; - const iterable = client.queryHubStatusAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listSpokes without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListSpokesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Spoke(), + ), + ]; + client.innerApiCalls.listSpokes = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listSpokes( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkconnectivity.v1beta.ISpoke[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.queryHubStatus.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.queryHubStatus.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with queryHubStatus with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.QueryHubStatusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.QueryHubStatusRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.queryHubStatus.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.queryHubStatusAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1beta.IHubStatusEntry[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.queryHubStatus.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.queryHubStatus.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listSpokes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSpokes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listSpokes', () => { - it('invokes listSpokes without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListSpokesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Spoke()), - ]; - client.innerApiCalls.listSpokes = stubSimpleCall(expectedResponse); - const [response] = await client.listSpokes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSpokes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSpokes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listSpokes with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListSpokesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listSpokes = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listSpokes(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listSpokes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSpokes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listSpokes without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListSpokesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Spoke()), - ]; - client.innerApiCalls.listSpokes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listSpokes( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1beta.ISpoke[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSpokes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSpokes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listSpokesStream without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListSpokesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Spoke(), + ), + ]; + client.descriptors.page.listSpokes.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listSpokesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1beta.Spoke[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkconnectivity.v1beta.Spoke) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listSpokes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listSpokes, request), + ); + assert( + (client.descriptors.page.listSpokes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listSpokes with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListSpokesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listSpokes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listSpokes(request), expectedError); - const actualRequest = (client.innerApiCalls.listSpokes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSpokes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listSpokesStream with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListSpokesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSpokes.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listSpokesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1beta.Spoke[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkconnectivity.v1beta.Spoke) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listSpokes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listSpokes, request), + ); + assert( + (client.descriptors.page.listSpokes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listSpokesStream without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListSpokesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Spoke()), - ]; - client.descriptors.page.listSpokes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listSpokesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1beta.Spoke[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1beta.Spoke) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listSpokes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSpokes, request)); - assert( - (client.descriptors.page.listSpokes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listSpokes without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListSpokesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Spoke(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Spoke(), + ), + ]; + client.descriptors.page.listSpokes.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1beta.ISpoke[] = + []; + const iterable = client.listSpokesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listSpokes.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listSpokes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listSpokesStream with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListSpokesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listSpokes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listSpokesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1beta.Spoke[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1beta.Spoke) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listSpokes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSpokes, request)); - assert( - (client.descriptors.page.listSpokes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listSpokes with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListSpokesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListSpokesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSpokes.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listSpokesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1beta.ISpoke[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listSpokes.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listSpokes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listRoutes', () => { + it('invokes listRoutes without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Route(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Route(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Route(), + ), + ]; + client.innerApiCalls.listRoutes = stubSimpleCall(expectedResponse); + const [response] = await client.listRoutes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listRoutes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listRoutes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listSpokes without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListSpokesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Spoke()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Spoke()), - ]; - client.descriptors.page.listSpokes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1beta.ISpoke[] = []; - const iterable = client.listSpokesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listRoutes without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Route(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Route(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Route(), + ), + ]; + client.innerApiCalls.listRoutes = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listRoutes( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkconnectivity.v1beta.IRoute[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listSpokes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSpokes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listSpokes with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListSpokesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListSpokesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listSpokes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listSpokesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1beta.ISpoke[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listSpokes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSpokes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listRoutes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listRoutes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listRoutes', () => { - it('invokes listRoutes without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Route()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Route()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Route()), - ]; - client.innerApiCalls.listRoutes = stubSimpleCall(expectedResponse); - const [response] = await client.listRoutes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRoutes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRoutes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listRoutes with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listRoutes = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listRoutes(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listRoutes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listRoutes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listRoutes without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Route()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Route()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Route()), - ]; - client.innerApiCalls.listRoutes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listRoutes( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1beta.IRoute[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRoutes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRoutes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listRoutesStream without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Route(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Route(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Route(), + ), + ]; + client.descriptors.page.listRoutes.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listRoutesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1beta.Route[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkconnectivity.v1beta.Route) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listRoutes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listRoutes, request), + ); + assert( + (client.descriptors.page.listRoutes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listRoutes with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listRoutes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listRoutes(request), expectedError); - const actualRequest = (client.innerApiCalls.listRoutes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRoutes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listRoutesStream with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRoutes.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listRoutesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1beta.Route[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkconnectivity.v1beta.Route) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listRoutes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listRoutes, request), + ); + assert( + (client.descriptors.page.listRoutes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listRoutesStream without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Route()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Route()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Route()), - ]; - client.descriptors.page.listRoutes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listRoutesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1beta.Route[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1beta.Route) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listRoutes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRoutes, request)); - assert( - (client.descriptors.page.listRoutes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listRoutes without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Route(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Route(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Route(), + ), + ]; + client.descriptors.page.listRoutes.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1beta.IRoute[] = + []; + const iterable = client.listRoutesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listRoutes.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listRoutes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listRoutesStream with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listRoutes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listRoutesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1beta.Route[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1beta.Route) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listRoutes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRoutes, request)); - assert( - (client.descriptors.page.listRoutes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listRoutes with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRoutes.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listRoutesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1beta.IRoute[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listRoutes.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listRoutes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listRouteTables', () => { + it('invokes listRouteTables without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListRouteTablesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListRouteTablesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RouteTable(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RouteTable(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RouteTable(), + ), + ]; + client.innerApiCalls.listRouteTables = stubSimpleCall(expectedResponse); + const [response] = await client.listRouteTables(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listRouteTables as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listRouteTables as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listRoutes without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Route()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Route()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Route()), - ]; - client.descriptors.page.listRoutes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1beta.IRoute[] = []; - const iterable = client.listRoutesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listRouteTables without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListRouteTablesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListRouteTablesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RouteTable(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RouteTable(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RouteTable(), + ), + ]; + client.innerApiCalls.listRouteTables = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listRouteTables( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkconnectivity.v1beta.IRouteTable[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listRoutes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRoutes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listRoutes with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listRoutes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listRoutesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1beta.IRoute[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listRoutes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRoutes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listRouteTables as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listRouteTables as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listRouteTables', () => { - it('invokes listRouteTables without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListRouteTablesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListRouteTablesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.RouteTable()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.RouteTable()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.RouteTable()), - ]; - client.innerApiCalls.listRouteTables = stubSimpleCall(expectedResponse); - const [response] = await client.listRouteTables(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRouteTables as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRouteTables as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listRouteTables with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListRouteTablesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListRouteTablesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listRouteTables = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listRouteTables(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listRouteTables as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listRouteTables as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listRouteTables without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListRouteTablesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListRouteTablesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.RouteTable()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.RouteTable()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.RouteTable()), - ]; - client.innerApiCalls.listRouteTables = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listRouteTables( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1beta.IRouteTable[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRouteTables as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRouteTables as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listRouteTablesStream without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListRouteTablesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListRouteTablesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RouteTable(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RouteTable(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RouteTable(), + ), + ]; + client.descriptors.page.listRouteTables.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listRouteTablesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1beta.RouteTable[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1beta.RouteTable, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listRouteTables.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listRouteTables, request), + ); + assert( + (client.descriptors.page.listRouteTables.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listRouteTables with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListRouteTablesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListRouteTablesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listRouteTables = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listRouteTables(request), expectedError); - const actualRequest = (client.innerApiCalls.listRouteTables as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRouteTables as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listRouteTablesStream with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListRouteTablesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListRouteTablesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRouteTables.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listRouteTablesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1beta.RouteTable[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1beta.RouteTable, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listRouteTables.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listRouteTables, request), + ); + assert( + (client.descriptors.page.listRouteTables.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listRouteTablesStream without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListRouteTablesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListRouteTablesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.RouteTable()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.RouteTable()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.RouteTable()), - ]; - client.descriptors.page.listRouteTables.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listRouteTablesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1beta.RouteTable[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1beta.RouteTable) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listRouteTables.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRouteTables, request)); - assert( - (client.descriptors.page.listRouteTables.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listRouteTables without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListRouteTablesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListRouteTablesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RouteTable(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RouteTable(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RouteTable(), + ), + ]; + client.descriptors.page.listRouteTables.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1beta.IRouteTable[] = + []; + const iterable = client.listRouteTablesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listRouteTables.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listRouteTables.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listRouteTablesStream with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListRouteTablesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListRouteTablesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listRouteTables.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listRouteTablesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1beta.RouteTable[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1beta.RouteTable) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listRouteTables.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRouteTables, request)); - assert( - (client.descriptors.page.listRouteTables.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listRouteTables with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListRouteTablesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListRouteTablesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRouteTables.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listRouteTablesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1beta.IRouteTable[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listRouteTables.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listRouteTables.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listGroups', () => { + it('invokes listGroups without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Group(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Group(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Group(), + ), + ]; + client.innerApiCalls.listGroups = stubSimpleCall(expectedResponse); + const [response] = await client.listGroups(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listGroups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listGroups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listRouteTables without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListRouteTablesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListRouteTablesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.RouteTable()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.RouteTable()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.RouteTable()), - ]; - client.descriptors.page.listRouteTables.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1beta.IRouteTable[] = []; - const iterable = client.listRouteTablesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listGroups without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Group(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Group(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Group(), + ), + ]; + client.innerApiCalls.listGroups = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listGroups( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkconnectivity.v1beta.IGroup[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listRouteTables.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRouteTables.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listRouteTables with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListRouteTablesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListRouteTablesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listRouteTables.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listRouteTablesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1beta.IRouteTable[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listRouteTables.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRouteTables.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listGroups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listGroups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listGroups', () => { - it('invokes listGroups without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Group()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Group()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Group()), - ]; - client.innerApiCalls.listGroups = stubSimpleCall(expectedResponse); - const [response] = await client.listGroups(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listGroups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listGroups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listGroups with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listGroups = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listGroups(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listGroups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listGroups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listGroups without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Group()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Group()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Group()), - ]; - client.innerApiCalls.listGroups = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listGroups( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1beta.IGroup[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listGroups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listGroups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listGroupsStream without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Group(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Group(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Group(), + ), + ]; + client.descriptors.page.listGroups.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listGroupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1beta.Group[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkconnectivity.v1beta.Group) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listGroups.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listGroups, request), + ); + assert( + (client.descriptors.page.listGroups.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listGroups with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listGroups = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listGroups(request), expectedError); - const actualRequest = (client.innerApiCalls.listGroups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listGroups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listGroupsStream with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listGroups.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listGroupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1beta.Group[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkconnectivity.v1beta.Group) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listGroups.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listGroups, request), + ); + assert( + (client.descriptors.page.listGroups.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listGroupsStream without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Group()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Group()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Group()), - ]; - client.descriptors.page.listGroups.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listGroupsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1beta.Group[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1beta.Group) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listGroups.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listGroups, request)); - assert( - (client.descriptors.page.listGroups.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listGroups without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Group(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Group(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Group(), + ), + ]; + client.descriptors.page.listGroups.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1beta.IGroup[] = + []; + const iterable = client.listGroupsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listGroups.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listGroups.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listGroupsStream with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listGroups.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listGroupsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1beta.Group[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1beta.Group) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listGroups.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listGroups, request)); - assert( - (client.descriptors.page.listGroups.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listGroups with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listGroups.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listGroupsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1beta.IGroup[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listGroups.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listGroups.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listGatewayAdvertisedRoutes', () => { + it('invokes listGatewayAdvertisedRoutes without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListGatewayAdvertisedRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListGatewayAdvertisedRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute(), + ), + ]; + client.innerApiCalls.listGatewayAdvertisedRoutes = + stubSimpleCall(expectedResponse); + const [response] = await client.listGatewayAdvertisedRoutes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listGatewayAdvertisedRoutes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listGatewayAdvertisedRoutes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listGroups without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Group()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Group()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Group()), - ]; - client.descriptors.page.listGroups.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1beta.IGroup[] = []; - const iterable = client.listGroupsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listGatewayAdvertisedRoutes without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListGatewayAdvertisedRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListGatewayAdvertisedRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute(), + ), + ]; + client.innerApiCalls.listGatewayAdvertisedRoutes = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listGatewayAdvertisedRoutes( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listGroups.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listGroups.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listGroups with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listGroups.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listGroupsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1beta.IGroup[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listGroups.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listGroups.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listGatewayAdvertisedRoutes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listGatewayAdvertisedRoutes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listGatewayAdvertisedRoutes', () => { - it('invokes listGatewayAdvertisedRoutes without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListGatewayAdvertisedRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListGatewayAdvertisedRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute()), - ]; - client.innerApiCalls.listGatewayAdvertisedRoutes = stubSimpleCall(expectedResponse); - const [response] = await client.listGatewayAdvertisedRoutes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listGatewayAdvertisedRoutes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listGatewayAdvertisedRoutes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listGatewayAdvertisedRoutes without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListGatewayAdvertisedRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListGatewayAdvertisedRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute()), - ]; - client.innerApiCalls.listGatewayAdvertisedRoutes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listGatewayAdvertisedRoutes( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listGatewayAdvertisedRoutes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listGatewayAdvertisedRoutes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listGatewayAdvertisedRoutes with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListGatewayAdvertisedRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListGatewayAdvertisedRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listGatewayAdvertisedRoutes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listGatewayAdvertisedRoutes(request), expectedError); - const actualRequest = (client.innerApiCalls.listGatewayAdvertisedRoutes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listGatewayAdvertisedRoutes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listGatewayAdvertisedRoutes with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListGatewayAdvertisedRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListGatewayAdvertisedRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listGatewayAdvertisedRoutes = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listGatewayAdvertisedRoutes(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listGatewayAdvertisedRoutes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listGatewayAdvertisedRoutes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listGatewayAdvertisedRoutesStream without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListGatewayAdvertisedRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListGatewayAdvertisedRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute()), - ]; - client.descriptors.page.listGatewayAdvertisedRoutes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listGatewayAdvertisedRoutesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listGatewayAdvertisedRoutes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listGatewayAdvertisedRoutes, request)); - assert( - (client.descriptors.page.listGatewayAdvertisedRoutes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listGatewayAdvertisedRoutesStream without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListGatewayAdvertisedRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListGatewayAdvertisedRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute(), + ), + ]; + client.descriptors.page.listGatewayAdvertisedRoutes.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listGatewayAdvertisedRoutesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listGatewayAdvertisedRoutes + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listGatewayAdvertisedRoutes, + request, + ), + ); + assert( + ( + client.descriptors.page.listGatewayAdvertisedRoutes + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listGatewayAdvertisedRoutesStream with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListGatewayAdvertisedRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListGatewayAdvertisedRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listGatewayAdvertisedRoutes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listGatewayAdvertisedRoutesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listGatewayAdvertisedRoutes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listGatewayAdvertisedRoutes, request)); - assert( - (client.descriptors.page.listGatewayAdvertisedRoutes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listGatewayAdvertisedRoutesStream with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListGatewayAdvertisedRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListGatewayAdvertisedRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listGatewayAdvertisedRoutes.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listGatewayAdvertisedRoutesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listGatewayAdvertisedRoutes + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listGatewayAdvertisedRoutes, + request, + ), + ); + assert( + ( + client.descriptors.page.listGatewayAdvertisedRoutes + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('uses async iteration with listGatewayAdvertisedRoutes without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListGatewayAdvertisedRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListGatewayAdvertisedRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute()), - ]; - client.descriptors.page.listGatewayAdvertisedRoutes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute[] = []; - const iterable = client.listGatewayAdvertisedRoutesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listGatewayAdvertisedRoutes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listGatewayAdvertisedRoutes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listGatewayAdvertisedRoutes without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListGatewayAdvertisedRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListGatewayAdvertisedRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GatewayAdvertisedRoute(), + ), + ]; + client.descriptors.page.listGatewayAdvertisedRoutes.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute[] = + []; + const iterable = client.listGatewayAdvertisedRoutesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listGatewayAdvertisedRoutes + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listGatewayAdvertisedRoutes + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('uses async iteration with listGatewayAdvertisedRoutes with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListGatewayAdvertisedRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListGatewayAdvertisedRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listGatewayAdvertisedRoutes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listGatewayAdvertisedRoutesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listGatewayAdvertisedRoutes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listGatewayAdvertisedRoutes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listGatewayAdvertisedRoutes with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListGatewayAdvertisedRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListGatewayAdvertisedRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listGatewayAdvertisedRoutes.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listGatewayAdvertisedRoutesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1beta.IGatewayAdvertisedRoute[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listGatewayAdvertisedRoutes + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listGatewayAdvertisedRoutes + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes setIamPolicy with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); + }); + it('invokes testIamPermissions with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes getLocation without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('destination', async () => { + const fakePath = '/rendered/path/destination'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + multicloud_data_transfer_config: 'multicloudDataTransferConfigValue', + destination: 'destinationValue', + }; + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.destinationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.destinationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('destinationPath', () => { + const result = client.destinationPath( + 'projectValue', + 'locationValue', + 'multicloudDataTransferConfigValue', + 'destinationValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.destinationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromDestinationName', () => { + const result = client.matchProjectFromDestinationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromDestinationName', () => { + const result = client.matchLocationFromDestinationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMulticloudDataTransferConfigFromDestinationName', () => { + const result = + client.matchMulticloudDataTransferConfigFromDestinationName(fakePath); + assert.strictEqual(result, 'multicloudDataTransferConfigValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchDestinationFromDestinationName', () => { + const result = client.matchDestinationFromDestinationName(fakePath); + assert.strictEqual(result, 'destinationValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('destination', async () => { - const fakePath = "/rendered/path/destination"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - multicloud_data_transfer_config: "multicloudDataTransferConfigValue", - destination: "destinationValue", - }; - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.destinationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.destinationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('destinationPath', () => { - const result = client.destinationPath("projectValue", "locationValue", "multicloudDataTransferConfigValue", "destinationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.destinationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDestinationName', () => { - const result = client.matchProjectFromDestinationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromDestinationName', () => { - const result = client.matchLocationFromDestinationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMulticloudDataTransferConfigFromDestinationName', () => { - const result = client.matchMulticloudDataTransferConfigFromDestinationName(fakePath); - assert.strictEqual(result, "multicloudDataTransferConfigValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDestinationFromDestinationName', () => { - const result = client.matchDestinationFromDestinationName(fakePath); - assert.strictEqual(result, "destinationValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('gatewayAdvertisedRoute', async () => { - const fakePath = "/rendered/path/gatewayAdvertisedRoute"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - spoke: "spokeValue", - gateway_advertised_route: "gatewayAdvertisedRouteValue", - }; - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.gatewayAdvertisedRoutePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.gatewayAdvertisedRoutePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('gatewayAdvertisedRoutePath', () => { - const result = client.gatewayAdvertisedRoutePath("projectValue", "locationValue", "spokeValue", "gatewayAdvertisedRouteValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.gatewayAdvertisedRoutePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromGatewayAdvertisedRouteName', () => { - const result = client.matchProjectFromGatewayAdvertisedRouteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.gatewayAdvertisedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromGatewayAdvertisedRouteName', () => { - const result = client.matchLocationFromGatewayAdvertisedRouteName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.gatewayAdvertisedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSpokeFromGatewayAdvertisedRouteName', () => { - const result = client.matchSpokeFromGatewayAdvertisedRouteName(fakePath); - assert.strictEqual(result, "spokeValue"); - assert((client.pathTemplates.gatewayAdvertisedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchGatewayAdvertisedRouteFromGatewayAdvertisedRouteName', () => { - const result = client.matchGatewayAdvertisedRouteFromGatewayAdvertisedRouteName(fakePath); - assert.strictEqual(result, "gatewayAdvertisedRouteValue"); - assert((client.pathTemplates.gatewayAdvertisedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('gatewayAdvertisedRoute', async () => { + const fakePath = '/rendered/path/gatewayAdvertisedRoute'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + spoke: 'spokeValue', + gateway_advertised_route: 'gatewayAdvertisedRouteValue', + }; + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.gatewayAdvertisedRoutePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.gatewayAdvertisedRoutePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('gatewayAdvertisedRoutePath', () => { + const result = client.gatewayAdvertisedRoutePath( + 'projectValue', + 'locationValue', + 'spokeValue', + 'gatewayAdvertisedRouteValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.gatewayAdvertisedRoutePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromGatewayAdvertisedRouteName', () => { + const result = + client.matchProjectFromGatewayAdvertisedRouteName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.gatewayAdvertisedRoutePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromGatewayAdvertisedRouteName', () => { + const result = + client.matchLocationFromGatewayAdvertisedRouteName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.gatewayAdvertisedRoutePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchSpokeFromGatewayAdvertisedRouteName', () => { + const result = + client.matchSpokeFromGatewayAdvertisedRouteName(fakePath); + assert.strictEqual(result, 'spokeValue'); + assert( + ( + client.pathTemplates.gatewayAdvertisedRoutePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchGatewayAdvertisedRouteFromGatewayAdvertisedRouteName', () => { + const result = + client.matchGatewayAdvertisedRouteFromGatewayAdvertisedRouteName( + fakePath, + ); + assert.strictEqual(result, 'gatewayAdvertisedRouteValue'); + assert( + ( + client.pathTemplates.gatewayAdvertisedRoutePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('group', async () => { - const fakePath = "/rendered/path/group"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - group: "groupValue", - }; - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.groupPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.groupPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('groupPath', () => { - const result = client.groupPath("projectValue", "hubValue", "groupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.groupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromGroupName', () => { - const result = client.matchProjectFromGroupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.groupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHubFromGroupName', () => { - const result = client.matchHubFromGroupName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.groupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchGroupFromGroupName', () => { - const result = client.matchGroupFromGroupName(fakePath); - assert.strictEqual(result, "groupValue"); - assert((client.pathTemplates.groupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('group', async () => { + const fakePath = '/rendered/path/group'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + group: 'groupValue', + }; + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.groupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.groupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('groupPath', () => { + const result = client.groupPath( + 'projectValue', + 'hubValue', + 'groupValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.groupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromGroupName', () => { + const result = client.matchProjectFromGroupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.groupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromGroupName', () => { + const result = client.matchHubFromGroupName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.groupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchGroupFromGroupName', () => { + const result = client.matchGroupFromGroupName(fakePath); + assert.strictEqual(result, 'groupValue'); + assert( + (client.pathTemplates.groupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('hub', async () => { - const fakePath = "/rendered/path/hub"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - }; - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.hubPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.hubPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('hubPath', () => { - const result = client.hubPath("projectValue", "hubValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.hubPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromHubName', () => { - const result = client.matchProjectFromHubName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.hubPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHubFromHubName', () => { - const result = client.matchHubFromHubName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.hubPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('hub', async () => { + const fakePath = '/rendered/path/hub'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + }; + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.hubPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.hubPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('hubPath', () => { + const result = client.hubPath('projectValue', 'hubValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.hubPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromHubName', () => { + const result = client.matchProjectFromHubName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.hubPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromHubName', () => { + const result = client.matchHubFromHubName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.hubPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('hubRoute', async () => { - const fakePath = "/rendered/path/hubRoute"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - route_table: "routeTableValue", - route: "routeValue", - }; - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.hubRoutePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.hubRoutePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('hubRoutePath', () => { - const result = client.hubRoutePath("projectValue", "hubValue", "routeTableValue", "routeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.hubRoutePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromHubRouteName', () => { - const result = client.matchProjectFromHubRouteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHubFromHubRouteName', () => { - const result = client.matchHubFromHubRouteName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRouteTableFromHubRouteName', () => { - const result = client.matchRouteTableFromHubRouteName(fakePath); - assert.strictEqual(result, "routeTableValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRouteFromHubRouteName', () => { - const result = client.matchRouteFromHubRouteName(fakePath); - assert.strictEqual(result, "routeValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('hubRoute', async () => { + const fakePath = '/rendered/path/hubRoute'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + route_table: 'routeTableValue', + route: 'routeValue', + }; + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.hubRoutePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.hubRoutePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('hubRoutePath', () => { + const result = client.hubRoutePath( + 'projectValue', + 'hubValue', + 'routeTableValue', + 'routeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.hubRoutePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromHubRouteName', () => { + const result = client.matchProjectFromHubRouteName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromHubRouteName', () => { + const result = client.matchHubFromHubRouteName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRouteTableFromHubRouteName', () => { + const result = client.matchRouteTableFromHubRouteName(fakePath); + assert.strictEqual(result, 'routeTableValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRouteFromHubRouteName', () => { + const result = client.matchRouteFromHubRouteName(fakePath); + assert.strictEqual(result, 'routeValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('instance', async () => { - const fakePath = "/rendered/path/instance"; - const expectedParameters = { - project: "projectValue", - zone: "zoneValue", - instance: "instanceValue", - }; - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.instancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.instancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('instancePath', () => { - const result = client.instancePath("projectValue", "zoneValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.instancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInstanceName', () => { - const result = client.matchProjectFromInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchZoneFromInstanceName', () => { - const result = client.matchZoneFromInstanceName(fakePath); - assert.strictEqual(result, "zoneValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromInstanceName', () => { - const result = client.matchInstanceFromInstanceName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('instance', async () => { + const fakePath = '/rendered/path/instance'; + const expectedParameters = { + project: 'projectValue', + zone: 'zoneValue', + instance: 'instanceValue', + }; + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.instancePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.instancePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('instancePath', () => { + const result = client.instancePath( + 'projectValue', + 'zoneValue', + 'instanceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.instancePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromInstanceName', () => { + const result = client.matchProjectFromInstanceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchZoneFromInstanceName', () => { + const result = client.matchZoneFromInstanceName(fakePath); + assert.strictEqual(result, 'zoneValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchInstanceFromInstanceName', () => { + const result = client.matchInstanceFromInstanceName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('interconnectAttachment', async () => { - const fakePath = "/rendered/path/interconnectAttachment"; - const expectedParameters = { - project: "projectValue", - region: "regionValue", - resource_id: "resourceIdValue", - }; - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.interconnectAttachmentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.interconnectAttachmentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('interconnectAttachmentPath', () => { - const result = client.interconnectAttachmentPath("projectValue", "regionValue", "resourceIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.interconnectAttachmentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInterconnectAttachmentName', () => { - const result = client.matchProjectFromInterconnectAttachmentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.interconnectAttachmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRegionFromInterconnectAttachmentName', () => { - const result = client.matchRegionFromInterconnectAttachmentName(fakePath); - assert.strictEqual(result, "regionValue"); - assert((client.pathTemplates.interconnectAttachmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchResourceIdFromInterconnectAttachmentName', () => { - const result = client.matchResourceIdFromInterconnectAttachmentName(fakePath); - assert.strictEqual(result, "resourceIdValue"); - assert((client.pathTemplates.interconnectAttachmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('interconnectAttachment', async () => { + const fakePath = '/rendered/path/interconnectAttachment'; + const expectedParameters = { + project: 'projectValue', + region: 'regionValue', + resource_id: 'resourceIdValue', + }; + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.interconnectAttachmentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.interconnectAttachmentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('interconnectAttachmentPath', () => { + const result = client.interconnectAttachmentPath( + 'projectValue', + 'regionValue', + 'resourceIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.interconnectAttachmentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromInterconnectAttachmentName', () => { + const result = + client.matchProjectFromInterconnectAttachmentName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.interconnectAttachmentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRegionFromInterconnectAttachmentName', () => { + const result = + client.matchRegionFromInterconnectAttachmentName(fakePath); + assert.strictEqual(result, 'regionValue'); + assert( + ( + client.pathTemplates.interconnectAttachmentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchResourceIdFromInterconnectAttachmentName', () => { + const result = + client.matchResourceIdFromInterconnectAttachmentName(fakePath); + assert.strictEqual(result, 'resourceIdValue'); + assert( + ( + client.pathTemplates.interconnectAttachmentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('multicloudDataTransferConfig', async () => { - const fakePath = "/rendered/path/multicloudDataTransferConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - multicloud_data_transfer_config: "multicloudDataTransferConfigValue", - }; - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.multicloudDataTransferConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.multicloudDataTransferConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('multicloudDataTransferConfigPath', () => { - const result = client.multicloudDataTransferConfigPath("projectValue", "locationValue", "multicloudDataTransferConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMulticloudDataTransferConfigName', () => { - const result = client.matchProjectFromMulticloudDataTransferConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMulticloudDataTransferConfigName', () => { - const result = client.matchLocationFromMulticloudDataTransferConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName', () => { - const result = client.matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName(fakePath); - assert.strictEqual(result, "multicloudDataTransferConfigValue"); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('multicloudDataTransferConfig', async () => { + const fakePath = '/rendered/path/multicloudDataTransferConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + multicloud_data_transfer_config: 'multicloudDataTransferConfigValue', + }; + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.multicloudDataTransferConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.multicloudDataTransferConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('multicloudDataTransferConfigPath', () => { + const result = client.multicloudDataTransferConfigPath( + 'projectValue', + 'locationValue', + 'multicloudDataTransferConfigValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMulticloudDataTransferConfigName', () => { + const result = + client.matchProjectFromMulticloudDataTransferConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMulticloudDataTransferConfigName', () => { + const result = + client.matchLocationFromMulticloudDataTransferConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName', () => { + const result = + client.matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName( + fakePath, + ); + assert.strictEqual(result, 'multicloudDataTransferConfigValue'); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('multicloudDataTransferSupportedService', async () => { - const fakePath = "/rendered/path/multicloudDataTransferSupportedService"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - multicloud_data_transfer_supported_service: "multicloudDataTransferSupportedServiceValue", - }; - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('multicloudDataTransferSupportedServicePath', () => { - const result = client.multicloudDataTransferSupportedServicePath("projectValue", "locationValue", "multicloudDataTransferSupportedServiceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMulticloudDataTransferSupportedServiceName', () => { - const result = client.matchProjectFromMulticloudDataTransferSupportedServiceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMulticloudDataTransferSupportedServiceName', () => { - const result = client.matchLocationFromMulticloudDataTransferSupportedServiceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName', () => { - const result = client.matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName(fakePath); - assert.strictEqual(result, "multicloudDataTransferSupportedServiceValue"); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('multicloudDataTransferSupportedService', async () => { + const fakePath = '/rendered/path/multicloudDataTransferSupportedService'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + multicloud_data_transfer_supported_service: + 'multicloudDataTransferSupportedServiceValue', + }; + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('multicloudDataTransferSupportedServicePath', () => { + const result = client.multicloudDataTransferSupportedServicePath( + 'projectValue', + 'locationValue', + 'multicloudDataTransferSupportedServiceValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMulticloudDataTransferSupportedServiceName', () => { + const result = + client.matchProjectFromMulticloudDataTransferSupportedServiceName( + fakePath, + ); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMulticloudDataTransferSupportedServiceName', () => { + const result = + client.matchLocationFromMulticloudDataTransferSupportedServiceName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName', () => { + const result = + client.matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName( + fakePath, + ); + assert.strictEqual( + result, + 'multicloudDataTransferSupportedServiceValue', + ); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('network', async () => { - const fakePath = "/rendered/path/network"; - const expectedParameters = { - project: "projectValue", - resource_id: "resourceIdValue", - }; - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.networkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.networkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('networkPath', () => { - const result = client.networkPath("projectValue", "resourceIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.networkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromNetworkName', () => { - const result = client.matchProjectFromNetworkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.networkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchResourceIdFromNetworkName', () => { - const result = client.matchResourceIdFromNetworkName(fakePath); - assert.strictEqual(result, "resourceIdValue"); - assert((client.pathTemplates.networkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('network', async () => { + const fakePath = '/rendered/path/network'; + const expectedParameters = { + project: 'projectValue', + resource_id: 'resourceIdValue', + }; + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.networkPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.networkPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('networkPath', () => { + const result = client.networkPath('projectValue', 'resourceIdValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.networkPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromNetworkName', () => { + const result = client.matchProjectFromNetworkName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.networkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchResourceIdFromNetworkName', () => { + const result = client.matchResourceIdFromNetworkName(fakePath); + assert.strictEqual(result, 'resourceIdValue'); + assert( + (client.pathTemplates.networkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('policyBasedRoute', async () => { - const fakePath = "/rendered/path/policyBasedRoute"; - const expectedParameters = { - project: "projectValue", - policy_based_route: "policyBasedRouteValue", - }; - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.policyBasedRoutePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.policyBasedRoutePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('policyBasedRoutePath', () => { - const result = client.policyBasedRoutePath("projectValue", "policyBasedRouteValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.policyBasedRoutePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromPolicyBasedRouteName', () => { - const result = client.matchProjectFromPolicyBasedRouteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchPolicyBasedRouteFromPolicyBasedRouteName', () => { - const result = client.matchPolicyBasedRouteFromPolicyBasedRouteName(fakePath); - assert.strictEqual(result, "policyBasedRouteValue"); - assert((client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('policyBasedRoute', async () => { + const fakePath = '/rendered/path/policyBasedRoute'; + const expectedParameters = { + project: 'projectValue', + policy_based_route: 'policyBasedRouteValue', + }; + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.policyBasedRoutePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.policyBasedRoutePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('policyBasedRoutePath', () => { + const result = client.policyBasedRoutePath( + 'projectValue', + 'policyBasedRouteValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.policyBasedRoutePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromPolicyBasedRouteName', () => { + const result = client.matchProjectFromPolicyBasedRouteName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchPolicyBasedRouteFromPolicyBasedRouteName', () => { + const result = + client.matchPolicyBasedRouteFromPolicyBasedRouteName(fakePath); + assert.strictEqual(result, 'policyBasedRouteValue'); + assert( + (client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('remoteTransportProfile', async () => { - const fakePath = "/rendered/path/remoteTransportProfile"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - remote_transport_profile: "remoteTransportProfileValue", - }; - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.remoteTransportProfilePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.remoteTransportProfilePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('remoteTransportProfilePath', () => { - const result = client.remoteTransportProfilePath("projectValue", "locationValue", "remoteTransportProfileValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.remoteTransportProfilePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRemoteTransportProfileName', () => { - const result = client.matchProjectFromRemoteTransportProfileName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.remoteTransportProfilePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromRemoteTransportProfileName', () => { - const result = client.matchLocationFromRemoteTransportProfileName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.remoteTransportProfilePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRemoteTransportProfileFromRemoteTransportProfileName', () => { - const result = client.matchRemoteTransportProfileFromRemoteTransportProfileName(fakePath); - assert.strictEqual(result, "remoteTransportProfileValue"); - assert((client.pathTemplates.remoteTransportProfilePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('remoteTransportProfile', async () => { + const fakePath = '/rendered/path/remoteTransportProfile'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + remote_transport_profile: 'remoteTransportProfileValue', + }; + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.remoteTransportProfilePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.remoteTransportProfilePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('remoteTransportProfilePath', () => { + const result = client.remoteTransportProfilePath( + 'projectValue', + 'locationValue', + 'remoteTransportProfileValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.remoteTransportProfilePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromRemoteTransportProfileName', () => { + const result = + client.matchProjectFromRemoteTransportProfileName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.remoteTransportProfilePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromRemoteTransportProfileName', () => { + const result = + client.matchLocationFromRemoteTransportProfileName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.remoteTransportProfilePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRemoteTransportProfileFromRemoteTransportProfileName', () => { + const result = + client.matchRemoteTransportProfileFromRemoteTransportProfileName( + fakePath, + ); + assert.strictEqual(result, 'remoteTransportProfileValue'); + assert( + ( + client.pathTemplates.remoteTransportProfilePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('routeTable', async () => { - const fakePath = "/rendered/path/routeTable"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - route_table: "routeTableValue", - }; - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.routeTablePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.routeTablePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('routeTablePath', () => { - const result = client.routeTablePath("projectValue", "hubValue", "routeTableValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.routeTablePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRouteTableName', () => { - const result = client.matchProjectFromRouteTableName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.routeTablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHubFromRouteTableName', () => { - const result = client.matchHubFromRouteTableName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.routeTablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRouteTableFromRouteTableName', () => { - const result = client.matchRouteTableFromRouteTableName(fakePath); - assert.strictEqual(result, "routeTableValue"); - assert((client.pathTemplates.routeTablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('routeTable', async () => { + const fakePath = '/rendered/path/routeTable'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + route_table: 'routeTableValue', + }; + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.routeTablePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.routeTablePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('routeTablePath', () => { + const result = client.routeTablePath( + 'projectValue', + 'hubValue', + 'routeTableValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.routeTablePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromRouteTableName', () => { + const result = client.matchProjectFromRouteTableName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.routeTablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromRouteTableName', () => { + const result = client.matchHubFromRouteTableName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.routeTablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRouteTableFromRouteTableName', () => { + const result = client.matchRouteTableFromRouteTableName(fakePath); + assert.strictEqual(result, 'routeTableValue'); + assert( + (client.pathTemplates.routeTablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('sACAttachment', async () => { - const fakePath = "/rendered/path/sACAttachment"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - sac_attachment: "sacAttachmentValue", - }; - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.sACAttachmentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.sACAttachmentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('sACAttachmentPath', () => { - const result = client.sACAttachmentPath("projectValue", "locationValue", "sacAttachmentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.sACAttachmentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromSACAttachmentName', () => { - const result = client.matchProjectFromSACAttachmentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.sACAttachmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromSACAttachmentName', () => { - const result = client.matchLocationFromSACAttachmentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.sACAttachmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSacAttachmentFromSACAttachmentName', () => { - const result = client.matchSacAttachmentFromSACAttachmentName(fakePath); - assert.strictEqual(result, "sacAttachmentValue"); - assert((client.pathTemplates.sACAttachmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('sACAttachment', async () => { + const fakePath = '/rendered/path/sACAttachment'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + sac_attachment: 'sacAttachmentValue', + }; + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.sACAttachmentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.sACAttachmentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('sACAttachmentPath', () => { + const result = client.sACAttachmentPath( + 'projectValue', + 'locationValue', + 'sacAttachmentValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.sACAttachmentPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromSACAttachmentName', () => { + const result = client.matchProjectFromSACAttachmentName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.sACAttachmentPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromSACAttachmentName', () => { + const result = client.matchLocationFromSACAttachmentName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.sACAttachmentPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchSacAttachmentFromSACAttachmentName', () => { + const result = client.matchSacAttachmentFromSACAttachmentName(fakePath); + assert.strictEqual(result, 'sacAttachmentValue'); + assert( + (client.pathTemplates.sACAttachmentPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('spoke', async () => { - const fakePath = "/rendered/path/spoke"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - spoke: "spokeValue", - }; - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.spokePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.spokePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('spokePath', () => { - const result = client.spokePath("projectValue", "locationValue", "spokeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.spokePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromSpokeName', () => { - const result = client.matchProjectFromSpokeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.spokePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromSpokeName', () => { - const result = client.matchLocationFromSpokeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.spokePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSpokeFromSpokeName', () => { - const result = client.matchSpokeFromSpokeName(fakePath); - assert.strictEqual(result, "spokeValue"); - assert((client.pathTemplates.spokePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('spoke', async () => { + const fakePath = '/rendered/path/spoke'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + spoke: 'spokeValue', + }; + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.spokePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.spokePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('spokePath', () => { + const result = client.spokePath( + 'projectValue', + 'locationValue', + 'spokeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.spokePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromSpokeName', () => { + const result = client.matchProjectFromSpokeName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.spokePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromSpokeName', () => { + const result = client.matchLocationFromSpokeName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.spokePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchSpokeFromSpokeName', () => { + const result = client.matchSpokeFromSpokeName(fakePath); + assert.strictEqual(result, 'spokeValue'); + assert( + (client.pathTemplates.spokePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('transport', async () => { - const fakePath = "/rendered/path/transport"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - transport: "transportValue", - }; - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.transportPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.transportPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('transportPath', () => { - const result = client.transportPath("projectValue", "locationValue", "transportValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.transportPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTransportName', () => { - const result = client.matchProjectFromTransportName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.transportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromTransportName', () => { - const result = client.matchLocationFromTransportName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.transportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTransportFromTransportName', () => { - const result = client.matchTransportFromTransportName(fakePath); - assert.strictEqual(result, "transportValue"); - assert((client.pathTemplates.transportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('transport', async () => { + const fakePath = '/rendered/path/transport'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + transport: 'transportValue', + }; + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.transportPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.transportPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('transportPath', () => { + const result = client.transportPath( + 'projectValue', + 'locationValue', + 'transportValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.transportPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromTransportName', () => { + const result = client.matchProjectFromTransportName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.transportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromTransportName', () => { + const result = client.matchLocationFromTransportName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.transportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTransportFromTransportName', () => { + const result = client.matchTransportFromTransportName(fakePath); + assert.strictEqual(result, 'transportValue'); + assert( + (client.pathTemplates.transportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('vpnTunnel', async () => { - const fakePath = "/rendered/path/vpnTunnel"; - const expectedParameters = { - project: "projectValue", - region: "regionValue", - resource_id: "resourceIdValue", - }; - const client = new hubserviceModule.v1beta.HubServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.vpnTunnelPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.vpnTunnelPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('vpnTunnelPath', () => { - const result = client.vpnTunnelPath("projectValue", "regionValue", "resourceIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.vpnTunnelPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromVpnTunnelName', () => { - const result = client.matchProjectFromVpnTunnelName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.vpnTunnelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRegionFromVpnTunnelName', () => { - const result = client.matchRegionFromVpnTunnelName(fakePath); - assert.strictEqual(result, "regionValue"); - assert((client.pathTemplates.vpnTunnelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchResourceIdFromVpnTunnelName', () => { - const result = client.matchResourceIdFromVpnTunnelName(fakePath); - assert.strictEqual(result, "resourceIdValue"); - assert((client.pathTemplates.vpnTunnelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('vpnTunnel', async () => { + const fakePath = '/rendered/path/vpnTunnel'; + const expectedParameters = { + project: 'projectValue', + region: 'regionValue', + resource_id: 'resourceIdValue', + }; + const client = new hubserviceModule.v1beta.HubServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.vpnTunnelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.vpnTunnelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('vpnTunnelPath', () => { + const result = client.vpnTunnelPath( + 'projectValue', + 'regionValue', + 'resourceIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.vpnTunnelPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromVpnTunnelName', () => { + const result = client.matchProjectFromVpnTunnelName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.vpnTunnelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRegionFromVpnTunnelName', () => { + const result = client.matchRegionFromVpnTunnelName(fakePath); + assert.strictEqual(result, 'regionValue'); + assert( + (client.pathTemplates.vpnTunnelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchResourceIdFromVpnTunnelName', () => { + const result = client.matchResourceIdFromVpnTunnelName(fakePath); + assert.strictEqual(result, 'resourceIdValue'); + assert( + (client.pathTemplates.vpnTunnelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-networkconnectivity/test/gapic_internal_range_service_v1.ts b/packages/google-cloud-networkconnectivity/test/gapic_internal_range_service_v1.ts index fc72fd1b0eb6..0614494c1b90 100644 --- a/packages/google-cloud-networkconnectivity/test/gapic_internal_range_service_v1.ts +++ b/packages/google-cloud-networkconnectivity/test/gapic_internal_range_service_v1.ts @@ -19,2490 +19,3409 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as internalrangeserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + IamProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1.InternalRangeServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = internalrangeserviceModule.v1.InternalRangeServiceClient.servicePath; - assert.strictEqual(servicePath, 'networkconnectivity.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = internalrangeserviceModule.v1.InternalRangeServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new internalrangeserviceModule.v1.InternalRangeServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); + }); - it('has port', () => { - const port = internalrangeserviceModule.v1.InternalRangeServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); + it('has universeDomain', () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('should create a client with no option', () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient(); - assert(client); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + internalrangeserviceModule.v1.InternalRangeServiceClient.servicePath; + assert.strictEqual(servicePath, 'networkconnectivity.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + internalrangeserviceModule.v1.InternalRangeServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + universeDomain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkconnectivity.example.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - fallback: true, - }); - assert(client); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + universe_domain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkconnectivity.example.com'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.internalRangeServiceStub, undefined); - await client.initialize(); - assert(client.internalRangeServiceStub); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkconnectivity.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'networkconnectivity.configured.example.com', + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has close method for the initialized client', done => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.internalRangeServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has port', () => { + const port = + internalrangeserviceModule.v1.InternalRangeServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has close method for the non-initialized client', done => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.internalRangeServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with no option', () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient(); + assert(client); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + it('should create a client with gRPC fallback', () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + fallback: true, }); + assert(client); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); + it('has initialize method and supports deferred initialization', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.internalRangeServiceStub, undefined); + await client.initialize(); + assert(client.internalRangeServiceStub); }); - describe('getInternalRange', () => { - it('invokes getInternalRange without error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetInternalRangeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetInternalRangeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.InternalRange() - ); - client.innerApiCalls.getInternalRange = stubSimpleCall(expectedResponse); - const [response] = await client.getInternalRange(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInternalRange as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInternalRange as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInternalRange without error using callback', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetInternalRangeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetInternalRangeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.InternalRange() - ); - client.innerApiCalls.getInternalRange = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getInternalRange( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1.IInternalRange|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInternalRange as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInternalRange as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInternalRange with error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetInternalRangeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetInternalRangeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getInternalRange = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getInternalRange(request), expectedError); - const actualRequest = (client.innerApiCalls.getInternalRange as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInternalRange as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInternalRange with closed client', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetInternalRangeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetInternalRangeRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getInternalRange(request), expectedError); - }); - }); - - describe('createInternalRange', () => { - it('invokes createInternalRange without error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateInternalRangeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateInternalRangeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createInternalRange = stubLongRunningCall(expectedResponse); - const [operation] = await client.createInternalRange(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createInternalRange as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInternalRange as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createInternalRange without error using callback', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateInternalRangeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateInternalRangeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createInternalRange = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createInternalRange( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createInternalRange as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInternalRange as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createInternalRange with call error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateInternalRangeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateInternalRangeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createInternalRange = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createInternalRange(request), expectedError); - const actualRequest = (client.innerApiCalls.createInternalRange as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInternalRange as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createInternalRange with LRO error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreateInternalRangeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreateInternalRangeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createInternalRange = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createInternalRange(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createInternalRange as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInternalRange as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateInternalRangeProgress without error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateInternalRangeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateInternalRangeProgress with error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateInternalRangeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); + it('has close method for the initialized client', (done) => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.internalRangeServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('updateInternalRange', () => { - it('invokes updateInternalRange without error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateInternalRangeRequest() - ); - request.internalRange ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateInternalRangeRequest', ['internalRange', 'name']); - request.internalRange.name = defaultValue1; - const expectedHeaderRequestParams = `internal_range.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateInternalRange = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateInternalRange(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateInternalRange as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInternalRange as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInternalRange without error using callback', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateInternalRangeRequest() - ); - request.internalRange ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateInternalRangeRequest', ['internalRange', 'name']); - request.internalRange.name = defaultValue1; - const expectedHeaderRequestParams = `internal_range.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateInternalRange = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateInternalRange( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateInternalRange as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInternalRange as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInternalRange with call error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateInternalRangeRequest() - ); - request.internalRange ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateInternalRangeRequest', ['internalRange', 'name']); - request.internalRange.name = defaultValue1; - const expectedHeaderRequestParams = `internal_range.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateInternalRange = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateInternalRange(request), expectedError); - const actualRequest = (client.innerApiCalls.updateInternalRange as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInternalRange as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInternalRange with LRO error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.UpdateInternalRangeRequest() - ); - request.internalRange ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.UpdateInternalRangeRequest', ['internalRange', 'name']); - request.internalRange.name = defaultValue1; - const expectedHeaderRequestParams = `internal_range.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateInternalRange = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateInternalRange(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateInternalRange as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInternalRange as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateInternalRangeProgress without error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateInternalRangeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateInternalRangeProgress with error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateInternalRangeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); + it('has close method for the non-initialized client', (done) => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.internalRangeServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('deleteInternalRange', () => { - it('invokes deleteInternalRange without error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteInternalRangeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteInternalRangeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteInternalRange = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteInternalRange(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteInternalRange as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInternalRange as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteInternalRange without error using callback', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteInternalRangeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteInternalRangeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteInternalRange = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteInternalRange( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteInternalRange as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInternalRange as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteInternalRange with call error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteInternalRangeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteInternalRangeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteInternalRange = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteInternalRange(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteInternalRange as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInternalRange as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteInternalRange with LRO error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeleteInternalRangeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeleteInternalRangeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteInternalRange = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteInternalRange(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteInternalRange as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInternalRange as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteInternalRangeProgress without error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteInternalRangeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteInternalRangeProgress with error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteInternalRangeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getInternalRange', () => { + it('invokes getInternalRange without error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetInternalRangeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetInternalRangeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.InternalRange(), + ); + client.innerApiCalls.getInternalRange = stubSimpleCall(expectedResponse); + const [response] = await client.getInternalRange(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getInternalRange as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInternalRange as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listInternalRanges', () => { - it('invokes listInternalRanges without error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListInternalRangesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListInternalRangesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.InternalRange()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.InternalRange()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.InternalRange()), - ]; - client.innerApiCalls.listInternalRanges = stubSimpleCall(expectedResponse); - const [response] = await client.listInternalRanges(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInternalRanges as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInternalRanges as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInternalRanges without error using callback', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListInternalRangesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListInternalRangesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.InternalRange()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.InternalRange()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.InternalRange()), - ]; - client.innerApiCalls.listInternalRanges = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listInternalRanges( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1.IInternalRange[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInternalRanges as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInternalRanges as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInternalRanges with error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListInternalRangesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListInternalRangesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listInternalRanges = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listInternalRanges(request), expectedError); - const actualRequest = (client.innerApiCalls.listInternalRanges as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInternalRanges as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInternalRangesStream without error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListInternalRangesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListInternalRangesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.InternalRange()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.InternalRange()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.InternalRange()), - ]; - client.descriptors.page.listInternalRanges.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listInternalRangesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.InternalRange[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.InternalRange) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listInternalRanges.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInternalRanges, request)); - assert( - (client.descriptors.page.listInternalRanges.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listInternalRangesStream with error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListInternalRangesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListInternalRangesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listInternalRanges.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listInternalRangesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.InternalRange[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.InternalRange) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listInternalRanges.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInternalRanges, request)); - assert( - (client.descriptors.page.listInternalRanges.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listInternalRanges without error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListInternalRangesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListInternalRangesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.InternalRange()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.InternalRange()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.InternalRange()), - ]; - client.descriptors.page.listInternalRanges.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1.IInternalRange[] = []; - const iterable = client.listInternalRangesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes getInternalRange without error using callback', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetInternalRangeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetInternalRangeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.InternalRange(), + ); + client.innerApiCalls.getInternalRange = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getInternalRange( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1.IInternalRange | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listInternalRanges.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInternalRanges.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listInternalRanges with error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListInternalRangesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListInternalRangesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listInternalRanges.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listInternalRangesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1.IInternalRange[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listInternalRanges.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInternalRanges.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getInternalRange as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInternalRange as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('Path templates', () => { - - describe('destination', async () => { - const fakePath = "/rendered/path/destination"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - multicloud_data_transfer_config: "multicloudDataTransferConfigValue", - destination: "destinationValue", - }; - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.destinationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.destinationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('destinationPath', () => { - const result = client.destinationPath("projectValue", "locationValue", "multicloudDataTransferConfigValue", "destinationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.destinationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDestinationName', () => { - const result = client.matchProjectFromDestinationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromDestinationName', () => { - const result = client.matchLocationFromDestinationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMulticloudDataTransferConfigFromDestinationName', () => { - const result = client.matchMulticloudDataTransferConfigFromDestinationName(fakePath); - assert.strictEqual(result, "multicloudDataTransferConfigValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDestinationFromDestinationName', () => { - const result = client.matchDestinationFromDestinationName(fakePath); - assert.strictEqual(result, "destinationValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('group', async () => { - const fakePath = "/rendered/path/group"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - group: "groupValue", - }; - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.groupPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.groupPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('groupPath', () => { - const result = client.groupPath("projectValue", "hubValue", "groupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.groupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromGroupName', () => { - const result = client.matchProjectFromGroupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.groupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHubFromGroupName', () => { - const result = client.matchHubFromGroupName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.groupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchGroupFromGroupName', () => { - const result = client.matchGroupFromGroupName(fakePath); - assert.strictEqual(result, "groupValue"); - assert((client.pathTemplates.groupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('hub', async () => { - const fakePath = "/rendered/path/hub"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - }; - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.hubPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.hubPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('hubPath', () => { - const result = client.hubPath("projectValue", "hubValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.hubPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromHubName', () => { - const result = client.matchProjectFromHubName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.hubPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHubFromHubName', () => { - const result = client.matchHubFromHubName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.hubPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('hubRoute', async () => { - const fakePath = "/rendered/path/hubRoute"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - route_table: "routeTableValue", - route: "routeValue", - }; - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.hubRoutePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.hubRoutePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('hubRoutePath', () => { - const result = client.hubRoutePath("projectValue", "hubValue", "routeTableValue", "routeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.hubRoutePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromHubRouteName', () => { - const result = client.matchProjectFromHubRouteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHubFromHubRouteName', () => { - const result = client.matchHubFromHubRouteName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRouteTableFromHubRouteName', () => { - const result = client.matchRouteTableFromHubRouteName(fakePath); - assert.strictEqual(result, "routeTableValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRouteFromHubRouteName', () => { - const result = client.matchRouteFromHubRouteName(fakePath); - assert.strictEqual(result, "routeValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('internalRange', async () => { - const fakePath = "/rendered/path/internalRange"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - internal_range: "internalRangeValue", - }; - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.internalRangePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.internalRangePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('internalRangePath', () => { - const result = client.internalRangePath("projectValue", "locationValue", "internalRangeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.internalRangePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInternalRangeName', () => { - const result = client.matchProjectFromInternalRangeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.internalRangePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromInternalRangeName', () => { - const result = client.matchLocationFromInternalRangeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.internalRangePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInternalRangeFromInternalRangeName', () => { - const result = client.matchInternalRangeFromInternalRangeName(fakePath); - assert.strictEqual(result, "internalRangeValue"); - assert((client.pathTemplates.internalRangePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes getInternalRange with error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetInternalRangeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetInternalRangeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getInternalRange = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getInternalRange(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getInternalRange as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInternalRange as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('multicloudDataTransferConfig', async () => { - const fakePath = "/rendered/path/multicloudDataTransferConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - multicloud_data_transfer_config: "multicloudDataTransferConfigValue", - }; - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.multicloudDataTransferConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.multicloudDataTransferConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('multicloudDataTransferConfigPath', () => { - const result = client.multicloudDataTransferConfigPath("projectValue", "locationValue", "multicloudDataTransferConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes getInternalRange with closed client', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetInternalRangeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetInternalRangeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getInternalRange(request), expectedError); + }); + }); + + describe('createInternalRange', () => { + it('invokes createInternalRange without error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateInternalRangeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateInternalRangeRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createInternalRange = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createInternalRange(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createInternalRange as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInternalRange as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromMulticloudDataTransferConfigName', () => { - const result = client.matchProjectFromMulticloudDataTransferConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes createInternalRange without error using callback', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateInternalRangeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateInternalRangeRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createInternalRange = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createInternalRange( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1.IInternalRange, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1.IInternalRange, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createInternalRange as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInternalRange as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromMulticloudDataTransferConfigName', () => { - const result = client.matchLocationFromMulticloudDataTransferConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes createInternalRange with call error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateInternalRangeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateInternalRangeRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInternalRange = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createInternalRange(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createInternalRange as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInternalRange as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName', () => { - const result = client.matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName(fakePath); - assert.strictEqual(result, "multicloudDataTransferConfigValue"); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes createInternalRange with LRO error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreateInternalRangeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreateInternalRangeRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInternalRange = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createInternalRange(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createInternalRange as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInternalRange as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('multicloudDataTransferSupportedService', async () => { - const fakePath = "/rendered/path/multicloudDataTransferSupportedService"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - multicloud_data_transfer_supported_service: "multicloudDataTransferSupportedServiceValue", - }; - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('multicloudDataTransferSupportedServicePath', () => { - const result = client.multicloudDataTransferSupportedServicePath("projectValue", "locationValue", "multicloudDataTransferSupportedServiceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes checkCreateInternalRangeProgress without error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateInternalRangeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('matchProjectFromMulticloudDataTransferSupportedServiceName', () => { - const result = client.matchProjectFromMulticloudDataTransferSupportedServiceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkCreateInternalRangeProgress with error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateInternalRangeProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateInternalRange', () => { + it('invokes updateInternalRange without error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateInternalRangeRequest(), + ); + request.internalRange ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateInternalRangeRequest', + ['internalRange', 'name'], + ); + request.internalRange.name = defaultValue1; + const expectedHeaderRequestParams = `internal_range.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateInternalRange = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateInternalRange(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateInternalRange as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInternalRange as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromMulticloudDataTransferSupportedServiceName', () => { - const result = client.matchLocationFromMulticloudDataTransferSupportedServiceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes updateInternalRange without error using callback', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateInternalRangeRequest(), + ); + request.internalRange ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateInternalRangeRequest', + ['internalRange', 'name'], + ); + request.internalRange.name = defaultValue1; + const expectedHeaderRequestParams = `internal_range.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateInternalRange = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateInternalRange( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1.IInternalRange, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1.IInternalRange, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateInternalRange as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInternalRange as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName', () => { - const result = client.matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName(fakePath); - assert.strictEqual(result, "multicloudDataTransferSupportedServiceValue"); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes updateInternalRange with call error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateInternalRangeRequest(), + ); + request.internalRange ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateInternalRangeRequest', + ['internalRange', 'name'], + ); + request.internalRange.name = defaultValue1; + const expectedHeaderRequestParams = `internal_range.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInternalRange = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateInternalRange(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateInternalRange as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInternalRange as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('policyBasedRoute', async () => { - const fakePath = "/rendered/path/policyBasedRoute"; - const expectedParameters = { - project: "projectValue", - policy_based_route: "policyBasedRouteValue", - }; - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.policyBasedRoutePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.policyBasedRoutePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('policyBasedRoutePath', () => { - const result = client.policyBasedRoutePath("projectValue", "policyBasedRouteValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.policyBasedRoutePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes updateInternalRange with LRO error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.UpdateInternalRangeRequest(), + ); + request.internalRange ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.UpdateInternalRangeRequest', + ['internalRange', 'name'], + ); + request.internalRange.name = defaultValue1; + const expectedHeaderRequestParams = `internal_range.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInternalRange = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateInternalRange(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateInternalRange as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInternalRange as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromPolicyBasedRouteName', () => { - const result = client.matchProjectFromPolicyBasedRouteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkUpdateInternalRangeProgress without error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateInternalRangeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('matchPolicyBasedRouteFromPolicyBasedRouteName', () => { - const result = client.matchPolicyBasedRouteFromPolicyBasedRouteName(fakePath); - assert.strictEqual(result, "policyBasedRouteValue"); - assert((client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes checkUpdateInternalRangeProgress with error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateInternalRangeProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteInternalRange', () => { + it('invokes deleteInternalRange without error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteInternalRangeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteInternalRangeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteInternalRange = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteInternalRange(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteInternalRange as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInternalRange as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes deleteInternalRange without error using callback', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteInternalRangeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteInternalRangeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteInternalRange = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteInternalRange( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteInternalRange as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInternalRange as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes deleteInternalRange with call error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteInternalRangeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteInternalRangeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInternalRange = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteInternalRange(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteInternalRange as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInternalRange as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('routeTable', async () => { - const fakePath = "/rendered/path/routeTable"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - route_table: "routeTableValue", - }; - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.routeTablePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.routeTablePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('routeTablePath', () => { - const result = client.routeTablePath("projectValue", "hubValue", "routeTableValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.routeTablePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes deleteInternalRange with LRO error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeleteInternalRangeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeleteInternalRangeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInternalRange = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteInternalRange(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteInternalRange as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInternalRange as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromRouteTableName', () => { - const result = client.matchProjectFromRouteTableName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.routeTablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkDeleteInternalRangeProgress without error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteInternalRangeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('matchHubFromRouteTableName', () => { - const result = client.matchHubFromRouteTableName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.routeTablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkDeleteInternalRangeProgress with error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteInternalRangeProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listInternalRanges', () => { + it('invokes listInternalRanges without error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListInternalRangesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListInternalRangesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.InternalRange(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.InternalRange(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.InternalRange(), + ), + ]; + client.innerApiCalls.listInternalRanges = + stubSimpleCall(expectedResponse); + const [response] = await client.listInternalRanges(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listInternalRanges as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInternalRanges as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchRouteTableFromRouteTableName', () => { - const result = client.matchRouteTableFromRouteTableName(fakePath); - assert.strictEqual(result, "routeTableValue"); - assert((client.pathTemplates.routeTablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes listInternalRanges without error using callback', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListInternalRangesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListInternalRangesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.InternalRange(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.InternalRange(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.InternalRange(), + ), + ]; + client.innerApiCalls.listInternalRanges = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listInternalRanges( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkconnectivity.v1.IInternalRange[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listInternalRanges as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInternalRanges as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('serviceClass', async () => { - const fakePath = "/rendered/path/serviceClass"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service_class: "serviceClassValue", - }; - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.serviceClassPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.serviceClassPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('serviceClassPath', () => { - const result = client.serviceClassPath("projectValue", "locationValue", "serviceClassValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.serviceClassPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes listInternalRanges with error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListInternalRangesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListInternalRangesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listInternalRanges = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listInternalRanges(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listInternalRanges as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInternalRanges as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromServiceClassName', () => { - const result = client.matchProjectFromServiceClassName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.serviceClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listInternalRangesStream without error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListInternalRangesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListInternalRangesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.InternalRange(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.InternalRange(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.InternalRange(), + ), + ]; + client.descriptors.page.listInternalRanges.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listInternalRangesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.InternalRange[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1.InternalRange, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listInternalRanges.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listInternalRanges, request), + ); + assert( + (client.descriptors.page.listInternalRanges.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('matchLocationFromServiceClassName', () => { - const result = client.matchLocationFromServiceClassName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.serviceClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listInternalRangesStream with error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListInternalRangesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListInternalRangesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInternalRanges.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listInternalRangesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.InternalRange[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1.InternalRange, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listInternalRanges.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listInternalRanges, request), + ); + assert( + (client.descriptors.page.listInternalRanges.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('matchServiceClassFromServiceClassName', () => { - const result = client.matchServiceClassFromServiceClassName(fakePath); - assert.strictEqual(result, "serviceClassValue"); - assert((client.pathTemplates.serviceClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with listInternalRanges without error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListInternalRangesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListInternalRangesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.InternalRange(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.InternalRange(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.InternalRange(), + ), + ]; + client.descriptors.page.listInternalRanges.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1.IInternalRange[] = + []; + const iterable = client.listInternalRangesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listInternalRanges.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listInternalRanges.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - describe('serviceConnectionMap', async () => { - const fakePath = "/rendered/path/serviceConnectionMap"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service_connection_map: "serviceConnectionMapValue", - }; - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.serviceConnectionMapPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.serviceConnectionMapPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('serviceConnectionMapPath', () => { - const result = client.serviceConnectionMapPath("projectValue", "locationValue", "serviceConnectionMapValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.serviceConnectionMapPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('uses async iteration with listInternalRanges with error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListInternalRangesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListInternalRangesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInternalRanges.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listInternalRangesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1.IInternalRange[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listInternalRanges.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listInternalRanges.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getIamPolicy without error using callback', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); + }); + it('invokes getIamPolicy with error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes setIamPolicy without error using callback', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); + }); + it('invokes setIamPolicy with error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes testIamPermissions without error using callback', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); + }); + it('invokes testIamPermissions with error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('destination', async () => { + const fakePath = '/rendered/path/destination'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + multicloud_data_transfer_config: 'multicloudDataTransferConfigValue', + destination: 'destinationValue', + }; + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.destinationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.destinationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('destinationPath', () => { + const result = client.destinationPath( + 'projectValue', + 'locationValue', + 'multicloudDataTransferConfigValue', + 'destinationValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.destinationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromDestinationName', () => { + const result = client.matchProjectFromDestinationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromDestinationName', () => { + const result = client.matchLocationFromDestinationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMulticloudDataTransferConfigFromDestinationName', () => { + const result = + client.matchMulticloudDataTransferConfigFromDestinationName(fakePath); + assert.strictEqual(result, 'multicloudDataTransferConfigValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchDestinationFromDestinationName', () => { + const result = client.matchDestinationFromDestinationName(fakePath); + assert.strictEqual(result, 'destinationValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromServiceConnectionMapName', () => { - const result = client.matchProjectFromServiceConnectionMapName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.serviceConnectionMapPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('group', async () => { + const fakePath = '/rendered/path/group'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + group: 'groupValue', + }; + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.groupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.groupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('groupPath', () => { + const result = client.groupPath( + 'projectValue', + 'hubValue', + 'groupValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.groupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromGroupName', () => { + const result = client.matchProjectFromGroupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.groupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromGroupName', () => { + const result = client.matchHubFromGroupName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.groupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchGroupFromGroupName', () => { + const result = client.matchGroupFromGroupName(fakePath); + assert.strictEqual(result, 'groupValue'); + assert( + (client.pathTemplates.groupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchLocationFromServiceConnectionMapName', () => { - const result = client.matchLocationFromServiceConnectionMapName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.serviceConnectionMapPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('hub', async () => { + const fakePath = '/rendered/path/hub'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + }; + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.hubPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.hubPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('hubPath', () => { + const result = client.hubPath('projectValue', 'hubValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.hubPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromHubName', () => { + const result = client.matchProjectFromHubName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.hubPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromHubName', () => { + const result = client.matchHubFromHubName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.hubPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchServiceConnectionMapFromServiceConnectionMapName', () => { - const result = client.matchServiceConnectionMapFromServiceConnectionMapName(fakePath); - assert.strictEqual(result, "serviceConnectionMapValue"); - assert((client.pathTemplates.serviceConnectionMapPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('hubRoute', async () => { + const fakePath = '/rendered/path/hubRoute'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + route_table: 'routeTableValue', + route: 'routeValue', + }; + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.hubRoutePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.hubRoutePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('hubRoutePath', () => { + const result = client.hubRoutePath( + 'projectValue', + 'hubValue', + 'routeTableValue', + 'routeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.hubRoutePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromHubRouteName', () => { + const result = client.matchProjectFromHubRouteName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromHubRouteName', () => { + const result = client.matchHubFromHubRouteName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRouteTableFromHubRouteName', () => { + const result = client.matchRouteTableFromHubRouteName(fakePath); + assert.strictEqual(result, 'routeTableValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRouteFromHubRouteName', () => { + const result = client.matchRouteFromHubRouteName(fakePath); + assert.strictEqual(result, 'routeValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('serviceConnectionPolicy', async () => { - const fakePath = "/rendered/path/serviceConnectionPolicy"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service_connection_policy: "serviceConnectionPolicyValue", - }; - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.serviceConnectionPolicyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.serviceConnectionPolicyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('serviceConnectionPolicyPath', () => { - const result = client.serviceConnectionPolicyPath("projectValue", "locationValue", "serviceConnectionPolicyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.serviceConnectionPolicyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('internalRange', async () => { + const fakePath = '/rendered/path/internalRange'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + internal_range: 'internalRangeValue', + }; + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.internalRangePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.internalRangePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('internalRangePath', () => { + const result = client.internalRangePath( + 'projectValue', + 'locationValue', + 'internalRangeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.internalRangePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromInternalRangeName', () => { + const result = client.matchProjectFromInternalRangeName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.internalRangePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromInternalRangeName', () => { + const result = client.matchLocationFromInternalRangeName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.internalRangePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchInternalRangeFromInternalRangeName', () => { + const result = client.matchInternalRangeFromInternalRangeName(fakePath); + assert.strictEqual(result, 'internalRangeValue'); + assert( + (client.pathTemplates.internalRangePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromServiceConnectionPolicyName', () => { - const result = client.matchProjectFromServiceConnectionPolicyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.serviceConnectionPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchLocationFromServiceConnectionPolicyName', () => { - const result = client.matchLocationFromServiceConnectionPolicyName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.serviceConnectionPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('multicloudDataTransferConfig', async () => { + const fakePath = '/rendered/path/multicloudDataTransferConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + multicloud_data_transfer_config: 'multicloudDataTransferConfigValue', + }; + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.multicloudDataTransferConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.multicloudDataTransferConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('multicloudDataTransferConfigPath', () => { + const result = client.multicloudDataTransferConfigPath( + 'projectValue', + 'locationValue', + 'multicloudDataTransferConfigValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMulticloudDataTransferConfigName', () => { + const result = + client.matchProjectFromMulticloudDataTransferConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMulticloudDataTransferConfigName', () => { + const result = + client.matchLocationFromMulticloudDataTransferConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName', () => { + const result = + client.matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName( + fakePath, + ); + assert.strictEqual(result, 'multicloudDataTransferConfigValue'); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchServiceConnectionPolicyFromServiceConnectionPolicyName', () => { - const result = client.matchServiceConnectionPolicyFromServiceConnectionPolicyName(fakePath); - assert.strictEqual(result, "serviceConnectionPolicyValue"); - assert((client.pathTemplates.serviceConnectionPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('multicloudDataTransferSupportedService', async () => { + const fakePath = '/rendered/path/multicloudDataTransferSupportedService'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + multicloud_data_transfer_supported_service: + 'multicloudDataTransferSupportedServiceValue', + }; + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('multicloudDataTransferSupportedServicePath', () => { + const result = client.multicloudDataTransferSupportedServicePath( + 'projectValue', + 'locationValue', + 'multicloudDataTransferSupportedServiceValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMulticloudDataTransferSupportedServiceName', () => { + const result = + client.matchProjectFromMulticloudDataTransferSupportedServiceName( + fakePath, + ); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMulticloudDataTransferSupportedServiceName', () => { + const result = + client.matchLocationFromMulticloudDataTransferSupportedServiceName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName', () => { + const result = + client.matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName( + fakePath, + ); + assert.strictEqual( + result, + 'multicloudDataTransferSupportedServiceValue', + ); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('serviceConnectionToken', async () => { - const fakePath = "/rendered/path/serviceConnectionToken"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service_connection_token: "serviceConnectionTokenValue", - }; - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.serviceConnectionTokenPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.serviceConnectionTokenPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('serviceConnectionTokenPath', () => { - const result = client.serviceConnectionTokenPath("projectValue", "locationValue", "serviceConnectionTokenValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.serviceConnectionTokenPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('policyBasedRoute', async () => { + const fakePath = '/rendered/path/policyBasedRoute'; + const expectedParameters = { + project: 'projectValue', + policy_based_route: 'policyBasedRouteValue', + }; + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.policyBasedRoutePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.policyBasedRoutePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('policyBasedRoutePath', () => { + const result = client.policyBasedRoutePath( + 'projectValue', + 'policyBasedRouteValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.policyBasedRoutePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromPolicyBasedRouteName', () => { + const result = client.matchProjectFromPolicyBasedRouteName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchPolicyBasedRouteFromPolicyBasedRouteName', () => { + const result = + client.matchPolicyBasedRouteFromPolicyBasedRouteName(fakePath); + assert.strictEqual(result, 'policyBasedRouteValue'); + assert( + (client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromServiceConnectionTokenName', () => { - const result = client.matchProjectFromServiceConnectionTokenName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.serviceConnectionTokenPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchLocationFromServiceConnectionTokenName', () => { - const result = client.matchLocationFromServiceConnectionTokenName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.serviceConnectionTokenPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('routeTable', async () => { + const fakePath = '/rendered/path/routeTable'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + route_table: 'routeTableValue', + }; + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.routeTablePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.routeTablePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('routeTablePath', () => { + const result = client.routeTablePath( + 'projectValue', + 'hubValue', + 'routeTableValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.routeTablePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromRouteTableName', () => { + const result = client.matchProjectFromRouteTableName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.routeTablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromRouteTableName', () => { + const result = client.matchHubFromRouteTableName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.routeTablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRouteTableFromRouteTableName', () => { + const result = client.matchRouteTableFromRouteTableName(fakePath); + assert.strictEqual(result, 'routeTableValue'); + assert( + (client.pathTemplates.routeTablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchServiceConnectionTokenFromServiceConnectionTokenName', () => { - const result = client.matchServiceConnectionTokenFromServiceConnectionTokenName(fakePath); - assert.strictEqual(result, "serviceConnectionTokenValue"); - assert((client.pathTemplates.serviceConnectionTokenPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('serviceClass', async () => { + const fakePath = '/rendered/path/serviceClass'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service_class: 'serviceClassValue', + }; + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.serviceClassPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.serviceClassPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('serviceClassPath', () => { + const result = client.serviceClassPath( + 'projectValue', + 'locationValue', + 'serviceClassValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.serviceClassPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceClassName', () => { + const result = client.matchProjectFromServiceClassName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.serviceClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromServiceClassName', () => { + const result = client.matchLocationFromServiceClassName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.serviceClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceClassFromServiceClassName', () => { + const result = client.matchServiceClassFromServiceClassName(fakePath); + assert.strictEqual(result, 'serviceClassValue'); + assert( + (client.pathTemplates.serviceClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('spoke', async () => { - const fakePath = "/rendered/path/spoke"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - spoke: "spokeValue", - }; - const client = new internalrangeserviceModule.v1.InternalRangeServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.spokePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.spokePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('spokePath', () => { - const result = client.spokePath("projectValue", "locationValue", "spokeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.spokePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('serviceConnectionMap', async () => { + const fakePath = '/rendered/path/serviceConnectionMap'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service_connection_map: 'serviceConnectionMapValue', + }; + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.serviceConnectionMapPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.serviceConnectionMapPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('serviceConnectionMapPath', () => { + const result = client.serviceConnectionMapPath( + 'projectValue', + 'locationValue', + 'serviceConnectionMapValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.serviceConnectionMapPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceConnectionMapName', () => { + const result = + client.matchProjectFromServiceConnectionMapName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.serviceConnectionMapPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromServiceConnectionMapName', () => { + const result = + client.matchLocationFromServiceConnectionMapName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.serviceConnectionMapPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceConnectionMapFromServiceConnectionMapName', () => { + const result = + client.matchServiceConnectionMapFromServiceConnectionMapName( + fakePath, + ); + assert.strictEqual(result, 'serviceConnectionMapValue'); + assert( + ( + client.pathTemplates.serviceConnectionMapPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromSpokeName', () => { - const result = client.matchProjectFromSpokeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.spokePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('serviceConnectionPolicy', async () => { + const fakePath = '/rendered/path/serviceConnectionPolicy'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service_connection_policy: 'serviceConnectionPolicyValue', + }; + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.serviceConnectionPolicyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.serviceConnectionPolicyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('serviceConnectionPolicyPath', () => { + const result = client.serviceConnectionPolicyPath( + 'projectValue', + 'locationValue', + 'serviceConnectionPolicyValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.serviceConnectionPolicyPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceConnectionPolicyName', () => { + const result = + client.matchProjectFromServiceConnectionPolicyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.serviceConnectionPolicyPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromServiceConnectionPolicyName', () => { + const result = + client.matchLocationFromServiceConnectionPolicyName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.serviceConnectionPolicyPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceConnectionPolicyFromServiceConnectionPolicyName', () => { + const result = + client.matchServiceConnectionPolicyFromServiceConnectionPolicyName( + fakePath, + ); + assert.strictEqual(result, 'serviceConnectionPolicyValue'); + assert( + ( + client.pathTemplates.serviceConnectionPolicyPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchLocationFromSpokeName', () => { - const result = client.matchLocationFromSpokeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.spokePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('serviceConnectionToken', async () => { + const fakePath = '/rendered/path/serviceConnectionToken'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service_connection_token: 'serviceConnectionTokenValue', + }; + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.serviceConnectionTokenPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.serviceConnectionTokenPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('serviceConnectionTokenPath', () => { + const result = client.serviceConnectionTokenPath( + 'projectValue', + 'locationValue', + 'serviceConnectionTokenValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.serviceConnectionTokenPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceConnectionTokenName', () => { + const result = + client.matchProjectFromServiceConnectionTokenName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.serviceConnectionTokenPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromServiceConnectionTokenName', () => { + const result = + client.matchLocationFromServiceConnectionTokenName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.serviceConnectionTokenPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceConnectionTokenFromServiceConnectionTokenName', () => { + const result = + client.matchServiceConnectionTokenFromServiceConnectionTokenName( + fakePath, + ); + assert.strictEqual(result, 'serviceConnectionTokenValue'); + assert( + ( + client.pathTemplates.serviceConnectionTokenPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchSpokeFromSpokeName', () => { - const result = client.matchSpokeFromSpokeName(fakePath); - assert.strictEqual(result, "spokeValue"); - assert((client.pathTemplates.spokePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('spoke', async () => { + const fakePath = '/rendered/path/spoke'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + spoke: 'spokeValue', + }; + const client = + new internalrangeserviceModule.v1.InternalRangeServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.spokePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.spokePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('spokePath', () => { + const result = client.spokePath( + 'projectValue', + 'locationValue', + 'spokeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.spokePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromSpokeName', () => { + const result = client.matchProjectFromSpokeName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.spokePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromSpokeName', () => { + const result = client.matchLocationFromSpokeName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.spokePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchSpokeFromSpokeName', () => { + const result = client.matchSpokeFromSpokeName(fakePath); + assert.strictEqual(result, 'spokeValue'); + assert( + (client.pathTemplates.spokePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-networkconnectivity/test/gapic_policy_based_routing_service_v1.ts b/packages/google-cloud-networkconnectivity/test/gapic_policy_based_routing_service_v1.ts index c428a0d58e68..4a7f063bbaf5 100644 --- a/packages/google-cloud-networkconnectivity/test/gapic_policy_based_routing_service_v1.ts +++ b/packages/google-cloud-networkconnectivity/test/gapic_policy_based_routing_service_v1.ts @@ -19,2340 +19,3248 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as policybasedroutingserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + IamProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1.PolicyBasedRoutingServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient.servicePath; - assert.strictEqual(servicePath, 'networkconnectivity.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.policyBasedRoutingServiceStub, undefined); - await client.initialize(); - assert(client.policyBasedRoutingServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.policyBasedRoutingServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has close method for the non-initialized client', done => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.policyBasedRoutingServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - }); - - describe('getPolicyBasedRoute', () => { - it('invokes getPolicyBasedRoute without error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetPolicyBasedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetPolicyBasedRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute() - ); - client.innerApiCalls.getPolicyBasedRoute = stubSimpleCall(expectedResponse); - const [response] = await client.getPolicyBasedRoute(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getPolicyBasedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPolicyBasedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getPolicyBasedRoute without error using callback', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetPolicyBasedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetPolicyBasedRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute() - ); - client.innerApiCalls.getPolicyBasedRoute = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getPolicyBasedRoute( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getPolicyBasedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPolicyBasedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getPolicyBasedRoute with error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetPolicyBasedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetPolicyBasedRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getPolicyBasedRoute = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getPolicyBasedRoute(request), expectedError); - const actualRequest = (client.innerApiCalls.getPolicyBasedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPolicyBasedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getPolicyBasedRoute with closed client', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.GetPolicyBasedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.GetPolicyBasedRouteRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getPolicyBasedRoute(request), expectedError); - }); - }); - - describe('createPolicyBasedRoute', () => { - it('invokes createPolicyBasedRoute without error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreatePolicyBasedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreatePolicyBasedRouteRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createPolicyBasedRoute = stubLongRunningCall(expectedResponse); - const [operation] = await client.createPolicyBasedRoute(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createPolicyBasedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPolicyBasedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createPolicyBasedRoute without error using callback', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreatePolicyBasedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreatePolicyBasedRouteRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createPolicyBasedRoute = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createPolicyBasedRoute( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createPolicyBasedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPolicyBasedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createPolicyBasedRoute with call error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreatePolicyBasedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreatePolicyBasedRouteRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createPolicyBasedRoute = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createPolicyBasedRoute(request), expectedError); - const actualRequest = (client.innerApiCalls.createPolicyBasedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPolicyBasedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createPolicyBasedRoute with LRO error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.CreatePolicyBasedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.CreatePolicyBasedRouteRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createPolicyBasedRoute = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createPolicyBasedRoute(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createPolicyBasedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPolicyBasedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreatePolicyBasedRouteProgress without error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreatePolicyBasedRouteProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreatePolicyBasedRouteProgress with error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreatePolicyBasedRouteProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deletePolicyBasedRoute', () => { - it('invokes deletePolicyBasedRoute without error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeletePolicyBasedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeletePolicyBasedRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deletePolicyBasedRoute = stubLongRunningCall(expectedResponse); - const [operation] = await client.deletePolicyBasedRoute(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deletePolicyBasedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePolicyBasedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deletePolicyBasedRoute without error using callback', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeletePolicyBasedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeletePolicyBasedRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deletePolicyBasedRoute = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deletePolicyBasedRoute( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deletePolicyBasedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePolicyBasedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deletePolicyBasedRoute with call error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeletePolicyBasedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeletePolicyBasedRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deletePolicyBasedRoute = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deletePolicyBasedRoute(request), expectedError); - const actualRequest = (client.innerApiCalls.deletePolicyBasedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePolicyBasedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deletePolicyBasedRoute with LRO error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.DeletePolicyBasedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.DeletePolicyBasedRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deletePolicyBasedRoute = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deletePolicyBasedRoute(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deletePolicyBasedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePolicyBasedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeletePolicyBasedRouteProgress without error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeletePolicyBasedRouteProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeletePolicyBasedRouteProgress with error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeletePolicyBasedRouteProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listPolicyBasedRoutes', () => { - it('invokes listPolicyBasedRoutes without error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListPolicyBasedRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListPolicyBasedRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute()), - ]; - client.innerApiCalls.listPolicyBasedRoutes = stubSimpleCall(expectedResponse); - const [response] = await client.listPolicyBasedRoutes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPolicyBasedRoutes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPolicyBasedRoutes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPolicyBasedRoutes without error using callback', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListPolicyBasedRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListPolicyBasedRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute()), - ]; - client.innerApiCalls.listPolicyBasedRoutes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listPolicyBasedRoutes( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPolicyBasedRoutes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPolicyBasedRoutes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPolicyBasedRoutes with error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListPolicyBasedRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListPolicyBasedRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listPolicyBasedRoutes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listPolicyBasedRoutes(request), expectedError); - const actualRequest = (client.innerApiCalls.listPolicyBasedRoutes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPolicyBasedRoutes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPolicyBasedRoutesStream without error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListPolicyBasedRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListPolicyBasedRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute()), - ]; - client.descriptors.page.listPolicyBasedRoutes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listPolicyBasedRoutesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listPolicyBasedRoutes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPolicyBasedRoutes, request)); - assert( - (client.descriptors.page.listPolicyBasedRoutes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); + }); - it('invokes listPolicyBasedRoutesStream with error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListPolicyBasedRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListPolicyBasedRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listPolicyBasedRoutes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listPolicyBasedRoutesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listPolicyBasedRoutes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPolicyBasedRoutes, request)); - assert( - (client.descriptors.page.listPolicyBasedRoutes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('has universeDomain', () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('uses async iteration with listPolicyBasedRoutes without error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListPolicyBasedRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListPolicyBasedRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute()), - ]; - client.descriptors.page.listPolicyBasedRoutes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute[] = []; - const iterable = client.listPolicyBasedRoutesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listPolicyBasedRoutes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPolicyBasedRoutes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient + .servicePath; + assert.strictEqual(servicePath, 'networkconnectivity.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient + .apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + universeDomain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkconnectivity.example.com'); + }); - it('uses async iteration with listPolicyBasedRoutes with error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1.ListPolicyBasedRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1.ListPolicyBasedRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listPolicyBasedRoutes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listPolicyBasedRoutesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listPolicyBasedRoutes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPolicyBasedRoutes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + universe_domain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkconnectivity.example.com'); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkconnectivity.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient( + { universeDomain: 'configured.example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'networkconnectivity.configured.example.com', + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); - it('uses async iteration with listLocations with error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + }); + }); + + it('has port', () => { + const port = + policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + fallback: true, }); + assert(client); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); + + it('has initialize method and supports deferred initialization', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); - it('invokes getOperation without error using callback', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); + assert.strictEqual(client.policyBasedRoutingServiceStub, undefined); + await client.initialize(); + assert(client.policyBasedRoutingServiceStub); + }); + + it('has close method for the initialized client', (done) => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.policyBasedRoutingServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); - it('invokes cancelOperation without error using callback', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); + }); + + it('has close method for the non-initialized client', (done) => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.policyBasedRoutingServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); - it('invokes deleteOperation without error using callback', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getPolicyBasedRoute', () => { + it('invokes getPolicyBasedRoute without error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetPolicyBasedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetPolicyBasedRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute(), + ); + client.innerApiCalls.getPolicyBasedRoute = + stubSimpleCall(expectedResponse); + const [response] = await client.getPolicyBasedRoute(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getPolicyBasedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPolicyBasedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getPolicyBasedRoute without error using callback', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetPolicyBasedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetPolicyBasedRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute(), + ); + client.innerApiCalls.getPolicyBasedRoute = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getPolicyBasedRoute( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('destination', async () => { - const fakePath = "/rendered/path/destination"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - multicloud_data_transfer_config: "multicloudDataTransferConfigValue", - destination: "destinationValue", - }; - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.destinationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.destinationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('destinationPath', () => { - const result = client.destinationPath("projectValue", "locationValue", "multicloudDataTransferConfigValue", "destinationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.destinationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDestinationName', () => { - const result = client.matchProjectFromDestinationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromDestinationName', () => { - const result = client.matchLocationFromDestinationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMulticloudDataTransferConfigFromDestinationName', () => { - const result = client.matchMulticloudDataTransferConfigFromDestinationName(fakePath); - assert.strictEqual(result, "multicloudDataTransferConfigValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDestinationFromDestinationName', () => { - const result = client.matchDestinationFromDestinationName(fakePath); - assert.strictEqual(result, "destinationValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('group', async () => { - const fakePath = "/rendered/path/group"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - group: "groupValue", - }; - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.groupPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.groupPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('groupPath', () => { - const result = client.groupPath("projectValue", "hubValue", "groupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.groupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromGroupName', () => { - const result = client.matchProjectFromGroupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.groupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHubFromGroupName', () => { - const result = client.matchHubFromGroupName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.groupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchGroupFromGroupName', () => { - const result = client.matchGroupFromGroupName(fakePath); - assert.strictEqual(result, "groupValue"); - assert((client.pathTemplates.groupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('hub', async () => { - const fakePath = "/rendered/path/hub"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - }; - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.hubPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.hubPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('hubPath', () => { - const result = client.hubPath("projectValue", "hubValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.hubPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromHubName', () => { - const result = client.matchProjectFromHubName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.hubPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHubFromHubName', () => { - const result = client.matchHubFromHubName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.hubPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('hubRoute', async () => { - const fakePath = "/rendered/path/hubRoute"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - route_table: "routeTableValue", - route: "routeValue", - }; - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.hubRoutePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.hubRoutePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('hubRoutePath', () => { - const result = client.hubRoutePath("projectValue", "hubValue", "routeTableValue", "routeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.hubRoutePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromHubRouteName', () => { - const result = client.matchProjectFromHubRouteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHubFromHubRouteName', () => { - const result = client.matchHubFromHubRouteName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRouteTableFromHubRouteName', () => { - const result = client.matchRouteTableFromHubRouteName(fakePath); - assert.strictEqual(result, "routeTableValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRouteFromHubRouteName', () => { - const result = client.matchRouteFromHubRouteName(fakePath); - assert.strictEqual(result, "routeValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('internalRange', async () => { - const fakePath = "/rendered/path/internalRange"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - internal_range: "internalRangeValue", - }; - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.internalRangePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.internalRangePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('internalRangePath', () => { - const result = client.internalRangePath("projectValue", "locationValue", "internalRangeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.internalRangePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInternalRangeName', () => { - const result = client.matchProjectFromInternalRangeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.internalRangePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromInternalRangeName', () => { - const result = client.matchLocationFromInternalRangeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.internalRangePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInternalRangeFromInternalRangeName', () => { - const result = client.matchInternalRangeFromInternalRangeName(fakePath); - assert.strictEqual(result, "internalRangeValue"); - assert((client.pathTemplates.internalRangePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('multicloudDataTransferConfig', async () => { - const fakePath = "/rendered/path/multicloudDataTransferConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - multicloud_data_transfer_config: "multicloudDataTransferConfigValue", - }; - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.multicloudDataTransferConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.multicloudDataTransferConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('multicloudDataTransferConfigPath', () => { - const result = client.multicloudDataTransferConfigPath("projectValue", "locationValue", "multicloudDataTransferConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMulticloudDataTransferConfigName', () => { - const result = client.matchProjectFromMulticloudDataTransferConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMulticloudDataTransferConfigName', () => { - const result = client.matchLocationFromMulticloudDataTransferConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName', () => { - const result = client.matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName(fakePath); - assert.strictEqual(result, "multicloudDataTransferConfigValue"); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('multicloudDataTransferSupportedService', async () => { - const fakePath = "/rendered/path/multicloudDataTransferSupportedService"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - multicloud_data_transfer_supported_service: "multicloudDataTransferSupportedServiceValue", - }; - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('multicloudDataTransferSupportedServicePath', () => { - const result = client.multicloudDataTransferSupportedServicePath("projectValue", "locationValue", "multicloudDataTransferSupportedServiceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMulticloudDataTransferSupportedServiceName', () => { - const result = client.matchProjectFromMulticloudDataTransferSupportedServiceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMulticloudDataTransferSupportedServiceName', () => { - const result = client.matchLocationFromMulticloudDataTransferSupportedServiceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName', () => { - const result = client.matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName(fakePath); - assert.strictEqual(result, "multicloudDataTransferSupportedServiceValue"); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('network', async () => { - const fakePath = "/rendered/path/network"; - const expectedParameters = { - project: "projectValue", - resource_id: "resourceIdValue", - }; - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.networkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.networkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('networkPath', () => { - const result = client.networkPath("projectValue", "resourceIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.networkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromNetworkName', () => { - const result = client.matchProjectFromNetworkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.networkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchResourceIdFromNetworkName', () => { - const result = client.matchResourceIdFromNetworkName(fakePath); - assert.strictEqual(result, "resourceIdValue"); - assert((client.pathTemplates.networkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('policyBasedRoute', async () => { - const fakePath = "/rendered/path/policyBasedRoute"; - const expectedParameters = { - project: "projectValue", - policy_based_route: "policyBasedRouteValue", - }; - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.policyBasedRoutePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.policyBasedRoutePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('policyBasedRoutePath', () => { - const result = client.policyBasedRoutePath("projectValue", "policyBasedRouteValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.policyBasedRoutePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromPolicyBasedRouteName', () => { - const result = client.matchProjectFromPolicyBasedRouteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchPolicyBasedRouteFromPolicyBasedRouteName', () => { - const result = client.matchPolicyBasedRouteFromPolicyBasedRouteName(fakePath); - assert.strictEqual(result, "policyBasedRouteValue"); - assert((client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('routeTable', async () => { - const fakePath = "/rendered/path/routeTable"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - route_table: "routeTableValue", - }; - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.routeTablePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.routeTablePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('routeTablePath', () => { - const result = client.routeTablePath("projectValue", "hubValue", "routeTableValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.routeTablePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRouteTableName', () => { - const result = client.matchProjectFromRouteTableName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.routeTablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHubFromRouteTableName', () => { - const result = client.matchHubFromRouteTableName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.routeTablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRouteTableFromRouteTableName', () => { - const result = client.matchRouteTableFromRouteTableName(fakePath); - assert.strictEqual(result, "routeTableValue"); - assert((client.pathTemplates.routeTablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('serviceClass', async () => { - const fakePath = "/rendered/path/serviceClass"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service_class: "serviceClassValue", - }; - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.serviceClassPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.serviceClassPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('serviceClassPath', () => { - const result = client.serviceClassPath("projectValue", "locationValue", "serviceClassValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.serviceClassPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceClassName', () => { - const result = client.matchProjectFromServiceClassName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.serviceClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServiceClassName', () => { - const result = client.matchLocationFromServiceClassName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.serviceClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceClassFromServiceClassName', () => { - const result = client.matchServiceClassFromServiceClassName(fakePath); - assert.strictEqual(result, "serviceClassValue"); - assert((client.pathTemplates.serviceClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('serviceConnectionMap', async () => { - const fakePath = "/rendered/path/serviceConnectionMap"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service_connection_map: "serviceConnectionMapValue", - }; - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.serviceConnectionMapPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.serviceConnectionMapPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('serviceConnectionMapPath', () => { - const result = client.serviceConnectionMapPath("projectValue", "locationValue", "serviceConnectionMapValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.serviceConnectionMapPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceConnectionMapName', () => { - const result = client.matchProjectFromServiceConnectionMapName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.serviceConnectionMapPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServiceConnectionMapName', () => { - const result = client.matchLocationFromServiceConnectionMapName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.serviceConnectionMapPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceConnectionMapFromServiceConnectionMapName', () => { - const result = client.matchServiceConnectionMapFromServiceConnectionMapName(fakePath); - assert.strictEqual(result, "serviceConnectionMapValue"); - assert((client.pathTemplates.serviceConnectionMapPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('serviceConnectionPolicy', async () => { - const fakePath = "/rendered/path/serviceConnectionPolicy"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service_connection_policy: "serviceConnectionPolicyValue", - }; - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.serviceConnectionPolicyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.serviceConnectionPolicyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('serviceConnectionPolicyPath', () => { - const result = client.serviceConnectionPolicyPath("projectValue", "locationValue", "serviceConnectionPolicyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.serviceConnectionPolicyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceConnectionPolicyName', () => { - const result = client.matchProjectFromServiceConnectionPolicyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.serviceConnectionPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServiceConnectionPolicyName', () => { - const result = client.matchLocationFromServiceConnectionPolicyName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.serviceConnectionPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceConnectionPolicyFromServiceConnectionPolicyName', () => { - const result = client.matchServiceConnectionPolicyFromServiceConnectionPolicyName(fakePath); - assert.strictEqual(result, "serviceConnectionPolicyValue"); - assert((client.pathTemplates.serviceConnectionPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('serviceConnectionToken', async () => { - const fakePath = "/rendered/path/serviceConnectionToken"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service_connection_token: "serviceConnectionTokenValue", - }; - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.serviceConnectionTokenPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.serviceConnectionTokenPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('serviceConnectionTokenPath', () => { - const result = client.serviceConnectionTokenPath("projectValue", "locationValue", "serviceConnectionTokenValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.serviceConnectionTokenPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceConnectionTokenName', () => { - const result = client.matchProjectFromServiceConnectionTokenName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.serviceConnectionTokenPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServiceConnectionTokenName', () => { - const result = client.matchLocationFromServiceConnectionTokenName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.serviceConnectionTokenPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceConnectionTokenFromServiceConnectionTokenName', () => { - const result = client.matchServiceConnectionTokenFromServiceConnectionTokenName(fakePath); - assert.strictEqual(result, "serviceConnectionTokenValue"); - assert((client.pathTemplates.serviceConnectionTokenPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('spoke', async () => { - const fakePath = "/rendered/path/spoke"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - spoke: "spokeValue", - }; - const client = new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.spokePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.spokePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('spokePath', () => { - const result = client.spokePath("projectValue", "locationValue", "spokeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.spokePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromSpokeName', () => { - const result = client.matchProjectFromSpokeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.spokePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromSpokeName', () => { - const result = client.matchLocationFromSpokeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.spokePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSpokeFromSpokeName', () => { - const result = client.matchSpokeFromSpokeName(fakePath); - assert.strictEqual(result, "spokeValue"); - assert((client.pathTemplates.spokePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getPolicyBasedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPolicyBasedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getPolicyBasedRoute with error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetPolicyBasedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetPolicyBasedRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getPolicyBasedRoute = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getPolicyBasedRoute(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getPolicyBasedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPolicyBasedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getPolicyBasedRoute with closed client', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.GetPolicyBasedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.GetPolicyBasedRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getPolicyBasedRoute(request), expectedError); + }); + }); + + describe('createPolicyBasedRoute', () => { + it('invokes createPolicyBasedRoute without error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreatePolicyBasedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreatePolicyBasedRouteRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createPolicyBasedRoute = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createPolicyBasedRoute(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createPolicyBasedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPolicyBasedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createPolicyBasedRoute without error using callback', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreatePolicyBasedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreatePolicyBasedRouteRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createPolicyBasedRoute = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createPolicyBasedRoute( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createPolicyBasedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPolicyBasedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createPolicyBasedRoute with call error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreatePolicyBasedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreatePolicyBasedRouteRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createPolicyBasedRoute = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.createPolicyBasedRoute(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createPolicyBasedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPolicyBasedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createPolicyBasedRoute with LRO error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.CreatePolicyBasedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.CreatePolicyBasedRouteRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createPolicyBasedRoute = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createPolicyBasedRoute(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createPolicyBasedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPolicyBasedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreatePolicyBasedRouteProgress without error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreatePolicyBasedRouteProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreatePolicyBasedRouteProgress with error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreatePolicyBasedRouteProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deletePolicyBasedRoute', () => { + it('invokes deletePolicyBasedRoute without error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeletePolicyBasedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeletePolicyBasedRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deletePolicyBasedRoute = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deletePolicyBasedRoute(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deletePolicyBasedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePolicyBasedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePolicyBasedRoute without error using callback', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeletePolicyBasedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeletePolicyBasedRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deletePolicyBasedRoute = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deletePolicyBasedRoute( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deletePolicyBasedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePolicyBasedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePolicyBasedRoute with call error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeletePolicyBasedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeletePolicyBasedRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deletePolicyBasedRoute = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.deletePolicyBasedRoute(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deletePolicyBasedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePolicyBasedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePolicyBasedRoute with LRO error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.DeletePolicyBasedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.DeletePolicyBasedRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deletePolicyBasedRoute = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deletePolicyBasedRoute(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deletePolicyBasedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePolicyBasedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeletePolicyBasedRouteProgress without error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeletePolicyBasedRouteProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeletePolicyBasedRouteProgress with error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeletePolicyBasedRouteProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listPolicyBasedRoutes', () => { + it('invokes listPolicyBasedRoutes without error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListPolicyBasedRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListPolicyBasedRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute(), + ), + ]; + client.innerApiCalls.listPolicyBasedRoutes = + stubSimpleCall(expectedResponse); + const [response] = await client.listPolicyBasedRoutes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listPolicyBasedRoutes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPolicyBasedRoutes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPolicyBasedRoutes without error using callback', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListPolicyBasedRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListPolicyBasedRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute(), + ), + ]; + client.innerApiCalls.listPolicyBasedRoutes = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listPolicyBasedRoutes( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listPolicyBasedRoutes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPolicyBasedRoutes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPolicyBasedRoutes with error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListPolicyBasedRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListPolicyBasedRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listPolicyBasedRoutes = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listPolicyBasedRoutes(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listPolicyBasedRoutes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPolicyBasedRoutes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPolicyBasedRoutesStream without error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListPolicyBasedRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListPolicyBasedRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute(), + ), + ]; + client.descriptors.page.listPolicyBasedRoutes.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listPolicyBasedRoutesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listPolicyBasedRoutes + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listPolicyBasedRoutes, request), + ); + assert( + ( + client.descriptors.page.listPolicyBasedRoutes + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + + it('invokes listPolicyBasedRoutesStream with error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListPolicyBasedRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListPolicyBasedRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPolicyBasedRoutes.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listPolicyBasedRoutesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listPolicyBasedRoutes + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listPolicyBasedRoutes, request), + ); + assert( + ( + client.descriptors.page.listPolicyBasedRoutes + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + + it('uses async iteration with listPolicyBasedRoutes without error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListPolicyBasedRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListPolicyBasedRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.PolicyBasedRoute(), + ), + ]; + client.descriptors.page.listPolicyBasedRoutes.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute[] = + []; + const iterable = client.listPolicyBasedRoutesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listPolicyBasedRoutes + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listPolicyBasedRoutes + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + + it('uses async iteration with listPolicyBasedRoutes with error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1.ListPolicyBasedRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1.ListPolicyBasedRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPolicyBasedRoutes.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listPolicyBasedRoutesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1.IPolicyBasedRoute[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listPolicyBasedRoutes + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listPolicyBasedRoutes + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getIamPolicy without error using callback', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); + }); + it('invokes getIamPolicy with error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes setIamPolicy without error using callback', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); + }); + it('invokes setIamPolicy with error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes testIamPermissions without error using callback', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); + }); + it('invokes testIamPermissions with error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('destination', async () => { + const fakePath = '/rendered/path/destination'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + multicloud_data_transfer_config: 'multicloudDataTransferConfigValue', + destination: 'destinationValue', + }; + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.destinationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.destinationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('destinationPath', () => { + const result = client.destinationPath( + 'projectValue', + 'locationValue', + 'multicloudDataTransferConfigValue', + 'destinationValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.destinationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromDestinationName', () => { + const result = client.matchProjectFromDestinationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromDestinationName', () => { + const result = client.matchLocationFromDestinationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMulticloudDataTransferConfigFromDestinationName', () => { + const result = + client.matchMulticloudDataTransferConfigFromDestinationName(fakePath); + assert.strictEqual(result, 'multicloudDataTransferConfigValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchDestinationFromDestinationName', () => { + const result = client.matchDestinationFromDestinationName(fakePath); + assert.strictEqual(result, 'destinationValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('group', async () => { + const fakePath = '/rendered/path/group'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + group: 'groupValue', + }; + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.groupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.groupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('groupPath', () => { + const result = client.groupPath( + 'projectValue', + 'hubValue', + 'groupValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.groupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromGroupName', () => { + const result = client.matchProjectFromGroupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.groupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromGroupName', () => { + const result = client.matchHubFromGroupName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.groupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchGroupFromGroupName', () => { + const result = client.matchGroupFromGroupName(fakePath); + assert.strictEqual(result, 'groupValue'); + assert( + (client.pathTemplates.groupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('hub', async () => { + const fakePath = '/rendered/path/hub'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + }; + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.hubPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.hubPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('hubPath', () => { + const result = client.hubPath('projectValue', 'hubValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.hubPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromHubName', () => { + const result = client.matchProjectFromHubName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.hubPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromHubName', () => { + const result = client.matchHubFromHubName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.hubPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('hubRoute', async () => { + const fakePath = '/rendered/path/hubRoute'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + route_table: 'routeTableValue', + route: 'routeValue', + }; + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.hubRoutePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.hubRoutePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('hubRoutePath', () => { + const result = client.hubRoutePath( + 'projectValue', + 'hubValue', + 'routeTableValue', + 'routeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.hubRoutePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromHubRouteName', () => { + const result = client.matchProjectFromHubRouteName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromHubRouteName', () => { + const result = client.matchHubFromHubRouteName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRouteTableFromHubRouteName', () => { + const result = client.matchRouteTableFromHubRouteName(fakePath); + assert.strictEqual(result, 'routeTableValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRouteFromHubRouteName', () => { + const result = client.matchRouteFromHubRouteName(fakePath); + assert.strictEqual(result, 'routeValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('internalRange', async () => { + const fakePath = '/rendered/path/internalRange'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + internal_range: 'internalRangeValue', + }; + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.internalRangePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.internalRangePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('internalRangePath', () => { + const result = client.internalRangePath( + 'projectValue', + 'locationValue', + 'internalRangeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.internalRangePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromInternalRangeName', () => { + const result = client.matchProjectFromInternalRangeName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.internalRangePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromInternalRangeName', () => { + const result = client.matchLocationFromInternalRangeName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.internalRangePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchInternalRangeFromInternalRangeName', () => { + const result = client.matchInternalRangeFromInternalRangeName(fakePath); + assert.strictEqual(result, 'internalRangeValue'); + assert( + (client.pathTemplates.internalRangePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('multicloudDataTransferConfig', async () => { + const fakePath = '/rendered/path/multicloudDataTransferConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + multicloud_data_transfer_config: 'multicloudDataTransferConfigValue', + }; + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.multicloudDataTransferConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.multicloudDataTransferConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('multicloudDataTransferConfigPath', () => { + const result = client.multicloudDataTransferConfigPath( + 'projectValue', + 'locationValue', + 'multicloudDataTransferConfigValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMulticloudDataTransferConfigName', () => { + const result = + client.matchProjectFromMulticloudDataTransferConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMulticloudDataTransferConfigName', () => { + const result = + client.matchLocationFromMulticloudDataTransferConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName', () => { + const result = + client.matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName( + fakePath, + ); + assert.strictEqual(result, 'multicloudDataTransferConfigValue'); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('multicloudDataTransferSupportedService', async () => { + const fakePath = '/rendered/path/multicloudDataTransferSupportedService'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + multicloud_data_transfer_supported_service: + 'multicloudDataTransferSupportedServiceValue', + }; + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('multicloudDataTransferSupportedServicePath', () => { + const result = client.multicloudDataTransferSupportedServicePath( + 'projectValue', + 'locationValue', + 'multicloudDataTransferSupportedServiceValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMulticloudDataTransferSupportedServiceName', () => { + const result = + client.matchProjectFromMulticloudDataTransferSupportedServiceName( + fakePath, + ); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMulticloudDataTransferSupportedServiceName', () => { + const result = + client.matchLocationFromMulticloudDataTransferSupportedServiceName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName', () => { + const result = + client.matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName( + fakePath, + ); + assert.strictEqual( + result, + 'multicloudDataTransferSupportedServiceValue', + ); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('network', async () => { + const fakePath = '/rendered/path/network'; + const expectedParameters = { + project: 'projectValue', + resource_id: 'resourceIdValue', + }; + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.networkPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.networkPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('networkPath', () => { + const result = client.networkPath('projectValue', 'resourceIdValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.networkPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromNetworkName', () => { + const result = client.matchProjectFromNetworkName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.networkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchResourceIdFromNetworkName', () => { + const result = client.matchResourceIdFromNetworkName(fakePath); + assert.strictEqual(result, 'resourceIdValue'); + assert( + (client.pathTemplates.networkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('policyBasedRoute', async () => { + const fakePath = '/rendered/path/policyBasedRoute'; + const expectedParameters = { + project: 'projectValue', + policy_based_route: 'policyBasedRouteValue', + }; + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.policyBasedRoutePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.policyBasedRoutePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('policyBasedRoutePath', () => { + const result = client.policyBasedRoutePath( + 'projectValue', + 'policyBasedRouteValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.policyBasedRoutePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromPolicyBasedRouteName', () => { + const result = client.matchProjectFromPolicyBasedRouteName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchPolicyBasedRouteFromPolicyBasedRouteName', () => { + const result = + client.matchPolicyBasedRouteFromPolicyBasedRouteName(fakePath); + assert.strictEqual(result, 'policyBasedRouteValue'); + assert( + (client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('routeTable', async () => { + const fakePath = '/rendered/path/routeTable'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + route_table: 'routeTableValue', + }; + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.routeTablePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.routeTablePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('routeTablePath', () => { + const result = client.routeTablePath( + 'projectValue', + 'hubValue', + 'routeTableValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.routeTablePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromRouteTableName', () => { + const result = client.matchProjectFromRouteTableName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.routeTablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromRouteTableName', () => { + const result = client.matchHubFromRouteTableName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.routeTablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRouteTableFromRouteTableName', () => { + const result = client.matchRouteTableFromRouteTableName(fakePath); + assert.strictEqual(result, 'routeTableValue'); + assert( + (client.pathTemplates.routeTablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('serviceClass', async () => { + const fakePath = '/rendered/path/serviceClass'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service_class: 'serviceClassValue', + }; + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.serviceClassPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.serviceClassPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('serviceClassPath', () => { + const result = client.serviceClassPath( + 'projectValue', + 'locationValue', + 'serviceClassValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.serviceClassPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceClassName', () => { + const result = client.matchProjectFromServiceClassName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.serviceClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromServiceClassName', () => { + const result = client.matchLocationFromServiceClassName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.serviceClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceClassFromServiceClassName', () => { + const result = client.matchServiceClassFromServiceClassName(fakePath); + assert.strictEqual(result, 'serviceClassValue'); + assert( + (client.pathTemplates.serviceClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('serviceConnectionMap', async () => { + const fakePath = '/rendered/path/serviceConnectionMap'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service_connection_map: 'serviceConnectionMapValue', + }; + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.serviceConnectionMapPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.serviceConnectionMapPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('serviceConnectionMapPath', () => { + const result = client.serviceConnectionMapPath( + 'projectValue', + 'locationValue', + 'serviceConnectionMapValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.serviceConnectionMapPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceConnectionMapName', () => { + const result = + client.matchProjectFromServiceConnectionMapName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.serviceConnectionMapPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromServiceConnectionMapName', () => { + const result = + client.matchLocationFromServiceConnectionMapName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.serviceConnectionMapPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceConnectionMapFromServiceConnectionMapName', () => { + const result = + client.matchServiceConnectionMapFromServiceConnectionMapName( + fakePath, + ); + assert.strictEqual(result, 'serviceConnectionMapValue'); + assert( + ( + client.pathTemplates.serviceConnectionMapPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('serviceConnectionPolicy', async () => { + const fakePath = '/rendered/path/serviceConnectionPolicy'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service_connection_policy: 'serviceConnectionPolicyValue', + }; + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.serviceConnectionPolicyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.serviceConnectionPolicyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('serviceConnectionPolicyPath', () => { + const result = client.serviceConnectionPolicyPath( + 'projectValue', + 'locationValue', + 'serviceConnectionPolicyValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.serviceConnectionPolicyPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceConnectionPolicyName', () => { + const result = + client.matchProjectFromServiceConnectionPolicyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.serviceConnectionPolicyPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromServiceConnectionPolicyName', () => { + const result = + client.matchLocationFromServiceConnectionPolicyName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.serviceConnectionPolicyPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceConnectionPolicyFromServiceConnectionPolicyName', () => { + const result = + client.matchServiceConnectionPolicyFromServiceConnectionPolicyName( + fakePath, + ); + assert.strictEqual(result, 'serviceConnectionPolicyValue'); + assert( + ( + client.pathTemplates.serviceConnectionPolicyPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('serviceConnectionToken', async () => { + const fakePath = '/rendered/path/serviceConnectionToken'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service_connection_token: 'serviceConnectionTokenValue', + }; + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.serviceConnectionTokenPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.serviceConnectionTokenPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('serviceConnectionTokenPath', () => { + const result = client.serviceConnectionTokenPath( + 'projectValue', + 'locationValue', + 'serviceConnectionTokenValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.serviceConnectionTokenPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceConnectionTokenName', () => { + const result = + client.matchProjectFromServiceConnectionTokenName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.serviceConnectionTokenPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromServiceConnectionTokenName', () => { + const result = + client.matchLocationFromServiceConnectionTokenName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.serviceConnectionTokenPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceConnectionTokenFromServiceConnectionTokenName', () => { + const result = + client.matchServiceConnectionTokenFromServiceConnectionTokenName( + fakePath, + ); + assert.strictEqual(result, 'serviceConnectionTokenValue'); + assert( + ( + client.pathTemplates.serviceConnectionTokenPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('spoke', async () => { + const fakePath = '/rendered/path/spoke'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + spoke: 'spokeValue', + }; + const client = + new policybasedroutingserviceModule.v1.PolicyBasedRoutingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.spokePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.spokePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('spokePath', () => { + const result = client.spokePath( + 'projectValue', + 'locationValue', + 'spokeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.spokePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromSpokeName', () => { + const result = client.matchProjectFromSpokeName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.spokePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromSpokeName', () => { + const result = client.matchLocationFromSpokeName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.spokePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchSpokeFromSpokeName', () => { + const result = client.matchSpokeFromSpokeName(fakePath); + assert.strictEqual(result, 'spokeValue'); + assert( + (client.pathTemplates.spokePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-networkconnectivity/test/gapic_policy_based_routing_service_v1beta.ts b/packages/google-cloud-networkconnectivity/test/gapic_policy_based_routing_service_v1beta.ts index 3e76122201d2..a6173191788c 100644 --- a/packages/google-cloud-networkconnectivity/test/gapic_policy_based_routing_service_v1beta.ts +++ b/packages/google-cloud-networkconnectivity/test/gapic_policy_based_routing_service_v1beta.ts @@ -19,2256 +19,3253 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as policybasedroutingserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + IamProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1beta.PolicyBasedRoutingServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient.servicePath; - assert.strictEqual(servicePath, 'networkconnectivity.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); + }); - it('has port', () => { - const port = policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); + it('has universeDomain', () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('should create a client with no option', () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient(); - assert(client); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient + .servicePath; + assert.strictEqual(servicePath, 'networkconnectivity.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient + .apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { universeDomain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkconnectivity.example.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - fallback: true, - }); - assert(client); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { universe_domain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkconnectivity.example.com'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.policyBasedRoutingServiceStub, undefined); - await client.initialize(); - assert(client.policyBasedRoutingServiceStub); - }); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkconnectivity.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { universeDomain: 'configured.example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'networkconnectivity.configured.example.com', + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { universe_domain: 'example.com', universeDomain: 'example.net' }, + ); + }); + }); - it('has close method for the initialized client', done => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.policyBasedRoutingServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has port', () => { + const port = + policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient + .port; + assert(port); + assert(typeof port === 'number'); + }); - it('has close method for the non-initialized client', done => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.policyBasedRoutingServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with no option', () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient(); + assert(client); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); + it('should create a client with gRPC fallback', () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + fallback: true, + }, + ); + assert(client); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.policyBasedRoutingServiceStub, undefined); + await client.initialize(); + assert(client.policyBasedRoutingServiceStub); }); - describe('getPolicyBasedRoute', () => { - it('invokes getPolicyBasedRoute without error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetPolicyBasedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetPolicyBasedRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute() - ); - client.innerApiCalls.getPolicyBasedRoute = stubSimpleCall(expectedResponse); - const [response] = await client.getPolicyBasedRoute(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getPolicyBasedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPolicyBasedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the initialized client', (done) => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.initialize().catch((err) => { + throw err; + }); + assert(client.policyBasedRoutingServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getPolicyBasedRoute without error using callback', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetPolicyBasedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetPolicyBasedRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute() - ); - client.innerApiCalls.getPolicyBasedRoute = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getPolicyBasedRoute( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getPolicyBasedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPolicyBasedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the non-initialized client', (done) => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.policyBasedRoutingServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getPolicyBasedRoute with error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetPolicyBasedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetPolicyBasedRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getPolicyBasedRoute = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getPolicyBasedRoute(request), expectedError); - const actualRequest = (client.innerApiCalls.getPolicyBasedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPolicyBasedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('invokes getPolicyBasedRoute with closed client', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetPolicyBasedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetPolicyBasedRouteRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getPolicyBasedRoute(request), expectedError); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getPolicyBasedRoute', () => { + it('invokes getPolicyBasedRoute without error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetPolicyBasedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetPolicyBasedRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute(), + ); + client.innerApiCalls.getPolicyBasedRoute = + stubSimpleCall(expectedResponse); + const [response] = await client.getPolicyBasedRoute(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getPolicyBasedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPolicyBasedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createPolicyBasedRoute', () => { - it('invokes createPolicyBasedRoute without error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.CreatePolicyBasedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.CreatePolicyBasedRouteRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createPolicyBasedRoute = stubLongRunningCall(expectedResponse); - const [operation] = await client.createPolicyBasedRoute(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createPolicyBasedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPolicyBasedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getPolicyBasedRoute without error using callback', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetPolicyBasedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetPolicyBasedRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute(), + ); + client.innerApiCalls.getPolicyBasedRoute = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getPolicyBasedRoute( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getPolicyBasedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPolicyBasedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createPolicyBasedRoute without error using callback', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.CreatePolicyBasedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.CreatePolicyBasedRouteRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createPolicyBasedRoute = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createPolicyBasedRoute( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createPolicyBasedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPolicyBasedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getPolicyBasedRoute with error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetPolicyBasedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetPolicyBasedRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getPolicyBasedRoute = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getPolicyBasedRoute(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getPolicyBasedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPolicyBasedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createPolicyBasedRoute with call error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.CreatePolicyBasedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.CreatePolicyBasedRouteRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createPolicyBasedRoute = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createPolicyBasedRoute(request), expectedError); - const actualRequest = (client.innerApiCalls.createPolicyBasedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPolicyBasedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getPolicyBasedRoute with closed client', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetPolicyBasedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetPolicyBasedRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getPolicyBasedRoute(request), expectedError); + }); + }); + + describe('createPolicyBasedRoute', () => { + it('invokes createPolicyBasedRoute without error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.CreatePolicyBasedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.CreatePolicyBasedRouteRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createPolicyBasedRoute = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createPolicyBasedRoute(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createPolicyBasedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPolicyBasedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createPolicyBasedRoute with LRO error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.CreatePolicyBasedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.CreatePolicyBasedRouteRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createPolicyBasedRoute = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createPolicyBasedRoute(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createPolicyBasedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPolicyBasedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createPolicyBasedRoute without error using callback', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.CreatePolicyBasedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.CreatePolicyBasedRouteRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createPolicyBasedRoute = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createPolicyBasedRoute( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createPolicyBasedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPolicyBasedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreatePolicyBasedRouteProgress without error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreatePolicyBasedRouteProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createPolicyBasedRoute with call error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.CreatePolicyBasedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.CreatePolicyBasedRouteRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createPolicyBasedRoute = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.createPolicyBasedRoute(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createPolicyBasedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPolicyBasedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreatePolicyBasedRouteProgress with error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreatePolicyBasedRouteProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createPolicyBasedRoute with LRO error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.CreatePolicyBasedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.CreatePolicyBasedRouteRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createPolicyBasedRoute = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createPolicyBasedRoute(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createPolicyBasedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPolicyBasedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deletePolicyBasedRoute', () => { - it('invokes deletePolicyBasedRoute without error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.DeletePolicyBasedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.DeletePolicyBasedRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deletePolicyBasedRoute = stubLongRunningCall(expectedResponse); - const [operation] = await client.deletePolicyBasedRoute(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deletePolicyBasedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePolicyBasedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreatePolicyBasedRouteProgress without error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkCreatePolicyBasedRouteProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deletePolicyBasedRoute without error using callback', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.DeletePolicyBasedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.DeletePolicyBasedRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deletePolicyBasedRoute = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deletePolicyBasedRoute( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deletePolicyBasedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePolicyBasedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreatePolicyBasedRouteProgress with error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreatePolicyBasedRouteProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deletePolicyBasedRoute', () => { + it('invokes deletePolicyBasedRoute without error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.DeletePolicyBasedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.DeletePolicyBasedRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deletePolicyBasedRoute = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deletePolicyBasedRoute(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deletePolicyBasedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePolicyBasedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deletePolicyBasedRoute with call error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.DeletePolicyBasedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.DeletePolicyBasedRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deletePolicyBasedRoute = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deletePolicyBasedRoute(request), expectedError); - const actualRequest = (client.innerApiCalls.deletePolicyBasedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePolicyBasedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deletePolicyBasedRoute without error using callback', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.DeletePolicyBasedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.DeletePolicyBasedRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deletePolicyBasedRoute = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deletePolicyBasedRoute( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deletePolicyBasedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePolicyBasedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deletePolicyBasedRoute with LRO error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.DeletePolicyBasedRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.DeletePolicyBasedRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deletePolicyBasedRoute = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deletePolicyBasedRoute(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deletePolicyBasedRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePolicyBasedRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deletePolicyBasedRoute with call error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.DeletePolicyBasedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.DeletePolicyBasedRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deletePolicyBasedRoute = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.deletePolicyBasedRoute(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deletePolicyBasedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePolicyBasedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeletePolicyBasedRouteProgress without error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeletePolicyBasedRouteProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deletePolicyBasedRoute with LRO error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.DeletePolicyBasedRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.DeletePolicyBasedRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deletePolicyBasedRoute = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deletePolicyBasedRoute(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deletePolicyBasedRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePolicyBasedRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeletePolicyBasedRouteProgress with error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeletePolicyBasedRouteProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeletePolicyBasedRouteProgress without error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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.checkDeletePolicyBasedRouteProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('listPolicyBasedRoutes', () => { - it('invokes listPolicyBasedRoutes without error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListPolicyBasedRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListPolicyBasedRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute()), - ]; - client.innerApiCalls.listPolicyBasedRoutes = stubSimpleCall(expectedResponse); - const [response] = await client.listPolicyBasedRoutes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPolicyBasedRoutes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPolicyBasedRoutes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeletePolicyBasedRouteProgress with error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeletePolicyBasedRouteProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listPolicyBasedRoutes', () => { + it('invokes listPolicyBasedRoutes without error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListPolicyBasedRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListPolicyBasedRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute(), + ), + ]; + client.innerApiCalls.listPolicyBasedRoutes = + stubSimpleCall(expectedResponse); + const [response] = await client.listPolicyBasedRoutes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listPolicyBasedRoutes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPolicyBasedRoutes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listPolicyBasedRoutes without error using callback', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListPolicyBasedRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListPolicyBasedRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute()), - ]; - client.innerApiCalls.listPolicyBasedRoutes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listPolicyBasedRoutes( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPolicyBasedRoutes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPolicyBasedRoutes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listPolicyBasedRoutes without error using callback', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListPolicyBasedRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListPolicyBasedRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute(), + ), + ]; + client.innerApiCalls.listPolicyBasedRoutes = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listPolicyBasedRoutes( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listPolicyBasedRoutes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPolicyBasedRoutes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listPolicyBasedRoutes with error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListPolicyBasedRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListPolicyBasedRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listPolicyBasedRoutes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listPolicyBasedRoutes(request), expectedError); - const actualRequest = (client.innerApiCalls.listPolicyBasedRoutes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPolicyBasedRoutes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listPolicyBasedRoutes with error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListPolicyBasedRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListPolicyBasedRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listPolicyBasedRoutes = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listPolicyBasedRoutes(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listPolicyBasedRoutes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPolicyBasedRoutes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listPolicyBasedRoutesStream without error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListPolicyBasedRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListPolicyBasedRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute()), - ]; - client.descriptors.page.listPolicyBasedRoutes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listPolicyBasedRoutesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listPolicyBasedRoutes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPolicyBasedRoutes, request)); - assert( - (client.descriptors.page.listPolicyBasedRoutes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listPolicyBasedRoutesStream without error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListPolicyBasedRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListPolicyBasedRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute(), + ), + ]; + client.descriptors.page.listPolicyBasedRoutes.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listPolicyBasedRoutesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listPolicyBasedRoutes + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listPolicyBasedRoutes, request), + ); + assert( + ( + client.descriptors.page.listPolicyBasedRoutes + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listPolicyBasedRoutesStream with error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListPolicyBasedRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListPolicyBasedRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listPolicyBasedRoutes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listPolicyBasedRoutesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listPolicyBasedRoutes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPolicyBasedRoutes, request)); - assert( - (client.descriptors.page.listPolicyBasedRoutes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listPolicyBasedRoutesStream with error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListPolicyBasedRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListPolicyBasedRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPolicyBasedRoutes.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listPolicyBasedRoutesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listPolicyBasedRoutes + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listPolicyBasedRoutes, request), + ); + assert( + ( + client.descriptors.page.listPolicyBasedRoutes + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('uses async iteration with listPolicyBasedRoutes without error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListPolicyBasedRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListPolicyBasedRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute()), - ]; - client.descriptors.page.listPolicyBasedRoutes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute[] = []; - const iterable = client.listPolicyBasedRoutesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listPolicyBasedRoutes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPolicyBasedRoutes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listPolicyBasedRoutes without error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListPolicyBasedRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListPolicyBasedRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.PolicyBasedRoute(), + ), + ]; + client.descriptors.page.listPolicyBasedRoutes.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute[] = + []; + const iterable = client.listPolicyBasedRoutesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listPolicyBasedRoutes + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listPolicyBasedRoutes + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('uses async iteration with listPolicyBasedRoutes with error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListPolicyBasedRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListPolicyBasedRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listPolicyBasedRoutes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listPolicyBasedRoutesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listPolicyBasedRoutes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPolicyBasedRoutes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listPolicyBasedRoutes with error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListPolicyBasedRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListPolicyBasedRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPolicyBasedRoutes.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listPolicyBasedRoutesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1beta.IPolicyBasedRoute[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listPolicyBasedRoutes + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listPolicyBasedRoutes + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy without error using callback', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy with error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes setIamPolicy without error using callback', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes setIamPolicy with error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes testIamPermissions without error using callback', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes testIamPermissions with error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('destination', async () => { + const fakePath = '/rendered/path/destination'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + multicloud_data_transfer_config: 'multicloudDataTransferConfigValue', + destination: 'destinationValue', + }; + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.destinationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.destinationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('destinationPath', () => { + const result = client.destinationPath( + 'projectValue', + 'locationValue', + 'multicloudDataTransferConfigValue', + 'destinationValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.destinationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromDestinationName', () => { + const result = client.matchProjectFromDestinationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromDestinationName', () => { + const result = client.matchLocationFromDestinationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMulticloudDataTransferConfigFromDestinationName', () => { + const result = + client.matchMulticloudDataTransferConfigFromDestinationName(fakePath); + assert.strictEqual(result, 'multicloudDataTransferConfigValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchDestinationFromDestinationName', () => { + const result = client.matchDestinationFromDestinationName(fakePath); + assert.strictEqual(result, 'destinationValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('destination', async () => { - const fakePath = "/rendered/path/destination"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - multicloud_data_transfer_config: "multicloudDataTransferConfigValue", - destination: "destinationValue", - }; - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.destinationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.destinationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('destinationPath', () => { - const result = client.destinationPath("projectValue", "locationValue", "multicloudDataTransferConfigValue", "destinationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.destinationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDestinationName', () => { - const result = client.matchProjectFromDestinationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromDestinationName', () => { - const result = client.matchLocationFromDestinationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMulticloudDataTransferConfigFromDestinationName', () => { - const result = client.matchMulticloudDataTransferConfigFromDestinationName(fakePath); - assert.strictEqual(result, "multicloudDataTransferConfigValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDestinationFromDestinationName', () => { - const result = client.matchDestinationFromDestinationName(fakePath); - assert.strictEqual(result, "destinationValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('gatewayAdvertisedRoute', async () => { - const fakePath = "/rendered/path/gatewayAdvertisedRoute"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - spoke: "spokeValue", - gateway_advertised_route: "gatewayAdvertisedRouteValue", - }; - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.gatewayAdvertisedRoutePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.gatewayAdvertisedRoutePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('gatewayAdvertisedRoutePath', () => { - const result = client.gatewayAdvertisedRoutePath("projectValue", "locationValue", "spokeValue", "gatewayAdvertisedRouteValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.gatewayAdvertisedRoutePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromGatewayAdvertisedRouteName', () => { - const result = client.matchProjectFromGatewayAdvertisedRouteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.gatewayAdvertisedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromGatewayAdvertisedRouteName', () => { - const result = client.matchLocationFromGatewayAdvertisedRouteName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.gatewayAdvertisedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSpokeFromGatewayAdvertisedRouteName', () => { - const result = client.matchSpokeFromGatewayAdvertisedRouteName(fakePath); - assert.strictEqual(result, "spokeValue"); - assert((client.pathTemplates.gatewayAdvertisedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchGatewayAdvertisedRouteFromGatewayAdvertisedRouteName', () => { - const result = client.matchGatewayAdvertisedRouteFromGatewayAdvertisedRouteName(fakePath); - assert.strictEqual(result, "gatewayAdvertisedRouteValue"); - assert((client.pathTemplates.gatewayAdvertisedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('gatewayAdvertisedRoute', async () => { + const fakePath = '/rendered/path/gatewayAdvertisedRoute'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + spoke: 'spokeValue', + gateway_advertised_route: 'gatewayAdvertisedRouteValue', + }; + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.gatewayAdvertisedRoutePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.gatewayAdvertisedRoutePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('gatewayAdvertisedRoutePath', () => { + const result = client.gatewayAdvertisedRoutePath( + 'projectValue', + 'locationValue', + 'spokeValue', + 'gatewayAdvertisedRouteValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.gatewayAdvertisedRoutePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromGatewayAdvertisedRouteName', () => { + const result = + client.matchProjectFromGatewayAdvertisedRouteName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.gatewayAdvertisedRoutePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromGatewayAdvertisedRouteName', () => { + const result = + client.matchLocationFromGatewayAdvertisedRouteName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.gatewayAdvertisedRoutePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchSpokeFromGatewayAdvertisedRouteName', () => { + const result = + client.matchSpokeFromGatewayAdvertisedRouteName(fakePath); + assert.strictEqual(result, 'spokeValue'); + assert( + ( + client.pathTemplates.gatewayAdvertisedRoutePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchGatewayAdvertisedRouteFromGatewayAdvertisedRouteName', () => { + const result = + client.matchGatewayAdvertisedRouteFromGatewayAdvertisedRouteName( + fakePath, + ); + assert.strictEqual(result, 'gatewayAdvertisedRouteValue'); + assert( + ( + client.pathTemplates.gatewayAdvertisedRoutePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('group', async () => { - const fakePath = "/rendered/path/group"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - group: "groupValue", - }; - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.groupPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.groupPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('groupPath', () => { - const result = client.groupPath("projectValue", "hubValue", "groupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.groupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromGroupName', () => { - const result = client.matchProjectFromGroupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.groupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHubFromGroupName', () => { - const result = client.matchHubFromGroupName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.groupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchGroupFromGroupName', () => { - const result = client.matchGroupFromGroupName(fakePath); - assert.strictEqual(result, "groupValue"); - assert((client.pathTemplates.groupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('group', async () => { + const fakePath = '/rendered/path/group'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + group: 'groupValue', + }; + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.groupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.groupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('groupPath', () => { + const result = client.groupPath( + 'projectValue', + 'hubValue', + 'groupValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.groupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromGroupName', () => { + const result = client.matchProjectFromGroupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.groupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromGroupName', () => { + const result = client.matchHubFromGroupName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.groupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchGroupFromGroupName', () => { + const result = client.matchGroupFromGroupName(fakePath); + assert.strictEqual(result, 'groupValue'); + assert( + (client.pathTemplates.groupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('hub', async () => { - const fakePath = "/rendered/path/hub"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - }; - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.hubPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.hubPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('hubPath', () => { - const result = client.hubPath("projectValue", "hubValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.hubPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromHubName', () => { - const result = client.matchProjectFromHubName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.hubPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHubFromHubName', () => { - const result = client.matchHubFromHubName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.hubPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('hub', async () => { + const fakePath = '/rendered/path/hub'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + }; + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.hubPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.hubPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('hubPath', () => { + const result = client.hubPath('projectValue', 'hubValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.hubPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromHubName', () => { + const result = client.matchProjectFromHubName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.hubPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromHubName', () => { + const result = client.matchHubFromHubName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.hubPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('hubRoute', async () => { - const fakePath = "/rendered/path/hubRoute"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - route_table: "routeTableValue", - route: "routeValue", - }; - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.hubRoutePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.hubRoutePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('hubRoutePath', () => { - const result = client.hubRoutePath("projectValue", "hubValue", "routeTableValue", "routeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.hubRoutePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromHubRouteName', () => { - const result = client.matchProjectFromHubRouteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHubFromHubRouteName', () => { - const result = client.matchHubFromHubRouteName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRouteTableFromHubRouteName', () => { - const result = client.matchRouteTableFromHubRouteName(fakePath); - assert.strictEqual(result, "routeTableValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRouteFromHubRouteName', () => { - const result = client.matchRouteFromHubRouteName(fakePath); - assert.strictEqual(result, "routeValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('hubRoute', async () => { + const fakePath = '/rendered/path/hubRoute'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + route_table: 'routeTableValue', + route: 'routeValue', + }; + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.hubRoutePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.hubRoutePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('hubRoutePath', () => { + const result = client.hubRoutePath( + 'projectValue', + 'hubValue', + 'routeTableValue', + 'routeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.hubRoutePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromHubRouteName', () => { + const result = client.matchProjectFromHubRouteName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromHubRouteName', () => { + const result = client.matchHubFromHubRouteName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRouteTableFromHubRouteName', () => { + const result = client.matchRouteTableFromHubRouteName(fakePath); + assert.strictEqual(result, 'routeTableValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRouteFromHubRouteName', () => { + const result = client.matchRouteFromHubRouteName(fakePath); + assert.strictEqual(result, 'routeValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('multicloudDataTransferConfig', async () => { - const fakePath = "/rendered/path/multicloudDataTransferConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - multicloud_data_transfer_config: "multicloudDataTransferConfigValue", - }; - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.multicloudDataTransferConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.multicloudDataTransferConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('multicloudDataTransferConfigPath', () => { - const result = client.multicloudDataTransferConfigPath("projectValue", "locationValue", "multicloudDataTransferConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMulticloudDataTransferConfigName', () => { - const result = client.matchProjectFromMulticloudDataTransferConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMulticloudDataTransferConfigName', () => { - const result = client.matchLocationFromMulticloudDataTransferConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName', () => { - const result = client.matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName(fakePath); - assert.strictEqual(result, "multicloudDataTransferConfigValue"); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('multicloudDataTransferConfig', async () => { + const fakePath = '/rendered/path/multicloudDataTransferConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + multicloud_data_transfer_config: 'multicloudDataTransferConfigValue', + }; + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.multicloudDataTransferConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.multicloudDataTransferConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('multicloudDataTransferConfigPath', () => { + const result = client.multicloudDataTransferConfigPath( + 'projectValue', + 'locationValue', + 'multicloudDataTransferConfigValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMulticloudDataTransferConfigName', () => { + const result = + client.matchProjectFromMulticloudDataTransferConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMulticloudDataTransferConfigName', () => { + const result = + client.matchLocationFromMulticloudDataTransferConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName', () => { + const result = + client.matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName( + fakePath, + ); + assert.strictEqual(result, 'multicloudDataTransferConfigValue'); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('multicloudDataTransferSupportedService', async () => { - const fakePath = "/rendered/path/multicloudDataTransferSupportedService"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - multicloud_data_transfer_supported_service: "multicloudDataTransferSupportedServiceValue", - }; - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('multicloudDataTransferSupportedServicePath', () => { - const result = client.multicloudDataTransferSupportedServicePath("projectValue", "locationValue", "multicloudDataTransferSupportedServiceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMulticloudDataTransferSupportedServiceName', () => { - const result = client.matchProjectFromMulticloudDataTransferSupportedServiceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMulticloudDataTransferSupportedServiceName', () => { - const result = client.matchLocationFromMulticloudDataTransferSupportedServiceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName', () => { - const result = client.matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName(fakePath); - assert.strictEqual(result, "multicloudDataTransferSupportedServiceValue"); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('multicloudDataTransferSupportedService', async () => { + const fakePath = '/rendered/path/multicloudDataTransferSupportedService'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + multicloud_data_transfer_supported_service: + 'multicloudDataTransferSupportedServiceValue', + }; + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('multicloudDataTransferSupportedServicePath', () => { + const result = client.multicloudDataTransferSupportedServicePath( + 'projectValue', + 'locationValue', + 'multicloudDataTransferSupportedServiceValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMulticloudDataTransferSupportedServiceName', () => { + const result = + client.matchProjectFromMulticloudDataTransferSupportedServiceName( + fakePath, + ); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMulticloudDataTransferSupportedServiceName', () => { + const result = + client.matchLocationFromMulticloudDataTransferSupportedServiceName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName', () => { + const result = + client.matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName( + fakePath, + ); + assert.strictEqual( + result, + 'multicloudDataTransferSupportedServiceValue', + ); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('network', async () => { - const fakePath = "/rendered/path/network"; - const expectedParameters = { - project: "projectValue", - resource_id: "resourceIdValue", - }; - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.networkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.networkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('networkPath', () => { - const result = client.networkPath("projectValue", "resourceIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.networkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromNetworkName', () => { - const result = client.matchProjectFromNetworkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.networkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchResourceIdFromNetworkName', () => { - const result = client.matchResourceIdFromNetworkName(fakePath); - assert.strictEqual(result, "resourceIdValue"); - assert((client.pathTemplates.networkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('network', async () => { + const fakePath = '/rendered/path/network'; + const expectedParameters = { + project: 'projectValue', + resource_id: 'resourceIdValue', + }; + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.networkPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.networkPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('networkPath', () => { + const result = client.networkPath('projectValue', 'resourceIdValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.networkPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromNetworkName', () => { + const result = client.matchProjectFromNetworkName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.networkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchResourceIdFromNetworkName', () => { + const result = client.matchResourceIdFromNetworkName(fakePath); + assert.strictEqual(result, 'resourceIdValue'); + assert( + (client.pathTemplates.networkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('policyBasedRoute', async () => { - const fakePath = "/rendered/path/policyBasedRoute"; - const expectedParameters = { - project: "projectValue", - policy_based_route: "policyBasedRouteValue", - }; - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.policyBasedRoutePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.policyBasedRoutePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('policyBasedRoutePath', () => { - const result = client.policyBasedRoutePath("projectValue", "policyBasedRouteValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.policyBasedRoutePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromPolicyBasedRouteName', () => { - const result = client.matchProjectFromPolicyBasedRouteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchPolicyBasedRouteFromPolicyBasedRouteName', () => { - const result = client.matchPolicyBasedRouteFromPolicyBasedRouteName(fakePath); - assert.strictEqual(result, "policyBasedRouteValue"); - assert((client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('policyBasedRoute', async () => { + const fakePath = '/rendered/path/policyBasedRoute'; + const expectedParameters = { + project: 'projectValue', + policy_based_route: 'policyBasedRouteValue', + }; + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.policyBasedRoutePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.policyBasedRoutePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('policyBasedRoutePath', () => { + const result = client.policyBasedRoutePath( + 'projectValue', + 'policyBasedRouteValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.policyBasedRoutePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromPolicyBasedRouteName', () => { + const result = client.matchProjectFromPolicyBasedRouteName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchPolicyBasedRouteFromPolicyBasedRouteName', () => { + const result = + client.matchPolicyBasedRouteFromPolicyBasedRouteName(fakePath); + assert.strictEqual(result, 'policyBasedRouteValue'); + assert( + (client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('remoteTransportProfile', async () => { - const fakePath = "/rendered/path/remoteTransportProfile"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - remote_transport_profile: "remoteTransportProfileValue", - }; - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.remoteTransportProfilePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.remoteTransportProfilePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('remoteTransportProfilePath', () => { - const result = client.remoteTransportProfilePath("projectValue", "locationValue", "remoteTransportProfileValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.remoteTransportProfilePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRemoteTransportProfileName', () => { - const result = client.matchProjectFromRemoteTransportProfileName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.remoteTransportProfilePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromRemoteTransportProfileName', () => { - const result = client.matchLocationFromRemoteTransportProfileName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.remoteTransportProfilePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRemoteTransportProfileFromRemoteTransportProfileName', () => { - const result = client.matchRemoteTransportProfileFromRemoteTransportProfileName(fakePath); - assert.strictEqual(result, "remoteTransportProfileValue"); - assert((client.pathTemplates.remoteTransportProfilePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('remoteTransportProfile', async () => { + const fakePath = '/rendered/path/remoteTransportProfile'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + remote_transport_profile: 'remoteTransportProfileValue', + }; + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.remoteTransportProfilePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.remoteTransportProfilePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('remoteTransportProfilePath', () => { + const result = client.remoteTransportProfilePath( + 'projectValue', + 'locationValue', + 'remoteTransportProfileValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.remoteTransportProfilePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromRemoteTransportProfileName', () => { + const result = + client.matchProjectFromRemoteTransportProfileName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.remoteTransportProfilePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromRemoteTransportProfileName', () => { + const result = + client.matchLocationFromRemoteTransportProfileName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.remoteTransportProfilePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRemoteTransportProfileFromRemoteTransportProfileName', () => { + const result = + client.matchRemoteTransportProfileFromRemoteTransportProfileName( + fakePath, + ); + assert.strictEqual(result, 'remoteTransportProfileValue'); + assert( + ( + client.pathTemplates.remoteTransportProfilePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('routeTable', async () => { - const fakePath = "/rendered/path/routeTable"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - route_table: "routeTableValue", - }; - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.routeTablePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.routeTablePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('routeTablePath', () => { - const result = client.routeTablePath("projectValue", "hubValue", "routeTableValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.routeTablePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRouteTableName', () => { - const result = client.matchProjectFromRouteTableName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.routeTablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHubFromRouteTableName', () => { - const result = client.matchHubFromRouteTableName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.routeTablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRouteTableFromRouteTableName', () => { - const result = client.matchRouteTableFromRouteTableName(fakePath); - assert.strictEqual(result, "routeTableValue"); - assert((client.pathTemplates.routeTablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('routeTable', async () => { + const fakePath = '/rendered/path/routeTable'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + route_table: 'routeTableValue', + }; + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.routeTablePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.routeTablePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('routeTablePath', () => { + const result = client.routeTablePath( + 'projectValue', + 'hubValue', + 'routeTableValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.routeTablePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromRouteTableName', () => { + const result = client.matchProjectFromRouteTableName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.routeTablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromRouteTableName', () => { + const result = client.matchHubFromRouteTableName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.routeTablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRouteTableFromRouteTableName', () => { + const result = client.matchRouteTableFromRouteTableName(fakePath); + assert.strictEqual(result, 'routeTableValue'); + assert( + (client.pathTemplates.routeTablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('spoke', async () => { - const fakePath = "/rendered/path/spoke"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - spoke: "spokeValue", - }; - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.spokePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.spokePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('spokePath', () => { - const result = client.spokePath("projectValue", "locationValue", "spokeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.spokePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromSpokeName', () => { - const result = client.matchProjectFromSpokeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.spokePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromSpokeName', () => { - const result = client.matchLocationFromSpokeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.spokePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSpokeFromSpokeName', () => { - const result = client.matchSpokeFromSpokeName(fakePath); - assert.strictEqual(result, "spokeValue"); - assert((client.pathTemplates.spokePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('spoke', async () => { + const fakePath = '/rendered/path/spoke'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + spoke: 'spokeValue', + }; + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.spokePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.spokePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('spokePath', () => { + const result = client.spokePath( + 'projectValue', + 'locationValue', + 'spokeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.spokePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromSpokeName', () => { + const result = client.matchProjectFromSpokeName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.spokePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromSpokeName', () => { + const result = client.matchLocationFromSpokeName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.spokePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchSpokeFromSpokeName', () => { + const result = client.matchSpokeFromSpokeName(fakePath); + assert.strictEqual(result, 'spokeValue'); + assert( + (client.pathTemplates.spokePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('transport', async () => { - const fakePath = "/rendered/path/transport"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - transport: "transportValue", - }; - const client = new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.transportPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.transportPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('transportPath', () => { - const result = client.transportPath("projectValue", "locationValue", "transportValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.transportPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTransportName', () => { - const result = client.matchProjectFromTransportName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.transportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromTransportName', () => { - const result = client.matchLocationFromTransportName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.transportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTransportFromTransportName', () => { - const result = client.matchTransportFromTransportName(fakePath); - assert.strictEqual(result, "transportValue"); - assert((client.pathTemplates.transportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('transport', async () => { + const fakePath = '/rendered/path/transport'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + transport: 'transportValue', + }; + const client = + new policybasedroutingserviceModule.v1beta.PolicyBasedRoutingServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.transportPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.transportPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('transportPath', () => { + const result = client.transportPath( + 'projectValue', + 'locationValue', + 'transportValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.transportPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromTransportName', () => { + const result = client.matchProjectFromTransportName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.transportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromTransportName', () => { + const result = client.matchLocationFromTransportName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.transportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTransportFromTransportName', () => { + const result = client.matchTransportFromTransportName(fakePath); + assert.strictEqual(result, 'transportValue'); + assert( + (client.pathTemplates.transportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-networkconnectivity/test/gapic_transport_manager_v1beta.ts b/packages/google-cloud-networkconnectivity/test/gapic_transport_manager_v1beta.ts index 0d43ea46eee2..478daefbe36b 100644 --- a/packages/google-cloud-networkconnectivity/test/gapic_transport_manager_v1beta.ts +++ b/packages/google-cloud-networkconnectivity/test/gapic_transport_manager_v1beta.ts @@ -19,2905 +19,3879 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as transportmanagerModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + IamProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1beta.TransportManagerClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = transportmanagerModule.v1beta.TransportManagerClient.servicePath; - assert.strictEqual(servicePath, 'networkconnectivity.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = transportmanagerModule.v1beta.TransportManagerClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new transportmanagerModule.v1beta.TransportManagerClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new transportmanagerModule.v1beta.TransportManagerClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkconnectivity.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new transportmanagerModule.v1beta.TransportManagerClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = transportmanagerModule.v1beta.TransportManagerClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.transportManagerStub, undefined); - await client.initialize(); - assert(client.transportManagerStub); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); + }); - it('has close method for the initialized client', done => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.transportManagerStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has universeDomain', () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has close method for the non-initialized client', done => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.transportManagerStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + transportmanagerModule.v1beta.TransportManagerClient.servicePath; + assert.strictEqual(servicePath, 'networkconnectivity.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + transportmanagerModule.v1beta.TransportManagerClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkconnectivity.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkconnectivity.example.com'); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkconnectivity.example.com'); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new transportmanagerModule.v1beta.TransportManagerClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkconnectivity.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new transportmanagerModule.v1beta.TransportManagerClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'networkconnectivity.configured.example.com', + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new transportmanagerModule.v1beta.TransportManagerClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); }); - describe('getRemoteTransportProfile', () => { - it('invokes getRemoteTransportProfile without error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetRemoteTransportProfileRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetRemoteTransportProfileRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile() - ); - client.innerApiCalls.getRemoteTransportProfile = stubSimpleCall(expectedResponse); - const [response] = await client.getRemoteTransportProfile(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRemoteTransportProfile as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRemoteTransportProfile as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has port', () => { + const port = transportmanagerModule.v1beta.TransportManagerClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('invokes getRemoteTransportProfile without error using callback', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetRemoteTransportProfileRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetRemoteTransportProfileRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile() - ); - client.innerApiCalls.getRemoteTransportProfile = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getRemoteTransportProfile( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRemoteTransportProfile as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRemoteTransportProfile as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('should create a client with no option', () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient(); + assert(client); + }); - it('invokes getRemoteTransportProfile with error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetRemoteTransportProfileRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetRemoteTransportProfileRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getRemoteTransportProfile = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getRemoteTransportProfile(request), expectedError); - const actualRequest = (client.innerApiCalls.getRemoteTransportProfile as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRemoteTransportProfile as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('should create a client with gRPC fallback', () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + fallback: true, + }); + assert(client); + }); - it('invokes getRemoteTransportProfile with closed client', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetRemoteTransportProfileRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetRemoteTransportProfileRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getRemoteTransportProfile(request), expectedError); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.transportManagerStub, undefined); + await client.initialize(); + assert(client.transportManagerStub); }); - describe('getTransport', () => { - it('invokes getTransport without error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetTransportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetTransportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.Transport() - ); - client.innerApiCalls.getTransport = stubSimpleCall(expectedResponse); - const [response] = await client.getTransport(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTransport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTransport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the initialized client', (done) => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.transportManagerStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getTransport without error using callback', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetTransportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetTransportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.Transport() - ); - client.innerApiCalls.getTransport = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getTransport( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1beta.ITransport|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTransport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTransport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the non-initialized client', (done) => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.transportManagerStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getTransport with error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetTransportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetTransportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getTransport = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getTransport(request), expectedError); - const actualRequest = (client.innerApiCalls.getTransport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTransport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('invokes getTransport with closed client', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetTransportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetTransportRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getTransport(request), expectedError); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getRemoteTransportProfile', () => { + it('invokes getRemoteTransportProfile without error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetRemoteTransportProfileRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetRemoteTransportProfileRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile(), + ); + client.innerApiCalls.getRemoteTransportProfile = + stubSimpleCall(expectedResponse); + const [response] = await client.getRemoteTransportProfile(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getRemoteTransportProfile as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getRemoteTransportProfile as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getStatus', () => { - it('invokes getStatus without error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetStatusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetStatusRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetStatusResponse() - ); - client.innerApiCalls.getStatus = stubSimpleCall(expectedResponse); - const [response] = await client.getStatus(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getStatus as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getStatus as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getRemoteTransportProfile without error using callback', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetRemoteTransportProfileRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetRemoteTransportProfileRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile(), + ); + client.innerApiCalls.getRemoteTransportProfile = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getRemoteTransportProfile( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getRemoteTransportProfile as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getRemoteTransportProfile as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getStatus without error using callback', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetStatusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetStatusRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetStatusResponse() - ); - client.innerApiCalls.getStatus = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getStatus( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1beta.IGetStatusResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getStatus as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getStatus as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getRemoteTransportProfile with error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetRemoteTransportProfileRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetRemoteTransportProfileRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getRemoteTransportProfile = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getRemoteTransportProfile(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.getRemoteTransportProfile as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getRemoteTransportProfile as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getStatus with error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetStatusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetStatusRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getStatus = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getStatus(request), expectedError); - const actualRequest = (client.innerApiCalls.getStatus as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getStatus as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getRemoteTransportProfile with closed client', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetRemoteTransportProfileRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetRemoteTransportProfileRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.getRemoteTransportProfile(request), + expectedError, + ); + }); + }); + + describe('getTransport', () => { + it('invokes getTransport without error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetTransportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetTransportRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Transport(), + ); + client.innerApiCalls.getTransport = stubSimpleCall(expectedResponse); + const [response] = await client.getTransport(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getTransport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTransport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getStatus with closed client', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.GetStatusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.GetStatusRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getStatus(request), expectedError); - }); + it('invokes getTransport without error using callback', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetTransportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetTransportRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Transport(), + ); + client.innerApiCalls.getTransport = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getTransport( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1beta.ITransport | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getTransport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTransport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createTransport', () => { - it('invokes createTransport without error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.CreateTransportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.CreateTransportRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createTransport = stubLongRunningCall(expectedResponse); - const [operation] = await client.createTransport(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createTransport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTransport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getTransport with error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetTransportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetTransportRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getTransport = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getTransport(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getTransport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTransport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createTransport without error using callback', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.CreateTransportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.CreateTransportRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createTransport = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createTransport( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createTransport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTransport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getTransport with closed client', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetTransportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetTransportRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getTransport(request), expectedError); + }); + }); + + describe('getStatus', () => { + it('invokes getStatus without error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetStatusRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetStatusRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetStatusResponse(), + ); + client.innerApiCalls.getStatus = stubSimpleCall(expectedResponse); + const [response] = await client.getStatus(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getStatus as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getStatus as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createTransport with call error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.CreateTransportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.CreateTransportRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createTransport = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createTransport(request), expectedError); - const actualRequest = (client.innerApiCalls.createTransport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTransport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getStatus without error using callback', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetStatusRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetStatusRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetStatusResponse(), + ); + client.innerApiCalls.getStatus = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getStatus( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkconnectivity.v1beta.IGetStatusResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getStatus as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getStatus as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createTransport with LRO error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.CreateTransportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.CreateTransportRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createTransport = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createTransport(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createTransport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTransport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getStatus with error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetStatusRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetStatusRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getStatus = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getStatus(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getStatus as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getStatus as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateTransportProgress without error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateTransportProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes getStatus with closed client', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.GetStatusRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.GetStatusRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getStatus(request), expectedError); + }); + }); + + describe('createTransport', () => { + it('invokes createTransport without error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.CreateTransportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.CreateTransportRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createTransport = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createTransport(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createTransport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTransport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateTransportProgress with error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes createTransport without error using callback', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.CreateTransportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.CreateTransportRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createTransport = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createTransport( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1beta.ITransport, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1beta.ITransport, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createTransport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTransport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateTransportProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createTransport with call error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.CreateTransportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.CreateTransportRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createTransport = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createTransport(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createTransport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTransport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateTransport', () => { - it('invokes updateTransport without error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.UpdateTransportRequest() - ); - request.transport ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.UpdateTransportRequest', ['transport', 'name']); - request.transport.name = defaultValue1; - const expectedHeaderRequestParams = `transport.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateTransport = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateTransport(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateTransport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTransport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createTransport with LRO error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.CreateTransportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.CreateTransportRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createTransport = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createTransport(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createTransport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTransport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateTransport without error using callback', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.UpdateTransportRequest() - ); - request.transport ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.UpdateTransportRequest', ['transport', 'name']); - request.transport.name = defaultValue1; - const expectedHeaderRequestParams = `transport.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateTransport = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateTransport( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateTransport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTransport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateTransportProgress without error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateTransportProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateTransport with call error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.UpdateTransportRequest() - ); - request.transport ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.UpdateTransportRequest', ['transport', 'name']); - request.transport.name = defaultValue1; - const expectedHeaderRequestParams = `transport.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateTransport = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateTransport(request), expectedError); - const actualRequest = (client.innerApiCalls.updateTransport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTransport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateTransportProgress with error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateTransportProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateTransport', () => { + it('invokes updateTransport without error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.UpdateTransportRequest(), + ); + request.transport ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.UpdateTransportRequest', + ['transport', 'name'], + ); + request.transport.name = defaultValue1; + const expectedHeaderRequestParams = `transport.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateTransport = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateTransport(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateTransport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTransport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateTransport with LRO error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.UpdateTransportRequest() - ); - request.transport ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.UpdateTransportRequest', ['transport', 'name']); - request.transport.name = defaultValue1; - const expectedHeaderRequestParams = `transport.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateTransport = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateTransport(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateTransport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTransport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateTransport without error using callback', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.UpdateTransportRequest(), + ); + request.transport ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.UpdateTransportRequest', + ['transport', 'name'], + ); + request.transport.name = defaultValue1; + const expectedHeaderRequestParams = `transport.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateTransport = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateTransport( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkconnectivity.v1beta.ITransport, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkconnectivity.v1beta.ITransport, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateTransport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTransport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateTransportProgress without error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateTransportProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateTransport with call error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.UpdateTransportRequest(), + ); + request.transport ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.UpdateTransportRequest', + ['transport', 'name'], + ); + request.transport.name = defaultValue1; + const expectedHeaderRequestParams = `transport.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateTransport = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateTransport(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateTransport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTransport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateTransportProgress with error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes updateTransport with LRO error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.UpdateTransportRequest(), + ); + request.transport ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.UpdateTransportRequest', + ['transport', 'name'], + ); + request.transport.name = defaultValue1; + const expectedHeaderRequestParams = `transport.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateTransport = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateTransport(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateTransport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTransport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateTransportProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpdateTransportProgress without error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateTransportProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('deleteTransport', () => { - it('invokes deleteTransport without error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.DeleteTransportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.DeleteTransportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteTransport = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteTransport(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteTransport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTransport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateTransportProgress with error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateTransportProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteTransport', () => { + it('invokes deleteTransport without error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.DeleteTransportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.DeleteTransportRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteTransport = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteTransport(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteTransport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTransport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTransport without error using callback', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.DeleteTransportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.DeleteTransportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteTransport = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteTransport( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteTransport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTransport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteTransport without error using callback', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.DeleteTransportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.DeleteTransportRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteTransport = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteTransport( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkconnectivity.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteTransport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTransport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTransport with call error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.DeleteTransportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.DeleteTransportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteTransport = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteTransport(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteTransport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTransport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteTransport with call error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.DeleteTransportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.DeleteTransportRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteTransport = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteTransport(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteTransport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTransport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTransport with LRO error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.DeleteTransportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.DeleteTransportRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteTransport = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteTransport(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteTransport as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTransport as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteTransport with LRO error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.DeleteTransportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.DeleteTransportRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteTransport = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteTransport(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteTransport as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTransport as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteTransportProgress without error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteTransportProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkDeleteTransportProgress without error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteTransportProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteTransportProgress with error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes checkDeleteTransportProgress with error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteTransportProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listRemoteTransportProfiles', () => { + it('invokes listRemoteTransportProfiles without error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListRemoteTransportProfilesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListRemoteTransportProfilesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile(), + ), + ]; + client.innerApiCalls.listRemoteTransportProfiles = + stubSimpleCall(expectedResponse); + const [response] = await client.listRemoteTransportProfiles(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listRemoteTransportProfiles as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listRemoteTransportProfiles as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteTransportProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes listRemoteTransportProfiles without error using callback', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListRemoteTransportProfilesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListRemoteTransportProfilesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile(), + ), + ]; + client.innerApiCalls.listRemoteTransportProfiles = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listRemoteTransportProfiles( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listRemoteTransportProfiles as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listRemoteTransportProfiles as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listRemoteTransportProfiles', () => { - it('invokes listRemoteTransportProfiles without error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListRemoteTransportProfilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListRemoteTransportProfilesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile()), - ]; - client.innerApiCalls.listRemoteTransportProfiles = stubSimpleCall(expectedResponse); - const [response] = await client.listRemoteTransportProfiles(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRemoteTransportProfiles as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRemoteTransportProfiles as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listRemoteTransportProfiles with error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListRemoteTransportProfilesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListRemoteTransportProfilesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listRemoteTransportProfiles = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listRemoteTransportProfiles(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listRemoteTransportProfiles as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listRemoteTransportProfiles as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listRemoteTransportProfiles without error using callback', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListRemoteTransportProfilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListRemoteTransportProfilesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile()), - ]; - client.innerApiCalls.listRemoteTransportProfiles = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listRemoteTransportProfiles( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRemoteTransportProfiles as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRemoteTransportProfiles as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listRemoteTransportProfilesStream without error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListRemoteTransportProfilesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListRemoteTransportProfilesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile(), + ), + ]; + client.descriptors.page.listRemoteTransportProfiles.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listRemoteTransportProfilesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listRemoteTransportProfiles + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listRemoteTransportProfiles, + request, + ), + ); + assert( + ( + client.descriptors.page.listRemoteTransportProfiles + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listRemoteTransportProfiles with error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListRemoteTransportProfilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListRemoteTransportProfilesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listRemoteTransportProfiles = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listRemoteTransportProfiles(request), expectedError); - const actualRequest = (client.innerApiCalls.listRemoteTransportProfiles as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRemoteTransportProfiles as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listRemoteTransportProfilesStream with error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListRemoteTransportProfilesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListRemoteTransportProfilesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRemoteTransportProfiles.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listRemoteTransportProfilesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listRemoteTransportProfiles + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listRemoteTransportProfiles, + request, + ), + ); + assert( + ( + client.descriptors.page.listRemoteTransportProfiles + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listRemoteTransportProfilesStream without error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListRemoteTransportProfilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListRemoteTransportProfilesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile()), - ]; - client.descriptors.page.listRemoteTransportProfiles.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listRemoteTransportProfilesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listRemoteTransportProfiles.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRemoteTransportProfiles, request)); - assert( - (client.descriptors.page.listRemoteTransportProfiles.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listRemoteTransportProfiles without error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListRemoteTransportProfilesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListRemoteTransportProfilesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile(), + ), + ]; + client.descriptors.page.listRemoteTransportProfiles.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile[] = + []; + const iterable = client.listRemoteTransportProfilesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listRemoteTransportProfiles + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listRemoteTransportProfiles + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listRemoteTransportProfilesStream with error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListRemoteTransportProfilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListRemoteTransportProfilesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listRemoteTransportProfiles.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listRemoteTransportProfilesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listRemoteTransportProfiles.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRemoteTransportProfiles, request)); - assert( - (client.descriptors.page.listRemoteTransportProfiles.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listRemoteTransportProfiles with error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListRemoteTransportProfilesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListRemoteTransportProfilesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRemoteTransportProfiles.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listRemoteTransportProfilesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listRemoteTransportProfiles + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listRemoteTransportProfiles + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('listTransports', () => { + it('invokes listTransports without error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListTransportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListTransportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Transport(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Transport(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Transport(), + ), + ]; + client.innerApiCalls.listTransports = stubSimpleCall(expectedResponse); + const [response] = await client.listTransports(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listTransports as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTransports as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listRemoteTransportProfiles without error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListRemoteTransportProfilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListRemoteTransportProfilesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.RemoteTransportProfile()), - ]; - client.descriptors.page.listRemoteTransportProfiles.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile[] = []; - const iterable = client.listRemoteTransportProfilesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listTransports without error using callback', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListTransportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListTransportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Transport(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Transport(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Transport(), + ), + ]; + client.innerApiCalls.listTransports = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listTransports( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkconnectivity.v1beta.ITransport[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listRemoteTransportProfiles.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRemoteTransportProfiles.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listRemoteTransportProfiles with error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListRemoteTransportProfilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListRemoteTransportProfilesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listRemoteTransportProfiles.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listRemoteTransportProfilesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1beta.IRemoteTransportProfile[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listRemoteTransportProfiles.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRemoteTransportProfiles.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listTransports as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTransports as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listTransports', () => { - it('invokes listTransports without error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListTransportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListTransportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Transport()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Transport()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Transport()), - ]; - client.innerApiCalls.listTransports = stubSimpleCall(expectedResponse); - const [response] = await client.listTransports(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTransports as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTransports as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listTransports without error using callback', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListTransportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListTransportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Transport()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Transport()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Transport()), - ]; - client.innerApiCalls.listTransports = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listTransports( - request, - (err?: Error|null, result?: protos.google.cloud.networkconnectivity.v1beta.ITransport[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTransports as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTransports as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listTransports with error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListTransportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListTransportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listTransports = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listTransports(request), expectedError); - const actualRequest = (client.innerApiCalls.listTransports as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTransports as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listTransports with error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListTransportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListTransportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listTransports = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listTransports(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listTransports as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTransports as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listTransportsStream without error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListTransportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListTransportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Transport()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Transport()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Transport()), - ]; - client.descriptors.page.listTransports.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listTransportsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1beta.Transport[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1beta.Transport) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listTransports.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTransports, request)); - assert( - (client.descriptors.page.listTransports.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listTransportsStream without error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListTransportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListTransportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Transport(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Transport(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Transport(), + ), + ]; + client.descriptors.page.listTransports.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listTransportsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1beta.Transport[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1beta.Transport, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listTransports.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listTransports, request), + ); + assert( + (client.descriptors.page.listTransports.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listTransportsStream with error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListTransportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListTransportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listTransports.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listTransportsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkconnectivity.v1beta.Transport[] = []; - stream.on('data', (response: protos.google.cloud.networkconnectivity.v1beta.Transport) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listTransports.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTransports, request)); - assert( - (client.descriptors.page.listTransports.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listTransportsStream with error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListTransportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListTransportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTransports.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listTransportsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkconnectivity.v1beta.Transport[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkconnectivity.v1beta.Transport, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listTransports.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listTransports, request), + ); + assert( + (client.descriptors.page.listTransports.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listTransports without error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListTransportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListTransportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Transport()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Transport()), - generateSampleMessage(new protos.google.cloud.networkconnectivity.v1beta.Transport()), - ]; - client.descriptors.page.listTransports.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkconnectivity.v1beta.ITransport[] = []; - const iterable = client.listTransportsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listTransports.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTransports.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listTransports without error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListTransportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListTransportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Transport(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Transport(), + ), + generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.Transport(), + ), + ]; + client.descriptors.page.listTransports.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkconnectivity.v1beta.ITransport[] = + []; + const iterable = client.listTransportsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listTransports.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listTransports.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listTransports with error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkconnectivity.v1beta.ListTransportsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkconnectivity.v1beta.ListTransportsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listTransports.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listTransportsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkconnectivity.v1beta.ITransport[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listTransports.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTransports.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listTransports with error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkconnectivity.v1beta.ListTransportsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkconnectivity.v1beta.ListTransportsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTransports.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listTransportsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkconnectivity.v1beta.ITransport[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listTransports.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listTransports.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy without error using callback', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy with error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes setIamPolicy with error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes testIamPermissions with error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('destination', async () => { + const fakePath = '/rendered/path/destination'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + multicloud_data_transfer_config: 'multicloudDataTransferConfigValue', + destination: 'destinationValue', + }; + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.destinationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.destinationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('destinationPath', () => { + const result = client.destinationPath( + 'projectValue', + 'locationValue', + 'multicloudDataTransferConfigValue', + 'destinationValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.destinationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromDestinationName', () => { + const result = client.matchProjectFromDestinationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromDestinationName', () => { + const result = client.matchLocationFromDestinationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMulticloudDataTransferConfigFromDestinationName', () => { + const result = + client.matchMulticloudDataTransferConfigFromDestinationName(fakePath); + assert.strictEqual(result, 'multicloudDataTransferConfigValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchDestinationFromDestinationName', () => { + const result = client.matchDestinationFromDestinationName(fakePath); + assert.strictEqual(result, 'destinationValue'); + assert( + (client.pathTemplates.destinationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('destination', async () => { - const fakePath = "/rendered/path/destination"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - multicloud_data_transfer_config: "multicloudDataTransferConfigValue", - destination: "destinationValue", - }; - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.destinationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.destinationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('destinationPath', () => { - const result = client.destinationPath("projectValue", "locationValue", "multicloudDataTransferConfigValue", "destinationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.destinationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDestinationName', () => { - const result = client.matchProjectFromDestinationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromDestinationName', () => { - const result = client.matchLocationFromDestinationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMulticloudDataTransferConfigFromDestinationName', () => { - const result = client.matchMulticloudDataTransferConfigFromDestinationName(fakePath); - assert.strictEqual(result, "multicloudDataTransferConfigValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDestinationFromDestinationName', () => { - const result = client.matchDestinationFromDestinationName(fakePath); - assert.strictEqual(result, "destinationValue"); - assert((client.pathTemplates.destinationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('gatewayAdvertisedRoute', async () => { - const fakePath = "/rendered/path/gatewayAdvertisedRoute"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - spoke: "spokeValue", - gateway_advertised_route: "gatewayAdvertisedRouteValue", - }; - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.gatewayAdvertisedRoutePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.gatewayAdvertisedRoutePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('gatewayAdvertisedRoutePath', () => { - const result = client.gatewayAdvertisedRoutePath("projectValue", "locationValue", "spokeValue", "gatewayAdvertisedRouteValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.gatewayAdvertisedRoutePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromGatewayAdvertisedRouteName', () => { - const result = client.matchProjectFromGatewayAdvertisedRouteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.gatewayAdvertisedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromGatewayAdvertisedRouteName', () => { - const result = client.matchLocationFromGatewayAdvertisedRouteName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.gatewayAdvertisedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSpokeFromGatewayAdvertisedRouteName', () => { - const result = client.matchSpokeFromGatewayAdvertisedRouteName(fakePath); - assert.strictEqual(result, "spokeValue"); - assert((client.pathTemplates.gatewayAdvertisedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchGatewayAdvertisedRouteFromGatewayAdvertisedRouteName', () => { - const result = client.matchGatewayAdvertisedRouteFromGatewayAdvertisedRouteName(fakePath); - assert.strictEqual(result, "gatewayAdvertisedRouteValue"); - assert((client.pathTemplates.gatewayAdvertisedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('group', async () => { - const fakePath = "/rendered/path/group"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - group: "groupValue", - }; - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.groupPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.groupPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('groupPath', () => { - const result = client.groupPath("projectValue", "hubValue", "groupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.groupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromGroupName', () => { - const result = client.matchProjectFromGroupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.groupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHubFromGroupName', () => { - const result = client.matchHubFromGroupName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.groupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchGroupFromGroupName', () => { - const result = client.matchGroupFromGroupName(fakePath); - assert.strictEqual(result, "groupValue"); - assert((client.pathTemplates.groupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('hub', async () => { - const fakePath = "/rendered/path/hub"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - }; - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.hubPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.hubPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('hubPath', () => { - const result = client.hubPath("projectValue", "hubValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.hubPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromHubName', () => { - const result = client.matchProjectFromHubName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.hubPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHubFromHubName', () => { - const result = client.matchHubFromHubName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.hubPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('hubRoute', async () => { - const fakePath = "/rendered/path/hubRoute"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - route_table: "routeTableValue", - route: "routeValue", - }; - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.hubRoutePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.hubRoutePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('hubRoutePath', () => { - const result = client.hubRoutePath("projectValue", "hubValue", "routeTableValue", "routeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.hubRoutePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromHubRouteName', () => { - const result = client.matchProjectFromHubRouteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHubFromHubRouteName', () => { - const result = client.matchHubFromHubRouteName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRouteTableFromHubRouteName', () => { - const result = client.matchRouteTableFromHubRouteName(fakePath); - assert.strictEqual(result, "routeTableValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRouteFromHubRouteName', () => { - const result = client.matchRouteFromHubRouteName(fakePath); - assert.strictEqual(result, "routeValue"); - assert((client.pathTemplates.hubRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('multicloudDataTransferConfig', async () => { - const fakePath = "/rendered/path/multicloudDataTransferConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - multicloud_data_transfer_config: "multicloudDataTransferConfigValue", - }; - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.multicloudDataTransferConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.multicloudDataTransferConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('multicloudDataTransferConfigPath', () => { - const result = client.multicloudDataTransferConfigPath("projectValue", "locationValue", "multicloudDataTransferConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMulticloudDataTransferConfigName', () => { - const result = client.matchProjectFromMulticloudDataTransferConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMulticloudDataTransferConfigName', () => { - const result = client.matchLocationFromMulticloudDataTransferConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName', () => { - const result = client.matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName(fakePath); - assert.strictEqual(result, "multicloudDataTransferConfigValue"); - assert((client.pathTemplates.multicloudDataTransferConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('multicloudDataTransferSupportedService', async () => { - const fakePath = "/rendered/path/multicloudDataTransferSupportedService"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - multicloud_data_transfer_supported_service: "multicloudDataTransferSupportedServiceValue", - }; - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('multicloudDataTransferSupportedServicePath', () => { - const result = client.multicloudDataTransferSupportedServicePath("projectValue", "locationValue", "multicloudDataTransferSupportedServiceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMulticloudDataTransferSupportedServiceName', () => { - const result = client.matchProjectFromMulticloudDataTransferSupportedServiceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMulticloudDataTransferSupportedServiceName', () => { - const result = client.matchLocationFromMulticloudDataTransferSupportedServiceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName', () => { - const result = client.matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName(fakePath); - assert.strictEqual(result, "multicloudDataTransferSupportedServiceValue"); - assert((client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('network', async () => { - const fakePath = "/rendered/path/network"; - const expectedParameters = { - project: "projectValue", - resource_id: "resourceIdValue", - }; - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.networkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.networkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('networkPath', () => { - const result = client.networkPath("projectValue", "resourceIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.networkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromNetworkName', () => { - const result = client.matchProjectFromNetworkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.networkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchResourceIdFromNetworkName', () => { - const result = client.matchResourceIdFromNetworkName(fakePath); - assert.strictEqual(result, "resourceIdValue"); - assert((client.pathTemplates.networkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('policyBasedRoute', async () => { - const fakePath = "/rendered/path/policyBasedRoute"; - const expectedParameters = { - project: "projectValue", - policy_based_route: "policyBasedRouteValue", - }; - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.policyBasedRoutePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.policyBasedRoutePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('policyBasedRoutePath', () => { - const result = client.policyBasedRoutePath("projectValue", "policyBasedRouteValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.policyBasedRoutePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromPolicyBasedRouteName', () => { - const result = client.matchProjectFromPolicyBasedRouteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchPolicyBasedRouteFromPolicyBasedRouteName', () => { - const result = client.matchPolicyBasedRouteFromPolicyBasedRouteName(fakePath); - assert.strictEqual(result, "policyBasedRouteValue"); - assert((client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('remoteTransportProfile', async () => { - const fakePath = "/rendered/path/remoteTransportProfile"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - remote_transport_profile: "remoteTransportProfileValue", - }; - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.remoteTransportProfilePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.remoteTransportProfilePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('remoteTransportProfilePath', () => { - const result = client.remoteTransportProfilePath("projectValue", "locationValue", "remoteTransportProfileValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.remoteTransportProfilePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRemoteTransportProfileName', () => { - const result = client.matchProjectFromRemoteTransportProfileName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.remoteTransportProfilePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromRemoteTransportProfileName', () => { - const result = client.matchLocationFromRemoteTransportProfileName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.remoteTransportProfilePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('gatewayAdvertisedRoute', async () => { + const fakePath = '/rendered/path/gatewayAdvertisedRoute'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + spoke: 'spokeValue', + gateway_advertised_route: 'gatewayAdvertisedRouteValue', + }; + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.gatewayAdvertisedRoutePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.gatewayAdvertisedRoutePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('gatewayAdvertisedRoutePath', () => { + const result = client.gatewayAdvertisedRoutePath( + 'projectValue', + 'locationValue', + 'spokeValue', + 'gatewayAdvertisedRouteValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.gatewayAdvertisedRoutePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromGatewayAdvertisedRouteName', () => { + const result = + client.matchProjectFromGatewayAdvertisedRouteName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.gatewayAdvertisedRoutePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromGatewayAdvertisedRouteName', () => { + const result = + client.matchLocationFromGatewayAdvertisedRouteName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.gatewayAdvertisedRoutePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchSpokeFromGatewayAdvertisedRouteName', () => { + const result = + client.matchSpokeFromGatewayAdvertisedRouteName(fakePath); + assert.strictEqual(result, 'spokeValue'); + assert( + ( + client.pathTemplates.gatewayAdvertisedRoutePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchGatewayAdvertisedRouteFromGatewayAdvertisedRouteName', () => { + const result = + client.matchGatewayAdvertisedRouteFromGatewayAdvertisedRouteName( + fakePath, + ); + assert.strictEqual(result, 'gatewayAdvertisedRouteValue'); + assert( + ( + client.pathTemplates.gatewayAdvertisedRoutePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchRemoteTransportProfileFromRemoteTransportProfileName', () => { - const result = client.matchRemoteTransportProfileFromRemoteTransportProfileName(fakePath); - assert.strictEqual(result, "remoteTransportProfileValue"); - assert((client.pathTemplates.remoteTransportProfilePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('group', async () => { + const fakePath = '/rendered/path/group'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + group: 'groupValue', + }; + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.groupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.groupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('groupPath', () => { + const result = client.groupPath( + 'projectValue', + 'hubValue', + 'groupValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.groupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromGroupName', () => { + const result = client.matchProjectFromGroupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.groupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromGroupName', () => { + const result = client.matchHubFromGroupName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.groupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchGroupFromGroupName', () => { + const result = client.matchGroupFromGroupName(fakePath); + assert.strictEqual(result, 'groupValue'); + assert( + (client.pathTemplates.groupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('routeTable', async () => { - const fakePath = "/rendered/path/routeTable"; - const expectedParameters = { - project: "projectValue", - hub: "hubValue", - route_table: "routeTableValue", - }; - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.routeTablePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.routeTablePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('routeTablePath', () => { - const result = client.routeTablePath("projectValue", "hubValue", "routeTableValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.routeTablePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('hub', async () => { + const fakePath = '/rendered/path/hub'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + }; + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.hubPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.hubPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('hubPath', () => { + const result = client.hubPath('projectValue', 'hubValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.hubPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromHubName', () => { + const result = client.matchProjectFromHubName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.hubPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromHubName', () => { + const result = client.matchHubFromHubName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.hubPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromRouteTableName', () => { - const result = client.matchProjectFromRouteTableName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.routeTablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('hubRoute', async () => { + const fakePath = '/rendered/path/hubRoute'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + route_table: 'routeTableValue', + route: 'routeValue', + }; + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.hubRoutePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.hubRoutePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('hubRoutePath', () => { + const result = client.hubRoutePath( + 'projectValue', + 'hubValue', + 'routeTableValue', + 'routeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.hubRoutePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromHubRouteName', () => { + const result = client.matchProjectFromHubRouteName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromHubRouteName', () => { + const result = client.matchHubFromHubRouteName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRouteTableFromHubRouteName', () => { + const result = client.matchRouteTableFromHubRouteName(fakePath); + assert.strictEqual(result, 'routeTableValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRouteFromHubRouteName', () => { + const result = client.matchRouteFromHubRouteName(fakePath); + assert.strictEqual(result, 'routeValue'); + assert( + (client.pathTemplates.hubRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchHubFromRouteTableName', () => { - const result = client.matchHubFromRouteTableName(fakePath); - assert.strictEqual(result, "hubValue"); - assert((client.pathTemplates.routeTablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchRouteTableFromRouteTableName', () => { - const result = client.matchRouteTableFromRouteTableName(fakePath); - assert.strictEqual(result, "routeTableValue"); - assert((client.pathTemplates.routeTablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('multicloudDataTransferConfig', async () => { + const fakePath = '/rendered/path/multicloudDataTransferConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + multicloud_data_transfer_config: 'multicloudDataTransferConfigValue', + }; + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.multicloudDataTransferConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.multicloudDataTransferConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('multicloudDataTransferConfigPath', () => { + const result = client.multicloudDataTransferConfigPath( + 'projectValue', + 'locationValue', + 'multicloudDataTransferConfigValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMulticloudDataTransferConfigName', () => { + const result = + client.matchProjectFromMulticloudDataTransferConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMulticloudDataTransferConfigName', () => { + const result = + client.matchLocationFromMulticloudDataTransferConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName', () => { + const result = + client.matchMulticloudDataTransferConfigFromMulticloudDataTransferConfigName( + fakePath, + ); + assert.strictEqual(result, 'multicloudDataTransferConfigValue'); + assert( + ( + client.pathTemplates.multicloudDataTransferConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('spoke', async () => { - const fakePath = "/rendered/path/spoke"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - spoke: "spokeValue", - }; - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.spokePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.spokePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('spokePath', () => { - const result = client.spokePath("projectValue", "locationValue", "spokeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.spokePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('multicloudDataTransferSupportedService', async () => { + const fakePath = '/rendered/path/multicloudDataTransferSupportedService'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + multicloud_data_transfer_supported_service: + 'multicloudDataTransferSupportedServiceValue', + }; + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.multicloudDataTransferSupportedServicePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('multicloudDataTransferSupportedServicePath', () => { + const result = client.multicloudDataTransferSupportedServicePath( + 'projectValue', + 'locationValue', + 'multicloudDataTransferSupportedServiceValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMulticloudDataTransferSupportedServiceName', () => { + const result = + client.matchProjectFromMulticloudDataTransferSupportedServiceName( + fakePath, + ); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMulticloudDataTransferSupportedServiceName', () => { + const result = + client.matchLocationFromMulticloudDataTransferSupportedServiceName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName', () => { + const result = + client.matchMulticloudDataTransferSupportedServiceFromMulticloudDataTransferSupportedServiceName( + fakePath, + ); + assert.strictEqual( + result, + 'multicloudDataTransferSupportedServiceValue', + ); + assert( + ( + client.pathTemplates + .multicloudDataTransferSupportedServicePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromSpokeName', () => { - const result = client.matchProjectFromSpokeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.spokePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('network', async () => { + const fakePath = '/rendered/path/network'; + const expectedParameters = { + project: 'projectValue', + resource_id: 'resourceIdValue', + }; + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.networkPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.networkPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('networkPath', () => { + const result = client.networkPath('projectValue', 'resourceIdValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.networkPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromNetworkName', () => { + const result = client.matchProjectFromNetworkName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.networkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchResourceIdFromNetworkName', () => { + const result = client.matchResourceIdFromNetworkName(fakePath); + assert.strictEqual(result, 'resourceIdValue'); + assert( + (client.pathTemplates.networkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchLocationFromSpokeName', () => { - const result = client.matchLocationFromSpokeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.spokePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('policyBasedRoute', async () => { + const fakePath = '/rendered/path/policyBasedRoute'; + const expectedParameters = { + project: 'projectValue', + policy_based_route: 'policyBasedRouteValue', + }; + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.policyBasedRoutePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.policyBasedRoutePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('policyBasedRoutePath', () => { + const result = client.policyBasedRoutePath( + 'projectValue', + 'policyBasedRouteValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.policyBasedRoutePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromPolicyBasedRouteName', () => { + const result = client.matchProjectFromPolicyBasedRouteName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchPolicyBasedRouteFromPolicyBasedRouteName', () => { + const result = + client.matchPolicyBasedRouteFromPolicyBasedRouteName(fakePath); + assert.strictEqual(result, 'policyBasedRouteValue'); + assert( + (client.pathTemplates.policyBasedRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchSpokeFromSpokeName', () => { - const result = client.matchSpokeFromSpokeName(fakePath); - assert.strictEqual(result, "spokeValue"); - assert((client.pathTemplates.spokePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('transport', async () => { - const fakePath = "/rendered/path/transport"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - transport: "transportValue", - }; - const client = new transportmanagerModule.v1beta.TransportManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.transportPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.transportPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('transportPath', () => { - const result = client.transportPath("projectValue", "locationValue", "transportValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.transportPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('remoteTransportProfile', async () => { + const fakePath = '/rendered/path/remoteTransportProfile'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + remote_transport_profile: 'remoteTransportProfileValue', + }; + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.remoteTransportProfilePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.remoteTransportProfilePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('remoteTransportProfilePath', () => { + const result = client.remoteTransportProfilePath( + 'projectValue', + 'locationValue', + 'remoteTransportProfileValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.remoteTransportProfilePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromRemoteTransportProfileName', () => { + const result = + client.matchProjectFromRemoteTransportProfileName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.remoteTransportProfilePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromRemoteTransportProfileName', () => { + const result = + client.matchLocationFromRemoteTransportProfileName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.remoteTransportProfilePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRemoteTransportProfileFromRemoteTransportProfileName', () => { + const result = + client.matchRemoteTransportProfileFromRemoteTransportProfileName( + fakePath, + ); + assert.strictEqual(result, 'remoteTransportProfileValue'); + assert( + ( + client.pathTemplates.remoteTransportProfilePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromTransportName', () => { - const result = client.matchProjectFromTransportName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.transportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('routeTable', async () => { + const fakePath = '/rendered/path/routeTable'; + const expectedParameters = { + project: 'projectValue', + hub: 'hubValue', + route_table: 'routeTableValue', + }; + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.routeTablePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.routeTablePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('routeTablePath', () => { + const result = client.routeTablePath( + 'projectValue', + 'hubValue', + 'routeTableValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.routeTablePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromRouteTableName', () => { + const result = client.matchProjectFromRouteTableName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.routeTablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHubFromRouteTableName', () => { + const result = client.matchHubFromRouteTableName(fakePath); + assert.strictEqual(result, 'hubValue'); + assert( + (client.pathTemplates.routeTablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRouteTableFromRouteTableName', () => { + const result = client.matchRouteTableFromRouteTableName(fakePath); + assert.strictEqual(result, 'routeTableValue'); + assert( + (client.pathTemplates.routeTablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchLocationFromTransportName', () => { - const result = client.matchLocationFromTransportName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.transportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('spoke', async () => { + const fakePath = '/rendered/path/spoke'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + spoke: 'spokeValue', + }; + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.spokePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.spokePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('spokePath', () => { + const result = client.spokePath( + 'projectValue', + 'locationValue', + 'spokeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.spokePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromSpokeName', () => { + const result = client.matchProjectFromSpokeName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.spokePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromSpokeName', () => { + const result = client.matchLocationFromSpokeName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.spokePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchSpokeFromSpokeName', () => { + const result = client.matchSpokeFromSpokeName(fakePath); + assert.strictEqual(result, 'spokeValue'); + assert( + (client.pathTemplates.spokePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchTransportFromTransportName', () => { - const result = client.matchTransportFromTransportName(fakePath); - assert.strictEqual(result, "transportValue"); - assert((client.pathTemplates.transportPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('transport', async () => { + const fakePath = '/rendered/path/transport'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + transport: 'transportValue', + }; + const client = new transportmanagerModule.v1beta.TransportManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.transportPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.transportPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('transportPath', () => { + const result = client.transportPath( + 'projectValue', + 'locationValue', + 'transportValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.transportPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromTransportName', () => { + const result = client.matchProjectFromTransportName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.transportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromTransportName', () => { + const result = client.matchLocationFromTransportName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.transportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTransportFromTransportName', () => { + const result = client.matchTransportFromTransportName(fakePath); + assert.strictEqual(result, 'transportValue'); + assert( + (client.pathTemplates.transportPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-networkconnectivity/webpack.config.js b/packages/google-cloud-networkconnectivity/webpack.config.js index 0406e1b73259..151b819ee94f 100644 --- a/packages/google-cloud-networkconnectivity/webpack.config.js +++ b/packages/google-cloud-networkconnectivity/webpack.config.js @@ -1,4 +1,4 @@ -// Copyright 2026 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-networkservices/.eslintignore b/packages/google-cloud-networkservices/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-networkservices/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-networkservices/.eslintrc.json b/packages/google-cloud-networkservices/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-networkservices/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-networkservices/README.md b/packages/google-cloud-networkservices/README.md index 9be535f93ad5..d0e1768dff1c 100644 --- a/packages/google-cloud-networkservices/README.md +++ b/packages/google-cloud-networkservices/README.md @@ -186,7 +186,7 @@ More Information: [Google Cloud Platform Launch Stages][launch_stages] ## Contributing -Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-networkservices/CONTRIBUTING.md). +Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/CONTRIBUTING.md). Please note that this `README.md` and a variety of configuration files in this repository (including `.nycrc` and `tsconfig.json`) @@ -196,7 +196,7 @@ are generated from a central template. Apache Version 2.0 -See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-networkservices/LICENSE) +See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/LICENSE) [shell_img]: https://gstatic.com/cloudssh/images/open-btn.png [projects]: https://console.cloud.google.com/project diff --git a/packages/google-cloud-networkservices/protos/protos.d.ts b/packages/google-cloud-networkservices/protos/protos.d.ts index 808f9b86efe5..49ca22f26e98 100644 --- a/packages/google-cloud-networkservices/protos/protos.d.ts +++ b/packages/google-cloud-networkservices/protos/protos.d.ts @@ -24110,6 +24110,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -24127,6 +24130,9 @@ export namespace google { /** CommonLanguageSettings destinations. */ public destinations: google.api.ClientLibraryDestination[]; + /** CommonLanguageSettings selectiveGapicGeneration. */ + public selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); + /** * Creates a new CommonLanguageSettings instance using the specified properties. * @param [properties] Properties to set @@ -24827,6 +24833,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -24841,6 +24850,9 @@ export namespace google { /** PythonSettings common. */ public common?: (google.api.ICommonLanguageSettings|null); + /** PythonSettings experimentalFeatures. */ + public experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); + /** * Creates a new PythonSettings instance using the specified properties. * @param [properties] Properties to set @@ -24919,6 +24931,118 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + namespace PythonSettings { + + /** Properties of an ExperimentalFeatures. */ + interface IExperimentalFeatures { + + /** ExperimentalFeatures restAsyncIoEnabled */ + restAsyncIoEnabled?: (boolean|null); + + /** ExperimentalFeatures protobufPythonicTypesEnabled */ + protobufPythonicTypesEnabled?: (boolean|null); + + /** ExperimentalFeatures unversionedPackageDisabled */ + unversionedPackageDisabled?: (boolean|null); + } + + /** Represents an ExperimentalFeatures. */ + class ExperimentalFeatures implements IExperimentalFeatures { + + /** + * Constructs a new ExperimentalFeatures. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.PythonSettings.IExperimentalFeatures); + + /** ExperimentalFeatures restAsyncIoEnabled. */ + public restAsyncIoEnabled: boolean; + + /** ExperimentalFeatures protobufPythonicTypesEnabled. */ + public protobufPythonicTypesEnabled: boolean; + + /** ExperimentalFeatures unversionedPackageDisabled. */ + public unversionedPackageDisabled: boolean; + + /** + * Creates a new ExperimentalFeatures instance using the specified properties. + * @param [properties] Properties to set + * @returns ExperimentalFeatures instance + */ + public static create(properties?: google.api.PythonSettings.IExperimentalFeatures): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Encodes the specified ExperimentalFeatures message. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @param message ExperimentalFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.PythonSettings.IExperimentalFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExperimentalFeatures message, length delimited. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @param message ExperimentalFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.PythonSettings.IExperimentalFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExperimentalFeatures + * @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.api.PythonSettings.ExperimentalFeatures; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExperimentalFeatures + * @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.api.PythonSettings.ExperimentalFeatures; + + /** + * Verifies an ExperimentalFeatures 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 an ExperimentalFeatures message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExperimentalFeatures + */ + public static fromObject(object: { [k: string]: any }): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Creates a plain object from an ExperimentalFeatures message. Also converts values to other types if specified. + * @param message ExperimentalFeatures + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.PythonSettings.ExperimentalFeatures, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExperimentalFeatures to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExperimentalFeatures + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + /** Properties of a NodeSettings. */ interface INodeSettings { @@ -25245,6 +25369,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -25259,6 +25386,9 @@ export namespace google { /** GoSettings common. */ public common?: (google.api.ICommonLanguageSettings|null); + /** GoSettings renamedServices. */ + public renamedServices: { [k: string]: string }; + /** * Creates a new GoSettings instance using the specified properties. * @param [properties] Properties to set @@ -25583,6 +25713,109 @@ export namespace google { PACKAGE_MANAGER = 20 } + /** Properties of a SelectiveGapicGeneration. */ + interface ISelectiveGapicGeneration { + + /** SelectiveGapicGeneration methods */ + methods?: (string[]|null); + + /** SelectiveGapicGeneration generateOmittedAsInternal */ + generateOmittedAsInternal?: (boolean|null); + } + + /** Represents a SelectiveGapicGeneration. */ + class SelectiveGapicGeneration implements ISelectiveGapicGeneration { + + /** + * Constructs a new SelectiveGapicGeneration. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.ISelectiveGapicGeneration); + + /** SelectiveGapicGeneration methods. */ + public methods: string[]; + + /** SelectiveGapicGeneration generateOmittedAsInternal. */ + public generateOmittedAsInternal: boolean; + + /** + * Creates a new SelectiveGapicGeneration instance using the specified properties. + * @param [properties] Properties to set + * @returns SelectiveGapicGeneration instance + */ + public static create(properties?: google.api.ISelectiveGapicGeneration): google.api.SelectiveGapicGeneration; + + /** + * Encodes the specified SelectiveGapicGeneration message. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @param message SelectiveGapicGeneration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.ISelectiveGapicGeneration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SelectiveGapicGeneration message, length delimited. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @param message SelectiveGapicGeneration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.ISelectiveGapicGeneration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SelectiveGapicGeneration + * @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.api.SelectiveGapicGeneration; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SelectiveGapicGeneration + * @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.api.SelectiveGapicGeneration; + + /** + * Verifies a SelectiveGapicGeneration 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 SelectiveGapicGeneration message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SelectiveGapicGeneration + */ + public static fromObject(object: { [k: string]: any }): google.api.SelectiveGapicGeneration; + + /** + * Creates a plain object from a SelectiveGapicGeneration message. Also converts values to other types if specified. + * @param message SelectiveGapicGeneration + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.SelectiveGapicGeneration, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SelectiveGapicGeneration to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SelectiveGapicGeneration + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** LaunchStage enum. */ enum LaunchStage { LAUNCH_STAGE_UNSPECIFIED = 0, @@ -25600,6 +25833,9 @@ export namespace google { /** FieldInfo format */ format?: (google.api.FieldInfo.Format|keyof typeof google.api.FieldInfo.Format|null); + + /** FieldInfo referencedTypes */ + referencedTypes?: (google.api.ITypeReference[]|null); } /** Represents a FieldInfo. */ @@ -25614,6 +25850,9 @@ export namespace google { /** FieldInfo format. */ public format: (google.api.FieldInfo.Format|keyof typeof google.api.FieldInfo.Format); + /** FieldInfo referencedTypes. */ + public referencedTypes: google.api.ITypeReference[]; + /** * Creates a new FieldInfo instance using the specified properties. * @param [properties] Properties to set @@ -25704,6 +25943,103 @@ export namespace google { } } + /** Properties of a TypeReference. */ + interface ITypeReference { + + /** TypeReference typeName */ + typeName?: (string|null); + } + + /** Represents a TypeReference. */ + class TypeReference implements ITypeReference { + + /** + * Constructs a new TypeReference. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.ITypeReference); + + /** TypeReference typeName. */ + public typeName: string; + + /** + * Creates a new TypeReference instance using the specified properties. + * @param [properties] Properties to set + * @returns TypeReference instance + */ + public static create(properties?: google.api.ITypeReference): google.api.TypeReference; + + /** + * Encodes the specified TypeReference message. Does not implicitly {@link google.api.TypeReference.verify|verify} messages. + * @param message TypeReference message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.ITypeReference, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified TypeReference message, length delimited. Does not implicitly {@link google.api.TypeReference.verify|verify} messages. + * @param message TypeReference message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.ITypeReference, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TypeReference message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns TypeReference + * @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.api.TypeReference; + + /** + * Decodes a TypeReference message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns TypeReference + * @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.api.TypeReference; + + /** + * Verifies a TypeReference 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 TypeReference message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TypeReference + */ + public static fromObject(object: { [k: string]: any }): google.api.TypeReference; + + /** + * Creates a plain object from a TypeReference message. Also converts values to other types if specified. + * @param message TypeReference + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.TypeReference, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TypeReference to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for TypeReference + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** Properties of a ResourceDescriptor. */ interface IResourceDescriptor { @@ -26060,6 +26396,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -26090,6 +26427,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -26139,6 +26479,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -26273,6 +26616,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -26314,6 +26660,9 @@ export namespace google { /** DescriptorProto reservedName. */ public reservedName: string[]; + /** DescriptorProto visibility. */ + public visibility: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility); + /** * Creates a new DescriptorProto instance using the specified properties. * @param [properties] Properties to set @@ -27161,6 +27510,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -27187,6 +27539,9 @@ export namespace google { /** EnumDescriptorProto reservedName. */ public reservedName: string[]; + /** EnumDescriptorProto visibility. */ + public visibility: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility); + /** * Creates a new EnumDescriptorProto instance using the specified properties. * @param [properties] Properties to set @@ -28121,6 +28476,9 @@ export namespace google { /** FieldOptions features */ features?: (google.protobuf.IFeatureSet|null); + /** FieldOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** FieldOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); @@ -28179,6 +28537,9 @@ export namespace google { /** FieldOptions features. */ public features?: (google.protobuf.IFeatureSet|null); + /** FieldOptions featureSupport. */ + public featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** FieldOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; @@ -28399,6 +28760,121 @@ export namespace google { */ public static getTypeUrl(typeUrlPrefix?: string): string; } + + /** Properties of a FeatureSupport. */ + interface IFeatureSupport { + + /** FeatureSupport editionIntroduced */ + editionIntroduced?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSupport editionDeprecated */ + editionDeprecated?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSupport deprecationWarning */ + deprecationWarning?: (string|null); + + /** FeatureSupport editionRemoved */ + editionRemoved?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + } + + /** Represents a FeatureSupport. */ + class FeatureSupport implements IFeatureSupport { + + /** + * Constructs a new FeatureSupport. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.FieldOptions.IFeatureSupport); + + /** FeatureSupport editionIntroduced. */ + public editionIntroduced: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSupport editionDeprecated. */ + public editionDeprecated: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSupport deprecationWarning. */ + public deprecationWarning: string; + + /** FeatureSupport editionRemoved. */ + public editionRemoved: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** + * Creates a new FeatureSupport instance using the specified properties. + * @param [properties] Properties to set + * @returns FeatureSupport instance + */ + public static create(properties?: google.protobuf.FieldOptions.IFeatureSupport): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Encodes the specified FeatureSupport message. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @param message FeatureSupport message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.FieldOptions.IFeatureSupport, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FeatureSupport message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @param message FeatureSupport message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.FieldOptions.IFeatureSupport, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FeatureSupport + * @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.protobuf.FieldOptions.FeatureSupport; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FeatureSupport + * @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.protobuf.FieldOptions.FeatureSupport; + + /** + * Verifies a FeatureSupport 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 FeatureSupport message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FeatureSupport + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Creates a plain object from a FeatureSupport message. Also converts values to other types if specified. + * @param message FeatureSupport + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldOptions.FeatureSupport, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FeatureSupport to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FeatureSupport + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } } /** Properties of an OneofOptions. */ @@ -28637,6 +29113,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -28659,6 +29138,9 @@ export namespace google { /** EnumValueOptions debugRedact. */ public debugRedact: boolean; + /** EnumValueOptions featureSupport. */ + public featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; @@ -29251,6 +29733,12 @@ export namespace google { /** FeatureSet jsonFormat */ jsonFormat?: (google.protobuf.FeatureSet.JsonFormat|keyof typeof google.protobuf.FeatureSet.JsonFormat|null); + + /** FeatureSet enforceNamingStyle */ + enforceNamingStyle?: (google.protobuf.FeatureSet.EnforceNamingStyle|keyof typeof google.protobuf.FeatureSet.EnforceNamingStyle|null); + + /** FeatureSet defaultSymbolVisibility */ + defaultSymbolVisibility?: (google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|keyof typeof google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|null); } /** Represents a FeatureSet. */ @@ -29280,6 +29768,12 @@ export namespace google { /** FeatureSet jsonFormat. */ public jsonFormat: (google.protobuf.FeatureSet.JsonFormat|keyof typeof google.protobuf.FeatureSet.JsonFormat); + /** FeatureSet enforceNamingStyle. */ + public enforceNamingStyle: (google.protobuf.FeatureSet.EnforceNamingStyle|keyof typeof google.protobuf.FeatureSet.EnforceNamingStyle); + + /** FeatureSet defaultSymbolVisibility. */ + public defaultSymbolVisibility: (google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|keyof typeof google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility); + /** * Creates a new FeatureSet instance using the specified properties. * @param [properties] Properties to set @@ -29402,6 +29896,116 @@ export namespace google { ALLOW = 1, LEGACY_BEST_EFFORT = 2 } + + /** EnforceNamingStyle enum. */ + enum EnforceNamingStyle { + ENFORCE_NAMING_STYLE_UNKNOWN = 0, + STYLE2024 = 1, + STYLE_LEGACY = 2 + } + + /** Properties of a VisibilityFeature. */ + interface IVisibilityFeature { + } + + /** Represents a VisibilityFeature. */ + class VisibilityFeature implements IVisibilityFeature { + + /** + * Constructs a new VisibilityFeature. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.FeatureSet.IVisibilityFeature); + + /** + * Creates a new VisibilityFeature instance using the specified properties. + * @param [properties] Properties to set + * @returns VisibilityFeature instance + */ + public static create(properties?: google.protobuf.FeatureSet.IVisibilityFeature): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Encodes the specified VisibilityFeature message. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @param message VisibilityFeature message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.FeatureSet.IVisibilityFeature, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified VisibilityFeature message, length delimited. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @param message VisibilityFeature message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.FeatureSet.IVisibilityFeature, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns VisibilityFeature + * @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.protobuf.FeatureSet.VisibilityFeature; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns VisibilityFeature + * @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.protobuf.FeatureSet.VisibilityFeature; + + /** + * Verifies a VisibilityFeature 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 VisibilityFeature message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns VisibilityFeature + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Creates a plain object from a VisibilityFeature message. Also converts values to other types if specified. + * @param message VisibilityFeature + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FeatureSet.VisibilityFeature, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this VisibilityFeature to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for VisibilityFeature + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace VisibilityFeature { + + /** DefaultSymbolVisibility enum. */ + enum DefaultSymbolVisibility { + DEFAULT_SYMBOL_VISIBILITY_UNKNOWN = 0, + EXPORT_ALL = 1, + EXPORT_TOP_LEVEL = 2, + LOCAL_ALL = 3, + STRICT = 4 + } + } } /** Properties of a FeatureSetDefaults. */ @@ -29521,8 +30125,11 @@ export namespace google { /** FeatureSetEditionDefault edition */ edition?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); - /** FeatureSetEditionDefault features */ - features?: (google.protobuf.IFeatureSet|null); + /** FeatureSetEditionDefault overridableFeatures */ + overridableFeatures?: (google.protobuf.IFeatureSet|null); + + /** FeatureSetEditionDefault fixedFeatures */ + fixedFeatures?: (google.protobuf.IFeatureSet|null); } /** Represents a FeatureSetEditionDefault. */ @@ -29537,8 +30144,11 @@ export namespace google { /** FeatureSetEditionDefault edition. */ public edition: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); - /** FeatureSetEditionDefault features. */ - public features?: (google.protobuf.IFeatureSet|null); + /** FeatureSetEditionDefault overridableFeatures. */ + public overridableFeatures?: (google.protobuf.IFeatureSet|null); + + /** FeatureSetEditionDefault fixedFeatures. */ + public fixedFeatures?: (google.protobuf.IFeatureSet|null); /** * Creates a new FeatureSetEditionDefault instance using the specified properties. @@ -30071,6 +30681,13 @@ export namespace google { } } + /** SymbolVisibility enum. */ + enum SymbolVisibility { + VISIBILITY_UNSET = 0, + VISIBILITY_LOCAL = 1, + VISIBILITY_EXPORT = 2 + } + /** Properties of a Timestamp. */ interface ITimestamp { diff --git a/packages/google-cloud-networkservices/protos/protos.js b/packages/google-cloud-networkservices/protos/protos.js index e6c440128339..131fd36770b0 100644 --- a/packages/google-cloud-networkservices/protos/protos.js +++ b/packages/google-cloud-networkservices/protos/protos.js @@ -59326,6 +59326,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -59360,6 +59361,14 @@ */ CommonLanguageSettings.prototype.destinations = $util.emptyArray; + /** + * CommonLanguageSettings selectiveGapicGeneration. + * @member {google.api.ISelectiveGapicGeneration|null|undefined} selectiveGapicGeneration + * @memberof google.api.CommonLanguageSettings + * @instance + */ + CommonLanguageSettings.prototype.selectiveGapicGeneration = null; + /** * Creates a new CommonLanguageSettings instance using the specified properties. * @function create @@ -59392,6 +59401,8 @@ writer.int32(message.destinations[i]); writer.ldelim(); } + if (message.selectiveGapicGeneration != null && Object.hasOwnProperty.call(message, "selectiveGapicGeneration")) + $root.google.api.SelectiveGapicGeneration.encode(message.selectiveGapicGeneration, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); return writer; }; @@ -59443,6 +59454,10 @@ message.destinations.push(reader.int32()); break; } + case 3: { + message.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -59494,6 +59509,11 @@ break; } } + if (message.selectiveGapicGeneration != null && message.hasOwnProperty("selectiveGapicGeneration")) { + var error = $root.google.api.SelectiveGapicGeneration.verify(message.selectiveGapicGeneration); + if (error) + return "selectiveGapicGeneration." + error; + } return null; }; @@ -59536,6 +59556,11 @@ break; } } + if (object.selectiveGapicGeneration != null) { + if (typeof object.selectiveGapicGeneration !== "object") + throw TypeError(".google.api.CommonLanguageSettings.selectiveGapicGeneration: object expected"); + message.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.fromObject(object.selectiveGapicGeneration); + } return message; }; @@ -59554,8 +59579,10 @@ var object = {}; if (options.arrays || options.defaults) object.destinations = []; - if (options.defaults) + if (options.defaults) { object.referenceDocsUri = ""; + object.selectiveGapicGeneration = null; + } if (message.referenceDocsUri != null && message.hasOwnProperty("referenceDocsUri")) object.referenceDocsUri = message.referenceDocsUri; if (message.destinations && message.destinations.length) { @@ -59563,6 +59590,8 @@ for (var j = 0; j < message.destinations.length; ++j) object.destinations[j] = options.enums === String ? $root.google.api.ClientLibraryDestination[message.destinations[j]] === undefined ? message.destinations[j] : $root.google.api.ClientLibraryDestination[message.destinations[j]] : message.destinations[j]; } + if (message.selectiveGapicGeneration != null && message.hasOwnProperty("selectiveGapicGeneration")) + object.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.toObject(message.selectiveGapicGeneration, options); return object; }; @@ -61385,6 +61414,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -61410,6 +61440,14 @@ */ PythonSettings.prototype.common = null; + /** + * PythonSettings experimentalFeatures. + * @member {google.api.PythonSettings.IExperimentalFeatures|null|undefined} experimentalFeatures + * @memberof google.api.PythonSettings + * @instance + */ + PythonSettings.prototype.experimentalFeatures = null; + /** * Creates a new PythonSettings instance using the specified properties. * @function create @@ -61436,6 +61474,8 @@ writer = $Writer.create(); if (message.common != null && Object.hasOwnProperty.call(message, "common")) $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.experimentalFeatures != null && Object.hasOwnProperty.call(message, "experimentalFeatures")) + $root.google.api.PythonSettings.ExperimentalFeatures.encode(message.experimentalFeatures, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; @@ -61476,6 +61516,10 @@ message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); break; } + case 2: { + message.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -61516,6 +61560,11 @@ if (error) return "common." + error; } + if (message.experimentalFeatures != null && message.hasOwnProperty("experimentalFeatures")) { + var error = $root.google.api.PythonSettings.ExperimentalFeatures.verify(message.experimentalFeatures); + if (error) + return "experimentalFeatures." + error; + } return null; }; @@ -61536,6 +61585,11 @@ throw TypeError(".google.api.PythonSettings.common: object expected"); message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); } + if (object.experimentalFeatures != null) { + if (typeof object.experimentalFeatures !== "object") + throw TypeError(".google.api.PythonSettings.experimentalFeatures: object expected"); + message.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.fromObject(object.experimentalFeatures); + } return message; }; @@ -61552,10 +61606,14 @@ if (!options) options = {}; var object = {}; - if (options.defaults) + if (options.defaults) { object.common = null; + object.experimentalFeatures = null; + } if (message.common != null && message.hasOwnProperty("common")) object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + if (message.experimentalFeatures != null && message.hasOwnProperty("experimentalFeatures")) + object.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.toObject(message.experimentalFeatures, options); return object; }; @@ -61585,6 +61643,258 @@ return typeUrlPrefix + "/google.api.PythonSettings"; }; + PythonSettings.ExperimentalFeatures = (function() { + + /** + * Properties of an ExperimentalFeatures. + * @memberof google.api.PythonSettings + * @interface IExperimentalFeatures + * @property {boolean|null} [restAsyncIoEnabled] ExperimentalFeatures restAsyncIoEnabled + * @property {boolean|null} [protobufPythonicTypesEnabled] ExperimentalFeatures protobufPythonicTypesEnabled + * @property {boolean|null} [unversionedPackageDisabled] ExperimentalFeatures unversionedPackageDisabled + */ + + /** + * Constructs a new ExperimentalFeatures. + * @memberof google.api.PythonSettings + * @classdesc Represents an ExperimentalFeatures. + * @implements IExperimentalFeatures + * @constructor + * @param {google.api.PythonSettings.IExperimentalFeatures=} [properties] Properties to set + */ + function ExperimentalFeatures(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]]; + } + + /** + * ExperimentalFeatures restAsyncIoEnabled. + * @member {boolean} restAsyncIoEnabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.restAsyncIoEnabled = false; + + /** + * ExperimentalFeatures protobufPythonicTypesEnabled. + * @member {boolean} protobufPythonicTypesEnabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.protobufPythonicTypesEnabled = false; + + /** + * ExperimentalFeatures unversionedPackageDisabled. + * @member {boolean} unversionedPackageDisabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.unversionedPackageDisabled = false; + + /** + * Creates a new ExperimentalFeatures instance using the specified properties. + * @function create + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures=} [properties] Properties to set + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures instance + */ + ExperimentalFeatures.create = function create(properties) { + return new ExperimentalFeatures(properties); + }; + + /** + * Encodes the specified ExperimentalFeatures message. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @function encode + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures} message ExperimentalFeatures message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExperimentalFeatures.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.restAsyncIoEnabled != null && Object.hasOwnProperty.call(message, "restAsyncIoEnabled")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.restAsyncIoEnabled); + if (message.protobufPythonicTypesEnabled != null && Object.hasOwnProperty.call(message, "protobufPythonicTypesEnabled")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.protobufPythonicTypesEnabled); + if (message.unversionedPackageDisabled != null && Object.hasOwnProperty.call(message, "unversionedPackageDisabled")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.unversionedPackageDisabled); + return writer; + }; + + /** + * Encodes the specified ExperimentalFeatures message, length delimited. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures} message ExperimentalFeatures message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExperimentalFeatures.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer. + * @function decode + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExperimentalFeatures.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.PythonSettings.ExperimentalFeatures(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.restAsyncIoEnabled = reader.bool(); + break; + } + case 2: { + message.protobufPythonicTypesEnabled = reader.bool(); + break; + } + case 3: { + message.unversionedPackageDisabled = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExperimentalFeatures.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExperimentalFeatures message. + * @function verify + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExperimentalFeatures.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.restAsyncIoEnabled != null && message.hasOwnProperty("restAsyncIoEnabled")) + if (typeof message.restAsyncIoEnabled !== "boolean") + return "restAsyncIoEnabled: boolean expected"; + if (message.protobufPythonicTypesEnabled != null && message.hasOwnProperty("protobufPythonicTypesEnabled")) + if (typeof message.protobufPythonicTypesEnabled !== "boolean") + return "protobufPythonicTypesEnabled: boolean expected"; + if (message.unversionedPackageDisabled != null && message.hasOwnProperty("unversionedPackageDisabled")) + if (typeof message.unversionedPackageDisabled !== "boolean") + return "unversionedPackageDisabled: boolean expected"; + return null; + }; + + /** + * Creates an ExperimentalFeatures message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {Object.} object Plain object + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + */ + ExperimentalFeatures.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.PythonSettings.ExperimentalFeatures) + return object; + var message = new $root.google.api.PythonSettings.ExperimentalFeatures(); + if (object.restAsyncIoEnabled != null) + message.restAsyncIoEnabled = Boolean(object.restAsyncIoEnabled); + if (object.protobufPythonicTypesEnabled != null) + message.protobufPythonicTypesEnabled = Boolean(object.protobufPythonicTypesEnabled); + if (object.unversionedPackageDisabled != null) + message.unversionedPackageDisabled = Boolean(object.unversionedPackageDisabled); + return message; + }; + + /** + * Creates a plain object from an ExperimentalFeatures message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.ExperimentalFeatures} message ExperimentalFeatures + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExperimentalFeatures.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.restAsyncIoEnabled = false; + object.protobufPythonicTypesEnabled = false; + object.unversionedPackageDisabled = false; + } + if (message.restAsyncIoEnabled != null && message.hasOwnProperty("restAsyncIoEnabled")) + object.restAsyncIoEnabled = message.restAsyncIoEnabled; + if (message.protobufPythonicTypesEnabled != null && message.hasOwnProperty("protobufPythonicTypesEnabled")) + object.protobufPythonicTypesEnabled = message.protobufPythonicTypesEnabled; + if (message.unversionedPackageDisabled != null && message.hasOwnProperty("unversionedPackageDisabled")) + object.unversionedPackageDisabled = message.unversionedPackageDisabled; + return object; + }; + + /** + * Converts this ExperimentalFeatures to JSON. + * @function toJSON + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + * @returns {Object.} JSON object + */ + ExperimentalFeatures.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExperimentalFeatures + * @function getTypeUrl + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExperimentalFeatures.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.PythonSettings.ExperimentalFeatures"; + }; + + return ExperimentalFeatures; + })(); + return PythonSettings; })(); @@ -62461,6 +62771,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -62472,6 +62783,7 @@ * @param {google.api.IGoSettings=} [properties] Properties to set */ function GoSettings(properties) { + this.renamedServices = {}; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -62486,6 +62798,14 @@ */ GoSettings.prototype.common = null; + /** + * GoSettings renamedServices. + * @member {Object.} renamedServices + * @memberof google.api.GoSettings + * @instance + */ + GoSettings.prototype.renamedServices = $util.emptyObject; + /** * Creates a new GoSettings instance using the specified properties. * @function create @@ -62512,6 +62832,9 @@ writer = $Writer.create(); if (message.common != null && Object.hasOwnProperty.call(message, "common")) $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.renamedServices != null && Object.hasOwnProperty.call(message, "renamedServices")) + for (var keys = Object.keys(message.renamedServices), i = 0; i < keys.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.renamedServices[keys[i]]).ldelim(); return writer; }; @@ -62542,7 +62865,7 @@ GoSettings.decode = function decode(reader, length, error) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.GoSettings(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.GoSettings(), key, value; while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) @@ -62552,6 +62875,29 @@ message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); break; } + case 2: { + if (message.renamedServices === $util.emptyObject) + message.renamedServices = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = ""; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = reader.string(); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.renamedServices[key] = value; + break; + } default: reader.skipType(tag & 7); break; @@ -62592,6 +62938,14 @@ if (error) return "common." + error; } + if (message.renamedServices != null && message.hasOwnProperty("renamedServices")) { + if (!$util.isObject(message.renamedServices)) + return "renamedServices: object expected"; + var key = Object.keys(message.renamedServices); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.renamedServices[key[i]])) + return "renamedServices: string{k:string} expected"; + } return null; }; @@ -62612,6 +62966,13 @@ throw TypeError(".google.api.GoSettings.common: object expected"); message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); } + if (object.renamedServices) { + if (typeof object.renamedServices !== "object") + throw TypeError(".google.api.GoSettings.renamedServices: object expected"); + message.renamedServices = {}; + for (var keys = Object.keys(object.renamedServices), i = 0; i < keys.length; ++i) + message.renamedServices[keys[i]] = String(object.renamedServices[keys[i]]); + } return message; }; @@ -62628,10 +62989,18 @@ if (!options) options = {}; var object = {}; + if (options.objects || options.defaults) + object.renamedServices = {}; if (options.defaults) object.common = null; if (message.common != null && message.hasOwnProperty("common")) object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + var keys2; + if (message.renamedServices && (keys2 = Object.keys(message.renamedServices)).length) { + object.renamedServices = {}; + for (var j = 0; j < keys2.length; ++j) + object.renamedServices[keys2[j]] = message.renamedServices[keys2[j]]; + } return object; }; @@ -63270,29 +63639,274 @@ return values; })(); - /** - * LaunchStage enum. - * @name google.api.LaunchStage - * @enum {number} - * @property {number} LAUNCH_STAGE_UNSPECIFIED=0 LAUNCH_STAGE_UNSPECIFIED value - * @property {number} UNIMPLEMENTED=6 UNIMPLEMENTED value - * @property {number} PRELAUNCH=7 PRELAUNCH value - * @property {number} EARLY_ACCESS=1 EARLY_ACCESS value - * @property {number} ALPHA=2 ALPHA value - * @property {number} BETA=3 BETA value - * @property {number} GA=4 GA value - * @property {number} DEPRECATED=5 DEPRECATED value - */ - api.LaunchStage = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "LAUNCH_STAGE_UNSPECIFIED"] = 0; - values[valuesById[6] = "UNIMPLEMENTED"] = 6; - values[valuesById[7] = "PRELAUNCH"] = 7; - values[valuesById[1] = "EARLY_ACCESS"] = 1; - values[valuesById[2] = "ALPHA"] = 2; - values[valuesById[3] = "BETA"] = 3; - values[valuesById[4] = "GA"] = 4; - values[valuesById[5] = "DEPRECATED"] = 5; + api.SelectiveGapicGeneration = (function() { + + /** + * Properties of a SelectiveGapicGeneration. + * @memberof google.api + * @interface ISelectiveGapicGeneration + * @property {Array.|null} [methods] SelectiveGapicGeneration methods + * @property {boolean|null} [generateOmittedAsInternal] SelectiveGapicGeneration generateOmittedAsInternal + */ + + /** + * Constructs a new SelectiveGapicGeneration. + * @memberof google.api + * @classdesc Represents a SelectiveGapicGeneration. + * @implements ISelectiveGapicGeneration + * @constructor + * @param {google.api.ISelectiveGapicGeneration=} [properties] Properties to set + */ + function SelectiveGapicGeneration(properties) { + this.methods = []; + 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]]; + } + + /** + * SelectiveGapicGeneration methods. + * @member {Array.} methods + * @memberof google.api.SelectiveGapicGeneration + * @instance + */ + SelectiveGapicGeneration.prototype.methods = $util.emptyArray; + + /** + * SelectiveGapicGeneration generateOmittedAsInternal. + * @member {boolean} generateOmittedAsInternal + * @memberof google.api.SelectiveGapicGeneration + * @instance + */ + SelectiveGapicGeneration.prototype.generateOmittedAsInternal = false; + + /** + * Creates a new SelectiveGapicGeneration instance using the specified properties. + * @function create + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration=} [properties] Properties to set + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration instance + */ + SelectiveGapicGeneration.create = function create(properties) { + return new SelectiveGapicGeneration(properties); + }; + + /** + * Encodes the specified SelectiveGapicGeneration message. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @function encode + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration} message SelectiveGapicGeneration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SelectiveGapicGeneration.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.methods != null && message.methods.length) + for (var i = 0; i < message.methods.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.methods[i]); + if (message.generateOmittedAsInternal != null && Object.hasOwnProperty.call(message, "generateOmittedAsInternal")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.generateOmittedAsInternal); + return writer; + }; + + /** + * Encodes the specified SelectiveGapicGeneration message, length delimited. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration} message SelectiveGapicGeneration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SelectiveGapicGeneration.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer. + * @function decode + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SelectiveGapicGeneration.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.SelectiveGapicGeneration(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + if (!(message.methods && message.methods.length)) + message.methods = []; + message.methods.push(reader.string()); + break; + } + case 2: { + message.generateOmittedAsInternal = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SelectiveGapicGeneration.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SelectiveGapicGeneration message. + * @function verify + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SelectiveGapicGeneration.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.methods != null && message.hasOwnProperty("methods")) { + if (!Array.isArray(message.methods)) + return "methods: array expected"; + for (var i = 0; i < message.methods.length; ++i) + if (!$util.isString(message.methods[i])) + return "methods: string[] expected"; + } + if (message.generateOmittedAsInternal != null && message.hasOwnProperty("generateOmittedAsInternal")) + if (typeof message.generateOmittedAsInternal !== "boolean") + return "generateOmittedAsInternal: boolean expected"; + return null; + }; + + /** + * Creates a SelectiveGapicGeneration message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {Object.} object Plain object + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + */ + SelectiveGapicGeneration.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.SelectiveGapicGeneration) + return object; + var message = new $root.google.api.SelectiveGapicGeneration(); + if (object.methods) { + if (!Array.isArray(object.methods)) + throw TypeError(".google.api.SelectiveGapicGeneration.methods: array expected"); + message.methods = []; + for (var i = 0; i < object.methods.length; ++i) + message.methods[i] = String(object.methods[i]); + } + if (object.generateOmittedAsInternal != null) + message.generateOmittedAsInternal = Boolean(object.generateOmittedAsInternal); + return message; + }; + + /** + * Creates a plain object from a SelectiveGapicGeneration message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.SelectiveGapicGeneration} message SelectiveGapicGeneration + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SelectiveGapicGeneration.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.methods = []; + if (options.defaults) + object.generateOmittedAsInternal = false; + if (message.methods && message.methods.length) { + object.methods = []; + for (var j = 0; j < message.methods.length; ++j) + object.methods[j] = message.methods[j]; + } + if (message.generateOmittedAsInternal != null && message.hasOwnProperty("generateOmittedAsInternal")) + object.generateOmittedAsInternal = message.generateOmittedAsInternal; + return object; + }; + + /** + * Converts this SelectiveGapicGeneration to JSON. + * @function toJSON + * @memberof google.api.SelectiveGapicGeneration + * @instance + * @returns {Object.} JSON object + */ + SelectiveGapicGeneration.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SelectiveGapicGeneration + * @function getTypeUrl + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SelectiveGapicGeneration.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.SelectiveGapicGeneration"; + }; + + return SelectiveGapicGeneration; + })(); + + /** + * LaunchStage enum. + * @name google.api.LaunchStage + * @enum {number} + * @property {number} LAUNCH_STAGE_UNSPECIFIED=0 LAUNCH_STAGE_UNSPECIFIED value + * @property {number} UNIMPLEMENTED=6 UNIMPLEMENTED value + * @property {number} PRELAUNCH=7 PRELAUNCH value + * @property {number} EARLY_ACCESS=1 EARLY_ACCESS value + * @property {number} ALPHA=2 ALPHA value + * @property {number} BETA=3 BETA value + * @property {number} GA=4 GA value + * @property {number} DEPRECATED=5 DEPRECATED value + */ + api.LaunchStage = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "LAUNCH_STAGE_UNSPECIFIED"] = 0; + values[valuesById[6] = "UNIMPLEMENTED"] = 6; + values[valuesById[7] = "PRELAUNCH"] = 7; + values[valuesById[1] = "EARLY_ACCESS"] = 1; + values[valuesById[2] = "ALPHA"] = 2; + values[valuesById[3] = "BETA"] = 3; + values[valuesById[4] = "GA"] = 4; + values[valuesById[5] = "DEPRECATED"] = 5; return values; })(); @@ -63303,6 +63917,7 @@ * @memberof google.api * @interface IFieldInfo * @property {google.api.FieldInfo.Format|null} [format] FieldInfo format + * @property {Array.|null} [referencedTypes] FieldInfo referencedTypes */ /** @@ -63314,6 +63929,7 @@ * @param {google.api.IFieldInfo=} [properties] Properties to set */ function FieldInfo(properties) { + this.referencedTypes = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -63328,6 +63944,14 @@ */ FieldInfo.prototype.format = 0; + /** + * FieldInfo referencedTypes. + * @member {Array.} referencedTypes + * @memberof google.api.FieldInfo + * @instance + */ + FieldInfo.prototype.referencedTypes = $util.emptyArray; + /** * Creates a new FieldInfo instance using the specified properties. * @function create @@ -63354,6 +63978,9 @@ writer = $Writer.create(); if (message.format != null && Object.hasOwnProperty.call(message, "format")) writer.uint32(/* id 1, wireType 0 =*/8).int32(message.format); + if (message.referencedTypes != null && message.referencedTypes.length) + for (var i = 0; i < message.referencedTypes.length; ++i) + $root.google.api.TypeReference.encode(message.referencedTypes[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; @@ -63394,6 +64021,12 @@ message.format = reader.int32(); break; } + case 2: { + if (!(message.referencedTypes && message.referencedTypes.length)) + message.referencedTypes = []; + message.referencedTypes.push($root.google.api.TypeReference.decode(reader, reader.uint32())); + break; + } default: reader.skipType(tag & 7); break; @@ -63440,6 +64073,15 @@ case 4: break; } + if (message.referencedTypes != null && message.hasOwnProperty("referencedTypes")) { + if (!Array.isArray(message.referencedTypes)) + return "referencedTypes: array expected"; + for (var i = 0; i < message.referencedTypes.length; ++i) { + var error = $root.google.api.TypeReference.verify(message.referencedTypes[i]); + if (error) + return "referencedTypes." + error; + } + } return null; }; @@ -63483,6 +64125,16 @@ message.format = 4; break; } + if (object.referencedTypes) { + if (!Array.isArray(object.referencedTypes)) + throw TypeError(".google.api.FieldInfo.referencedTypes: array expected"); + message.referencedTypes = []; + for (var i = 0; i < object.referencedTypes.length; ++i) { + if (typeof object.referencedTypes[i] !== "object") + throw TypeError(".google.api.FieldInfo.referencedTypes: object expected"); + message.referencedTypes[i] = $root.google.api.TypeReference.fromObject(object.referencedTypes[i]); + } + } return message; }; @@ -63499,10 +64151,17 @@ if (!options) options = {}; var object = {}; + if (options.arrays || options.defaults) + object.referencedTypes = []; if (options.defaults) object.format = options.enums === String ? "FORMAT_UNSPECIFIED" : 0; if (message.format != null && message.hasOwnProperty("format")) object.format = options.enums === String ? $root.google.api.FieldInfo.Format[message.format] === undefined ? message.format : $root.google.api.FieldInfo.Format[message.format] : message.format; + if (message.referencedTypes && message.referencedTypes.length) { + object.referencedTypes = []; + for (var j = 0; j < message.referencedTypes.length; ++j) + object.referencedTypes[j] = $root.google.api.TypeReference.toObject(message.referencedTypes[j], options); + } return object; }; @@ -63555,32 +64214,24 @@ return FieldInfo; })(); - api.ResourceDescriptor = (function() { + api.TypeReference = (function() { /** - * Properties of a ResourceDescriptor. + * Properties of a TypeReference. * @memberof google.api - * @interface IResourceDescriptor - * @property {string|null} [type] ResourceDescriptor type - * @property {Array.|null} [pattern] ResourceDescriptor pattern - * @property {string|null} [nameField] ResourceDescriptor nameField - * @property {google.api.ResourceDescriptor.History|null} [history] ResourceDescriptor history - * @property {string|null} [plural] ResourceDescriptor plural - * @property {string|null} [singular] ResourceDescriptor singular - * @property {Array.|null} [style] ResourceDescriptor style + * @interface ITypeReference + * @property {string|null} [typeName] TypeReference typeName */ /** - * Constructs a new ResourceDescriptor. + * Constructs a new TypeReference. * @memberof google.api - * @classdesc Represents a ResourceDescriptor. - * @implements IResourceDescriptor + * @classdesc Represents a TypeReference. + * @implements ITypeReference * @constructor - * @param {google.api.IResourceDescriptor=} [properties] Properties to set + * @param {google.api.ITypeReference=} [properties] Properties to set */ - function ResourceDescriptor(properties) { - this.pattern = []; - this.style = []; + function TypeReference(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -63588,48 +64239,261 @@ } /** - * ResourceDescriptor type. - * @member {string} type - * @memberof google.api.ResourceDescriptor + * TypeReference typeName. + * @member {string} typeName + * @memberof google.api.TypeReference * @instance */ - ResourceDescriptor.prototype.type = ""; + TypeReference.prototype.typeName = ""; /** - * ResourceDescriptor pattern. - * @member {Array.} pattern - * @memberof google.api.ResourceDescriptor - * @instance + * Creates a new TypeReference instance using the specified properties. + * @function create + * @memberof google.api.TypeReference + * @static + * @param {google.api.ITypeReference=} [properties] Properties to set + * @returns {google.api.TypeReference} TypeReference instance */ - ResourceDescriptor.prototype.pattern = $util.emptyArray; + TypeReference.create = function create(properties) { + return new TypeReference(properties); + }; /** - * ResourceDescriptor nameField. - * @member {string} nameField - * @memberof google.api.ResourceDescriptor - * @instance + * Encodes the specified TypeReference message. Does not implicitly {@link google.api.TypeReference.verify|verify} messages. + * @function encode + * @memberof google.api.TypeReference + * @static + * @param {google.api.ITypeReference} message TypeReference message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer */ - ResourceDescriptor.prototype.nameField = ""; + TypeReference.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.typeName != null && Object.hasOwnProperty.call(message, "typeName")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.typeName); + return writer; + }; /** - * ResourceDescriptor history. - * @member {google.api.ResourceDescriptor.History} history - * @memberof google.api.ResourceDescriptor - * @instance + * Encodes the specified TypeReference message, length delimited. Does not implicitly {@link google.api.TypeReference.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.TypeReference + * @static + * @param {google.api.ITypeReference} message TypeReference message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer */ - ResourceDescriptor.prototype.history = 0; + TypeReference.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; /** - * ResourceDescriptor plural. - * @member {string} plural - * @memberof google.api.ResourceDescriptor - * @instance + * Decodes a TypeReference message from the specified reader or buffer. + * @function decode + * @memberof google.api.TypeReference + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.TypeReference} TypeReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - ResourceDescriptor.prototype.plural = ""; - - /** - * ResourceDescriptor singular. - * @member {string} singular + TypeReference.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.TypeReference(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.typeName = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a TypeReference message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.TypeReference + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.TypeReference} TypeReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TypeReference.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TypeReference message. + * @function verify + * @memberof google.api.TypeReference + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TypeReference.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.typeName != null && message.hasOwnProperty("typeName")) + if (!$util.isString(message.typeName)) + return "typeName: string expected"; + return null; + }; + + /** + * Creates a TypeReference message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.TypeReference + * @static + * @param {Object.} object Plain object + * @returns {google.api.TypeReference} TypeReference + */ + TypeReference.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.TypeReference) + return object; + var message = new $root.google.api.TypeReference(); + if (object.typeName != null) + message.typeName = String(object.typeName); + return message; + }; + + /** + * Creates a plain object from a TypeReference message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.TypeReference + * @static + * @param {google.api.TypeReference} message TypeReference + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TypeReference.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.typeName = ""; + if (message.typeName != null && message.hasOwnProperty("typeName")) + object.typeName = message.typeName; + return object; + }; + + /** + * Converts this TypeReference to JSON. + * @function toJSON + * @memberof google.api.TypeReference + * @instance + * @returns {Object.} JSON object + */ + TypeReference.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for TypeReference + * @function getTypeUrl + * @memberof google.api.TypeReference + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + TypeReference.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.TypeReference"; + }; + + return TypeReference; + })(); + + api.ResourceDescriptor = (function() { + + /** + * Properties of a ResourceDescriptor. + * @memberof google.api + * @interface IResourceDescriptor + * @property {string|null} [type] ResourceDescriptor type + * @property {Array.|null} [pattern] ResourceDescriptor pattern + * @property {string|null} [nameField] ResourceDescriptor nameField + * @property {google.api.ResourceDescriptor.History|null} [history] ResourceDescriptor history + * @property {string|null} [plural] ResourceDescriptor plural + * @property {string|null} [singular] ResourceDescriptor singular + * @property {Array.|null} [style] ResourceDescriptor style + */ + + /** + * Constructs a new ResourceDescriptor. + * @memberof google.api + * @classdesc Represents a ResourceDescriptor. + * @implements IResourceDescriptor + * @constructor + * @param {google.api.IResourceDescriptor=} [properties] Properties to set + */ + function ResourceDescriptor(properties) { + this.pattern = []; + this.style = []; + 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]]; + } + + /** + * ResourceDescriptor type. + * @member {string} type + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.type = ""; + + /** + * ResourceDescriptor pattern. + * @member {Array.} pattern + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.pattern = $util.emptyArray; + + /** + * ResourceDescriptor nameField. + * @member {string} nameField + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.nameField = ""; + + /** + * ResourceDescriptor history. + * @member {google.api.ResourceDescriptor.History} history + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.history = 0; + + /** + * ResourceDescriptor plural. + * @member {string} plural + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.plural = ""; + + /** + * ResourceDescriptor singular. + * @member {string} singular * @memberof google.api.ResourceDescriptor * @instance */ @@ -64486,6 +65350,7 @@ * @name google.protobuf.Edition * @enum {number} * @property {number} EDITION_UNKNOWN=0 EDITION_UNKNOWN value + * @property {number} EDITION_LEGACY=900 EDITION_LEGACY value * @property {number} EDITION_PROTO2=998 EDITION_PROTO2 value * @property {number} EDITION_PROTO3=999 EDITION_PROTO3 value * @property {number} EDITION_2023=1000 EDITION_2023 value @@ -64500,6 +65365,7 @@ protobuf.Edition = (function() { var valuesById = {}, values = Object.create(valuesById); values[valuesById[0] = "EDITION_UNKNOWN"] = 0; + values[valuesById[900] = "EDITION_LEGACY"] = 900; values[valuesById[998] = "EDITION_PROTO2"] = 998; values[valuesById[999] = "EDITION_PROTO3"] = 999; values[valuesById[1000] = "EDITION_2023"] = 1000; @@ -64524,6 +65390,7 @@ * @property {Array.|null} [dependency] FileDescriptorProto dependency * @property {Array.|null} [publicDependency] FileDescriptorProto publicDependency * @property {Array.|null} [weakDependency] FileDescriptorProto weakDependency + * @property {Array.|null} [optionDependency] FileDescriptorProto optionDependency * @property {Array.|null} [messageType] FileDescriptorProto messageType * @property {Array.|null} [enumType] FileDescriptorProto enumType * @property {Array.|null} [service] FileDescriptorProto service @@ -64546,6 +65413,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -64596,6 +65464,14 @@ */ FileDescriptorProto.prototype.weakDependency = $util.emptyArray; + /** + * FileDescriptorProto optionDependency. + * @member {Array.} optionDependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.optionDependency = $util.emptyArray; + /** * FileDescriptorProto messageType. * @member {Array.} messageType @@ -64717,6 +65593,9 @@ writer.uint32(/* id 12, wireType 2 =*/98).string(message.syntax); if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) writer.uint32(/* id 14, wireType 0 =*/112).int32(message.edition); + if (message.optionDependency != null && message.optionDependency.length) + for (var i = 0; i < message.optionDependency.length; ++i) + writer.uint32(/* id 15, wireType 2 =*/122).string(message.optionDependency[i]); return writer; }; @@ -64789,6 +65668,12 @@ message.weakDependency.push(reader.int32()); break; } + case 15: { + if (!(message.optionDependency && message.optionDependency.length)) + message.optionDependency = []; + message.optionDependency.push(reader.string()); + break; + } case 4: { if (!(message.messageType && message.messageType.length)) message.messageType = []; @@ -64891,6 +65776,13 @@ if (!$util.isInteger(message.weakDependency[i])) return "weakDependency: integer[] expected"; } + if (message.optionDependency != null && message.hasOwnProperty("optionDependency")) { + if (!Array.isArray(message.optionDependency)) + return "optionDependency: array expected"; + for (var i = 0; i < message.optionDependency.length; ++i) + if (!$util.isString(message.optionDependency[i])) + return "optionDependency: string[] expected"; + } if (message.messageType != null && message.hasOwnProperty("messageType")) { if (!Array.isArray(message.messageType)) return "messageType: array expected"; @@ -64945,6 +65837,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -64997,6 +65890,13 @@ for (var i = 0; i < object.weakDependency.length; ++i) message.weakDependency[i] = object.weakDependency[i] | 0; } + if (object.optionDependency) { + if (!Array.isArray(object.optionDependency)) + throw TypeError(".google.protobuf.FileDescriptorProto.optionDependency: array expected"); + message.optionDependency = []; + for (var i = 0; i < object.optionDependency.length; ++i) + message.optionDependency[i] = String(object.optionDependency[i]); + } if (object.messageType) { if (!Array.isArray(object.messageType)) throw TypeError(".google.protobuf.FileDescriptorProto.messageType: array expected"); @@ -65060,6 +65960,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -65125,6 +66029,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -65181,6 +66086,11 @@ object.syntax = message.syntax; if (message.edition != null && message.hasOwnProperty("edition")) object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.optionDependency && message.optionDependency.length) { + object.optionDependency = []; + for (var j = 0; j < message.optionDependency.length; ++j) + object.optionDependency[j] = message.optionDependency[j]; + } return object; }; @@ -65229,6 +66139,7 @@ * @property {google.protobuf.IMessageOptions|null} [options] DescriptorProto options * @property {Array.|null} [reservedRange] DescriptorProto reservedRange * @property {Array.|null} [reservedName] DescriptorProto reservedName + * @property {google.protobuf.SymbolVisibility|null} [visibility] DescriptorProto visibility */ /** @@ -65334,6 +66245,14 @@ */ DescriptorProto.prototype.reservedName = $util.emptyArray; + /** + * DescriptorProto visibility. + * @member {google.protobuf.SymbolVisibility} visibility + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.visibility = 0; + /** * Creates a new DescriptorProto instance using the specified properties. * @function create @@ -65386,6 +66305,8 @@ if (message.reservedName != null && message.reservedName.length) for (var i = 0; i < message.reservedName.length; ++i) writer.uint32(/* id 10, wireType 2 =*/82).string(message.reservedName[i]); + if (message.visibility != null && Object.hasOwnProperty.call(message, "visibility")) + writer.uint32(/* id 11, wireType 0 =*/88).int32(message.visibility); return writer; }; @@ -65478,6 +66399,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -65591,6 +66516,15 @@ if (!$util.isString(message.reservedName[i])) return "reservedName: string[] expected"; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + switch (message.visibility) { + default: + return "visibility: enum value expected"; + case 0: + case 1: + case 2: + break; + } return null; }; @@ -65690,6 +66624,26 @@ for (var i = 0; i < object.reservedName.length; ++i) message.reservedName[i] = String(object.reservedName[i]); } + switch (object.visibility) { + default: + if (typeof object.visibility === "number") { + message.visibility = object.visibility; + break; + } + break; + case "VISIBILITY_UNSET": + case 0: + message.visibility = 0; + break; + case "VISIBILITY_LOCAL": + case 1: + message.visibility = 1; + break; + case "VISIBILITY_EXPORT": + case 2: + message.visibility = 2; + break; + } return message; }; @@ -65719,6 +66673,7 @@ if (options.defaults) { object.name = ""; object.options = null; + object.visibility = options.enums === String ? "VISIBILITY_UNSET" : 0; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -65764,6 +66719,8 @@ for (var j = 0; j < message.reservedName.length; ++j) object.reservedName[j] = message.reservedName[j]; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + object.visibility = options.enums === String ? $root.google.protobuf.SymbolVisibility[message.visibility] === undefined ? message.visibility : $root.google.protobuf.SymbolVisibility[message.visibility] : message.visibility; return object; }; @@ -67808,6 +68765,7 @@ * @property {google.protobuf.IEnumOptions|null} [options] EnumDescriptorProto options * @property {Array.|null} [reservedRange] EnumDescriptorProto reservedRange * @property {Array.|null} [reservedName] EnumDescriptorProto reservedName + * @property {google.protobuf.SymbolVisibility|null} [visibility] EnumDescriptorProto visibility */ /** @@ -67868,6 +68826,14 @@ */ EnumDescriptorProto.prototype.reservedName = $util.emptyArray; + /** + * EnumDescriptorProto visibility. + * @member {google.protobuf.SymbolVisibility} visibility + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.visibility = 0; + /** * Creates a new EnumDescriptorProto instance using the specified properties. * @function create @@ -67905,6 +68871,8 @@ if (message.reservedName != null && message.reservedName.length) for (var i = 0; i < message.reservedName.length; ++i) writer.uint32(/* id 5, wireType 2 =*/42).string(message.reservedName[i]); + if (message.visibility != null && Object.hasOwnProperty.call(message, "visibility")) + writer.uint32(/* id 6, wireType 0 =*/48).int32(message.visibility); return writer; }; @@ -67967,6 +68935,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -68035,6 +69007,15 @@ if (!$util.isString(message.reservedName[i])) return "reservedName: string[] expected"; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + switch (message.visibility) { + default: + return "visibility: enum value expected"; + case 0: + case 1: + case 2: + break; + } return null; }; @@ -68084,6 +69065,26 @@ for (var i = 0; i < object.reservedName.length; ++i) message.reservedName[i] = String(object.reservedName[i]); } + switch (object.visibility) { + default: + if (typeof object.visibility === "number") { + message.visibility = object.visibility; + break; + } + break; + case "VISIBILITY_UNSET": + case 0: + message.visibility = 0; + break; + case "VISIBILITY_LOCAL": + case 1: + message.visibility = 1; + break; + case "VISIBILITY_EXPORT": + case 2: + message.visibility = 2; + break; + } return message; }; @@ -68108,6 +69109,7 @@ if (options.defaults) { object.name = ""; object.options = null; + object.visibility = options.enums === String ? "VISIBILITY_UNSET" : 0; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -68128,6 +69130,8 @@ for (var j = 0; j < message.reservedName.length; ++j) object.reservedName[j] = message.reservedName[j]; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + object.visibility = options.enums === String ? $root.google.protobuf.SymbolVisibility[message.visibility] === undefined ? message.visibility : $root.google.protobuf.SymbolVisibility[message.visibility] : message.visibility; return object; }; @@ -70446,6 +71450,7 @@ * @property {Array.|null} [targets] FieldOptions targets * @property {Array.|null} [editionDefaults] FieldOptions editionDefaults * @property {google.protobuf.IFeatureSet|null} [features] FieldOptions features + * @property {google.protobuf.FieldOptions.IFeatureSupport|null} [featureSupport] FieldOptions featureSupport * @property {Array.|null} [uninterpretedOption] FieldOptions uninterpretedOption * @property {Array.|null} [".google.api.fieldBehavior"] FieldOptions .google.api.fieldBehavior * @property {google.api.IFieldInfo|null} [".google.api.fieldInfo"] FieldOptions .google.api.fieldInfo @@ -70567,6 +71572,14 @@ */ FieldOptions.prototype.features = null; + /** + * FieldOptions featureSupport. + * @member {google.protobuf.FieldOptions.IFeatureSupport|null|undefined} featureSupport + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.featureSupport = null; + /** * FieldOptions uninterpretedOption. * @member {Array.} uninterpretedOption @@ -70649,6 +71662,8 @@ $root.google.protobuf.FieldOptions.EditionDefault.encode(message.editionDefaults[i], writer.uint32(/* id 20, wireType 2 =*/162).fork()).ldelim(); if (message.features != null && Object.hasOwnProperty.call(message, "features")) $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 21, wireType 2 =*/170).fork()).ldelim(); + if (message.featureSupport != null && Object.hasOwnProperty.call(message, "featureSupport")) + $root.google.protobuf.FieldOptions.FeatureSupport.encode(message.featureSupport, writer.uint32(/* id 22, wireType 2 =*/178).fork()).ldelim(); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); @@ -70752,6 +71767,10 @@ message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); break; } + case 22: { + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.decode(reader, reader.uint32()); + break; + } case 999: { if (!(message.uninterpretedOption && message.uninterpretedOption.length)) message.uninterpretedOption = []; @@ -70891,6 +71910,11 @@ if (error) return "features." + error; } + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) { + var error = $root.google.protobuf.FieldOptions.FeatureSupport.verify(message.featureSupport); + if (error) + return "featureSupport." + error; + } if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { if (!Array.isArray(message.uninterpretedOption)) return "uninterpretedOption: array expected"; @@ -71084,6 +72108,11 @@ throw TypeError(".google.protobuf.FieldOptions.features: object expected"); message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); } + if (object.featureSupport != null) { + if (typeof object.featureSupport !== "object") + throw TypeError(".google.protobuf.FieldOptions.featureSupport: object expected"); + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.fromObject(object.featureSupport); + } if (object.uninterpretedOption) { if (!Array.isArray(object.uninterpretedOption)) throw TypeError(".google.protobuf.FieldOptions.uninterpretedOption: array expected"); @@ -71186,6 +72215,7 @@ object.debugRedact = false; object.retention = options.enums === String ? "RETENTION_UNKNOWN" : 0; object.features = null; + object.featureSupport = null; object[".google.api.resourceReference"] = null; object[".google.api.fieldInfo"] = null; } @@ -71219,6 +72249,8 @@ } if (message.features != null && message.hasOwnProperty("features")) object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) + object.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.toObject(message.featureSupport, options); if (message.uninterpretedOption && message.uninterpretedOption.length) { object.uninterpretedOption = []; for (var j = 0; j < message.uninterpretedOption.length; ++j) @@ -71493,6 +72525,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -71534,103 +72567,589 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; + case "EDITION_PROTO2": + case 998: + message.edition = 998; + break; + case "EDITION_PROTO3": + case 999: + message.edition = 999; + break; + case "EDITION_2023": + case 1000: + message.edition = 1000; + break; + case "EDITION_2024": + case 1001: + message.edition = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.edition = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.edition = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.edition = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.edition = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.edition = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.edition = 2147483647; + break; + } + if (object.value != null) + message.value = String(object.value); + return message; + }; + + /** + * Creates a plain object from an EditionDefault message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {google.protobuf.FieldOptions.EditionDefault} message EditionDefault + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EditionDefault.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.value = ""; + object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + } + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + if (message.edition != null && message.hasOwnProperty("edition")) + object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + return object; + }; + + /** + * Converts this EditionDefault to JSON. + * @function toJSON + * @memberof google.protobuf.FieldOptions.EditionDefault + * @instance + * @returns {Object.} JSON object + */ + EditionDefault.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for EditionDefault + * @function getTypeUrl + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + EditionDefault.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FieldOptions.EditionDefault"; + }; + + return EditionDefault; + })(); + + FieldOptions.FeatureSupport = (function() { + + /** + * Properties of a FeatureSupport. + * @memberof google.protobuf.FieldOptions + * @interface IFeatureSupport + * @property {google.protobuf.Edition|null} [editionIntroduced] FeatureSupport editionIntroduced + * @property {google.protobuf.Edition|null} [editionDeprecated] FeatureSupport editionDeprecated + * @property {string|null} [deprecationWarning] FeatureSupport deprecationWarning + * @property {google.protobuf.Edition|null} [editionRemoved] FeatureSupport editionRemoved + */ + + /** + * Constructs a new FeatureSupport. + * @memberof google.protobuf.FieldOptions + * @classdesc Represents a FeatureSupport. + * @implements IFeatureSupport + * @constructor + * @param {google.protobuf.FieldOptions.IFeatureSupport=} [properties] Properties to set + */ + function FeatureSupport(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]]; + } + + /** + * FeatureSupport editionIntroduced. + * @member {google.protobuf.Edition} editionIntroduced + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionIntroduced = 0; + + /** + * FeatureSupport editionDeprecated. + * @member {google.protobuf.Edition} editionDeprecated + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionDeprecated = 0; + + /** + * FeatureSupport deprecationWarning. + * @member {string} deprecationWarning + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.deprecationWarning = ""; + + /** + * FeatureSupport editionRemoved. + * @member {google.protobuf.Edition} editionRemoved + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionRemoved = 0; + + /** + * Creates a new FeatureSupport instance using the specified properties. + * @function create + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport=} [properties] Properties to set + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport instance + */ + FeatureSupport.create = function create(properties) { + return new FeatureSupport(properties); + }; + + /** + * Encodes the specified FeatureSupport message. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport} message FeatureSupport message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSupport.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.editionIntroduced != null && Object.hasOwnProperty.call(message, "editionIntroduced")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.editionIntroduced); + if (message.editionDeprecated != null && Object.hasOwnProperty.call(message, "editionDeprecated")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.editionDeprecated); + if (message.deprecationWarning != null && Object.hasOwnProperty.call(message, "deprecationWarning")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.deprecationWarning); + if (message.editionRemoved != null && Object.hasOwnProperty.call(message, "editionRemoved")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.editionRemoved); + return writer; + }; + + /** + * Encodes the specified FeatureSupport message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport} message FeatureSupport message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSupport.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSupport.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FieldOptions.FeatureSupport(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.editionIntroduced = reader.int32(); + break; + } + case 2: { + message.editionDeprecated = reader.int32(); + break; + } + case 3: { + message.deprecationWarning = reader.string(); + break; + } + case 4: { + message.editionRemoved = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSupport.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FeatureSupport message. + * @function verify + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FeatureSupport.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.editionIntroduced != null && message.hasOwnProperty("editionIntroduced")) + switch (message.editionIntroduced) { + default: + return "editionIntroduced: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + if (message.editionDeprecated != null && message.hasOwnProperty("editionDeprecated")) + switch (message.editionDeprecated) { + default: + return "editionDeprecated: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + if (message.deprecationWarning != null && message.hasOwnProperty("deprecationWarning")) + if (!$util.isString(message.deprecationWarning)) + return "deprecationWarning: string expected"; + if (message.editionRemoved != null && message.hasOwnProperty("editionRemoved")) + switch (message.editionRemoved) { + default: + return "editionRemoved: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + return null; + }; + + /** + * Creates a FeatureSupport message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + */ + FeatureSupport.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FieldOptions.FeatureSupport) + return object; + var message = new $root.google.protobuf.FieldOptions.FeatureSupport(); + switch (object.editionIntroduced) { + default: + if (typeof object.editionIntroduced === "number") { + message.editionIntroduced = object.editionIntroduced; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionIntroduced = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionIntroduced = 900; + break; + case "EDITION_PROTO2": + case 998: + message.editionIntroduced = 998; + break; + case "EDITION_PROTO3": + case 999: + message.editionIntroduced = 999; + break; + case "EDITION_2023": + case 1000: + message.editionIntroduced = 1000; + break; + case "EDITION_2024": + case 1001: + message.editionIntroduced = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.editionIntroduced = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.editionIntroduced = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.editionIntroduced = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.editionIntroduced = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.editionIntroduced = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.editionIntroduced = 2147483647; + break; + } + switch (object.editionDeprecated) { + default: + if (typeof object.editionDeprecated === "number") { + message.editionDeprecated = object.editionDeprecated; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionDeprecated = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionDeprecated = 900; + break; + case "EDITION_PROTO2": + case 998: + message.editionDeprecated = 998; + break; + case "EDITION_PROTO3": + case 999: + message.editionDeprecated = 999; + break; + case "EDITION_2023": + case 1000: + message.editionDeprecated = 1000; + break; + case "EDITION_2024": + case 1001: + message.editionDeprecated = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.editionDeprecated = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.editionDeprecated = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.editionDeprecated = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.editionDeprecated = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.editionDeprecated = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.editionDeprecated = 2147483647; + break; + } + if (object.deprecationWarning != null) + message.deprecationWarning = String(object.deprecationWarning); + switch (object.editionRemoved) { + default: + if (typeof object.editionRemoved === "number") { + message.editionRemoved = object.editionRemoved; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionRemoved = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionRemoved = 900; + break; case "EDITION_PROTO2": case 998: - message.edition = 998; + message.editionRemoved = 998; break; case "EDITION_PROTO3": case 999: - message.edition = 999; + message.editionRemoved = 999; break; case "EDITION_2023": case 1000: - message.edition = 1000; + message.editionRemoved = 1000; break; case "EDITION_2024": case 1001: - message.edition = 1001; + message.editionRemoved = 1001; break; case "EDITION_1_TEST_ONLY": case 1: - message.edition = 1; + message.editionRemoved = 1; break; case "EDITION_2_TEST_ONLY": case 2: - message.edition = 2; + message.editionRemoved = 2; break; case "EDITION_99997_TEST_ONLY": case 99997: - message.edition = 99997; + message.editionRemoved = 99997; break; case "EDITION_99998_TEST_ONLY": case 99998: - message.edition = 99998; + message.editionRemoved = 99998; break; case "EDITION_99999_TEST_ONLY": case 99999: - message.edition = 99999; + message.editionRemoved = 99999; break; case "EDITION_MAX": case 2147483647: - message.edition = 2147483647; + message.editionRemoved = 2147483647; break; } - if (object.value != null) - message.value = String(object.value); return message; }; /** - * Creates a plain object from an EditionDefault message. Also converts values to other types if specified. + * Creates a plain object from a FeatureSupport message. Also converts values to other types if specified. * @function toObject - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @static - * @param {google.protobuf.FieldOptions.EditionDefault} message EditionDefault + * @param {google.protobuf.FieldOptions.FeatureSupport} message FeatureSupport * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - EditionDefault.toObject = function toObject(message, options) { + FeatureSupport.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { - object.value = ""; - object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.editionIntroduced = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.editionDeprecated = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.deprecationWarning = ""; + object.editionRemoved = options.enums === String ? "EDITION_UNKNOWN" : 0; } - if (message.value != null && message.hasOwnProperty("value")) - object.value = message.value; - if (message.edition != null && message.hasOwnProperty("edition")) - object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.editionIntroduced != null && message.hasOwnProperty("editionIntroduced")) + object.editionIntroduced = options.enums === String ? $root.google.protobuf.Edition[message.editionIntroduced] === undefined ? message.editionIntroduced : $root.google.protobuf.Edition[message.editionIntroduced] : message.editionIntroduced; + if (message.editionDeprecated != null && message.hasOwnProperty("editionDeprecated")) + object.editionDeprecated = options.enums === String ? $root.google.protobuf.Edition[message.editionDeprecated] === undefined ? message.editionDeprecated : $root.google.protobuf.Edition[message.editionDeprecated] : message.editionDeprecated; + if (message.deprecationWarning != null && message.hasOwnProperty("deprecationWarning")) + object.deprecationWarning = message.deprecationWarning; + if (message.editionRemoved != null && message.hasOwnProperty("editionRemoved")) + object.editionRemoved = options.enums === String ? $root.google.protobuf.Edition[message.editionRemoved] === undefined ? message.editionRemoved : $root.google.protobuf.Edition[message.editionRemoved] : message.editionRemoved; return object; }; /** - * Converts this EditionDefault to JSON. + * Converts this FeatureSupport to JSON. * @function toJSON - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @instance * @returns {Object.} JSON object */ - EditionDefault.prototype.toJSON = function toJSON() { + FeatureSupport.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for EditionDefault + * Gets the default type url for FeatureSupport * @function getTypeUrl - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - EditionDefault.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + FeatureSupport.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.protobuf.FieldOptions.EditionDefault"; + return typeUrlPrefix + "/google.protobuf.FieldOptions.FeatureSupport"; }; - return EditionDefault; + return FeatureSupport; })(); return FieldOptions; @@ -72225,6 +73744,7 @@ * @property {boolean|null} [deprecated] EnumValueOptions deprecated * @property {google.protobuf.IFeatureSet|null} [features] EnumValueOptions features * @property {boolean|null} [debugRedact] EnumValueOptions debugRedact + * @property {google.protobuf.FieldOptions.IFeatureSupport|null} [featureSupport] EnumValueOptions featureSupport * @property {Array.|null} [uninterpretedOption] EnumValueOptions uninterpretedOption */ @@ -72268,6 +73788,14 @@ */ EnumValueOptions.prototype.debugRedact = false; + /** + * EnumValueOptions featureSupport. + * @member {google.protobuf.FieldOptions.IFeatureSupport|null|undefined} featureSupport + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.featureSupport = null; + /** * EnumValueOptions uninterpretedOption. * @member {Array.} uninterpretedOption @@ -72306,6 +73834,8 @@ $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.debugRedact != null && Object.hasOwnProperty.call(message, "debugRedact")) writer.uint32(/* id 3, wireType 0 =*/24).bool(message.debugRedact); + if (message.featureSupport != null && Object.hasOwnProperty.call(message, "featureSupport")) + $root.google.protobuf.FieldOptions.FeatureSupport.encode(message.featureSupport, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); @@ -72357,6 +73887,10 @@ message.debugRedact = reader.bool(); break; } + case 4: { + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.decode(reader, reader.uint32()); + break; + } case 999: { if (!(message.uninterpretedOption && message.uninterpretedOption.length)) message.uninterpretedOption = []; @@ -72409,6 +73943,11 @@ if (message.debugRedact != null && message.hasOwnProperty("debugRedact")) if (typeof message.debugRedact !== "boolean") return "debugRedact: boolean expected"; + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) { + var error = $root.google.protobuf.FieldOptions.FeatureSupport.verify(message.featureSupport); + if (error) + return "featureSupport." + error; + } if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { if (!Array.isArray(message.uninterpretedOption)) return "uninterpretedOption: array expected"; @@ -72442,6 +73981,11 @@ } if (object.debugRedact != null) message.debugRedact = Boolean(object.debugRedact); + if (object.featureSupport != null) { + if (typeof object.featureSupport !== "object") + throw TypeError(".google.protobuf.EnumValueOptions.featureSupport: object expected"); + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.fromObject(object.featureSupport); + } if (object.uninterpretedOption) { if (!Array.isArray(object.uninterpretedOption)) throw TypeError(".google.protobuf.EnumValueOptions.uninterpretedOption: array expected"); @@ -72474,6 +74018,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -72481,6 +74026,8 @@ object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); if (message.debugRedact != null && message.hasOwnProperty("debugRedact")) object.debugRedact = message.debugRedact; + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) + object.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.toObject(message.featureSupport, options); if (message.uninterpretedOption && message.uninterpretedOption.length) { object.uninterpretedOption = []; for (var j = 0; j < message.uninterpretedOption.length; ++j) @@ -73948,6 +75495,8 @@ * @property {google.protobuf.FeatureSet.Utf8Validation|null} [utf8Validation] FeatureSet utf8Validation * @property {google.protobuf.FeatureSet.MessageEncoding|null} [messageEncoding] FeatureSet messageEncoding * @property {google.protobuf.FeatureSet.JsonFormat|null} [jsonFormat] FeatureSet jsonFormat + * @property {google.protobuf.FeatureSet.EnforceNamingStyle|null} [enforceNamingStyle] FeatureSet enforceNamingStyle + * @property {google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|null} [defaultSymbolVisibility] FeatureSet defaultSymbolVisibility */ /** @@ -74013,6 +75562,22 @@ */ FeatureSet.prototype.jsonFormat = 0; + /** + * FeatureSet enforceNamingStyle. + * @member {google.protobuf.FeatureSet.EnforceNamingStyle} enforceNamingStyle + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.enforceNamingStyle = 0; + + /** + * FeatureSet defaultSymbolVisibility. + * @member {google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility} defaultSymbolVisibility + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.defaultSymbolVisibility = 0; + /** * Creates a new FeatureSet instance using the specified properties. * @function create @@ -74049,6 +75614,10 @@ writer.uint32(/* id 5, wireType 0 =*/40).int32(message.messageEncoding); if (message.jsonFormat != null && Object.hasOwnProperty.call(message, "jsonFormat")) writer.uint32(/* id 6, wireType 0 =*/48).int32(message.jsonFormat); + if (message.enforceNamingStyle != null && Object.hasOwnProperty.call(message, "enforceNamingStyle")) + writer.uint32(/* id 7, wireType 0 =*/56).int32(message.enforceNamingStyle); + if (message.defaultSymbolVisibility != null && Object.hasOwnProperty.call(message, "defaultSymbolVisibility")) + writer.uint32(/* id 8, wireType 0 =*/64).int32(message.defaultSymbolVisibility); return writer; }; @@ -74109,6 +75678,14 @@ message.jsonFormat = reader.int32(); break; } + case 7: { + message.enforceNamingStyle = reader.int32(); + break; + } + case 8: { + message.defaultSymbolVisibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -74199,6 +75776,26 @@ case 2: break; } + if (message.enforceNamingStyle != null && message.hasOwnProperty("enforceNamingStyle")) + switch (message.enforceNamingStyle) { + default: + return "enforceNamingStyle: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.defaultSymbolVisibility != null && message.hasOwnProperty("defaultSymbolVisibility")) + switch (message.defaultSymbolVisibility) { + default: + return "defaultSymbolVisibility: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } return null; }; @@ -74338,6 +75935,54 @@ message.jsonFormat = 2; break; } + switch (object.enforceNamingStyle) { + default: + if (typeof object.enforceNamingStyle === "number") { + message.enforceNamingStyle = object.enforceNamingStyle; + break; + } + break; + case "ENFORCE_NAMING_STYLE_UNKNOWN": + case 0: + message.enforceNamingStyle = 0; + break; + case "STYLE2024": + case 1: + message.enforceNamingStyle = 1; + break; + case "STYLE_LEGACY": + case 2: + message.enforceNamingStyle = 2; + break; + } + switch (object.defaultSymbolVisibility) { + default: + if (typeof object.defaultSymbolVisibility === "number") { + message.defaultSymbolVisibility = object.defaultSymbolVisibility; + break; + } + break; + case "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN": + case 0: + message.defaultSymbolVisibility = 0; + break; + case "EXPORT_ALL": + case 1: + message.defaultSymbolVisibility = 1; + break; + case "EXPORT_TOP_LEVEL": + case 2: + message.defaultSymbolVisibility = 2; + break; + case "LOCAL_ALL": + case 3: + message.defaultSymbolVisibility = 3; + break; + case "STRICT": + case 4: + message.defaultSymbolVisibility = 4; + break; + } return message; }; @@ -74361,6 +76006,8 @@ object.utf8Validation = options.enums === String ? "UTF8_VALIDATION_UNKNOWN" : 0; object.messageEncoding = options.enums === String ? "MESSAGE_ENCODING_UNKNOWN" : 0; object.jsonFormat = options.enums === String ? "JSON_FORMAT_UNKNOWN" : 0; + object.enforceNamingStyle = options.enums === String ? "ENFORCE_NAMING_STYLE_UNKNOWN" : 0; + object.defaultSymbolVisibility = options.enums === String ? "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN" : 0; } if (message.fieldPresence != null && message.hasOwnProperty("fieldPresence")) object.fieldPresence = options.enums === String ? $root.google.protobuf.FeatureSet.FieldPresence[message.fieldPresence] === undefined ? message.fieldPresence : $root.google.protobuf.FeatureSet.FieldPresence[message.fieldPresence] : message.fieldPresence; @@ -74374,6 +76021,10 @@ object.messageEncoding = options.enums === String ? $root.google.protobuf.FeatureSet.MessageEncoding[message.messageEncoding] === undefined ? message.messageEncoding : $root.google.protobuf.FeatureSet.MessageEncoding[message.messageEncoding] : message.messageEncoding; if (message.jsonFormat != null && message.hasOwnProperty("jsonFormat")) object.jsonFormat = options.enums === String ? $root.google.protobuf.FeatureSet.JsonFormat[message.jsonFormat] === undefined ? message.jsonFormat : $root.google.protobuf.FeatureSet.JsonFormat[message.jsonFormat] : message.jsonFormat; + if (message.enforceNamingStyle != null && message.hasOwnProperty("enforceNamingStyle")) + object.enforceNamingStyle = options.enums === String ? $root.google.protobuf.FeatureSet.EnforceNamingStyle[message.enforceNamingStyle] === undefined ? message.enforceNamingStyle : $root.google.protobuf.FeatureSet.EnforceNamingStyle[message.enforceNamingStyle] : message.enforceNamingStyle; + if (message.defaultSymbolVisibility != null && message.hasOwnProperty("defaultSymbolVisibility")) + object.defaultSymbolVisibility = options.enums === String ? $root.google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility[message.defaultSymbolVisibility] === undefined ? message.defaultSymbolVisibility : $root.google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility[message.defaultSymbolVisibility] : message.defaultSymbolVisibility; return object; }; @@ -74501,6 +76152,219 @@ return values; })(); + /** + * EnforceNamingStyle enum. + * @name google.protobuf.FeatureSet.EnforceNamingStyle + * @enum {number} + * @property {number} ENFORCE_NAMING_STYLE_UNKNOWN=0 ENFORCE_NAMING_STYLE_UNKNOWN value + * @property {number} STYLE2024=1 STYLE2024 value + * @property {number} STYLE_LEGACY=2 STYLE_LEGACY value + */ + FeatureSet.EnforceNamingStyle = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "ENFORCE_NAMING_STYLE_UNKNOWN"] = 0; + values[valuesById[1] = "STYLE2024"] = 1; + values[valuesById[2] = "STYLE_LEGACY"] = 2; + return values; + })(); + + FeatureSet.VisibilityFeature = (function() { + + /** + * Properties of a VisibilityFeature. + * @memberof google.protobuf.FeatureSet + * @interface IVisibilityFeature + */ + + /** + * Constructs a new VisibilityFeature. + * @memberof google.protobuf.FeatureSet + * @classdesc Represents a VisibilityFeature. + * @implements IVisibilityFeature + * @constructor + * @param {google.protobuf.FeatureSet.IVisibilityFeature=} [properties] Properties to set + */ + function VisibilityFeature(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]]; + } + + /** + * Creates a new VisibilityFeature instance using the specified properties. + * @function create + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature=} [properties] Properties to set + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature instance + */ + VisibilityFeature.create = function create(properties) { + return new VisibilityFeature(properties); + }; + + /** + * Encodes the specified VisibilityFeature message. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature} message VisibilityFeature message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VisibilityFeature.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified VisibilityFeature message, length delimited. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature} message VisibilityFeature message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VisibilityFeature.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VisibilityFeature.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FeatureSet.VisibilityFeature(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VisibilityFeature.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a VisibilityFeature message. + * @function verify + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + VisibilityFeature.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a VisibilityFeature message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + */ + VisibilityFeature.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FeatureSet.VisibilityFeature) + return object; + return new $root.google.protobuf.FeatureSet.VisibilityFeature(); + }; + + /** + * Creates a plain object from a VisibilityFeature message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.VisibilityFeature} message VisibilityFeature + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + VisibilityFeature.toObject = function toObject() { + return {}; + }; + + /** + * Converts this VisibilityFeature to JSON. + * @function toJSON + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @instance + * @returns {Object.} JSON object + */ + VisibilityFeature.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for VisibilityFeature + * @function getTypeUrl + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + VisibilityFeature.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FeatureSet.VisibilityFeature"; + }; + + /** + * DefaultSymbolVisibility enum. + * @name google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility + * @enum {number} + * @property {number} DEFAULT_SYMBOL_VISIBILITY_UNKNOWN=0 DEFAULT_SYMBOL_VISIBILITY_UNKNOWN value + * @property {number} EXPORT_ALL=1 EXPORT_ALL value + * @property {number} EXPORT_TOP_LEVEL=2 EXPORT_TOP_LEVEL value + * @property {number} LOCAL_ALL=3 LOCAL_ALL value + * @property {number} STRICT=4 STRICT value + */ + VisibilityFeature.DefaultSymbolVisibility = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN"] = 0; + values[valuesById[1] = "EXPORT_ALL"] = 1; + values[valuesById[2] = "EXPORT_TOP_LEVEL"] = 2; + values[valuesById[3] = "LOCAL_ALL"] = 3; + values[valuesById[4] = "STRICT"] = 4; + return values; + })(); + + return VisibilityFeature; + })(); + return FeatureSet; })(); @@ -74685,6 +76549,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -74702,6 +76567,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -74750,6 +76616,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -74802,6 +76672,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -74910,7 +76784,8 @@ * @memberof google.protobuf.FeatureSetDefaults * @interface IFeatureSetEditionDefault * @property {google.protobuf.Edition|null} [edition] FeatureSetEditionDefault edition - * @property {google.protobuf.IFeatureSet|null} [features] FeatureSetEditionDefault features + * @property {google.protobuf.IFeatureSet|null} [overridableFeatures] FeatureSetEditionDefault overridableFeatures + * @property {google.protobuf.IFeatureSet|null} [fixedFeatures] FeatureSetEditionDefault fixedFeatures */ /** @@ -74937,12 +76812,20 @@ FeatureSetEditionDefault.prototype.edition = 0; /** - * FeatureSetEditionDefault features. - * @member {google.protobuf.IFeatureSet|null|undefined} features + * FeatureSetEditionDefault overridableFeatures. + * @member {google.protobuf.IFeatureSet|null|undefined} overridableFeatures + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @instance + */ + FeatureSetEditionDefault.prototype.overridableFeatures = null; + + /** + * FeatureSetEditionDefault fixedFeatures. + * @member {google.protobuf.IFeatureSet|null|undefined} fixedFeatures * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault * @instance */ - FeatureSetEditionDefault.prototype.features = null; + FeatureSetEditionDefault.prototype.fixedFeatures = null; /** * Creates a new FeatureSetEditionDefault instance using the specified properties. @@ -74968,10 +76851,12 @@ FeatureSetEditionDefault.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.features != null && Object.hasOwnProperty.call(message, "features")) - $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) writer.uint32(/* id 3, wireType 0 =*/24).int32(message.edition); + if (message.overridableFeatures != null && Object.hasOwnProperty.call(message, "overridableFeatures")) + $root.google.protobuf.FeatureSet.encode(message.overridableFeatures, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.fixedFeatures != null && Object.hasOwnProperty.call(message, "fixedFeatures")) + $root.google.protobuf.FeatureSet.encode(message.fixedFeatures, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); return writer; }; @@ -75012,8 +76897,12 @@ message.edition = reader.int32(); break; } - case 2: { - message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + case 4: { + message.overridableFeatures = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + break; + } + case 5: { + message.fixedFeatures = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); break; } default: @@ -75056,6 +76945,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -75068,10 +76958,15 @@ case 2147483647: break; } - if (message.features != null && message.hasOwnProperty("features")) { - var error = $root.google.protobuf.FeatureSet.verify(message.features); + if (message.overridableFeatures != null && message.hasOwnProperty("overridableFeatures")) { + var error = $root.google.protobuf.FeatureSet.verify(message.overridableFeatures); + if (error) + return "overridableFeatures." + error; + } + if (message.fixedFeatures != null && message.hasOwnProperty("fixedFeatures")) { + var error = $root.google.protobuf.FeatureSet.verify(message.fixedFeatures); if (error) - return "features." + error; + return "fixedFeatures." + error; } return null; }; @@ -75099,6 +76994,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -75140,10 +77039,15 @@ message.edition = 2147483647; break; } - if (object.features != null) { - if (typeof object.features !== "object") - throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.features: object expected"); - message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); + if (object.overridableFeatures != null) { + if (typeof object.overridableFeatures !== "object") + throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.overridableFeatures: object expected"); + message.overridableFeatures = $root.google.protobuf.FeatureSet.fromObject(object.overridableFeatures); + } + if (object.fixedFeatures != null) { + if (typeof object.fixedFeatures !== "object") + throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.fixedFeatures: object expected"); + message.fixedFeatures = $root.google.protobuf.FeatureSet.fromObject(object.fixedFeatures); } return message; }; @@ -75162,13 +77066,16 @@ options = {}; var object = {}; if (options.defaults) { - object.features = null; object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.overridableFeatures = null; + object.fixedFeatures = null; } - if (message.features != null && message.hasOwnProperty("features")) - object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); if (message.edition != null && message.hasOwnProperty("edition")) object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.overridableFeatures != null && message.hasOwnProperty("overridableFeatures")) + object.overridableFeatures = $root.google.protobuf.FeatureSet.toObject(message.overridableFeatures, options); + if (message.fixedFeatures != null && message.hasOwnProperty("fixedFeatures")) + object.fixedFeatures = $root.google.protobuf.FeatureSet.toObject(message.fixedFeatures, options); return object; }; @@ -76383,6 +78290,22 @@ return GeneratedCodeInfo; })(); + /** + * SymbolVisibility enum. + * @name google.protobuf.SymbolVisibility + * @enum {number} + * @property {number} VISIBILITY_UNSET=0 VISIBILITY_UNSET value + * @property {number} VISIBILITY_LOCAL=1 VISIBILITY_LOCAL value + * @property {number} VISIBILITY_EXPORT=2 VISIBILITY_EXPORT value + */ + protobuf.SymbolVisibility = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "VISIBILITY_UNSET"] = 0; + values[valuesById[1] = "VISIBILITY_LOCAL"] = 1; + values[valuesById[2] = "VISIBILITY_EXPORT"] = 2; + return values; + })(); + protobuf.Timestamp = (function() { /** diff --git a/packages/google-cloud-networkservices/protos/protos.json b/packages/google-cloud-networkservices/protos/protos.json index f303794d39c5..ef6ebd26228c 100644 --- a/packages/google-cloud-networkservices/protos/protos.json +++ b/packages/google-cloud-networkservices/protos/protos.json @@ -7787,8 +7787,7 @@ "java_multiple_files": true, "java_outer_classname": "ResourceProto", "java_package": "com.google.api", - "objc_class_prefix": "GAPI", - "cc_enable_arenas": true + "objc_class_prefix": "GAPI" }, "nested": { "fieldBehavior": { @@ -7934,6 +7933,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -8074,6 +8077,28 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "experimentalFeatures": { + "type": "ExperimentalFeatures", + "id": 2 + } + }, + "nested": { + "ExperimentalFeatures": { + "fields": { + "restAsyncIoEnabled": { + "type": "bool", + "id": 1 + }, + "protobufPythonicTypesEnabled": { + "type": "bool", + "id": 2 + }, + "unversionedPackageDisabled": { + "type": "bool", + "id": 3 + } + } } } }, @@ -8131,6 +8156,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -8192,6 +8222,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -8214,6 +8257,11 @@ "format": { "type": "Format", "id": 1 + }, + "referencedTypes": { + "rule": "repeated", + "type": "TypeReference", + "id": 2 } }, "nested": { @@ -8228,6 +8276,14 @@ } } }, + "TypeReference": { + "fields": { + "typeName": { + "type": "string", + "id": 1 + } + } + }, "resourceReference": { "type": "google.api.ResourceReference", "id": 1055, @@ -8326,12 +8382,19 @@ "type": "FileDescriptorProto", "id": 1 } - } + }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ] }, "Edition": { "edition": "proto2", "values": { "EDITION_UNKNOWN": 0, + "EDITION_LEGACY": 900, "EDITION_PROTO2": 998, "EDITION_PROTO3": 999, "EDITION_2023": 1000, @@ -8370,6 +8433,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -8458,6 +8526,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -8683,6 +8755,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -8733,7 +8809,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -8897,6 +8980,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -9032,7 +9116,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -9060,6 +9145,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -9129,6 +9218,26 @@ "id": 2 } } + }, + "FeatureSupport": { + "fields": { + "editionIntroduced": { + "type": "Edition", + "id": 1 + }, + "editionDeprecated": { + "type": "Edition", + "id": 2 + }, + "deprecationWarning": { + "type": "string", + "id": 3 + }, + "editionRemoved": { + "type": "Edition", + "id": 4 + } + } } } }, @@ -9217,6 +9326,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -9359,6 +9472,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -9369,6 +9483,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -9379,6 +9494,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -9389,6 +9505,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -9399,7 +9516,8 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", - "edition_defaults.edition": "EDITION_PROTO2", + "feature_support.edition_introduced": "EDITION_2023", + "edition_defaults.edition": "EDITION_LEGACY", "edition_defaults.value": "LENGTH_PREFIXED" } }, @@ -9409,27 +9527,38 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "ALLOW" } + }, + "enforceNamingStyle": { + "type": "EnforceNamingStyle", + "id": 7, + "options": { + "retention": "RETENTION_SOURCE", + "targets": "TARGET_TYPE_METHOD", + "feature_support.edition_introduced": "EDITION_2024", + "edition_defaults.edition": "EDITION_2024", + "edition_defaults.value": "STYLE2024" + } + }, + "defaultSymbolVisibility": { + "type": "VisibilityFeature.DefaultSymbolVisibility", + "id": 8, + "options": { + "retention": "RETENTION_SOURCE", + "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2024", + "edition_defaults.edition": "EDITION_2024", + "edition_defaults.value": "EXPORT_TOP_LEVEL" + } } }, "extensions": [ [ 1000, - 1000 - ], - [ - 1001, - 1001 - ], - [ - 1002, - 1002 - ], - [ - 9990, - 9990 + 9994 ], [ 9995, @@ -9474,7 +9603,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -9489,6 +9624,33 @@ "ALLOW": 1, "LEGACY_BEST_EFFORT": 2 } + }, + "EnforceNamingStyle": { + "values": { + "ENFORCE_NAMING_STYLE_UNKNOWN": 0, + "STYLE2024": 1, + "STYLE_LEGACY": 2 + } + }, + "VisibilityFeature": { + "fields": {}, + "reserved": [ + [ + 1, + 536870911 + ] + ], + "nested": { + "DefaultSymbolVisibility": { + "values": { + "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN": 0, + "EXPORT_ALL": 1, + "EXPORT_TOP_LEVEL": 2, + "LOCAL_ALL": 3, + "STRICT": 4 + } + } + } } } }, @@ -9516,11 +9678,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -9533,6 +9710,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -9618,6 +9801,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Timestamp": { "fields": { "seconds": { @@ -9739,6 +9930,7 @@ "java_multiple_files": true, "java_outer_classname": "OperationsProto", "java_package": "com.google.longrunning", + "objc_class_prefix": "GLRUN", "php_namespace": "Google\\LongRunning" }, "nested": { diff --git a/packages/google-cloud-networkservices/samples/generated/v1/snippet_metadata_google.cloud.networkservices.v1.json b/packages/google-cloud-networkservices/samples/generated/v1/snippet_metadata_google.cloud.networkservices.v1.json index 293ee8328f45..603c9e345259 100644 --- a/packages/google-cloud-networkservices/samples/generated/v1/snippet_metadata_google.cloud.networkservices.v1.json +++ b/packages/google-cloud-networkservices/samples/generated/v1/snippet_metadata_google.cloud.networkservices.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-networkservices", - "version": "0.12.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-networkservices/samples/generated/v1beta1/snippet_metadata_google.cloud.networkservices.v1beta1.json b/packages/google-cloud-networkservices/samples/generated/v1beta1/snippet_metadata_google.cloud.networkservices.v1beta1.json index d106a9d23b06..eea63b00d6a3 100644 --- a/packages/google-cloud-networkservices/samples/generated/v1beta1/snippet_metadata_google.cloud.networkservices.v1beta1.json +++ b/packages/google-cloud-networkservices/samples/generated/v1beta1/snippet_metadata_google.cloud.networkservices.v1beta1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-networkservices", - "version": "0.12.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-networkservices/src/v1/dep_service_client.ts b/packages/google-cloud-networkservices/src/v1/dep_service_client.ts index 9a418265a2ef..deeb367133d3 100644 --- a/packages/google-cloud-networkservices/src/v1/dep_service_client.ts +++ b/packages/google-cloud-networkservices/src/v1/dep_service_client.ts @@ -18,11 +18,24 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -44,7 +57,7 @@ export class DepServiceClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('networkservices'); @@ -57,12 +70,12 @@ export class DepServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - depServiceStub?: Promise<{[name: string]: Function}>; + depServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of DepServiceClient. @@ -103,21 +116,42 @@ export class DepServiceClient { * const client = new DepServiceClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof DepServiceClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'networkservices.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -142,7 +176,7 @@ export class DepServiceClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -155,18 +189,14 @@ export class DepServiceClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -188,61 +218,61 @@ export class DepServiceClient { // Create useful helper objects for these. this.pathTemplates = { authzExtensionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/authzExtensions/{authz_extension}' + 'projects/{project}/locations/{location}/authzExtensions/{authz_extension}', ), endpointPolicyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/endpointPolicies/{endpoint_policy}' + 'projects/{project}/locations/{location}/endpointPolicies/{endpoint_policy}', ), gatewayPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/gateways/{gateway}' + 'projects/{project}/locations/{location}/gateways/{gateway}', ), gatewayRouteViewPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/gateways/{gateway}/routeViews/{route_view}' + 'projects/{project}/locations/{location}/gateways/{gateway}/routeViews/{route_view}', ), grpcRoutePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/grpcRoutes/{grpc_route}' + 'projects/{project}/locations/{location}/grpcRoutes/{grpc_route}', ), httpRoutePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/httpRoutes/{http_route}' + 'projects/{project}/locations/{location}/httpRoutes/{http_route}', ), lbEdgeExtensionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/lbEdgeExtensions/{lb_edge_extension}' + 'projects/{project}/locations/{location}/lbEdgeExtensions/{lb_edge_extension}', ), lbRouteExtensionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/lbRouteExtensions/{lb_route_extension}' + 'projects/{project}/locations/{location}/lbRouteExtensions/{lb_route_extension}', ), lbTrafficExtensionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/lbTrafficExtensions/{lb_traffic_extension}' + 'projects/{project}/locations/{location}/lbTrafficExtensions/{lb_traffic_extension}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), meshPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/meshes/{mesh}' + 'projects/{project}/locations/{location}/meshes/{mesh}', ), meshRouteViewPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/meshes/{mesh}/routeViews/{route_view}' + 'projects/{project}/locations/{location}/meshes/{mesh}/routeViews/{route_view}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), serviceBindingPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/serviceBindings/{service_binding}' + 'projects/{project}/locations/{location}/serviceBindings/{service_binding}', ), serviceLbPolicyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/serviceLbPolicies/{service_lb_policy}' + 'projects/{project}/locations/{location}/serviceLbPolicies/{service_lb_policy}', ), tcpRoutePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/tcpRoutes/{tcp_route}' + 'projects/{project}/locations/{location}/tcpRoutes/{tcp_route}', ), tlsRoutePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/tlsRoutes/{tls_route}' + 'projects/{project}/locations/{location}/tlsRoutes/{tls_route}', ), wasmPluginPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/wasmPlugins/{wasm_plugin}' + 'projects/{project}/locations/{location}/wasmPlugins/{wasm_plugin}', ), wasmPluginVersionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/wasmPlugins/{wasm_plugin}/versions/{wasm_plugin_version}' + 'projects/{project}/locations/{location}/wasmPlugins/{wasm_plugin}/versions/{wasm_plugin_version}', ), }; @@ -250,14 +280,26 @@ export class DepServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listLbTrafficExtensions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'lbTrafficExtensions'), - listLbRouteExtensions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'lbRouteExtensions'), - listLbEdgeExtensions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'lbEdgeExtensions'), - listAuthzExtensions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'authzExtensions') + listLbTrafficExtensions: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'lbTrafficExtensions', + ), + listLbRouteExtensions: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'lbRouteExtensions', + ), + listLbEdgeExtensions: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'lbEdgeExtensions', + ), + listAuthzExtensions: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'authzExtensions', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -266,120 +308,306 @@ export class DepServiceClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1/{resource=projects/*/locations/*/edgeCacheKeysets/*}:getIamPolicy',additional_bindings: [{get: '/v1/{resource=projects/*/locations/*/edgeCacheOrigins/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/edgeCacheServices/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/endpointPolicies/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/serviceBindings/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/meshes/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/gateways/*}:getIamPolicy',}], - },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1/{resource=projects/*/locations/*/edgeCacheKeysets/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/edgeCacheOrigins/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/edgeCacheServices/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/endpointPolicies/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceBindings/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/meshes/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/gateways/*}:setIamPolicy',body: '*',}], - },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1/{resource=projects/*/locations/*/edgeCacheKeysets/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/edgeCacheOrigins/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/edgeCacheServices/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/endpointPolicies/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceBindings/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/meshes/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/gateways/*}:testIamPermissions',body: '*',}], - },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1/{resource=projects/*/locations/*/edgeCacheKeysets/*}:getIamPolicy', + additional_bindings: [ + { + get: '/v1/{resource=projects/*/locations/*/edgeCacheOrigins/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/edgeCacheServices/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/endpointPolicies/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/serviceBindings/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/meshes/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/gateways/*}:getIamPolicy', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1/{resource=projects/*/locations/*/edgeCacheKeysets/*}:setIamPolicy', + body: '*', + additional_bindings: [ + { + post: '/v1/{resource=projects/*/locations/*/edgeCacheOrigins/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/edgeCacheServices/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/endpointPolicies/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceBindings/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/meshes/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/gateways/*}:setIamPolicy', + body: '*', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1/{resource=projects/*/locations/*/edgeCacheKeysets/*}:testIamPermissions', + body: '*', + additional_bindings: [ + { + post: '/v1/{resource=projects/*/locations/*/edgeCacheOrigins/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/edgeCacheServices/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/endpointPolicies/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceBindings/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/meshes/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/gateways/*}:testIamPermissions', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createLbTrafficExtensionResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.LbTrafficExtension') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.LbTrafficExtension', + ) as gax.protobuf.Type; const createLbTrafficExtensionMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateLbTrafficExtensionResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.LbTrafficExtension') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.LbTrafficExtension', + ) as gax.protobuf.Type; const updateLbTrafficExtensionMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteLbTrafficExtensionResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteLbTrafficExtensionMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const createLbRouteExtensionResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.LbRouteExtension') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.LbRouteExtension', + ) as gax.protobuf.Type; const createLbRouteExtensionMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateLbRouteExtensionResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.LbRouteExtension') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.LbRouteExtension', + ) as gax.protobuf.Type; const updateLbRouteExtensionMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteLbRouteExtensionResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteLbRouteExtensionMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const createLbEdgeExtensionResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.LbEdgeExtension') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.LbEdgeExtension', + ) as gax.protobuf.Type; const createLbEdgeExtensionMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateLbEdgeExtensionResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.LbEdgeExtension') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.LbEdgeExtension', + ) as gax.protobuf.Type; const updateLbEdgeExtensionMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteLbEdgeExtensionResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteLbEdgeExtensionMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const createAuthzExtensionResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.AuthzExtension') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.AuthzExtension', + ) as gax.protobuf.Type; const createAuthzExtensionMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateAuthzExtensionResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.AuthzExtension') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.AuthzExtension', + ) as gax.protobuf.Type; const updateAuthzExtensionMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteAuthzExtensionResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteAuthzExtensionMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createLbTrafficExtension: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - createLbTrafficExtensionResponse.decode.bind(createLbTrafficExtensionResponse), - createLbTrafficExtensionMetadata.decode.bind(createLbTrafficExtensionMetadata)), + createLbTrafficExtensionResponse.decode.bind( + createLbTrafficExtensionResponse, + ), + createLbTrafficExtensionMetadata.decode.bind( + createLbTrafficExtensionMetadata, + ), + ), updateLbTrafficExtension: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - updateLbTrafficExtensionResponse.decode.bind(updateLbTrafficExtensionResponse), - updateLbTrafficExtensionMetadata.decode.bind(updateLbTrafficExtensionMetadata)), + updateLbTrafficExtensionResponse.decode.bind( + updateLbTrafficExtensionResponse, + ), + updateLbTrafficExtensionMetadata.decode.bind( + updateLbTrafficExtensionMetadata, + ), + ), deleteLbTrafficExtension: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - deleteLbTrafficExtensionResponse.decode.bind(deleteLbTrafficExtensionResponse), - deleteLbTrafficExtensionMetadata.decode.bind(deleteLbTrafficExtensionMetadata)), + deleteLbTrafficExtensionResponse.decode.bind( + deleteLbTrafficExtensionResponse, + ), + deleteLbTrafficExtensionMetadata.decode.bind( + deleteLbTrafficExtensionMetadata, + ), + ), createLbRouteExtension: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - createLbRouteExtensionResponse.decode.bind(createLbRouteExtensionResponse), - createLbRouteExtensionMetadata.decode.bind(createLbRouteExtensionMetadata)), + createLbRouteExtensionResponse.decode.bind( + createLbRouteExtensionResponse, + ), + createLbRouteExtensionMetadata.decode.bind( + createLbRouteExtensionMetadata, + ), + ), updateLbRouteExtension: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - updateLbRouteExtensionResponse.decode.bind(updateLbRouteExtensionResponse), - updateLbRouteExtensionMetadata.decode.bind(updateLbRouteExtensionMetadata)), + updateLbRouteExtensionResponse.decode.bind( + updateLbRouteExtensionResponse, + ), + updateLbRouteExtensionMetadata.decode.bind( + updateLbRouteExtensionMetadata, + ), + ), deleteLbRouteExtension: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - deleteLbRouteExtensionResponse.decode.bind(deleteLbRouteExtensionResponse), - deleteLbRouteExtensionMetadata.decode.bind(deleteLbRouteExtensionMetadata)), + deleteLbRouteExtensionResponse.decode.bind( + deleteLbRouteExtensionResponse, + ), + deleteLbRouteExtensionMetadata.decode.bind( + deleteLbRouteExtensionMetadata, + ), + ), createLbEdgeExtension: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - createLbEdgeExtensionResponse.decode.bind(createLbEdgeExtensionResponse), - createLbEdgeExtensionMetadata.decode.bind(createLbEdgeExtensionMetadata)), + createLbEdgeExtensionResponse.decode.bind( + createLbEdgeExtensionResponse, + ), + createLbEdgeExtensionMetadata.decode.bind( + createLbEdgeExtensionMetadata, + ), + ), updateLbEdgeExtension: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - updateLbEdgeExtensionResponse.decode.bind(updateLbEdgeExtensionResponse), - updateLbEdgeExtensionMetadata.decode.bind(updateLbEdgeExtensionMetadata)), + updateLbEdgeExtensionResponse.decode.bind( + updateLbEdgeExtensionResponse, + ), + updateLbEdgeExtensionMetadata.decode.bind( + updateLbEdgeExtensionMetadata, + ), + ), deleteLbEdgeExtension: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - deleteLbEdgeExtensionResponse.decode.bind(deleteLbEdgeExtensionResponse), - deleteLbEdgeExtensionMetadata.decode.bind(deleteLbEdgeExtensionMetadata)), + deleteLbEdgeExtensionResponse.decode.bind( + deleteLbEdgeExtensionResponse, + ), + deleteLbEdgeExtensionMetadata.decode.bind( + deleteLbEdgeExtensionMetadata, + ), + ), createAuthzExtension: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createAuthzExtensionResponse.decode.bind(createAuthzExtensionResponse), - createAuthzExtensionMetadata.decode.bind(createAuthzExtensionMetadata)), + createAuthzExtensionMetadata.decode.bind(createAuthzExtensionMetadata), + ), updateAuthzExtension: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateAuthzExtensionResponse.decode.bind(updateAuthzExtensionResponse), - updateAuthzExtensionMetadata.decode.bind(updateAuthzExtensionMetadata)), + updateAuthzExtensionMetadata.decode.bind(updateAuthzExtensionMetadata), + ), deleteAuthzExtension: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteAuthzExtensionResponse.decode.bind(deleteAuthzExtensionResponse), - deleteAuthzExtensionMetadata.decode.bind(deleteAuthzExtensionMetadata)) + deleteAuthzExtensionMetadata.decode.bind(deleteAuthzExtensionMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.networkservices.v1.DepService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.networkservices.v1.DepService', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -410,28 +638,54 @@ export class DepServiceClient { // Put together the "service stub" for // google.cloud.networkservices.v1.DepService. this.depServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.networkservices.v1.DepService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.networkservices.v1.DepService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.networkservices.v1.DepService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const depServiceStubMethods = - ['listLbTrafficExtensions', 'getLbTrafficExtension', 'createLbTrafficExtension', 'updateLbTrafficExtension', 'deleteLbTrafficExtension', 'listLbRouteExtensions', 'getLbRouteExtension', 'createLbRouteExtension', 'updateLbRouteExtension', 'deleteLbRouteExtension', 'listLbEdgeExtensions', 'getLbEdgeExtension', 'createLbEdgeExtension', 'updateLbEdgeExtension', 'deleteLbEdgeExtension', 'listAuthzExtensions', 'getAuthzExtension', 'createAuthzExtension', 'updateAuthzExtension', 'deleteAuthzExtension']; + const depServiceStubMethods = [ + 'listLbTrafficExtensions', + 'getLbTrafficExtension', + 'createLbTrafficExtension', + 'updateLbTrafficExtension', + 'deleteLbTrafficExtension', + 'listLbRouteExtensions', + 'getLbRouteExtension', + 'createLbRouteExtension', + 'updateLbRouteExtension', + 'deleteLbRouteExtension', + 'listLbEdgeExtensions', + 'getLbEdgeExtension', + 'createLbEdgeExtension', + 'updateLbEdgeExtension', + 'deleteLbEdgeExtension', + 'listAuthzExtensions', + 'getAuthzExtension', + 'createAuthzExtension', + 'updateAuthzExtension', + 'deleteAuthzExtension', + ]; for (const methodName of depServiceStubMethods) { const callPromise = this.depServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -441,7 +695,7 @@ export class DepServiceClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -456,8 +710,14 @@ export class DepServiceClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkservices.googleapis.com'; } @@ -468,8 +728,14 @@ export class DepServiceClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkservices.googleapis.com'; } @@ -500,9 +766,7 @@ export class DepServiceClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -511,8 +775,9 @@ export class DepServiceClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -523,1977 +788,2942 @@ export class DepServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets details of the specified `LbTrafficExtension` resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the `LbTrafficExtension` resource to get. Must be in - * the format - * `projects/{project}/locations/{location}/lbTrafficExtensions/{lb_traffic_extension}`. - * @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 {@link protos.google.cloud.networkservices.v1.LbTrafficExtension|LbTrafficExtension}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/dep_service.get_lb_traffic_extension.js - * region_tag:networkservices_v1_generated_DepService_GetLbTrafficExtension_async - */ + /** + * Gets details of the specified `LbTrafficExtension` resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the `LbTrafficExtension` resource to get. Must be in + * the format + * `projects/{project}/locations/{location}/lbTrafficExtensions/{lb_traffic_extension}`. + * @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 {@link protos.google.cloud.networkservices.v1.LbTrafficExtension|LbTrafficExtension}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/dep_service.get_lb_traffic_extension.js + * region_tag:networkservices_v1_generated_DepService_GetLbTrafficExtension_async + */ getLbTrafficExtension( - request?: protos.google.cloud.networkservices.v1.IGetLbTrafficExtensionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.ILbTrafficExtension, - protos.google.cloud.networkservices.v1.IGetLbTrafficExtensionRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IGetLbTrafficExtensionRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.ILbTrafficExtension, + ( + | protos.google.cloud.networkservices.v1.IGetLbTrafficExtensionRequest + | undefined + ), + {} | undefined, + ] + >; getLbTrafficExtension( - request: protos.google.cloud.networkservices.v1.IGetLbTrafficExtensionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkservices.v1.ILbTrafficExtension, - protos.google.cloud.networkservices.v1.IGetLbTrafficExtensionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetLbTrafficExtensionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkservices.v1.ILbTrafficExtension, + | protos.google.cloud.networkservices.v1.IGetLbTrafficExtensionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getLbTrafficExtension( - request: protos.google.cloud.networkservices.v1.IGetLbTrafficExtensionRequest, - callback: Callback< - protos.google.cloud.networkservices.v1.ILbTrafficExtension, - protos.google.cloud.networkservices.v1.IGetLbTrafficExtensionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetLbTrafficExtensionRequest, + callback: Callback< + protos.google.cloud.networkservices.v1.ILbTrafficExtension, + | protos.google.cloud.networkservices.v1.IGetLbTrafficExtensionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getLbTrafficExtension( - request?: protos.google.cloud.networkservices.v1.IGetLbTrafficExtensionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkservices.v1.ILbTrafficExtension, - protos.google.cloud.networkservices.v1.IGetLbTrafficExtensionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkservices.v1.IGetLbTrafficExtensionRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkservices.v1.ILbTrafficExtension, - protos.google.cloud.networkservices.v1.IGetLbTrafficExtensionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkservices.v1.ILbTrafficExtension, - protos.google.cloud.networkservices.v1.IGetLbTrafficExtensionRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkservices.v1.IGetLbTrafficExtensionRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkservices.v1.ILbTrafficExtension, + | protos.google.cloud.networkservices.v1.IGetLbTrafficExtensionRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.ILbTrafficExtension, + ( + | protos.google.cloud.networkservices.v1.IGetLbTrafficExtensionRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getLbTrafficExtension request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkservices.v1.ILbTrafficExtension, - protos.google.cloud.networkservices.v1.IGetLbTrafficExtensionRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkservices.v1.ILbTrafficExtension, + | protos.google.cloud.networkservices.v1.IGetLbTrafficExtensionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getLbTrafficExtension response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getLbTrafficExtension(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkservices.v1.ILbTrafficExtension, - protos.google.cloud.networkservices.v1.IGetLbTrafficExtensionRequest|undefined, - {}|undefined - ]) => { - this._log.info('getLbTrafficExtension response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getLbTrafficExtension(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkservices.v1.ILbTrafficExtension, + ( + | protos.google.cloud.networkservices.v1.IGetLbTrafficExtensionRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getLbTrafficExtension response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of the specified `LbRouteExtension` resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the `LbRouteExtension` resource to get. Must be in the - * format - * `projects/{project}/locations/{location}/lbRouteExtensions/{lb_route_extension}`. - * @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 {@link protos.google.cloud.networkservices.v1.LbRouteExtension|LbRouteExtension}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/dep_service.get_lb_route_extension.js - * region_tag:networkservices_v1_generated_DepService_GetLbRouteExtension_async - */ + /** + * Gets details of the specified `LbRouteExtension` resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the `LbRouteExtension` resource to get. Must be in the + * format + * `projects/{project}/locations/{location}/lbRouteExtensions/{lb_route_extension}`. + * @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 {@link protos.google.cloud.networkservices.v1.LbRouteExtension|LbRouteExtension}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/dep_service.get_lb_route_extension.js + * region_tag:networkservices_v1_generated_DepService_GetLbRouteExtension_async + */ getLbRouteExtension( - request?: protos.google.cloud.networkservices.v1.IGetLbRouteExtensionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.ILbRouteExtension, - protos.google.cloud.networkservices.v1.IGetLbRouteExtensionRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IGetLbRouteExtensionRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.ILbRouteExtension, + ( + | protos.google.cloud.networkservices.v1.IGetLbRouteExtensionRequest + | undefined + ), + {} | undefined, + ] + >; getLbRouteExtension( - request: protos.google.cloud.networkservices.v1.IGetLbRouteExtensionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkservices.v1.ILbRouteExtension, - protos.google.cloud.networkservices.v1.IGetLbRouteExtensionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetLbRouteExtensionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkservices.v1.ILbRouteExtension, + | protos.google.cloud.networkservices.v1.IGetLbRouteExtensionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getLbRouteExtension( - request: protos.google.cloud.networkservices.v1.IGetLbRouteExtensionRequest, - callback: Callback< - protos.google.cloud.networkservices.v1.ILbRouteExtension, - protos.google.cloud.networkservices.v1.IGetLbRouteExtensionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetLbRouteExtensionRequest, + callback: Callback< + protos.google.cloud.networkservices.v1.ILbRouteExtension, + | protos.google.cloud.networkservices.v1.IGetLbRouteExtensionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getLbRouteExtension( - request?: protos.google.cloud.networkservices.v1.IGetLbRouteExtensionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkservices.v1.ILbRouteExtension, - protos.google.cloud.networkservices.v1.IGetLbRouteExtensionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkservices.v1.IGetLbRouteExtensionRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkservices.v1.ILbRouteExtension, - protos.google.cloud.networkservices.v1.IGetLbRouteExtensionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkservices.v1.ILbRouteExtension, - protos.google.cloud.networkservices.v1.IGetLbRouteExtensionRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkservices.v1.IGetLbRouteExtensionRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkservices.v1.ILbRouteExtension, + | protos.google.cloud.networkservices.v1.IGetLbRouteExtensionRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.ILbRouteExtension, + ( + | protos.google.cloud.networkservices.v1.IGetLbRouteExtensionRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getLbRouteExtension request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkservices.v1.ILbRouteExtension, - protos.google.cloud.networkservices.v1.IGetLbRouteExtensionRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkservices.v1.ILbRouteExtension, + | protos.google.cloud.networkservices.v1.IGetLbRouteExtensionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getLbRouteExtension response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getLbRouteExtension(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkservices.v1.ILbRouteExtension, - protos.google.cloud.networkservices.v1.IGetLbRouteExtensionRequest|undefined, - {}|undefined - ]) => { - this._log.info('getLbRouteExtension response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getLbRouteExtension(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkservices.v1.ILbRouteExtension, + ( + | protos.google.cloud.networkservices.v1.IGetLbRouteExtensionRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getLbRouteExtension response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of the specified `LbEdgeExtension` resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the `LbEdgeExtension` resource to get. Must be in the - * format - * `projects/{project}/locations/{location}/lbEdgeExtensions/{lb_edge_extension}`. - * @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 {@link protos.google.cloud.networkservices.v1.LbEdgeExtension|LbEdgeExtension}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/dep_service.get_lb_edge_extension.js - * region_tag:networkservices_v1_generated_DepService_GetLbEdgeExtension_async - */ + /** + * Gets details of the specified `LbEdgeExtension` resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the `LbEdgeExtension` resource to get. Must be in the + * format + * `projects/{project}/locations/{location}/lbEdgeExtensions/{lb_edge_extension}`. + * @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 {@link protos.google.cloud.networkservices.v1.LbEdgeExtension|LbEdgeExtension}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/dep_service.get_lb_edge_extension.js + * region_tag:networkservices_v1_generated_DepService_GetLbEdgeExtension_async + */ getLbEdgeExtension( - request?: protos.google.cloud.networkservices.v1.IGetLbEdgeExtensionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.ILbEdgeExtension, - protos.google.cloud.networkservices.v1.IGetLbEdgeExtensionRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IGetLbEdgeExtensionRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.ILbEdgeExtension, + ( + | protos.google.cloud.networkservices.v1.IGetLbEdgeExtensionRequest + | undefined + ), + {} | undefined, + ] + >; getLbEdgeExtension( - request: protos.google.cloud.networkservices.v1.IGetLbEdgeExtensionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkservices.v1.ILbEdgeExtension, - protos.google.cloud.networkservices.v1.IGetLbEdgeExtensionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetLbEdgeExtensionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkservices.v1.ILbEdgeExtension, + | protos.google.cloud.networkservices.v1.IGetLbEdgeExtensionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getLbEdgeExtension( - request: protos.google.cloud.networkservices.v1.IGetLbEdgeExtensionRequest, - callback: Callback< - protos.google.cloud.networkservices.v1.ILbEdgeExtension, - protos.google.cloud.networkservices.v1.IGetLbEdgeExtensionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetLbEdgeExtensionRequest, + callback: Callback< + protos.google.cloud.networkservices.v1.ILbEdgeExtension, + | protos.google.cloud.networkservices.v1.IGetLbEdgeExtensionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getLbEdgeExtension( - request?: protos.google.cloud.networkservices.v1.IGetLbEdgeExtensionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkservices.v1.ILbEdgeExtension, - protos.google.cloud.networkservices.v1.IGetLbEdgeExtensionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkservices.v1.IGetLbEdgeExtensionRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkservices.v1.ILbEdgeExtension, - protos.google.cloud.networkservices.v1.IGetLbEdgeExtensionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkservices.v1.ILbEdgeExtension, - protos.google.cloud.networkservices.v1.IGetLbEdgeExtensionRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkservices.v1.IGetLbEdgeExtensionRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkservices.v1.ILbEdgeExtension, + | protos.google.cloud.networkservices.v1.IGetLbEdgeExtensionRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.ILbEdgeExtension, + ( + | protos.google.cloud.networkservices.v1.IGetLbEdgeExtensionRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getLbEdgeExtension request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkservices.v1.ILbEdgeExtension, - protos.google.cloud.networkservices.v1.IGetLbEdgeExtensionRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkservices.v1.ILbEdgeExtension, + | protos.google.cloud.networkservices.v1.IGetLbEdgeExtensionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getLbEdgeExtension response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getLbEdgeExtension(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkservices.v1.ILbEdgeExtension, - protos.google.cloud.networkservices.v1.IGetLbEdgeExtensionRequest|undefined, - {}|undefined - ]) => { - this._log.info('getLbEdgeExtension response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getLbEdgeExtension(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkservices.v1.ILbEdgeExtension, + ( + | protos.google.cloud.networkservices.v1.IGetLbEdgeExtensionRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getLbEdgeExtension response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of the specified `AuthzExtension` resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the `AuthzExtension` resource to get. Must be in - * the format - * `projects/{project}/locations/{location}/authzExtensions/{authz_extension}`. - * @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 {@link protos.google.cloud.networkservices.v1.AuthzExtension|AuthzExtension}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/dep_service.get_authz_extension.js - * region_tag:networkservices_v1_generated_DepService_GetAuthzExtension_async - */ + /** + * Gets details of the specified `AuthzExtension` resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the `AuthzExtension` resource to get. Must be in + * the format + * `projects/{project}/locations/{location}/authzExtensions/{authz_extension}`. + * @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 {@link protos.google.cloud.networkservices.v1.AuthzExtension|AuthzExtension}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/dep_service.get_authz_extension.js + * region_tag:networkservices_v1_generated_DepService_GetAuthzExtension_async + */ getAuthzExtension( - request?: protos.google.cloud.networkservices.v1.IGetAuthzExtensionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.IAuthzExtension, - protos.google.cloud.networkservices.v1.IGetAuthzExtensionRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IGetAuthzExtensionRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IAuthzExtension, + ( + | protos.google.cloud.networkservices.v1.IGetAuthzExtensionRequest + | undefined + ), + {} | undefined, + ] + >; getAuthzExtension( - request: protos.google.cloud.networkservices.v1.IGetAuthzExtensionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkservices.v1.IAuthzExtension, - protos.google.cloud.networkservices.v1.IGetAuthzExtensionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetAuthzExtensionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkservices.v1.IAuthzExtension, + | protos.google.cloud.networkservices.v1.IGetAuthzExtensionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAuthzExtension( - request: protos.google.cloud.networkservices.v1.IGetAuthzExtensionRequest, - callback: Callback< - protos.google.cloud.networkservices.v1.IAuthzExtension, - protos.google.cloud.networkservices.v1.IGetAuthzExtensionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetAuthzExtensionRequest, + callback: Callback< + protos.google.cloud.networkservices.v1.IAuthzExtension, + | protos.google.cloud.networkservices.v1.IGetAuthzExtensionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAuthzExtension( - request?: protos.google.cloud.networkservices.v1.IGetAuthzExtensionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkservices.v1.IAuthzExtension, - protos.google.cloud.networkservices.v1.IGetAuthzExtensionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkservices.v1.IGetAuthzExtensionRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkservices.v1.IAuthzExtension, - protos.google.cloud.networkservices.v1.IGetAuthzExtensionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkservices.v1.IAuthzExtension, - protos.google.cloud.networkservices.v1.IGetAuthzExtensionRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkservices.v1.IGetAuthzExtensionRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkservices.v1.IAuthzExtension, + | protos.google.cloud.networkservices.v1.IGetAuthzExtensionRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IAuthzExtension, + ( + | protos.google.cloud.networkservices.v1.IGetAuthzExtensionRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getAuthzExtension request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkservices.v1.IAuthzExtension, - protos.google.cloud.networkservices.v1.IGetAuthzExtensionRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkservices.v1.IAuthzExtension, + | protos.google.cloud.networkservices.v1.IGetAuthzExtensionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getAuthzExtension response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getAuthzExtension(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkservices.v1.IAuthzExtension, - protos.google.cloud.networkservices.v1.IGetAuthzExtensionRequest|undefined, - {}|undefined - ]) => { - this._log.info('getAuthzExtension response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getAuthzExtension(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkservices.v1.IAuthzExtension, + ( + | protos.google.cloud.networkservices.v1.IGetAuthzExtensionRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getAuthzExtension response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a new `LbTrafficExtension` resource in a given project and - * location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the `LbTrafficExtension` resource. Must be - * in the format `projects/{project}/locations/{location}`. - * @param {string} request.lbTrafficExtensionId - * Required. User-provided ID of the `LbTrafficExtension` resource to be - * created. - * @param {google.cloud.networkservices.v1.LbTrafficExtension} request.lbTrafficExtension - * Required. `LbTrafficExtension` resource to be created. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server can ignore - * the request if it has already been completed. The server guarantees - * that for 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server ignores the second request This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/dep_service.create_lb_traffic_extension.js - * region_tag:networkservices_v1_generated_DepService_CreateLbTrafficExtension_async - */ - createLbTrafficExtension( - request?: protos.google.cloud.networkservices.v1.ICreateLbTrafficExtensionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + /** + * Creates a new `LbTrafficExtension` resource in a given project and + * location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the `LbTrafficExtension` resource. Must be + * in the format `projects/{project}/locations/{location}`. + * @param {string} request.lbTrafficExtensionId + * Required. User-provided ID of the `LbTrafficExtension` resource to be + * created. + * @param {google.cloud.networkservices.v1.LbTrafficExtension} request.lbTrafficExtension + * Required. `LbTrafficExtension` resource to be created. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server can ignore + * the request if it has already been completed. The server guarantees + * that for 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server ignores the second request This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/dep_service.create_lb_traffic_extension.js + * region_tag:networkservices_v1_generated_DepService_CreateLbTrafficExtension_async + */ createLbTrafficExtension( - request: protos.google.cloud.networkservices.v1.ICreateLbTrafficExtensionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request?: protos.google.cloud.networkservices.v1.ICreateLbTrafficExtensionRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createLbTrafficExtension( - request: protos.google.cloud.networkservices.v1.ICreateLbTrafficExtensionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.ICreateLbTrafficExtensionRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createLbTrafficExtension( - request?: protos.google.cloud.networkservices.v1.ICreateLbTrafficExtensionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request: protos.google.cloud.networkservices.v1.ICreateLbTrafficExtensionRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; + createLbTrafficExtension( + request?: protos.google.cloud.networkservices.v1.ICreateLbTrafficExtensionRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createLbTrafficExtension response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createLbTrafficExtension request %j', request); - return this.innerApiCalls.createLbTrafficExtension(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createLbTrafficExtension response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createLbTrafficExtension(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createLbTrafficExtension response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createLbTrafficExtension()`. - * @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/dep_service.create_lb_traffic_extension.js - * region_tag:networkservices_v1_generated_DepService_CreateLbTrafficExtension_async - */ - async checkCreateLbTrafficExtensionProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createLbTrafficExtension()`. + * @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/dep_service.create_lb_traffic_extension.js + * region_tag:networkservices_v1_generated_DepService_CreateLbTrafficExtension_async + */ + async checkCreateLbTrafficExtensionProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1.LbTrafficExtension, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('createLbTrafficExtension long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createLbTrafficExtension, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createLbTrafficExtension, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1.LbTrafficExtension, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Updates the parameters of the specified `LbTrafficExtension` resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Used to specify the fields to be overwritten in the - * `LbTrafficExtension` resource by the update. - * The fields specified in the `update_mask` are relative to the resource, not - * the full request. A field is overwritten if it is in the mask. If the - * user does not specify a mask, then all fields are overwritten. - * @param {google.cloud.networkservices.v1.LbTrafficExtension} request.lbTrafficExtension - * Required. `LbTrafficExtension` resource being updated. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server can ignore - * the request if it has already been completed. The server guarantees - * that for 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server ignores the second request This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/dep_service.update_lb_traffic_extension.js - * region_tag:networkservices_v1_generated_DepService_UpdateLbTrafficExtension_async - */ + /** + * Updates the parameters of the specified `LbTrafficExtension` resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Used to specify the fields to be overwritten in the + * `LbTrafficExtension` resource by the update. + * The fields specified in the `update_mask` are relative to the resource, not + * the full request. A field is overwritten if it is in the mask. If the + * user does not specify a mask, then all fields are overwritten. + * @param {google.cloud.networkservices.v1.LbTrafficExtension} request.lbTrafficExtension + * Required. `LbTrafficExtension` resource being updated. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server can ignore + * the request if it has already been completed. The server guarantees + * that for 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server ignores the second request This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/dep_service.update_lb_traffic_extension.js + * region_tag:networkservices_v1_generated_DepService_UpdateLbTrafficExtension_async + */ updateLbTrafficExtension( - request?: protos.google.cloud.networkservices.v1.IUpdateLbTrafficExtensionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IUpdateLbTrafficExtensionRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateLbTrafficExtension( - request: protos.google.cloud.networkservices.v1.IUpdateLbTrafficExtensionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IUpdateLbTrafficExtensionRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateLbTrafficExtension( - request: protos.google.cloud.networkservices.v1.IUpdateLbTrafficExtensionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IUpdateLbTrafficExtensionRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateLbTrafficExtension( - request?: protos.google.cloud.networkservices.v1.IUpdateLbTrafficExtensionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.IUpdateLbTrafficExtensionRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'lb_traffic_extension.name': request.lbTrafficExtension!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'lb_traffic_extension.name': request.lbTrafficExtension!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateLbTrafficExtension response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateLbTrafficExtension request %j', request); - return this.innerApiCalls.updateLbTrafficExtension(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateLbTrafficExtension response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateLbTrafficExtension(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateLbTrafficExtension response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateLbTrafficExtension()`. - * @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/dep_service.update_lb_traffic_extension.js - * region_tag:networkservices_v1_generated_DepService_UpdateLbTrafficExtension_async - */ - async checkUpdateLbTrafficExtensionProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateLbTrafficExtension()`. + * @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/dep_service.update_lb_traffic_extension.js + * region_tag:networkservices_v1_generated_DepService_UpdateLbTrafficExtension_async + */ + async checkUpdateLbTrafficExtensionProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1.LbTrafficExtension, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('updateLbTrafficExtension long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateLbTrafficExtension, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateLbTrafficExtension, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1.LbTrafficExtension, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Deletes the specified `LbTrafficExtension` resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the `LbTrafficExtension` resource to delete. Must be - * in the format - * `projects/{project}/locations/{location}/lbTrafficExtensions/{lb_traffic_extension}`. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server can ignore - * the request if it has already been completed. The server guarantees - * that for 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server ignores the second request This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/dep_service.delete_lb_traffic_extension.js - * region_tag:networkservices_v1_generated_DepService_DeleteLbTrafficExtension_async - */ + /** + * Deletes the specified `LbTrafficExtension` resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the `LbTrafficExtension` resource to delete. Must be + * in the format + * `projects/{project}/locations/{location}/lbTrafficExtensions/{lb_traffic_extension}`. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server can ignore + * the request if it has already been completed. The server guarantees + * that for 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server ignores the second request This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/dep_service.delete_lb_traffic_extension.js + * region_tag:networkservices_v1_generated_DepService_DeleteLbTrafficExtension_async + */ deleteLbTrafficExtension( - request?: protos.google.cloud.networkservices.v1.IDeleteLbTrafficExtensionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IDeleteLbTrafficExtensionRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteLbTrafficExtension( - request: protos.google.cloud.networkservices.v1.IDeleteLbTrafficExtensionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IDeleteLbTrafficExtensionRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteLbTrafficExtension( - request: protos.google.cloud.networkservices.v1.IDeleteLbTrafficExtensionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IDeleteLbTrafficExtensionRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteLbTrafficExtension( - request?: protos.google.cloud.networkservices.v1.IDeleteLbTrafficExtensionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.IDeleteLbTrafficExtensionRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteLbTrafficExtension response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteLbTrafficExtension request %j', request); - return this.innerApiCalls.deleteLbTrafficExtension(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteLbTrafficExtension response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteLbTrafficExtension(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteLbTrafficExtension response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteLbTrafficExtension()`. - * @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/dep_service.delete_lb_traffic_extension.js - * region_tag:networkservices_v1_generated_DepService_DeleteLbTrafficExtension_async - */ - async checkDeleteLbTrafficExtensionProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteLbTrafficExtension()`. + * @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/dep_service.delete_lb_traffic_extension.js + * region_tag:networkservices_v1_generated_DepService_DeleteLbTrafficExtension_async + */ + async checkDeleteLbTrafficExtensionProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('deleteLbTrafficExtension long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteLbTrafficExtension, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteLbTrafficExtension, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Creates a new `LbRouteExtension` resource in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the `LbRouteExtension` resource. Must be - * in the format `projects/{project}/locations/{location}`. - * @param {string} request.lbRouteExtensionId - * Required. User-provided ID of the `LbRouteExtension` resource to be - * created. - * @param {google.cloud.networkservices.v1.LbRouteExtension} request.lbRouteExtension - * Required. `LbRouteExtension` resource to be created. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server can ignore - * the request if it has already been completed. The server guarantees - * that for 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server ignores the second request This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/dep_service.create_lb_route_extension.js - * region_tag:networkservices_v1_generated_DepService_CreateLbRouteExtension_async - */ + /** + * Creates a new `LbRouteExtension` resource in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the `LbRouteExtension` resource. Must be + * in the format `projects/{project}/locations/{location}`. + * @param {string} request.lbRouteExtensionId + * Required. User-provided ID of the `LbRouteExtension` resource to be + * created. + * @param {google.cloud.networkservices.v1.LbRouteExtension} request.lbRouteExtension + * Required. `LbRouteExtension` resource to be created. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server can ignore + * the request if it has already been completed. The server guarantees + * that for 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server ignores the second request This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/dep_service.create_lb_route_extension.js + * region_tag:networkservices_v1_generated_DepService_CreateLbRouteExtension_async + */ createLbRouteExtension( - request?: protos.google.cloud.networkservices.v1.ICreateLbRouteExtensionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.ICreateLbRouteExtensionRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.ILbRouteExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createLbRouteExtension( - request: protos.google.cloud.networkservices.v1.ICreateLbRouteExtensionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.ICreateLbRouteExtensionRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.ILbRouteExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createLbRouteExtension( - request: protos.google.cloud.networkservices.v1.ICreateLbRouteExtensionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.ICreateLbRouteExtensionRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.ILbRouteExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createLbRouteExtension( - request?: protos.google.cloud.networkservices.v1.ICreateLbRouteExtensionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.ICreateLbRouteExtensionRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.ILbRouteExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1.ILbRouteExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.ILbRouteExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.ILbRouteExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createLbRouteExtension response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createLbRouteExtension request %j', request); - return this.innerApiCalls.createLbRouteExtension(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createLbRouteExtension response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createLbRouteExtension(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1.ILbRouteExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createLbRouteExtension response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createLbRouteExtension()`. - * @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/dep_service.create_lb_route_extension.js - * region_tag:networkservices_v1_generated_DepService_CreateLbRouteExtension_async - */ - async checkCreateLbRouteExtensionProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createLbRouteExtension()`. + * @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/dep_service.create_lb_route_extension.js + * region_tag:networkservices_v1_generated_DepService_CreateLbRouteExtension_async + */ + async checkCreateLbRouteExtensionProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1.LbRouteExtension, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('createLbRouteExtension long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createLbRouteExtension, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createLbRouteExtension, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1.LbRouteExtension, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Updates the parameters of the specified `LbRouteExtension` resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Used to specify the fields to be overwritten in the - * `LbRouteExtension` resource by the update. - * The fields specified in the `update_mask` are relative to the resource, not - * the full request. A field is overwritten if it is in the mask. If the - * user does not specify a mask, then all fields are overwritten. - * @param {google.cloud.networkservices.v1.LbRouteExtension} request.lbRouteExtension - * Required. `LbRouteExtension` resource being updated. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server can ignore - * the request if it has already been completed. The server guarantees - * that for 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server ignores the second request This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/dep_service.update_lb_route_extension.js - * region_tag:networkservices_v1_generated_DepService_UpdateLbRouteExtension_async - */ + /** + * Updates the parameters of the specified `LbRouteExtension` resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Used to specify the fields to be overwritten in the + * `LbRouteExtension` resource by the update. + * The fields specified in the `update_mask` are relative to the resource, not + * the full request. A field is overwritten if it is in the mask. If the + * user does not specify a mask, then all fields are overwritten. + * @param {google.cloud.networkservices.v1.LbRouteExtension} request.lbRouteExtension + * Required. `LbRouteExtension` resource being updated. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server can ignore + * the request if it has already been completed. The server guarantees + * that for 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server ignores the second request This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/dep_service.update_lb_route_extension.js + * region_tag:networkservices_v1_generated_DepService_UpdateLbRouteExtension_async + */ updateLbRouteExtension( - request?: protos.google.cloud.networkservices.v1.IUpdateLbRouteExtensionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IUpdateLbRouteExtensionRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.ILbRouteExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateLbRouteExtension( - request: protos.google.cloud.networkservices.v1.IUpdateLbRouteExtensionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IUpdateLbRouteExtensionRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.ILbRouteExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateLbRouteExtension( - request: protos.google.cloud.networkservices.v1.IUpdateLbRouteExtensionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IUpdateLbRouteExtensionRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.ILbRouteExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateLbRouteExtension( - request?: protos.google.cloud.networkservices.v1.IUpdateLbRouteExtensionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.IUpdateLbRouteExtensionRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.ILbRouteExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1.ILbRouteExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.ILbRouteExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'lb_route_extension.name': request.lbRouteExtension!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'lb_route_extension.name': request.lbRouteExtension!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.ILbRouteExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateLbRouteExtension response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateLbRouteExtension request %j', request); - return this.innerApiCalls.updateLbRouteExtension(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateLbRouteExtension response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateLbRouteExtension(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1.ILbRouteExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateLbRouteExtension response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateLbRouteExtension()`. - * @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/dep_service.update_lb_route_extension.js - * region_tag:networkservices_v1_generated_DepService_UpdateLbRouteExtension_async - */ - async checkUpdateLbRouteExtensionProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateLbRouteExtension()`. + * @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/dep_service.update_lb_route_extension.js + * region_tag:networkservices_v1_generated_DepService_UpdateLbRouteExtension_async + */ + async checkUpdateLbRouteExtensionProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1.LbRouteExtension, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('updateLbRouteExtension long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateLbRouteExtension, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateLbRouteExtension, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1.LbRouteExtension, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Deletes the specified `LbRouteExtension` resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the `LbRouteExtension` resource to delete. Must be in - * the format - * `projects/{project}/locations/{location}/lbRouteExtensions/{lb_route_extension}`. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server can ignore - * the request if it has already been completed. The server guarantees - * that for 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server ignores the second request This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/dep_service.delete_lb_route_extension.js - * region_tag:networkservices_v1_generated_DepService_DeleteLbRouteExtension_async - */ + /** + * Deletes the specified `LbRouteExtension` resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the `LbRouteExtension` resource to delete. Must be in + * the format + * `projects/{project}/locations/{location}/lbRouteExtensions/{lb_route_extension}`. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server can ignore + * the request if it has already been completed. The server guarantees + * that for 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server ignores the second request This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/dep_service.delete_lb_route_extension.js + * region_tag:networkservices_v1_generated_DepService_DeleteLbRouteExtension_async + */ deleteLbRouteExtension( - request?: protos.google.cloud.networkservices.v1.IDeleteLbRouteExtensionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IDeleteLbRouteExtensionRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteLbRouteExtension( - request: protos.google.cloud.networkservices.v1.IDeleteLbRouteExtensionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IDeleteLbRouteExtensionRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteLbRouteExtension( - request: protos.google.cloud.networkservices.v1.IDeleteLbRouteExtensionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IDeleteLbRouteExtensionRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteLbRouteExtension( - request?: protos.google.cloud.networkservices.v1.IDeleteLbRouteExtensionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.IDeleteLbRouteExtensionRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteLbRouteExtension response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteLbRouteExtension request %j', request); - return this.innerApiCalls.deleteLbRouteExtension(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteLbRouteExtension response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteLbRouteExtension(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteLbRouteExtension response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteLbRouteExtension()`. - * @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/dep_service.delete_lb_route_extension.js - * region_tag:networkservices_v1_generated_DepService_DeleteLbRouteExtension_async - */ - async checkDeleteLbRouteExtensionProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteLbRouteExtension()`. + * @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/dep_service.delete_lb_route_extension.js + * region_tag:networkservices_v1_generated_DepService_DeleteLbRouteExtension_async + */ + async checkDeleteLbRouteExtensionProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('deleteLbRouteExtension long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteLbRouteExtension, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteLbRouteExtension, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Creates a new `LbEdgeExtension` resource in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the `LbEdgeExtension` resource. Must be in - * the format `projects/{project}/locations/{location}`. - * @param {string} request.lbEdgeExtensionId - * Required. User-provided ID of the `LbEdgeExtension` resource to be created. - * @param {google.cloud.networkservices.v1.LbEdgeExtension} request.lbEdgeExtension - * Required. `LbEdgeExtension` resource to be created. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server can ignore - * the request if it has already been completed. The server guarantees - * that for 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server ignores the second request This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/dep_service.create_lb_edge_extension.js - * region_tag:networkservices_v1_generated_DepService_CreateLbEdgeExtension_async - */ + /** + * Creates a new `LbEdgeExtension` resource in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the `LbEdgeExtension` resource. Must be in + * the format `projects/{project}/locations/{location}`. + * @param {string} request.lbEdgeExtensionId + * Required. User-provided ID of the `LbEdgeExtension` resource to be created. + * @param {google.cloud.networkservices.v1.LbEdgeExtension} request.lbEdgeExtension + * Required. `LbEdgeExtension` resource to be created. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server can ignore + * the request if it has already been completed. The server guarantees + * that for 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server ignores the second request This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/dep_service.create_lb_edge_extension.js + * region_tag:networkservices_v1_generated_DepService_CreateLbEdgeExtension_async + */ createLbEdgeExtension( - request?: protos.google.cloud.networkservices.v1.ICreateLbEdgeExtensionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.ICreateLbEdgeExtensionRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.ILbEdgeExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createLbEdgeExtension( - request: protos.google.cloud.networkservices.v1.ICreateLbEdgeExtensionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.ICreateLbEdgeExtensionRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.ILbEdgeExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createLbEdgeExtension( - request: protos.google.cloud.networkservices.v1.ICreateLbEdgeExtensionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.ICreateLbEdgeExtensionRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.ILbEdgeExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createLbEdgeExtension( - request?: protos.google.cloud.networkservices.v1.ICreateLbEdgeExtensionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.ICreateLbEdgeExtensionRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.ILbEdgeExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1.ILbEdgeExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.ILbEdgeExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.ILbEdgeExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createLbEdgeExtension response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createLbEdgeExtension request %j', request); - return this.innerApiCalls.createLbEdgeExtension(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createLbEdgeExtension response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createLbEdgeExtension(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1.ILbEdgeExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createLbEdgeExtension response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createLbEdgeExtension()`. - * @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/dep_service.create_lb_edge_extension.js - * region_tag:networkservices_v1_generated_DepService_CreateLbEdgeExtension_async - */ - async checkCreateLbEdgeExtensionProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createLbEdgeExtension()`. + * @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/dep_service.create_lb_edge_extension.js + * region_tag:networkservices_v1_generated_DepService_CreateLbEdgeExtension_async + */ + async checkCreateLbEdgeExtensionProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1.LbEdgeExtension, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('createLbEdgeExtension long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createLbEdgeExtension, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createLbEdgeExtension, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1.LbEdgeExtension, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Updates the parameters of the specified `LbEdgeExtension` resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Used to specify the fields to be overwritten in the - * `LbEdgeExtension` resource by the update. - * The fields specified in the `update_mask` are relative to the resource, not - * the full request. A field is overwritten if it is in the mask. If the - * user does not specify a mask, then all fields are overwritten. - * @param {google.cloud.networkservices.v1.LbEdgeExtension} request.lbEdgeExtension - * Required. `LbEdgeExtension` resource being updated. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server can ignore - * the request if it has already been completed. The server guarantees - * that for 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server ignores the second request This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/dep_service.update_lb_edge_extension.js - * region_tag:networkservices_v1_generated_DepService_UpdateLbEdgeExtension_async - */ + /** + * Updates the parameters of the specified `LbEdgeExtension` resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Used to specify the fields to be overwritten in the + * `LbEdgeExtension` resource by the update. + * The fields specified in the `update_mask` are relative to the resource, not + * the full request. A field is overwritten if it is in the mask. If the + * user does not specify a mask, then all fields are overwritten. + * @param {google.cloud.networkservices.v1.LbEdgeExtension} request.lbEdgeExtension + * Required. `LbEdgeExtension` resource being updated. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server can ignore + * the request if it has already been completed. The server guarantees + * that for 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server ignores the second request This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/dep_service.update_lb_edge_extension.js + * region_tag:networkservices_v1_generated_DepService_UpdateLbEdgeExtension_async + */ updateLbEdgeExtension( - request?: protos.google.cloud.networkservices.v1.IUpdateLbEdgeExtensionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IUpdateLbEdgeExtensionRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.ILbEdgeExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateLbEdgeExtension( - request: protos.google.cloud.networkservices.v1.IUpdateLbEdgeExtensionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IUpdateLbEdgeExtensionRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.ILbEdgeExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateLbEdgeExtension( - request: protos.google.cloud.networkservices.v1.IUpdateLbEdgeExtensionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IUpdateLbEdgeExtensionRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.ILbEdgeExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateLbEdgeExtension( - request?: protos.google.cloud.networkservices.v1.IUpdateLbEdgeExtensionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.IUpdateLbEdgeExtensionRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.ILbEdgeExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1.ILbEdgeExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.ILbEdgeExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'lb_edge_extension.name': request.lbEdgeExtension!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'lb_edge_extension.name': request.lbEdgeExtension!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.ILbEdgeExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateLbEdgeExtension response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateLbEdgeExtension request %j', request); - return this.innerApiCalls.updateLbEdgeExtension(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateLbEdgeExtension response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateLbEdgeExtension(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1.ILbEdgeExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateLbEdgeExtension response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateLbEdgeExtension()`. - * @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/dep_service.update_lb_edge_extension.js - * region_tag:networkservices_v1_generated_DepService_UpdateLbEdgeExtension_async - */ - async checkUpdateLbEdgeExtensionProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateLbEdgeExtension()`. + * @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/dep_service.update_lb_edge_extension.js + * region_tag:networkservices_v1_generated_DepService_UpdateLbEdgeExtension_async + */ + async checkUpdateLbEdgeExtensionProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1.LbEdgeExtension, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('updateLbEdgeExtension long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateLbEdgeExtension, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateLbEdgeExtension, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1.LbEdgeExtension, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Deletes the specified `LbEdgeExtension` resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the `LbEdgeExtension` resource to delete. Must be in - * the format - * `projects/{project}/locations/{location}/lbEdgeExtensions/{lb_edge_extension}`. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server can ignore - * the request if it has already been completed. The server guarantees - * that for 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server ignores the second request This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/dep_service.delete_lb_edge_extension.js - * region_tag:networkservices_v1_generated_DepService_DeleteLbEdgeExtension_async - */ + /** + * Deletes the specified `LbEdgeExtension` resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the `LbEdgeExtension` resource to delete. Must be in + * the format + * `projects/{project}/locations/{location}/lbEdgeExtensions/{lb_edge_extension}`. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server can ignore + * the request if it has already been completed. The server guarantees + * that for 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server ignores the second request This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/dep_service.delete_lb_edge_extension.js + * region_tag:networkservices_v1_generated_DepService_DeleteLbEdgeExtension_async + */ deleteLbEdgeExtension( - request?: protos.google.cloud.networkservices.v1.IDeleteLbEdgeExtensionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IDeleteLbEdgeExtensionRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteLbEdgeExtension( - request: protos.google.cloud.networkservices.v1.IDeleteLbEdgeExtensionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IDeleteLbEdgeExtensionRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteLbEdgeExtension( - request: protos.google.cloud.networkservices.v1.IDeleteLbEdgeExtensionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IDeleteLbEdgeExtensionRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteLbEdgeExtension( - request?: protos.google.cloud.networkservices.v1.IDeleteLbEdgeExtensionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.IDeleteLbEdgeExtensionRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteLbEdgeExtension response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteLbEdgeExtension request %j', request); - return this.innerApiCalls.deleteLbEdgeExtension(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteLbEdgeExtension response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteLbEdgeExtension(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteLbEdgeExtension response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteLbEdgeExtension()`. - * @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/dep_service.delete_lb_edge_extension.js - * region_tag:networkservices_v1_generated_DepService_DeleteLbEdgeExtension_async - */ - async checkDeleteLbEdgeExtensionProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteLbEdgeExtension()`. + * @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/dep_service.delete_lb_edge_extension.js + * region_tag:networkservices_v1_generated_DepService_DeleteLbEdgeExtension_async + */ + async checkDeleteLbEdgeExtensionProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('deleteLbEdgeExtension long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteLbEdgeExtension, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteLbEdgeExtension, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Creates a new `AuthzExtension` resource in a given project - * and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the `AuthzExtension` resource. Must - * be in the format `projects/{project}/locations/{location}`. - * @param {string} request.authzExtensionId - * Required. User-provided ID of the `AuthzExtension` resource to be - * created. - * @param {google.cloud.networkservices.v1.AuthzExtension} request.authzExtension - * Required. `AuthzExtension` resource to be created. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server can ignore - * the request if it has already been completed. The server guarantees - * that for 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server ignores the second request This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/dep_service.create_authz_extension.js - * region_tag:networkservices_v1_generated_DepService_CreateAuthzExtension_async - */ + /** + * Creates a new `AuthzExtension` resource in a given project + * and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the `AuthzExtension` resource. Must + * be in the format `projects/{project}/locations/{location}`. + * @param {string} request.authzExtensionId + * Required. User-provided ID of the `AuthzExtension` resource to be + * created. + * @param {google.cloud.networkservices.v1.AuthzExtension} request.authzExtension + * Required. `AuthzExtension` resource to be created. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server can ignore + * the request if it has already been completed. The server guarantees + * that for 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server ignores the second request This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/dep_service.create_authz_extension.js + * region_tag:networkservices_v1_generated_DepService_CreateAuthzExtension_async + */ createAuthzExtension( - request?: protos.google.cloud.networkservices.v1.ICreateAuthzExtensionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.ICreateAuthzExtensionRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IAuthzExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createAuthzExtension( - request: protos.google.cloud.networkservices.v1.ICreateAuthzExtensionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.ICreateAuthzExtensionRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IAuthzExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createAuthzExtension( - request: protos.google.cloud.networkservices.v1.ICreateAuthzExtensionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.ICreateAuthzExtensionRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IAuthzExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createAuthzExtension( - request?: protos.google.cloud.networkservices.v1.ICreateAuthzExtensionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.ICreateAuthzExtensionRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IAuthzExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IAuthzExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IAuthzExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IAuthzExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createAuthzExtension response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createAuthzExtension request %j', request); - return this.innerApiCalls.createAuthzExtension(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createAuthzExtension response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createAuthzExtension(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1.IAuthzExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createAuthzExtension response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createAuthzExtension()`. - * @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/dep_service.create_authz_extension.js - * region_tag:networkservices_v1_generated_DepService_CreateAuthzExtension_async - */ - async checkCreateAuthzExtensionProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createAuthzExtension()`. + * @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/dep_service.create_authz_extension.js + * region_tag:networkservices_v1_generated_DepService_CreateAuthzExtension_async + */ + async checkCreateAuthzExtensionProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1.AuthzExtension, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('createAuthzExtension long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createAuthzExtension, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createAuthzExtension, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1.AuthzExtension, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Updates the parameters of the specified `AuthzExtension` - * resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Used to specify the fields to be overwritten in the - * `AuthzExtension` resource by the update. - * The fields specified in the `update_mask` are relative to the resource, not - * the full request. A field is overwritten if it is in the mask. If the - * user does not specify a mask, then all fields are overwritten. - * @param {google.cloud.networkservices.v1.AuthzExtension} request.authzExtension - * Required. `AuthzExtension` resource being updated. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server can ignore - * the request if it has already been completed. The server guarantees - * that for 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server ignores the second request This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/dep_service.update_authz_extension.js - * region_tag:networkservices_v1_generated_DepService_UpdateAuthzExtension_async - */ + /** + * Updates the parameters of the specified `AuthzExtension` + * resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Used to specify the fields to be overwritten in the + * `AuthzExtension` resource by the update. + * The fields specified in the `update_mask` are relative to the resource, not + * the full request. A field is overwritten if it is in the mask. If the + * user does not specify a mask, then all fields are overwritten. + * @param {google.cloud.networkservices.v1.AuthzExtension} request.authzExtension + * Required. `AuthzExtension` resource being updated. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server can ignore + * the request if it has already been completed. The server guarantees + * that for 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server ignores the second request This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/dep_service.update_authz_extension.js + * region_tag:networkservices_v1_generated_DepService_UpdateAuthzExtension_async + */ updateAuthzExtension( - request?: protos.google.cloud.networkservices.v1.IUpdateAuthzExtensionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IUpdateAuthzExtensionRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IAuthzExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateAuthzExtension( - request: protos.google.cloud.networkservices.v1.IUpdateAuthzExtensionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IUpdateAuthzExtensionRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IAuthzExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateAuthzExtension( - request: protos.google.cloud.networkservices.v1.IUpdateAuthzExtensionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IUpdateAuthzExtensionRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IAuthzExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateAuthzExtension( - request?: protos.google.cloud.networkservices.v1.IUpdateAuthzExtensionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.IUpdateAuthzExtensionRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IAuthzExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IAuthzExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IAuthzExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'authz_extension.name': request.authzExtension!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'authz_extension.name': request.authzExtension!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IAuthzExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateAuthzExtension response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateAuthzExtension request %j', request); - return this.innerApiCalls.updateAuthzExtension(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateAuthzExtension response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateAuthzExtension(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1.IAuthzExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateAuthzExtension response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateAuthzExtension()`. - * @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/dep_service.update_authz_extension.js - * region_tag:networkservices_v1_generated_DepService_UpdateAuthzExtension_async - */ - async checkUpdateAuthzExtensionProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateAuthzExtension()`. + * @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/dep_service.update_authz_extension.js + * region_tag:networkservices_v1_generated_DepService_UpdateAuthzExtension_async + */ + async checkUpdateAuthzExtensionProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1.AuthzExtension, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('updateAuthzExtension long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateAuthzExtension, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateAuthzExtension, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1.AuthzExtension, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Deletes the specified `AuthzExtension` resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the `AuthzExtension` resource to delete. Must - * be in the format - * `projects/{project}/locations/{location}/authzExtensions/{authz_extension}`. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server can ignore - * the request if it has already been completed. The server guarantees - * that for 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server ignores the second request This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/dep_service.delete_authz_extension.js - * region_tag:networkservices_v1_generated_DepService_DeleteAuthzExtension_async - */ + /** + * Deletes the specified `AuthzExtension` resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the `AuthzExtension` resource to delete. Must + * be in the format + * `projects/{project}/locations/{location}/authzExtensions/{authz_extension}`. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server can ignore + * the request if it has already been completed. The server guarantees + * that for 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server ignores the second request This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/dep_service.delete_authz_extension.js + * region_tag:networkservices_v1_generated_DepService_DeleteAuthzExtension_async + */ deleteAuthzExtension( - request?: protos.google.cloud.networkservices.v1.IDeleteAuthzExtensionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IDeleteAuthzExtensionRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteAuthzExtension( - request: protos.google.cloud.networkservices.v1.IDeleteAuthzExtensionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IDeleteAuthzExtensionRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteAuthzExtension( - request: protos.google.cloud.networkservices.v1.IDeleteAuthzExtensionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IDeleteAuthzExtensionRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteAuthzExtension( - request?: protos.google.cloud.networkservices.v1.IDeleteAuthzExtensionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.IDeleteAuthzExtensionRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteAuthzExtension response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteAuthzExtension request %j', request); - return this.innerApiCalls.deleteAuthzExtension(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteAuthzExtension response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteAuthzExtension(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteAuthzExtension response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteAuthzExtension()`. - * @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/dep_service.delete_authz_extension.js - * region_tag:networkservices_v1_generated_DepService_DeleteAuthzExtension_async - */ - async checkDeleteAuthzExtensionProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteAuthzExtension()`. + * @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/dep_service.delete_authz_extension.js + * region_tag:networkservices_v1_generated_DepService_DeleteAuthzExtension_async + */ + async checkDeleteAuthzExtensionProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('deleteAuthzExtension long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteAuthzExtension, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists `LbTrafficExtension` resources in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the `LbTrafficExtension` - * resources are listed. These values are specified in the following format: - * `projects/{project}/locations/{location}`. - * @param {number} [request.pageSize] - * Optional. Requested page size. The server might return fewer items than - * requested. If unspecified, the server picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results that the server returns. - * @param {string} [request.filter] - * Optional. Filtering results. - * @param {string} [request.orderBy] - * Optional. Hint about how to order the results. - * @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 Array of {@link protos.google.cloud.networkservices.v1.LbTrafficExtension|LbTrafficExtension}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listLbTrafficExtensionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteAuthzExtension, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1.OperationMetadata + >; + } + /** + * Lists `LbTrafficExtension` resources in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the `LbTrafficExtension` + * resources are listed. These values are specified in the following format: + * `projects/{project}/locations/{location}`. + * @param {number} [request.pageSize] + * Optional. Requested page size. The server might return fewer items than + * requested. If unspecified, the server picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results that the server returns. + * @param {string} [request.filter] + * Optional. Filtering results. + * @param {string} [request.orderBy] + * Optional. Hint about how to order the results. + * @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 Array of {@link protos.google.cloud.networkservices.v1.LbTrafficExtension|LbTrafficExtension}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listLbTrafficExtensionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listLbTrafficExtensions( - request?: protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.ILbTrafficExtension[], - protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsRequest|null, - protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsResponse - ]>; + request?: protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.ILbTrafficExtension[], + protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsRequest | null, + protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsResponse, + ] + >; listLbTrafficExtensions( - request: protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsRequest, - protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsResponse|null|undefined, - protos.google.cloud.networkservices.v1.ILbTrafficExtension>): void; + request: protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsRequest, + | protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.ILbTrafficExtension + >, + ): void; listLbTrafficExtensions( - request: protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsRequest, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsRequest, - protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsResponse|null|undefined, - protos.google.cloud.networkservices.v1.ILbTrafficExtension>): void; + request: protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsRequest, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsRequest, + | protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.ILbTrafficExtension + >, + ): void; listLbTrafficExtensions( - request?: protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsRequest, - protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsResponse|null|undefined, - protos.google.cloud.networkservices.v1.ILbTrafficExtension>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsRequest, - protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsResponse|null|undefined, - protos.google.cloud.networkservices.v1.ILbTrafficExtension>): - Promise<[ - protos.google.cloud.networkservices.v1.ILbTrafficExtension[], - protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsRequest|null, - protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsResponse - ]>|void { + | protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.ILbTrafficExtension + >, + callback?: PaginationCallback< + protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsRequest, + | protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.ILbTrafficExtension + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.ILbTrafficExtension[], + protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsRequest | null, + protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsRequest, - protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsResponse|null|undefined, - protos.google.cloud.networkservices.v1.ILbTrafficExtension>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsRequest, + | protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.ILbTrafficExtension + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listLbTrafficExtensions values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2502,210 +3732,239 @@ export class DepServiceClient { this._log.info('listLbTrafficExtensions request %j', request); return this.innerApiCalls .listLbTrafficExtensions(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkservices.v1.ILbTrafficExtension[], - protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsRequest|null, - protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsResponse - ]) => { - this._log.info('listLbTrafficExtensions values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkservices.v1.ILbTrafficExtension[], + protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsRequest | null, + protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsResponse, + ]) => { + this._log.info('listLbTrafficExtensions values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listLbTrafficExtensions`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the `LbTrafficExtension` - * resources are listed. These values are specified in the following format: - * `projects/{project}/locations/{location}`. - * @param {number} [request.pageSize] - * Optional. Requested page size. The server might return fewer items than - * requested. If unspecified, the server picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results that the server returns. - * @param {string} [request.filter] - * Optional. Filtering results. - * @param {string} [request.orderBy] - * Optional. Hint about how to order the results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.LbTrafficExtension|LbTrafficExtension} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listLbTrafficExtensionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listLbTrafficExtensions`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the `LbTrafficExtension` + * resources are listed. These values are specified in the following format: + * `projects/{project}/locations/{location}`. + * @param {number} [request.pageSize] + * Optional. Requested page size. The server might return fewer items than + * requested. If unspecified, the server picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results that the server returns. + * @param {string} [request.filter] + * Optional. Filtering results. + * @param {string} [request.orderBy] + * Optional. Hint about how to order the results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.LbTrafficExtension|LbTrafficExtension} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listLbTrafficExtensionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listLbTrafficExtensionsStream( - request?: protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listLbTrafficExtensions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listLbTrafficExtensions stream %j', request); return this.descriptors.page.listLbTrafficExtensions.createStream( this.innerApiCalls.listLbTrafficExtensions as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listLbTrafficExtensions`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the `LbTrafficExtension` - * resources are listed. These values are specified in the following format: - * `projects/{project}/locations/{location}`. - * @param {number} [request.pageSize] - * Optional. Requested page size. The server might return fewer items than - * requested. If unspecified, the server picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results that the server returns. - * @param {string} [request.filter] - * Optional. Filtering results. - * @param {string} [request.orderBy] - * Optional. Hint about how to order the results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkservices.v1.LbTrafficExtension|LbTrafficExtension}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/dep_service.list_lb_traffic_extensions.js - * region_tag:networkservices_v1_generated_DepService_ListLbTrafficExtensions_async - */ + /** + * Equivalent to `listLbTrafficExtensions`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the `LbTrafficExtension` + * resources are listed. These values are specified in the following format: + * `projects/{project}/locations/{location}`. + * @param {number} [request.pageSize] + * Optional. Requested page size. The server might return fewer items than + * requested. If unspecified, the server picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results that the server returns. + * @param {string} [request.filter] + * Optional. Filtering results. + * @param {string} [request.orderBy] + * Optional. Hint about how to order the results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkservices.v1.LbTrafficExtension|LbTrafficExtension}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/dep_service.list_lb_traffic_extensions.js + * region_tag:networkservices_v1_generated_DepService_ListLbTrafficExtensions_async + */ listLbTrafficExtensionsAsync( - request?: protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkservices.v1.IListLbTrafficExtensionsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listLbTrafficExtensions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listLbTrafficExtensions iterate %j', request); return this.descriptors.page.listLbTrafficExtensions.asyncIterate( this.innerApiCalls['listLbTrafficExtensions'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists `LbRouteExtension` resources in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the `LbRouteExtension` - * resources are listed. These values are specified in the following format: - * `projects/{project}/locations/{location}`. - * @param {number} [request.pageSize] - * Optional. Requested page size. The server might return fewer items than - * requested. If unspecified, the server picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results that the server returns. - * @param {string} [request.filter] - * Optional. Filtering results. - * @param {string} [request.orderBy] - * Optional. Hint about how to order the results. - * @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 Array of {@link protos.google.cloud.networkservices.v1.LbRouteExtension|LbRouteExtension}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listLbRouteExtensionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists `LbRouteExtension` resources in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the `LbRouteExtension` + * resources are listed. These values are specified in the following format: + * `projects/{project}/locations/{location}`. + * @param {number} [request.pageSize] + * Optional. Requested page size. The server might return fewer items than + * requested. If unspecified, the server picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results that the server returns. + * @param {string} [request.filter] + * Optional. Filtering results. + * @param {string} [request.orderBy] + * Optional. Hint about how to order the results. + * @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 Array of {@link protos.google.cloud.networkservices.v1.LbRouteExtension|LbRouteExtension}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listLbRouteExtensionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listLbRouteExtensions( - request?: protos.google.cloud.networkservices.v1.IListLbRouteExtensionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.ILbRouteExtension[], - protos.google.cloud.networkservices.v1.IListLbRouteExtensionsRequest|null, - protos.google.cloud.networkservices.v1.IListLbRouteExtensionsResponse - ]>; + request?: protos.google.cloud.networkservices.v1.IListLbRouteExtensionsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.ILbRouteExtension[], + protos.google.cloud.networkservices.v1.IListLbRouteExtensionsRequest | null, + protos.google.cloud.networkservices.v1.IListLbRouteExtensionsResponse, + ] + >; listLbRouteExtensions( - request: protos.google.cloud.networkservices.v1.IListLbRouteExtensionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListLbRouteExtensionsRequest, - protos.google.cloud.networkservices.v1.IListLbRouteExtensionsResponse|null|undefined, - protos.google.cloud.networkservices.v1.ILbRouteExtension>): void; + request: protos.google.cloud.networkservices.v1.IListLbRouteExtensionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListLbRouteExtensionsRequest, + | protos.google.cloud.networkservices.v1.IListLbRouteExtensionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.ILbRouteExtension + >, + ): void; listLbRouteExtensions( - request: protos.google.cloud.networkservices.v1.IListLbRouteExtensionsRequest, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListLbRouteExtensionsRequest, - protos.google.cloud.networkservices.v1.IListLbRouteExtensionsResponse|null|undefined, - protos.google.cloud.networkservices.v1.ILbRouteExtension>): void; + request: protos.google.cloud.networkservices.v1.IListLbRouteExtensionsRequest, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListLbRouteExtensionsRequest, + | protos.google.cloud.networkservices.v1.IListLbRouteExtensionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.ILbRouteExtension + >, + ): void; listLbRouteExtensions( - request?: protos.google.cloud.networkservices.v1.IListLbRouteExtensionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkservices.v1.IListLbRouteExtensionsRequest, - protos.google.cloud.networkservices.v1.IListLbRouteExtensionsResponse|null|undefined, - protos.google.cloud.networkservices.v1.ILbRouteExtension>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkservices.v1.IListLbRouteExtensionsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkservices.v1.IListLbRouteExtensionsRequest, - protos.google.cloud.networkservices.v1.IListLbRouteExtensionsResponse|null|undefined, - protos.google.cloud.networkservices.v1.ILbRouteExtension>): - Promise<[ - protos.google.cloud.networkservices.v1.ILbRouteExtension[], - protos.google.cloud.networkservices.v1.IListLbRouteExtensionsRequest|null, - protos.google.cloud.networkservices.v1.IListLbRouteExtensionsResponse - ]>|void { + | protos.google.cloud.networkservices.v1.IListLbRouteExtensionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.ILbRouteExtension + >, + callback?: PaginationCallback< + protos.google.cloud.networkservices.v1.IListLbRouteExtensionsRequest, + | protos.google.cloud.networkservices.v1.IListLbRouteExtensionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.ILbRouteExtension + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.ILbRouteExtension[], + protos.google.cloud.networkservices.v1.IListLbRouteExtensionsRequest | null, + protos.google.cloud.networkservices.v1.IListLbRouteExtensionsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListLbRouteExtensionsRequest, - protos.google.cloud.networkservices.v1.IListLbRouteExtensionsResponse|null|undefined, - protos.google.cloud.networkservices.v1.ILbRouteExtension>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkservices.v1.IListLbRouteExtensionsRequest, + | protos.google.cloud.networkservices.v1.IListLbRouteExtensionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.ILbRouteExtension + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listLbRouteExtensions values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2714,210 +3973,239 @@ export class DepServiceClient { this._log.info('listLbRouteExtensions request %j', request); return this.innerApiCalls .listLbRouteExtensions(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkservices.v1.ILbRouteExtension[], - protos.google.cloud.networkservices.v1.IListLbRouteExtensionsRequest|null, - protos.google.cloud.networkservices.v1.IListLbRouteExtensionsResponse - ]) => { - this._log.info('listLbRouteExtensions values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkservices.v1.ILbRouteExtension[], + protos.google.cloud.networkservices.v1.IListLbRouteExtensionsRequest | null, + protos.google.cloud.networkservices.v1.IListLbRouteExtensionsResponse, + ]) => { + this._log.info('listLbRouteExtensions values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listLbRouteExtensions`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the `LbRouteExtension` - * resources are listed. These values are specified in the following format: - * `projects/{project}/locations/{location}`. - * @param {number} [request.pageSize] - * Optional. Requested page size. The server might return fewer items than - * requested. If unspecified, the server picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results that the server returns. - * @param {string} [request.filter] - * Optional. Filtering results. - * @param {string} [request.orderBy] - * Optional. Hint about how to order the results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.LbRouteExtension|LbRouteExtension} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listLbRouteExtensionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listLbRouteExtensions`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the `LbRouteExtension` + * resources are listed. These values are specified in the following format: + * `projects/{project}/locations/{location}`. + * @param {number} [request.pageSize] + * Optional. Requested page size. The server might return fewer items than + * requested. If unspecified, the server picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results that the server returns. + * @param {string} [request.filter] + * Optional. Filtering results. + * @param {string} [request.orderBy] + * Optional. Hint about how to order the results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.LbRouteExtension|LbRouteExtension} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listLbRouteExtensionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listLbRouteExtensionsStream( - request?: protos.google.cloud.networkservices.v1.IListLbRouteExtensionsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkservices.v1.IListLbRouteExtensionsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listLbRouteExtensions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listLbRouteExtensions stream %j', request); return this.descriptors.page.listLbRouteExtensions.createStream( this.innerApiCalls.listLbRouteExtensions as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listLbRouteExtensions`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the `LbRouteExtension` - * resources are listed. These values are specified in the following format: - * `projects/{project}/locations/{location}`. - * @param {number} [request.pageSize] - * Optional. Requested page size. The server might return fewer items than - * requested. If unspecified, the server picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results that the server returns. - * @param {string} [request.filter] - * Optional. Filtering results. - * @param {string} [request.orderBy] - * Optional. Hint about how to order the results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkservices.v1.LbRouteExtension|LbRouteExtension}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/dep_service.list_lb_route_extensions.js - * region_tag:networkservices_v1_generated_DepService_ListLbRouteExtensions_async - */ + /** + * Equivalent to `listLbRouteExtensions`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the `LbRouteExtension` + * resources are listed. These values are specified in the following format: + * `projects/{project}/locations/{location}`. + * @param {number} [request.pageSize] + * Optional. Requested page size. The server might return fewer items than + * requested. If unspecified, the server picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results that the server returns. + * @param {string} [request.filter] + * Optional. Filtering results. + * @param {string} [request.orderBy] + * Optional. Hint about how to order the results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkservices.v1.LbRouteExtension|LbRouteExtension}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/dep_service.list_lb_route_extensions.js + * region_tag:networkservices_v1_generated_DepService_ListLbRouteExtensions_async + */ listLbRouteExtensionsAsync( - request?: protos.google.cloud.networkservices.v1.IListLbRouteExtensionsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkservices.v1.IListLbRouteExtensionsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listLbRouteExtensions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listLbRouteExtensions iterate %j', request); return this.descriptors.page.listLbRouteExtensions.asyncIterate( this.innerApiCalls['listLbRouteExtensions'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists `LbEdgeExtension` resources in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the `LbEdgeExtension` - * resources are listed. These values are specified in the following format: - * `projects/{project}/locations/{location}`. - * @param {number} [request.pageSize] - * Optional. Requested page size. The server might return fewer items than - * requested. If unspecified, the server picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results that the server returns. - * @param {string} [request.filter] - * Optional. Filtering results. - * @param {string} [request.orderBy] - * Optional. Hint about how to order the results. - * @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 Array of {@link protos.google.cloud.networkservices.v1.LbEdgeExtension|LbEdgeExtension}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listLbEdgeExtensionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists `LbEdgeExtension` resources in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the `LbEdgeExtension` + * resources are listed. These values are specified in the following format: + * `projects/{project}/locations/{location}`. + * @param {number} [request.pageSize] + * Optional. Requested page size. The server might return fewer items than + * requested. If unspecified, the server picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results that the server returns. + * @param {string} [request.filter] + * Optional. Filtering results. + * @param {string} [request.orderBy] + * Optional. Hint about how to order the results. + * @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 Array of {@link protos.google.cloud.networkservices.v1.LbEdgeExtension|LbEdgeExtension}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listLbEdgeExtensionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listLbEdgeExtensions( - request?: protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.ILbEdgeExtension[], - protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsRequest|null, - protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsResponse - ]>; + request?: protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.ILbEdgeExtension[], + protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsRequest | null, + protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsResponse, + ] + >; listLbEdgeExtensions( - request: protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsRequest, - protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsResponse|null|undefined, - protos.google.cloud.networkservices.v1.ILbEdgeExtension>): void; + request: protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsRequest, + | protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.ILbEdgeExtension + >, + ): void; listLbEdgeExtensions( - request: protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsRequest, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsRequest, - protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsResponse|null|undefined, - protos.google.cloud.networkservices.v1.ILbEdgeExtension>): void; + request: protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsRequest, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsRequest, + | protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.ILbEdgeExtension + >, + ): void; listLbEdgeExtensions( - request?: protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsRequest, - protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsResponse|null|undefined, - protos.google.cloud.networkservices.v1.ILbEdgeExtension>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsRequest, - protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsResponse|null|undefined, - protos.google.cloud.networkservices.v1.ILbEdgeExtension>): - Promise<[ - protos.google.cloud.networkservices.v1.ILbEdgeExtension[], - protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsRequest|null, - protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsResponse - ]>|void { + | protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.ILbEdgeExtension + >, + callback?: PaginationCallback< + protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsRequest, + | protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.ILbEdgeExtension + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.ILbEdgeExtension[], + protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsRequest | null, + protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsRequest, - protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsResponse|null|undefined, - protos.google.cloud.networkservices.v1.ILbEdgeExtension>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsRequest, + | protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.ILbEdgeExtension + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listLbEdgeExtensions values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2926,210 +4214,239 @@ export class DepServiceClient { this._log.info('listLbEdgeExtensions request %j', request); return this.innerApiCalls .listLbEdgeExtensions(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkservices.v1.ILbEdgeExtension[], - protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsRequest|null, - protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsResponse - ]) => { - this._log.info('listLbEdgeExtensions values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkservices.v1.ILbEdgeExtension[], + protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsRequest | null, + protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsResponse, + ]) => { + this._log.info('listLbEdgeExtensions values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listLbEdgeExtensions`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the `LbEdgeExtension` - * resources are listed. These values are specified in the following format: - * `projects/{project}/locations/{location}`. - * @param {number} [request.pageSize] - * Optional. Requested page size. The server might return fewer items than - * requested. If unspecified, the server picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results that the server returns. - * @param {string} [request.filter] - * Optional. Filtering results. - * @param {string} [request.orderBy] - * Optional. Hint about how to order the results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.LbEdgeExtension|LbEdgeExtension} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listLbEdgeExtensionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listLbEdgeExtensions`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the `LbEdgeExtension` + * resources are listed. These values are specified in the following format: + * `projects/{project}/locations/{location}`. + * @param {number} [request.pageSize] + * Optional. Requested page size. The server might return fewer items than + * requested. If unspecified, the server picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results that the server returns. + * @param {string} [request.filter] + * Optional. Filtering results. + * @param {string} [request.orderBy] + * Optional. Hint about how to order the results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.LbEdgeExtension|LbEdgeExtension} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listLbEdgeExtensionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listLbEdgeExtensionsStream( - request?: protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listLbEdgeExtensions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listLbEdgeExtensions stream %j', request); return this.descriptors.page.listLbEdgeExtensions.createStream( this.innerApiCalls.listLbEdgeExtensions as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listLbEdgeExtensions`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the `LbEdgeExtension` - * resources are listed. These values are specified in the following format: - * `projects/{project}/locations/{location}`. - * @param {number} [request.pageSize] - * Optional. Requested page size. The server might return fewer items than - * requested. If unspecified, the server picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results that the server returns. - * @param {string} [request.filter] - * Optional. Filtering results. - * @param {string} [request.orderBy] - * Optional. Hint about how to order the results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkservices.v1.LbEdgeExtension|LbEdgeExtension}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/dep_service.list_lb_edge_extensions.js - * region_tag:networkservices_v1_generated_DepService_ListLbEdgeExtensions_async - */ + /** + * Equivalent to `listLbEdgeExtensions`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the `LbEdgeExtension` + * resources are listed. These values are specified in the following format: + * `projects/{project}/locations/{location}`. + * @param {number} [request.pageSize] + * Optional. Requested page size. The server might return fewer items than + * requested. If unspecified, the server picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results that the server returns. + * @param {string} [request.filter] + * Optional. Filtering results. + * @param {string} [request.orderBy] + * Optional. Hint about how to order the results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkservices.v1.LbEdgeExtension|LbEdgeExtension}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/dep_service.list_lb_edge_extensions.js + * region_tag:networkservices_v1_generated_DepService_ListLbEdgeExtensions_async + */ listLbEdgeExtensionsAsync( - request?: protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkservices.v1.IListLbEdgeExtensionsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listLbEdgeExtensions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listLbEdgeExtensions iterate %j', request); return this.descriptors.page.listLbEdgeExtensions.asyncIterate( this.innerApiCalls['listLbEdgeExtensions'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists `AuthzExtension` resources in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the `AuthzExtension` - * resources are listed. These values are specified in the following format: - * `projects/{project}/locations/{location}`. - * @param {number} [request.pageSize] - * Optional. Requested page size. The server might return fewer items than - * requested. If unspecified, the server picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results that the server returns. - * @param {string} [request.filter] - * Optional. Filtering results. - * @param {string} [request.orderBy] - * Optional. Hint about how to order the results. - * @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 Array of {@link protos.google.cloud.networkservices.v1.AuthzExtension|AuthzExtension}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listAuthzExtensionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists `AuthzExtension` resources in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the `AuthzExtension` + * resources are listed. These values are specified in the following format: + * `projects/{project}/locations/{location}`. + * @param {number} [request.pageSize] + * Optional. Requested page size. The server might return fewer items than + * requested. If unspecified, the server picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results that the server returns. + * @param {string} [request.filter] + * Optional. Filtering results. + * @param {string} [request.orderBy] + * Optional. Hint about how to order the results. + * @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 Array of {@link protos.google.cloud.networkservices.v1.AuthzExtension|AuthzExtension}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listAuthzExtensionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listAuthzExtensions( - request?: protos.google.cloud.networkservices.v1.IListAuthzExtensionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.IAuthzExtension[], - protos.google.cloud.networkservices.v1.IListAuthzExtensionsRequest|null, - protos.google.cloud.networkservices.v1.IListAuthzExtensionsResponse - ]>; + request?: protos.google.cloud.networkservices.v1.IListAuthzExtensionsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IAuthzExtension[], + protos.google.cloud.networkservices.v1.IListAuthzExtensionsRequest | null, + protos.google.cloud.networkservices.v1.IListAuthzExtensionsResponse, + ] + >; listAuthzExtensions( - request: protos.google.cloud.networkservices.v1.IListAuthzExtensionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListAuthzExtensionsRequest, - protos.google.cloud.networkservices.v1.IListAuthzExtensionsResponse|null|undefined, - protos.google.cloud.networkservices.v1.IAuthzExtension>): void; + request: protos.google.cloud.networkservices.v1.IListAuthzExtensionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListAuthzExtensionsRequest, + | protos.google.cloud.networkservices.v1.IListAuthzExtensionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IAuthzExtension + >, + ): void; listAuthzExtensions( - request: protos.google.cloud.networkservices.v1.IListAuthzExtensionsRequest, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListAuthzExtensionsRequest, - protos.google.cloud.networkservices.v1.IListAuthzExtensionsResponse|null|undefined, - protos.google.cloud.networkservices.v1.IAuthzExtension>): void; + request: protos.google.cloud.networkservices.v1.IListAuthzExtensionsRequest, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListAuthzExtensionsRequest, + | protos.google.cloud.networkservices.v1.IListAuthzExtensionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IAuthzExtension + >, + ): void; listAuthzExtensions( - request?: protos.google.cloud.networkservices.v1.IListAuthzExtensionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkservices.v1.IListAuthzExtensionsRequest, - protos.google.cloud.networkservices.v1.IListAuthzExtensionsResponse|null|undefined, - protos.google.cloud.networkservices.v1.IAuthzExtension>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkservices.v1.IListAuthzExtensionsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkservices.v1.IListAuthzExtensionsRequest, - protos.google.cloud.networkservices.v1.IListAuthzExtensionsResponse|null|undefined, - protos.google.cloud.networkservices.v1.IAuthzExtension>): - Promise<[ - protos.google.cloud.networkservices.v1.IAuthzExtension[], - protos.google.cloud.networkservices.v1.IListAuthzExtensionsRequest|null, - protos.google.cloud.networkservices.v1.IListAuthzExtensionsResponse - ]>|void { + | protos.google.cloud.networkservices.v1.IListAuthzExtensionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IAuthzExtension + >, + callback?: PaginationCallback< + protos.google.cloud.networkservices.v1.IListAuthzExtensionsRequest, + | protos.google.cloud.networkservices.v1.IListAuthzExtensionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IAuthzExtension + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IAuthzExtension[], + protos.google.cloud.networkservices.v1.IListAuthzExtensionsRequest | null, + protos.google.cloud.networkservices.v1.IListAuthzExtensionsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListAuthzExtensionsRequest, - protos.google.cloud.networkservices.v1.IListAuthzExtensionsResponse|null|undefined, - protos.google.cloud.networkservices.v1.IAuthzExtension>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkservices.v1.IListAuthzExtensionsRequest, + | protos.google.cloud.networkservices.v1.IListAuthzExtensionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IAuthzExtension + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listAuthzExtensions values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -3138,147 +4455,151 @@ export class DepServiceClient { this._log.info('listAuthzExtensions request %j', request); return this.innerApiCalls .listAuthzExtensions(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkservices.v1.IAuthzExtension[], - protos.google.cloud.networkservices.v1.IListAuthzExtensionsRequest|null, - protos.google.cloud.networkservices.v1.IListAuthzExtensionsResponse - ]) => { - this._log.info('listAuthzExtensions values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkservices.v1.IAuthzExtension[], + protos.google.cloud.networkservices.v1.IListAuthzExtensionsRequest | null, + protos.google.cloud.networkservices.v1.IListAuthzExtensionsResponse, + ]) => { + this._log.info('listAuthzExtensions values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listAuthzExtensions`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the `AuthzExtension` - * resources are listed. These values are specified in the following format: - * `projects/{project}/locations/{location}`. - * @param {number} [request.pageSize] - * Optional. Requested page size. The server might return fewer items than - * requested. If unspecified, the server picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results that the server returns. - * @param {string} [request.filter] - * Optional. Filtering results. - * @param {string} [request.orderBy] - * Optional. Hint about how to order the results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.AuthzExtension|AuthzExtension} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listAuthzExtensionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listAuthzExtensions`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the `AuthzExtension` + * resources are listed. These values are specified in the following format: + * `projects/{project}/locations/{location}`. + * @param {number} [request.pageSize] + * Optional. Requested page size. The server might return fewer items than + * requested. If unspecified, the server picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results that the server returns. + * @param {string} [request.filter] + * Optional. Filtering results. + * @param {string} [request.orderBy] + * Optional. Hint about how to order the results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.AuthzExtension|AuthzExtension} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listAuthzExtensionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listAuthzExtensionsStream( - request?: protos.google.cloud.networkservices.v1.IListAuthzExtensionsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkservices.v1.IListAuthzExtensionsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listAuthzExtensions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listAuthzExtensions stream %j', request); return this.descriptors.page.listAuthzExtensions.createStream( this.innerApiCalls.listAuthzExtensions as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listAuthzExtensions`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the `AuthzExtension` - * resources are listed. These values are specified in the following format: - * `projects/{project}/locations/{location}`. - * @param {number} [request.pageSize] - * Optional. Requested page size. The server might return fewer items than - * requested. If unspecified, the server picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results that the server returns. - * @param {string} [request.filter] - * Optional. Filtering results. - * @param {string} [request.orderBy] - * Optional. Hint about how to order the results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkservices.v1.AuthzExtension|AuthzExtension}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/dep_service.list_authz_extensions.js - * region_tag:networkservices_v1_generated_DepService_ListAuthzExtensions_async - */ + /** + * Equivalent to `listAuthzExtensions`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the `AuthzExtension` + * resources are listed. These values are specified in the following format: + * `projects/{project}/locations/{location}`. + * @param {number} [request.pageSize] + * Optional. Requested page size. The server might return fewer items than + * requested. If unspecified, the server picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results that the server returns. + * @param {string} [request.filter] + * Optional. Filtering results. + * @param {string} [request.orderBy] + * Optional. Hint about how to order the results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkservices.v1.AuthzExtension|AuthzExtension}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/dep_service.list_authz_extensions.js + * region_tag:networkservices_v1_generated_DepService_ListAuthzExtensions_async + */ listAuthzExtensionsAsync( - request?: protos.google.cloud.networkservices.v1.IListAuthzExtensionsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkservices.v1.IListAuthzExtensionsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listAuthzExtensions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listAuthzExtensions iterate %j', request); return this.descriptors.page.listAuthzExtensions.asyncIterate( this.innerApiCalls['listAuthzExtensions'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -3292,40 +4613,40 @@ export class DepServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -3339,41 +4660,41 @@ export class DepServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -3387,12 +4708,12 @@ export class DepServiceClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -3427,12 +4748,11 @@ export class DepServiceClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -3465,12 +4785,12 @@ export class DepServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -3513,22 +4833,22 @@ export class DepServiceClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -3563,15 +4883,15 @@ export class DepServiceClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - 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 ?? '', - }); + 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 ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -3605,7 +4925,7 @@ export class DepServiceClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -3618,25 +4938,24 @@ export class DepServiceClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -3675,22 +4994,22 @@ export class DepServiceClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -3706,7 +5025,11 @@ export class DepServiceClient { * @param {string} authz_extension * @returns {string} Resource name string. */ - authzExtensionPath(project:string,location:string,authzExtension:string) { + authzExtensionPath( + project: string, + location: string, + authzExtension: string, + ) { return this.pathTemplates.authzExtensionPathTemplate.render({ project: project, location: location, @@ -3722,7 +5045,9 @@ export class DepServiceClient { * @returns {string} A string representing the project. */ matchProjectFromAuthzExtensionName(authzExtensionName: string) { - return this.pathTemplates.authzExtensionPathTemplate.match(authzExtensionName).project; + return this.pathTemplates.authzExtensionPathTemplate.match( + authzExtensionName, + ).project; } /** @@ -3733,7 +5058,9 @@ export class DepServiceClient { * @returns {string} A string representing the location. */ matchLocationFromAuthzExtensionName(authzExtensionName: string) { - return this.pathTemplates.authzExtensionPathTemplate.match(authzExtensionName).location; + return this.pathTemplates.authzExtensionPathTemplate.match( + authzExtensionName, + ).location; } /** @@ -3744,7 +5071,9 @@ export class DepServiceClient { * @returns {string} A string representing the authz_extension. */ matchAuthzExtensionFromAuthzExtensionName(authzExtensionName: string) { - return this.pathTemplates.authzExtensionPathTemplate.match(authzExtensionName).authz_extension; + return this.pathTemplates.authzExtensionPathTemplate.match( + authzExtensionName, + ).authz_extension; } /** @@ -3755,7 +5084,11 @@ export class DepServiceClient { * @param {string} endpoint_policy * @returns {string} Resource name string. */ - endpointPolicyPath(project:string,location:string,endpointPolicy:string) { + endpointPolicyPath( + project: string, + location: string, + endpointPolicy: string, + ) { return this.pathTemplates.endpointPolicyPathTemplate.render({ project: project, location: location, @@ -3771,7 +5104,9 @@ export class DepServiceClient { * @returns {string} A string representing the project. */ matchProjectFromEndpointPolicyName(endpointPolicyName: string) { - return this.pathTemplates.endpointPolicyPathTemplate.match(endpointPolicyName).project; + return this.pathTemplates.endpointPolicyPathTemplate.match( + endpointPolicyName, + ).project; } /** @@ -3782,7 +5117,9 @@ export class DepServiceClient { * @returns {string} A string representing the location. */ matchLocationFromEndpointPolicyName(endpointPolicyName: string) { - return this.pathTemplates.endpointPolicyPathTemplate.match(endpointPolicyName).location; + return this.pathTemplates.endpointPolicyPathTemplate.match( + endpointPolicyName, + ).location; } /** @@ -3793,7 +5130,9 @@ export class DepServiceClient { * @returns {string} A string representing the endpoint_policy. */ matchEndpointPolicyFromEndpointPolicyName(endpointPolicyName: string) { - return this.pathTemplates.endpointPolicyPathTemplate.match(endpointPolicyName).endpoint_policy; + return this.pathTemplates.endpointPolicyPathTemplate.match( + endpointPolicyName, + ).endpoint_policy; } /** @@ -3804,7 +5143,7 @@ export class DepServiceClient { * @param {string} gateway * @returns {string} Resource name string. */ - gatewayPath(project:string,location:string,gateway:string) { + gatewayPath(project: string, location: string, gateway: string) { return this.pathTemplates.gatewayPathTemplate.render({ project: project, location: location, @@ -3854,7 +5193,12 @@ export class DepServiceClient { * @param {string} route_view * @returns {string} Resource name string. */ - gatewayRouteViewPath(project:string,location:string,gateway:string,routeView:string) { + gatewayRouteViewPath( + project: string, + location: string, + gateway: string, + routeView: string, + ) { return this.pathTemplates.gatewayRouteViewPathTemplate.render({ project: project, location: location, @@ -3871,7 +5215,9 @@ export class DepServiceClient { * @returns {string} A string representing the project. */ matchProjectFromGatewayRouteViewName(gatewayRouteViewName: string) { - return this.pathTemplates.gatewayRouteViewPathTemplate.match(gatewayRouteViewName).project; + return this.pathTemplates.gatewayRouteViewPathTemplate.match( + gatewayRouteViewName, + ).project; } /** @@ -3882,7 +5228,9 @@ export class DepServiceClient { * @returns {string} A string representing the location. */ matchLocationFromGatewayRouteViewName(gatewayRouteViewName: string) { - return this.pathTemplates.gatewayRouteViewPathTemplate.match(gatewayRouteViewName).location; + return this.pathTemplates.gatewayRouteViewPathTemplate.match( + gatewayRouteViewName, + ).location; } /** @@ -3893,7 +5241,9 @@ export class DepServiceClient { * @returns {string} A string representing the gateway. */ matchGatewayFromGatewayRouteViewName(gatewayRouteViewName: string) { - return this.pathTemplates.gatewayRouteViewPathTemplate.match(gatewayRouteViewName).gateway; + return this.pathTemplates.gatewayRouteViewPathTemplate.match( + gatewayRouteViewName, + ).gateway; } /** @@ -3904,7 +5254,9 @@ export class DepServiceClient { * @returns {string} A string representing the route_view. */ matchRouteViewFromGatewayRouteViewName(gatewayRouteViewName: string) { - return this.pathTemplates.gatewayRouteViewPathTemplate.match(gatewayRouteViewName).route_view; + return this.pathTemplates.gatewayRouteViewPathTemplate.match( + gatewayRouteViewName, + ).route_view; } /** @@ -3915,7 +5267,7 @@ export class DepServiceClient { * @param {string} grpc_route * @returns {string} Resource name string. */ - grpcRoutePath(project:string,location:string,grpcRoute:string) { + grpcRoutePath(project: string, location: string, grpcRoute: string) { return this.pathTemplates.grpcRoutePathTemplate.render({ project: project, location: location, @@ -3931,7 +5283,8 @@ export class DepServiceClient { * @returns {string} A string representing the project. */ matchProjectFromGrpcRouteName(grpcRouteName: string) { - return this.pathTemplates.grpcRoutePathTemplate.match(grpcRouteName).project; + return this.pathTemplates.grpcRoutePathTemplate.match(grpcRouteName) + .project; } /** @@ -3942,7 +5295,8 @@ export class DepServiceClient { * @returns {string} A string representing the location. */ matchLocationFromGrpcRouteName(grpcRouteName: string) { - return this.pathTemplates.grpcRoutePathTemplate.match(grpcRouteName).location; + return this.pathTemplates.grpcRoutePathTemplate.match(grpcRouteName) + .location; } /** @@ -3953,7 +5307,8 @@ export class DepServiceClient { * @returns {string} A string representing the grpc_route. */ matchGrpcRouteFromGrpcRouteName(grpcRouteName: string) { - return this.pathTemplates.grpcRoutePathTemplate.match(grpcRouteName).grpc_route; + return this.pathTemplates.grpcRoutePathTemplate.match(grpcRouteName) + .grpc_route; } /** @@ -3964,7 +5319,7 @@ export class DepServiceClient { * @param {string} http_route * @returns {string} Resource name string. */ - httpRoutePath(project:string,location:string,httpRoute:string) { + httpRoutePath(project: string, location: string, httpRoute: string) { return this.pathTemplates.httpRoutePathTemplate.render({ project: project, location: location, @@ -3980,7 +5335,8 @@ export class DepServiceClient { * @returns {string} A string representing the project. */ matchProjectFromHttpRouteName(httpRouteName: string) { - return this.pathTemplates.httpRoutePathTemplate.match(httpRouteName).project; + return this.pathTemplates.httpRoutePathTemplate.match(httpRouteName) + .project; } /** @@ -3991,7 +5347,8 @@ export class DepServiceClient { * @returns {string} A string representing the location. */ matchLocationFromHttpRouteName(httpRouteName: string) { - return this.pathTemplates.httpRoutePathTemplate.match(httpRouteName).location; + return this.pathTemplates.httpRoutePathTemplate.match(httpRouteName) + .location; } /** @@ -4002,7 +5359,8 @@ export class DepServiceClient { * @returns {string} A string representing the http_route. */ matchHttpRouteFromHttpRouteName(httpRouteName: string) { - return this.pathTemplates.httpRoutePathTemplate.match(httpRouteName).http_route; + return this.pathTemplates.httpRoutePathTemplate.match(httpRouteName) + .http_route; } /** @@ -4013,7 +5371,11 @@ export class DepServiceClient { * @param {string} lb_edge_extension * @returns {string} Resource name string. */ - lbEdgeExtensionPath(project:string,location:string,lbEdgeExtension:string) { + lbEdgeExtensionPath( + project: string, + location: string, + lbEdgeExtension: string, + ) { return this.pathTemplates.lbEdgeExtensionPathTemplate.render({ project: project, location: location, @@ -4029,7 +5391,9 @@ export class DepServiceClient { * @returns {string} A string representing the project. */ matchProjectFromLbEdgeExtensionName(lbEdgeExtensionName: string) { - return this.pathTemplates.lbEdgeExtensionPathTemplate.match(lbEdgeExtensionName).project; + return this.pathTemplates.lbEdgeExtensionPathTemplate.match( + lbEdgeExtensionName, + ).project; } /** @@ -4040,7 +5404,9 @@ export class DepServiceClient { * @returns {string} A string representing the location. */ matchLocationFromLbEdgeExtensionName(lbEdgeExtensionName: string) { - return this.pathTemplates.lbEdgeExtensionPathTemplate.match(lbEdgeExtensionName).location; + return this.pathTemplates.lbEdgeExtensionPathTemplate.match( + lbEdgeExtensionName, + ).location; } /** @@ -4051,7 +5417,9 @@ export class DepServiceClient { * @returns {string} A string representing the lb_edge_extension. */ matchLbEdgeExtensionFromLbEdgeExtensionName(lbEdgeExtensionName: string) { - return this.pathTemplates.lbEdgeExtensionPathTemplate.match(lbEdgeExtensionName).lb_edge_extension; + return this.pathTemplates.lbEdgeExtensionPathTemplate.match( + lbEdgeExtensionName, + ).lb_edge_extension; } /** @@ -4062,7 +5430,11 @@ export class DepServiceClient { * @param {string} lb_route_extension * @returns {string} Resource name string. */ - lbRouteExtensionPath(project:string,location:string,lbRouteExtension:string) { + lbRouteExtensionPath( + project: string, + location: string, + lbRouteExtension: string, + ) { return this.pathTemplates.lbRouteExtensionPathTemplate.render({ project: project, location: location, @@ -4078,7 +5450,9 @@ export class DepServiceClient { * @returns {string} A string representing the project. */ matchProjectFromLbRouteExtensionName(lbRouteExtensionName: string) { - return this.pathTemplates.lbRouteExtensionPathTemplate.match(lbRouteExtensionName).project; + return this.pathTemplates.lbRouteExtensionPathTemplate.match( + lbRouteExtensionName, + ).project; } /** @@ -4089,7 +5463,9 @@ export class DepServiceClient { * @returns {string} A string representing the location. */ matchLocationFromLbRouteExtensionName(lbRouteExtensionName: string) { - return this.pathTemplates.lbRouteExtensionPathTemplate.match(lbRouteExtensionName).location; + return this.pathTemplates.lbRouteExtensionPathTemplate.match( + lbRouteExtensionName, + ).location; } /** @@ -4100,7 +5476,9 @@ export class DepServiceClient { * @returns {string} A string representing the lb_route_extension. */ matchLbRouteExtensionFromLbRouteExtensionName(lbRouteExtensionName: string) { - return this.pathTemplates.lbRouteExtensionPathTemplate.match(lbRouteExtensionName).lb_route_extension; + return this.pathTemplates.lbRouteExtensionPathTemplate.match( + lbRouteExtensionName, + ).lb_route_extension; } /** @@ -4111,7 +5489,11 @@ export class DepServiceClient { * @param {string} lb_traffic_extension * @returns {string} Resource name string. */ - lbTrafficExtensionPath(project:string,location:string,lbTrafficExtension:string) { + lbTrafficExtensionPath( + project: string, + location: string, + lbTrafficExtension: string, + ) { return this.pathTemplates.lbTrafficExtensionPathTemplate.render({ project: project, location: location, @@ -4127,7 +5509,9 @@ export class DepServiceClient { * @returns {string} A string representing the project. */ matchProjectFromLbTrafficExtensionName(lbTrafficExtensionName: string) { - return this.pathTemplates.lbTrafficExtensionPathTemplate.match(lbTrafficExtensionName).project; + return this.pathTemplates.lbTrafficExtensionPathTemplate.match( + lbTrafficExtensionName, + ).project; } /** @@ -4138,7 +5522,9 @@ export class DepServiceClient { * @returns {string} A string representing the location. */ matchLocationFromLbTrafficExtensionName(lbTrafficExtensionName: string) { - return this.pathTemplates.lbTrafficExtensionPathTemplate.match(lbTrafficExtensionName).location; + return this.pathTemplates.lbTrafficExtensionPathTemplate.match( + lbTrafficExtensionName, + ).location; } /** @@ -4148,8 +5534,12 @@ export class DepServiceClient { * A fully-qualified path representing LbTrafficExtension resource. * @returns {string} A string representing the lb_traffic_extension. */ - matchLbTrafficExtensionFromLbTrafficExtensionName(lbTrafficExtensionName: string) { - return this.pathTemplates.lbTrafficExtensionPathTemplate.match(lbTrafficExtensionName).lb_traffic_extension; + matchLbTrafficExtensionFromLbTrafficExtensionName( + lbTrafficExtensionName: string, + ) { + return this.pathTemplates.lbTrafficExtensionPathTemplate.match( + lbTrafficExtensionName, + ).lb_traffic_extension; } /** @@ -4159,7 +5549,7 @@ export class DepServiceClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -4196,7 +5586,7 @@ export class DepServiceClient { * @param {string} mesh * @returns {string} Resource name string. */ - meshPath(project:string,location:string,mesh:string) { + meshPath(project: string, location: string, mesh: string) { return this.pathTemplates.meshPathTemplate.render({ project: project, location: location, @@ -4246,7 +5636,12 @@ export class DepServiceClient { * @param {string} route_view * @returns {string} Resource name string. */ - meshRouteViewPath(project:string,location:string,mesh:string,routeView:string) { + meshRouteViewPath( + project: string, + location: string, + mesh: string, + routeView: string, + ) { return this.pathTemplates.meshRouteViewPathTemplate.render({ project: project, location: location, @@ -4263,7 +5658,8 @@ export class DepServiceClient { * @returns {string} A string representing the project. */ matchProjectFromMeshRouteViewName(meshRouteViewName: string) { - return this.pathTemplates.meshRouteViewPathTemplate.match(meshRouteViewName).project; + return this.pathTemplates.meshRouteViewPathTemplate.match(meshRouteViewName) + .project; } /** @@ -4274,7 +5670,8 @@ export class DepServiceClient { * @returns {string} A string representing the location. */ matchLocationFromMeshRouteViewName(meshRouteViewName: string) { - return this.pathTemplates.meshRouteViewPathTemplate.match(meshRouteViewName).location; + return this.pathTemplates.meshRouteViewPathTemplate.match(meshRouteViewName) + .location; } /** @@ -4285,7 +5682,8 @@ export class DepServiceClient { * @returns {string} A string representing the mesh. */ matchMeshFromMeshRouteViewName(meshRouteViewName: string) { - return this.pathTemplates.meshRouteViewPathTemplate.match(meshRouteViewName).mesh; + return this.pathTemplates.meshRouteViewPathTemplate.match(meshRouteViewName) + .mesh; } /** @@ -4296,7 +5694,8 @@ export class DepServiceClient { * @returns {string} A string representing the route_view. */ matchRouteViewFromMeshRouteViewName(meshRouteViewName: string) { - return this.pathTemplates.meshRouteViewPathTemplate.match(meshRouteViewName).route_view; + return this.pathTemplates.meshRouteViewPathTemplate.match(meshRouteViewName) + .route_view; } /** @@ -4305,7 +5704,7 @@ export class DepServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -4330,7 +5729,11 @@ export class DepServiceClient { * @param {string} service_binding * @returns {string} Resource name string. */ - serviceBindingPath(project:string,location:string,serviceBinding:string) { + serviceBindingPath( + project: string, + location: string, + serviceBinding: string, + ) { return this.pathTemplates.serviceBindingPathTemplate.render({ project: project, location: location, @@ -4346,7 +5749,9 @@ export class DepServiceClient { * @returns {string} A string representing the project. */ matchProjectFromServiceBindingName(serviceBindingName: string) { - return this.pathTemplates.serviceBindingPathTemplate.match(serviceBindingName).project; + return this.pathTemplates.serviceBindingPathTemplate.match( + serviceBindingName, + ).project; } /** @@ -4357,7 +5762,9 @@ export class DepServiceClient { * @returns {string} A string representing the location. */ matchLocationFromServiceBindingName(serviceBindingName: string) { - return this.pathTemplates.serviceBindingPathTemplate.match(serviceBindingName).location; + return this.pathTemplates.serviceBindingPathTemplate.match( + serviceBindingName, + ).location; } /** @@ -4368,7 +5775,9 @@ export class DepServiceClient { * @returns {string} A string representing the service_binding. */ matchServiceBindingFromServiceBindingName(serviceBindingName: string) { - return this.pathTemplates.serviceBindingPathTemplate.match(serviceBindingName).service_binding; + return this.pathTemplates.serviceBindingPathTemplate.match( + serviceBindingName, + ).service_binding; } /** @@ -4379,7 +5788,11 @@ export class DepServiceClient { * @param {string} service_lb_policy * @returns {string} Resource name string. */ - serviceLbPolicyPath(project:string,location:string,serviceLbPolicy:string) { + serviceLbPolicyPath( + project: string, + location: string, + serviceLbPolicy: string, + ) { return this.pathTemplates.serviceLbPolicyPathTemplate.render({ project: project, location: location, @@ -4395,7 +5808,9 @@ export class DepServiceClient { * @returns {string} A string representing the project. */ matchProjectFromServiceLbPolicyName(serviceLbPolicyName: string) { - return this.pathTemplates.serviceLbPolicyPathTemplate.match(serviceLbPolicyName).project; + return this.pathTemplates.serviceLbPolicyPathTemplate.match( + serviceLbPolicyName, + ).project; } /** @@ -4406,7 +5821,9 @@ export class DepServiceClient { * @returns {string} A string representing the location. */ matchLocationFromServiceLbPolicyName(serviceLbPolicyName: string) { - return this.pathTemplates.serviceLbPolicyPathTemplate.match(serviceLbPolicyName).location; + return this.pathTemplates.serviceLbPolicyPathTemplate.match( + serviceLbPolicyName, + ).location; } /** @@ -4417,7 +5834,9 @@ export class DepServiceClient { * @returns {string} A string representing the service_lb_policy. */ matchServiceLbPolicyFromServiceLbPolicyName(serviceLbPolicyName: string) { - return this.pathTemplates.serviceLbPolicyPathTemplate.match(serviceLbPolicyName).service_lb_policy; + return this.pathTemplates.serviceLbPolicyPathTemplate.match( + serviceLbPolicyName, + ).service_lb_policy; } /** @@ -4428,7 +5847,7 @@ export class DepServiceClient { * @param {string} tcp_route * @returns {string} Resource name string. */ - tcpRoutePath(project:string,location:string,tcpRoute:string) { + tcpRoutePath(project: string, location: string, tcpRoute: string) { return this.pathTemplates.tcpRoutePathTemplate.render({ project: project, location: location, @@ -4466,7 +5885,8 @@ export class DepServiceClient { * @returns {string} A string representing the tcp_route. */ matchTcpRouteFromTcpRouteName(tcpRouteName: string) { - return this.pathTemplates.tcpRoutePathTemplate.match(tcpRouteName).tcp_route; + return this.pathTemplates.tcpRoutePathTemplate.match(tcpRouteName) + .tcp_route; } /** @@ -4477,7 +5897,7 @@ export class DepServiceClient { * @param {string} tls_route * @returns {string} Resource name string. */ - tlsRoutePath(project:string,location:string,tlsRoute:string) { + tlsRoutePath(project: string, location: string, tlsRoute: string) { return this.pathTemplates.tlsRoutePathTemplate.render({ project: project, location: location, @@ -4515,7 +5935,8 @@ export class DepServiceClient { * @returns {string} A string representing the tls_route. */ matchTlsRouteFromTlsRouteName(tlsRouteName: string) { - return this.pathTemplates.tlsRoutePathTemplate.match(tlsRouteName).tls_route; + return this.pathTemplates.tlsRoutePathTemplate.match(tlsRouteName) + .tls_route; } /** @@ -4526,7 +5947,7 @@ export class DepServiceClient { * @param {string} wasm_plugin * @returns {string} Resource name string. */ - wasmPluginPath(project:string,location:string,wasmPlugin:string) { + wasmPluginPath(project: string, location: string, wasmPlugin: string) { return this.pathTemplates.wasmPluginPathTemplate.render({ project: project, location: location, @@ -4542,7 +5963,8 @@ export class DepServiceClient { * @returns {string} A string representing the project. */ matchProjectFromWasmPluginName(wasmPluginName: string) { - return this.pathTemplates.wasmPluginPathTemplate.match(wasmPluginName).project; + return this.pathTemplates.wasmPluginPathTemplate.match(wasmPluginName) + .project; } /** @@ -4553,7 +5975,8 @@ export class DepServiceClient { * @returns {string} A string representing the location. */ matchLocationFromWasmPluginName(wasmPluginName: string) { - return this.pathTemplates.wasmPluginPathTemplate.match(wasmPluginName).location; + return this.pathTemplates.wasmPluginPathTemplate.match(wasmPluginName) + .location; } /** @@ -4564,7 +5987,8 @@ export class DepServiceClient { * @returns {string} A string representing the wasm_plugin. */ matchWasmPluginFromWasmPluginName(wasmPluginName: string) { - return this.pathTemplates.wasmPluginPathTemplate.match(wasmPluginName).wasm_plugin; + return this.pathTemplates.wasmPluginPathTemplate.match(wasmPluginName) + .wasm_plugin; } /** @@ -4576,7 +6000,12 @@ export class DepServiceClient { * @param {string} wasm_plugin_version * @returns {string} Resource name string. */ - wasmPluginVersionPath(project:string,location:string,wasmPlugin:string,wasmPluginVersion:string) { + wasmPluginVersionPath( + project: string, + location: string, + wasmPlugin: string, + wasmPluginVersion: string, + ) { return this.pathTemplates.wasmPluginVersionPathTemplate.render({ project: project, location: location, @@ -4593,7 +6022,9 @@ export class DepServiceClient { * @returns {string} A string representing the project. */ matchProjectFromWasmPluginVersionName(wasmPluginVersionName: string) { - return this.pathTemplates.wasmPluginVersionPathTemplate.match(wasmPluginVersionName).project; + return this.pathTemplates.wasmPluginVersionPathTemplate.match( + wasmPluginVersionName, + ).project; } /** @@ -4604,7 +6035,9 @@ export class DepServiceClient { * @returns {string} A string representing the location. */ matchLocationFromWasmPluginVersionName(wasmPluginVersionName: string) { - return this.pathTemplates.wasmPluginVersionPathTemplate.match(wasmPluginVersionName).location; + return this.pathTemplates.wasmPluginVersionPathTemplate.match( + wasmPluginVersionName, + ).location; } /** @@ -4615,7 +6048,9 @@ export class DepServiceClient { * @returns {string} A string representing the wasm_plugin. */ matchWasmPluginFromWasmPluginVersionName(wasmPluginVersionName: string) { - return this.pathTemplates.wasmPluginVersionPathTemplate.match(wasmPluginVersionName).wasm_plugin; + return this.pathTemplates.wasmPluginVersionPathTemplate.match( + wasmPluginVersionName, + ).wasm_plugin; } /** @@ -4625,8 +6060,12 @@ export class DepServiceClient { * A fully-qualified path representing WasmPluginVersion resource. * @returns {string} A string representing the wasm_plugin_version. */ - matchWasmPluginVersionFromWasmPluginVersionName(wasmPluginVersionName: string) { - return this.pathTemplates.wasmPluginVersionPathTemplate.match(wasmPluginVersionName).wasm_plugin_version; + matchWasmPluginVersionFromWasmPluginVersionName( + wasmPluginVersionName: string, + ) { + return this.pathTemplates.wasmPluginVersionPathTemplate.match( + wasmPluginVersionName, + ).wasm_plugin_version; } /** @@ -4637,15 +6076,19 @@ export class DepServiceClient { */ close(): Promise { if (this.depServiceStub && !this._terminated) { - return this.depServiceStub.then(stub => { + return this.depServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-networkservices/src/v1/index.ts b/packages/google-cloud-networkservices/src/v1/index.ts index 2639fbafc70a..0c90cbddde24 100644 --- a/packages/google-cloud-networkservices/src/v1/index.ts +++ b/packages/google-cloud-networkservices/src/v1/index.ts @@ -16,5 +16,5 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {DepServiceClient} from './dep_service_client'; -export {NetworkServicesClient} from './network_services_client'; +export { DepServiceClient } from './dep_service_client'; +export { NetworkServicesClient } from './network_services_client'; diff --git a/packages/google-cloud-networkservices/src/v1/network_services_client.ts b/packages/google-cloud-networkservices/src/v1/network_services_client.ts index 324afd3b1441..5edcbcc7e4b8 100644 --- a/packages/google-cloud-networkservices/src/v1/network_services_client.ts +++ b/packages/google-cloud-networkservices/src/v1/network_services_client.ts @@ -18,11 +18,24 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -44,7 +57,7 @@ export class NetworkServicesClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('networkservices'); @@ -57,12 +70,12 @@ export class NetworkServicesClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - networkServicesStub?: Promise<{[name: string]: Function}>; + networkServicesStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of NetworkServicesClient. @@ -103,21 +116,42 @@ export class NetworkServicesClient { * const client = new NetworkServicesClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof NetworkServicesClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'networkservices.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -142,7 +176,7 @@ export class NetworkServicesClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -155,18 +189,14 @@ export class NetworkServicesClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -188,55 +218,55 @@ export class NetworkServicesClient { // Create useful helper objects for these. this.pathTemplates = { authzExtensionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/authzExtensions/{authz_extension}' + 'projects/{project}/locations/{location}/authzExtensions/{authz_extension}', ), endpointPolicyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/endpointPolicies/{endpoint_policy}' + 'projects/{project}/locations/{location}/endpointPolicies/{endpoint_policy}', ), gatewayPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/gateways/{gateway}' + 'projects/{project}/locations/{location}/gateways/{gateway}', ), gatewayRouteViewPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/gateways/{gateway}/routeViews/{route_view}' + 'projects/{project}/locations/{location}/gateways/{gateway}/routeViews/{route_view}', ), grpcRoutePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/grpcRoutes/{grpc_route}' + 'projects/{project}/locations/{location}/grpcRoutes/{grpc_route}', ), httpRoutePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/httpRoutes/{http_route}' + 'projects/{project}/locations/{location}/httpRoutes/{http_route}', ), lbEdgeExtensionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/lbEdgeExtensions/{lb_edge_extension}' + 'projects/{project}/locations/{location}/lbEdgeExtensions/{lb_edge_extension}', ), lbRouteExtensionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/lbRouteExtensions/{lb_route_extension}' + 'projects/{project}/locations/{location}/lbRouteExtensions/{lb_route_extension}', ), lbTrafficExtensionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/lbTrafficExtensions/{lb_traffic_extension}' + 'projects/{project}/locations/{location}/lbTrafficExtensions/{lb_traffic_extension}', ), meshPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/meshes/{mesh}' + 'projects/{project}/locations/{location}/meshes/{mesh}', ), meshRouteViewPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/meshes/{mesh}/routeViews/{route_view}' + 'projects/{project}/locations/{location}/meshes/{mesh}/routeViews/{route_view}', ), serviceBindingPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/serviceBindings/{service_binding}' + 'projects/{project}/locations/{location}/serviceBindings/{service_binding}', ), serviceLbPolicyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/serviceLbPolicies/{service_lb_policy}' + 'projects/{project}/locations/{location}/serviceLbPolicies/{service_lb_policy}', ), tcpRoutePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/tcpRoutes/{tcp_route}' + 'projects/{project}/locations/{location}/tcpRoutes/{tcp_route}', ), tlsRoutePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/tlsRoutes/{tls_route}' + 'projects/{project}/locations/{location}/tlsRoutes/{tls_route}', ), wasmPluginPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/wasmPlugins/{wasm_plugin}' + 'projects/{project}/locations/{location}/wasmPlugins/{wasm_plugin}', ), wasmPluginVersionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/wasmPlugins/{wasm_plugin}/versions/{wasm_plugin_version}' + 'projects/{project}/locations/{location}/wasmPlugins/{wasm_plugin}/versions/{wasm_plugin_version}', ), }; @@ -244,32 +274,71 @@ export class NetworkServicesClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listEndpointPolicies: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'endpointPolicies'), - listWasmPluginVersions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'wasmPluginVersions'), - listWasmPlugins: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'wasmPlugins'), - listGateways: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'gateways'), - listGrpcRoutes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'grpcRoutes'), - listHttpRoutes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'httpRoutes'), - listTcpRoutes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tcpRoutes'), - listTlsRoutes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tlsRoutes'), - listServiceBindings: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'serviceBindings'), - listMeshes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'meshes'), - listServiceLbPolicies: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'serviceLbPolicies'), - listGatewayRouteViews: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'gatewayRouteViews'), - listMeshRouteViews: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'meshRouteViews') + listEndpointPolicies: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'endpointPolicies', + ), + listWasmPluginVersions: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'wasmPluginVersions', + ), + listWasmPlugins: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'wasmPlugins', + ), + listGateways: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'gateways', + ), + listGrpcRoutes: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'grpcRoutes', + ), + listHttpRoutes: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'httpRoutes', + ), + listTcpRoutes: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'tcpRoutes', + ), + listTlsRoutes: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'tlsRoutes', + ), + listServiceBindings: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'serviceBindings', + ), + listMeshes: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'meshes', + ), + listServiceLbPolicies: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'serviceLbPolicies', + ), + listGatewayRouteViews: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'gatewayRouteViews', + ), + listMeshRouteViews: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'meshRouteViews', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -278,280 +347,510 @@ export class NetworkServicesClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1/{resource=projects/*/locations/*/edgeCacheKeysets/*}:getIamPolicy',additional_bindings: [{get: '/v1/{resource=projects/*/locations/*/edgeCacheOrigins/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/edgeCacheServices/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/endpointPolicies/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/serviceBindings/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/meshes/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/gateways/*}:getIamPolicy',}], - },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1/{resource=projects/*/locations/*/edgeCacheKeysets/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/edgeCacheOrigins/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/edgeCacheServices/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/endpointPolicies/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceBindings/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/meshes/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/gateways/*}:setIamPolicy',body: '*',}], - },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1/{resource=projects/*/locations/*/edgeCacheKeysets/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/edgeCacheOrigins/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/edgeCacheServices/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/endpointPolicies/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/serviceBindings/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/meshes/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/gateways/*}:testIamPermissions',body: '*',}], - },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1/{resource=projects/*/locations/*/edgeCacheKeysets/*}:getIamPolicy', + additional_bindings: [ + { + get: '/v1/{resource=projects/*/locations/*/edgeCacheOrigins/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/edgeCacheServices/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/endpointPolicies/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/serviceBindings/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/meshes/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/gateways/*}:getIamPolicy', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1/{resource=projects/*/locations/*/edgeCacheKeysets/*}:setIamPolicy', + body: '*', + additional_bindings: [ + { + post: '/v1/{resource=projects/*/locations/*/edgeCacheOrigins/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/edgeCacheServices/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/endpointPolicies/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceBindings/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/meshes/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/gateways/*}:setIamPolicy', + body: '*', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1/{resource=projects/*/locations/*/edgeCacheKeysets/*}:testIamPermissions', + body: '*', + additional_bindings: [ + { + post: '/v1/{resource=projects/*/locations/*/edgeCacheOrigins/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/edgeCacheServices/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/endpointPolicies/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/serviceBindings/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/meshes/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/gateways/*}:testIamPermissions', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createEndpointPolicyResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.EndpointPolicy') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.EndpointPolicy', + ) as gax.protobuf.Type; const createEndpointPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateEndpointPolicyResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.EndpointPolicy') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.EndpointPolicy', + ) as gax.protobuf.Type; const updateEndpointPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteEndpointPolicyResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteEndpointPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const createWasmPluginVersionResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.WasmPluginVersion') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.WasmPluginVersion', + ) as gax.protobuf.Type; const createWasmPluginVersionMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteWasmPluginVersionResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteWasmPluginVersionMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const createWasmPluginResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.WasmPlugin') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.WasmPlugin', + ) as gax.protobuf.Type; const createWasmPluginMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateWasmPluginResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.WasmPlugin') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.WasmPlugin', + ) as gax.protobuf.Type; const updateWasmPluginMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteWasmPluginResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteWasmPluginMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const createGatewayResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.Gateway') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.Gateway', + ) as gax.protobuf.Type; const createGatewayMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateGatewayResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.Gateway') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.Gateway', + ) as gax.protobuf.Type; const updateGatewayMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteGatewayResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteGatewayMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const createGrpcRouteResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.GrpcRoute') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.GrpcRoute', + ) as gax.protobuf.Type; const createGrpcRouteMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateGrpcRouteResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.GrpcRoute') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.GrpcRoute', + ) as gax.protobuf.Type; const updateGrpcRouteMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteGrpcRouteResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteGrpcRouteMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const createHttpRouteResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.HttpRoute') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.HttpRoute', + ) as gax.protobuf.Type; const createHttpRouteMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateHttpRouteResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.HttpRoute') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.HttpRoute', + ) as gax.protobuf.Type; const updateHttpRouteMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteHttpRouteResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteHttpRouteMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const createTcpRouteResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.TcpRoute') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.TcpRoute', + ) as gax.protobuf.Type; const createTcpRouteMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateTcpRouteResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.TcpRoute') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.TcpRoute', + ) as gax.protobuf.Type; const updateTcpRouteMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteTcpRouteResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteTcpRouteMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const createTlsRouteResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.TlsRoute') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.TlsRoute', + ) as gax.protobuf.Type; const createTlsRouteMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateTlsRouteResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.TlsRoute') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.TlsRoute', + ) as gax.protobuf.Type; const updateTlsRouteMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteTlsRouteResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteTlsRouteMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const createServiceBindingResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.ServiceBinding') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.ServiceBinding', + ) as gax.protobuf.Type; const createServiceBindingMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateServiceBindingResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.ServiceBinding') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.ServiceBinding', + ) as gax.protobuf.Type; const updateServiceBindingMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteServiceBindingResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteServiceBindingMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const createMeshResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.Mesh') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.Mesh', + ) as gax.protobuf.Type; const createMeshMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateMeshResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.Mesh') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.Mesh', + ) as gax.protobuf.Type; const updateMeshMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteMeshResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteMeshMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const createServiceLbPolicyResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.ServiceLbPolicy') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.ServiceLbPolicy', + ) as gax.protobuf.Type; const createServiceLbPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateServiceLbPolicyResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.ServiceLbPolicy') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.ServiceLbPolicy', + ) as gax.protobuf.Type; const updateServiceLbPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteServiceLbPolicyResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteServiceLbPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createEndpointPolicy: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createEndpointPolicyResponse.decode.bind(createEndpointPolicyResponse), - createEndpointPolicyMetadata.decode.bind(createEndpointPolicyMetadata)), + createEndpointPolicyMetadata.decode.bind(createEndpointPolicyMetadata), + ), updateEndpointPolicy: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateEndpointPolicyResponse.decode.bind(updateEndpointPolicyResponse), - updateEndpointPolicyMetadata.decode.bind(updateEndpointPolicyMetadata)), + updateEndpointPolicyMetadata.decode.bind(updateEndpointPolicyMetadata), + ), deleteEndpointPolicy: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteEndpointPolicyResponse.decode.bind(deleteEndpointPolicyResponse), - deleteEndpointPolicyMetadata.decode.bind(deleteEndpointPolicyMetadata)), + deleteEndpointPolicyMetadata.decode.bind(deleteEndpointPolicyMetadata), + ), createWasmPluginVersion: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - createWasmPluginVersionResponse.decode.bind(createWasmPluginVersionResponse), - createWasmPluginVersionMetadata.decode.bind(createWasmPluginVersionMetadata)), + createWasmPluginVersionResponse.decode.bind( + createWasmPluginVersionResponse, + ), + createWasmPluginVersionMetadata.decode.bind( + createWasmPluginVersionMetadata, + ), + ), deleteWasmPluginVersion: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - deleteWasmPluginVersionResponse.decode.bind(deleteWasmPluginVersionResponse), - deleteWasmPluginVersionMetadata.decode.bind(deleteWasmPluginVersionMetadata)), + deleteWasmPluginVersionResponse.decode.bind( + deleteWasmPluginVersionResponse, + ), + deleteWasmPluginVersionMetadata.decode.bind( + deleteWasmPluginVersionMetadata, + ), + ), createWasmPlugin: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createWasmPluginResponse.decode.bind(createWasmPluginResponse), - createWasmPluginMetadata.decode.bind(createWasmPluginMetadata)), + createWasmPluginMetadata.decode.bind(createWasmPluginMetadata), + ), updateWasmPlugin: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateWasmPluginResponse.decode.bind(updateWasmPluginResponse), - updateWasmPluginMetadata.decode.bind(updateWasmPluginMetadata)), + updateWasmPluginMetadata.decode.bind(updateWasmPluginMetadata), + ), deleteWasmPlugin: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteWasmPluginResponse.decode.bind(deleteWasmPluginResponse), - deleteWasmPluginMetadata.decode.bind(deleteWasmPluginMetadata)), + deleteWasmPluginMetadata.decode.bind(deleteWasmPluginMetadata), + ), createGateway: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createGatewayResponse.decode.bind(createGatewayResponse), - createGatewayMetadata.decode.bind(createGatewayMetadata)), + createGatewayMetadata.decode.bind(createGatewayMetadata), + ), updateGateway: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateGatewayResponse.decode.bind(updateGatewayResponse), - updateGatewayMetadata.decode.bind(updateGatewayMetadata)), + updateGatewayMetadata.decode.bind(updateGatewayMetadata), + ), deleteGateway: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteGatewayResponse.decode.bind(deleteGatewayResponse), - deleteGatewayMetadata.decode.bind(deleteGatewayMetadata)), + deleteGatewayMetadata.decode.bind(deleteGatewayMetadata), + ), createGrpcRoute: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createGrpcRouteResponse.decode.bind(createGrpcRouteResponse), - createGrpcRouteMetadata.decode.bind(createGrpcRouteMetadata)), + createGrpcRouteMetadata.decode.bind(createGrpcRouteMetadata), + ), updateGrpcRoute: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateGrpcRouteResponse.decode.bind(updateGrpcRouteResponse), - updateGrpcRouteMetadata.decode.bind(updateGrpcRouteMetadata)), + updateGrpcRouteMetadata.decode.bind(updateGrpcRouteMetadata), + ), deleteGrpcRoute: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteGrpcRouteResponse.decode.bind(deleteGrpcRouteResponse), - deleteGrpcRouteMetadata.decode.bind(deleteGrpcRouteMetadata)), + deleteGrpcRouteMetadata.decode.bind(deleteGrpcRouteMetadata), + ), createHttpRoute: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createHttpRouteResponse.decode.bind(createHttpRouteResponse), - createHttpRouteMetadata.decode.bind(createHttpRouteMetadata)), + createHttpRouteMetadata.decode.bind(createHttpRouteMetadata), + ), updateHttpRoute: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateHttpRouteResponse.decode.bind(updateHttpRouteResponse), - updateHttpRouteMetadata.decode.bind(updateHttpRouteMetadata)), + updateHttpRouteMetadata.decode.bind(updateHttpRouteMetadata), + ), deleteHttpRoute: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteHttpRouteResponse.decode.bind(deleteHttpRouteResponse), - deleteHttpRouteMetadata.decode.bind(deleteHttpRouteMetadata)), + deleteHttpRouteMetadata.decode.bind(deleteHttpRouteMetadata), + ), createTcpRoute: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createTcpRouteResponse.decode.bind(createTcpRouteResponse), - createTcpRouteMetadata.decode.bind(createTcpRouteMetadata)), + createTcpRouteMetadata.decode.bind(createTcpRouteMetadata), + ), updateTcpRoute: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateTcpRouteResponse.decode.bind(updateTcpRouteResponse), - updateTcpRouteMetadata.decode.bind(updateTcpRouteMetadata)), + updateTcpRouteMetadata.decode.bind(updateTcpRouteMetadata), + ), deleteTcpRoute: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteTcpRouteResponse.decode.bind(deleteTcpRouteResponse), - deleteTcpRouteMetadata.decode.bind(deleteTcpRouteMetadata)), + deleteTcpRouteMetadata.decode.bind(deleteTcpRouteMetadata), + ), createTlsRoute: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createTlsRouteResponse.decode.bind(createTlsRouteResponse), - createTlsRouteMetadata.decode.bind(createTlsRouteMetadata)), + createTlsRouteMetadata.decode.bind(createTlsRouteMetadata), + ), updateTlsRoute: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateTlsRouteResponse.decode.bind(updateTlsRouteResponse), - updateTlsRouteMetadata.decode.bind(updateTlsRouteMetadata)), + updateTlsRouteMetadata.decode.bind(updateTlsRouteMetadata), + ), deleteTlsRoute: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteTlsRouteResponse.decode.bind(deleteTlsRouteResponse), - deleteTlsRouteMetadata.decode.bind(deleteTlsRouteMetadata)), + deleteTlsRouteMetadata.decode.bind(deleteTlsRouteMetadata), + ), createServiceBinding: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createServiceBindingResponse.decode.bind(createServiceBindingResponse), - createServiceBindingMetadata.decode.bind(createServiceBindingMetadata)), + createServiceBindingMetadata.decode.bind(createServiceBindingMetadata), + ), updateServiceBinding: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateServiceBindingResponse.decode.bind(updateServiceBindingResponse), - updateServiceBindingMetadata.decode.bind(updateServiceBindingMetadata)), + updateServiceBindingMetadata.decode.bind(updateServiceBindingMetadata), + ), deleteServiceBinding: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteServiceBindingResponse.decode.bind(deleteServiceBindingResponse), - deleteServiceBindingMetadata.decode.bind(deleteServiceBindingMetadata)), + deleteServiceBindingMetadata.decode.bind(deleteServiceBindingMetadata), + ), createMesh: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createMeshResponse.decode.bind(createMeshResponse), - createMeshMetadata.decode.bind(createMeshMetadata)), + createMeshMetadata.decode.bind(createMeshMetadata), + ), updateMesh: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateMeshResponse.decode.bind(updateMeshResponse), - updateMeshMetadata.decode.bind(updateMeshMetadata)), + updateMeshMetadata.decode.bind(updateMeshMetadata), + ), deleteMesh: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteMeshResponse.decode.bind(deleteMeshResponse), - deleteMeshMetadata.decode.bind(deleteMeshMetadata)), + deleteMeshMetadata.decode.bind(deleteMeshMetadata), + ), createServiceLbPolicy: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - createServiceLbPolicyResponse.decode.bind(createServiceLbPolicyResponse), - createServiceLbPolicyMetadata.decode.bind(createServiceLbPolicyMetadata)), + createServiceLbPolicyResponse.decode.bind( + createServiceLbPolicyResponse, + ), + createServiceLbPolicyMetadata.decode.bind( + createServiceLbPolicyMetadata, + ), + ), updateServiceLbPolicy: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - updateServiceLbPolicyResponse.decode.bind(updateServiceLbPolicyResponse), - updateServiceLbPolicyMetadata.decode.bind(updateServiceLbPolicyMetadata)), + updateServiceLbPolicyResponse.decode.bind( + updateServiceLbPolicyResponse, + ), + updateServiceLbPolicyMetadata.decode.bind( + updateServiceLbPolicyMetadata, + ), + ), deleteServiceLbPolicy: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - deleteServiceLbPolicyResponse.decode.bind(deleteServiceLbPolicyResponse), - deleteServiceLbPolicyMetadata.decode.bind(deleteServiceLbPolicyMetadata)) + deleteServiceLbPolicyResponse.decode.bind( + deleteServiceLbPolicyResponse, + ), + deleteServiceLbPolicyMetadata.decode.bind( + deleteServiceLbPolicyMetadata, + ), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.networkservices.v1.NetworkServices', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.networkservices.v1.NetworkServices', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -582,28 +881,92 @@ export class NetworkServicesClient { // Put together the "service stub" for // google.cloud.networkservices.v1.NetworkServices. this.networkServicesStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.networkservices.v1.NetworkServices') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.networkservices.v1.NetworkServices', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.networkservices.v1.NetworkServices, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const networkServicesStubMethods = - ['listEndpointPolicies', 'getEndpointPolicy', 'createEndpointPolicy', 'updateEndpointPolicy', 'deleteEndpointPolicy', 'listWasmPluginVersions', 'getWasmPluginVersion', 'createWasmPluginVersion', 'deleteWasmPluginVersion', 'listWasmPlugins', 'getWasmPlugin', 'createWasmPlugin', 'updateWasmPlugin', 'deleteWasmPlugin', 'listGateways', 'getGateway', 'createGateway', 'updateGateway', 'deleteGateway', 'listGrpcRoutes', 'getGrpcRoute', 'createGrpcRoute', 'updateGrpcRoute', 'deleteGrpcRoute', 'listHttpRoutes', 'getHttpRoute', 'createHttpRoute', 'updateHttpRoute', 'deleteHttpRoute', 'listTcpRoutes', 'getTcpRoute', 'createTcpRoute', 'updateTcpRoute', 'deleteTcpRoute', 'listTlsRoutes', 'getTlsRoute', 'createTlsRoute', 'updateTlsRoute', 'deleteTlsRoute', 'listServiceBindings', 'getServiceBinding', 'createServiceBinding', 'updateServiceBinding', 'deleteServiceBinding', 'listMeshes', 'getMesh', 'createMesh', 'updateMesh', 'deleteMesh', 'listServiceLbPolicies', 'getServiceLbPolicy', 'createServiceLbPolicy', 'updateServiceLbPolicy', 'deleteServiceLbPolicy', 'getGatewayRouteView', 'getMeshRouteView', 'listGatewayRouteViews', 'listMeshRouteViews']; + const networkServicesStubMethods = [ + 'listEndpointPolicies', + 'getEndpointPolicy', + 'createEndpointPolicy', + 'updateEndpointPolicy', + 'deleteEndpointPolicy', + 'listWasmPluginVersions', + 'getWasmPluginVersion', + 'createWasmPluginVersion', + 'deleteWasmPluginVersion', + 'listWasmPlugins', + 'getWasmPlugin', + 'createWasmPlugin', + 'updateWasmPlugin', + 'deleteWasmPlugin', + 'listGateways', + 'getGateway', + 'createGateway', + 'updateGateway', + 'deleteGateway', + 'listGrpcRoutes', + 'getGrpcRoute', + 'createGrpcRoute', + 'updateGrpcRoute', + 'deleteGrpcRoute', + 'listHttpRoutes', + 'getHttpRoute', + 'createHttpRoute', + 'updateHttpRoute', + 'deleteHttpRoute', + 'listTcpRoutes', + 'getTcpRoute', + 'createTcpRoute', + 'updateTcpRoute', + 'deleteTcpRoute', + 'listTlsRoutes', + 'getTlsRoute', + 'createTlsRoute', + 'updateTlsRoute', + 'deleteTlsRoute', + 'listServiceBindings', + 'getServiceBinding', + 'createServiceBinding', + 'updateServiceBinding', + 'deleteServiceBinding', + 'listMeshes', + 'getMesh', + 'createMesh', + 'updateMesh', + 'deleteMesh', + 'listServiceLbPolicies', + 'getServiceLbPolicy', + 'createServiceLbPolicy', + 'updateServiceLbPolicy', + 'deleteServiceLbPolicy', + 'getGatewayRouteView', + 'getMeshRouteView', + 'listGatewayRouteViews', + 'listMeshRouteViews', + ]; for (const methodName of networkServicesStubMethods) { const callPromise = this.networkServicesStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -613,7 +976,7 @@ export class NetworkServicesClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -628,8 +991,14 @@ export class NetworkServicesClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkservices.googleapis.com'; } @@ -640,8 +1009,14 @@ export class NetworkServicesClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkservices.googleapis.com'; } @@ -672,9 +1047,7 @@ export class NetworkServicesClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -683,8 +1056,9 @@ export class NetworkServicesClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -695,4901 +1069,7493 @@ export class NetworkServicesClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets details of a single EndpointPolicy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the EndpointPolicy to get. Must be in the format - * `projects/* /locations/global/endpointPolicies/*`. - * @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 {@link protos.google.cloud.networkservices.v1.EndpointPolicy|EndpointPolicy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_services.get_endpoint_policy.js - * region_tag:networkservices_v1_generated_NetworkServices_GetEndpointPolicy_async - */ + /** + * Gets details of a single EndpointPolicy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the EndpointPolicy to get. Must be in the format + * `projects/* /locations/global/endpointPolicies/*`. + * @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 {@link protos.google.cloud.networkservices.v1.EndpointPolicy|EndpointPolicy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_services.get_endpoint_policy.js + * region_tag:networkservices_v1_generated_NetworkServices_GetEndpointPolicy_async + */ getEndpointPolicy( - request?: protos.google.cloud.networkservices.v1.IGetEndpointPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.IEndpointPolicy, - protos.google.cloud.networkservices.v1.IGetEndpointPolicyRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IGetEndpointPolicyRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IEndpointPolicy, + ( + | protos.google.cloud.networkservices.v1.IGetEndpointPolicyRequest + | undefined + ), + {} | undefined, + ] + >; getEndpointPolicy( - request: protos.google.cloud.networkservices.v1.IGetEndpointPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkservices.v1.IEndpointPolicy, - protos.google.cloud.networkservices.v1.IGetEndpointPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetEndpointPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkservices.v1.IEndpointPolicy, + | protos.google.cloud.networkservices.v1.IGetEndpointPolicyRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getEndpointPolicy( - request: protos.google.cloud.networkservices.v1.IGetEndpointPolicyRequest, - callback: Callback< - protos.google.cloud.networkservices.v1.IEndpointPolicy, - protos.google.cloud.networkservices.v1.IGetEndpointPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetEndpointPolicyRequest, + callback: Callback< + protos.google.cloud.networkservices.v1.IEndpointPolicy, + | protos.google.cloud.networkservices.v1.IGetEndpointPolicyRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getEndpointPolicy( - request?: protos.google.cloud.networkservices.v1.IGetEndpointPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkservices.v1.IEndpointPolicy, - protos.google.cloud.networkservices.v1.IGetEndpointPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkservices.v1.IGetEndpointPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkservices.v1.IEndpointPolicy, - protos.google.cloud.networkservices.v1.IGetEndpointPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkservices.v1.IEndpointPolicy, - protos.google.cloud.networkservices.v1.IGetEndpointPolicyRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkservices.v1.IGetEndpointPolicyRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkservices.v1.IEndpointPolicy, + | protos.google.cloud.networkservices.v1.IGetEndpointPolicyRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IEndpointPolicy, + ( + | protos.google.cloud.networkservices.v1.IGetEndpointPolicyRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getEndpointPolicy request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkservices.v1.IEndpointPolicy, - protos.google.cloud.networkservices.v1.IGetEndpointPolicyRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkservices.v1.IEndpointPolicy, + | protos.google.cloud.networkservices.v1.IGetEndpointPolicyRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getEndpointPolicy response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getEndpointPolicy(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkservices.v1.IEndpointPolicy, - protos.google.cloud.networkservices.v1.IGetEndpointPolicyRequest|undefined, - {}|undefined - ]) => { - this._log.info('getEndpointPolicy response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getEndpointPolicy(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkservices.v1.IEndpointPolicy, + ( + | protos.google.cloud.networkservices.v1.IGetEndpointPolicyRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getEndpointPolicy response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of the specified `WasmPluginVersion` resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the `WasmPluginVersion` resource to get. Must be in - * the format - * `projects/{project}/locations/global/wasmPlugins/{wasm_plugin}/versions/{wasm_plugin_version}`. - * @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 {@link protos.google.cloud.networkservices.v1.WasmPluginVersion|WasmPluginVersion}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_services.get_wasm_plugin_version.js - * region_tag:networkservices_v1_generated_NetworkServices_GetWasmPluginVersion_async - */ + /** + * Gets details of the specified `WasmPluginVersion` resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the `WasmPluginVersion` resource to get. Must be in + * the format + * `projects/{project}/locations/global/wasmPlugins/{wasm_plugin}/versions/{wasm_plugin_version}`. + * @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 {@link protos.google.cloud.networkservices.v1.WasmPluginVersion|WasmPluginVersion}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_services.get_wasm_plugin_version.js + * region_tag:networkservices_v1_generated_NetworkServices_GetWasmPluginVersion_async + */ getWasmPluginVersion( - request?: protos.google.cloud.networkservices.v1.IGetWasmPluginVersionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.IWasmPluginVersion, - protos.google.cloud.networkservices.v1.IGetWasmPluginVersionRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IGetWasmPluginVersionRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IWasmPluginVersion, + ( + | protos.google.cloud.networkservices.v1.IGetWasmPluginVersionRequest + | undefined + ), + {} | undefined, + ] + >; getWasmPluginVersion( - request: protos.google.cloud.networkservices.v1.IGetWasmPluginVersionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkservices.v1.IWasmPluginVersion, - protos.google.cloud.networkservices.v1.IGetWasmPluginVersionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetWasmPluginVersionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkservices.v1.IWasmPluginVersion, + | protos.google.cloud.networkservices.v1.IGetWasmPluginVersionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getWasmPluginVersion( - request: protos.google.cloud.networkservices.v1.IGetWasmPluginVersionRequest, - callback: Callback< - protos.google.cloud.networkservices.v1.IWasmPluginVersion, - protos.google.cloud.networkservices.v1.IGetWasmPluginVersionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetWasmPluginVersionRequest, + callback: Callback< + protos.google.cloud.networkservices.v1.IWasmPluginVersion, + | protos.google.cloud.networkservices.v1.IGetWasmPluginVersionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getWasmPluginVersion( - request?: protos.google.cloud.networkservices.v1.IGetWasmPluginVersionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkservices.v1.IWasmPluginVersion, - protos.google.cloud.networkservices.v1.IGetWasmPluginVersionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkservices.v1.IGetWasmPluginVersionRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkservices.v1.IWasmPluginVersion, - protos.google.cloud.networkservices.v1.IGetWasmPluginVersionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkservices.v1.IWasmPluginVersion, - protos.google.cloud.networkservices.v1.IGetWasmPluginVersionRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkservices.v1.IGetWasmPluginVersionRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkservices.v1.IWasmPluginVersion, + | protos.google.cloud.networkservices.v1.IGetWasmPluginVersionRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IWasmPluginVersion, + ( + | protos.google.cloud.networkservices.v1.IGetWasmPluginVersionRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getWasmPluginVersion request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkservices.v1.IWasmPluginVersion, - protos.google.cloud.networkservices.v1.IGetWasmPluginVersionRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkservices.v1.IWasmPluginVersion, + | protos.google.cloud.networkservices.v1.IGetWasmPluginVersionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getWasmPluginVersion response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getWasmPluginVersion(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkservices.v1.IWasmPluginVersion, - protos.google.cloud.networkservices.v1.IGetWasmPluginVersionRequest|undefined, - {}|undefined - ]) => { - this._log.info('getWasmPluginVersion response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getWasmPluginVersion(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkservices.v1.IWasmPluginVersion, + ( + | protos.google.cloud.networkservices.v1.IGetWasmPluginVersionRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getWasmPluginVersion response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of the specified `WasmPlugin` resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the `WasmPlugin` resource to get. Must be in the - * format `projects/{project}/locations/global/wasmPlugins/{wasm_plugin}`. - * @param {google.cloud.networkservices.v1.WasmPluginView} request.view - * Determines how much data must be returned in the response. See - * [AIP-157](https://google.aip.dev/157). - * @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 {@link protos.google.cloud.networkservices.v1.WasmPlugin|WasmPlugin}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_services.get_wasm_plugin.js - * region_tag:networkservices_v1_generated_NetworkServices_GetWasmPlugin_async - */ + /** + * Gets details of the specified `WasmPlugin` resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the `WasmPlugin` resource to get. Must be in the + * format `projects/{project}/locations/global/wasmPlugins/{wasm_plugin}`. + * @param {google.cloud.networkservices.v1.WasmPluginView} request.view + * Determines how much data must be returned in the response. See + * [AIP-157](https://google.aip.dev/157). + * @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 {@link protos.google.cloud.networkservices.v1.WasmPlugin|WasmPlugin}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_services.get_wasm_plugin.js + * region_tag:networkservices_v1_generated_NetworkServices_GetWasmPlugin_async + */ getWasmPlugin( - request?: protos.google.cloud.networkservices.v1.IGetWasmPluginRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.IWasmPlugin, - protos.google.cloud.networkservices.v1.IGetWasmPluginRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IGetWasmPluginRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IWasmPlugin, + protos.google.cloud.networkservices.v1.IGetWasmPluginRequest | undefined, + {} | undefined, + ] + >; getWasmPlugin( - request: protos.google.cloud.networkservices.v1.IGetWasmPluginRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkservices.v1.IWasmPlugin, - protos.google.cloud.networkservices.v1.IGetWasmPluginRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetWasmPluginRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkservices.v1.IWasmPlugin, + | protos.google.cloud.networkservices.v1.IGetWasmPluginRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getWasmPlugin( - request: protos.google.cloud.networkservices.v1.IGetWasmPluginRequest, - callback: Callback< - protos.google.cloud.networkservices.v1.IWasmPlugin, - protos.google.cloud.networkservices.v1.IGetWasmPluginRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetWasmPluginRequest, + callback: Callback< + protos.google.cloud.networkservices.v1.IWasmPlugin, + | protos.google.cloud.networkservices.v1.IGetWasmPluginRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getWasmPlugin( - request?: protos.google.cloud.networkservices.v1.IGetWasmPluginRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkservices.v1.IWasmPlugin, - protos.google.cloud.networkservices.v1.IGetWasmPluginRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkservices.v1.IGetWasmPluginRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkservices.v1.IWasmPlugin, - protos.google.cloud.networkservices.v1.IGetWasmPluginRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkservices.v1.IWasmPlugin, - protos.google.cloud.networkservices.v1.IGetWasmPluginRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkservices.v1.IGetWasmPluginRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkservices.v1.IWasmPlugin, + | protos.google.cloud.networkservices.v1.IGetWasmPluginRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IWasmPlugin, + protos.google.cloud.networkservices.v1.IGetWasmPluginRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getWasmPlugin request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkservices.v1.IWasmPlugin, - protos.google.cloud.networkservices.v1.IGetWasmPluginRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkservices.v1.IWasmPlugin, + | protos.google.cloud.networkservices.v1.IGetWasmPluginRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getWasmPlugin response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getWasmPlugin(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkservices.v1.IWasmPlugin, - protos.google.cloud.networkservices.v1.IGetWasmPluginRequest|undefined, - {}|undefined - ]) => { - this._log.info('getWasmPlugin response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getWasmPlugin(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkservices.v1.IWasmPlugin, + ( + | protos.google.cloud.networkservices.v1.IGetWasmPluginRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getWasmPlugin response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single Gateway. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the Gateway to get. Must be in the format - * `projects/* /locations/* /gateways/*`. - * @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 {@link protos.google.cloud.networkservices.v1.Gateway|Gateway}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_services.get_gateway.js - * region_tag:networkservices_v1_generated_NetworkServices_GetGateway_async - */ + /** + * Gets details of a single Gateway. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the Gateway to get. Must be in the format + * `projects/* /locations/* /gateways/*`. + * @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 {@link protos.google.cloud.networkservices.v1.Gateway|Gateway}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_services.get_gateway.js + * region_tag:networkservices_v1_generated_NetworkServices_GetGateway_async + */ getGateway( - request?: protos.google.cloud.networkservices.v1.IGetGatewayRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.IGateway, - protos.google.cloud.networkservices.v1.IGetGatewayRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IGetGatewayRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IGateway, + protos.google.cloud.networkservices.v1.IGetGatewayRequest | undefined, + {} | undefined, + ] + >; getGateway( - request: protos.google.cloud.networkservices.v1.IGetGatewayRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkservices.v1.IGateway, - protos.google.cloud.networkservices.v1.IGetGatewayRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetGatewayRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkservices.v1.IGateway, + | protos.google.cloud.networkservices.v1.IGetGatewayRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getGateway( - request: protos.google.cloud.networkservices.v1.IGetGatewayRequest, - callback: Callback< - protos.google.cloud.networkservices.v1.IGateway, - protos.google.cloud.networkservices.v1.IGetGatewayRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetGatewayRequest, + callback: Callback< + protos.google.cloud.networkservices.v1.IGateway, + | protos.google.cloud.networkservices.v1.IGetGatewayRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getGateway( - request?: protos.google.cloud.networkservices.v1.IGetGatewayRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkservices.v1.IGateway, - protos.google.cloud.networkservices.v1.IGetGatewayRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkservices.v1.IGetGatewayRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkservices.v1.IGateway, - protos.google.cloud.networkservices.v1.IGetGatewayRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkservices.v1.IGateway, - protos.google.cloud.networkservices.v1.IGetGatewayRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkservices.v1.IGetGatewayRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkservices.v1.IGateway, + | protos.google.cloud.networkservices.v1.IGetGatewayRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IGateway, + protos.google.cloud.networkservices.v1.IGetGatewayRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getGateway request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkservices.v1.IGateway, - protos.google.cloud.networkservices.v1.IGetGatewayRequest|null|undefined, - {}|null|undefined>|undefined = callback - ? (error, response, options, rawResponse) => { - this._log.info('getGateway response %j', response); - callback!(error, response, options, rawResponse); // We verified callback above. + const wrappedCallback: + | Callback< + protos.google.cloud.networkservices.v1.IGateway, + | protos.google.cloud.networkservices.v1.IGetGatewayRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getGateway response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getGateway(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkservices.v1.IGateway, - protos.google.cloud.networkservices.v1.IGetGatewayRequest|undefined, - {}|undefined - ]) => { - this._log.info('getGateway response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getGateway(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkservices.v1.IGateway, + protos.google.cloud.networkservices.v1.IGetGatewayRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getGateway response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single GrpcRoute. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the GrpcRoute to get. Must be in the format - * `projects/* /locations/global/grpcRoutes/*`. - * @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 {@link protos.google.cloud.networkservices.v1.GrpcRoute|GrpcRoute}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_services.get_grpc_route.js - * region_tag:networkservices_v1_generated_NetworkServices_GetGrpcRoute_async - */ + /** + * Gets details of a single GrpcRoute. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the GrpcRoute to get. Must be in the format + * `projects/* /locations/global/grpcRoutes/*`. + * @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 {@link protos.google.cloud.networkservices.v1.GrpcRoute|GrpcRoute}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_services.get_grpc_route.js + * region_tag:networkservices_v1_generated_NetworkServices_GetGrpcRoute_async + */ getGrpcRoute( - request?: protos.google.cloud.networkservices.v1.IGetGrpcRouteRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.IGrpcRoute, - protos.google.cloud.networkservices.v1.IGetGrpcRouteRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IGetGrpcRouteRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IGrpcRoute, + protos.google.cloud.networkservices.v1.IGetGrpcRouteRequest | undefined, + {} | undefined, + ] + >; getGrpcRoute( - request: protos.google.cloud.networkservices.v1.IGetGrpcRouteRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkservices.v1.IGrpcRoute, - protos.google.cloud.networkservices.v1.IGetGrpcRouteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetGrpcRouteRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkservices.v1.IGrpcRoute, + | protos.google.cloud.networkservices.v1.IGetGrpcRouteRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getGrpcRoute( - request: protos.google.cloud.networkservices.v1.IGetGrpcRouteRequest, - callback: Callback< - protos.google.cloud.networkservices.v1.IGrpcRoute, - protos.google.cloud.networkservices.v1.IGetGrpcRouteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetGrpcRouteRequest, + callback: Callback< + protos.google.cloud.networkservices.v1.IGrpcRoute, + | protos.google.cloud.networkservices.v1.IGetGrpcRouteRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getGrpcRoute( - request?: protos.google.cloud.networkservices.v1.IGetGrpcRouteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkservices.v1.IGrpcRoute, - protos.google.cloud.networkservices.v1.IGetGrpcRouteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkservices.v1.IGetGrpcRouteRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkservices.v1.IGrpcRoute, - protos.google.cloud.networkservices.v1.IGetGrpcRouteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkservices.v1.IGrpcRoute, - protos.google.cloud.networkservices.v1.IGetGrpcRouteRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkservices.v1.IGetGrpcRouteRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkservices.v1.IGrpcRoute, + | protos.google.cloud.networkservices.v1.IGetGrpcRouteRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IGrpcRoute, + protos.google.cloud.networkservices.v1.IGetGrpcRouteRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getGrpcRoute request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkservices.v1.IGrpcRoute, - protos.google.cloud.networkservices.v1.IGetGrpcRouteRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkservices.v1.IGrpcRoute, + | protos.google.cloud.networkservices.v1.IGetGrpcRouteRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getGrpcRoute response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getGrpcRoute(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkservices.v1.IGrpcRoute, - protos.google.cloud.networkservices.v1.IGetGrpcRouteRequest|undefined, - {}|undefined - ]) => { - this._log.info('getGrpcRoute response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getGrpcRoute(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkservices.v1.IGrpcRoute, + ( + | protos.google.cloud.networkservices.v1.IGetGrpcRouteRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getGrpcRoute response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single HttpRoute. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the HttpRoute to get. Must be in the format - * `projects/* /locations/global/httpRoutes/*`. - * @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 {@link protos.google.cloud.networkservices.v1.HttpRoute|HttpRoute}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_services.get_http_route.js - * region_tag:networkservices_v1_generated_NetworkServices_GetHttpRoute_async - */ + /** + * Gets details of a single HttpRoute. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the HttpRoute to get. Must be in the format + * `projects/* /locations/global/httpRoutes/*`. + * @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 {@link protos.google.cloud.networkservices.v1.HttpRoute|HttpRoute}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_services.get_http_route.js + * region_tag:networkservices_v1_generated_NetworkServices_GetHttpRoute_async + */ getHttpRoute( - request?: protos.google.cloud.networkservices.v1.IGetHttpRouteRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.IHttpRoute, - protos.google.cloud.networkservices.v1.IGetHttpRouteRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IGetHttpRouteRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IHttpRoute, + protos.google.cloud.networkservices.v1.IGetHttpRouteRequest | undefined, + {} | undefined, + ] + >; getHttpRoute( - request: protos.google.cloud.networkservices.v1.IGetHttpRouteRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkservices.v1.IHttpRoute, - protos.google.cloud.networkservices.v1.IGetHttpRouteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetHttpRouteRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkservices.v1.IHttpRoute, + | protos.google.cloud.networkservices.v1.IGetHttpRouteRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getHttpRoute( - request: protos.google.cloud.networkservices.v1.IGetHttpRouteRequest, - callback: Callback< - protos.google.cloud.networkservices.v1.IHttpRoute, - protos.google.cloud.networkservices.v1.IGetHttpRouteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetHttpRouteRequest, + callback: Callback< + protos.google.cloud.networkservices.v1.IHttpRoute, + | protos.google.cloud.networkservices.v1.IGetHttpRouteRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getHttpRoute( - request?: protos.google.cloud.networkservices.v1.IGetHttpRouteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkservices.v1.IHttpRoute, - protos.google.cloud.networkservices.v1.IGetHttpRouteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkservices.v1.IGetHttpRouteRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkservices.v1.IHttpRoute, - protos.google.cloud.networkservices.v1.IGetHttpRouteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkservices.v1.IHttpRoute, - protos.google.cloud.networkservices.v1.IGetHttpRouteRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkservices.v1.IGetHttpRouteRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkservices.v1.IHttpRoute, + | protos.google.cloud.networkservices.v1.IGetHttpRouteRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IHttpRoute, + protos.google.cloud.networkservices.v1.IGetHttpRouteRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getHttpRoute request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkservices.v1.IHttpRoute, - protos.google.cloud.networkservices.v1.IGetHttpRouteRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkservices.v1.IHttpRoute, + | protos.google.cloud.networkservices.v1.IGetHttpRouteRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getHttpRoute response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getHttpRoute(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkservices.v1.IHttpRoute, - protos.google.cloud.networkservices.v1.IGetHttpRouteRequest|undefined, - {}|undefined - ]) => { - this._log.info('getHttpRoute response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getHttpRoute(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkservices.v1.IHttpRoute, + ( + | protos.google.cloud.networkservices.v1.IGetHttpRouteRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getHttpRoute response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single TcpRoute. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the TcpRoute to get. Must be in the format - * `projects/* /locations/global/tcpRoutes/*`. - * @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 {@link protos.google.cloud.networkservices.v1.TcpRoute|TcpRoute}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_services.get_tcp_route.js - * region_tag:networkservices_v1_generated_NetworkServices_GetTcpRoute_async - */ + /** + * Gets details of a single TcpRoute. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the TcpRoute to get. Must be in the format + * `projects/* /locations/global/tcpRoutes/*`. + * @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 {@link protos.google.cloud.networkservices.v1.TcpRoute|TcpRoute}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_services.get_tcp_route.js + * region_tag:networkservices_v1_generated_NetworkServices_GetTcpRoute_async + */ getTcpRoute( - request?: protos.google.cloud.networkservices.v1.IGetTcpRouteRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.ITcpRoute, - protos.google.cloud.networkservices.v1.IGetTcpRouteRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IGetTcpRouteRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.ITcpRoute, + protos.google.cloud.networkservices.v1.IGetTcpRouteRequest | undefined, + {} | undefined, + ] + >; getTcpRoute( - request: protos.google.cloud.networkservices.v1.IGetTcpRouteRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkservices.v1.ITcpRoute, - protos.google.cloud.networkservices.v1.IGetTcpRouteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetTcpRouteRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkservices.v1.ITcpRoute, + | protos.google.cloud.networkservices.v1.IGetTcpRouteRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getTcpRoute( - request: protos.google.cloud.networkservices.v1.IGetTcpRouteRequest, - callback: Callback< - protos.google.cloud.networkservices.v1.ITcpRoute, - protos.google.cloud.networkservices.v1.IGetTcpRouteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetTcpRouteRequest, + callback: Callback< + protos.google.cloud.networkservices.v1.ITcpRoute, + | protos.google.cloud.networkservices.v1.IGetTcpRouteRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getTcpRoute( - request?: protos.google.cloud.networkservices.v1.IGetTcpRouteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkservices.v1.ITcpRoute, - protos.google.cloud.networkservices.v1.IGetTcpRouteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkservices.v1.IGetTcpRouteRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkservices.v1.ITcpRoute, - protos.google.cloud.networkservices.v1.IGetTcpRouteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkservices.v1.ITcpRoute, - protos.google.cloud.networkservices.v1.IGetTcpRouteRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkservices.v1.IGetTcpRouteRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkservices.v1.ITcpRoute, + | protos.google.cloud.networkservices.v1.IGetTcpRouteRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.ITcpRoute, + protos.google.cloud.networkservices.v1.IGetTcpRouteRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getTcpRoute request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkservices.v1.ITcpRoute, - protos.google.cloud.networkservices.v1.IGetTcpRouteRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkservices.v1.ITcpRoute, + | protos.google.cloud.networkservices.v1.IGetTcpRouteRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getTcpRoute response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getTcpRoute(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkservices.v1.ITcpRoute, - protos.google.cloud.networkservices.v1.IGetTcpRouteRequest|undefined, - {}|undefined - ]) => { - this._log.info('getTcpRoute response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getTcpRoute(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkservices.v1.ITcpRoute, + ( + | protos.google.cloud.networkservices.v1.IGetTcpRouteRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getTcpRoute response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single TlsRoute. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the TlsRoute to get. Must be in the format - * `projects/* /locations/global/tlsRoutes/*`. - * @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 {@link protos.google.cloud.networkservices.v1.TlsRoute|TlsRoute}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_services.get_tls_route.js - * region_tag:networkservices_v1_generated_NetworkServices_GetTlsRoute_async - */ + /** + * Gets details of a single TlsRoute. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the TlsRoute to get. Must be in the format + * `projects/* /locations/global/tlsRoutes/*`. + * @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 {@link protos.google.cloud.networkservices.v1.TlsRoute|TlsRoute}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_services.get_tls_route.js + * region_tag:networkservices_v1_generated_NetworkServices_GetTlsRoute_async + */ getTlsRoute( - request?: protos.google.cloud.networkservices.v1.IGetTlsRouteRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.ITlsRoute, - protos.google.cloud.networkservices.v1.IGetTlsRouteRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IGetTlsRouteRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.ITlsRoute, + protos.google.cloud.networkservices.v1.IGetTlsRouteRequest | undefined, + {} | undefined, + ] + >; getTlsRoute( - request: protos.google.cloud.networkservices.v1.IGetTlsRouteRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkservices.v1.ITlsRoute, - protos.google.cloud.networkservices.v1.IGetTlsRouteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetTlsRouteRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkservices.v1.ITlsRoute, + | protos.google.cloud.networkservices.v1.IGetTlsRouteRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getTlsRoute( - request: protos.google.cloud.networkservices.v1.IGetTlsRouteRequest, - callback: Callback< - protos.google.cloud.networkservices.v1.ITlsRoute, - protos.google.cloud.networkservices.v1.IGetTlsRouteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetTlsRouteRequest, + callback: Callback< + protos.google.cloud.networkservices.v1.ITlsRoute, + | protos.google.cloud.networkservices.v1.IGetTlsRouteRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getTlsRoute( - request?: protos.google.cloud.networkservices.v1.IGetTlsRouteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkservices.v1.ITlsRoute, - protos.google.cloud.networkservices.v1.IGetTlsRouteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkservices.v1.IGetTlsRouteRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkservices.v1.ITlsRoute, - protos.google.cloud.networkservices.v1.IGetTlsRouteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkservices.v1.ITlsRoute, - protos.google.cloud.networkservices.v1.IGetTlsRouteRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkservices.v1.IGetTlsRouteRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkservices.v1.ITlsRoute, + | protos.google.cloud.networkservices.v1.IGetTlsRouteRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.ITlsRoute, + protos.google.cloud.networkservices.v1.IGetTlsRouteRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getTlsRoute request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkservices.v1.ITlsRoute, - protos.google.cloud.networkservices.v1.IGetTlsRouteRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkservices.v1.ITlsRoute, + | protos.google.cloud.networkservices.v1.IGetTlsRouteRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getTlsRoute response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getTlsRoute(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkservices.v1.ITlsRoute, - protos.google.cloud.networkservices.v1.IGetTlsRouteRequest|undefined, - {}|undefined - ]) => { - this._log.info('getTlsRoute response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getTlsRoute(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkservices.v1.ITlsRoute, + ( + | protos.google.cloud.networkservices.v1.IGetTlsRouteRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getTlsRoute response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single ServiceBinding. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the ServiceBinding to get. Must be in the format - * `projects/* /locations/* /serviceBindings/*`. - * @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 {@link protos.google.cloud.networkservices.v1.ServiceBinding|ServiceBinding}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_services.get_service_binding.js - * region_tag:networkservices_v1_generated_NetworkServices_GetServiceBinding_async - */ + /** + * Gets details of a single ServiceBinding. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the ServiceBinding to get. Must be in the format + * `projects/* /locations/* /serviceBindings/*`. + * @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 {@link protos.google.cloud.networkservices.v1.ServiceBinding|ServiceBinding}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_services.get_service_binding.js + * region_tag:networkservices_v1_generated_NetworkServices_GetServiceBinding_async + */ getServiceBinding( - request?: protos.google.cloud.networkservices.v1.IGetServiceBindingRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.IServiceBinding, - protos.google.cloud.networkservices.v1.IGetServiceBindingRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IGetServiceBindingRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IServiceBinding, + ( + | protos.google.cloud.networkservices.v1.IGetServiceBindingRequest + | undefined + ), + {} | undefined, + ] + >; getServiceBinding( - request: protos.google.cloud.networkservices.v1.IGetServiceBindingRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkservices.v1.IServiceBinding, - protos.google.cloud.networkservices.v1.IGetServiceBindingRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetServiceBindingRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkservices.v1.IServiceBinding, + | protos.google.cloud.networkservices.v1.IGetServiceBindingRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getServiceBinding( - request: protos.google.cloud.networkservices.v1.IGetServiceBindingRequest, - callback: Callback< - protos.google.cloud.networkservices.v1.IServiceBinding, - protos.google.cloud.networkservices.v1.IGetServiceBindingRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetServiceBindingRequest, + callback: Callback< + protos.google.cloud.networkservices.v1.IServiceBinding, + | protos.google.cloud.networkservices.v1.IGetServiceBindingRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getServiceBinding( - request?: protos.google.cloud.networkservices.v1.IGetServiceBindingRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkservices.v1.IServiceBinding, - protos.google.cloud.networkservices.v1.IGetServiceBindingRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkservices.v1.IGetServiceBindingRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkservices.v1.IServiceBinding, - protos.google.cloud.networkservices.v1.IGetServiceBindingRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkservices.v1.IServiceBinding, - protos.google.cloud.networkservices.v1.IGetServiceBindingRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkservices.v1.IGetServiceBindingRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkservices.v1.IServiceBinding, + | protos.google.cloud.networkservices.v1.IGetServiceBindingRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IServiceBinding, + ( + | protos.google.cloud.networkservices.v1.IGetServiceBindingRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getServiceBinding request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkservices.v1.IServiceBinding, - protos.google.cloud.networkservices.v1.IGetServiceBindingRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkservices.v1.IServiceBinding, + | protos.google.cloud.networkservices.v1.IGetServiceBindingRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getServiceBinding response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getServiceBinding(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkservices.v1.IServiceBinding, - protos.google.cloud.networkservices.v1.IGetServiceBindingRequest|undefined, - {}|undefined - ]) => { - this._log.info('getServiceBinding response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getServiceBinding(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkservices.v1.IServiceBinding, + ( + | protos.google.cloud.networkservices.v1.IGetServiceBindingRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getServiceBinding response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single Mesh. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the Mesh to get. Must be in the format - * `projects/* /locations/global/meshes/*`. - * @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 {@link protos.google.cloud.networkservices.v1.Mesh|Mesh}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_services.get_mesh.js - * region_tag:networkservices_v1_generated_NetworkServices_GetMesh_async - */ + /** + * Gets details of a single Mesh. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the Mesh to get. Must be in the format + * `projects/* /locations/global/meshes/*`. + * @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 {@link protos.google.cloud.networkservices.v1.Mesh|Mesh}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_services.get_mesh.js + * region_tag:networkservices_v1_generated_NetworkServices_GetMesh_async + */ getMesh( - request?: protos.google.cloud.networkservices.v1.IGetMeshRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.IMesh, - protos.google.cloud.networkservices.v1.IGetMeshRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IGetMeshRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IMesh, + protos.google.cloud.networkservices.v1.IGetMeshRequest | undefined, + {} | undefined, + ] + >; getMesh( - request: protos.google.cloud.networkservices.v1.IGetMeshRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkservices.v1.IMesh, - protos.google.cloud.networkservices.v1.IGetMeshRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetMeshRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkservices.v1.IMesh, + protos.google.cloud.networkservices.v1.IGetMeshRequest | null | undefined, + {} | null | undefined + >, + ): void; getMesh( - request: protos.google.cloud.networkservices.v1.IGetMeshRequest, - callback: Callback< - protos.google.cloud.networkservices.v1.IMesh, - protos.google.cloud.networkservices.v1.IGetMeshRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetMeshRequest, + callback: Callback< + protos.google.cloud.networkservices.v1.IMesh, + protos.google.cloud.networkservices.v1.IGetMeshRequest | null | undefined, + {} | null | undefined + >, + ): void; getMesh( - request?: protos.google.cloud.networkservices.v1.IGetMeshRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkservices.v1.IMesh, - protos.google.cloud.networkservices.v1.IGetMeshRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkservices.v1.IGetMeshRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkservices.v1.IMesh, - protos.google.cloud.networkservices.v1.IGetMeshRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkservices.v1.IMesh, - protos.google.cloud.networkservices.v1.IGetMeshRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkservices.v1.IGetMeshRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkservices.v1.IMesh, + protos.google.cloud.networkservices.v1.IGetMeshRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IMesh, + protos.google.cloud.networkservices.v1.IGetMeshRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getMesh request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkservices.v1.IMesh, - protos.google.cloud.networkservices.v1.IGetMeshRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkservices.v1.IMesh, + | protos.google.cloud.networkservices.v1.IGetMeshRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getMesh response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getMesh(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkservices.v1.IMesh, - protos.google.cloud.networkservices.v1.IGetMeshRequest|undefined, - {}|undefined - ]) => { - this._log.info('getMesh response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getMesh(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkservices.v1.IMesh, + protos.google.cloud.networkservices.v1.IGetMeshRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getMesh response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single ServiceLbPolicy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the ServiceLbPolicy to get. Must be in the format - * `projects/{project}/locations/{location}/serviceLbPolicies/*`. - * @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 {@link protos.google.cloud.networkservices.v1.ServiceLbPolicy|ServiceLbPolicy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_services.get_service_lb_policy.js - * region_tag:networkservices_v1_generated_NetworkServices_GetServiceLbPolicy_async - */ + /** + * Gets details of a single ServiceLbPolicy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the ServiceLbPolicy to get. Must be in the format + * `projects/{project}/locations/{location}/serviceLbPolicies/*`. + * @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 {@link protos.google.cloud.networkservices.v1.ServiceLbPolicy|ServiceLbPolicy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_services.get_service_lb_policy.js + * region_tag:networkservices_v1_generated_NetworkServices_GetServiceLbPolicy_async + */ getServiceLbPolicy( - request?: protos.google.cloud.networkservices.v1.IGetServiceLbPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.IServiceLbPolicy, - protos.google.cloud.networkservices.v1.IGetServiceLbPolicyRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IGetServiceLbPolicyRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IServiceLbPolicy, + ( + | protos.google.cloud.networkservices.v1.IGetServiceLbPolicyRequest + | undefined + ), + {} | undefined, + ] + >; getServiceLbPolicy( - request: protos.google.cloud.networkservices.v1.IGetServiceLbPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkservices.v1.IServiceLbPolicy, - protos.google.cloud.networkservices.v1.IGetServiceLbPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetServiceLbPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkservices.v1.IServiceLbPolicy, + | protos.google.cloud.networkservices.v1.IGetServiceLbPolicyRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getServiceLbPolicy( - request: protos.google.cloud.networkservices.v1.IGetServiceLbPolicyRequest, - callback: Callback< - protos.google.cloud.networkservices.v1.IServiceLbPolicy, - protos.google.cloud.networkservices.v1.IGetServiceLbPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetServiceLbPolicyRequest, + callback: Callback< + protos.google.cloud.networkservices.v1.IServiceLbPolicy, + | protos.google.cloud.networkservices.v1.IGetServiceLbPolicyRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getServiceLbPolicy( - request?: protos.google.cloud.networkservices.v1.IGetServiceLbPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkservices.v1.IServiceLbPolicy, - protos.google.cloud.networkservices.v1.IGetServiceLbPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkservices.v1.IGetServiceLbPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkservices.v1.IServiceLbPolicy, - protos.google.cloud.networkservices.v1.IGetServiceLbPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkservices.v1.IServiceLbPolicy, - protos.google.cloud.networkservices.v1.IGetServiceLbPolicyRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkservices.v1.IGetServiceLbPolicyRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkservices.v1.IServiceLbPolicy, + | protos.google.cloud.networkservices.v1.IGetServiceLbPolicyRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IServiceLbPolicy, + ( + | protos.google.cloud.networkservices.v1.IGetServiceLbPolicyRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getServiceLbPolicy request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkservices.v1.IServiceLbPolicy, - protos.google.cloud.networkservices.v1.IGetServiceLbPolicyRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkservices.v1.IServiceLbPolicy, + | protos.google.cloud.networkservices.v1.IGetServiceLbPolicyRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getServiceLbPolicy response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getServiceLbPolicy(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkservices.v1.IServiceLbPolicy, - protos.google.cloud.networkservices.v1.IGetServiceLbPolicyRequest|undefined, - {}|undefined - ]) => { - this._log.info('getServiceLbPolicy response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getServiceLbPolicy(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkservices.v1.IServiceLbPolicy, + ( + | protos.google.cloud.networkservices.v1.IGetServiceLbPolicyRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getServiceLbPolicy response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Get a single RouteView of a Gateway. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the GatewayRouteView resource. - * Formats: - * projects/{project}/locations/{location}/gateways/{gateway}/routeViews/{route_view} - * @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 {@link protos.google.cloud.networkservices.v1.GatewayRouteView|GatewayRouteView}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_services.get_gateway_route_view.js - * region_tag:networkservices_v1_generated_NetworkServices_GetGatewayRouteView_async - */ + /** + * Get a single RouteView of a Gateway. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the GatewayRouteView resource. + * Formats: + * projects/{project}/locations/{location}/gateways/{gateway}/routeViews/{route_view} + * @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 {@link protos.google.cloud.networkservices.v1.GatewayRouteView|GatewayRouteView}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_services.get_gateway_route_view.js + * region_tag:networkservices_v1_generated_NetworkServices_GetGatewayRouteView_async + */ getGatewayRouteView( - request?: protos.google.cloud.networkservices.v1.IGetGatewayRouteViewRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.IGatewayRouteView, - protos.google.cloud.networkservices.v1.IGetGatewayRouteViewRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IGetGatewayRouteViewRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IGatewayRouteView, + ( + | protos.google.cloud.networkservices.v1.IGetGatewayRouteViewRequest + | undefined + ), + {} | undefined, + ] + >; getGatewayRouteView( - request: protos.google.cloud.networkservices.v1.IGetGatewayRouteViewRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkservices.v1.IGatewayRouteView, - protos.google.cloud.networkservices.v1.IGetGatewayRouteViewRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetGatewayRouteViewRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkservices.v1.IGatewayRouteView, + | protos.google.cloud.networkservices.v1.IGetGatewayRouteViewRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getGatewayRouteView( - request: protos.google.cloud.networkservices.v1.IGetGatewayRouteViewRequest, - callback: Callback< - protos.google.cloud.networkservices.v1.IGatewayRouteView, - protos.google.cloud.networkservices.v1.IGetGatewayRouteViewRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetGatewayRouteViewRequest, + callback: Callback< + protos.google.cloud.networkservices.v1.IGatewayRouteView, + | protos.google.cloud.networkservices.v1.IGetGatewayRouteViewRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getGatewayRouteView( - request?: protos.google.cloud.networkservices.v1.IGetGatewayRouteViewRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkservices.v1.IGatewayRouteView, - protos.google.cloud.networkservices.v1.IGetGatewayRouteViewRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkservices.v1.IGetGatewayRouteViewRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkservices.v1.IGatewayRouteView, - protos.google.cloud.networkservices.v1.IGetGatewayRouteViewRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkservices.v1.IGatewayRouteView, - protos.google.cloud.networkservices.v1.IGetGatewayRouteViewRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkservices.v1.IGetGatewayRouteViewRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkservices.v1.IGatewayRouteView, + | protos.google.cloud.networkservices.v1.IGetGatewayRouteViewRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IGatewayRouteView, + ( + | protos.google.cloud.networkservices.v1.IGetGatewayRouteViewRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getGatewayRouteView request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkservices.v1.IGatewayRouteView, - protos.google.cloud.networkservices.v1.IGetGatewayRouteViewRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkservices.v1.IGatewayRouteView, + | protos.google.cloud.networkservices.v1.IGetGatewayRouteViewRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getGatewayRouteView response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getGatewayRouteView(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkservices.v1.IGatewayRouteView, - protos.google.cloud.networkservices.v1.IGetGatewayRouteViewRequest|undefined, - {}|undefined - ]) => { - this._log.info('getGatewayRouteView response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getGatewayRouteView(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkservices.v1.IGatewayRouteView, + ( + | protos.google.cloud.networkservices.v1.IGetGatewayRouteViewRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getGatewayRouteView response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Get a single RouteView of a Mesh. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the MeshRouteView resource. - * Format: - * projects/{project}/locations/{location}/meshes/{mesh}/routeViews/{route_view} - * @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 {@link protos.google.cloud.networkservices.v1.MeshRouteView|MeshRouteView}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_services.get_mesh_route_view.js - * region_tag:networkservices_v1_generated_NetworkServices_GetMeshRouteView_async - */ + /** + * Get a single RouteView of a Mesh. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the MeshRouteView resource. + * Format: + * projects/{project}/locations/{location}/meshes/{mesh}/routeViews/{route_view} + * @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 {@link protos.google.cloud.networkservices.v1.MeshRouteView|MeshRouteView}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_services.get_mesh_route_view.js + * region_tag:networkservices_v1_generated_NetworkServices_GetMeshRouteView_async + */ getMeshRouteView( - request?: protos.google.cloud.networkservices.v1.IGetMeshRouteViewRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.IMeshRouteView, - protos.google.cloud.networkservices.v1.IGetMeshRouteViewRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IGetMeshRouteViewRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IMeshRouteView, + ( + | protos.google.cloud.networkservices.v1.IGetMeshRouteViewRequest + | undefined + ), + {} | undefined, + ] + >; getMeshRouteView( - request: protos.google.cloud.networkservices.v1.IGetMeshRouteViewRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkservices.v1.IMeshRouteView, - protos.google.cloud.networkservices.v1.IGetMeshRouteViewRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetMeshRouteViewRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkservices.v1.IMeshRouteView, + | protos.google.cloud.networkservices.v1.IGetMeshRouteViewRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getMeshRouteView( - request: protos.google.cloud.networkservices.v1.IGetMeshRouteViewRequest, - callback: Callback< - protos.google.cloud.networkservices.v1.IMeshRouteView, - protos.google.cloud.networkservices.v1.IGetMeshRouteViewRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IGetMeshRouteViewRequest, + callback: Callback< + protos.google.cloud.networkservices.v1.IMeshRouteView, + | protos.google.cloud.networkservices.v1.IGetMeshRouteViewRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getMeshRouteView( - request?: protos.google.cloud.networkservices.v1.IGetMeshRouteViewRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkservices.v1.IMeshRouteView, - protos.google.cloud.networkservices.v1.IGetMeshRouteViewRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkservices.v1.IGetMeshRouteViewRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkservices.v1.IMeshRouteView, - protos.google.cloud.networkservices.v1.IGetMeshRouteViewRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkservices.v1.IMeshRouteView, - protos.google.cloud.networkservices.v1.IGetMeshRouteViewRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkservices.v1.IGetMeshRouteViewRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkservices.v1.IMeshRouteView, + | protos.google.cloud.networkservices.v1.IGetMeshRouteViewRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IMeshRouteView, + ( + | protos.google.cloud.networkservices.v1.IGetMeshRouteViewRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getMeshRouteView request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkservices.v1.IMeshRouteView, - protos.google.cloud.networkservices.v1.IGetMeshRouteViewRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkservices.v1.IMeshRouteView, + | protos.google.cloud.networkservices.v1.IGetMeshRouteViewRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getMeshRouteView response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getMeshRouteView(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkservices.v1.IMeshRouteView, - protos.google.cloud.networkservices.v1.IGetMeshRouteViewRequest|undefined, - {}|undefined - ]) => { - this._log.info('getMeshRouteView response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getMeshRouteView(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkservices.v1.IMeshRouteView, + ( + | protos.google.cloud.networkservices.v1.IGetMeshRouteViewRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getMeshRouteView response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a new EndpointPolicy in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the EndpointPolicy. Must be in the - * format `projects/* /locations/global`. - * @param {string} request.endpointPolicyId - * Required. Short name of the EndpointPolicy resource to be created. - * E.g. "CustomECS". - * @param {google.cloud.networkservices.v1.EndpointPolicy} request.endpointPolicy - * Required. EndpointPolicy resource to be created. - * @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/network_services.create_endpoint_policy.js - * region_tag:networkservices_v1_generated_NetworkServices_CreateEndpointPolicy_async - */ + /** + * Creates a new EndpointPolicy in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the EndpointPolicy. Must be in the + * format `projects/* /locations/global`. + * @param {string} request.endpointPolicyId + * Required. Short name of the EndpointPolicy resource to be created. + * E.g. "CustomECS". + * @param {google.cloud.networkservices.v1.EndpointPolicy} request.endpointPolicy + * Required. EndpointPolicy resource to be created. + * @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/network_services.create_endpoint_policy.js + * region_tag:networkservices_v1_generated_NetworkServices_CreateEndpointPolicy_async + */ createEndpointPolicy( - request?: protos.google.cloud.networkservices.v1.ICreateEndpointPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.ICreateEndpointPolicyRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IEndpointPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createEndpointPolicy( - request: protos.google.cloud.networkservices.v1.ICreateEndpointPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.ICreateEndpointPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IEndpointPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createEndpointPolicy( - request: protos.google.cloud.networkservices.v1.ICreateEndpointPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.ICreateEndpointPolicyRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IEndpointPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createEndpointPolicy( - request?: protos.google.cloud.networkservices.v1.ICreateEndpointPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.ICreateEndpointPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IEndpointPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IEndpointPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IEndpointPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IEndpointPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createEndpointPolicy response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createEndpointPolicy request %j', request); - return this.innerApiCalls.createEndpointPolicy(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createEndpointPolicy response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createEndpointPolicy(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1.IEndpointPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createEndpointPolicy response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createEndpointPolicy()`. - * @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/network_services.create_endpoint_policy.js - * region_tag:networkservices_v1_generated_NetworkServices_CreateEndpointPolicy_async - */ - async checkCreateEndpointPolicyProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createEndpointPolicy()`. + * @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/network_services.create_endpoint_policy.js + * region_tag:networkservices_v1_generated_NetworkServices_CreateEndpointPolicy_async + */ + async checkCreateEndpointPolicyProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1.EndpointPolicy, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('createEndpointPolicy long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createEndpointPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createEndpointPolicy, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1.EndpointPolicy, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Updates the parameters of a single EndpointPolicy. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask is used to specify the fields to be overwritten in the - * EndpointPolicy resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - * @param {google.cloud.networkservices.v1.EndpointPolicy} request.endpointPolicy - * Required. Updated EndpointPolicy resource. - * @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/network_services.update_endpoint_policy.js - * region_tag:networkservices_v1_generated_NetworkServices_UpdateEndpointPolicy_async - */ + /** + * Updates the parameters of a single EndpointPolicy. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask is used to specify the fields to be overwritten in the + * EndpointPolicy resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @param {google.cloud.networkservices.v1.EndpointPolicy} request.endpointPolicy + * Required. Updated EndpointPolicy resource. + * @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/network_services.update_endpoint_policy.js + * region_tag:networkservices_v1_generated_NetworkServices_UpdateEndpointPolicy_async + */ updateEndpointPolicy( - request?: protos.google.cloud.networkservices.v1.IUpdateEndpointPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IUpdateEndpointPolicyRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IEndpointPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateEndpointPolicy( - request: protos.google.cloud.networkservices.v1.IUpdateEndpointPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IUpdateEndpointPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IEndpointPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateEndpointPolicy( - request: protos.google.cloud.networkservices.v1.IUpdateEndpointPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IUpdateEndpointPolicyRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IEndpointPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateEndpointPolicy( - request?: protos.google.cloud.networkservices.v1.IUpdateEndpointPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.IUpdateEndpointPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IEndpointPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IEndpointPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IEndpointPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'endpoint_policy.name': request.endpointPolicy!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'endpoint_policy.name': request.endpointPolicy!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IEndpointPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateEndpointPolicy response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateEndpointPolicy request %j', request); - return this.innerApiCalls.updateEndpointPolicy(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateEndpointPolicy response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateEndpointPolicy(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1.IEndpointPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateEndpointPolicy response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateEndpointPolicy()`. - * @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/network_services.update_endpoint_policy.js - * region_tag:networkservices_v1_generated_NetworkServices_UpdateEndpointPolicy_async - */ - async checkUpdateEndpointPolicyProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateEndpointPolicy()`. + * @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/network_services.update_endpoint_policy.js + * region_tag:networkservices_v1_generated_NetworkServices_UpdateEndpointPolicy_async + */ + async checkUpdateEndpointPolicyProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1.EndpointPolicy, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('updateEndpointPolicy long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateEndpointPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateEndpointPolicy, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1.EndpointPolicy, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Deletes a single EndpointPolicy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the EndpointPolicy to delete. Must be in the format - * `projects/* /locations/global/endpointPolicies/*`. - * @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/network_services.delete_endpoint_policy.js - * region_tag:networkservices_v1_generated_NetworkServices_DeleteEndpointPolicy_async - */ + /** + * Deletes a single EndpointPolicy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the EndpointPolicy to delete. Must be in the format + * `projects/* /locations/global/endpointPolicies/*`. + * @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/network_services.delete_endpoint_policy.js + * region_tag:networkservices_v1_generated_NetworkServices_DeleteEndpointPolicy_async + */ deleteEndpointPolicy( - request?: protos.google.cloud.networkservices.v1.IDeleteEndpointPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IDeleteEndpointPolicyRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteEndpointPolicy( - request: protos.google.cloud.networkservices.v1.IDeleteEndpointPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IDeleteEndpointPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteEndpointPolicy( - request: protos.google.cloud.networkservices.v1.IDeleteEndpointPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IDeleteEndpointPolicyRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteEndpointPolicy( - request?: protos.google.cloud.networkservices.v1.IDeleteEndpointPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.IDeleteEndpointPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteEndpointPolicy response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteEndpointPolicy request %j', request); - return this.innerApiCalls.deleteEndpointPolicy(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteEndpointPolicy response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteEndpointPolicy(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteEndpointPolicy response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteEndpointPolicy()`. - * @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/network_services.delete_endpoint_policy.js - * region_tag:networkservices_v1_generated_NetworkServices_DeleteEndpointPolicy_async - */ - async checkDeleteEndpointPolicyProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteEndpointPolicy()`. + * @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/network_services.delete_endpoint_policy.js + * region_tag:networkservices_v1_generated_NetworkServices_DeleteEndpointPolicy_async + */ + async checkDeleteEndpointPolicyProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('deleteEndpointPolicy long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteEndpointPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteEndpointPolicy, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Creates a new `WasmPluginVersion` resource in a given project - * and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the `WasmPluginVersion` resource. Must be - * in the format - * `projects/{project}/locations/global/wasmPlugins/{wasm_plugin}`. - * @param {string} request.wasmPluginVersionId - * Required. User-provided ID of the `WasmPluginVersion` resource to be - * created. - * @param {google.cloud.networkservices.v1.WasmPluginVersion} request.wasmPluginVersion - * Required. `WasmPluginVersion` resource to be created. - * @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/network_services.create_wasm_plugin_version.js - * region_tag:networkservices_v1_generated_NetworkServices_CreateWasmPluginVersion_async - */ + /** + * Creates a new `WasmPluginVersion` resource in a given project + * and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the `WasmPluginVersion` resource. Must be + * in the format + * `projects/{project}/locations/global/wasmPlugins/{wasm_plugin}`. + * @param {string} request.wasmPluginVersionId + * Required. User-provided ID of the `WasmPluginVersion` resource to be + * created. + * @param {google.cloud.networkservices.v1.WasmPluginVersion} request.wasmPluginVersion + * Required. `WasmPluginVersion` resource to be created. + * @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/network_services.create_wasm_plugin_version.js + * region_tag:networkservices_v1_generated_NetworkServices_CreateWasmPluginVersion_async + */ createWasmPluginVersion( - request?: protos.google.cloud.networkservices.v1.ICreateWasmPluginVersionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.ICreateWasmPluginVersionRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IWasmPluginVersion, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createWasmPluginVersion( - request: protos.google.cloud.networkservices.v1.ICreateWasmPluginVersionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.ICreateWasmPluginVersionRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IWasmPluginVersion, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createWasmPluginVersion( - request: protos.google.cloud.networkservices.v1.ICreateWasmPluginVersionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.ICreateWasmPluginVersionRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IWasmPluginVersion, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createWasmPluginVersion( - request?: protos.google.cloud.networkservices.v1.ICreateWasmPluginVersionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.ICreateWasmPluginVersionRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IWasmPluginVersion, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IWasmPluginVersion, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IWasmPluginVersion, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IWasmPluginVersion, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createWasmPluginVersion response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createWasmPluginVersion request %j', request); - return this.innerApiCalls.createWasmPluginVersion(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createWasmPluginVersion response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createWasmPluginVersion(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1.IWasmPluginVersion, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createWasmPluginVersion response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createWasmPluginVersion()`. - * @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/network_services.create_wasm_plugin_version.js - * region_tag:networkservices_v1_generated_NetworkServices_CreateWasmPluginVersion_async - */ - async checkCreateWasmPluginVersionProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createWasmPluginVersion()`. + * @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/network_services.create_wasm_plugin_version.js + * region_tag:networkservices_v1_generated_NetworkServices_CreateWasmPluginVersion_async + */ + async checkCreateWasmPluginVersionProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1.WasmPluginVersion, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('createWasmPluginVersion long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createWasmPluginVersion, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createWasmPluginVersion, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1.WasmPluginVersion, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Deletes the specified `WasmPluginVersion` resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the `WasmPluginVersion` resource to delete. Must be in - * the format - * `projects/{project}/locations/global/wasmPlugins/{wasm_plugin}/versions/{wasm_plugin_version}`. - * @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/network_services.delete_wasm_plugin_version.js - * region_tag:networkservices_v1_generated_NetworkServices_DeleteWasmPluginVersion_async - */ + /** + * Deletes the specified `WasmPluginVersion` resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the `WasmPluginVersion` resource to delete. Must be in + * the format + * `projects/{project}/locations/global/wasmPlugins/{wasm_plugin}/versions/{wasm_plugin_version}`. + * @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/network_services.delete_wasm_plugin_version.js + * region_tag:networkservices_v1_generated_NetworkServices_DeleteWasmPluginVersion_async + */ deleteWasmPluginVersion( - request?: protos.google.cloud.networkservices.v1.IDeleteWasmPluginVersionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IDeleteWasmPluginVersionRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteWasmPluginVersion( - request: protos.google.cloud.networkservices.v1.IDeleteWasmPluginVersionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IDeleteWasmPluginVersionRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteWasmPluginVersion( - request: protos.google.cloud.networkservices.v1.IDeleteWasmPluginVersionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IDeleteWasmPluginVersionRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteWasmPluginVersion( - request?: protos.google.cloud.networkservices.v1.IDeleteWasmPluginVersionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.IDeleteWasmPluginVersionRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteWasmPluginVersion response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteWasmPluginVersion request %j', request); - return this.innerApiCalls.deleteWasmPluginVersion(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteWasmPluginVersion response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteWasmPluginVersion(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteWasmPluginVersion response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteWasmPluginVersion()`. - * @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/network_services.delete_wasm_plugin_version.js - * region_tag:networkservices_v1_generated_NetworkServices_DeleteWasmPluginVersion_async - */ - async checkDeleteWasmPluginVersionProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteWasmPluginVersion()`. + * @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/network_services.delete_wasm_plugin_version.js + * region_tag:networkservices_v1_generated_NetworkServices_DeleteWasmPluginVersion_async + */ + async checkDeleteWasmPluginVersionProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('deleteWasmPluginVersion long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteWasmPluginVersion, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteWasmPluginVersion, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Creates a new `WasmPlugin` resource in a given project - * and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the `WasmPlugin` resource. Must be in the - * format `projects/{project}/locations/global`. - * @param {string} request.wasmPluginId - * Required. User-provided ID of the `WasmPlugin` resource to be created. - * @param {google.cloud.networkservices.v1.WasmPlugin} request.wasmPlugin - * Required. `WasmPlugin` resource to be created. - * @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/network_services.create_wasm_plugin.js - * region_tag:networkservices_v1_generated_NetworkServices_CreateWasmPlugin_async - */ + /** + * Creates a new `WasmPlugin` resource in a given project + * and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the `WasmPlugin` resource. Must be in the + * format `projects/{project}/locations/global`. + * @param {string} request.wasmPluginId + * Required. User-provided ID of the `WasmPlugin` resource to be created. + * @param {google.cloud.networkservices.v1.WasmPlugin} request.wasmPlugin + * Required. `WasmPlugin` resource to be created. + * @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/network_services.create_wasm_plugin.js + * region_tag:networkservices_v1_generated_NetworkServices_CreateWasmPlugin_async + */ createWasmPlugin( - request?: protos.google.cloud.networkservices.v1.ICreateWasmPluginRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.ICreateWasmPluginRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IWasmPlugin, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createWasmPlugin( - request: protos.google.cloud.networkservices.v1.ICreateWasmPluginRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.ICreateWasmPluginRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IWasmPlugin, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createWasmPlugin( - request: protos.google.cloud.networkservices.v1.ICreateWasmPluginRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.ICreateWasmPluginRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IWasmPlugin, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createWasmPlugin( - request?: protos.google.cloud.networkservices.v1.ICreateWasmPluginRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.ICreateWasmPluginRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IWasmPlugin, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IWasmPlugin, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IWasmPlugin, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IWasmPlugin, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createWasmPlugin response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createWasmPlugin request %j', request); - return this.innerApiCalls.createWasmPlugin(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createWasmPlugin response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createWasmPlugin(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1.IWasmPlugin, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createWasmPlugin response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createWasmPlugin()`. - * @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/network_services.create_wasm_plugin.js - * region_tag:networkservices_v1_generated_NetworkServices_CreateWasmPlugin_async - */ - async checkCreateWasmPluginProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createWasmPlugin()`. + * @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/network_services.create_wasm_plugin.js + * region_tag:networkservices_v1_generated_NetworkServices_CreateWasmPlugin_async + */ + async checkCreateWasmPluginProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1.WasmPlugin, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('createWasmPlugin long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createWasmPlugin, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createWasmPlugin, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1.WasmPlugin, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Updates the parameters of the specified `WasmPlugin` resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Used to specify the fields to be overwritten in the - * `WasmPlugin` resource by the update. - * The fields specified in the `update_mask` field are relative to the - * resource, not the full request. - * An omitted `update_mask` field is treated as an implied `update_mask` - * field equivalent to all fields that are populated (that have a non-empty - * value). - * The `update_mask` field supports a special value `*`, which means that - * each field in the given `WasmPlugin` resource (including the empty ones) - * replaces the current value. - * @param {google.cloud.networkservices.v1.WasmPlugin} request.wasmPlugin - * Required. Updated `WasmPlugin` resource. - * @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/network_services.update_wasm_plugin.js - * region_tag:networkservices_v1_generated_NetworkServices_UpdateWasmPlugin_async - */ + /** + * Updates the parameters of the specified `WasmPlugin` resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Used to specify the fields to be overwritten in the + * `WasmPlugin` resource by the update. + * The fields specified in the `update_mask` field are relative to the + * resource, not the full request. + * An omitted `update_mask` field is treated as an implied `update_mask` + * field equivalent to all fields that are populated (that have a non-empty + * value). + * The `update_mask` field supports a special value `*`, which means that + * each field in the given `WasmPlugin` resource (including the empty ones) + * replaces the current value. + * @param {google.cloud.networkservices.v1.WasmPlugin} request.wasmPlugin + * Required. Updated `WasmPlugin` resource. + * @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/network_services.update_wasm_plugin.js + * region_tag:networkservices_v1_generated_NetworkServices_UpdateWasmPlugin_async + */ updateWasmPlugin( - request?: protos.google.cloud.networkservices.v1.IUpdateWasmPluginRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IUpdateWasmPluginRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IWasmPlugin, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateWasmPlugin( - request: protos.google.cloud.networkservices.v1.IUpdateWasmPluginRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IUpdateWasmPluginRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IWasmPlugin, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateWasmPlugin( - request: protos.google.cloud.networkservices.v1.IUpdateWasmPluginRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IUpdateWasmPluginRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IWasmPlugin, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateWasmPlugin( - request?: protos.google.cloud.networkservices.v1.IUpdateWasmPluginRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.IUpdateWasmPluginRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IWasmPlugin, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IWasmPlugin, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IWasmPlugin, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'wasm_plugin.name': request.wasmPlugin!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'wasm_plugin.name': request.wasmPlugin!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IWasmPlugin, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateWasmPlugin response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateWasmPlugin request %j', request); - return this.innerApiCalls.updateWasmPlugin(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateWasmPlugin response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateWasmPlugin(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1.IWasmPlugin, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateWasmPlugin response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateWasmPlugin()`. - * @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/network_services.update_wasm_plugin.js - * region_tag:networkservices_v1_generated_NetworkServices_UpdateWasmPlugin_async - */ - async checkUpdateWasmPluginProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateWasmPlugin()`. + * @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/network_services.update_wasm_plugin.js + * region_tag:networkservices_v1_generated_NetworkServices_UpdateWasmPlugin_async + */ + async checkUpdateWasmPluginProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1.WasmPlugin, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('updateWasmPlugin long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateWasmPlugin, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateWasmPlugin, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1.WasmPlugin, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Deletes the specified `WasmPlugin` resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the `WasmPlugin` resource to delete. Must be in the - * format `projects/{project}/locations/global/wasmPlugins/{wasm_plugin}`. - * @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/network_services.delete_wasm_plugin.js - * region_tag:networkservices_v1_generated_NetworkServices_DeleteWasmPlugin_async - */ + /** + * Deletes the specified `WasmPlugin` resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the `WasmPlugin` resource to delete. Must be in the + * format `projects/{project}/locations/global/wasmPlugins/{wasm_plugin}`. + * @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/network_services.delete_wasm_plugin.js + * region_tag:networkservices_v1_generated_NetworkServices_DeleteWasmPlugin_async + */ deleteWasmPlugin( - request?: protos.google.cloud.networkservices.v1.IDeleteWasmPluginRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IDeleteWasmPluginRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteWasmPlugin( - request: protos.google.cloud.networkservices.v1.IDeleteWasmPluginRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IDeleteWasmPluginRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteWasmPlugin( - request: protos.google.cloud.networkservices.v1.IDeleteWasmPluginRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IDeleteWasmPluginRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteWasmPlugin( - request?: protos.google.cloud.networkservices.v1.IDeleteWasmPluginRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.IDeleteWasmPluginRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteWasmPlugin response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteWasmPlugin request %j', request); - return this.innerApiCalls.deleteWasmPlugin(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteWasmPlugin response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteWasmPlugin(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteWasmPlugin response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteWasmPlugin()`. - * @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/network_services.delete_wasm_plugin.js - * region_tag:networkservices_v1_generated_NetworkServices_DeleteWasmPlugin_async - */ - async checkDeleteWasmPluginProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteWasmPlugin()`. + * @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/network_services.delete_wasm_plugin.js + * region_tag:networkservices_v1_generated_NetworkServices_DeleteWasmPlugin_async + */ + async checkDeleteWasmPluginProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('deleteWasmPlugin long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteWasmPlugin, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteWasmPlugin, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Creates a new Gateway in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the Gateway. Must be in the - * format `projects/* /locations/*`. - * @param {string} request.gatewayId - * Required. Short name of the Gateway resource to be created. - * @param {google.cloud.networkservices.v1.Gateway} request.gateway - * Required. Gateway resource to be created. - * @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/network_services.create_gateway.js - * region_tag:networkservices_v1_generated_NetworkServices_CreateGateway_async - */ + /** + * Creates a new Gateway in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the Gateway. Must be in the + * format `projects/* /locations/*`. + * @param {string} request.gatewayId + * Required. Short name of the Gateway resource to be created. + * @param {google.cloud.networkservices.v1.Gateway} request.gateway + * Required. Gateway resource to be created. + * @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/network_services.create_gateway.js + * region_tag:networkservices_v1_generated_NetworkServices_CreateGateway_async + */ createGateway( - request?: protos.google.cloud.networkservices.v1.ICreateGatewayRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.ICreateGatewayRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IGateway, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createGateway( - request: protos.google.cloud.networkservices.v1.ICreateGatewayRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.ICreateGatewayRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IGateway, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createGateway( - request: protos.google.cloud.networkservices.v1.ICreateGatewayRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.ICreateGatewayRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IGateway, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createGateway( - request?: protos.google.cloud.networkservices.v1.ICreateGatewayRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.ICreateGatewayRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IGateway, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IGateway, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IGateway, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IGateway, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createGateway response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createGateway request %j', request); - return this.innerApiCalls.createGateway(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createGateway response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createGateway(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1.IGateway, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createGateway response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createGateway()`. - * @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/network_services.create_gateway.js - * region_tag:networkservices_v1_generated_NetworkServices_CreateGateway_async - */ - async checkCreateGatewayProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createGateway()`. + * @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/network_services.create_gateway.js + * region_tag:networkservices_v1_generated_NetworkServices_CreateGateway_async + */ + async checkCreateGatewayProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1.Gateway, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('createGateway long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createGateway, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createGateway, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1.Gateway, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Updates the parameters of a single Gateway. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask is used to specify the fields to be overwritten in the - * Gateway resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - * @param {google.cloud.networkservices.v1.Gateway} request.gateway - * Required. Updated Gateway resource. - * @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/network_services.update_gateway.js - * region_tag:networkservices_v1_generated_NetworkServices_UpdateGateway_async - */ + /** + * Updates the parameters of a single Gateway. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask is used to specify the fields to be overwritten in the + * Gateway resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @param {google.cloud.networkservices.v1.Gateway} request.gateway + * Required. Updated Gateway resource. + * @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/network_services.update_gateway.js + * region_tag:networkservices_v1_generated_NetworkServices_UpdateGateway_async + */ updateGateway( - request?: protos.google.cloud.networkservices.v1.IUpdateGatewayRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IUpdateGatewayRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IGateway, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateGateway( - request: protos.google.cloud.networkservices.v1.IUpdateGatewayRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IUpdateGatewayRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IGateway, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateGateway( - request: protos.google.cloud.networkservices.v1.IUpdateGatewayRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IUpdateGatewayRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IGateway, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateGateway( - request?: protos.google.cloud.networkservices.v1.IUpdateGatewayRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.IUpdateGatewayRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IGateway, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IGateway, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IGateway, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'gateway.name': request.gateway!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'gateway.name': request.gateway!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IGateway, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateGateway response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateGateway request %j', request); - return this.innerApiCalls.updateGateway(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateGateway response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateGateway(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1.IGateway, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateGateway response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateGateway()`. - * @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/network_services.update_gateway.js - * region_tag:networkservices_v1_generated_NetworkServices_UpdateGateway_async - */ - async checkUpdateGatewayProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateGateway()`. + * @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/network_services.update_gateway.js + * region_tag:networkservices_v1_generated_NetworkServices_UpdateGateway_async + */ + async checkUpdateGatewayProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1.Gateway, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('updateGateway long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateGateway, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateGateway, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1.Gateway, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Deletes a single Gateway. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the Gateway to delete. Must be in the format - * `projects/* /locations/* /gateways/*`. - * @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/network_services.delete_gateway.js - * region_tag:networkservices_v1_generated_NetworkServices_DeleteGateway_async - */ + /** + * Deletes a single Gateway. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the Gateway to delete. Must be in the format + * `projects/* /locations/* /gateways/*`. + * @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/network_services.delete_gateway.js + * region_tag:networkservices_v1_generated_NetworkServices_DeleteGateway_async + */ deleteGateway( - request?: protos.google.cloud.networkservices.v1.IDeleteGatewayRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IDeleteGatewayRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteGateway( - request: protos.google.cloud.networkservices.v1.IDeleteGatewayRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IDeleteGatewayRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteGateway( - request: protos.google.cloud.networkservices.v1.IDeleteGatewayRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IDeleteGatewayRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteGateway( - request?: protos.google.cloud.networkservices.v1.IDeleteGatewayRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.IDeleteGatewayRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteGateway response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteGateway request %j', request); - return this.innerApiCalls.deleteGateway(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteGateway response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteGateway(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteGateway response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteGateway()`. - * @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/network_services.delete_gateway.js - * region_tag:networkservices_v1_generated_NetworkServices_DeleteGateway_async - */ - async checkDeleteGatewayProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteGateway()`. + * @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/network_services.delete_gateway.js + * region_tag:networkservices_v1_generated_NetworkServices_DeleteGateway_async + */ + async checkDeleteGatewayProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('deleteGateway long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteGateway, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteGateway, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Creates a new GrpcRoute in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the GrpcRoute. Must be in the - * format `projects/* /locations/global`. - * @param {string} request.grpcRouteId - * Required. Short name of the GrpcRoute resource to be created. - * @param {google.cloud.networkservices.v1.GrpcRoute} request.grpcRoute - * Required. GrpcRoute resource to be created. - * @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/network_services.create_grpc_route.js - * region_tag:networkservices_v1_generated_NetworkServices_CreateGrpcRoute_async - */ + /** + * Creates a new GrpcRoute in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the GrpcRoute. Must be in the + * format `projects/* /locations/global`. + * @param {string} request.grpcRouteId + * Required. Short name of the GrpcRoute resource to be created. + * @param {google.cloud.networkservices.v1.GrpcRoute} request.grpcRoute + * Required. GrpcRoute resource to be created. + * @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/network_services.create_grpc_route.js + * region_tag:networkservices_v1_generated_NetworkServices_CreateGrpcRoute_async + */ createGrpcRoute( - request?: protos.google.cloud.networkservices.v1.ICreateGrpcRouteRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.ICreateGrpcRouteRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IGrpcRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createGrpcRoute( - request: protos.google.cloud.networkservices.v1.ICreateGrpcRouteRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.ICreateGrpcRouteRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IGrpcRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createGrpcRoute( - request: protos.google.cloud.networkservices.v1.ICreateGrpcRouteRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.ICreateGrpcRouteRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IGrpcRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createGrpcRoute( - request?: protos.google.cloud.networkservices.v1.ICreateGrpcRouteRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.ICreateGrpcRouteRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IGrpcRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IGrpcRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IGrpcRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IGrpcRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createGrpcRoute response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createGrpcRoute request %j', request); - return this.innerApiCalls.createGrpcRoute(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createGrpcRoute response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createGrpcRoute(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1.IGrpcRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createGrpcRoute response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createGrpcRoute()`. - * @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/network_services.create_grpc_route.js - * region_tag:networkservices_v1_generated_NetworkServices_CreateGrpcRoute_async - */ - async checkCreateGrpcRouteProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createGrpcRoute()`. + * @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/network_services.create_grpc_route.js + * region_tag:networkservices_v1_generated_NetworkServices_CreateGrpcRoute_async + */ + async checkCreateGrpcRouteProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1.GrpcRoute, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('createGrpcRoute long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createGrpcRoute, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createGrpcRoute, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1.GrpcRoute, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Updates the parameters of a single GrpcRoute. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask is used to specify the fields to be overwritten in the - * GrpcRoute resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - * @param {google.cloud.networkservices.v1.GrpcRoute} request.grpcRoute - * Required. Updated GrpcRoute resource. - * @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/network_services.update_grpc_route.js - * region_tag:networkservices_v1_generated_NetworkServices_UpdateGrpcRoute_async - */ + /** + * Updates the parameters of a single GrpcRoute. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask is used to specify the fields to be overwritten in the + * GrpcRoute resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @param {google.cloud.networkservices.v1.GrpcRoute} request.grpcRoute + * Required. Updated GrpcRoute resource. + * @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/network_services.update_grpc_route.js + * region_tag:networkservices_v1_generated_NetworkServices_UpdateGrpcRoute_async + */ updateGrpcRoute( - request?: protos.google.cloud.networkservices.v1.IUpdateGrpcRouteRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IUpdateGrpcRouteRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IGrpcRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateGrpcRoute( - request: protos.google.cloud.networkservices.v1.IUpdateGrpcRouteRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IUpdateGrpcRouteRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IGrpcRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateGrpcRoute( - request: protos.google.cloud.networkservices.v1.IUpdateGrpcRouteRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IUpdateGrpcRouteRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IGrpcRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateGrpcRoute( - request?: protos.google.cloud.networkservices.v1.IUpdateGrpcRouteRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.IUpdateGrpcRouteRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IGrpcRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IGrpcRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IGrpcRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'grpc_route.name': request.grpcRoute!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'grpc_route.name': request.grpcRoute!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IGrpcRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateGrpcRoute response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateGrpcRoute request %j', request); - return this.innerApiCalls.updateGrpcRoute(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateGrpcRoute response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateGrpcRoute(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1.IGrpcRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateGrpcRoute response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateGrpcRoute()`. - * @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/network_services.update_grpc_route.js - * region_tag:networkservices_v1_generated_NetworkServices_UpdateGrpcRoute_async - */ - async checkUpdateGrpcRouteProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateGrpcRoute()`. + * @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/network_services.update_grpc_route.js + * region_tag:networkservices_v1_generated_NetworkServices_UpdateGrpcRoute_async + */ + async checkUpdateGrpcRouteProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1.GrpcRoute, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('updateGrpcRoute long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateGrpcRoute, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateGrpcRoute, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1.GrpcRoute, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Deletes a single GrpcRoute. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the GrpcRoute to delete. Must be in the format - * `projects/* /locations/global/grpcRoutes/*`. - * @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/network_services.delete_grpc_route.js - * region_tag:networkservices_v1_generated_NetworkServices_DeleteGrpcRoute_async - */ + /** + * Deletes a single GrpcRoute. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the GrpcRoute to delete. Must be in the format + * `projects/* /locations/global/grpcRoutes/*`. + * @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/network_services.delete_grpc_route.js + * region_tag:networkservices_v1_generated_NetworkServices_DeleteGrpcRoute_async + */ deleteGrpcRoute( - request?: protos.google.cloud.networkservices.v1.IDeleteGrpcRouteRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IDeleteGrpcRouteRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteGrpcRoute( - request: protos.google.cloud.networkservices.v1.IDeleteGrpcRouteRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IDeleteGrpcRouteRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteGrpcRoute( - request: protos.google.cloud.networkservices.v1.IDeleteGrpcRouteRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IDeleteGrpcRouteRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteGrpcRoute( - request?: protos.google.cloud.networkservices.v1.IDeleteGrpcRouteRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.IDeleteGrpcRouteRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteGrpcRoute response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteGrpcRoute request %j', request); - return this.innerApiCalls.deleteGrpcRoute(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteGrpcRoute response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteGrpcRoute(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteGrpcRoute response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteGrpcRoute()`. - * @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/network_services.delete_grpc_route.js - * region_tag:networkservices_v1_generated_NetworkServices_DeleteGrpcRoute_async - */ - async checkDeleteGrpcRouteProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteGrpcRoute()`. + * @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/network_services.delete_grpc_route.js + * region_tag:networkservices_v1_generated_NetworkServices_DeleteGrpcRoute_async + */ + async checkDeleteGrpcRouteProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('deleteGrpcRoute long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteGrpcRoute, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteGrpcRoute, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Creates a new HttpRoute in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the HttpRoute. Must be in the - * format `projects/* /locations/global`. - * @param {string} request.httpRouteId - * Required. Short name of the HttpRoute resource to be created. - * @param {google.cloud.networkservices.v1.HttpRoute} request.httpRoute - * Required. HttpRoute resource to be created. - * @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/network_services.create_http_route.js - * region_tag:networkservices_v1_generated_NetworkServices_CreateHttpRoute_async - */ + /** + * Creates a new HttpRoute in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the HttpRoute. Must be in the + * format `projects/* /locations/global`. + * @param {string} request.httpRouteId + * Required. Short name of the HttpRoute resource to be created. + * @param {google.cloud.networkservices.v1.HttpRoute} request.httpRoute + * Required. HttpRoute resource to be created. + * @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/network_services.create_http_route.js + * region_tag:networkservices_v1_generated_NetworkServices_CreateHttpRoute_async + */ createHttpRoute( - request?: protos.google.cloud.networkservices.v1.ICreateHttpRouteRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.ICreateHttpRouteRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IHttpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createHttpRoute( - request: protos.google.cloud.networkservices.v1.ICreateHttpRouteRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.ICreateHttpRouteRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IHttpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createHttpRoute( - request: protos.google.cloud.networkservices.v1.ICreateHttpRouteRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.ICreateHttpRouteRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IHttpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createHttpRoute( - request?: protos.google.cloud.networkservices.v1.ICreateHttpRouteRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.ICreateHttpRouteRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IHttpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IHttpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IHttpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IHttpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createHttpRoute response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createHttpRoute request %j', request); - return this.innerApiCalls.createHttpRoute(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createHttpRoute response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createHttpRoute(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1.IHttpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createHttpRoute response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createHttpRoute()`. - * @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/network_services.create_http_route.js - * region_tag:networkservices_v1_generated_NetworkServices_CreateHttpRoute_async - */ - async checkCreateHttpRouteProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createHttpRoute()`. + * @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/network_services.create_http_route.js + * region_tag:networkservices_v1_generated_NetworkServices_CreateHttpRoute_async + */ + async checkCreateHttpRouteProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1.HttpRoute, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('createHttpRoute long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createHttpRoute, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createHttpRoute, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1.HttpRoute, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Updates the parameters of a single HttpRoute. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask is used to specify the fields to be overwritten in the - * HttpRoute resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - * @param {google.cloud.networkservices.v1.HttpRoute} request.httpRoute - * Required. Updated HttpRoute resource. - * @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/network_services.update_http_route.js - * region_tag:networkservices_v1_generated_NetworkServices_UpdateHttpRoute_async - */ + /** + * Updates the parameters of a single HttpRoute. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask is used to specify the fields to be overwritten in the + * HttpRoute resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @param {google.cloud.networkservices.v1.HttpRoute} request.httpRoute + * Required. Updated HttpRoute resource. + * @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/network_services.update_http_route.js + * region_tag:networkservices_v1_generated_NetworkServices_UpdateHttpRoute_async + */ updateHttpRoute( - request?: protos.google.cloud.networkservices.v1.IUpdateHttpRouteRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IUpdateHttpRouteRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IHttpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateHttpRoute( - request: protos.google.cloud.networkservices.v1.IUpdateHttpRouteRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IUpdateHttpRouteRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IHttpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateHttpRoute( - request: protos.google.cloud.networkservices.v1.IUpdateHttpRouteRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IUpdateHttpRouteRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IHttpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateHttpRoute( - request?: protos.google.cloud.networkservices.v1.IUpdateHttpRouteRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.IUpdateHttpRouteRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IHttpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IHttpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IHttpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'http_route.name': request.httpRoute!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'http_route.name': request.httpRoute!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IHttpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateHttpRoute response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateHttpRoute request %j', request); - return this.innerApiCalls.updateHttpRoute(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateHttpRoute response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateHttpRoute(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1.IHttpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateHttpRoute response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateHttpRoute()`. - * @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/network_services.update_http_route.js - * region_tag:networkservices_v1_generated_NetworkServices_UpdateHttpRoute_async - */ - async checkUpdateHttpRouteProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateHttpRoute()`. + * @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/network_services.update_http_route.js + * region_tag:networkservices_v1_generated_NetworkServices_UpdateHttpRoute_async + */ + async checkUpdateHttpRouteProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1.HttpRoute, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('updateHttpRoute long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateHttpRoute, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateHttpRoute, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1.HttpRoute, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Deletes a single HttpRoute. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the HttpRoute to delete. Must be in the format - * `projects/* /locations/global/httpRoutes/*`. - * @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/network_services.delete_http_route.js - * region_tag:networkservices_v1_generated_NetworkServices_DeleteHttpRoute_async - */ + /** + * Deletes a single HttpRoute. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the HttpRoute to delete. Must be in the format + * `projects/* /locations/global/httpRoutes/*`. + * @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/network_services.delete_http_route.js + * region_tag:networkservices_v1_generated_NetworkServices_DeleteHttpRoute_async + */ deleteHttpRoute( - request?: protos.google.cloud.networkservices.v1.IDeleteHttpRouteRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IDeleteHttpRouteRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteHttpRoute( - request: protos.google.cloud.networkservices.v1.IDeleteHttpRouteRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IDeleteHttpRouteRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteHttpRoute( - request: protos.google.cloud.networkservices.v1.IDeleteHttpRouteRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IDeleteHttpRouteRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteHttpRoute( - request?: protos.google.cloud.networkservices.v1.IDeleteHttpRouteRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.IDeleteHttpRouteRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteHttpRoute response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteHttpRoute request %j', request); - return this.innerApiCalls.deleteHttpRoute(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteHttpRoute response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteHttpRoute(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteHttpRoute response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteHttpRoute()`. - * @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/network_services.delete_http_route.js - * region_tag:networkservices_v1_generated_NetworkServices_DeleteHttpRoute_async - */ - async checkDeleteHttpRouteProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteHttpRoute()`. + * @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/network_services.delete_http_route.js + * region_tag:networkservices_v1_generated_NetworkServices_DeleteHttpRoute_async + */ + async checkDeleteHttpRouteProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('deleteHttpRoute long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteHttpRoute, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteHttpRoute, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Creates a new TcpRoute in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the TcpRoute. Must be in the - * format `projects/* /locations/global`. - * @param {string} request.tcpRouteId - * Required. Short name of the TcpRoute resource to be created. - * @param {google.cloud.networkservices.v1.TcpRoute} request.tcpRoute - * Required. TcpRoute resource to be created. - * @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/network_services.create_tcp_route.js - * region_tag:networkservices_v1_generated_NetworkServices_CreateTcpRoute_async - */ + /** + * Creates a new TcpRoute in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the TcpRoute. Must be in the + * format `projects/* /locations/global`. + * @param {string} request.tcpRouteId + * Required. Short name of the TcpRoute resource to be created. + * @param {google.cloud.networkservices.v1.TcpRoute} request.tcpRoute + * Required. TcpRoute resource to be created. + * @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/network_services.create_tcp_route.js + * region_tag:networkservices_v1_generated_NetworkServices_CreateTcpRoute_async + */ createTcpRoute( - request?: protos.google.cloud.networkservices.v1.ICreateTcpRouteRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.ICreateTcpRouteRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.ITcpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createTcpRoute( - request: protos.google.cloud.networkservices.v1.ICreateTcpRouteRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.ICreateTcpRouteRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.ITcpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createTcpRoute( - request: protos.google.cloud.networkservices.v1.ICreateTcpRouteRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.ICreateTcpRouteRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.ITcpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createTcpRoute( - request?: protos.google.cloud.networkservices.v1.ICreateTcpRouteRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.ICreateTcpRouteRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.ITcpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1.ITcpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.ITcpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.ITcpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createTcpRoute response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createTcpRoute request %j', request); - return this.innerApiCalls.createTcpRoute(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createTcpRoute response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createTcpRoute(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1.ITcpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createTcpRoute response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createTcpRoute()`. - * @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/network_services.create_tcp_route.js - * region_tag:networkservices_v1_generated_NetworkServices_CreateTcpRoute_async - */ - async checkCreateTcpRouteProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createTcpRoute()`. + * @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/network_services.create_tcp_route.js + * region_tag:networkservices_v1_generated_NetworkServices_CreateTcpRoute_async + */ + async checkCreateTcpRouteProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1.TcpRoute, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('createTcpRoute long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createTcpRoute, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createTcpRoute, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1.TcpRoute, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Updates the parameters of a single TcpRoute. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask is used to specify the fields to be overwritten in the - * TcpRoute resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - * @param {google.cloud.networkservices.v1.TcpRoute} request.tcpRoute - * Required. Updated TcpRoute resource. - * @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/network_services.update_tcp_route.js - * region_tag:networkservices_v1_generated_NetworkServices_UpdateTcpRoute_async - */ + /** + * Updates the parameters of a single TcpRoute. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask is used to specify the fields to be overwritten in the + * TcpRoute resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @param {google.cloud.networkservices.v1.TcpRoute} request.tcpRoute + * Required. Updated TcpRoute resource. + * @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/network_services.update_tcp_route.js + * region_tag:networkservices_v1_generated_NetworkServices_UpdateTcpRoute_async + */ updateTcpRoute( - request?: protos.google.cloud.networkservices.v1.IUpdateTcpRouteRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IUpdateTcpRouteRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.ITcpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateTcpRoute( - request: protos.google.cloud.networkservices.v1.IUpdateTcpRouteRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IUpdateTcpRouteRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.ITcpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateTcpRoute( - request: protos.google.cloud.networkservices.v1.IUpdateTcpRouteRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IUpdateTcpRouteRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.ITcpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateTcpRoute( - request?: protos.google.cloud.networkservices.v1.IUpdateTcpRouteRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.IUpdateTcpRouteRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.ITcpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1.ITcpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.ITcpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'tcp_route.name': request.tcpRoute!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'tcp_route.name': request.tcpRoute!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.ITcpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateTcpRoute response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateTcpRoute request %j', request); - return this.innerApiCalls.updateTcpRoute(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateTcpRoute response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateTcpRoute(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1.ITcpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateTcpRoute response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateTcpRoute()`. - * @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/network_services.update_tcp_route.js - * region_tag:networkservices_v1_generated_NetworkServices_UpdateTcpRoute_async - */ - async checkUpdateTcpRouteProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateTcpRoute()`. + * @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/network_services.update_tcp_route.js + * region_tag:networkservices_v1_generated_NetworkServices_UpdateTcpRoute_async + */ + async checkUpdateTcpRouteProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1.TcpRoute, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('updateTcpRoute long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateTcpRoute, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateTcpRoute, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1.TcpRoute, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Deletes a single TcpRoute. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the TcpRoute to delete. Must be in the format - * `projects/* /locations/global/tcpRoutes/*`. - * @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/network_services.delete_tcp_route.js - * region_tag:networkservices_v1_generated_NetworkServices_DeleteTcpRoute_async - */ + /** + * Deletes a single TcpRoute. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the TcpRoute to delete. Must be in the format + * `projects/* /locations/global/tcpRoutes/*`. + * @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/network_services.delete_tcp_route.js + * region_tag:networkservices_v1_generated_NetworkServices_DeleteTcpRoute_async + */ deleteTcpRoute( - request?: protos.google.cloud.networkservices.v1.IDeleteTcpRouteRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IDeleteTcpRouteRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteTcpRoute( - request: protos.google.cloud.networkservices.v1.IDeleteTcpRouteRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IDeleteTcpRouteRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteTcpRoute( - request: protos.google.cloud.networkservices.v1.IDeleteTcpRouteRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IDeleteTcpRouteRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteTcpRoute( - request?: protos.google.cloud.networkservices.v1.IDeleteTcpRouteRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.IDeleteTcpRouteRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteTcpRoute response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteTcpRoute request %j', request); - return this.innerApiCalls.deleteTcpRoute(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteTcpRoute response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteTcpRoute(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteTcpRoute response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteTcpRoute()`. - * @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/network_services.delete_tcp_route.js - * region_tag:networkservices_v1_generated_NetworkServices_DeleteTcpRoute_async - */ - async checkDeleteTcpRouteProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteTcpRoute()`. + * @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/network_services.delete_tcp_route.js + * region_tag:networkservices_v1_generated_NetworkServices_DeleteTcpRoute_async + */ + async checkDeleteTcpRouteProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('deleteTcpRoute long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteTcpRoute, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteTcpRoute, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Creates a new TlsRoute in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the TlsRoute. Must be in the - * format `projects/* /locations/global`. - * @param {string} request.tlsRouteId - * Required. Short name of the TlsRoute resource to be created. - * @param {google.cloud.networkservices.v1.TlsRoute} request.tlsRoute - * Required. TlsRoute resource to be created. - * @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/network_services.create_tls_route.js - * region_tag:networkservices_v1_generated_NetworkServices_CreateTlsRoute_async - */ + /** + * Creates a new TlsRoute in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the TlsRoute. Must be in the + * format `projects/* /locations/global`. + * @param {string} request.tlsRouteId + * Required. Short name of the TlsRoute resource to be created. + * @param {google.cloud.networkservices.v1.TlsRoute} request.tlsRoute + * Required. TlsRoute resource to be created. + * @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/network_services.create_tls_route.js + * region_tag:networkservices_v1_generated_NetworkServices_CreateTlsRoute_async + */ createTlsRoute( - request?: protos.google.cloud.networkservices.v1.ICreateTlsRouteRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.ICreateTlsRouteRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.ITlsRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createTlsRoute( - request: protos.google.cloud.networkservices.v1.ICreateTlsRouteRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.ICreateTlsRouteRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.ITlsRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createTlsRoute( - request: protos.google.cloud.networkservices.v1.ICreateTlsRouteRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.ICreateTlsRouteRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.ITlsRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createTlsRoute( - request?: protos.google.cloud.networkservices.v1.ICreateTlsRouteRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.ICreateTlsRouteRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.ITlsRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1.ITlsRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.ITlsRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.ITlsRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createTlsRoute response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createTlsRoute request %j', request); - return this.innerApiCalls.createTlsRoute(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createTlsRoute response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createTlsRoute(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1.ITlsRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createTlsRoute response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createTlsRoute()`. - * @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/network_services.create_tls_route.js - * region_tag:networkservices_v1_generated_NetworkServices_CreateTlsRoute_async - */ - async checkCreateTlsRouteProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createTlsRoute()`. + * @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/network_services.create_tls_route.js + * region_tag:networkservices_v1_generated_NetworkServices_CreateTlsRoute_async + */ + async checkCreateTlsRouteProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1.TlsRoute, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('createTlsRoute long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createTlsRoute, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createTlsRoute, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1.TlsRoute, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Updates the parameters of a single TlsRoute. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask is used to specify the fields to be overwritten in the - * TlsRoute resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - * @param {google.cloud.networkservices.v1.TlsRoute} request.tlsRoute - * Required. Updated TlsRoute resource. - * @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/network_services.update_tls_route.js - * region_tag:networkservices_v1_generated_NetworkServices_UpdateTlsRoute_async - */ + /** + * Updates the parameters of a single TlsRoute. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask is used to specify the fields to be overwritten in the + * TlsRoute resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @param {google.cloud.networkservices.v1.TlsRoute} request.tlsRoute + * Required. Updated TlsRoute resource. + * @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/network_services.update_tls_route.js + * region_tag:networkservices_v1_generated_NetworkServices_UpdateTlsRoute_async + */ updateTlsRoute( - request?: protos.google.cloud.networkservices.v1.IUpdateTlsRouteRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IUpdateTlsRouteRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.ITlsRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateTlsRoute( - request: protos.google.cloud.networkservices.v1.IUpdateTlsRouteRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IUpdateTlsRouteRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.ITlsRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateTlsRoute( - request: protos.google.cloud.networkservices.v1.IUpdateTlsRouteRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IUpdateTlsRouteRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.ITlsRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateTlsRoute( - request?: protos.google.cloud.networkservices.v1.IUpdateTlsRouteRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.IUpdateTlsRouteRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.ITlsRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1.ITlsRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.ITlsRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'tls_route.name': request.tlsRoute!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'tls_route.name': request.tlsRoute!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.ITlsRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateTlsRoute response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateTlsRoute request %j', request); - return this.innerApiCalls.updateTlsRoute(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateTlsRoute response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateTlsRoute(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1.ITlsRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateTlsRoute response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateTlsRoute()`. - * @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/network_services.update_tls_route.js - * region_tag:networkservices_v1_generated_NetworkServices_UpdateTlsRoute_async - */ - async checkUpdateTlsRouteProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateTlsRoute()`. + * @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/network_services.update_tls_route.js + * region_tag:networkservices_v1_generated_NetworkServices_UpdateTlsRoute_async + */ + async checkUpdateTlsRouteProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1.TlsRoute, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('updateTlsRoute long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateTlsRoute, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateTlsRoute, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1.TlsRoute, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Deletes a single TlsRoute. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the TlsRoute to delete. Must be in the format - * `projects/* /locations/global/tlsRoutes/*`. - * @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/network_services.delete_tls_route.js - * region_tag:networkservices_v1_generated_NetworkServices_DeleteTlsRoute_async - */ + /** + * Deletes a single TlsRoute. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the TlsRoute to delete. Must be in the format + * `projects/* /locations/global/tlsRoutes/*`. + * @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/network_services.delete_tls_route.js + * region_tag:networkservices_v1_generated_NetworkServices_DeleteTlsRoute_async + */ deleteTlsRoute( - request?: protos.google.cloud.networkservices.v1.IDeleteTlsRouteRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IDeleteTlsRouteRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteTlsRoute( - request: protos.google.cloud.networkservices.v1.IDeleteTlsRouteRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IDeleteTlsRouteRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteTlsRoute( - request: protos.google.cloud.networkservices.v1.IDeleteTlsRouteRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IDeleteTlsRouteRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteTlsRoute( - request?: protos.google.cloud.networkservices.v1.IDeleteTlsRouteRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.IDeleteTlsRouteRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteTlsRoute response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteTlsRoute request %j', request); - return this.innerApiCalls.deleteTlsRoute(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteTlsRoute response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteTlsRoute(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteTlsRoute response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteTlsRoute()`. - * @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/network_services.delete_tls_route.js - * region_tag:networkservices_v1_generated_NetworkServices_DeleteTlsRoute_async - */ - async checkDeleteTlsRouteProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteTlsRoute()`. + * @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/network_services.delete_tls_route.js + * region_tag:networkservices_v1_generated_NetworkServices_DeleteTlsRoute_async + */ + async checkDeleteTlsRouteProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('deleteTlsRoute long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteTlsRoute, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteTlsRoute, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Creates a new ServiceBinding in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the ServiceBinding. Must be in the - * format `projects/* /locations/*`. - * @param {string} request.serviceBindingId - * Required. Short name of the ServiceBinding resource to be created. - * @param {google.cloud.networkservices.v1.ServiceBinding} request.serviceBinding - * Required. ServiceBinding resource to be created. - * @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/network_services.create_service_binding.js - * region_tag:networkservices_v1_generated_NetworkServices_CreateServiceBinding_async - */ + /** + * Creates a new ServiceBinding in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the ServiceBinding. Must be in the + * format `projects/* /locations/*`. + * @param {string} request.serviceBindingId + * Required. Short name of the ServiceBinding resource to be created. + * @param {google.cloud.networkservices.v1.ServiceBinding} request.serviceBinding + * Required. ServiceBinding resource to be created. + * @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/network_services.create_service_binding.js + * region_tag:networkservices_v1_generated_NetworkServices_CreateServiceBinding_async + */ createServiceBinding( - request?: protos.google.cloud.networkservices.v1.ICreateServiceBindingRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.ICreateServiceBindingRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IServiceBinding, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createServiceBinding( - request: protos.google.cloud.networkservices.v1.ICreateServiceBindingRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.ICreateServiceBindingRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IServiceBinding, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createServiceBinding( - request: protos.google.cloud.networkservices.v1.ICreateServiceBindingRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.ICreateServiceBindingRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IServiceBinding, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createServiceBinding( - request?: protos.google.cloud.networkservices.v1.ICreateServiceBindingRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.ICreateServiceBindingRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IServiceBinding, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IServiceBinding, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IServiceBinding, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IServiceBinding, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createServiceBinding response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createServiceBinding request %j', request); - return this.innerApiCalls.createServiceBinding(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createServiceBinding response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createServiceBinding(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1.IServiceBinding, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createServiceBinding response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createServiceBinding()`. - * @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/network_services.create_service_binding.js - * region_tag:networkservices_v1_generated_NetworkServices_CreateServiceBinding_async - */ - async checkCreateServiceBindingProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createServiceBinding()`. + * @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/network_services.create_service_binding.js + * region_tag:networkservices_v1_generated_NetworkServices_CreateServiceBinding_async + */ + async checkCreateServiceBindingProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1.ServiceBinding, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('createServiceBinding long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createServiceBinding, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createServiceBinding, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1.ServiceBinding, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Updates the parameters of a single ServiceBinding. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask is used to specify the fields to be overwritten in the - * ServiceBinding resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - * @param {google.cloud.networkservices.v1.ServiceBinding} request.serviceBinding - * Required. Updated ServiceBinding resource. - * @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/network_services.update_service_binding.js - * region_tag:networkservices_v1_generated_NetworkServices_UpdateServiceBinding_async - */ + /** + * Updates the parameters of a single ServiceBinding. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask is used to specify the fields to be overwritten in the + * ServiceBinding resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @param {google.cloud.networkservices.v1.ServiceBinding} request.serviceBinding + * Required. Updated ServiceBinding resource. + * @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/network_services.update_service_binding.js + * region_tag:networkservices_v1_generated_NetworkServices_UpdateServiceBinding_async + */ updateServiceBinding( - request?: protos.google.cloud.networkservices.v1.IUpdateServiceBindingRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IUpdateServiceBindingRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IServiceBinding, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateServiceBinding( - request: protos.google.cloud.networkservices.v1.IUpdateServiceBindingRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IUpdateServiceBindingRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IServiceBinding, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateServiceBinding( - request: protos.google.cloud.networkservices.v1.IUpdateServiceBindingRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IUpdateServiceBindingRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IServiceBinding, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateServiceBinding( - request?: protos.google.cloud.networkservices.v1.IUpdateServiceBindingRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.IUpdateServiceBindingRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IServiceBinding, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IServiceBinding, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IServiceBinding, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'service_binding.name': request.serviceBinding!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'service_binding.name': request.serviceBinding!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IServiceBinding, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateServiceBinding response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateServiceBinding request %j', request); - return this.innerApiCalls.updateServiceBinding(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateServiceBinding response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateServiceBinding(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1.IServiceBinding, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateServiceBinding response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateServiceBinding()`. - * @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/network_services.update_service_binding.js - * region_tag:networkservices_v1_generated_NetworkServices_UpdateServiceBinding_async - */ - async checkUpdateServiceBindingProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateServiceBinding()`. + * @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/network_services.update_service_binding.js + * region_tag:networkservices_v1_generated_NetworkServices_UpdateServiceBinding_async + */ + async checkUpdateServiceBindingProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1.ServiceBinding, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('updateServiceBinding long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateServiceBinding, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateServiceBinding, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1.ServiceBinding, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Deletes a single ServiceBinding. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the ServiceBinding to delete. Must be in the format - * `projects/* /locations/* /serviceBindings/*`. - * @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/network_services.delete_service_binding.js - * region_tag:networkservices_v1_generated_NetworkServices_DeleteServiceBinding_async - */ + /** + * Deletes a single ServiceBinding. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the ServiceBinding to delete. Must be in the format + * `projects/* /locations/* /serviceBindings/*`. + * @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/network_services.delete_service_binding.js + * region_tag:networkservices_v1_generated_NetworkServices_DeleteServiceBinding_async + */ deleteServiceBinding( - request?: protos.google.cloud.networkservices.v1.IDeleteServiceBindingRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IDeleteServiceBindingRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteServiceBinding( - request: protos.google.cloud.networkservices.v1.IDeleteServiceBindingRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IDeleteServiceBindingRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteServiceBinding( - request: protos.google.cloud.networkservices.v1.IDeleteServiceBindingRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IDeleteServiceBindingRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteServiceBinding( - request?: protos.google.cloud.networkservices.v1.IDeleteServiceBindingRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.IDeleteServiceBindingRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteServiceBinding response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteServiceBinding request %j', request); - return this.innerApiCalls.deleteServiceBinding(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteServiceBinding response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteServiceBinding(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteServiceBinding response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteServiceBinding()`. - * @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/network_services.delete_service_binding.js - * region_tag:networkservices_v1_generated_NetworkServices_DeleteServiceBinding_async - */ - async checkDeleteServiceBindingProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteServiceBinding()`. + * @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/network_services.delete_service_binding.js + * region_tag:networkservices_v1_generated_NetworkServices_DeleteServiceBinding_async + */ + async checkDeleteServiceBindingProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('deleteServiceBinding long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteServiceBinding, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteServiceBinding, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Creates a new Mesh in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the Mesh. Must be in the - * format `projects/* /locations/global`. - * @param {string} request.meshId - * Required. Short name of the Mesh resource to be created. - * @param {google.cloud.networkservices.v1.Mesh} request.mesh - * Required. Mesh resource to be created. - * @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/network_services.create_mesh.js - * region_tag:networkservices_v1_generated_NetworkServices_CreateMesh_async - */ + /** + * Creates a new Mesh in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the Mesh. Must be in the + * format `projects/* /locations/global`. + * @param {string} request.meshId + * Required. Short name of the Mesh resource to be created. + * @param {google.cloud.networkservices.v1.Mesh} request.mesh + * Required. Mesh resource to be created. + * @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/network_services.create_mesh.js + * region_tag:networkservices_v1_generated_NetworkServices_CreateMesh_async + */ createMesh( - request?: protos.google.cloud.networkservices.v1.ICreateMeshRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.ICreateMeshRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IMesh, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createMesh( - request: protos.google.cloud.networkservices.v1.ICreateMeshRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.ICreateMeshRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IMesh, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createMesh( - request: protos.google.cloud.networkservices.v1.ICreateMeshRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.ICreateMeshRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IMesh, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createMesh( - request?: protos.google.cloud.networkservices.v1.ICreateMeshRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.ICreateMeshRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IMesh, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IMesh, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IMesh, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IMesh, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createMesh response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createMesh request %j', request); - return this.innerApiCalls.createMesh(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createMesh response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createMesh(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1.IMesh, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createMesh response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createMesh()`. - * @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/network_services.create_mesh.js - * region_tag:networkservices_v1_generated_NetworkServices_CreateMesh_async - */ - async checkCreateMeshProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createMesh()`. + * @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/network_services.create_mesh.js + * region_tag:networkservices_v1_generated_NetworkServices_CreateMesh_async + */ + async checkCreateMeshProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1.Mesh, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('createMesh long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createMesh, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createMesh, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1.Mesh, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Updates the parameters of a single Mesh. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask is used to specify the fields to be overwritten in the - * Mesh resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - * @param {google.cloud.networkservices.v1.Mesh} request.mesh - * Required. Updated Mesh resource. - * @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/network_services.update_mesh.js - * region_tag:networkservices_v1_generated_NetworkServices_UpdateMesh_async - */ + /** + * Updates the parameters of a single Mesh. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask is used to specify the fields to be overwritten in the + * Mesh resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @param {google.cloud.networkservices.v1.Mesh} request.mesh + * Required. Updated Mesh resource. + * @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/network_services.update_mesh.js + * region_tag:networkservices_v1_generated_NetworkServices_UpdateMesh_async + */ updateMesh( - request?: protos.google.cloud.networkservices.v1.IUpdateMeshRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IUpdateMeshRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IMesh, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateMesh( - request: protos.google.cloud.networkservices.v1.IUpdateMeshRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IUpdateMeshRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IMesh, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateMesh( - request: protos.google.cloud.networkservices.v1.IUpdateMeshRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IUpdateMeshRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IMesh, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateMesh( - request?: protos.google.cloud.networkservices.v1.IUpdateMeshRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.IUpdateMeshRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IMesh, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IMesh, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IMesh, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'mesh.name': request.mesh!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'mesh.name': request.mesh!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IMesh, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateMesh response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateMesh request %j', request); - return this.innerApiCalls.updateMesh(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateMesh response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateMesh(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1.IMesh, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateMesh response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateMesh()`. - * @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/network_services.update_mesh.js - * region_tag:networkservices_v1_generated_NetworkServices_UpdateMesh_async - */ - async checkUpdateMeshProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateMesh()`. + * @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/network_services.update_mesh.js + * region_tag:networkservices_v1_generated_NetworkServices_UpdateMesh_async + */ + async checkUpdateMeshProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1.Mesh, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('updateMesh long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateMesh, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateMesh, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1.Mesh, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Deletes a single Mesh. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the Mesh to delete. Must be in the format - * `projects/* /locations/global/meshes/*`. - * @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/network_services.delete_mesh.js - * region_tag:networkservices_v1_generated_NetworkServices_DeleteMesh_async - */ + /** + * Deletes a single Mesh. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the Mesh to delete. Must be in the format + * `projects/* /locations/global/meshes/*`. + * @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/network_services.delete_mesh.js + * region_tag:networkservices_v1_generated_NetworkServices_DeleteMesh_async + */ deleteMesh( - request?: protos.google.cloud.networkservices.v1.IDeleteMeshRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IDeleteMeshRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteMesh( - request: protos.google.cloud.networkservices.v1.IDeleteMeshRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IDeleteMeshRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteMesh( - request: protos.google.cloud.networkservices.v1.IDeleteMeshRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IDeleteMeshRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteMesh( - request?: protos.google.cloud.networkservices.v1.IDeleteMeshRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.IDeleteMeshRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteMesh response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteMesh request %j', request); - return this.innerApiCalls.deleteMesh(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteMesh response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteMesh(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteMesh response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteMesh()`. - * @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/network_services.delete_mesh.js - * region_tag:networkservices_v1_generated_NetworkServices_DeleteMesh_async - */ - async checkDeleteMeshProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteMesh()`. + * @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/network_services.delete_mesh.js + * region_tag:networkservices_v1_generated_NetworkServices_DeleteMesh_async + */ + async checkDeleteMeshProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('deleteMesh long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteMesh, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteMesh, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Creates a new ServiceLbPolicy in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the ServiceLbPolicy. Must be in the - * format `projects/{project}/locations/{location}`. - * @param {string} request.serviceLbPolicyId - * Required. Short name of the ServiceLbPolicy resource to be created. - * E.g. for resource name - * `projects/{project}/locations/{location}/serviceLbPolicies/{service_lb_policy_name}`. - * the id is value of {service_lb_policy_name} - * @param {google.cloud.networkservices.v1.ServiceLbPolicy} request.serviceLbPolicy - * Required. ServiceLbPolicy resource to be created. - * @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/network_services.create_service_lb_policy.js - * region_tag:networkservices_v1_generated_NetworkServices_CreateServiceLbPolicy_async - */ + /** + * Creates a new ServiceLbPolicy in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the ServiceLbPolicy. Must be in the + * format `projects/{project}/locations/{location}`. + * @param {string} request.serviceLbPolicyId + * Required. Short name of the ServiceLbPolicy resource to be created. + * E.g. for resource name + * `projects/{project}/locations/{location}/serviceLbPolicies/{service_lb_policy_name}`. + * the id is value of {service_lb_policy_name} + * @param {google.cloud.networkservices.v1.ServiceLbPolicy} request.serviceLbPolicy + * Required. ServiceLbPolicy resource to be created. + * @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/network_services.create_service_lb_policy.js + * region_tag:networkservices_v1_generated_NetworkServices_CreateServiceLbPolicy_async + */ createServiceLbPolicy( - request?: protos.google.cloud.networkservices.v1.ICreateServiceLbPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.ICreateServiceLbPolicyRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IServiceLbPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createServiceLbPolicy( - request: protos.google.cloud.networkservices.v1.ICreateServiceLbPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.ICreateServiceLbPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IServiceLbPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createServiceLbPolicy( - request: protos.google.cloud.networkservices.v1.ICreateServiceLbPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.ICreateServiceLbPolicyRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IServiceLbPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createServiceLbPolicy( - request?: protos.google.cloud.networkservices.v1.ICreateServiceLbPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.ICreateServiceLbPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IServiceLbPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IServiceLbPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IServiceLbPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IServiceLbPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createServiceLbPolicy response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createServiceLbPolicy request %j', request); - return this.innerApiCalls.createServiceLbPolicy(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createServiceLbPolicy response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createServiceLbPolicy(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1.IServiceLbPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createServiceLbPolicy response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createServiceLbPolicy()`. - * @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/network_services.create_service_lb_policy.js - * region_tag:networkservices_v1_generated_NetworkServices_CreateServiceLbPolicy_async - */ - async checkCreateServiceLbPolicyProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createServiceLbPolicy()`. + * @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/network_services.create_service_lb_policy.js + * region_tag:networkservices_v1_generated_NetworkServices_CreateServiceLbPolicy_async + */ + async checkCreateServiceLbPolicyProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1.ServiceLbPolicy, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('createServiceLbPolicy long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createServiceLbPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createServiceLbPolicy, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1.ServiceLbPolicy, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Updates the parameters of a single ServiceLbPolicy. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask is used to specify the fields to be overwritten in the - * ServiceLbPolicy resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - * @param {google.cloud.networkservices.v1.ServiceLbPolicy} request.serviceLbPolicy - * Required. Updated ServiceLbPolicy resource. - * @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/network_services.update_service_lb_policy.js - * region_tag:networkservices_v1_generated_NetworkServices_UpdateServiceLbPolicy_async - */ + /** + * Updates the parameters of a single ServiceLbPolicy. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask is used to specify the fields to be overwritten in the + * ServiceLbPolicy resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @param {google.cloud.networkservices.v1.ServiceLbPolicy} request.serviceLbPolicy + * Required. Updated ServiceLbPolicy resource. + * @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/network_services.update_service_lb_policy.js + * region_tag:networkservices_v1_generated_NetworkServices_UpdateServiceLbPolicy_async + */ updateServiceLbPolicy( - request?: protos.google.cloud.networkservices.v1.IUpdateServiceLbPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IUpdateServiceLbPolicyRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IServiceLbPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateServiceLbPolicy( - request: protos.google.cloud.networkservices.v1.IUpdateServiceLbPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IUpdateServiceLbPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IServiceLbPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateServiceLbPolicy( - request: protos.google.cloud.networkservices.v1.IUpdateServiceLbPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IUpdateServiceLbPolicyRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IServiceLbPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateServiceLbPolicy( - request?: protos.google.cloud.networkservices.v1.IUpdateServiceLbPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.IUpdateServiceLbPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IServiceLbPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1.IServiceLbPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1.IServiceLbPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'service_lb_policy.name': request.serviceLbPolicy!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'service_lb_policy.name': request.serviceLbPolicy!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1.IServiceLbPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateServiceLbPolicy response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateServiceLbPolicy request %j', request); - return this.innerApiCalls.updateServiceLbPolicy(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateServiceLbPolicy response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateServiceLbPolicy(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1.IServiceLbPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateServiceLbPolicy response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateServiceLbPolicy()`. - * @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/network_services.update_service_lb_policy.js - * region_tag:networkservices_v1_generated_NetworkServices_UpdateServiceLbPolicy_async - */ - async checkUpdateServiceLbPolicyProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateServiceLbPolicy()`. + * @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/network_services.update_service_lb_policy.js + * region_tag:networkservices_v1_generated_NetworkServices_UpdateServiceLbPolicy_async + */ + async checkUpdateServiceLbPolicyProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1.ServiceLbPolicy, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('updateServiceLbPolicy long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateServiceLbPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateServiceLbPolicy, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1.ServiceLbPolicy, + protos.google.cloud.networkservices.v1.OperationMetadata + >; } -/** - * Deletes a single ServiceLbPolicy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the ServiceLbPolicy to delete. Must be in the format - * `projects/{project}/locations/{location}/serviceLbPolicies/*`. - * @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/network_services.delete_service_lb_policy.js - * region_tag:networkservices_v1_generated_NetworkServices_DeleteServiceLbPolicy_async - */ + /** + * Deletes a single ServiceLbPolicy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the ServiceLbPolicy to delete. Must be in the format + * `projects/{project}/locations/{location}/serviceLbPolicies/*`. + * @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/network_services.delete_service_lb_policy.js + * region_tag:networkservices_v1_generated_NetworkServices_DeleteServiceLbPolicy_async + */ deleteServiceLbPolicy( - request?: protos.google.cloud.networkservices.v1.IDeleteServiceLbPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1.IDeleteServiceLbPolicyRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteServiceLbPolicy( - request: protos.google.cloud.networkservices.v1.IDeleteServiceLbPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IDeleteServiceLbPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteServiceLbPolicy( - request: protos.google.cloud.networkservices.v1.IDeleteServiceLbPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1.IDeleteServiceLbPolicyRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteServiceLbPolicy( - request?: protos.google.cloud.networkservices.v1.IDeleteServiceLbPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1.IDeleteServiceLbPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteServiceLbPolicy response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteServiceLbPolicy request %j', request); - return this.innerApiCalls.deleteServiceLbPolicy(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteServiceLbPolicy response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteServiceLbPolicy(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteServiceLbPolicy response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteServiceLbPolicy()`. - * @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/network_services.delete_service_lb_policy.js - * region_tag:networkservices_v1_generated_NetworkServices_DeleteServiceLbPolicy_async - */ - async checkDeleteServiceLbPolicyProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteServiceLbPolicy()`. + * @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/network_services.delete_service_lb_policy.js + * region_tag:networkservices_v1_generated_NetworkServices_DeleteServiceLbPolicy_async + */ + async checkDeleteServiceLbPolicyProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1.OperationMetadata + > + > { this._log.info('deleteServiceLbPolicy long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteServiceLbPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists EndpointPolicies in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the EndpointPolicies should - * be listed, specified in the format `projects/* /locations/global`. - * @param {number} request.pageSize - * Maximum number of EndpointPolicies to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListEndpointPoliciesResponse` - * Indicates that this is a continuation of a prior - * `ListEndpointPolicies` call, and that the system should return the - * next page of data. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If true, allow partial responses for multi-regional Aggregated - * List requests. Otherwise if one of the locations is down or unreachable, - * the Aggregated List request will fail. - * @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 Array of {@link protos.google.cloud.networkservices.v1.EndpointPolicy|EndpointPolicy}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listEndpointPoliciesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteServiceLbPolicy, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1.OperationMetadata + >; + } + /** + * Lists EndpointPolicies in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the EndpointPolicies should + * be listed, specified in the format `projects/* /locations/global`. + * @param {number} request.pageSize + * Maximum number of EndpointPolicies to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListEndpointPoliciesResponse` + * Indicates that this is a continuation of a prior + * `ListEndpointPolicies` call, and that the system should return the + * next page of data. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If true, allow partial responses for multi-regional Aggregated + * List requests. Otherwise if one of the locations is down or unreachable, + * the Aggregated List request will fail. + * @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 Array of {@link protos.google.cloud.networkservices.v1.EndpointPolicy|EndpointPolicy}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listEndpointPoliciesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listEndpointPolicies( - request?: protos.google.cloud.networkservices.v1.IListEndpointPoliciesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.IEndpointPolicy[], - protos.google.cloud.networkservices.v1.IListEndpointPoliciesRequest|null, - protos.google.cloud.networkservices.v1.IListEndpointPoliciesResponse - ]>; + request?: protos.google.cloud.networkservices.v1.IListEndpointPoliciesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IEndpointPolicy[], + protos.google.cloud.networkservices.v1.IListEndpointPoliciesRequest | null, + protos.google.cloud.networkservices.v1.IListEndpointPoliciesResponse, + ] + >; listEndpointPolicies( - request: protos.google.cloud.networkservices.v1.IListEndpointPoliciesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListEndpointPoliciesRequest, - protos.google.cloud.networkservices.v1.IListEndpointPoliciesResponse|null|undefined, - protos.google.cloud.networkservices.v1.IEndpointPolicy>): void; + request: protos.google.cloud.networkservices.v1.IListEndpointPoliciesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListEndpointPoliciesRequest, + | protos.google.cloud.networkservices.v1.IListEndpointPoliciesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IEndpointPolicy + >, + ): void; listEndpointPolicies( - request: protos.google.cloud.networkservices.v1.IListEndpointPoliciesRequest, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListEndpointPoliciesRequest, - protos.google.cloud.networkservices.v1.IListEndpointPoliciesResponse|null|undefined, - protos.google.cloud.networkservices.v1.IEndpointPolicy>): void; + request: protos.google.cloud.networkservices.v1.IListEndpointPoliciesRequest, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListEndpointPoliciesRequest, + | protos.google.cloud.networkservices.v1.IListEndpointPoliciesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IEndpointPolicy + >, + ): void; listEndpointPolicies( - request?: protos.google.cloud.networkservices.v1.IListEndpointPoliciesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkservices.v1.IListEndpointPoliciesRequest, - protos.google.cloud.networkservices.v1.IListEndpointPoliciesResponse|null|undefined, - protos.google.cloud.networkservices.v1.IEndpointPolicy>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkservices.v1.IListEndpointPoliciesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkservices.v1.IListEndpointPoliciesRequest, - protos.google.cloud.networkservices.v1.IListEndpointPoliciesResponse|null|undefined, - protos.google.cloud.networkservices.v1.IEndpointPolicy>): - Promise<[ - protos.google.cloud.networkservices.v1.IEndpointPolicy[], - protos.google.cloud.networkservices.v1.IListEndpointPoliciesRequest|null, - protos.google.cloud.networkservices.v1.IListEndpointPoliciesResponse - ]>|void { + | protos.google.cloud.networkservices.v1.IListEndpointPoliciesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IEndpointPolicy + >, + callback?: PaginationCallback< + protos.google.cloud.networkservices.v1.IListEndpointPoliciesRequest, + | protos.google.cloud.networkservices.v1.IListEndpointPoliciesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IEndpointPolicy + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IEndpointPolicy[], + protos.google.cloud.networkservices.v1.IListEndpointPoliciesRequest | null, + protos.google.cloud.networkservices.v1.IListEndpointPoliciesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListEndpointPoliciesRequest, - protos.google.cloud.networkservices.v1.IListEndpointPoliciesResponse|null|undefined, - protos.google.cloud.networkservices.v1.IEndpointPolicy>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkservices.v1.IListEndpointPoliciesRequest, + | protos.google.cloud.networkservices.v1.IListEndpointPoliciesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IEndpointPolicy + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listEndpointPolicies values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -5598,214 +8564,243 @@ export class NetworkServicesClient { this._log.info('listEndpointPolicies request %j', request); return this.innerApiCalls .listEndpointPolicies(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkservices.v1.IEndpointPolicy[], - protos.google.cloud.networkservices.v1.IListEndpointPoliciesRequest|null, - protos.google.cloud.networkservices.v1.IListEndpointPoliciesResponse - ]) => { - this._log.info('listEndpointPolicies values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkservices.v1.IEndpointPolicy[], + protos.google.cloud.networkservices.v1.IListEndpointPoliciesRequest | null, + protos.google.cloud.networkservices.v1.IListEndpointPoliciesResponse, + ]) => { + this._log.info('listEndpointPolicies values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listEndpointPolicies`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the EndpointPolicies should - * be listed, specified in the format `projects/* /locations/global`. - * @param {number} request.pageSize - * Maximum number of EndpointPolicies to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListEndpointPoliciesResponse` - * Indicates that this is a continuation of a prior - * `ListEndpointPolicies` call, and that the system should return the - * next page of data. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If true, allow partial responses for multi-regional Aggregated - * List requests. Otherwise if one of the locations is down or unreachable, - * the Aggregated List request will fail. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.EndpointPolicy|EndpointPolicy} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listEndpointPoliciesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listEndpointPolicies`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the EndpointPolicies should + * be listed, specified in the format `projects/* /locations/global`. + * @param {number} request.pageSize + * Maximum number of EndpointPolicies to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListEndpointPoliciesResponse` + * Indicates that this is a continuation of a prior + * `ListEndpointPolicies` call, and that the system should return the + * next page of data. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If true, allow partial responses for multi-regional Aggregated + * List requests. Otherwise if one of the locations is down or unreachable, + * the Aggregated List request will fail. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.EndpointPolicy|EndpointPolicy} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listEndpointPoliciesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listEndpointPoliciesStream( - request?: protos.google.cloud.networkservices.v1.IListEndpointPoliciesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkservices.v1.IListEndpointPoliciesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listEndpointPolicies']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listEndpointPolicies stream %j', request); return this.descriptors.page.listEndpointPolicies.createStream( this.innerApiCalls.listEndpointPolicies as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listEndpointPolicies`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the EndpointPolicies should - * be listed, specified in the format `projects/* /locations/global`. - * @param {number} request.pageSize - * Maximum number of EndpointPolicies to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListEndpointPoliciesResponse` - * Indicates that this is a continuation of a prior - * `ListEndpointPolicies` call, and that the system should return the - * next page of data. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If true, allow partial responses for multi-regional Aggregated - * List requests. Otherwise if one of the locations is down or unreachable, - * the Aggregated List request will fail. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkservices.v1.EndpointPolicy|EndpointPolicy}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_services.list_endpoint_policies.js - * region_tag:networkservices_v1_generated_NetworkServices_ListEndpointPolicies_async - */ + /** + * Equivalent to `listEndpointPolicies`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the EndpointPolicies should + * be listed, specified in the format `projects/* /locations/global`. + * @param {number} request.pageSize + * Maximum number of EndpointPolicies to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListEndpointPoliciesResponse` + * Indicates that this is a continuation of a prior + * `ListEndpointPolicies` call, and that the system should return the + * next page of data. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If true, allow partial responses for multi-regional Aggregated + * List requests. Otherwise if one of the locations is down or unreachable, + * the Aggregated List request will fail. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkservices.v1.EndpointPolicy|EndpointPolicy}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_services.list_endpoint_policies.js + * region_tag:networkservices_v1_generated_NetworkServices_ListEndpointPolicies_async + */ listEndpointPoliciesAsync( - request?: protos.google.cloud.networkservices.v1.IListEndpointPoliciesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkservices.v1.IListEndpointPoliciesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listEndpointPolicies']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listEndpointPolicies iterate %j', request); return this.descriptors.page.listEndpointPolicies.asyncIterate( this.innerApiCalls['listEndpointPolicies'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists `WasmPluginVersion` resources in a given project and - * location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The `WasmPlugin` resource whose `WasmPluginVersion`s - * are listed, specified in the following format: - * `projects/{project}/locations/global/wasmPlugins/{wasm_plugin}`. - * @param {number} request.pageSize - * Maximum number of `WasmPluginVersion` resources to return per - * call. If not specified, at most 50 `WasmPluginVersion` resources are - * returned. The maximum value is 1000; values above 1000 are coerced to - * 1000. - * @param {string} request.pageToken - * The value returned by the last `ListWasmPluginVersionsResponse` call. - * Indicates that this is a continuation of a prior - * `ListWasmPluginVersions` call, and that the - * next page of data is to be returned. - * @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 Array of {@link protos.google.cloud.networkservices.v1.WasmPluginVersion|WasmPluginVersion}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listWasmPluginVersionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists `WasmPluginVersion` resources in a given project and + * location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The `WasmPlugin` resource whose `WasmPluginVersion`s + * are listed, specified in the following format: + * `projects/{project}/locations/global/wasmPlugins/{wasm_plugin}`. + * @param {number} request.pageSize + * Maximum number of `WasmPluginVersion` resources to return per + * call. If not specified, at most 50 `WasmPluginVersion` resources are + * returned. The maximum value is 1000; values above 1000 are coerced to + * 1000. + * @param {string} request.pageToken + * The value returned by the last `ListWasmPluginVersionsResponse` call. + * Indicates that this is a continuation of a prior + * `ListWasmPluginVersions` call, and that the + * next page of data is to be returned. + * @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 Array of {@link protos.google.cloud.networkservices.v1.WasmPluginVersion|WasmPluginVersion}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listWasmPluginVersionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listWasmPluginVersions( - request?: protos.google.cloud.networkservices.v1.IListWasmPluginVersionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.IWasmPluginVersion[], - protos.google.cloud.networkservices.v1.IListWasmPluginVersionsRequest|null, - protos.google.cloud.networkservices.v1.IListWasmPluginVersionsResponse - ]>; + request?: protos.google.cloud.networkservices.v1.IListWasmPluginVersionsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IWasmPluginVersion[], + protos.google.cloud.networkservices.v1.IListWasmPluginVersionsRequest | null, + protos.google.cloud.networkservices.v1.IListWasmPluginVersionsResponse, + ] + >; listWasmPluginVersions( - request: protos.google.cloud.networkservices.v1.IListWasmPluginVersionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListWasmPluginVersionsRequest, - protos.google.cloud.networkservices.v1.IListWasmPluginVersionsResponse|null|undefined, - protos.google.cloud.networkservices.v1.IWasmPluginVersion>): void; + request: protos.google.cloud.networkservices.v1.IListWasmPluginVersionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListWasmPluginVersionsRequest, + | protos.google.cloud.networkservices.v1.IListWasmPluginVersionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IWasmPluginVersion + >, + ): void; listWasmPluginVersions( - request: protos.google.cloud.networkservices.v1.IListWasmPluginVersionsRequest, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListWasmPluginVersionsRequest, - protos.google.cloud.networkservices.v1.IListWasmPluginVersionsResponse|null|undefined, - protos.google.cloud.networkservices.v1.IWasmPluginVersion>): void; + request: protos.google.cloud.networkservices.v1.IListWasmPluginVersionsRequest, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListWasmPluginVersionsRequest, + | protos.google.cloud.networkservices.v1.IListWasmPluginVersionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IWasmPluginVersion + >, + ): void; listWasmPluginVersions( - request?: protos.google.cloud.networkservices.v1.IListWasmPluginVersionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkservices.v1.IListWasmPluginVersionsRequest, - protos.google.cloud.networkservices.v1.IListWasmPluginVersionsResponse|null|undefined, - protos.google.cloud.networkservices.v1.IWasmPluginVersion>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkservices.v1.IListWasmPluginVersionsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkservices.v1.IListWasmPluginVersionsRequest, - protos.google.cloud.networkservices.v1.IListWasmPluginVersionsResponse|null|undefined, - protos.google.cloud.networkservices.v1.IWasmPluginVersion>): - Promise<[ - protos.google.cloud.networkservices.v1.IWasmPluginVersion[], - protos.google.cloud.networkservices.v1.IListWasmPluginVersionsRequest|null, - protos.google.cloud.networkservices.v1.IListWasmPluginVersionsResponse - ]>|void { + | protos.google.cloud.networkservices.v1.IListWasmPluginVersionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IWasmPluginVersion + >, + callback?: PaginationCallback< + protos.google.cloud.networkservices.v1.IListWasmPluginVersionsRequest, + | protos.google.cloud.networkservices.v1.IListWasmPluginVersionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IWasmPluginVersion + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IWasmPluginVersion[], + protos.google.cloud.networkservices.v1.IListWasmPluginVersionsRequest | null, + protos.google.cloud.networkservices.v1.IListWasmPluginVersionsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListWasmPluginVersionsRequest, - protos.google.cloud.networkservices.v1.IListWasmPluginVersionsResponse|null|undefined, - protos.google.cloud.networkservices.v1.IWasmPluginVersion>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkservices.v1.IListWasmPluginVersionsRequest, + | protos.google.cloud.networkservices.v1.IListWasmPluginVersionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IWasmPluginVersion + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listWasmPluginVersions values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -5814,213 +8809,242 @@ export class NetworkServicesClient { this._log.info('listWasmPluginVersions request %j', request); return this.innerApiCalls .listWasmPluginVersions(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkservices.v1.IWasmPluginVersion[], - protos.google.cloud.networkservices.v1.IListWasmPluginVersionsRequest|null, - protos.google.cloud.networkservices.v1.IListWasmPluginVersionsResponse - ]) => { - this._log.info('listWasmPluginVersions values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkservices.v1.IWasmPluginVersion[], + protos.google.cloud.networkservices.v1.IListWasmPluginVersionsRequest | null, + protos.google.cloud.networkservices.v1.IListWasmPluginVersionsResponse, + ]) => { + this._log.info('listWasmPluginVersions values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listWasmPluginVersions`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The `WasmPlugin` resource whose `WasmPluginVersion`s - * are listed, specified in the following format: - * `projects/{project}/locations/global/wasmPlugins/{wasm_plugin}`. - * @param {number} request.pageSize - * Maximum number of `WasmPluginVersion` resources to return per - * call. If not specified, at most 50 `WasmPluginVersion` resources are - * returned. The maximum value is 1000; values above 1000 are coerced to - * 1000. - * @param {string} request.pageToken - * The value returned by the last `ListWasmPluginVersionsResponse` call. - * Indicates that this is a continuation of a prior - * `ListWasmPluginVersions` call, and that the - * next page of data is to be returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.WasmPluginVersion|WasmPluginVersion} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listWasmPluginVersionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listWasmPluginVersions`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The `WasmPlugin` resource whose `WasmPluginVersion`s + * are listed, specified in the following format: + * `projects/{project}/locations/global/wasmPlugins/{wasm_plugin}`. + * @param {number} request.pageSize + * Maximum number of `WasmPluginVersion` resources to return per + * call. If not specified, at most 50 `WasmPluginVersion` resources are + * returned. The maximum value is 1000; values above 1000 are coerced to + * 1000. + * @param {string} request.pageToken + * The value returned by the last `ListWasmPluginVersionsResponse` call. + * Indicates that this is a continuation of a prior + * `ListWasmPluginVersions` call, and that the + * next page of data is to be returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.WasmPluginVersion|WasmPluginVersion} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listWasmPluginVersionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listWasmPluginVersionsStream( - request?: protos.google.cloud.networkservices.v1.IListWasmPluginVersionsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkservices.v1.IListWasmPluginVersionsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listWasmPluginVersions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listWasmPluginVersions stream %j', request); return this.descriptors.page.listWasmPluginVersions.createStream( this.innerApiCalls.listWasmPluginVersions as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listWasmPluginVersions`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The `WasmPlugin` resource whose `WasmPluginVersion`s - * are listed, specified in the following format: - * `projects/{project}/locations/global/wasmPlugins/{wasm_plugin}`. - * @param {number} request.pageSize - * Maximum number of `WasmPluginVersion` resources to return per - * call. If not specified, at most 50 `WasmPluginVersion` resources are - * returned. The maximum value is 1000; values above 1000 are coerced to - * 1000. - * @param {string} request.pageToken - * The value returned by the last `ListWasmPluginVersionsResponse` call. - * Indicates that this is a continuation of a prior - * `ListWasmPluginVersions` call, and that the - * next page of data is to be returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkservices.v1.WasmPluginVersion|WasmPluginVersion}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_services.list_wasm_plugin_versions.js - * region_tag:networkservices_v1_generated_NetworkServices_ListWasmPluginVersions_async - */ + /** + * Equivalent to `listWasmPluginVersions`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The `WasmPlugin` resource whose `WasmPluginVersion`s + * are listed, specified in the following format: + * `projects/{project}/locations/global/wasmPlugins/{wasm_plugin}`. + * @param {number} request.pageSize + * Maximum number of `WasmPluginVersion` resources to return per + * call. If not specified, at most 50 `WasmPluginVersion` resources are + * returned. The maximum value is 1000; values above 1000 are coerced to + * 1000. + * @param {string} request.pageToken + * The value returned by the last `ListWasmPluginVersionsResponse` call. + * Indicates that this is a continuation of a prior + * `ListWasmPluginVersions` call, and that the + * next page of data is to be returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkservices.v1.WasmPluginVersion|WasmPluginVersion}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_services.list_wasm_plugin_versions.js + * region_tag:networkservices_v1_generated_NetworkServices_ListWasmPluginVersions_async + */ listWasmPluginVersionsAsync( - request?: protos.google.cloud.networkservices.v1.IListWasmPluginVersionsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkservices.v1.IListWasmPluginVersionsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listWasmPluginVersions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listWasmPluginVersions iterate %j', request); return this.descriptors.page.listWasmPluginVersions.asyncIterate( this.innerApiCalls['listWasmPluginVersions'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists `WasmPlugin` resources in a given project and - * location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the `WasmPlugin` resources - * are listed, specified in the following format: - * `projects/{project}/locations/global`. - * @param {number} request.pageSize - * Maximum number of `WasmPlugin` resources to return per call. - * If not specified, at most 50 `WasmPlugin` resources are returned. - * The maximum value is 1000; values above 1000 are coerced to 1000. - * @param {string} request.pageToken - * The value returned by the last `ListWasmPluginsResponse` call. - * Indicates that this is a continuation of a prior - * `ListWasmPlugins` call, and that the - * next page of data is to be returned. - * @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 Array of {@link protos.google.cloud.networkservices.v1.WasmPlugin|WasmPlugin}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listWasmPluginsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists `WasmPlugin` resources in a given project and + * location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the `WasmPlugin` resources + * are listed, specified in the following format: + * `projects/{project}/locations/global`. + * @param {number} request.pageSize + * Maximum number of `WasmPlugin` resources to return per call. + * If not specified, at most 50 `WasmPlugin` resources are returned. + * The maximum value is 1000; values above 1000 are coerced to 1000. + * @param {string} request.pageToken + * The value returned by the last `ListWasmPluginsResponse` call. + * Indicates that this is a continuation of a prior + * `ListWasmPlugins` call, and that the + * next page of data is to be returned. + * @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 Array of {@link protos.google.cloud.networkservices.v1.WasmPlugin|WasmPlugin}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listWasmPluginsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listWasmPlugins( - request?: protos.google.cloud.networkservices.v1.IListWasmPluginsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.IWasmPlugin[], - protos.google.cloud.networkservices.v1.IListWasmPluginsRequest|null, - protos.google.cloud.networkservices.v1.IListWasmPluginsResponse - ]>; + request?: protos.google.cloud.networkservices.v1.IListWasmPluginsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IWasmPlugin[], + protos.google.cloud.networkservices.v1.IListWasmPluginsRequest | null, + protos.google.cloud.networkservices.v1.IListWasmPluginsResponse, + ] + >; listWasmPlugins( - request: protos.google.cloud.networkservices.v1.IListWasmPluginsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListWasmPluginsRequest, - protos.google.cloud.networkservices.v1.IListWasmPluginsResponse|null|undefined, - protos.google.cloud.networkservices.v1.IWasmPlugin>): void; + request: protos.google.cloud.networkservices.v1.IListWasmPluginsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListWasmPluginsRequest, + | protos.google.cloud.networkservices.v1.IListWasmPluginsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IWasmPlugin + >, + ): void; listWasmPlugins( - request: protos.google.cloud.networkservices.v1.IListWasmPluginsRequest, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListWasmPluginsRequest, - protos.google.cloud.networkservices.v1.IListWasmPluginsResponse|null|undefined, - protos.google.cloud.networkservices.v1.IWasmPlugin>): void; + request: protos.google.cloud.networkservices.v1.IListWasmPluginsRequest, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListWasmPluginsRequest, + | protos.google.cloud.networkservices.v1.IListWasmPluginsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IWasmPlugin + >, + ): void; listWasmPlugins( - request?: protos.google.cloud.networkservices.v1.IListWasmPluginsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkservices.v1.IListWasmPluginsRequest, - protos.google.cloud.networkservices.v1.IListWasmPluginsResponse|null|undefined, - protos.google.cloud.networkservices.v1.IWasmPlugin>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkservices.v1.IListWasmPluginsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkservices.v1.IListWasmPluginsRequest, - protos.google.cloud.networkservices.v1.IListWasmPluginsResponse|null|undefined, - protos.google.cloud.networkservices.v1.IWasmPlugin>): - Promise<[ - protos.google.cloud.networkservices.v1.IWasmPlugin[], - protos.google.cloud.networkservices.v1.IListWasmPluginsRequest|null, - protos.google.cloud.networkservices.v1.IListWasmPluginsResponse - ]>|void { + | protos.google.cloud.networkservices.v1.IListWasmPluginsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IWasmPlugin + >, + callback?: PaginationCallback< + protos.google.cloud.networkservices.v1.IListWasmPluginsRequest, + | protos.google.cloud.networkservices.v1.IListWasmPluginsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IWasmPlugin + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IWasmPlugin[], + protos.google.cloud.networkservices.v1.IListWasmPluginsRequest | null, + protos.google.cloud.networkservices.v1.IListWasmPluginsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListWasmPluginsRequest, - protos.google.cloud.networkservices.v1.IListWasmPluginsResponse|null|undefined, - protos.google.cloud.networkservices.v1.IWasmPlugin>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkservices.v1.IListWasmPluginsRequest, + | protos.google.cloud.networkservices.v1.IListWasmPluginsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IWasmPlugin + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listWasmPlugins values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -6029,206 +9053,235 @@ export class NetworkServicesClient { this._log.info('listWasmPlugins request %j', request); return this.innerApiCalls .listWasmPlugins(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkservices.v1.IWasmPlugin[], - protos.google.cloud.networkservices.v1.IListWasmPluginsRequest|null, - protos.google.cloud.networkservices.v1.IListWasmPluginsResponse - ]) => { - this._log.info('listWasmPlugins values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkservices.v1.IWasmPlugin[], + protos.google.cloud.networkservices.v1.IListWasmPluginsRequest | null, + protos.google.cloud.networkservices.v1.IListWasmPluginsResponse, + ]) => { + this._log.info('listWasmPlugins values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listWasmPlugins`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the `WasmPlugin` resources - * are listed, specified in the following format: - * `projects/{project}/locations/global`. - * @param {number} request.pageSize - * Maximum number of `WasmPlugin` resources to return per call. - * If not specified, at most 50 `WasmPlugin` resources are returned. - * The maximum value is 1000; values above 1000 are coerced to 1000. - * @param {string} request.pageToken - * The value returned by the last `ListWasmPluginsResponse` call. - * Indicates that this is a continuation of a prior - * `ListWasmPlugins` call, and that the - * next page of data is to be returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.WasmPlugin|WasmPlugin} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listWasmPluginsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listWasmPlugins`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the `WasmPlugin` resources + * are listed, specified in the following format: + * `projects/{project}/locations/global`. + * @param {number} request.pageSize + * Maximum number of `WasmPlugin` resources to return per call. + * If not specified, at most 50 `WasmPlugin` resources are returned. + * The maximum value is 1000; values above 1000 are coerced to 1000. + * @param {string} request.pageToken + * The value returned by the last `ListWasmPluginsResponse` call. + * Indicates that this is a continuation of a prior + * `ListWasmPlugins` call, and that the + * next page of data is to be returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.WasmPlugin|WasmPlugin} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listWasmPluginsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listWasmPluginsStream( - request?: protos.google.cloud.networkservices.v1.IListWasmPluginsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkservices.v1.IListWasmPluginsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listWasmPlugins']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listWasmPlugins stream %j', request); return this.descriptors.page.listWasmPlugins.createStream( this.innerApiCalls.listWasmPlugins as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listWasmPlugins`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the `WasmPlugin` resources - * are listed, specified in the following format: - * `projects/{project}/locations/global`. - * @param {number} request.pageSize - * Maximum number of `WasmPlugin` resources to return per call. - * If not specified, at most 50 `WasmPlugin` resources are returned. - * The maximum value is 1000; values above 1000 are coerced to 1000. - * @param {string} request.pageToken - * The value returned by the last `ListWasmPluginsResponse` call. - * Indicates that this is a continuation of a prior - * `ListWasmPlugins` call, and that the - * next page of data is to be returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkservices.v1.WasmPlugin|WasmPlugin}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_services.list_wasm_plugins.js - * region_tag:networkservices_v1_generated_NetworkServices_ListWasmPlugins_async - */ + /** + * Equivalent to `listWasmPlugins`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the `WasmPlugin` resources + * are listed, specified in the following format: + * `projects/{project}/locations/global`. + * @param {number} request.pageSize + * Maximum number of `WasmPlugin` resources to return per call. + * If not specified, at most 50 `WasmPlugin` resources are returned. + * The maximum value is 1000; values above 1000 are coerced to 1000. + * @param {string} request.pageToken + * The value returned by the last `ListWasmPluginsResponse` call. + * Indicates that this is a continuation of a prior + * `ListWasmPlugins` call, and that the + * next page of data is to be returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkservices.v1.WasmPlugin|WasmPlugin}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_services.list_wasm_plugins.js + * region_tag:networkservices_v1_generated_NetworkServices_ListWasmPlugins_async + */ listWasmPluginsAsync( - request?: protos.google.cloud.networkservices.v1.IListWasmPluginsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkservices.v1.IListWasmPluginsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listWasmPlugins']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listWasmPlugins iterate %j', request); return this.descriptors.page.listWasmPlugins.asyncIterate( this.innerApiCalls['listWasmPlugins'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists Gateways in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the Gateways should be - * listed, specified in the format `projects/* /locations/*`. - * @param {number} request.pageSize - * Maximum number of Gateways to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListGatewaysResponse` - * Indicates that this is a continuation of a prior `ListGateways` call, - * and that the system should return the next page of data. - * @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 Array of {@link protos.google.cloud.networkservices.v1.Gateway|Gateway}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listGatewaysAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists Gateways in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the Gateways should be + * listed, specified in the format `projects/* /locations/*`. + * @param {number} request.pageSize + * Maximum number of Gateways to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListGatewaysResponse` + * Indicates that this is a continuation of a prior `ListGateways` call, + * and that the system should return the next page of data. + * @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 Array of {@link protos.google.cloud.networkservices.v1.Gateway|Gateway}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listGatewaysAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listGateways( - request?: protos.google.cloud.networkservices.v1.IListGatewaysRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.IGateway[], - protos.google.cloud.networkservices.v1.IListGatewaysRequest|null, - protos.google.cloud.networkservices.v1.IListGatewaysResponse - ]>; + request?: protos.google.cloud.networkservices.v1.IListGatewaysRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IGateway[], + protos.google.cloud.networkservices.v1.IListGatewaysRequest | null, + protos.google.cloud.networkservices.v1.IListGatewaysResponse, + ] + >; listGateways( - request: protos.google.cloud.networkservices.v1.IListGatewaysRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListGatewaysRequest, - protos.google.cloud.networkservices.v1.IListGatewaysResponse|null|undefined, - protos.google.cloud.networkservices.v1.IGateway>): void; + request: protos.google.cloud.networkservices.v1.IListGatewaysRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListGatewaysRequest, + | protos.google.cloud.networkservices.v1.IListGatewaysResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IGateway + >, + ): void; listGateways( - request: protos.google.cloud.networkservices.v1.IListGatewaysRequest, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListGatewaysRequest, - protos.google.cloud.networkservices.v1.IListGatewaysResponse|null|undefined, - protos.google.cloud.networkservices.v1.IGateway>): void; + request: protos.google.cloud.networkservices.v1.IListGatewaysRequest, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListGatewaysRequest, + | protos.google.cloud.networkservices.v1.IListGatewaysResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IGateway + >, + ): void; listGateways( - request?: protos.google.cloud.networkservices.v1.IListGatewaysRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkservices.v1.IListGatewaysRequest, - protos.google.cloud.networkservices.v1.IListGatewaysResponse|null|undefined, - protos.google.cloud.networkservices.v1.IGateway>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkservices.v1.IListGatewaysRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkservices.v1.IListGatewaysRequest, - protos.google.cloud.networkservices.v1.IListGatewaysResponse|null|undefined, - protos.google.cloud.networkservices.v1.IGateway>): - Promise<[ - protos.google.cloud.networkservices.v1.IGateway[], - protos.google.cloud.networkservices.v1.IListGatewaysRequest|null, - protos.google.cloud.networkservices.v1.IListGatewaysResponse - ]>|void { + | protos.google.cloud.networkservices.v1.IListGatewaysResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IGateway + >, + callback?: PaginationCallback< + protos.google.cloud.networkservices.v1.IListGatewaysRequest, + | protos.google.cloud.networkservices.v1.IListGatewaysResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IGateway + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IGateway[], + protos.google.cloud.networkservices.v1.IListGatewaysRequest | null, + protos.google.cloud.networkservices.v1.IListGatewaysResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListGatewaysRequest, - protos.google.cloud.networkservices.v1.IListGatewaysResponse|null|undefined, - protos.google.cloud.networkservices.v1.IGateway>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkservices.v1.IListGatewaysRequest, + | protos.google.cloud.networkservices.v1.IListGatewaysResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IGateway + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listGateways values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -6237,202 +9290,231 @@ export class NetworkServicesClient { this._log.info('listGateways request %j', request); return this.innerApiCalls .listGateways(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkservices.v1.IGateway[], - protos.google.cloud.networkservices.v1.IListGatewaysRequest|null, - protos.google.cloud.networkservices.v1.IListGatewaysResponse - ]) => { - this._log.info('listGateways values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkservices.v1.IGateway[], + protos.google.cloud.networkservices.v1.IListGatewaysRequest | null, + protos.google.cloud.networkservices.v1.IListGatewaysResponse, + ]) => { + this._log.info('listGateways values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listGateways`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the Gateways should be - * listed, specified in the format `projects/* /locations/*`. - * @param {number} request.pageSize - * Maximum number of Gateways to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListGatewaysResponse` - * Indicates that this is a continuation of a prior `ListGateways` call, - * and that the system should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.Gateway|Gateway} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listGatewaysAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listGateways`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the Gateways should be + * listed, specified in the format `projects/* /locations/*`. + * @param {number} request.pageSize + * Maximum number of Gateways to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListGatewaysResponse` + * Indicates that this is a continuation of a prior `ListGateways` call, + * and that the system should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.Gateway|Gateway} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listGatewaysAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listGatewaysStream( - request?: protos.google.cloud.networkservices.v1.IListGatewaysRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkservices.v1.IListGatewaysRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listGateways']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listGateways stream %j', request); return this.descriptors.page.listGateways.createStream( this.innerApiCalls.listGateways as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listGateways`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the Gateways should be - * listed, specified in the format `projects/* /locations/*`. - * @param {number} request.pageSize - * Maximum number of Gateways to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListGatewaysResponse` - * Indicates that this is a continuation of a prior `ListGateways` call, - * and that the system should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkservices.v1.Gateway|Gateway}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_services.list_gateways.js - * region_tag:networkservices_v1_generated_NetworkServices_ListGateways_async - */ + /** + * Equivalent to `listGateways`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the Gateways should be + * listed, specified in the format `projects/* /locations/*`. + * @param {number} request.pageSize + * Maximum number of Gateways to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListGatewaysResponse` + * Indicates that this is a continuation of a prior `ListGateways` call, + * and that the system should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkservices.v1.Gateway|Gateway}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_services.list_gateways.js + * region_tag:networkservices_v1_generated_NetworkServices_ListGateways_async + */ listGatewaysAsync( - request?: protos.google.cloud.networkservices.v1.IListGatewaysRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkservices.v1.IListGatewaysRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listGateways']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listGateways iterate %j', request); return this.descriptors.page.listGateways.asyncIterate( this.innerApiCalls['listGateways'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists GrpcRoutes in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the GrpcRoutes should be - * listed, specified in the format `projects/* /locations/global`. - * @param {number} request.pageSize - * Maximum number of GrpcRoutes to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListGrpcRoutesResponse` - * Indicates that this is a continuation of a prior `ListGrpcRoutes` call, - * and that the system should return the next page of data. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If true, allow partial responses for multi-regional Aggregated - * List requests. Otherwise if one of the locations is down or unreachable, - * the Aggregated List request will fail. - * @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 Array of {@link protos.google.cloud.networkservices.v1.GrpcRoute|GrpcRoute}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listGrpcRoutesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists GrpcRoutes in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the GrpcRoutes should be + * listed, specified in the format `projects/* /locations/global`. + * @param {number} request.pageSize + * Maximum number of GrpcRoutes to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListGrpcRoutesResponse` + * Indicates that this is a continuation of a prior `ListGrpcRoutes` call, + * and that the system should return the next page of data. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If true, allow partial responses for multi-regional Aggregated + * List requests. Otherwise if one of the locations is down or unreachable, + * the Aggregated List request will fail. + * @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 Array of {@link protos.google.cloud.networkservices.v1.GrpcRoute|GrpcRoute}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listGrpcRoutesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listGrpcRoutes( - request?: protos.google.cloud.networkservices.v1.IListGrpcRoutesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.IGrpcRoute[], - protos.google.cloud.networkservices.v1.IListGrpcRoutesRequest|null, - protos.google.cloud.networkservices.v1.IListGrpcRoutesResponse - ]>; + request?: protos.google.cloud.networkservices.v1.IListGrpcRoutesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IGrpcRoute[], + protos.google.cloud.networkservices.v1.IListGrpcRoutesRequest | null, + protos.google.cloud.networkservices.v1.IListGrpcRoutesResponse, + ] + >; listGrpcRoutes( - request: protos.google.cloud.networkservices.v1.IListGrpcRoutesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListGrpcRoutesRequest, - protos.google.cloud.networkservices.v1.IListGrpcRoutesResponse|null|undefined, - protos.google.cloud.networkservices.v1.IGrpcRoute>): void; + request: protos.google.cloud.networkservices.v1.IListGrpcRoutesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListGrpcRoutesRequest, + | protos.google.cloud.networkservices.v1.IListGrpcRoutesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IGrpcRoute + >, + ): void; listGrpcRoutes( - request: protos.google.cloud.networkservices.v1.IListGrpcRoutesRequest, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListGrpcRoutesRequest, - protos.google.cloud.networkservices.v1.IListGrpcRoutesResponse|null|undefined, - protos.google.cloud.networkservices.v1.IGrpcRoute>): void; + request: protos.google.cloud.networkservices.v1.IListGrpcRoutesRequest, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListGrpcRoutesRequest, + | protos.google.cloud.networkservices.v1.IListGrpcRoutesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IGrpcRoute + >, + ): void; listGrpcRoutes( - request?: protos.google.cloud.networkservices.v1.IListGrpcRoutesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkservices.v1.IListGrpcRoutesRequest, - protos.google.cloud.networkservices.v1.IListGrpcRoutesResponse|null|undefined, - protos.google.cloud.networkservices.v1.IGrpcRoute>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkservices.v1.IListGrpcRoutesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkservices.v1.IListGrpcRoutesRequest, - protos.google.cloud.networkservices.v1.IListGrpcRoutesResponse|null|undefined, - protos.google.cloud.networkservices.v1.IGrpcRoute>): - Promise<[ - protos.google.cloud.networkservices.v1.IGrpcRoute[], - protos.google.cloud.networkservices.v1.IListGrpcRoutesRequest|null, - protos.google.cloud.networkservices.v1.IListGrpcRoutesResponse - ]>|void { + | protos.google.cloud.networkservices.v1.IListGrpcRoutesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IGrpcRoute + >, + callback?: PaginationCallback< + protos.google.cloud.networkservices.v1.IListGrpcRoutesRequest, + | protos.google.cloud.networkservices.v1.IListGrpcRoutesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IGrpcRoute + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IGrpcRoute[], + protos.google.cloud.networkservices.v1.IListGrpcRoutesRequest | null, + protos.google.cloud.networkservices.v1.IListGrpcRoutesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListGrpcRoutesRequest, - protos.google.cloud.networkservices.v1.IListGrpcRoutesResponse|null|undefined, - protos.google.cloud.networkservices.v1.IGrpcRoute>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkservices.v1.IListGrpcRoutesRequest, + | protos.google.cloud.networkservices.v1.IListGrpcRoutesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IGrpcRoute + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listGrpcRoutes values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -6441,210 +9523,239 @@ export class NetworkServicesClient { this._log.info('listGrpcRoutes request %j', request); return this.innerApiCalls .listGrpcRoutes(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkservices.v1.IGrpcRoute[], - protos.google.cloud.networkservices.v1.IListGrpcRoutesRequest|null, - protos.google.cloud.networkservices.v1.IListGrpcRoutesResponse - ]) => { - this._log.info('listGrpcRoutes values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkservices.v1.IGrpcRoute[], + protos.google.cloud.networkservices.v1.IListGrpcRoutesRequest | null, + protos.google.cloud.networkservices.v1.IListGrpcRoutesResponse, + ]) => { + this._log.info('listGrpcRoutes values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listGrpcRoutes`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the GrpcRoutes should be - * listed, specified in the format `projects/* /locations/global`. - * @param {number} request.pageSize - * Maximum number of GrpcRoutes to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListGrpcRoutesResponse` - * Indicates that this is a continuation of a prior `ListGrpcRoutes` call, - * and that the system should return the next page of data. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If true, allow partial responses for multi-regional Aggregated - * List requests. Otherwise if one of the locations is down or unreachable, - * the Aggregated List request will fail. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.GrpcRoute|GrpcRoute} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listGrpcRoutesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listGrpcRoutes`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the GrpcRoutes should be + * listed, specified in the format `projects/* /locations/global`. + * @param {number} request.pageSize + * Maximum number of GrpcRoutes to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListGrpcRoutesResponse` + * Indicates that this is a continuation of a prior `ListGrpcRoutes` call, + * and that the system should return the next page of data. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If true, allow partial responses for multi-regional Aggregated + * List requests. Otherwise if one of the locations is down or unreachable, + * the Aggregated List request will fail. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.GrpcRoute|GrpcRoute} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listGrpcRoutesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listGrpcRoutesStream( - request?: protos.google.cloud.networkservices.v1.IListGrpcRoutesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkservices.v1.IListGrpcRoutesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listGrpcRoutes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listGrpcRoutes stream %j', request); return this.descriptors.page.listGrpcRoutes.createStream( this.innerApiCalls.listGrpcRoutes as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listGrpcRoutes`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the GrpcRoutes should be - * listed, specified in the format `projects/* /locations/global`. - * @param {number} request.pageSize - * Maximum number of GrpcRoutes to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListGrpcRoutesResponse` - * Indicates that this is a continuation of a prior `ListGrpcRoutes` call, - * and that the system should return the next page of data. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If true, allow partial responses for multi-regional Aggregated - * List requests. Otherwise if one of the locations is down or unreachable, - * the Aggregated List request will fail. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkservices.v1.GrpcRoute|GrpcRoute}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_services.list_grpc_routes.js - * region_tag:networkservices_v1_generated_NetworkServices_ListGrpcRoutes_async - */ + /** + * Equivalent to `listGrpcRoutes`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the GrpcRoutes should be + * listed, specified in the format `projects/* /locations/global`. + * @param {number} request.pageSize + * Maximum number of GrpcRoutes to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListGrpcRoutesResponse` + * Indicates that this is a continuation of a prior `ListGrpcRoutes` call, + * and that the system should return the next page of data. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If true, allow partial responses for multi-regional Aggregated + * List requests. Otherwise if one of the locations is down or unreachable, + * the Aggregated List request will fail. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkservices.v1.GrpcRoute|GrpcRoute}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_services.list_grpc_routes.js + * region_tag:networkservices_v1_generated_NetworkServices_ListGrpcRoutes_async + */ listGrpcRoutesAsync( - request?: protos.google.cloud.networkservices.v1.IListGrpcRoutesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkservices.v1.IListGrpcRoutesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listGrpcRoutes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listGrpcRoutes iterate %j', request); return this.descriptors.page.listGrpcRoutes.asyncIterate( this.innerApiCalls['listGrpcRoutes'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists HttpRoute in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the HttpRoutes should be - * listed, specified in the format `projects/* /locations/global`. - * @param {number} request.pageSize - * Maximum number of HttpRoutes to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListHttpRoutesResponse` - * Indicates that this is a continuation of a prior `ListHttpRoutes` call, - * and that the system should return the next page of data. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If true, allow partial responses for multi-regional Aggregated - * List requests. Otherwise if one of the locations is down or unreachable, - * the Aggregated List request will fail. - * @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 Array of {@link protos.google.cloud.networkservices.v1.HttpRoute|HttpRoute}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listHttpRoutesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists HttpRoute in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the HttpRoutes should be + * listed, specified in the format `projects/* /locations/global`. + * @param {number} request.pageSize + * Maximum number of HttpRoutes to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListHttpRoutesResponse` + * Indicates that this is a continuation of a prior `ListHttpRoutes` call, + * and that the system should return the next page of data. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If true, allow partial responses for multi-regional Aggregated + * List requests. Otherwise if one of the locations is down or unreachable, + * the Aggregated List request will fail. + * @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 Array of {@link protos.google.cloud.networkservices.v1.HttpRoute|HttpRoute}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listHttpRoutesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listHttpRoutes( - request?: protos.google.cloud.networkservices.v1.IListHttpRoutesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.IHttpRoute[], - protos.google.cloud.networkservices.v1.IListHttpRoutesRequest|null, - protos.google.cloud.networkservices.v1.IListHttpRoutesResponse - ]>; + request?: protos.google.cloud.networkservices.v1.IListHttpRoutesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IHttpRoute[], + protos.google.cloud.networkservices.v1.IListHttpRoutesRequest | null, + protos.google.cloud.networkservices.v1.IListHttpRoutesResponse, + ] + >; listHttpRoutes( - request: protos.google.cloud.networkservices.v1.IListHttpRoutesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListHttpRoutesRequest, - protos.google.cloud.networkservices.v1.IListHttpRoutesResponse|null|undefined, - protos.google.cloud.networkservices.v1.IHttpRoute>): void; + request: protos.google.cloud.networkservices.v1.IListHttpRoutesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListHttpRoutesRequest, + | protos.google.cloud.networkservices.v1.IListHttpRoutesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IHttpRoute + >, + ): void; listHttpRoutes( - request: protos.google.cloud.networkservices.v1.IListHttpRoutesRequest, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListHttpRoutesRequest, - protos.google.cloud.networkservices.v1.IListHttpRoutesResponse|null|undefined, - protos.google.cloud.networkservices.v1.IHttpRoute>): void; + request: protos.google.cloud.networkservices.v1.IListHttpRoutesRequest, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListHttpRoutesRequest, + | protos.google.cloud.networkservices.v1.IListHttpRoutesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IHttpRoute + >, + ): void; listHttpRoutes( - request?: protos.google.cloud.networkservices.v1.IListHttpRoutesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkservices.v1.IListHttpRoutesRequest, - protos.google.cloud.networkservices.v1.IListHttpRoutesResponse|null|undefined, - protos.google.cloud.networkservices.v1.IHttpRoute>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkservices.v1.IListHttpRoutesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkservices.v1.IListHttpRoutesRequest, - protos.google.cloud.networkservices.v1.IListHttpRoutesResponse|null|undefined, - protos.google.cloud.networkservices.v1.IHttpRoute>): - Promise<[ - protos.google.cloud.networkservices.v1.IHttpRoute[], - protos.google.cloud.networkservices.v1.IListHttpRoutesRequest|null, - protos.google.cloud.networkservices.v1.IListHttpRoutesResponse - ]>|void { + | protos.google.cloud.networkservices.v1.IListHttpRoutesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IHttpRoute + >, + callback?: PaginationCallback< + protos.google.cloud.networkservices.v1.IListHttpRoutesRequest, + | protos.google.cloud.networkservices.v1.IListHttpRoutesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IHttpRoute + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IHttpRoute[], + protos.google.cloud.networkservices.v1.IListHttpRoutesRequest | null, + protos.google.cloud.networkservices.v1.IListHttpRoutesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListHttpRoutesRequest, - protos.google.cloud.networkservices.v1.IListHttpRoutesResponse|null|undefined, - protos.google.cloud.networkservices.v1.IHttpRoute>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkservices.v1.IListHttpRoutesRequest, + | protos.google.cloud.networkservices.v1.IListHttpRoutesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IHttpRoute + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listHttpRoutes values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -6653,210 +9764,239 @@ export class NetworkServicesClient { this._log.info('listHttpRoutes request %j', request); return this.innerApiCalls .listHttpRoutes(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkservices.v1.IHttpRoute[], - protos.google.cloud.networkservices.v1.IListHttpRoutesRequest|null, - protos.google.cloud.networkservices.v1.IListHttpRoutesResponse - ]) => { - this._log.info('listHttpRoutes values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkservices.v1.IHttpRoute[], + protos.google.cloud.networkservices.v1.IListHttpRoutesRequest | null, + protos.google.cloud.networkservices.v1.IListHttpRoutesResponse, + ]) => { + this._log.info('listHttpRoutes values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listHttpRoutes`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the HttpRoutes should be - * listed, specified in the format `projects/* /locations/global`. - * @param {number} request.pageSize - * Maximum number of HttpRoutes to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListHttpRoutesResponse` - * Indicates that this is a continuation of a prior `ListHttpRoutes` call, - * and that the system should return the next page of data. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If true, allow partial responses for multi-regional Aggregated - * List requests. Otherwise if one of the locations is down or unreachable, - * the Aggregated List request will fail. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.HttpRoute|HttpRoute} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listHttpRoutesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listHttpRoutes`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the HttpRoutes should be + * listed, specified in the format `projects/* /locations/global`. + * @param {number} request.pageSize + * Maximum number of HttpRoutes to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListHttpRoutesResponse` + * Indicates that this is a continuation of a prior `ListHttpRoutes` call, + * and that the system should return the next page of data. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If true, allow partial responses for multi-regional Aggregated + * List requests. Otherwise if one of the locations is down or unreachable, + * the Aggregated List request will fail. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.HttpRoute|HttpRoute} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listHttpRoutesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listHttpRoutesStream( - request?: protos.google.cloud.networkservices.v1.IListHttpRoutesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkservices.v1.IListHttpRoutesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listHttpRoutes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listHttpRoutes stream %j', request); return this.descriptors.page.listHttpRoutes.createStream( this.innerApiCalls.listHttpRoutes as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listHttpRoutes`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the HttpRoutes should be - * listed, specified in the format `projects/* /locations/global`. - * @param {number} request.pageSize - * Maximum number of HttpRoutes to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListHttpRoutesResponse` - * Indicates that this is a continuation of a prior `ListHttpRoutes` call, - * and that the system should return the next page of data. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If true, allow partial responses for multi-regional Aggregated - * List requests. Otherwise if one of the locations is down or unreachable, - * the Aggregated List request will fail. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkservices.v1.HttpRoute|HttpRoute}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_services.list_http_routes.js - * region_tag:networkservices_v1_generated_NetworkServices_ListHttpRoutes_async - */ + /** + * Equivalent to `listHttpRoutes`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the HttpRoutes should be + * listed, specified in the format `projects/* /locations/global`. + * @param {number} request.pageSize + * Maximum number of HttpRoutes to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListHttpRoutesResponse` + * Indicates that this is a continuation of a prior `ListHttpRoutes` call, + * and that the system should return the next page of data. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If true, allow partial responses for multi-regional Aggregated + * List requests. Otherwise if one of the locations is down or unreachable, + * the Aggregated List request will fail. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkservices.v1.HttpRoute|HttpRoute}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_services.list_http_routes.js + * region_tag:networkservices_v1_generated_NetworkServices_ListHttpRoutes_async + */ listHttpRoutesAsync( - request?: protos.google.cloud.networkservices.v1.IListHttpRoutesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkservices.v1.IListHttpRoutesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listHttpRoutes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listHttpRoutes iterate %j', request); return this.descriptors.page.listHttpRoutes.asyncIterate( this.innerApiCalls['listHttpRoutes'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists TcpRoute in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the TcpRoutes should be - * listed, specified in the format `projects/* /locations/global`. - * @param {number} request.pageSize - * Maximum number of TcpRoutes to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListTcpRoutesResponse` - * Indicates that this is a continuation of a prior `ListTcpRoutes` call, - * and that the system should return the next page of data. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If true, allow partial responses for multi-regional Aggregated - * List requests. Otherwise if one of the locations is down or unreachable, - * the Aggregated List request will fail. - * @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 Array of {@link protos.google.cloud.networkservices.v1.TcpRoute|TcpRoute}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listTcpRoutesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists TcpRoute in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the TcpRoutes should be + * listed, specified in the format `projects/* /locations/global`. + * @param {number} request.pageSize + * Maximum number of TcpRoutes to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListTcpRoutesResponse` + * Indicates that this is a continuation of a prior `ListTcpRoutes` call, + * and that the system should return the next page of data. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If true, allow partial responses for multi-regional Aggregated + * List requests. Otherwise if one of the locations is down or unreachable, + * the Aggregated List request will fail. + * @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 Array of {@link protos.google.cloud.networkservices.v1.TcpRoute|TcpRoute}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listTcpRoutesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listTcpRoutes( - request?: protos.google.cloud.networkservices.v1.IListTcpRoutesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.ITcpRoute[], - protos.google.cloud.networkservices.v1.IListTcpRoutesRequest|null, - protos.google.cloud.networkservices.v1.IListTcpRoutesResponse - ]>; + request?: protos.google.cloud.networkservices.v1.IListTcpRoutesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.ITcpRoute[], + protos.google.cloud.networkservices.v1.IListTcpRoutesRequest | null, + protos.google.cloud.networkservices.v1.IListTcpRoutesResponse, + ] + >; listTcpRoutes( - request: protos.google.cloud.networkservices.v1.IListTcpRoutesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListTcpRoutesRequest, - protos.google.cloud.networkservices.v1.IListTcpRoutesResponse|null|undefined, - protos.google.cloud.networkservices.v1.ITcpRoute>): void; + request: protos.google.cloud.networkservices.v1.IListTcpRoutesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListTcpRoutesRequest, + | protos.google.cloud.networkservices.v1.IListTcpRoutesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.ITcpRoute + >, + ): void; listTcpRoutes( - request: protos.google.cloud.networkservices.v1.IListTcpRoutesRequest, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListTcpRoutesRequest, - protos.google.cloud.networkservices.v1.IListTcpRoutesResponse|null|undefined, - protos.google.cloud.networkservices.v1.ITcpRoute>): void; + request: protos.google.cloud.networkservices.v1.IListTcpRoutesRequest, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListTcpRoutesRequest, + | protos.google.cloud.networkservices.v1.IListTcpRoutesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.ITcpRoute + >, + ): void; listTcpRoutes( - request?: protos.google.cloud.networkservices.v1.IListTcpRoutesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkservices.v1.IListTcpRoutesRequest, - protos.google.cloud.networkservices.v1.IListTcpRoutesResponse|null|undefined, - protos.google.cloud.networkservices.v1.ITcpRoute>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkservices.v1.IListTcpRoutesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkservices.v1.IListTcpRoutesRequest, - protos.google.cloud.networkservices.v1.IListTcpRoutesResponse|null|undefined, - protos.google.cloud.networkservices.v1.ITcpRoute>): - Promise<[ - protos.google.cloud.networkservices.v1.ITcpRoute[], - protos.google.cloud.networkservices.v1.IListTcpRoutesRequest|null, - protos.google.cloud.networkservices.v1.IListTcpRoutesResponse - ]>|void { + | protos.google.cloud.networkservices.v1.IListTcpRoutesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.ITcpRoute + >, + callback?: PaginationCallback< + protos.google.cloud.networkservices.v1.IListTcpRoutesRequest, + | protos.google.cloud.networkservices.v1.IListTcpRoutesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.ITcpRoute + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.ITcpRoute[], + protos.google.cloud.networkservices.v1.IListTcpRoutesRequest | null, + protos.google.cloud.networkservices.v1.IListTcpRoutesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListTcpRoutesRequest, - protos.google.cloud.networkservices.v1.IListTcpRoutesResponse|null|undefined, - protos.google.cloud.networkservices.v1.ITcpRoute>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkservices.v1.IListTcpRoutesRequest, + | protos.google.cloud.networkservices.v1.IListTcpRoutesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.ITcpRoute + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listTcpRoutes values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -6865,210 +10005,239 @@ export class NetworkServicesClient { this._log.info('listTcpRoutes request %j', request); return this.innerApiCalls .listTcpRoutes(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkservices.v1.ITcpRoute[], - protos.google.cloud.networkservices.v1.IListTcpRoutesRequest|null, - protos.google.cloud.networkservices.v1.IListTcpRoutesResponse - ]) => { - this._log.info('listTcpRoutes values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkservices.v1.ITcpRoute[], + protos.google.cloud.networkservices.v1.IListTcpRoutesRequest | null, + protos.google.cloud.networkservices.v1.IListTcpRoutesResponse, + ]) => { + this._log.info('listTcpRoutes values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listTcpRoutes`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the TcpRoutes should be - * listed, specified in the format `projects/* /locations/global`. - * @param {number} request.pageSize - * Maximum number of TcpRoutes to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListTcpRoutesResponse` - * Indicates that this is a continuation of a prior `ListTcpRoutes` call, - * and that the system should return the next page of data. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If true, allow partial responses for multi-regional Aggregated - * List requests. Otherwise if one of the locations is down or unreachable, - * the Aggregated List request will fail. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.TcpRoute|TcpRoute} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listTcpRoutesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listTcpRoutes`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the TcpRoutes should be + * listed, specified in the format `projects/* /locations/global`. + * @param {number} request.pageSize + * Maximum number of TcpRoutes to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListTcpRoutesResponse` + * Indicates that this is a continuation of a prior `ListTcpRoutes` call, + * and that the system should return the next page of data. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If true, allow partial responses for multi-regional Aggregated + * List requests. Otherwise if one of the locations is down or unreachable, + * the Aggregated List request will fail. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.TcpRoute|TcpRoute} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listTcpRoutesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listTcpRoutesStream( - request?: protos.google.cloud.networkservices.v1.IListTcpRoutesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkservices.v1.IListTcpRoutesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listTcpRoutes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listTcpRoutes stream %j', request); return this.descriptors.page.listTcpRoutes.createStream( this.innerApiCalls.listTcpRoutes as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listTcpRoutes`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the TcpRoutes should be - * listed, specified in the format `projects/* /locations/global`. - * @param {number} request.pageSize - * Maximum number of TcpRoutes to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListTcpRoutesResponse` - * Indicates that this is a continuation of a prior `ListTcpRoutes` call, - * and that the system should return the next page of data. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If true, allow partial responses for multi-regional Aggregated - * List requests. Otherwise if one of the locations is down or unreachable, - * the Aggregated List request will fail. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkservices.v1.TcpRoute|TcpRoute}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_services.list_tcp_routes.js - * region_tag:networkservices_v1_generated_NetworkServices_ListTcpRoutes_async - */ + /** + * Equivalent to `listTcpRoutes`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the TcpRoutes should be + * listed, specified in the format `projects/* /locations/global`. + * @param {number} request.pageSize + * Maximum number of TcpRoutes to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListTcpRoutesResponse` + * Indicates that this is a continuation of a prior `ListTcpRoutes` call, + * and that the system should return the next page of data. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If true, allow partial responses for multi-regional Aggregated + * List requests. Otherwise if one of the locations is down or unreachable, + * the Aggregated List request will fail. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkservices.v1.TcpRoute|TcpRoute}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_services.list_tcp_routes.js + * region_tag:networkservices_v1_generated_NetworkServices_ListTcpRoutes_async + */ listTcpRoutesAsync( - request?: protos.google.cloud.networkservices.v1.IListTcpRoutesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkservices.v1.IListTcpRoutesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listTcpRoutes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listTcpRoutes iterate %j', request); return this.descriptors.page.listTcpRoutes.asyncIterate( this.innerApiCalls['listTcpRoutes'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists TlsRoute in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the TlsRoutes should be - * listed, specified in the format `projects/* /locations/global`. - * @param {number} request.pageSize - * Maximum number of TlsRoutes to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListTlsRoutesResponse` - * Indicates that this is a continuation of a prior `ListTlsRoutes` call, - * and that the system should return the next page of data. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If true, allow partial responses for multi-regional Aggregated - * List requests. Otherwise if one of the locations is down or unreachable, - * the Aggregated List request will fail. - * @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 Array of {@link protos.google.cloud.networkservices.v1.TlsRoute|TlsRoute}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listTlsRoutesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists TlsRoute in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the TlsRoutes should be + * listed, specified in the format `projects/* /locations/global`. + * @param {number} request.pageSize + * Maximum number of TlsRoutes to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListTlsRoutesResponse` + * Indicates that this is a continuation of a prior `ListTlsRoutes` call, + * and that the system should return the next page of data. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If true, allow partial responses for multi-regional Aggregated + * List requests. Otherwise if one of the locations is down or unreachable, + * the Aggregated List request will fail. + * @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 Array of {@link protos.google.cloud.networkservices.v1.TlsRoute|TlsRoute}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listTlsRoutesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listTlsRoutes( - request?: protos.google.cloud.networkservices.v1.IListTlsRoutesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.ITlsRoute[], - protos.google.cloud.networkservices.v1.IListTlsRoutesRequest|null, - protos.google.cloud.networkservices.v1.IListTlsRoutesResponse - ]>; + request?: protos.google.cloud.networkservices.v1.IListTlsRoutesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.ITlsRoute[], + protos.google.cloud.networkservices.v1.IListTlsRoutesRequest | null, + protos.google.cloud.networkservices.v1.IListTlsRoutesResponse, + ] + >; listTlsRoutes( - request: protos.google.cloud.networkservices.v1.IListTlsRoutesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListTlsRoutesRequest, - protos.google.cloud.networkservices.v1.IListTlsRoutesResponse|null|undefined, - protos.google.cloud.networkservices.v1.ITlsRoute>): void; + request: protos.google.cloud.networkservices.v1.IListTlsRoutesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListTlsRoutesRequest, + | protos.google.cloud.networkservices.v1.IListTlsRoutesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.ITlsRoute + >, + ): void; listTlsRoutes( - request: protos.google.cloud.networkservices.v1.IListTlsRoutesRequest, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListTlsRoutesRequest, - protos.google.cloud.networkservices.v1.IListTlsRoutesResponse|null|undefined, - protos.google.cloud.networkservices.v1.ITlsRoute>): void; + request: protos.google.cloud.networkservices.v1.IListTlsRoutesRequest, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListTlsRoutesRequest, + | protos.google.cloud.networkservices.v1.IListTlsRoutesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.ITlsRoute + >, + ): void; listTlsRoutes( - request?: protos.google.cloud.networkservices.v1.IListTlsRoutesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkservices.v1.IListTlsRoutesRequest, - protos.google.cloud.networkservices.v1.IListTlsRoutesResponse|null|undefined, - protos.google.cloud.networkservices.v1.ITlsRoute>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkservices.v1.IListTlsRoutesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkservices.v1.IListTlsRoutesRequest, - protos.google.cloud.networkservices.v1.IListTlsRoutesResponse|null|undefined, - protos.google.cloud.networkservices.v1.ITlsRoute>): - Promise<[ - protos.google.cloud.networkservices.v1.ITlsRoute[], - protos.google.cloud.networkservices.v1.IListTlsRoutesRequest|null, - protos.google.cloud.networkservices.v1.IListTlsRoutesResponse - ]>|void { + | protos.google.cloud.networkservices.v1.IListTlsRoutesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.ITlsRoute + >, + callback?: PaginationCallback< + protos.google.cloud.networkservices.v1.IListTlsRoutesRequest, + | protos.google.cloud.networkservices.v1.IListTlsRoutesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.ITlsRoute + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.ITlsRoute[], + protos.google.cloud.networkservices.v1.IListTlsRoutesRequest | null, + protos.google.cloud.networkservices.v1.IListTlsRoutesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListTlsRoutesRequest, - protos.google.cloud.networkservices.v1.IListTlsRoutesResponse|null|undefined, - protos.google.cloud.networkservices.v1.ITlsRoute>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkservices.v1.IListTlsRoutesRequest, + | protos.google.cloud.networkservices.v1.IListTlsRoutesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.ITlsRoute + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listTlsRoutes values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -7077,206 +10246,235 @@ export class NetworkServicesClient { this._log.info('listTlsRoutes request %j', request); return this.innerApiCalls .listTlsRoutes(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkservices.v1.ITlsRoute[], - protos.google.cloud.networkservices.v1.IListTlsRoutesRequest|null, - protos.google.cloud.networkservices.v1.IListTlsRoutesResponse - ]) => { - this._log.info('listTlsRoutes values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkservices.v1.ITlsRoute[], + protos.google.cloud.networkservices.v1.IListTlsRoutesRequest | null, + protos.google.cloud.networkservices.v1.IListTlsRoutesResponse, + ]) => { + this._log.info('listTlsRoutes values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listTlsRoutes`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the TlsRoutes should be - * listed, specified in the format `projects/* /locations/global`. - * @param {number} request.pageSize - * Maximum number of TlsRoutes to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListTlsRoutesResponse` - * Indicates that this is a continuation of a prior `ListTlsRoutes` call, - * and that the system should return the next page of data. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If true, allow partial responses for multi-regional Aggregated - * List requests. Otherwise if one of the locations is down or unreachable, - * the Aggregated List request will fail. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.TlsRoute|TlsRoute} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listTlsRoutesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listTlsRoutes`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the TlsRoutes should be + * listed, specified in the format `projects/* /locations/global`. + * @param {number} request.pageSize + * Maximum number of TlsRoutes to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListTlsRoutesResponse` + * Indicates that this is a continuation of a prior `ListTlsRoutes` call, + * and that the system should return the next page of data. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If true, allow partial responses for multi-regional Aggregated + * List requests. Otherwise if one of the locations is down or unreachable, + * the Aggregated List request will fail. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.TlsRoute|TlsRoute} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listTlsRoutesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listTlsRoutesStream( - request?: protos.google.cloud.networkservices.v1.IListTlsRoutesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkservices.v1.IListTlsRoutesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listTlsRoutes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listTlsRoutes stream %j', request); return this.descriptors.page.listTlsRoutes.createStream( this.innerApiCalls.listTlsRoutes as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listTlsRoutes`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the TlsRoutes should be - * listed, specified in the format `projects/* /locations/global`. - * @param {number} request.pageSize - * Maximum number of TlsRoutes to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListTlsRoutesResponse` - * Indicates that this is a continuation of a prior `ListTlsRoutes` call, - * and that the system should return the next page of data. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If true, allow partial responses for multi-regional Aggregated - * List requests. Otherwise if one of the locations is down or unreachable, - * the Aggregated List request will fail. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkservices.v1.TlsRoute|TlsRoute}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_services.list_tls_routes.js - * region_tag:networkservices_v1_generated_NetworkServices_ListTlsRoutes_async - */ + /** + * Equivalent to `listTlsRoutes`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the TlsRoutes should be + * listed, specified in the format `projects/* /locations/global`. + * @param {number} request.pageSize + * Maximum number of TlsRoutes to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListTlsRoutesResponse` + * Indicates that this is a continuation of a prior `ListTlsRoutes` call, + * and that the system should return the next page of data. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If true, allow partial responses for multi-regional Aggregated + * List requests. Otherwise if one of the locations is down or unreachable, + * the Aggregated List request will fail. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkservices.v1.TlsRoute|TlsRoute}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_services.list_tls_routes.js + * region_tag:networkservices_v1_generated_NetworkServices_ListTlsRoutes_async + */ listTlsRoutesAsync( - request?: protos.google.cloud.networkservices.v1.IListTlsRoutesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkservices.v1.IListTlsRoutesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listTlsRoutes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listTlsRoutes iterate %j', request); return this.descriptors.page.listTlsRoutes.asyncIterate( this.innerApiCalls['listTlsRoutes'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists ServiceBinding in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the ServiceBindings should be - * listed, specified in the format `projects/* /locations/*`. - * @param {number} request.pageSize - * Maximum number of ServiceBindings to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListServiceBindingsResponse` - * Indicates that this is a continuation of a prior `ListRouters` call, - * and that the system should return the next page of data. - * @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 Array of {@link protos.google.cloud.networkservices.v1.ServiceBinding|ServiceBinding}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listServiceBindingsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists ServiceBinding in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the ServiceBindings should be + * listed, specified in the format `projects/* /locations/*`. + * @param {number} request.pageSize + * Maximum number of ServiceBindings to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListServiceBindingsResponse` + * Indicates that this is a continuation of a prior `ListRouters` call, + * and that the system should return the next page of data. + * @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 Array of {@link protos.google.cloud.networkservices.v1.ServiceBinding|ServiceBinding}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listServiceBindingsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listServiceBindings( - request?: protos.google.cloud.networkservices.v1.IListServiceBindingsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.IServiceBinding[], - protos.google.cloud.networkservices.v1.IListServiceBindingsRequest|null, - protos.google.cloud.networkservices.v1.IListServiceBindingsResponse - ]>; + request?: protos.google.cloud.networkservices.v1.IListServiceBindingsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IServiceBinding[], + protos.google.cloud.networkservices.v1.IListServiceBindingsRequest | null, + protos.google.cloud.networkservices.v1.IListServiceBindingsResponse, + ] + >; listServiceBindings( - request: protos.google.cloud.networkservices.v1.IListServiceBindingsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListServiceBindingsRequest, - protos.google.cloud.networkservices.v1.IListServiceBindingsResponse|null|undefined, - protos.google.cloud.networkservices.v1.IServiceBinding>): void; + request: protos.google.cloud.networkservices.v1.IListServiceBindingsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListServiceBindingsRequest, + | protos.google.cloud.networkservices.v1.IListServiceBindingsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IServiceBinding + >, + ): void; listServiceBindings( - request: protos.google.cloud.networkservices.v1.IListServiceBindingsRequest, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListServiceBindingsRequest, - protos.google.cloud.networkservices.v1.IListServiceBindingsResponse|null|undefined, - protos.google.cloud.networkservices.v1.IServiceBinding>): void; + request: protos.google.cloud.networkservices.v1.IListServiceBindingsRequest, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListServiceBindingsRequest, + | protos.google.cloud.networkservices.v1.IListServiceBindingsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IServiceBinding + >, + ): void; listServiceBindings( - request?: protos.google.cloud.networkservices.v1.IListServiceBindingsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkservices.v1.IListServiceBindingsRequest, - protos.google.cloud.networkservices.v1.IListServiceBindingsResponse|null|undefined, - protos.google.cloud.networkservices.v1.IServiceBinding>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkservices.v1.IListServiceBindingsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkservices.v1.IListServiceBindingsRequest, - protos.google.cloud.networkservices.v1.IListServiceBindingsResponse|null|undefined, - protos.google.cloud.networkservices.v1.IServiceBinding>): - Promise<[ - protos.google.cloud.networkservices.v1.IServiceBinding[], - protos.google.cloud.networkservices.v1.IListServiceBindingsRequest|null, - protos.google.cloud.networkservices.v1.IListServiceBindingsResponse - ]>|void { + | protos.google.cloud.networkservices.v1.IListServiceBindingsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IServiceBinding + >, + callback?: PaginationCallback< + protos.google.cloud.networkservices.v1.IListServiceBindingsRequest, + | protos.google.cloud.networkservices.v1.IListServiceBindingsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IServiceBinding + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IServiceBinding[], + protos.google.cloud.networkservices.v1.IListServiceBindingsRequest | null, + protos.google.cloud.networkservices.v1.IListServiceBindingsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListServiceBindingsRequest, - protos.google.cloud.networkservices.v1.IListServiceBindingsResponse|null|undefined, - protos.google.cloud.networkservices.v1.IServiceBinding>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkservices.v1.IListServiceBindingsRequest, + | protos.google.cloud.networkservices.v1.IListServiceBindingsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IServiceBinding + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listServiceBindings values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -7285,202 +10483,231 @@ export class NetworkServicesClient { this._log.info('listServiceBindings request %j', request); return this.innerApiCalls .listServiceBindings(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkservices.v1.IServiceBinding[], - protos.google.cloud.networkservices.v1.IListServiceBindingsRequest|null, - protos.google.cloud.networkservices.v1.IListServiceBindingsResponse - ]) => { - this._log.info('listServiceBindings values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkservices.v1.IServiceBinding[], + protos.google.cloud.networkservices.v1.IListServiceBindingsRequest | null, + protos.google.cloud.networkservices.v1.IListServiceBindingsResponse, + ]) => { + this._log.info('listServiceBindings values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listServiceBindings`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the ServiceBindings should be - * listed, specified in the format `projects/* /locations/*`. - * @param {number} request.pageSize - * Maximum number of ServiceBindings to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListServiceBindingsResponse` - * Indicates that this is a continuation of a prior `ListRouters` call, - * and that the system should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.ServiceBinding|ServiceBinding} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listServiceBindingsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listServiceBindings`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the ServiceBindings should be + * listed, specified in the format `projects/* /locations/*`. + * @param {number} request.pageSize + * Maximum number of ServiceBindings to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListServiceBindingsResponse` + * Indicates that this is a continuation of a prior `ListRouters` call, + * and that the system should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.ServiceBinding|ServiceBinding} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listServiceBindingsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listServiceBindingsStream( - request?: protos.google.cloud.networkservices.v1.IListServiceBindingsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkservices.v1.IListServiceBindingsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listServiceBindings']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listServiceBindings stream %j', request); return this.descriptors.page.listServiceBindings.createStream( this.innerApiCalls.listServiceBindings as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listServiceBindings`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the ServiceBindings should be - * listed, specified in the format `projects/* /locations/*`. - * @param {number} request.pageSize - * Maximum number of ServiceBindings to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListServiceBindingsResponse` - * Indicates that this is a continuation of a prior `ListRouters` call, - * and that the system should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkservices.v1.ServiceBinding|ServiceBinding}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_services.list_service_bindings.js - * region_tag:networkservices_v1_generated_NetworkServices_ListServiceBindings_async - */ + /** + * Equivalent to `listServiceBindings`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the ServiceBindings should be + * listed, specified in the format `projects/* /locations/*`. + * @param {number} request.pageSize + * Maximum number of ServiceBindings to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListServiceBindingsResponse` + * Indicates that this is a continuation of a prior `ListRouters` call, + * and that the system should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkservices.v1.ServiceBinding|ServiceBinding}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_services.list_service_bindings.js + * region_tag:networkservices_v1_generated_NetworkServices_ListServiceBindings_async + */ listServiceBindingsAsync( - request?: protos.google.cloud.networkservices.v1.IListServiceBindingsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkservices.v1.IListServiceBindingsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listServiceBindings']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listServiceBindings iterate %j', request); return this.descriptors.page.listServiceBindings.asyncIterate( this.innerApiCalls['listServiceBindings'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists Meshes in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the Meshes should be - * listed, specified in the format `projects/* /locations/global`. - * @param {number} request.pageSize - * Maximum number of Meshes to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListMeshesResponse` - * Indicates that this is a continuation of a prior `ListMeshes` call, - * and that the system should return the next page of data. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If true, allow partial responses for multi-regional Aggregated - * List requests. Otherwise if one of the locations is down or unreachable, - * the Aggregated List request will fail. - * @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 Array of {@link protos.google.cloud.networkservices.v1.Mesh|Mesh}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listMeshesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists Meshes in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the Meshes should be + * listed, specified in the format `projects/* /locations/global`. + * @param {number} request.pageSize + * Maximum number of Meshes to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListMeshesResponse` + * Indicates that this is a continuation of a prior `ListMeshes` call, + * and that the system should return the next page of data. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If true, allow partial responses for multi-regional Aggregated + * List requests. Otherwise if one of the locations is down or unreachable, + * the Aggregated List request will fail. + * @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 Array of {@link protos.google.cloud.networkservices.v1.Mesh|Mesh}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listMeshesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMeshes( - request?: protos.google.cloud.networkservices.v1.IListMeshesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.IMesh[], - protos.google.cloud.networkservices.v1.IListMeshesRequest|null, - protos.google.cloud.networkservices.v1.IListMeshesResponse - ]>; + request?: protos.google.cloud.networkservices.v1.IListMeshesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IMesh[], + protos.google.cloud.networkservices.v1.IListMeshesRequest | null, + protos.google.cloud.networkservices.v1.IListMeshesResponse, + ] + >; listMeshes( - request: protos.google.cloud.networkservices.v1.IListMeshesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListMeshesRequest, - protos.google.cloud.networkservices.v1.IListMeshesResponse|null|undefined, - protos.google.cloud.networkservices.v1.IMesh>): void; + request: protos.google.cloud.networkservices.v1.IListMeshesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListMeshesRequest, + | protos.google.cloud.networkservices.v1.IListMeshesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IMesh + >, + ): void; listMeshes( - request: protos.google.cloud.networkservices.v1.IListMeshesRequest, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListMeshesRequest, - protos.google.cloud.networkservices.v1.IListMeshesResponse|null|undefined, - protos.google.cloud.networkservices.v1.IMesh>): void; + request: protos.google.cloud.networkservices.v1.IListMeshesRequest, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListMeshesRequest, + | protos.google.cloud.networkservices.v1.IListMeshesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IMesh + >, + ): void; listMeshes( - request?: protos.google.cloud.networkservices.v1.IListMeshesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkservices.v1.IListMeshesRequest, - protos.google.cloud.networkservices.v1.IListMeshesResponse|null|undefined, - protos.google.cloud.networkservices.v1.IMesh>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkservices.v1.IListMeshesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkservices.v1.IListMeshesRequest, - protos.google.cloud.networkservices.v1.IListMeshesResponse|null|undefined, - protos.google.cloud.networkservices.v1.IMesh>): - Promise<[ - protos.google.cloud.networkservices.v1.IMesh[], - protos.google.cloud.networkservices.v1.IListMeshesRequest|null, - protos.google.cloud.networkservices.v1.IListMeshesResponse - ]>|void { + | protos.google.cloud.networkservices.v1.IListMeshesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IMesh + >, + callback?: PaginationCallback< + protos.google.cloud.networkservices.v1.IListMeshesRequest, + | protos.google.cloud.networkservices.v1.IListMeshesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IMesh + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IMesh[], + protos.google.cloud.networkservices.v1.IListMeshesRequest | null, + protos.google.cloud.networkservices.v1.IListMeshesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListMeshesRequest, - protos.google.cloud.networkservices.v1.IListMeshesResponse|null|undefined, - protos.google.cloud.networkservices.v1.IMesh>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkservices.v1.IListMeshesRequest, + | protos.google.cloud.networkservices.v1.IListMeshesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IMesh + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listMeshes values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -7489,207 +10716,236 @@ export class NetworkServicesClient { this._log.info('listMeshes request %j', request); return this.innerApiCalls .listMeshes(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkservices.v1.IMesh[], - protos.google.cloud.networkservices.v1.IListMeshesRequest|null, - protos.google.cloud.networkservices.v1.IListMeshesResponse - ]) => { - this._log.info('listMeshes values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkservices.v1.IMesh[], + protos.google.cloud.networkservices.v1.IListMeshesRequest | null, + protos.google.cloud.networkservices.v1.IListMeshesResponse, + ]) => { + this._log.info('listMeshes values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listMeshes`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the Meshes should be - * listed, specified in the format `projects/* /locations/global`. - * @param {number} request.pageSize - * Maximum number of Meshes to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListMeshesResponse` - * Indicates that this is a continuation of a prior `ListMeshes` call, - * and that the system should return the next page of data. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If true, allow partial responses for multi-regional Aggregated - * List requests. Otherwise if one of the locations is down or unreachable, - * the Aggregated List request will fail. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.Mesh|Mesh} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listMeshesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listMeshes`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the Meshes should be + * listed, specified in the format `projects/* /locations/global`. + * @param {number} request.pageSize + * Maximum number of Meshes to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListMeshesResponse` + * Indicates that this is a continuation of a prior `ListMeshes` call, + * and that the system should return the next page of data. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If true, allow partial responses for multi-regional Aggregated + * List requests. Otherwise if one of the locations is down or unreachable, + * the Aggregated List request will fail. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.Mesh|Mesh} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listMeshesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMeshesStream( - request?: protos.google.cloud.networkservices.v1.IListMeshesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkservices.v1.IListMeshesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listMeshes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listMeshes stream %j', request); return this.descriptors.page.listMeshes.createStream( this.innerApiCalls.listMeshes as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listMeshes`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the Meshes should be - * listed, specified in the format `projects/* /locations/global`. - * @param {number} request.pageSize - * Maximum number of Meshes to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListMeshesResponse` - * Indicates that this is a continuation of a prior `ListMeshes` call, - * and that the system should return the next page of data. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If true, allow partial responses for multi-regional Aggregated - * List requests. Otherwise if one of the locations is down or unreachable, - * the Aggregated List request will fail. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkservices.v1.Mesh|Mesh}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_services.list_meshes.js - * region_tag:networkservices_v1_generated_NetworkServices_ListMeshes_async - */ + /** + * Equivalent to `listMeshes`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the Meshes should be + * listed, specified in the format `projects/* /locations/global`. + * @param {number} request.pageSize + * Maximum number of Meshes to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListMeshesResponse` + * Indicates that this is a continuation of a prior `ListMeshes` call, + * and that the system should return the next page of data. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If true, allow partial responses for multi-regional Aggregated + * List requests. Otherwise if one of the locations is down or unreachable, + * the Aggregated List request will fail. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkservices.v1.Mesh|Mesh}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_services.list_meshes.js + * region_tag:networkservices_v1_generated_NetworkServices_ListMeshes_async + */ listMeshesAsync( - request?: protos.google.cloud.networkservices.v1.IListMeshesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkservices.v1.IListMeshesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listMeshes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listMeshes iterate %j', request); return this.descriptors.page.listMeshes.asyncIterate( this.innerApiCalls['listMeshes'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists ServiceLbPolicies in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the ServiceLbPolicies should - * be listed, specified in the format - * `projects/{project}/locations/{location}`. - * @param {number} request.pageSize - * Maximum number of ServiceLbPolicies to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListServiceLbPoliciesResponse` - * Indicates that this is a continuation of a prior `ListRouters` call, - * and that the system should return the next page of data. - * @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 Array of {@link protos.google.cloud.networkservices.v1.ServiceLbPolicy|ServiceLbPolicy}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listServiceLbPoliciesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists ServiceLbPolicies in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the ServiceLbPolicies should + * be listed, specified in the format + * `projects/{project}/locations/{location}`. + * @param {number} request.pageSize + * Maximum number of ServiceLbPolicies to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListServiceLbPoliciesResponse` + * Indicates that this is a continuation of a prior `ListRouters` call, + * and that the system should return the next page of data. + * @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 Array of {@link protos.google.cloud.networkservices.v1.ServiceLbPolicy|ServiceLbPolicy}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listServiceLbPoliciesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listServiceLbPolicies( - request?: protos.google.cloud.networkservices.v1.IListServiceLbPoliciesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.IServiceLbPolicy[], - protos.google.cloud.networkservices.v1.IListServiceLbPoliciesRequest|null, - protos.google.cloud.networkservices.v1.IListServiceLbPoliciesResponse - ]>; + request?: protos.google.cloud.networkservices.v1.IListServiceLbPoliciesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IServiceLbPolicy[], + protos.google.cloud.networkservices.v1.IListServiceLbPoliciesRequest | null, + protos.google.cloud.networkservices.v1.IListServiceLbPoliciesResponse, + ] + >; listServiceLbPolicies( - request: protos.google.cloud.networkservices.v1.IListServiceLbPoliciesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListServiceLbPoliciesRequest, - protos.google.cloud.networkservices.v1.IListServiceLbPoliciesResponse|null|undefined, - protos.google.cloud.networkservices.v1.IServiceLbPolicy>): void; + request: protos.google.cloud.networkservices.v1.IListServiceLbPoliciesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListServiceLbPoliciesRequest, + | protos.google.cloud.networkservices.v1.IListServiceLbPoliciesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IServiceLbPolicy + >, + ): void; listServiceLbPolicies( - request: protos.google.cloud.networkservices.v1.IListServiceLbPoliciesRequest, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListServiceLbPoliciesRequest, - protos.google.cloud.networkservices.v1.IListServiceLbPoliciesResponse|null|undefined, - protos.google.cloud.networkservices.v1.IServiceLbPolicy>): void; + request: protos.google.cloud.networkservices.v1.IListServiceLbPoliciesRequest, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListServiceLbPoliciesRequest, + | protos.google.cloud.networkservices.v1.IListServiceLbPoliciesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IServiceLbPolicy + >, + ): void; listServiceLbPolicies( - request?: protos.google.cloud.networkservices.v1.IListServiceLbPoliciesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkservices.v1.IListServiceLbPoliciesRequest, - protos.google.cloud.networkservices.v1.IListServiceLbPoliciesResponse|null|undefined, - protos.google.cloud.networkservices.v1.IServiceLbPolicy>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkservices.v1.IListServiceLbPoliciesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkservices.v1.IListServiceLbPoliciesRequest, - protos.google.cloud.networkservices.v1.IListServiceLbPoliciesResponse|null|undefined, - protos.google.cloud.networkservices.v1.IServiceLbPolicy>): - Promise<[ - protos.google.cloud.networkservices.v1.IServiceLbPolicy[], - protos.google.cloud.networkservices.v1.IListServiceLbPoliciesRequest|null, - protos.google.cloud.networkservices.v1.IListServiceLbPoliciesResponse - ]>|void { + | protos.google.cloud.networkservices.v1.IListServiceLbPoliciesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IServiceLbPolicy + >, + callback?: PaginationCallback< + protos.google.cloud.networkservices.v1.IListServiceLbPoliciesRequest, + | protos.google.cloud.networkservices.v1.IListServiceLbPoliciesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IServiceLbPolicy + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IServiceLbPolicy[], + protos.google.cloud.networkservices.v1.IListServiceLbPoliciesRequest | null, + protos.google.cloud.networkservices.v1.IListServiceLbPoliciesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListServiceLbPoliciesRequest, - protos.google.cloud.networkservices.v1.IListServiceLbPoliciesResponse|null|undefined, - protos.google.cloud.networkservices.v1.IServiceLbPolicy>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkservices.v1.IListServiceLbPoliciesRequest, + | protos.google.cloud.networkservices.v1.IListServiceLbPoliciesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IServiceLbPolicy + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listServiceLbPolicies values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -7698,201 +10954,230 @@ export class NetworkServicesClient { this._log.info('listServiceLbPolicies request %j', request); return this.innerApiCalls .listServiceLbPolicies(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkservices.v1.IServiceLbPolicy[], - protos.google.cloud.networkservices.v1.IListServiceLbPoliciesRequest|null, - protos.google.cloud.networkservices.v1.IListServiceLbPoliciesResponse - ]) => { - this._log.info('listServiceLbPolicies values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkservices.v1.IServiceLbPolicy[], + protos.google.cloud.networkservices.v1.IListServiceLbPoliciesRequest | null, + protos.google.cloud.networkservices.v1.IListServiceLbPoliciesResponse, + ]) => { + this._log.info('listServiceLbPolicies values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listServiceLbPolicies`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the ServiceLbPolicies should - * be listed, specified in the format - * `projects/{project}/locations/{location}`. - * @param {number} request.pageSize - * Maximum number of ServiceLbPolicies to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListServiceLbPoliciesResponse` - * Indicates that this is a continuation of a prior `ListRouters` call, - * and that the system should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.ServiceLbPolicy|ServiceLbPolicy} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listServiceLbPoliciesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listServiceLbPolicies`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the ServiceLbPolicies should + * be listed, specified in the format + * `projects/{project}/locations/{location}`. + * @param {number} request.pageSize + * Maximum number of ServiceLbPolicies to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListServiceLbPoliciesResponse` + * Indicates that this is a continuation of a prior `ListRouters` call, + * and that the system should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.ServiceLbPolicy|ServiceLbPolicy} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listServiceLbPoliciesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listServiceLbPoliciesStream( - request?: protos.google.cloud.networkservices.v1.IListServiceLbPoliciesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkservices.v1.IListServiceLbPoliciesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listServiceLbPolicies']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listServiceLbPolicies stream %j', request); return this.descriptors.page.listServiceLbPolicies.createStream( this.innerApiCalls.listServiceLbPolicies as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listServiceLbPolicies`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the ServiceLbPolicies should - * be listed, specified in the format - * `projects/{project}/locations/{location}`. - * @param {number} request.pageSize - * Maximum number of ServiceLbPolicies to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListServiceLbPoliciesResponse` - * Indicates that this is a continuation of a prior `ListRouters` call, - * and that the system should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkservices.v1.ServiceLbPolicy|ServiceLbPolicy}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_services.list_service_lb_policies.js - * region_tag:networkservices_v1_generated_NetworkServices_ListServiceLbPolicies_async - */ + /** + * Equivalent to `listServiceLbPolicies`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the ServiceLbPolicies should + * be listed, specified in the format + * `projects/{project}/locations/{location}`. + * @param {number} request.pageSize + * Maximum number of ServiceLbPolicies to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListServiceLbPoliciesResponse` + * Indicates that this is a continuation of a prior `ListRouters` call, + * and that the system should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkservices.v1.ServiceLbPolicy|ServiceLbPolicy}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_services.list_service_lb_policies.js + * region_tag:networkservices_v1_generated_NetworkServices_ListServiceLbPolicies_async + */ listServiceLbPoliciesAsync( - request?: protos.google.cloud.networkservices.v1.IListServiceLbPoliciesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkservices.v1.IListServiceLbPoliciesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listServiceLbPolicies']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listServiceLbPolicies iterate %j', request); return this.descriptors.page.listServiceLbPolicies.asyncIterate( this.innerApiCalls['listServiceLbPolicies'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists RouteViews - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The Gateway to which a Route is associated. - * Formats: - * projects/{project}/locations/{location}/gateways/{gateway} - * @param {number} request.pageSize - * Maximum number of GatewayRouteViews to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListGatewayRouteViewsResponse` - * Indicates that this is a continuation of a prior `ListGatewayRouteViews` - * call, and that the system should return the next page of data. - * @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 Array of {@link protos.google.cloud.networkservices.v1.GatewayRouteView|GatewayRouteView}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listGatewayRouteViewsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists RouteViews + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The Gateway to which a Route is associated. + * Formats: + * projects/{project}/locations/{location}/gateways/{gateway} + * @param {number} request.pageSize + * Maximum number of GatewayRouteViews to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListGatewayRouteViewsResponse` + * Indicates that this is a continuation of a prior `ListGatewayRouteViews` + * call, and that the system should return the next page of data. + * @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 Array of {@link protos.google.cloud.networkservices.v1.GatewayRouteView|GatewayRouteView}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listGatewayRouteViewsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listGatewayRouteViews( - request?: protos.google.cloud.networkservices.v1.IListGatewayRouteViewsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.IGatewayRouteView[], - protos.google.cloud.networkservices.v1.IListGatewayRouteViewsRequest|null, - protos.google.cloud.networkservices.v1.IListGatewayRouteViewsResponse - ]>; + request?: protos.google.cloud.networkservices.v1.IListGatewayRouteViewsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IGatewayRouteView[], + protos.google.cloud.networkservices.v1.IListGatewayRouteViewsRequest | null, + protos.google.cloud.networkservices.v1.IListGatewayRouteViewsResponse, + ] + >; listGatewayRouteViews( - request: protos.google.cloud.networkservices.v1.IListGatewayRouteViewsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListGatewayRouteViewsRequest, - protos.google.cloud.networkservices.v1.IListGatewayRouteViewsResponse|null|undefined, - protos.google.cloud.networkservices.v1.IGatewayRouteView>): void; + request: protos.google.cloud.networkservices.v1.IListGatewayRouteViewsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListGatewayRouteViewsRequest, + | protos.google.cloud.networkservices.v1.IListGatewayRouteViewsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IGatewayRouteView + >, + ): void; listGatewayRouteViews( - request: protos.google.cloud.networkservices.v1.IListGatewayRouteViewsRequest, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListGatewayRouteViewsRequest, - protos.google.cloud.networkservices.v1.IListGatewayRouteViewsResponse|null|undefined, - protos.google.cloud.networkservices.v1.IGatewayRouteView>): void; + request: protos.google.cloud.networkservices.v1.IListGatewayRouteViewsRequest, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListGatewayRouteViewsRequest, + | protos.google.cloud.networkservices.v1.IListGatewayRouteViewsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IGatewayRouteView + >, + ): void; listGatewayRouteViews( - request?: protos.google.cloud.networkservices.v1.IListGatewayRouteViewsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkservices.v1.IListGatewayRouteViewsRequest, - protos.google.cloud.networkservices.v1.IListGatewayRouteViewsResponse|null|undefined, - protos.google.cloud.networkservices.v1.IGatewayRouteView>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkservices.v1.IListGatewayRouteViewsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkservices.v1.IListGatewayRouteViewsRequest, - protos.google.cloud.networkservices.v1.IListGatewayRouteViewsResponse|null|undefined, - protos.google.cloud.networkservices.v1.IGatewayRouteView>): - Promise<[ - protos.google.cloud.networkservices.v1.IGatewayRouteView[], - protos.google.cloud.networkservices.v1.IListGatewayRouteViewsRequest|null, - protos.google.cloud.networkservices.v1.IListGatewayRouteViewsResponse - ]>|void { + | protos.google.cloud.networkservices.v1.IListGatewayRouteViewsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IGatewayRouteView + >, + callback?: PaginationCallback< + protos.google.cloud.networkservices.v1.IListGatewayRouteViewsRequest, + | protos.google.cloud.networkservices.v1.IListGatewayRouteViewsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IGatewayRouteView + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IGatewayRouteView[], + protos.google.cloud.networkservices.v1.IListGatewayRouteViewsRequest | null, + protos.google.cloud.networkservices.v1.IListGatewayRouteViewsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListGatewayRouteViewsRequest, - protos.google.cloud.networkservices.v1.IListGatewayRouteViewsResponse|null|undefined, - protos.google.cloud.networkservices.v1.IGatewayRouteView>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkservices.v1.IListGatewayRouteViewsRequest, + | protos.google.cloud.networkservices.v1.IListGatewayRouteViewsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IGatewayRouteView + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listGatewayRouteViews values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -7901,201 +11186,230 @@ export class NetworkServicesClient { this._log.info('listGatewayRouteViews request %j', request); return this.innerApiCalls .listGatewayRouteViews(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkservices.v1.IGatewayRouteView[], - protos.google.cloud.networkservices.v1.IListGatewayRouteViewsRequest|null, - protos.google.cloud.networkservices.v1.IListGatewayRouteViewsResponse - ]) => { - this._log.info('listGatewayRouteViews values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkservices.v1.IGatewayRouteView[], + protos.google.cloud.networkservices.v1.IListGatewayRouteViewsRequest | null, + protos.google.cloud.networkservices.v1.IListGatewayRouteViewsResponse, + ]) => { + this._log.info('listGatewayRouteViews values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listGatewayRouteViews`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The Gateway to which a Route is associated. - * Formats: - * projects/{project}/locations/{location}/gateways/{gateway} - * @param {number} request.pageSize - * Maximum number of GatewayRouteViews to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListGatewayRouteViewsResponse` - * Indicates that this is a continuation of a prior `ListGatewayRouteViews` - * call, and that the system should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.GatewayRouteView|GatewayRouteView} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listGatewayRouteViewsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listGatewayRouteViews`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The Gateway to which a Route is associated. + * Formats: + * projects/{project}/locations/{location}/gateways/{gateway} + * @param {number} request.pageSize + * Maximum number of GatewayRouteViews to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListGatewayRouteViewsResponse` + * Indicates that this is a continuation of a prior `ListGatewayRouteViews` + * call, and that the system should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.GatewayRouteView|GatewayRouteView} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listGatewayRouteViewsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listGatewayRouteViewsStream( - request?: protos.google.cloud.networkservices.v1.IListGatewayRouteViewsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkservices.v1.IListGatewayRouteViewsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listGatewayRouteViews']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listGatewayRouteViews stream %j', request); return this.descriptors.page.listGatewayRouteViews.createStream( this.innerApiCalls.listGatewayRouteViews as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listGatewayRouteViews`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The Gateway to which a Route is associated. - * Formats: - * projects/{project}/locations/{location}/gateways/{gateway} - * @param {number} request.pageSize - * Maximum number of GatewayRouteViews to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListGatewayRouteViewsResponse` - * Indicates that this is a continuation of a prior `ListGatewayRouteViews` - * call, and that the system should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkservices.v1.GatewayRouteView|GatewayRouteView}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_services.list_gateway_route_views.js - * region_tag:networkservices_v1_generated_NetworkServices_ListGatewayRouteViews_async - */ + /** + * Equivalent to `listGatewayRouteViews`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The Gateway to which a Route is associated. + * Formats: + * projects/{project}/locations/{location}/gateways/{gateway} + * @param {number} request.pageSize + * Maximum number of GatewayRouteViews to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListGatewayRouteViewsResponse` + * Indicates that this is a continuation of a prior `ListGatewayRouteViews` + * call, and that the system should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkservices.v1.GatewayRouteView|GatewayRouteView}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_services.list_gateway_route_views.js + * region_tag:networkservices_v1_generated_NetworkServices_ListGatewayRouteViews_async + */ listGatewayRouteViewsAsync( - request?: protos.google.cloud.networkservices.v1.IListGatewayRouteViewsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkservices.v1.IListGatewayRouteViewsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listGatewayRouteViews']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listGatewayRouteViews iterate %j', request); return this.descriptors.page.listGatewayRouteViews.asyncIterate( this.innerApiCalls['listGatewayRouteViews'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists RouteViews - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The Mesh to which a Route is associated. - * Format: - * projects/{project}/locations/{location}/meshes/{mesh} - * @param {number} request.pageSize - * Maximum number of MeshRouteViews to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListMeshRouteViewsResponse` - * Indicates that this is a continuation of a prior `ListMeshRouteViews` call, - * and that the system should return the next page of data. - * @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 Array of {@link protos.google.cloud.networkservices.v1.MeshRouteView|MeshRouteView}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listMeshRouteViewsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists RouteViews + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The Mesh to which a Route is associated. + * Format: + * projects/{project}/locations/{location}/meshes/{mesh} + * @param {number} request.pageSize + * Maximum number of MeshRouteViews to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListMeshRouteViewsResponse` + * Indicates that this is a continuation of a prior `ListMeshRouteViews` call, + * and that the system should return the next page of data. + * @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 Array of {@link protos.google.cloud.networkservices.v1.MeshRouteView|MeshRouteView}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listMeshRouteViewsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMeshRouteViews( - request?: protos.google.cloud.networkservices.v1.IListMeshRouteViewsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1.IMeshRouteView[], - protos.google.cloud.networkservices.v1.IListMeshRouteViewsRequest|null, - protos.google.cloud.networkservices.v1.IListMeshRouteViewsResponse - ]>; + request?: protos.google.cloud.networkservices.v1.IListMeshRouteViewsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IMeshRouteView[], + protos.google.cloud.networkservices.v1.IListMeshRouteViewsRequest | null, + protos.google.cloud.networkservices.v1.IListMeshRouteViewsResponse, + ] + >; listMeshRouteViews( - request: protos.google.cloud.networkservices.v1.IListMeshRouteViewsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListMeshRouteViewsRequest, - protos.google.cloud.networkservices.v1.IListMeshRouteViewsResponse|null|undefined, - protos.google.cloud.networkservices.v1.IMeshRouteView>): void; + request: protos.google.cloud.networkservices.v1.IListMeshRouteViewsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListMeshRouteViewsRequest, + | protos.google.cloud.networkservices.v1.IListMeshRouteViewsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IMeshRouteView + >, + ): void; listMeshRouteViews( - request: protos.google.cloud.networkservices.v1.IListMeshRouteViewsRequest, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListMeshRouteViewsRequest, - protos.google.cloud.networkservices.v1.IListMeshRouteViewsResponse|null|undefined, - protos.google.cloud.networkservices.v1.IMeshRouteView>): void; + request: protos.google.cloud.networkservices.v1.IListMeshRouteViewsRequest, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1.IListMeshRouteViewsRequest, + | protos.google.cloud.networkservices.v1.IListMeshRouteViewsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IMeshRouteView + >, + ): void; listMeshRouteViews( - request?: protos.google.cloud.networkservices.v1.IListMeshRouteViewsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkservices.v1.IListMeshRouteViewsRequest, - protos.google.cloud.networkservices.v1.IListMeshRouteViewsResponse|null|undefined, - protos.google.cloud.networkservices.v1.IMeshRouteView>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkservices.v1.IListMeshRouteViewsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkservices.v1.IListMeshRouteViewsRequest, - protos.google.cloud.networkservices.v1.IListMeshRouteViewsResponse|null|undefined, - protos.google.cloud.networkservices.v1.IMeshRouteView>): - Promise<[ - protos.google.cloud.networkservices.v1.IMeshRouteView[], - protos.google.cloud.networkservices.v1.IListMeshRouteViewsRequest|null, - protos.google.cloud.networkservices.v1.IListMeshRouteViewsResponse - ]>|void { + | protos.google.cloud.networkservices.v1.IListMeshRouteViewsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IMeshRouteView + >, + callback?: PaginationCallback< + protos.google.cloud.networkservices.v1.IListMeshRouteViewsRequest, + | protos.google.cloud.networkservices.v1.IListMeshRouteViewsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IMeshRouteView + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1.IMeshRouteView[], + protos.google.cloud.networkservices.v1.IListMeshRouteViewsRequest | null, + protos.google.cloud.networkservices.v1.IListMeshRouteViewsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkservices.v1.IListMeshRouteViewsRequest, - protos.google.cloud.networkservices.v1.IListMeshRouteViewsResponse|null|undefined, - protos.google.cloud.networkservices.v1.IMeshRouteView>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkservices.v1.IListMeshRouteViewsRequest, + | protos.google.cloud.networkservices.v1.IListMeshRouteViewsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1.IMeshRouteView + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listMeshRouteViews values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -8104,141 +11418,145 @@ export class NetworkServicesClient { this._log.info('listMeshRouteViews request %j', request); return this.innerApiCalls .listMeshRouteViews(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkservices.v1.IMeshRouteView[], - protos.google.cloud.networkservices.v1.IListMeshRouteViewsRequest|null, - protos.google.cloud.networkservices.v1.IListMeshRouteViewsResponse - ]) => { - this._log.info('listMeshRouteViews values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkservices.v1.IMeshRouteView[], + protos.google.cloud.networkservices.v1.IListMeshRouteViewsRequest | null, + protos.google.cloud.networkservices.v1.IListMeshRouteViewsResponse, + ]) => { + this._log.info('listMeshRouteViews values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listMeshRouteViews`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The Mesh to which a Route is associated. - * Format: - * projects/{project}/locations/{location}/meshes/{mesh} - * @param {number} request.pageSize - * Maximum number of MeshRouteViews to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListMeshRouteViewsResponse` - * Indicates that this is a continuation of a prior `ListMeshRouteViews` call, - * and that the system should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.MeshRouteView|MeshRouteView} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listMeshRouteViewsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listMeshRouteViews`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The Mesh to which a Route is associated. + * Format: + * projects/{project}/locations/{location}/meshes/{mesh} + * @param {number} request.pageSize + * Maximum number of MeshRouteViews to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListMeshRouteViewsResponse` + * Indicates that this is a continuation of a prior `ListMeshRouteViews` call, + * and that the system should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1.MeshRouteView|MeshRouteView} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listMeshRouteViewsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMeshRouteViewsStream( - request?: protos.google.cloud.networkservices.v1.IListMeshRouteViewsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkservices.v1.IListMeshRouteViewsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listMeshRouteViews']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listMeshRouteViews stream %j', request); return this.descriptors.page.listMeshRouteViews.createStream( this.innerApiCalls.listMeshRouteViews as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listMeshRouteViews`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The Mesh to which a Route is associated. - * Format: - * projects/{project}/locations/{location}/meshes/{mesh} - * @param {number} request.pageSize - * Maximum number of MeshRouteViews to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListMeshRouteViewsResponse` - * Indicates that this is a continuation of a prior `ListMeshRouteViews` call, - * and that the system should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkservices.v1.MeshRouteView|MeshRouteView}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/network_services.list_mesh_route_views.js - * region_tag:networkservices_v1_generated_NetworkServices_ListMeshRouteViews_async - */ + /** + * Equivalent to `listMeshRouteViews`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The Mesh to which a Route is associated. + * Format: + * projects/{project}/locations/{location}/meshes/{mesh} + * @param {number} request.pageSize + * Maximum number of MeshRouteViews to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListMeshRouteViewsResponse` + * Indicates that this is a continuation of a prior `ListMeshRouteViews` call, + * and that the system should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkservices.v1.MeshRouteView|MeshRouteView}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/network_services.list_mesh_route_views.js + * region_tag:networkservices_v1_generated_NetworkServices_ListMeshRouteViews_async + */ listMeshRouteViewsAsync( - request?: protos.google.cloud.networkservices.v1.IListMeshRouteViewsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkservices.v1.IListMeshRouteViewsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listMeshRouteViews']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listMeshRouteViews iterate %j', request); return this.descriptors.page.listMeshRouteViews.asyncIterate( this.innerApiCalls['listMeshRouteViews'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -8252,40 +11570,40 @@ export class NetworkServicesClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -8299,41 +11617,41 @@ export class NetworkServicesClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -8347,12 +11665,12 @@ export class NetworkServicesClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -8387,12 +11705,11 @@ export class NetworkServicesClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -8425,12 +11742,12 @@ export class NetworkServicesClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -8473,22 +11790,22 @@ export class NetworkServicesClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -8523,15 +11840,15 @@ export class NetworkServicesClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - 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 ?? '', - }); + 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 ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -8565,7 +11882,7 @@ export class NetworkServicesClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -8578,25 +11895,24 @@ export class NetworkServicesClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -8635,22 +11951,22 @@ export class NetworkServicesClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -8666,7 +11982,11 @@ export class NetworkServicesClient { * @param {string} authz_extension * @returns {string} Resource name string. */ - authzExtensionPath(project:string,location:string,authzExtension:string) { + authzExtensionPath( + project: string, + location: string, + authzExtension: string, + ) { return this.pathTemplates.authzExtensionPathTemplate.render({ project: project, location: location, @@ -8682,7 +12002,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the project. */ matchProjectFromAuthzExtensionName(authzExtensionName: string) { - return this.pathTemplates.authzExtensionPathTemplate.match(authzExtensionName).project; + return this.pathTemplates.authzExtensionPathTemplate.match( + authzExtensionName, + ).project; } /** @@ -8693,7 +12015,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the location. */ matchLocationFromAuthzExtensionName(authzExtensionName: string) { - return this.pathTemplates.authzExtensionPathTemplate.match(authzExtensionName).location; + return this.pathTemplates.authzExtensionPathTemplate.match( + authzExtensionName, + ).location; } /** @@ -8704,7 +12028,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the authz_extension. */ matchAuthzExtensionFromAuthzExtensionName(authzExtensionName: string) { - return this.pathTemplates.authzExtensionPathTemplate.match(authzExtensionName).authz_extension; + return this.pathTemplates.authzExtensionPathTemplate.match( + authzExtensionName, + ).authz_extension; } /** @@ -8715,7 +12041,11 @@ export class NetworkServicesClient { * @param {string} endpoint_policy * @returns {string} Resource name string. */ - endpointPolicyPath(project:string,location:string,endpointPolicy:string) { + endpointPolicyPath( + project: string, + location: string, + endpointPolicy: string, + ) { return this.pathTemplates.endpointPolicyPathTemplate.render({ project: project, location: location, @@ -8731,7 +12061,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the project. */ matchProjectFromEndpointPolicyName(endpointPolicyName: string) { - return this.pathTemplates.endpointPolicyPathTemplate.match(endpointPolicyName).project; + return this.pathTemplates.endpointPolicyPathTemplate.match( + endpointPolicyName, + ).project; } /** @@ -8742,7 +12074,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the location. */ matchLocationFromEndpointPolicyName(endpointPolicyName: string) { - return this.pathTemplates.endpointPolicyPathTemplate.match(endpointPolicyName).location; + return this.pathTemplates.endpointPolicyPathTemplate.match( + endpointPolicyName, + ).location; } /** @@ -8753,7 +12087,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the endpoint_policy. */ matchEndpointPolicyFromEndpointPolicyName(endpointPolicyName: string) { - return this.pathTemplates.endpointPolicyPathTemplate.match(endpointPolicyName).endpoint_policy; + return this.pathTemplates.endpointPolicyPathTemplate.match( + endpointPolicyName, + ).endpoint_policy; } /** @@ -8764,7 +12100,7 @@ export class NetworkServicesClient { * @param {string} gateway * @returns {string} Resource name string. */ - gatewayPath(project:string,location:string,gateway:string) { + gatewayPath(project: string, location: string, gateway: string) { return this.pathTemplates.gatewayPathTemplate.render({ project: project, location: location, @@ -8814,7 +12150,12 @@ export class NetworkServicesClient { * @param {string} route_view * @returns {string} Resource name string. */ - gatewayRouteViewPath(project:string,location:string,gateway:string,routeView:string) { + gatewayRouteViewPath( + project: string, + location: string, + gateway: string, + routeView: string, + ) { return this.pathTemplates.gatewayRouteViewPathTemplate.render({ project: project, location: location, @@ -8831,7 +12172,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the project. */ matchProjectFromGatewayRouteViewName(gatewayRouteViewName: string) { - return this.pathTemplates.gatewayRouteViewPathTemplate.match(gatewayRouteViewName).project; + return this.pathTemplates.gatewayRouteViewPathTemplate.match( + gatewayRouteViewName, + ).project; } /** @@ -8842,7 +12185,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the location. */ matchLocationFromGatewayRouteViewName(gatewayRouteViewName: string) { - return this.pathTemplates.gatewayRouteViewPathTemplate.match(gatewayRouteViewName).location; + return this.pathTemplates.gatewayRouteViewPathTemplate.match( + gatewayRouteViewName, + ).location; } /** @@ -8853,7 +12198,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the gateway. */ matchGatewayFromGatewayRouteViewName(gatewayRouteViewName: string) { - return this.pathTemplates.gatewayRouteViewPathTemplate.match(gatewayRouteViewName).gateway; + return this.pathTemplates.gatewayRouteViewPathTemplate.match( + gatewayRouteViewName, + ).gateway; } /** @@ -8864,7 +12211,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the route_view. */ matchRouteViewFromGatewayRouteViewName(gatewayRouteViewName: string) { - return this.pathTemplates.gatewayRouteViewPathTemplate.match(gatewayRouteViewName).route_view; + return this.pathTemplates.gatewayRouteViewPathTemplate.match( + gatewayRouteViewName, + ).route_view; } /** @@ -8875,7 +12224,7 @@ export class NetworkServicesClient { * @param {string} grpc_route * @returns {string} Resource name string. */ - grpcRoutePath(project:string,location:string,grpcRoute:string) { + grpcRoutePath(project: string, location: string, grpcRoute: string) { return this.pathTemplates.grpcRoutePathTemplate.render({ project: project, location: location, @@ -8891,7 +12240,8 @@ export class NetworkServicesClient { * @returns {string} A string representing the project. */ matchProjectFromGrpcRouteName(grpcRouteName: string) { - return this.pathTemplates.grpcRoutePathTemplate.match(grpcRouteName).project; + return this.pathTemplates.grpcRoutePathTemplate.match(grpcRouteName) + .project; } /** @@ -8902,7 +12252,8 @@ export class NetworkServicesClient { * @returns {string} A string representing the location. */ matchLocationFromGrpcRouteName(grpcRouteName: string) { - return this.pathTemplates.grpcRoutePathTemplate.match(grpcRouteName).location; + return this.pathTemplates.grpcRoutePathTemplate.match(grpcRouteName) + .location; } /** @@ -8913,7 +12264,8 @@ export class NetworkServicesClient { * @returns {string} A string representing the grpc_route. */ matchGrpcRouteFromGrpcRouteName(grpcRouteName: string) { - return this.pathTemplates.grpcRoutePathTemplate.match(grpcRouteName).grpc_route; + return this.pathTemplates.grpcRoutePathTemplate.match(grpcRouteName) + .grpc_route; } /** @@ -8924,7 +12276,7 @@ export class NetworkServicesClient { * @param {string} http_route * @returns {string} Resource name string. */ - httpRoutePath(project:string,location:string,httpRoute:string) { + httpRoutePath(project: string, location: string, httpRoute: string) { return this.pathTemplates.httpRoutePathTemplate.render({ project: project, location: location, @@ -8940,7 +12292,8 @@ export class NetworkServicesClient { * @returns {string} A string representing the project. */ matchProjectFromHttpRouteName(httpRouteName: string) { - return this.pathTemplates.httpRoutePathTemplate.match(httpRouteName).project; + return this.pathTemplates.httpRoutePathTemplate.match(httpRouteName) + .project; } /** @@ -8951,7 +12304,8 @@ export class NetworkServicesClient { * @returns {string} A string representing the location. */ matchLocationFromHttpRouteName(httpRouteName: string) { - return this.pathTemplates.httpRoutePathTemplate.match(httpRouteName).location; + return this.pathTemplates.httpRoutePathTemplate.match(httpRouteName) + .location; } /** @@ -8962,7 +12316,8 @@ export class NetworkServicesClient { * @returns {string} A string representing the http_route. */ matchHttpRouteFromHttpRouteName(httpRouteName: string) { - return this.pathTemplates.httpRoutePathTemplate.match(httpRouteName).http_route; + return this.pathTemplates.httpRoutePathTemplate.match(httpRouteName) + .http_route; } /** @@ -8973,7 +12328,11 @@ export class NetworkServicesClient { * @param {string} lb_edge_extension * @returns {string} Resource name string. */ - lbEdgeExtensionPath(project:string,location:string,lbEdgeExtension:string) { + lbEdgeExtensionPath( + project: string, + location: string, + lbEdgeExtension: string, + ) { return this.pathTemplates.lbEdgeExtensionPathTemplate.render({ project: project, location: location, @@ -8989,7 +12348,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the project. */ matchProjectFromLbEdgeExtensionName(lbEdgeExtensionName: string) { - return this.pathTemplates.lbEdgeExtensionPathTemplate.match(lbEdgeExtensionName).project; + return this.pathTemplates.lbEdgeExtensionPathTemplate.match( + lbEdgeExtensionName, + ).project; } /** @@ -9000,7 +12361,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the location. */ matchLocationFromLbEdgeExtensionName(lbEdgeExtensionName: string) { - return this.pathTemplates.lbEdgeExtensionPathTemplate.match(lbEdgeExtensionName).location; + return this.pathTemplates.lbEdgeExtensionPathTemplate.match( + lbEdgeExtensionName, + ).location; } /** @@ -9011,7 +12374,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the lb_edge_extension. */ matchLbEdgeExtensionFromLbEdgeExtensionName(lbEdgeExtensionName: string) { - return this.pathTemplates.lbEdgeExtensionPathTemplate.match(lbEdgeExtensionName).lb_edge_extension; + return this.pathTemplates.lbEdgeExtensionPathTemplate.match( + lbEdgeExtensionName, + ).lb_edge_extension; } /** @@ -9022,7 +12387,11 @@ export class NetworkServicesClient { * @param {string} lb_route_extension * @returns {string} Resource name string. */ - lbRouteExtensionPath(project:string,location:string,lbRouteExtension:string) { + lbRouteExtensionPath( + project: string, + location: string, + lbRouteExtension: string, + ) { return this.pathTemplates.lbRouteExtensionPathTemplate.render({ project: project, location: location, @@ -9038,7 +12407,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the project. */ matchProjectFromLbRouteExtensionName(lbRouteExtensionName: string) { - return this.pathTemplates.lbRouteExtensionPathTemplate.match(lbRouteExtensionName).project; + return this.pathTemplates.lbRouteExtensionPathTemplate.match( + lbRouteExtensionName, + ).project; } /** @@ -9049,7 +12420,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the location. */ matchLocationFromLbRouteExtensionName(lbRouteExtensionName: string) { - return this.pathTemplates.lbRouteExtensionPathTemplate.match(lbRouteExtensionName).location; + return this.pathTemplates.lbRouteExtensionPathTemplate.match( + lbRouteExtensionName, + ).location; } /** @@ -9060,7 +12433,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the lb_route_extension. */ matchLbRouteExtensionFromLbRouteExtensionName(lbRouteExtensionName: string) { - return this.pathTemplates.lbRouteExtensionPathTemplate.match(lbRouteExtensionName).lb_route_extension; + return this.pathTemplates.lbRouteExtensionPathTemplate.match( + lbRouteExtensionName, + ).lb_route_extension; } /** @@ -9071,7 +12446,11 @@ export class NetworkServicesClient { * @param {string} lb_traffic_extension * @returns {string} Resource name string. */ - lbTrafficExtensionPath(project:string,location:string,lbTrafficExtension:string) { + lbTrafficExtensionPath( + project: string, + location: string, + lbTrafficExtension: string, + ) { return this.pathTemplates.lbTrafficExtensionPathTemplate.render({ project: project, location: location, @@ -9087,7 +12466,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the project. */ matchProjectFromLbTrafficExtensionName(lbTrafficExtensionName: string) { - return this.pathTemplates.lbTrafficExtensionPathTemplate.match(lbTrafficExtensionName).project; + return this.pathTemplates.lbTrafficExtensionPathTemplate.match( + lbTrafficExtensionName, + ).project; } /** @@ -9098,7 +12479,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the location. */ matchLocationFromLbTrafficExtensionName(lbTrafficExtensionName: string) { - return this.pathTemplates.lbTrafficExtensionPathTemplate.match(lbTrafficExtensionName).location; + return this.pathTemplates.lbTrafficExtensionPathTemplate.match( + lbTrafficExtensionName, + ).location; } /** @@ -9108,8 +12491,12 @@ export class NetworkServicesClient { * A fully-qualified path representing LbTrafficExtension resource. * @returns {string} A string representing the lb_traffic_extension. */ - matchLbTrafficExtensionFromLbTrafficExtensionName(lbTrafficExtensionName: string) { - return this.pathTemplates.lbTrafficExtensionPathTemplate.match(lbTrafficExtensionName).lb_traffic_extension; + matchLbTrafficExtensionFromLbTrafficExtensionName( + lbTrafficExtensionName: string, + ) { + return this.pathTemplates.lbTrafficExtensionPathTemplate.match( + lbTrafficExtensionName, + ).lb_traffic_extension; } /** @@ -9120,7 +12507,7 @@ export class NetworkServicesClient { * @param {string} mesh * @returns {string} Resource name string. */ - meshPath(project:string,location:string,mesh:string) { + meshPath(project: string, location: string, mesh: string) { return this.pathTemplates.meshPathTemplate.render({ project: project, location: location, @@ -9170,7 +12557,12 @@ export class NetworkServicesClient { * @param {string} route_view * @returns {string} Resource name string. */ - meshRouteViewPath(project:string,location:string,mesh:string,routeView:string) { + meshRouteViewPath( + project: string, + location: string, + mesh: string, + routeView: string, + ) { return this.pathTemplates.meshRouteViewPathTemplate.render({ project: project, location: location, @@ -9187,7 +12579,8 @@ export class NetworkServicesClient { * @returns {string} A string representing the project. */ matchProjectFromMeshRouteViewName(meshRouteViewName: string) { - return this.pathTemplates.meshRouteViewPathTemplate.match(meshRouteViewName).project; + return this.pathTemplates.meshRouteViewPathTemplate.match(meshRouteViewName) + .project; } /** @@ -9198,7 +12591,8 @@ export class NetworkServicesClient { * @returns {string} A string representing the location. */ matchLocationFromMeshRouteViewName(meshRouteViewName: string) { - return this.pathTemplates.meshRouteViewPathTemplate.match(meshRouteViewName).location; + return this.pathTemplates.meshRouteViewPathTemplate.match(meshRouteViewName) + .location; } /** @@ -9209,7 +12603,8 @@ export class NetworkServicesClient { * @returns {string} A string representing the mesh. */ matchMeshFromMeshRouteViewName(meshRouteViewName: string) { - return this.pathTemplates.meshRouteViewPathTemplate.match(meshRouteViewName).mesh; + return this.pathTemplates.meshRouteViewPathTemplate.match(meshRouteViewName) + .mesh; } /** @@ -9220,7 +12615,8 @@ export class NetworkServicesClient { * @returns {string} A string representing the route_view. */ matchRouteViewFromMeshRouteViewName(meshRouteViewName: string) { - return this.pathTemplates.meshRouteViewPathTemplate.match(meshRouteViewName).route_view; + return this.pathTemplates.meshRouteViewPathTemplate.match(meshRouteViewName) + .route_view; } /** @@ -9231,7 +12627,11 @@ export class NetworkServicesClient { * @param {string} service_binding * @returns {string} Resource name string. */ - serviceBindingPath(project:string,location:string,serviceBinding:string) { + serviceBindingPath( + project: string, + location: string, + serviceBinding: string, + ) { return this.pathTemplates.serviceBindingPathTemplate.render({ project: project, location: location, @@ -9247,7 +12647,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the project. */ matchProjectFromServiceBindingName(serviceBindingName: string) { - return this.pathTemplates.serviceBindingPathTemplate.match(serviceBindingName).project; + return this.pathTemplates.serviceBindingPathTemplate.match( + serviceBindingName, + ).project; } /** @@ -9258,7 +12660,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the location. */ matchLocationFromServiceBindingName(serviceBindingName: string) { - return this.pathTemplates.serviceBindingPathTemplate.match(serviceBindingName).location; + return this.pathTemplates.serviceBindingPathTemplate.match( + serviceBindingName, + ).location; } /** @@ -9269,7 +12673,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the service_binding. */ matchServiceBindingFromServiceBindingName(serviceBindingName: string) { - return this.pathTemplates.serviceBindingPathTemplate.match(serviceBindingName).service_binding; + return this.pathTemplates.serviceBindingPathTemplate.match( + serviceBindingName, + ).service_binding; } /** @@ -9280,7 +12686,11 @@ export class NetworkServicesClient { * @param {string} service_lb_policy * @returns {string} Resource name string. */ - serviceLbPolicyPath(project:string,location:string,serviceLbPolicy:string) { + serviceLbPolicyPath( + project: string, + location: string, + serviceLbPolicy: string, + ) { return this.pathTemplates.serviceLbPolicyPathTemplate.render({ project: project, location: location, @@ -9296,7 +12706,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the project. */ matchProjectFromServiceLbPolicyName(serviceLbPolicyName: string) { - return this.pathTemplates.serviceLbPolicyPathTemplate.match(serviceLbPolicyName).project; + return this.pathTemplates.serviceLbPolicyPathTemplate.match( + serviceLbPolicyName, + ).project; } /** @@ -9307,7 +12719,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the location. */ matchLocationFromServiceLbPolicyName(serviceLbPolicyName: string) { - return this.pathTemplates.serviceLbPolicyPathTemplate.match(serviceLbPolicyName).location; + return this.pathTemplates.serviceLbPolicyPathTemplate.match( + serviceLbPolicyName, + ).location; } /** @@ -9318,7 +12732,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the service_lb_policy. */ matchServiceLbPolicyFromServiceLbPolicyName(serviceLbPolicyName: string) { - return this.pathTemplates.serviceLbPolicyPathTemplate.match(serviceLbPolicyName).service_lb_policy; + return this.pathTemplates.serviceLbPolicyPathTemplate.match( + serviceLbPolicyName, + ).service_lb_policy; } /** @@ -9329,7 +12745,7 @@ export class NetworkServicesClient { * @param {string} tcp_route * @returns {string} Resource name string. */ - tcpRoutePath(project:string,location:string,tcpRoute:string) { + tcpRoutePath(project: string, location: string, tcpRoute: string) { return this.pathTemplates.tcpRoutePathTemplate.render({ project: project, location: location, @@ -9367,7 +12783,8 @@ export class NetworkServicesClient { * @returns {string} A string representing the tcp_route. */ matchTcpRouteFromTcpRouteName(tcpRouteName: string) { - return this.pathTemplates.tcpRoutePathTemplate.match(tcpRouteName).tcp_route; + return this.pathTemplates.tcpRoutePathTemplate.match(tcpRouteName) + .tcp_route; } /** @@ -9378,7 +12795,7 @@ export class NetworkServicesClient { * @param {string} tls_route * @returns {string} Resource name string. */ - tlsRoutePath(project:string,location:string,tlsRoute:string) { + tlsRoutePath(project: string, location: string, tlsRoute: string) { return this.pathTemplates.tlsRoutePathTemplate.render({ project: project, location: location, @@ -9416,7 +12833,8 @@ export class NetworkServicesClient { * @returns {string} A string representing the tls_route. */ matchTlsRouteFromTlsRouteName(tlsRouteName: string) { - return this.pathTemplates.tlsRoutePathTemplate.match(tlsRouteName).tls_route; + return this.pathTemplates.tlsRoutePathTemplate.match(tlsRouteName) + .tls_route; } /** @@ -9427,7 +12845,7 @@ export class NetworkServicesClient { * @param {string} wasm_plugin * @returns {string} Resource name string. */ - wasmPluginPath(project:string,location:string,wasmPlugin:string) { + wasmPluginPath(project: string, location: string, wasmPlugin: string) { return this.pathTemplates.wasmPluginPathTemplate.render({ project: project, location: location, @@ -9443,7 +12861,8 @@ export class NetworkServicesClient { * @returns {string} A string representing the project. */ matchProjectFromWasmPluginName(wasmPluginName: string) { - return this.pathTemplates.wasmPluginPathTemplate.match(wasmPluginName).project; + return this.pathTemplates.wasmPluginPathTemplate.match(wasmPluginName) + .project; } /** @@ -9454,7 +12873,8 @@ export class NetworkServicesClient { * @returns {string} A string representing the location. */ matchLocationFromWasmPluginName(wasmPluginName: string) { - return this.pathTemplates.wasmPluginPathTemplate.match(wasmPluginName).location; + return this.pathTemplates.wasmPluginPathTemplate.match(wasmPluginName) + .location; } /** @@ -9465,7 +12885,8 @@ export class NetworkServicesClient { * @returns {string} A string representing the wasm_plugin. */ matchWasmPluginFromWasmPluginName(wasmPluginName: string) { - return this.pathTemplates.wasmPluginPathTemplate.match(wasmPluginName).wasm_plugin; + return this.pathTemplates.wasmPluginPathTemplate.match(wasmPluginName) + .wasm_plugin; } /** @@ -9477,7 +12898,12 @@ export class NetworkServicesClient { * @param {string} wasm_plugin_version * @returns {string} Resource name string. */ - wasmPluginVersionPath(project:string,location:string,wasmPlugin:string,wasmPluginVersion:string) { + wasmPluginVersionPath( + project: string, + location: string, + wasmPlugin: string, + wasmPluginVersion: string, + ) { return this.pathTemplates.wasmPluginVersionPathTemplate.render({ project: project, location: location, @@ -9494,7 +12920,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the project. */ matchProjectFromWasmPluginVersionName(wasmPluginVersionName: string) { - return this.pathTemplates.wasmPluginVersionPathTemplate.match(wasmPluginVersionName).project; + return this.pathTemplates.wasmPluginVersionPathTemplate.match( + wasmPluginVersionName, + ).project; } /** @@ -9505,7 +12933,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the location. */ matchLocationFromWasmPluginVersionName(wasmPluginVersionName: string) { - return this.pathTemplates.wasmPluginVersionPathTemplate.match(wasmPluginVersionName).location; + return this.pathTemplates.wasmPluginVersionPathTemplate.match( + wasmPluginVersionName, + ).location; } /** @@ -9516,7 +12946,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the wasm_plugin. */ matchWasmPluginFromWasmPluginVersionName(wasmPluginVersionName: string) { - return this.pathTemplates.wasmPluginVersionPathTemplate.match(wasmPluginVersionName).wasm_plugin; + return this.pathTemplates.wasmPluginVersionPathTemplate.match( + wasmPluginVersionName, + ).wasm_plugin; } /** @@ -9526,8 +12958,12 @@ export class NetworkServicesClient { * A fully-qualified path representing WasmPluginVersion resource. * @returns {string} A string representing the wasm_plugin_version. */ - matchWasmPluginVersionFromWasmPluginVersionName(wasmPluginVersionName: string) { - return this.pathTemplates.wasmPluginVersionPathTemplate.match(wasmPluginVersionName).wasm_plugin_version; + matchWasmPluginVersionFromWasmPluginVersionName( + wasmPluginVersionName: string, + ) { + return this.pathTemplates.wasmPluginVersionPathTemplate.match( + wasmPluginVersionName, + ).wasm_plugin_version; } /** @@ -9538,15 +12974,19 @@ export class NetworkServicesClient { */ close(): Promise { if (this.networkServicesStub && !this._terminated) { - return this.networkServicesStub.then(stub => { + return this.networkServicesStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-networkservices/src/v1beta1/dep_service_client.ts b/packages/google-cloud-networkservices/src/v1beta1/dep_service_client.ts index e89610755fbb..b1795ff2f787 100644 --- a/packages/google-cloud-networkservices/src/v1beta1/dep_service_client.ts +++ b/packages/google-cloud-networkservices/src/v1beta1/dep_service_client.ts @@ -18,11 +18,20 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -44,7 +53,7 @@ export class DepServiceClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('networkservices'); @@ -57,10 +66,10 @@ export class DepServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - depServiceStub?: Promise<{[name: string]: Function}>; + depServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of DepServiceClient. @@ -101,21 +110,42 @@ export class DepServiceClient { * const client = new DepServiceClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof DepServiceClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'networkservices.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -140,7 +170,7 @@ export class DepServiceClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -154,10 +184,7 @@ export class DepServiceClient { } // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -179,19 +206,19 @@ export class DepServiceClient { // Create useful helper objects for these. this.pathTemplates = { endpointPolicyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/endpointPolicies/{endpoint_policy}' + 'projects/{project}/locations/{location}/endpointPolicies/{endpoint_policy}', ), lbRouteExtensionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/lbRouteExtensions/{lb_route_extension}' + 'projects/{project}/locations/{location}/lbRouteExtensions/{lb_route_extension}', ), lbTrafficExtensionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/lbTrafficExtensions/{lb_traffic_extension}' + 'projects/{project}/locations/{location}/lbTrafficExtensions/{lb_traffic_extension}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), }; @@ -199,10 +226,16 @@ export class DepServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listLbTrafficExtensions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'lbTrafficExtensions'), - listLbRouteExtensions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'lbRouteExtensions') + listLbTrafficExtensions: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'lbTrafficExtensions', + ), + listLbRouteExtensions: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'lbRouteExtensions', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -211,69 +244,156 @@ export class DepServiceClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1beta1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1beta1/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1beta1/{resource=projects/*/locations/*/endpointPolicies/*}:getIamPolicy',},{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1beta1/{resource=projects/*/locations/*/endpointPolicies/*}:setIamPolicy',body: '*',},{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1beta1/{resource=projects/*/locations/*/endpointPolicies/*}:testIamPermissions',body: '*',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1beta1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1beta1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta1/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1beta1/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1beta1/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1beta1/{resource=projects/*/locations/*/endpointPolicies/*}:getIamPolicy', + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1beta1/{resource=projects/*/locations/*/endpointPolicies/*}:setIamPolicy', + body: '*', + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1beta1/{resource=projects/*/locations/*/endpointPolicies/*}:testIamPermissions', + body: '*', + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1beta1/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1beta1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1beta1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1beta1/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createLbTrafficExtensionResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1beta1.LbTrafficExtension') as gax.protobuf.Type; + '.google.cloud.networkservices.v1beta1.LbTrafficExtension', + ) as gax.protobuf.Type; const createLbTrafficExtensionMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; const updateLbTrafficExtensionResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1beta1.LbTrafficExtension') as gax.protobuf.Type; + '.google.cloud.networkservices.v1beta1.LbTrafficExtension', + ) as gax.protobuf.Type; const updateLbTrafficExtensionMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; const deleteLbTrafficExtensionResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteLbTrafficExtensionMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; const createLbRouteExtensionResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1beta1.LbRouteExtension') as gax.protobuf.Type; + '.google.cloud.networkservices.v1beta1.LbRouteExtension', + ) as gax.protobuf.Type; const createLbRouteExtensionMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; const updateLbRouteExtensionResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1beta1.LbRouteExtension') as gax.protobuf.Type; + '.google.cloud.networkservices.v1beta1.LbRouteExtension', + ) as gax.protobuf.Type; const updateLbRouteExtensionMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; const deleteLbRouteExtensionResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteLbRouteExtensionMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createLbTrafficExtension: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - createLbTrafficExtensionResponse.decode.bind(createLbTrafficExtensionResponse), - createLbTrafficExtensionMetadata.decode.bind(createLbTrafficExtensionMetadata)), + createLbTrafficExtensionResponse.decode.bind( + createLbTrafficExtensionResponse, + ), + createLbTrafficExtensionMetadata.decode.bind( + createLbTrafficExtensionMetadata, + ), + ), updateLbTrafficExtension: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - updateLbTrafficExtensionResponse.decode.bind(updateLbTrafficExtensionResponse), - updateLbTrafficExtensionMetadata.decode.bind(updateLbTrafficExtensionMetadata)), + updateLbTrafficExtensionResponse.decode.bind( + updateLbTrafficExtensionResponse, + ), + updateLbTrafficExtensionMetadata.decode.bind( + updateLbTrafficExtensionMetadata, + ), + ), deleteLbTrafficExtension: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - deleteLbTrafficExtensionResponse.decode.bind(deleteLbTrafficExtensionResponse), - deleteLbTrafficExtensionMetadata.decode.bind(deleteLbTrafficExtensionMetadata)), + deleteLbTrafficExtensionResponse.decode.bind( + deleteLbTrafficExtensionResponse, + ), + deleteLbTrafficExtensionMetadata.decode.bind( + deleteLbTrafficExtensionMetadata, + ), + ), createLbRouteExtension: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - createLbRouteExtensionResponse.decode.bind(createLbRouteExtensionResponse), - createLbRouteExtensionMetadata.decode.bind(createLbRouteExtensionMetadata)), + createLbRouteExtensionResponse.decode.bind( + createLbRouteExtensionResponse, + ), + createLbRouteExtensionMetadata.decode.bind( + createLbRouteExtensionMetadata, + ), + ), updateLbRouteExtension: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - updateLbRouteExtensionResponse.decode.bind(updateLbRouteExtensionResponse), - updateLbRouteExtensionMetadata.decode.bind(updateLbRouteExtensionMetadata)), + updateLbRouteExtensionResponse.decode.bind( + updateLbRouteExtensionResponse, + ), + updateLbRouteExtensionMetadata.decode.bind( + updateLbRouteExtensionMetadata, + ), + ), deleteLbRouteExtension: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - deleteLbRouteExtensionResponse.decode.bind(deleteLbRouteExtensionResponse), - deleteLbRouteExtensionMetadata.decode.bind(deleteLbRouteExtensionMetadata)) + deleteLbRouteExtensionResponse.decode.bind( + deleteLbRouteExtensionResponse, + ), + deleteLbRouteExtensionMetadata.decode.bind( + deleteLbRouteExtensionMetadata, + ), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.networkservices.v1beta1.DepService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.networkservices.v1beta1.DepService', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -304,28 +424,44 @@ export class DepServiceClient { // Put together the "service stub" for // google.cloud.networkservices.v1beta1.DepService. this.depServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.networkservices.v1beta1.DepService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.networkservices.v1beta1.DepService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.networkservices.v1beta1.DepService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const depServiceStubMethods = - ['listLbTrafficExtensions', 'getLbTrafficExtension', 'createLbTrafficExtension', 'updateLbTrafficExtension', 'deleteLbTrafficExtension', 'listLbRouteExtensions', 'getLbRouteExtension', 'createLbRouteExtension', 'updateLbRouteExtension', 'deleteLbRouteExtension']; + const depServiceStubMethods = [ + 'listLbTrafficExtensions', + 'getLbTrafficExtension', + 'createLbTrafficExtension', + 'updateLbTrafficExtension', + 'deleteLbTrafficExtension', + 'listLbRouteExtensions', + 'getLbRouteExtension', + 'createLbRouteExtension', + 'updateLbRouteExtension', + 'deleteLbRouteExtension', + ]; for (const methodName of depServiceStubMethods) { const callPromise = this.depServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -335,7 +471,7 @@ export class DepServiceClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -350,8 +486,14 @@ export class DepServiceClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkservices.googleapis.com'; } @@ -362,8 +504,14 @@ export class DepServiceClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkservices.googleapis.com'; } @@ -394,9 +542,7 @@ export class DepServiceClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -405,8 +551,9 @@ export class DepServiceClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -417,1042 +564,1537 @@ export class DepServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets details of the specified `LbTrafficExtension` resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the `LbTrafficExtension` resource to get. Must be in - * the format - * `projects/{project}/locations/{location}/lbTrafficExtensions/{lb_traffic_extension}`. - * @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 {@link protos.google.cloud.networkservices.v1beta1.LbTrafficExtension|LbTrafficExtension}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/dep_service.get_lb_traffic_extension.js - * region_tag:networkservices_v1beta1_generated_DepService_GetLbTrafficExtension_async - */ + /** + * Gets details of the specified `LbTrafficExtension` resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the `LbTrafficExtension` resource to get. Must be in + * the format + * `projects/{project}/locations/{location}/lbTrafficExtensions/{lb_traffic_extension}`. + * @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 {@link protos.google.cloud.networkservices.v1beta1.LbTrafficExtension|LbTrafficExtension}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/dep_service.get_lb_traffic_extension.js + * region_tag:networkservices_v1beta1_generated_DepService_GetLbTrafficExtension_async + */ getLbTrafficExtension( - request?: protos.google.cloud.networkservices.v1beta1.IGetLbTrafficExtensionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, - protos.google.cloud.networkservices.v1beta1.IGetLbTrafficExtensionRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1beta1.IGetLbTrafficExtensionRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, + ( + | protos.google.cloud.networkservices.v1beta1.IGetLbTrafficExtensionRequest + | undefined + ), + {} | undefined, + ] + >; getLbTrafficExtension( - request: protos.google.cloud.networkservices.v1beta1.IGetLbTrafficExtensionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, - protos.google.cloud.networkservices.v1beta1.IGetLbTrafficExtensionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1beta1.IGetLbTrafficExtensionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, + | protos.google.cloud.networkservices.v1beta1.IGetLbTrafficExtensionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getLbTrafficExtension( - request: protos.google.cloud.networkservices.v1beta1.IGetLbTrafficExtensionRequest, - callback: Callback< - protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, - protos.google.cloud.networkservices.v1beta1.IGetLbTrafficExtensionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1beta1.IGetLbTrafficExtensionRequest, + callback: Callback< + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, + | protos.google.cloud.networkservices.v1beta1.IGetLbTrafficExtensionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getLbTrafficExtension( - request?: protos.google.cloud.networkservices.v1beta1.IGetLbTrafficExtensionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, - protos.google.cloud.networkservices.v1beta1.IGetLbTrafficExtensionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkservices.v1beta1.IGetLbTrafficExtensionRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, - protos.google.cloud.networkservices.v1beta1.IGetLbTrafficExtensionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, - protos.google.cloud.networkservices.v1beta1.IGetLbTrafficExtensionRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkservices.v1beta1.IGetLbTrafficExtensionRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, + | protos.google.cloud.networkservices.v1beta1.IGetLbTrafficExtensionRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, + ( + | protos.google.cloud.networkservices.v1beta1.IGetLbTrafficExtensionRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getLbTrafficExtension request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, - protos.google.cloud.networkservices.v1beta1.IGetLbTrafficExtensionRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, + | protos.google.cloud.networkservices.v1beta1.IGetLbTrafficExtensionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getLbTrafficExtension response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getLbTrafficExtension(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, - protos.google.cloud.networkservices.v1beta1.IGetLbTrafficExtensionRequest|undefined, - {}|undefined - ]) => { - this._log.info('getLbTrafficExtension response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getLbTrafficExtension(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, + ( + | protos.google.cloud.networkservices.v1beta1.IGetLbTrafficExtensionRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getLbTrafficExtension response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of the specified `LbRouteExtension` resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the `LbRouteExtension` resource to get. Must be in the - * format - * `projects/{project}/locations/{location}/lbRouteExtensions/{lb_route_extension}`. - * @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 {@link protos.google.cloud.networkservices.v1beta1.LbRouteExtension|LbRouteExtension}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/dep_service.get_lb_route_extension.js - * region_tag:networkservices_v1beta1_generated_DepService_GetLbRouteExtension_async - */ + /** + * Gets details of the specified `LbRouteExtension` resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the `LbRouteExtension` resource to get. Must be in the + * format + * `projects/{project}/locations/{location}/lbRouteExtensions/{lb_route_extension}`. + * @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 {@link protos.google.cloud.networkservices.v1beta1.LbRouteExtension|LbRouteExtension}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/dep_service.get_lb_route_extension.js + * region_tag:networkservices_v1beta1_generated_DepService_GetLbRouteExtension_async + */ getLbRouteExtension( - request?: protos.google.cloud.networkservices.v1beta1.IGetLbRouteExtensionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, - protos.google.cloud.networkservices.v1beta1.IGetLbRouteExtensionRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1beta1.IGetLbRouteExtensionRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, + ( + | protos.google.cloud.networkservices.v1beta1.IGetLbRouteExtensionRequest + | undefined + ), + {} | undefined, + ] + >; getLbRouteExtension( - request: protos.google.cloud.networkservices.v1beta1.IGetLbRouteExtensionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, - protos.google.cloud.networkservices.v1beta1.IGetLbRouteExtensionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1beta1.IGetLbRouteExtensionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, + | protos.google.cloud.networkservices.v1beta1.IGetLbRouteExtensionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getLbRouteExtension( - request: protos.google.cloud.networkservices.v1beta1.IGetLbRouteExtensionRequest, - callback: Callback< - protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, - protos.google.cloud.networkservices.v1beta1.IGetLbRouteExtensionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1beta1.IGetLbRouteExtensionRequest, + callback: Callback< + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, + | protos.google.cloud.networkservices.v1beta1.IGetLbRouteExtensionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getLbRouteExtension( - request?: protos.google.cloud.networkservices.v1beta1.IGetLbRouteExtensionRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.networkservices.v1beta1.IGetLbRouteExtensionRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, - protos.google.cloud.networkservices.v1beta1.IGetLbRouteExtensionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, - protos.google.cloud.networkservices.v1beta1.IGetLbRouteExtensionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, - protos.google.cloud.networkservices.v1beta1.IGetLbRouteExtensionRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkservices.v1beta1.IGetLbRouteExtensionRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, + | protos.google.cloud.networkservices.v1beta1.IGetLbRouteExtensionRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, + ( + | protos.google.cloud.networkservices.v1beta1.IGetLbRouteExtensionRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getLbRouteExtension request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, - protos.google.cloud.networkservices.v1beta1.IGetLbRouteExtensionRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, + | protos.google.cloud.networkservices.v1beta1.IGetLbRouteExtensionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getLbRouteExtension response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getLbRouteExtension(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, - protos.google.cloud.networkservices.v1beta1.IGetLbRouteExtensionRequest|undefined, - {}|undefined - ]) => { - this._log.info('getLbRouteExtension response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getLbRouteExtension(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, + ( + | protos.google.cloud.networkservices.v1beta1.IGetLbRouteExtensionRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getLbRouteExtension response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a new `LbTrafficExtension` resource in a given project and - * location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the `LbTrafficExtension` resource. Must be - * in the format `projects/{project}/locations/{location}`. - * @param {string} request.lbTrafficExtensionId - * Required. User-provided ID of the `LbTrafficExtension` resource to be - * created. - * @param {google.cloud.networkservices.v1beta1.LbTrafficExtension} request.lbTrafficExtension - * Required. `LbTrafficExtension` resource to be created. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server can ignore - * the request if it has already been completed. The server guarantees - * that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, ignores the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1beta1/dep_service.create_lb_traffic_extension.js - * region_tag:networkservices_v1beta1_generated_DepService_CreateLbTrafficExtension_async - */ + /** + * Creates a new `LbTrafficExtension` resource in a given project and + * location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the `LbTrafficExtension` resource. Must be + * in the format `projects/{project}/locations/{location}`. + * @param {string} request.lbTrafficExtensionId + * Required. User-provided ID of the `LbTrafficExtension` resource to be + * created. + * @param {google.cloud.networkservices.v1beta1.LbTrafficExtension} request.lbTrafficExtension + * Required. `LbTrafficExtension` resource to be created. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server can ignore + * the request if it has already been completed. The server guarantees + * that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, ignores the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1beta1/dep_service.create_lb_traffic_extension.js + * region_tag:networkservices_v1beta1_generated_DepService_CreateLbTrafficExtension_async + */ createLbTrafficExtension( - request?: protos.google.cloud.networkservices.v1beta1.ICreateLbTrafficExtensionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1beta1.ICreateLbTrafficExtensionRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createLbTrafficExtension( - request: protos.google.cloud.networkservices.v1beta1.ICreateLbTrafficExtensionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1beta1.ICreateLbTrafficExtensionRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createLbTrafficExtension( - request: protos.google.cloud.networkservices.v1beta1.ICreateLbTrafficExtensionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1beta1.ICreateLbTrafficExtensionRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createLbTrafficExtension( - request?: protos.google.cloud.networkservices.v1beta1.ICreateLbTrafficExtensionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1beta1.ICreateLbTrafficExtensionRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createLbTrafficExtension response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createLbTrafficExtension request %j', request); - return this.innerApiCalls.createLbTrafficExtension(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createLbTrafficExtension response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createLbTrafficExtension(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createLbTrafficExtension response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createLbTrafficExtension()`. - * @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/v1beta1/dep_service.create_lb_traffic_extension.js - * region_tag:networkservices_v1beta1_generated_DepService_CreateLbTrafficExtension_async - */ - async checkCreateLbTrafficExtensionProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createLbTrafficExtension()`. + * @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/v1beta1/dep_service.create_lb_traffic_extension.js + * region_tag:networkservices_v1beta1_generated_DepService_CreateLbTrafficExtension_async + */ + async checkCreateLbTrafficExtensionProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1beta1.LbTrafficExtension, + protos.google.cloud.networkservices.v1beta1.OperationMetadata + > + > { this._log.info('createLbTrafficExtension long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createLbTrafficExtension, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createLbTrafficExtension, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1beta1.LbTrafficExtension, + protos.google.cloud.networkservices.v1beta1.OperationMetadata + >; } -/** - * Updates the parameters of the specified `LbTrafficExtension` resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Used to specify the fields to be overwritten in the - * `LbTrafficExtension` resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field is overwritten if it is in the mask. If the - * user does not specify a mask, then all fields are overwritten. - * @param {google.cloud.networkservices.v1beta1.LbTrafficExtension} request.lbTrafficExtension - * Required. `LbTrafficExtension` resource being updated. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server can ignore - * the request if it has already been completed. The server guarantees - * that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, ignores the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1beta1/dep_service.update_lb_traffic_extension.js - * region_tag:networkservices_v1beta1_generated_DepService_UpdateLbTrafficExtension_async - */ + /** + * Updates the parameters of the specified `LbTrafficExtension` resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Used to specify the fields to be overwritten in the + * `LbTrafficExtension` resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field is overwritten if it is in the mask. If the + * user does not specify a mask, then all fields are overwritten. + * @param {google.cloud.networkservices.v1beta1.LbTrafficExtension} request.lbTrafficExtension + * Required. `LbTrafficExtension` resource being updated. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server can ignore + * the request if it has already been completed. The server guarantees + * that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, ignores the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1beta1/dep_service.update_lb_traffic_extension.js + * region_tag:networkservices_v1beta1_generated_DepService_UpdateLbTrafficExtension_async + */ updateLbTrafficExtension( - request?: protos.google.cloud.networkservices.v1beta1.IUpdateLbTrafficExtensionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1beta1.IUpdateLbTrafficExtensionRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateLbTrafficExtension( - request: protos.google.cloud.networkservices.v1beta1.IUpdateLbTrafficExtensionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1beta1.IUpdateLbTrafficExtensionRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateLbTrafficExtension( - request: protos.google.cloud.networkservices.v1beta1.IUpdateLbTrafficExtensionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1beta1.IUpdateLbTrafficExtensionRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateLbTrafficExtension( - request?: protos.google.cloud.networkservices.v1beta1.IUpdateLbTrafficExtensionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1beta1.IUpdateLbTrafficExtensionRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'lb_traffic_extension.name': request.lbTrafficExtension!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'lb_traffic_extension.name': request.lbTrafficExtension!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateLbTrafficExtension response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateLbTrafficExtension request %j', request); - return this.innerApiCalls.updateLbTrafficExtension(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateLbTrafficExtension response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateLbTrafficExtension(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateLbTrafficExtension response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateLbTrafficExtension()`. - * @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/v1beta1/dep_service.update_lb_traffic_extension.js - * region_tag:networkservices_v1beta1_generated_DepService_UpdateLbTrafficExtension_async - */ - async checkUpdateLbTrafficExtensionProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateLbTrafficExtension()`. + * @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/v1beta1/dep_service.update_lb_traffic_extension.js + * region_tag:networkservices_v1beta1_generated_DepService_UpdateLbTrafficExtension_async + */ + async checkUpdateLbTrafficExtensionProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1beta1.LbTrafficExtension, + protos.google.cloud.networkservices.v1beta1.OperationMetadata + > + > { this._log.info('updateLbTrafficExtension long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateLbTrafficExtension, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateLbTrafficExtension, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1beta1.LbTrafficExtension, + protos.google.cloud.networkservices.v1beta1.OperationMetadata + >; } -/** - * Deletes the specified `LbTrafficExtension` resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the `LbTrafficExtension` resource to delete. Must be - * in the format - * `projects/{project}/locations/{location}/lbTrafficExtensions/{lb_traffic_extension}`. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server can ignore - * the request if it has already been completed. The server guarantees - * that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, ignores the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1beta1/dep_service.delete_lb_traffic_extension.js - * region_tag:networkservices_v1beta1_generated_DepService_DeleteLbTrafficExtension_async - */ + /** + * Deletes the specified `LbTrafficExtension` resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the `LbTrafficExtension` resource to delete. Must be + * in the format + * `projects/{project}/locations/{location}/lbTrafficExtensions/{lb_traffic_extension}`. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server can ignore + * the request if it has already been completed. The server guarantees + * that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, ignores the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1beta1/dep_service.delete_lb_traffic_extension.js + * region_tag:networkservices_v1beta1_generated_DepService_DeleteLbTrafficExtension_async + */ deleteLbTrafficExtension( - request?: protos.google.cloud.networkservices.v1beta1.IDeleteLbTrafficExtensionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1beta1.IDeleteLbTrafficExtensionRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteLbTrafficExtension( - request: protos.google.cloud.networkservices.v1beta1.IDeleteLbTrafficExtensionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1beta1.IDeleteLbTrafficExtensionRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteLbTrafficExtension( - request: protos.google.cloud.networkservices.v1beta1.IDeleteLbTrafficExtensionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1beta1.IDeleteLbTrafficExtensionRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteLbTrafficExtension( - request?: protos.google.cloud.networkservices.v1beta1.IDeleteLbTrafficExtensionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1beta1.IDeleteLbTrafficExtensionRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteLbTrafficExtension response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteLbTrafficExtension request %j', request); - return this.innerApiCalls.deleteLbTrafficExtension(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteLbTrafficExtension response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteLbTrafficExtension(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteLbTrafficExtension response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteLbTrafficExtension()`. - * @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/v1beta1/dep_service.delete_lb_traffic_extension.js - * region_tag:networkservices_v1beta1_generated_DepService_DeleteLbTrafficExtension_async - */ - async checkDeleteLbTrafficExtensionProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteLbTrafficExtension()`. + * @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/v1beta1/dep_service.delete_lb_traffic_extension.js + * region_tag:networkservices_v1beta1_generated_DepService_DeleteLbTrafficExtension_async + */ + async checkDeleteLbTrafficExtensionProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1beta1.OperationMetadata + > + > { this._log.info('deleteLbTrafficExtension long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteLbTrafficExtension, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteLbTrafficExtension, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1beta1.OperationMetadata + >; } -/** - * Creates a new `LbRouteExtension` resource in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the `LbRouteExtension` resource. Must be - * in the format `projects/{project}/locations/{location}`. - * @param {string} request.lbRouteExtensionId - * Required. User-provided ID of the `LbRouteExtension` resource to be - * created. - * @param {google.cloud.networkservices.v1beta1.LbRouteExtension} request.lbRouteExtension - * Required. `LbRouteExtension` resource to be created. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server can ignore - * the request if it has already been completed. The server guarantees - * that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, ignores the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1beta1/dep_service.create_lb_route_extension.js - * region_tag:networkservices_v1beta1_generated_DepService_CreateLbRouteExtension_async - */ + /** + * Creates a new `LbRouteExtension` resource in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the `LbRouteExtension` resource. Must be + * in the format `projects/{project}/locations/{location}`. + * @param {string} request.lbRouteExtensionId + * Required. User-provided ID of the `LbRouteExtension` resource to be + * created. + * @param {google.cloud.networkservices.v1beta1.LbRouteExtension} request.lbRouteExtension + * Required. `LbRouteExtension` resource to be created. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server can ignore + * the request if it has already been completed. The server guarantees + * that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, ignores the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1beta1/dep_service.create_lb_route_extension.js + * region_tag:networkservices_v1beta1_generated_DepService_CreateLbRouteExtension_async + */ createLbRouteExtension( - request?: protos.google.cloud.networkservices.v1beta1.ICreateLbRouteExtensionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1beta1.ICreateLbRouteExtensionRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createLbRouteExtension( - request: protos.google.cloud.networkservices.v1beta1.ICreateLbRouteExtensionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1beta1.ICreateLbRouteExtensionRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createLbRouteExtension( - request: protos.google.cloud.networkservices.v1beta1.ICreateLbRouteExtensionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1beta1.ICreateLbRouteExtensionRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createLbRouteExtension( - request?: protos.google.cloud.networkservices.v1beta1.ICreateLbRouteExtensionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1beta1.ICreateLbRouteExtensionRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createLbRouteExtension response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createLbRouteExtension request %j', request); - return this.innerApiCalls.createLbRouteExtension(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createLbRouteExtension response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createLbRouteExtension(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createLbRouteExtension response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createLbRouteExtension()`. - * @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/v1beta1/dep_service.create_lb_route_extension.js - * region_tag:networkservices_v1beta1_generated_DepService_CreateLbRouteExtension_async - */ - async checkCreateLbRouteExtensionProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createLbRouteExtension()`. + * @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/v1beta1/dep_service.create_lb_route_extension.js + * region_tag:networkservices_v1beta1_generated_DepService_CreateLbRouteExtension_async + */ + async checkCreateLbRouteExtensionProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1beta1.LbRouteExtension, + protos.google.cloud.networkservices.v1beta1.OperationMetadata + > + > { this._log.info('createLbRouteExtension long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createLbRouteExtension, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createLbRouteExtension, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1beta1.LbRouteExtension, + protos.google.cloud.networkservices.v1beta1.OperationMetadata + >; } -/** - * Updates the parameters of the specified `LbRouteExtension` resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Used to specify the fields to be overwritten in the - * `LbRouteExtension` resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field is overwritten if it is in the mask. If the - * user does not specify a mask, then all fields are overwritten. - * @param {google.cloud.networkservices.v1beta1.LbRouteExtension} request.lbRouteExtension - * Required. `LbRouteExtension` resource being updated. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server can ignore - * the request if it has already been completed. The server guarantees - * that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, ignores the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1beta1/dep_service.update_lb_route_extension.js - * region_tag:networkservices_v1beta1_generated_DepService_UpdateLbRouteExtension_async - */ + /** + * Updates the parameters of the specified `LbRouteExtension` resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Used to specify the fields to be overwritten in the + * `LbRouteExtension` resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field is overwritten if it is in the mask. If the + * user does not specify a mask, then all fields are overwritten. + * @param {google.cloud.networkservices.v1beta1.LbRouteExtension} request.lbRouteExtension + * Required. `LbRouteExtension` resource being updated. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server can ignore + * the request if it has already been completed. The server guarantees + * that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, ignores the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1beta1/dep_service.update_lb_route_extension.js + * region_tag:networkservices_v1beta1_generated_DepService_UpdateLbRouteExtension_async + */ updateLbRouteExtension( - request?: protos.google.cloud.networkservices.v1beta1.IUpdateLbRouteExtensionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1beta1.IUpdateLbRouteExtensionRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateLbRouteExtension( - request: protos.google.cloud.networkservices.v1beta1.IUpdateLbRouteExtensionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1beta1.IUpdateLbRouteExtensionRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateLbRouteExtension( - request: protos.google.cloud.networkservices.v1beta1.IUpdateLbRouteExtensionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1beta1.IUpdateLbRouteExtensionRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateLbRouteExtension( - request?: protos.google.cloud.networkservices.v1beta1.IUpdateLbRouteExtensionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1beta1.IUpdateLbRouteExtensionRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'lb_route_extension.name': request.lbRouteExtension!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'lb_route_extension.name': request.lbRouteExtension!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateLbRouteExtension response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateLbRouteExtension request %j', request); - return this.innerApiCalls.updateLbRouteExtension(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateLbRouteExtension response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateLbRouteExtension(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateLbRouteExtension response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateLbRouteExtension()`. - * @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/v1beta1/dep_service.update_lb_route_extension.js - * region_tag:networkservices_v1beta1_generated_DepService_UpdateLbRouteExtension_async - */ - async checkUpdateLbRouteExtensionProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateLbRouteExtension()`. + * @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/v1beta1/dep_service.update_lb_route_extension.js + * region_tag:networkservices_v1beta1_generated_DepService_UpdateLbRouteExtension_async + */ + async checkUpdateLbRouteExtensionProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1beta1.LbRouteExtension, + protos.google.cloud.networkservices.v1beta1.OperationMetadata + > + > { this._log.info('updateLbRouteExtension long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateLbRouteExtension, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateLbRouteExtension, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1beta1.LbRouteExtension, + protos.google.cloud.networkservices.v1beta1.OperationMetadata + >; } -/** - * Deletes the specified `LbRouteExtension` resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the `LbRouteExtension` resource to delete. Must be in - * the format - * `projects/{project}/locations/{location}/lbRouteExtensions/{lb_route_extension}`. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server can ignore - * the request if it has already been completed. The server guarantees - * that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, ignores the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1beta1/dep_service.delete_lb_route_extension.js - * region_tag:networkservices_v1beta1_generated_DepService_DeleteLbRouteExtension_async - */ + /** + * Deletes the specified `LbRouteExtension` resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the `LbRouteExtension` resource to delete. Must be in + * the format + * `projects/{project}/locations/{location}/lbRouteExtensions/{lb_route_extension}`. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server can ignore + * the request if it has already been completed. The server guarantees + * that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, ignores the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1beta1/dep_service.delete_lb_route_extension.js + * region_tag:networkservices_v1beta1_generated_DepService_DeleteLbRouteExtension_async + */ deleteLbRouteExtension( - request?: protos.google.cloud.networkservices.v1beta1.IDeleteLbRouteExtensionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1beta1.IDeleteLbRouteExtensionRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteLbRouteExtension( - request: protos.google.cloud.networkservices.v1beta1.IDeleteLbRouteExtensionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1beta1.IDeleteLbRouteExtensionRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteLbRouteExtension( - request: protos.google.cloud.networkservices.v1beta1.IDeleteLbRouteExtensionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1beta1.IDeleteLbRouteExtensionRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteLbRouteExtension( - request?: protos.google.cloud.networkservices.v1beta1.IDeleteLbRouteExtensionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1beta1.IDeleteLbRouteExtensionRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteLbRouteExtension response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteLbRouteExtension request %j', request); - return this.innerApiCalls.deleteLbRouteExtension(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteLbRouteExtension response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteLbRouteExtension(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteLbRouteExtension response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteLbRouteExtension()`. - * @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/v1beta1/dep_service.delete_lb_route_extension.js - * region_tag:networkservices_v1beta1_generated_DepService_DeleteLbRouteExtension_async - */ - async checkDeleteLbRouteExtensionProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteLbRouteExtension()`. + * @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/v1beta1/dep_service.delete_lb_route_extension.js + * region_tag:networkservices_v1beta1_generated_DepService_DeleteLbRouteExtension_async + */ + async checkDeleteLbRouteExtensionProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1beta1.OperationMetadata + > + > { this._log.info('deleteLbRouteExtension long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteLbRouteExtension, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteLbRouteExtension, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1beta1.OperationMetadata + >; } - /** - * Lists `LbTrafficExtension` resources in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the `LbTrafficExtension` - * resources are listed, specified in the following format: - * `projects/{project}/locations/{location}`. - * @param {number} [request.pageSize] - * Optional. Requested page size. The server might return fewer items than - * requested. If unspecified, the server picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results that the server returns. - * @param {string} [request.filter] - * Optional. Filtering results. - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results. - * @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 Array of {@link protos.google.cloud.networkservices.v1beta1.LbTrafficExtension|LbTrafficExtension}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listLbTrafficExtensionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists `LbTrafficExtension` resources in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the `LbTrafficExtension` + * resources are listed, specified in the following format: + * `projects/{project}/locations/{location}`. + * @param {number} [request.pageSize] + * Optional. Requested page size. The server might return fewer items than + * requested. If unspecified, the server picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results that the server returns. + * @param {string} [request.filter] + * Optional. Filtering results. + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results. + * @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 Array of {@link protos.google.cloud.networkservices.v1beta1.LbTrafficExtension|LbTrafficExtension}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listLbTrafficExtensionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listLbTrafficExtensions( - request?: protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension[], - protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsRequest|null, - protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsResponse - ]>; + request?: protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension[], + protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsRequest | null, + protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsResponse, + ] + >; listLbTrafficExtensions( - request: protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsRequest, - protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsResponse|null|undefined, - protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension>): void; + request: protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsRequest, + | protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension + >, + ): void; listLbTrafficExtensions( - request: protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsRequest, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsRequest, - protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsResponse|null|undefined, - protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension>): void; + request: protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsRequest, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsRequest, + | protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension + >, + ): void; listLbTrafficExtensions( - request?: protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsRequest, - protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsResponse|null|undefined, - protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsRequest, - protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsResponse|null|undefined, - protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension>): - Promise<[ - protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension[], - protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsRequest|null, - protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsResponse - ]>|void { + | protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension + >, + callback?: PaginationCallback< + protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsRequest, + | protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension[], + protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsRequest | null, + protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsRequest, - protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsResponse|null|undefined, - protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsRequest, + | protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listLbTrafficExtensions values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1461,210 +2103,239 @@ export class DepServiceClient { this._log.info('listLbTrafficExtensions request %j', request); return this.innerApiCalls .listLbTrafficExtensions(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension[], - protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsRequest|null, - protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsResponse - ]) => { - this._log.info('listLbTrafficExtensions values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension[], + protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsRequest | null, + protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsResponse, + ]) => { + this._log.info('listLbTrafficExtensions values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listLbTrafficExtensions`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the `LbTrafficExtension` - * resources are listed, specified in the following format: - * `projects/{project}/locations/{location}`. - * @param {number} [request.pageSize] - * Optional. Requested page size. The server might return fewer items than - * requested. If unspecified, the server picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results that the server returns. - * @param {string} [request.filter] - * Optional. Filtering results. - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1beta1.LbTrafficExtension|LbTrafficExtension} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listLbTrafficExtensionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listLbTrafficExtensions`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the `LbTrafficExtension` + * resources are listed, specified in the following format: + * `projects/{project}/locations/{location}`. + * @param {number} [request.pageSize] + * Optional. Requested page size. The server might return fewer items than + * requested. If unspecified, the server picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results that the server returns. + * @param {string} [request.filter] + * Optional. Filtering results. + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1beta1.LbTrafficExtension|LbTrafficExtension} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listLbTrafficExtensionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listLbTrafficExtensionsStream( - request?: protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listLbTrafficExtensions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listLbTrafficExtensions stream %j', request); return this.descriptors.page.listLbTrafficExtensions.createStream( this.innerApiCalls.listLbTrafficExtensions as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listLbTrafficExtensions`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the `LbTrafficExtension` - * resources are listed, specified in the following format: - * `projects/{project}/locations/{location}`. - * @param {number} [request.pageSize] - * Optional. Requested page size. The server might return fewer items than - * requested. If unspecified, the server picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results that the server returns. - * @param {string} [request.filter] - * Optional. Filtering results. - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkservices.v1beta1.LbTrafficExtension|LbTrafficExtension}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/dep_service.list_lb_traffic_extensions.js - * region_tag:networkservices_v1beta1_generated_DepService_ListLbTrafficExtensions_async - */ + /** + * Equivalent to `listLbTrafficExtensions`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the `LbTrafficExtension` + * resources are listed, specified in the following format: + * `projects/{project}/locations/{location}`. + * @param {number} [request.pageSize] + * Optional. Requested page size. The server might return fewer items than + * requested. If unspecified, the server picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results that the server returns. + * @param {string} [request.filter] + * Optional. Filtering results. + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkservices.v1beta1.LbTrafficExtension|LbTrafficExtension}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/dep_service.list_lb_traffic_extensions.js + * region_tag:networkservices_v1beta1_generated_DepService_ListLbTrafficExtensions_async + */ listLbTrafficExtensionsAsync( - request?: protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkservices.v1beta1.IListLbTrafficExtensionsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listLbTrafficExtensions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listLbTrafficExtensions iterate %j', request); return this.descriptors.page.listLbTrafficExtensions.asyncIterate( this.innerApiCalls['listLbTrafficExtensions'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists `LbRouteExtension` resources in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the `LbRouteExtension` - * resources are listed, specified in the following format: - * `projects/{project}/locations/{location}`. - * @param {number} [request.pageSize] - * Optional. Requested page size. The server might return fewer items than - * requested. If unspecified, the server picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results that the server returns. - * @param {string} [request.filter] - * Optional. Filtering results. - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results. - * @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 Array of {@link protos.google.cloud.networkservices.v1beta1.LbRouteExtension|LbRouteExtension}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listLbRouteExtensionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists `LbRouteExtension` resources in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the `LbRouteExtension` + * resources are listed, specified in the following format: + * `projects/{project}/locations/{location}`. + * @param {number} [request.pageSize] + * Optional. Requested page size. The server might return fewer items than + * requested. If unspecified, the server picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results that the server returns. + * @param {string} [request.filter] + * Optional. Filtering results. + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results. + * @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 Array of {@link protos.google.cloud.networkservices.v1beta1.LbRouteExtension|LbRouteExtension}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listLbRouteExtensionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listLbRouteExtensions( - request?: protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1beta1.ILbRouteExtension[], - protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsRequest|null, - protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsResponse - ]>; + request?: protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension[], + protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsRequest | null, + protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsResponse, + ] + >; listLbRouteExtensions( - request: protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsRequest, - protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsResponse|null|undefined, - protos.google.cloud.networkservices.v1beta1.ILbRouteExtension>): void; + request: protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsRequest, + | protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension + >, + ): void; listLbRouteExtensions( - request: protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsRequest, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsRequest, - protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsResponse|null|undefined, - protos.google.cloud.networkservices.v1beta1.ILbRouteExtension>): void; + request: protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsRequest, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsRequest, + | protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension + >, + ): void; listLbRouteExtensions( - request?: protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsRequest, - protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsResponse|null|undefined, - protos.google.cloud.networkservices.v1beta1.ILbRouteExtension>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsRequest, - protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsResponse|null|undefined, - protos.google.cloud.networkservices.v1beta1.ILbRouteExtension>): - Promise<[ - protos.google.cloud.networkservices.v1beta1.ILbRouteExtension[], - protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsRequest|null, - protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsResponse - ]>|void { + | protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension + >, + callback?: PaginationCallback< + protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsRequest, + | protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension[], + protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsRequest | null, + protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsRequest, - protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsResponse|null|undefined, - protos.google.cloud.networkservices.v1beta1.ILbRouteExtension>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsRequest, + | protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsResponse + | null + | undefined, + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listLbRouteExtensions values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1673,120 +2344,124 @@ export class DepServiceClient { this._log.info('listLbRouteExtensions request %j', request); return this.innerApiCalls .listLbRouteExtensions(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkservices.v1beta1.ILbRouteExtension[], - protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsRequest|null, - protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsResponse - ]) => { - this._log.info('listLbRouteExtensions values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension[], + protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsRequest | null, + protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsResponse, + ]) => { + this._log.info('listLbRouteExtensions values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listLbRouteExtensions`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the `LbRouteExtension` - * resources are listed, specified in the following format: - * `projects/{project}/locations/{location}`. - * @param {number} [request.pageSize] - * Optional. Requested page size. The server might return fewer items than - * requested. If unspecified, the server picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results that the server returns. - * @param {string} [request.filter] - * Optional. Filtering results. - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1beta1.LbRouteExtension|LbRouteExtension} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listLbRouteExtensionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listLbRouteExtensions`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the `LbRouteExtension` + * resources are listed, specified in the following format: + * `projects/{project}/locations/{location}`. + * @param {number} [request.pageSize] + * Optional. Requested page size. The server might return fewer items than + * requested. If unspecified, the server picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results that the server returns. + * @param {string} [request.filter] + * Optional. Filtering results. + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1beta1.LbRouteExtension|LbRouteExtension} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listLbRouteExtensionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listLbRouteExtensionsStream( - request?: protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listLbRouteExtensions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listLbRouteExtensions stream %j', request); return this.descriptors.page.listLbRouteExtensions.createStream( this.innerApiCalls.listLbRouteExtensions as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listLbRouteExtensions`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the `LbRouteExtension` - * resources are listed, specified in the following format: - * `projects/{project}/locations/{location}`. - * @param {number} [request.pageSize] - * Optional. Requested page size. The server might return fewer items than - * requested. If unspecified, the server picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results that the server returns. - * @param {string} [request.filter] - * Optional. Filtering results. - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkservices.v1beta1.LbRouteExtension|LbRouteExtension}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/dep_service.list_lb_route_extensions.js - * region_tag:networkservices_v1beta1_generated_DepService_ListLbRouteExtensions_async - */ + /** + * Equivalent to `listLbRouteExtensions`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the `LbRouteExtension` + * resources are listed, specified in the following format: + * `projects/{project}/locations/{location}`. + * @param {number} [request.pageSize] + * Optional. Requested page size. The server might return fewer items than + * requested. If unspecified, the server picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results that the server returns. + * @param {string} [request.filter] + * Optional. Filtering results. + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkservices.v1beta1.LbRouteExtension|LbRouteExtension}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/dep_service.list_lb_route_extensions.js + * region_tag:networkservices_v1beta1_generated_DepService_ListLbRouteExtensions_async + */ listLbRouteExtensionsAsync( - request?: protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkservices.v1beta1.IListLbRouteExtensionsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listLbRouteExtensions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listLbRouteExtensions iterate %j', request); return this.descriptors.page.listLbRouteExtensions.asyncIterate( this.innerApiCalls['listLbRouteExtensions'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -1801,7 +2476,11 @@ export class DepServiceClient { * @param {string} endpoint_policy * @returns {string} Resource name string. */ - endpointPolicyPath(project:string,location:string,endpointPolicy:string) { + endpointPolicyPath( + project: string, + location: string, + endpointPolicy: string, + ) { return this.pathTemplates.endpointPolicyPathTemplate.render({ project: project, location: location, @@ -1817,7 +2496,9 @@ export class DepServiceClient { * @returns {string} A string representing the project. */ matchProjectFromEndpointPolicyName(endpointPolicyName: string) { - return this.pathTemplates.endpointPolicyPathTemplate.match(endpointPolicyName).project; + return this.pathTemplates.endpointPolicyPathTemplate.match( + endpointPolicyName, + ).project; } /** @@ -1828,7 +2509,9 @@ export class DepServiceClient { * @returns {string} A string representing the location. */ matchLocationFromEndpointPolicyName(endpointPolicyName: string) { - return this.pathTemplates.endpointPolicyPathTemplate.match(endpointPolicyName).location; + return this.pathTemplates.endpointPolicyPathTemplate.match( + endpointPolicyName, + ).location; } /** @@ -1839,7 +2522,9 @@ export class DepServiceClient { * @returns {string} A string representing the endpoint_policy. */ matchEndpointPolicyFromEndpointPolicyName(endpointPolicyName: string) { - return this.pathTemplates.endpointPolicyPathTemplate.match(endpointPolicyName).endpoint_policy; + return this.pathTemplates.endpointPolicyPathTemplate.match( + endpointPolicyName, + ).endpoint_policy; } /** @@ -1850,7 +2535,11 @@ export class DepServiceClient { * @param {string} lb_route_extension * @returns {string} Resource name string. */ - lbRouteExtensionPath(project:string,location:string,lbRouteExtension:string) { + lbRouteExtensionPath( + project: string, + location: string, + lbRouteExtension: string, + ) { return this.pathTemplates.lbRouteExtensionPathTemplate.render({ project: project, location: location, @@ -1866,7 +2555,9 @@ export class DepServiceClient { * @returns {string} A string representing the project. */ matchProjectFromLbRouteExtensionName(lbRouteExtensionName: string) { - return this.pathTemplates.lbRouteExtensionPathTemplate.match(lbRouteExtensionName).project; + return this.pathTemplates.lbRouteExtensionPathTemplate.match( + lbRouteExtensionName, + ).project; } /** @@ -1877,7 +2568,9 @@ export class DepServiceClient { * @returns {string} A string representing the location. */ matchLocationFromLbRouteExtensionName(lbRouteExtensionName: string) { - return this.pathTemplates.lbRouteExtensionPathTemplate.match(lbRouteExtensionName).location; + return this.pathTemplates.lbRouteExtensionPathTemplate.match( + lbRouteExtensionName, + ).location; } /** @@ -1888,7 +2581,9 @@ export class DepServiceClient { * @returns {string} A string representing the lb_route_extension. */ matchLbRouteExtensionFromLbRouteExtensionName(lbRouteExtensionName: string) { - return this.pathTemplates.lbRouteExtensionPathTemplate.match(lbRouteExtensionName).lb_route_extension; + return this.pathTemplates.lbRouteExtensionPathTemplate.match( + lbRouteExtensionName, + ).lb_route_extension; } /** @@ -1899,7 +2594,11 @@ export class DepServiceClient { * @param {string} lb_traffic_extension * @returns {string} Resource name string. */ - lbTrafficExtensionPath(project:string,location:string,lbTrafficExtension:string) { + lbTrafficExtensionPath( + project: string, + location: string, + lbTrafficExtension: string, + ) { return this.pathTemplates.lbTrafficExtensionPathTemplate.render({ project: project, location: location, @@ -1915,7 +2614,9 @@ export class DepServiceClient { * @returns {string} A string representing the project. */ matchProjectFromLbTrafficExtensionName(lbTrafficExtensionName: string) { - return this.pathTemplates.lbTrafficExtensionPathTemplate.match(lbTrafficExtensionName).project; + return this.pathTemplates.lbTrafficExtensionPathTemplate.match( + lbTrafficExtensionName, + ).project; } /** @@ -1926,7 +2627,9 @@ export class DepServiceClient { * @returns {string} A string representing the location. */ matchLocationFromLbTrafficExtensionName(lbTrafficExtensionName: string) { - return this.pathTemplates.lbTrafficExtensionPathTemplate.match(lbTrafficExtensionName).location; + return this.pathTemplates.lbTrafficExtensionPathTemplate.match( + lbTrafficExtensionName, + ).location; } /** @@ -1936,8 +2639,12 @@ export class DepServiceClient { * A fully-qualified path representing LbTrafficExtension resource. * @returns {string} A string representing the lb_traffic_extension. */ - matchLbTrafficExtensionFromLbTrafficExtensionName(lbTrafficExtensionName: string) { - return this.pathTemplates.lbTrafficExtensionPathTemplate.match(lbTrafficExtensionName).lb_traffic_extension; + matchLbTrafficExtensionFromLbTrafficExtensionName( + lbTrafficExtensionName: string, + ) { + return this.pathTemplates.lbTrafficExtensionPathTemplate.match( + lbTrafficExtensionName, + ).lb_traffic_extension; } /** @@ -1947,7 +2654,7 @@ export class DepServiceClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -1982,7 +2689,7 @@ export class DepServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -2007,7 +2714,7 @@ export class DepServiceClient { */ close(): Promise { if (this.depServiceStub && !this._terminated) { - return this.depServiceStub.then(stub => { + return this.depServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -2016,4 +2723,4 @@ export class DepServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-networkservices/src/v1beta1/index.ts b/packages/google-cloud-networkservices/src/v1beta1/index.ts index 2639fbafc70a..0c90cbddde24 100644 --- a/packages/google-cloud-networkservices/src/v1beta1/index.ts +++ b/packages/google-cloud-networkservices/src/v1beta1/index.ts @@ -16,5 +16,5 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {DepServiceClient} from './dep_service_client'; -export {NetworkServicesClient} from './network_services_client'; +export { DepServiceClient } from './dep_service_client'; +export { NetworkServicesClient } from './network_services_client'; diff --git a/packages/google-cloud-networkservices/src/v1beta1/network_services_client.ts b/packages/google-cloud-networkservices/src/v1beta1/network_services_client.ts index f5a201deecff..dfa407c36f88 100644 --- a/packages/google-cloud-networkservices/src/v1beta1/network_services_client.ts +++ b/packages/google-cloud-networkservices/src/v1beta1/network_services_client.ts @@ -18,11 +18,20 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -44,7 +53,7 @@ export class NetworkServicesClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('networkservices'); @@ -57,10 +66,10 @@ export class NetworkServicesClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - networkServicesStub?: Promise<{[name: string]: Function}>; + networkServicesStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of NetworkServicesClient. @@ -101,21 +110,42 @@ export class NetworkServicesClient { * const client = new NetworkServicesClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof NetworkServicesClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'networkservices.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -140,7 +170,7 @@ export class NetworkServicesClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -154,10 +184,7 @@ export class NetworkServicesClient { } // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -179,13 +206,13 @@ export class NetworkServicesClient { // Create useful helper objects for these. this.pathTemplates = { endpointPolicyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/endpointPolicies/{endpoint_policy}' + 'projects/{project}/locations/{location}/endpointPolicies/{endpoint_policy}', ), lbRouteExtensionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/lbRouteExtensions/{lb_route_extension}' + 'projects/{project}/locations/{location}/lbRouteExtensions/{lb_route_extension}', ), lbTrafficExtensionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/lbTrafficExtensions/{lb_traffic_extension}' + 'projects/{project}/locations/{location}/lbTrafficExtensions/{lb_traffic_extension}', ), }; @@ -193,8 +220,11 @@ export class NetworkServicesClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listEndpointPolicies: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'endpointPolicies') + listEndpointPolicies: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'endpointPolicies', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -203,45 +233,99 @@ export class NetworkServicesClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1beta1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1beta1/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1beta1/{resource=projects/*/locations/*/endpointPolicies/*}:getIamPolicy',},{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1beta1/{resource=projects/*/locations/*/endpointPolicies/*}:setIamPolicy',body: '*',},{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1beta1/{resource=projects/*/locations/*/endpointPolicies/*}:testIamPermissions',body: '*',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1beta1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1beta1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta1/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1beta1/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1beta1/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1beta1/{resource=projects/*/locations/*/endpointPolicies/*}:getIamPolicy', + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1beta1/{resource=projects/*/locations/*/endpointPolicies/*}:setIamPolicy', + body: '*', + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1beta1/{resource=projects/*/locations/*/endpointPolicies/*}:testIamPermissions', + body: '*', + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1beta1/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1beta1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1beta1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1beta1/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createEndpointPolicyResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1beta1.EndpointPolicy') as gax.protobuf.Type; + '.google.cloud.networkservices.v1beta1.EndpointPolicy', + ) as gax.protobuf.Type; const createEndpointPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; const updateEndpointPolicyResponse = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1beta1.EndpointPolicy') as gax.protobuf.Type; + '.google.cloud.networkservices.v1beta1.EndpointPolicy', + ) as gax.protobuf.Type; const updateEndpointPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; const deleteEndpointPolicyResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteEndpointPolicyMetadata = protoFilesRoot.lookup( - '.google.cloud.networkservices.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkservices.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createEndpointPolicy: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createEndpointPolicyResponse.decode.bind(createEndpointPolicyResponse), - createEndpointPolicyMetadata.decode.bind(createEndpointPolicyMetadata)), + createEndpointPolicyMetadata.decode.bind(createEndpointPolicyMetadata), + ), updateEndpointPolicy: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateEndpointPolicyResponse.decode.bind(updateEndpointPolicyResponse), - updateEndpointPolicyMetadata.decode.bind(updateEndpointPolicyMetadata)), + updateEndpointPolicyMetadata.decode.bind(updateEndpointPolicyMetadata), + ), deleteEndpointPolicy: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteEndpointPolicyResponse.decode.bind(deleteEndpointPolicyResponse), - deleteEndpointPolicyMetadata.decode.bind(deleteEndpointPolicyMetadata)) + deleteEndpointPolicyMetadata.decode.bind(deleteEndpointPolicyMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.networkservices.v1beta1.NetworkServices', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.networkservices.v1beta1.NetworkServices', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -272,28 +356,40 @@ export class NetworkServicesClient { // Put together the "service stub" for // google.cloud.networkservices.v1beta1.NetworkServices. this.networkServicesStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.networkservices.v1beta1.NetworkServices') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.networkservices.v1beta1.NetworkServices, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.networkservices.v1beta1.NetworkServices', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.networkservices.v1beta1 + .NetworkServices, + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const networkServicesStubMethods = - ['listEndpointPolicies', 'getEndpointPolicy', 'createEndpointPolicy', 'updateEndpointPolicy', 'deleteEndpointPolicy']; + const networkServicesStubMethods = [ + 'listEndpointPolicies', + 'getEndpointPolicy', + 'createEndpointPolicy', + 'updateEndpointPolicy', + 'deleteEndpointPolicy', + ]; for (const methodName of networkServicesStubMethods) { const callPromise = this.networkServicesStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -303,7 +399,7 @@ export class NetworkServicesClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -318,8 +414,14 @@ export class NetworkServicesClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkservices.googleapis.com'; } @@ -330,8 +432,14 @@ export class NetworkServicesClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkservices.googleapis.com'; } @@ -362,9 +470,7 @@ export class NetworkServicesClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -373,8 +479,9 @@ export class NetworkServicesClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -385,521 +492,781 @@ export class NetworkServicesClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets details of a single EndpointPolicy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the EndpointPolicy to get. Must be in the format - * `projects/* /locations/global/endpointPolicies/*`. - * @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 {@link protos.google.cloud.networkservices.v1beta1.EndpointPolicy|EndpointPolicy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/network_services.get_endpoint_policy.js - * region_tag:networkservices_v1beta1_generated_NetworkServices_GetEndpointPolicy_async - */ + /** + * Gets details of a single EndpointPolicy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the EndpointPolicy to get. Must be in the format + * `projects/* /locations/global/endpointPolicies/*`. + * @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 {@link protos.google.cloud.networkservices.v1beta1.EndpointPolicy|EndpointPolicy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/network_services.get_endpoint_policy.js + * region_tag:networkservices_v1beta1_generated_NetworkServices_GetEndpointPolicy_async + */ getEndpointPolicy( - request?: protos.google.cloud.networkservices.v1beta1.IGetEndpointPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, - protos.google.cloud.networkservices.v1beta1.IGetEndpointPolicyRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1beta1.IGetEndpointPolicyRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, + ( + | protos.google.cloud.networkservices.v1beta1.IGetEndpointPolicyRequest + | undefined + ), + {} | undefined, + ] + >; getEndpointPolicy( - request: protos.google.cloud.networkservices.v1beta1.IGetEndpointPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, - protos.google.cloud.networkservices.v1beta1.IGetEndpointPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1beta1.IGetEndpointPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, + | protos.google.cloud.networkservices.v1beta1.IGetEndpointPolicyRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getEndpointPolicy( - request: protos.google.cloud.networkservices.v1beta1.IGetEndpointPolicyRequest, - callback: Callback< - protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, - protos.google.cloud.networkservices.v1beta1.IGetEndpointPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1beta1.IGetEndpointPolicyRequest, + callback: Callback< + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, + | protos.google.cloud.networkservices.v1beta1.IGetEndpointPolicyRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getEndpointPolicy( - request?: protos.google.cloud.networkservices.v1beta1.IGetEndpointPolicyRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.networkservices.v1beta1.IGetEndpointPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, - protos.google.cloud.networkservices.v1beta1.IGetEndpointPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, - protos.google.cloud.networkservices.v1beta1.IGetEndpointPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, - protos.google.cloud.networkservices.v1beta1.IGetEndpointPolicyRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkservices.v1beta1.IGetEndpointPolicyRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, + | protos.google.cloud.networkservices.v1beta1.IGetEndpointPolicyRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, + ( + | protos.google.cloud.networkservices.v1beta1.IGetEndpointPolicyRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getEndpointPolicy request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, - protos.google.cloud.networkservices.v1beta1.IGetEndpointPolicyRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, + | protos.google.cloud.networkservices.v1beta1.IGetEndpointPolicyRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getEndpointPolicy response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getEndpointPolicy(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, - protos.google.cloud.networkservices.v1beta1.IGetEndpointPolicyRequest|undefined, - {}|undefined - ]) => { - this._log.info('getEndpointPolicy response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getEndpointPolicy(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, + ( + | protos.google.cloud.networkservices.v1beta1.IGetEndpointPolicyRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getEndpointPolicy response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a new EndpointPolicy in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the EndpointPolicy. Must be in the - * format `projects/* /locations/global`. - * @param {string} request.endpointPolicyId - * Required. Short name of the EndpointPolicy resource to be created. - * E.g. "CustomECS". - * @param {google.cloud.networkservices.v1beta1.EndpointPolicy} request.endpointPolicy - * Required. EndpointPolicy resource to be created. - * @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/v1beta1/network_services.create_endpoint_policy.js - * region_tag:networkservices_v1beta1_generated_NetworkServices_CreateEndpointPolicy_async - */ + /** + * Creates a new EndpointPolicy in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the EndpointPolicy. Must be in the + * format `projects/* /locations/global`. + * @param {string} request.endpointPolicyId + * Required. Short name of the EndpointPolicy resource to be created. + * E.g. "CustomECS". + * @param {google.cloud.networkservices.v1beta1.EndpointPolicy} request.endpointPolicy + * Required. EndpointPolicy resource to be created. + * @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/v1beta1/network_services.create_endpoint_policy.js + * region_tag:networkservices_v1beta1_generated_NetworkServices_CreateEndpointPolicy_async + */ createEndpointPolicy( - request?: protos.google.cloud.networkservices.v1beta1.ICreateEndpointPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1beta1.ICreateEndpointPolicyRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createEndpointPolicy( - request: protos.google.cloud.networkservices.v1beta1.ICreateEndpointPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1beta1.ICreateEndpointPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createEndpointPolicy( - request: protos.google.cloud.networkservices.v1beta1.ICreateEndpointPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1beta1.ICreateEndpointPolicyRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createEndpointPolicy( - request?: protos.google.cloud.networkservices.v1beta1.ICreateEndpointPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1beta1.ICreateEndpointPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createEndpointPolicy response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createEndpointPolicy request %j', request); - return this.innerApiCalls.createEndpointPolicy(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createEndpointPolicy response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createEndpointPolicy(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createEndpointPolicy response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createEndpointPolicy()`. - * @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/v1beta1/network_services.create_endpoint_policy.js - * region_tag:networkservices_v1beta1_generated_NetworkServices_CreateEndpointPolicy_async - */ - async checkCreateEndpointPolicyProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createEndpointPolicy()`. + * @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/v1beta1/network_services.create_endpoint_policy.js + * region_tag:networkservices_v1beta1_generated_NetworkServices_CreateEndpointPolicy_async + */ + async checkCreateEndpointPolicyProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1beta1.EndpointPolicy, + protos.google.cloud.networkservices.v1beta1.OperationMetadata + > + > { this._log.info('createEndpointPolicy long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createEndpointPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createEndpointPolicy, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1beta1.EndpointPolicy, + protos.google.cloud.networkservices.v1beta1.OperationMetadata + >; } -/** - * Updates the parameters of a single EndpointPolicy. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask is used to specify the fields to be overwritten in the - * EndpointPolicy resource by the update. - * The fields specified in the update_mask are relative to the resource, not - * the full request. A field will be overwritten if it is in the mask. If the - * user does not provide a mask then all fields will be overwritten. - * @param {google.cloud.networkservices.v1beta1.EndpointPolicy} request.endpointPolicy - * Required. Updated EndpointPolicy resource. - * @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/v1beta1/network_services.update_endpoint_policy.js - * region_tag:networkservices_v1beta1_generated_NetworkServices_UpdateEndpointPolicy_async - */ + /** + * Updates the parameters of a single EndpointPolicy. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask is used to specify the fields to be overwritten in the + * EndpointPolicy resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. If the + * user does not provide a mask then all fields will be overwritten. + * @param {google.cloud.networkservices.v1beta1.EndpointPolicy} request.endpointPolicy + * Required. Updated EndpointPolicy resource. + * @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/v1beta1/network_services.update_endpoint_policy.js + * region_tag:networkservices_v1beta1_generated_NetworkServices_UpdateEndpointPolicy_async + */ updateEndpointPolicy( - request?: protos.google.cloud.networkservices.v1beta1.IUpdateEndpointPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1beta1.IUpdateEndpointPolicyRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateEndpointPolicy( - request: protos.google.cloud.networkservices.v1beta1.IUpdateEndpointPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1beta1.IUpdateEndpointPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateEndpointPolicy( - request: protos.google.cloud.networkservices.v1beta1.IUpdateEndpointPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1beta1.IUpdateEndpointPolicyRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateEndpointPolicy( - request?: protos.google.cloud.networkservices.v1beta1.IUpdateEndpointPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1beta1.IUpdateEndpointPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'endpoint_policy.name': request.endpointPolicy!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'endpoint_policy.name': request.endpointPolicy!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateEndpointPolicy response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateEndpointPolicy request %j', request); - return this.innerApiCalls.updateEndpointPolicy(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateEndpointPolicy response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateEndpointPolicy(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateEndpointPolicy response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateEndpointPolicy()`. - * @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/v1beta1/network_services.update_endpoint_policy.js - * region_tag:networkservices_v1beta1_generated_NetworkServices_UpdateEndpointPolicy_async - */ - async checkUpdateEndpointPolicyProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateEndpointPolicy()`. + * @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/v1beta1/network_services.update_endpoint_policy.js + * region_tag:networkservices_v1beta1_generated_NetworkServices_UpdateEndpointPolicy_async + */ + async checkUpdateEndpointPolicyProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkservices.v1beta1.EndpointPolicy, + protos.google.cloud.networkservices.v1beta1.OperationMetadata + > + > { this._log.info('updateEndpointPolicy long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateEndpointPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateEndpointPolicy, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkservices.v1beta1.EndpointPolicy, + protos.google.cloud.networkservices.v1beta1.OperationMetadata + >; } -/** - * Deletes a single EndpointPolicy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the EndpointPolicy to delete. Must be in the format - * `projects/* /locations/global/endpointPolicies/*`. - * @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/v1beta1/network_services.delete_endpoint_policy.js - * region_tag:networkservices_v1beta1_generated_NetworkServices_DeleteEndpointPolicy_async - */ + /** + * Deletes a single EndpointPolicy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the EndpointPolicy to delete. Must be in the format + * `projects/* /locations/global/endpointPolicies/*`. + * @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/v1beta1/network_services.delete_endpoint_policy.js + * region_tag:networkservices_v1beta1_generated_NetworkServices_DeleteEndpointPolicy_async + */ deleteEndpointPolicy( - request?: protos.google.cloud.networkservices.v1beta1.IDeleteEndpointPolicyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkservices.v1beta1.IDeleteEndpointPolicyRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteEndpointPolicy( - request: protos.google.cloud.networkservices.v1beta1.IDeleteEndpointPolicyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1beta1.IDeleteEndpointPolicyRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteEndpointPolicy( - request: protos.google.cloud.networkservices.v1beta1.IDeleteEndpointPolicyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkservices.v1beta1.IDeleteEndpointPolicyRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteEndpointPolicy( - request?: protos.google.cloud.networkservices.v1beta1.IDeleteEndpointPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkservices.v1beta1.IDeleteEndpointPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteEndpointPolicy response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteEndpointPolicy request %j', request); - return this.innerApiCalls.deleteEndpointPolicy(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteEndpointPolicy response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteEndpointPolicy(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteEndpointPolicy response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteEndpointPolicy()`. - * @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/v1beta1/network_services.delete_endpoint_policy.js - * region_tag:networkservices_v1beta1_generated_NetworkServices_DeleteEndpointPolicy_async - */ - async checkDeleteEndpointPolicyProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteEndpointPolicy()`. + * @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/v1beta1/network_services.delete_endpoint_policy.js + * region_tag:networkservices_v1beta1_generated_NetworkServices_DeleteEndpointPolicy_async + */ + async checkDeleteEndpointPolicyProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1beta1.OperationMetadata + > + > { this._log.info('deleteEndpointPolicy long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteEndpointPolicy, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteEndpointPolicy, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkservices.v1beta1.OperationMetadata + >; } - /** - * Lists EndpointPolicies in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the EndpointPolicies should - * be listed, specified in the format `projects/* /locations/global`. - * @param {number} request.pageSize - * Maximum number of EndpointPolicies to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListEndpointPoliciesResponse` - * Indicates that this is a continuation of a prior - * `ListEndpointPolicies` call, and that the system should return the - * next page of data. - * @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 Array of {@link protos.google.cloud.networkservices.v1beta1.EndpointPolicy|EndpointPolicy}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listEndpointPoliciesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists EndpointPolicies in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the EndpointPolicies should + * be listed, specified in the format `projects/* /locations/global`. + * @param {number} request.pageSize + * Maximum number of EndpointPolicies to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListEndpointPoliciesResponse` + * Indicates that this is a continuation of a prior + * `ListEndpointPolicies` call, and that the system should return the + * next page of data. + * @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 Array of {@link protos.google.cloud.networkservices.v1beta1.EndpointPolicy|EndpointPolicy}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listEndpointPoliciesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listEndpointPolicies( - request?: protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkservices.v1beta1.IEndpointPolicy[], - protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesRequest|null, - protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesResponse - ]>; + request?: protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy[], + protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesRequest | null, + protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesResponse, + ] + >; listEndpointPolicies( - request: protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesRequest, - protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesResponse|null|undefined, - protos.google.cloud.networkservices.v1beta1.IEndpointPolicy>): void; + request: protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesRequest, + | protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy + >, + ): void; listEndpointPolicies( - request: protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesRequest, - callback: PaginationCallback< - protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesRequest, - protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesResponse|null|undefined, - protos.google.cloud.networkservices.v1beta1.IEndpointPolicy>): void; + request: protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesRequest, + callback: PaginationCallback< + protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesRequest, + | protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy + >, + ): void; listEndpointPolicies( - request?: protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesRequest, - protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesResponse|null|undefined, - protos.google.cloud.networkservices.v1beta1.IEndpointPolicy>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesRequest, - protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesResponse|null|undefined, - protos.google.cloud.networkservices.v1beta1.IEndpointPolicy>): - Promise<[ - protos.google.cloud.networkservices.v1beta1.IEndpointPolicy[], - protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesRequest|null, - protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesResponse - ]>|void { + | protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy + >, + callback?: PaginationCallback< + protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesRequest, + | protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy + >, + ): Promise< + [ + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy[], + protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesRequest | null, + protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesRequest, - protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesResponse|null|undefined, - protos.google.cloud.networkservices.v1beta1.IEndpointPolicy>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesRequest, + | protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesResponse + | null + | undefined, + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listEndpointPolicies values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -908,114 +1275,118 @@ export class NetworkServicesClient { this._log.info('listEndpointPolicies request %j', request); return this.innerApiCalls .listEndpointPolicies(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkservices.v1beta1.IEndpointPolicy[], - protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesRequest|null, - protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesResponse - ]) => { - this._log.info('listEndpointPolicies values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy[], + protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesRequest | null, + protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesResponse, + ]) => { + this._log.info('listEndpointPolicies values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listEndpointPolicies`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the EndpointPolicies should - * be listed, specified in the format `projects/* /locations/global`. - * @param {number} request.pageSize - * Maximum number of EndpointPolicies to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListEndpointPoliciesResponse` - * Indicates that this is a continuation of a prior - * `ListEndpointPolicies` call, and that the system should return the - * next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1beta1.EndpointPolicy|EndpointPolicy} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listEndpointPoliciesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listEndpointPolicies`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the EndpointPolicies should + * be listed, specified in the format `projects/* /locations/global`. + * @param {number} request.pageSize + * Maximum number of EndpointPolicies to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListEndpointPoliciesResponse` + * Indicates that this is a continuation of a prior + * `ListEndpointPolicies` call, and that the system should return the + * next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.networkservices.v1beta1.EndpointPolicy|EndpointPolicy} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listEndpointPoliciesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listEndpointPoliciesStream( - request?: protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listEndpointPolicies']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listEndpointPolicies stream %j', request); return this.descriptors.page.listEndpointPolicies.createStream( this.innerApiCalls.listEndpointPolicies as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listEndpointPolicies`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the EndpointPolicies should - * be listed, specified in the format `projects/* /locations/global`. - * @param {number} request.pageSize - * Maximum number of EndpointPolicies to return per call. - * @param {string} request.pageToken - * The value returned by the last `ListEndpointPoliciesResponse` - * Indicates that this is a continuation of a prior - * `ListEndpointPolicies` call, and that the system should return the - * next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkservices.v1beta1.EndpointPolicy|EndpointPolicy}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/network_services.list_endpoint_policies.js - * region_tag:networkservices_v1beta1_generated_NetworkServices_ListEndpointPolicies_async - */ + /** + * Equivalent to `listEndpointPolicies`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the EndpointPolicies should + * be listed, specified in the format `projects/* /locations/global`. + * @param {number} request.pageSize + * Maximum number of EndpointPolicies to return per call. + * @param {string} request.pageToken + * The value returned by the last `ListEndpointPoliciesResponse` + * Indicates that this is a continuation of a prior + * `ListEndpointPolicies` call, and that the system should return the + * next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkservices.v1beta1.EndpointPolicy|EndpointPolicy}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/network_services.list_endpoint_policies.js + * region_tag:networkservices_v1beta1_generated_NetworkServices_ListEndpointPolicies_async + */ listEndpointPoliciesAsync( - request?: protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkservices.v1beta1.IListEndpointPoliciesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listEndpointPolicies']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listEndpointPolicies iterate %j', request); return this.descriptors.page.listEndpointPolicies.asyncIterate( this.innerApiCalls['listEndpointPolicies'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -1030,7 +1401,11 @@ export class NetworkServicesClient { * @param {string} endpoint_policy * @returns {string} Resource name string. */ - endpointPolicyPath(project:string,location:string,endpointPolicy:string) { + endpointPolicyPath( + project: string, + location: string, + endpointPolicy: string, + ) { return this.pathTemplates.endpointPolicyPathTemplate.render({ project: project, location: location, @@ -1046,7 +1421,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the project. */ matchProjectFromEndpointPolicyName(endpointPolicyName: string) { - return this.pathTemplates.endpointPolicyPathTemplate.match(endpointPolicyName).project; + return this.pathTemplates.endpointPolicyPathTemplate.match( + endpointPolicyName, + ).project; } /** @@ -1057,7 +1434,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the location. */ matchLocationFromEndpointPolicyName(endpointPolicyName: string) { - return this.pathTemplates.endpointPolicyPathTemplate.match(endpointPolicyName).location; + return this.pathTemplates.endpointPolicyPathTemplate.match( + endpointPolicyName, + ).location; } /** @@ -1068,7 +1447,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the endpoint_policy. */ matchEndpointPolicyFromEndpointPolicyName(endpointPolicyName: string) { - return this.pathTemplates.endpointPolicyPathTemplate.match(endpointPolicyName).endpoint_policy; + return this.pathTemplates.endpointPolicyPathTemplate.match( + endpointPolicyName, + ).endpoint_policy; } /** @@ -1079,7 +1460,11 @@ export class NetworkServicesClient { * @param {string} lb_route_extension * @returns {string} Resource name string. */ - lbRouteExtensionPath(project:string,location:string,lbRouteExtension:string) { + lbRouteExtensionPath( + project: string, + location: string, + lbRouteExtension: string, + ) { return this.pathTemplates.lbRouteExtensionPathTemplate.render({ project: project, location: location, @@ -1095,7 +1480,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the project. */ matchProjectFromLbRouteExtensionName(lbRouteExtensionName: string) { - return this.pathTemplates.lbRouteExtensionPathTemplate.match(lbRouteExtensionName).project; + return this.pathTemplates.lbRouteExtensionPathTemplate.match( + lbRouteExtensionName, + ).project; } /** @@ -1106,7 +1493,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the location. */ matchLocationFromLbRouteExtensionName(lbRouteExtensionName: string) { - return this.pathTemplates.lbRouteExtensionPathTemplate.match(lbRouteExtensionName).location; + return this.pathTemplates.lbRouteExtensionPathTemplate.match( + lbRouteExtensionName, + ).location; } /** @@ -1117,7 +1506,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the lb_route_extension. */ matchLbRouteExtensionFromLbRouteExtensionName(lbRouteExtensionName: string) { - return this.pathTemplates.lbRouteExtensionPathTemplate.match(lbRouteExtensionName).lb_route_extension; + return this.pathTemplates.lbRouteExtensionPathTemplate.match( + lbRouteExtensionName, + ).lb_route_extension; } /** @@ -1128,7 +1519,11 @@ export class NetworkServicesClient { * @param {string} lb_traffic_extension * @returns {string} Resource name string. */ - lbTrafficExtensionPath(project:string,location:string,lbTrafficExtension:string) { + lbTrafficExtensionPath( + project: string, + location: string, + lbTrafficExtension: string, + ) { return this.pathTemplates.lbTrafficExtensionPathTemplate.render({ project: project, location: location, @@ -1144,7 +1539,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the project. */ matchProjectFromLbTrafficExtensionName(lbTrafficExtensionName: string) { - return this.pathTemplates.lbTrafficExtensionPathTemplate.match(lbTrafficExtensionName).project; + return this.pathTemplates.lbTrafficExtensionPathTemplate.match( + lbTrafficExtensionName, + ).project; } /** @@ -1155,7 +1552,9 @@ export class NetworkServicesClient { * @returns {string} A string representing the location. */ matchLocationFromLbTrafficExtensionName(lbTrafficExtensionName: string) { - return this.pathTemplates.lbTrafficExtensionPathTemplate.match(lbTrafficExtensionName).location; + return this.pathTemplates.lbTrafficExtensionPathTemplate.match( + lbTrafficExtensionName, + ).location; } /** @@ -1165,8 +1564,12 @@ export class NetworkServicesClient { * A fully-qualified path representing LbTrafficExtension resource. * @returns {string} A string representing the lb_traffic_extension. */ - matchLbTrafficExtensionFromLbTrafficExtensionName(lbTrafficExtensionName: string) { - return this.pathTemplates.lbTrafficExtensionPathTemplate.match(lbTrafficExtensionName).lb_traffic_extension; + matchLbTrafficExtensionFromLbTrafficExtensionName( + lbTrafficExtensionName: string, + ) { + return this.pathTemplates.lbTrafficExtensionPathTemplate.match( + lbTrafficExtensionName, + ).lb_traffic_extension; } /** @@ -1177,7 +1580,7 @@ export class NetworkServicesClient { */ close(): Promise { if (this.networkServicesStub && !this._terminated) { - return this.networkServicesStub.then(stub => { + return this.networkServicesStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -1186,4 +1589,4 @@ export class NetworkServicesClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-networkservices/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-networkservices/system-test/fixtures/sample/src/index.ts index 480f596b1241..bd9b9af77fae 100644 --- a/packages/google-cloud-networkservices/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-networkservices/system-test/fixtures/sample/src/index.ts @@ -16,7 +16,10 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {DepServiceClient, NetworkServicesClient} from '@google-cloud/networkservices'; +import { + DepServiceClient, + NetworkServicesClient, +} from '@google-cloud/networkservices'; // check that the client class type name can be used function doStuffWithDepServiceClient(client: DepServiceClient) { diff --git a/packages/google-cloud-networkservices/system-test/install.ts b/packages/google-cloud-networkservices/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-networkservices/system-test/install.ts +++ b/packages/google-cloud-networkservices/system-test/install.ts @@ -16,34 +16,36 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {packNTest} from 'pack-n-play'; -import {readFileSync} from 'fs'; -import {describe, it} from 'mocha'; +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; +import { describe, it } from 'mocha'; describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { + it('TypeScript code', async function () { this.timeout(300000); const options = { packageDir: process.cwd(), sample: { description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } + ts: readFileSync( + './system-test/fixtures/sample/src/index.ts', + ).toString(), + }, }; await packNTest(options); }); - it('JavaScript code', async function() { + it('JavaScript code', async function () { this.timeout(300000); const options = { packageDir: process.cwd(), sample: { description: 'JavaScript user can use the library', - cjs: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } + cjs: readFileSync( + './system-test/fixtures/sample/src/index.js', + ).toString(), + }, }; await packNTest(options); }); - }); diff --git a/packages/google-cloud-networkservices/test/gapic_dep_service_v1.ts b/packages/google-cloud-networkservices/test/gapic_dep_service_v1.ts index 55726bf99f99..241519f1716e 100644 --- a/packages/google-cloud-networkservices/test/gapic_dep_service_v1.ts +++ b/packages/google-cloud-networkservices/test/gapic_dep_service_v1.ts @@ -19,5109 +19,6741 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as depserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + IamProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1.DepServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new depserviceModule.v1.DepServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkservices.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new depserviceModule.v1.DepServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = depserviceModule.v1.DepServiceClient.servicePath; - assert.strictEqual(servicePath, 'networkservices.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = depserviceModule.v1.DepServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkservices.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new depserviceModule.v1.DepServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkservices.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new depserviceModule.v1.DepServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkservices.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new depserviceModule.v1.DepServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkservices.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new depserviceModule.v1.DepServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkservices.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new depserviceModule.v1.DepServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = depserviceModule.v1.DepServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new depserviceModule.v1.DepServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new depserviceModule.v1.DepServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.depServiceStub, undefined); - await client.initialize(); - assert(client.depServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.depServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has close method for the non-initialized client', done => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.depServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new depserviceModule.v1.DepServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkservices.googleapis.com'); }); - describe('getLbTrafficExtension', () => { - it('invokes getLbTrafficExtension without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetLbTrafficExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetLbTrafficExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.LbTrafficExtension() - ); - client.innerApiCalls.getLbTrafficExtension = stubSimpleCall(expectedResponse); - const [response] = await client.getLbTrafficExtension(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getLbTrafficExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getLbTrafficExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getLbTrafficExtension without error using callback', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetLbTrafficExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetLbTrafficExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.LbTrafficExtension() - ); - client.innerApiCalls.getLbTrafficExtension = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLbTrafficExtension( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.ILbTrafficExtension|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getLbTrafficExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getLbTrafficExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getLbTrafficExtension with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetLbTrafficExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetLbTrafficExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getLbTrafficExtension = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLbTrafficExtension(request), expectedError); - const actualRequest = (client.innerApiCalls.getLbTrafficExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getLbTrafficExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getLbTrafficExtension with closed client', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetLbTrafficExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetLbTrafficExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getLbTrafficExtension(request), expectedError); - }); + it('has universeDomain', () => { + const client = new depserviceModule.v1.DepServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); }); - describe('getLbRouteExtension', () => { - it('invokes getLbRouteExtension without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetLbRouteExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetLbRouteExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.LbRouteExtension() - ); - client.innerApiCalls.getLbRouteExtension = stubSimpleCall(expectedResponse); - const [response] = await client.getLbRouteExtension(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getLbRouteExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getLbRouteExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = depserviceModule.v1.DepServiceClient.servicePath; + assert.strictEqual(servicePath, 'networkservices.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = depserviceModule.v1.DepServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkservices.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new depserviceModule.v1.DepServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkservices.example.com'); + }); - it('invokes getLbRouteExtension without error using callback', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetLbRouteExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetLbRouteExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.LbRouteExtension() - ); - client.innerApiCalls.getLbRouteExtension = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLbRouteExtension( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.ILbRouteExtension|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getLbRouteExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getLbRouteExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new depserviceModule.v1.DepServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkservices.example.com'); + }); - it('invokes getLbRouteExtension with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetLbRouteExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetLbRouteExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getLbRouteExtension = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLbRouteExtension(request), expectedError); - const actualRequest = (client.innerApiCalls.getLbRouteExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getLbRouteExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new depserviceModule.v1.DepServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkservices.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new depserviceModule.v1.DepServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'networkservices.configured.example.com', + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new depserviceModule.v1.DepServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('invokes getLbRouteExtension with closed client', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetLbRouteExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetLbRouteExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getLbRouteExtension(request), expectedError); - }); + it('has port', () => { + const port = depserviceModule.v1.DepServiceClient.port; + assert(port); + assert(typeof port === 'number'); }); - describe('getLbEdgeExtension', () => { - it('invokes getLbEdgeExtension without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetLbEdgeExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetLbEdgeExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.LbEdgeExtension() - ); - client.innerApiCalls.getLbEdgeExtension = stubSimpleCall(expectedResponse); - const [response] = await client.getLbEdgeExtension(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getLbEdgeExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getLbEdgeExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('should create a client with no option', () => { + const client = new depserviceModule.v1.DepServiceClient(); + assert(client); + }); - it('invokes getLbEdgeExtension without error using callback', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetLbEdgeExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetLbEdgeExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.LbEdgeExtension() - ); - client.innerApiCalls.getLbEdgeExtension = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLbEdgeExtension( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.ILbEdgeExtension|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getLbEdgeExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getLbEdgeExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('should create a client with gRPC fallback', () => { + const client = new depserviceModule.v1.DepServiceClient({ + fallback: true, + }); + assert(client); + }); - it('invokes getLbEdgeExtension with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetLbEdgeExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetLbEdgeExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getLbEdgeExtension = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLbEdgeExtension(request), expectedError); - const actualRequest = (client.innerApiCalls.getLbEdgeExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getLbEdgeExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.depServiceStub, undefined); + await client.initialize(); + assert(client.depServiceStub); + }); - it('invokes getLbEdgeExtension with closed client', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetLbEdgeExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetLbEdgeExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getLbEdgeExtension(request), expectedError); + it('has close method for the initialized client', (done) => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.depServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('getAuthzExtension', () => { - it('invokes getAuthzExtension without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetAuthzExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetAuthzExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.AuthzExtension() - ); - client.innerApiCalls.getAuthzExtension = stubSimpleCall(expectedResponse); - const [response] = await client.getAuthzExtension(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getAuthzExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAuthzExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the non-initialized client', (done) => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.depServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getAuthzExtension without error using callback', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetAuthzExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetAuthzExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.AuthzExtension() - ); - client.innerApiCalls.getAuthzExtension = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getAuthzExtension( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.IAuthzExtension|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getAuthzExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAuthzExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('invokes getAuthzExtension with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetAuthzExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetAuthzExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getAuthzExtension = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getAuthzExtension(request), expectedError); - const actualRequest = (client.innerApiCalls.getAuthzExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAuthzExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getLbTrafficExtension', () => { + it('invokes getLbTrafficExtension without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetLbTrafficExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetLbTrafficExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbTrafficExtension(), + ); + client.innerApiCalls.getLbTrafficExtension = + stubSimpleCall(expectedResponse); + const [response] = await client.getLbTrafficExtension(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getLbTrafficExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getLbTrafficExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getAuthzExtension with closed client', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetAuthzExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetAuthzExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getAuthzExtension(request), expectedError); - }); + it('invokes getLbTrafficExtension without error using callback', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetLbTrafficExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetLbTrafficExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbTrafficExtension(), + ); + client.innerApiCalls.getLbTrafficExtension = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLbTrafficExtension( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkservices.v1.ILbTrafficExtension | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getLbTrafficExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getLbTrafficExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createLbTrafficExtension', () => { - it('invokes createLbTrafficExtension without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateLbTrafficExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateLbTrafficExtensionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createLbTrafficExtension = stubLongRunningCall(expectedResponse); - const [operation] = await client.createLbTrafficExtension(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createLbTrafficExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createLbTrafficExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getLbTrafficExtension with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetLbTrafficExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetLbTrafficExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getLbTrafficExtension = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLbTrafficExtension(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.getLbTrafficExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getLbTrafficExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createLbTrafficExtension without error using callback', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateLbTrafficExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateLbTrafficExtensionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createLbTrafficExtension = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createLbTrafficExtension( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createLbTrafficExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createLbTrafficExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getLbTrafficExtension with closed client', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetLbTrafficExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetLbTrafficExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.getLbTrafficExtension(request), + expectedError, + ); + }); + }); + + describe('getLbRouteExtension', () => { + it('invokes getLbRouteExtension without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetLbRouteExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetLbRouteExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbRouteExtension(), + ); + client.innerApiCalls.getLbRouteExtension = + stubSimpleCall(expectedResponse); + const [response] = await client.getLbRouteExtension(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getLbRouteExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getLbRouteExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createLbTrafficExtension with call error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateLbTrafficExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateLbTrafficExtensionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createLbTrafficExtension = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createLbTrafficExtension(request), expectedError); - const actualRequest = (client.innerApiCalls.createLbTrafficExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createLbTrafficExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getLbRouteExtension without error using callback', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetLbRouteExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetLbRouteExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbRouteExtension(), + ); + client.innerApiCalls.getLbRouteExtension = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLbRouteExtension( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkservices.v1.ILbRouteExtension | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getLbRouteExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getLbRouteExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createLbTrafficExtension with LRO error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateLbTrafficExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateLbTrafficExtensionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createLbTrafficExtension = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createLbTrafficExtension(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createLbTrafficExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createLbTrafficExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getLbRouteExtension with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetLbRouteExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetLbRouteExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getLbRouteExtension = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getLbRouteExtension(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getLbRouteExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getLbRouteExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateLbTrafficExtensionProgress without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateLbTrafficExtensionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes getLbRouteExtension with closed client', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetLbRouteExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetLbRouteExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getLbRouteExtension(request), expectedError); + }); + }); + + describe('getLbEdgeExtension', () => { + it('invokes getLbEdgeExtension without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetLbEdgeExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetLbEdgeExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbEdgeExtension(), + ); + client.innerApiCalls.getLbEdgeExtension = + stubSimpleCall(expectedResponse); + const [response] = await client.getLbEdgeExtension(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getLbEdgeExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getLbEdgeExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateLbTrafficExtensionProgress with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateLbTrafficExtensionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes getLbEdgeExtension without error using callback', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetLbEdgeExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetLbEdgeExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbEdgeExtension(), + ); + client.innerApiCalls.getLbEdgeExtension = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLbEdgeExtension( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkservices.v1.ILbEdgeExtension | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getLbEdgeExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getLbEdgeExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateLbTrafficExtension', () => { - it('invokes updateLbTrafficExtension without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateLbTrafficExtensionRequest() - ); - request.lbTrafficExtension ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateLbTrafficExtensionRequest', ['lbTrafficExtension', 'name']); - request.lbTrafficExtension.name = defaultValue1; - const expectedHeaderRequestParams = `lb_traffic_extension.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateLbTrafficExtension = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateLbTrafficExtension(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateLbTrafficExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateLbTrafficExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getLbEdgeExtension with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetLbEdgeExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetLbEdgeExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getLbEdgeExtension = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getLbEdgeExtension(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getLbEdgeExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getLbEdgeExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateLbTrafficExtension without error using callback', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateLbTrafficExtensionRequest() - ); - request.lbTrafficExtension ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateLbTrafficExtensionRequest', ['lbTrafficExtension', 'name']); - request.lbTrafficExtension.name = defaultValue1; - const expectedHeaderRequestParams = `lb_traffic_extension.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateLbTrafficExtension = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateLbTrafficExtension( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateLbTrafficExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateLbTrafficExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getLbEdgeExtension with closed client', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetLbEdgeExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetLbEdgeExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getLbEdgeExtension(request), expectedError); + }); + }); + + describe('getAuthzExtension', () => { + it('invokes getAuthzExtension without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetAuthzExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetAuthzExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.AuthzExtension(), + ); + client.innerApiCalls.getAuthzExtension = stubSimpleCall(expectedResponse); + const [response] = await client.getAuthzExtension(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getAuthzExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAuthzExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateLbTrafficExtension with call error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateLbTrafficExtensionRequest() - ); - request.lbTrafficExtension ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateLbTrafficExtensionRequest', ['lbTrafficExtension', 'name']); - request.lbTrafficExtension.name = defaultValue1; - const expectedHeaderRequestParams = `lb_traffic_extension.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateLbTrafficExtension = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateLbTrafficExtension(request), expectedError); - const actualRequest = (client.innerApiCalls.updateLbTrafficExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateLbTrafficExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getAuthzExtension without error using callback', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetAuthzExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetAuthzExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.AuthzExtension(), + ); + client.innerApiCalls.getAuthzExtension = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getAuthzExtension( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkservices.v1.IAuthzExtension | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getAuthzExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAuthzExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateLbTrafficExtension with LRO error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateLbTrafficExtensionRequest() - ); - request.lbTrafficExtension ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateLbTrafficExtensionRequest', ['lbTrafficExtension', 'name']); - request.lbTrafficExtension.name = defaultValue1; - const expectedHeaderRequestParams = `lb_traffic_extension.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateLbTrafficExtension = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateLbTrafficExtension(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateLbTrafficExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateLbTrafficExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getAuthzExtension with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetAuthzExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetAuthzExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getAuthzExtension = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getAuthzExtension(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getAuthzExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAuthzExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateLbTrafficExtensionProgress without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateLbTrafficExtensionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes getAuthzExtension with closed client', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetAuthzExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetAuthzExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getAuthzExtension(request), expectedError); + }); + }); + + describe('createLbTrafficExtension', () => { + it('invokes createLbTrafficExtension without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateLbTrafficExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateLbTrafficExtensionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createLbTrafficExtension = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createLbTrafficExtension(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createLbTrafficExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createLbTrafficExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateLbTrafficExtensionProgress with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateLbTrafficExtensionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createLbTrafficExtension without error using callback', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateLbTrafficExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateLbTrafficExtensionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createLbTrafficExtension = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createLbTrafficExtension( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createLbTrafficExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createLbTrafficExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteLbTrafficExtension', () => { - it('invokes deleteLbTrafficExtension without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteLbTrafficExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteLbTrafficExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteLbTrafficExtension = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteLbTrafficExtension(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteLbTrafficExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteLbTrafficExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createLbTrafficExtension with call error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateLbTrafficExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateLbTrafficExtensionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createLbTrafficExtension = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.createLbTrafficExtension(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createLbTrafficExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createLbTrafficExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteLbTrafficExtension without error using callback', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteLbTrafficExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteLbTrafficExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteLbTrafficExtension = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteLbTrafficExtension( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteLbTrafficExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteLbTrafficExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createLbTrafficExtension with LRO error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateLbTrafficExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateLbTrafficExtensionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createLbTrafficExtension = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createLbTrafficExtension(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createLbTrafficExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createLbTrafficExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteLbTrafficExtension with call error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteLbTrafficExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteLbTrafficExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteLbTrafficExtension = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteLbTrafficExtension(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteLbTrafficExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteLbTrafficExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateLbTrafficExtensionProgress without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateLbTrafficExtensionProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteLbTrafficExtension with LRO error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteLbTrafficExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteLbTrafficExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteLbTrafficExtension = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteLbTrafficExtension(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteLbTrafficExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteLbTrafficExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateLbTrafficExtensionProgress with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateLbTrafficExtensionProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateLbTrafficExtension', () => { + it('invokes updateLbTrafficExtension without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateLbTrafficExtensionRequest(), + ); + request.lbTrafficExtension ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateLbTrafficExtensionRequest', + ['lbTrafficExtension', 'name'], + ); + request.lbTrafficExtension.name = defaultValue1; + const expectedHeaderRequestParams = `lb_traffic_extension.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateLbTrafficExtension = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateLbTrafficExtension(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateLbTrafficExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateLbTrafficExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteLbTrafficExtensionProgress without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteLbTrafficExtensionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateLbTrafficExtension without error using callback', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateLbTrafficExtensionRequest(), + ); + request.lbTrafficExtension ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateLbTrafficExtensionRequest', + ['lbTrafficExtension', 'name'], + ); + request.lbTrafficExtension.name = defaultValue1; + const expectedHeaderRequestParams = `lb_traffic_extension.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateLbTrafficExtension = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateLbTrafficExtension( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateLbTrafficExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateLbTrafficExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteLbTrafficExtensionProgress with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteLbTrafficExtensionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateLbTrafficExtension with call error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateLbTrafficExtensionRequest(), + ); + request.lbTrafficExtension ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateLbTrafficExtensionRequest', + ['lbTrafficExtension', 'name'], + ); + request.lbTrafficExtension.name = defaultValue1; + const expectedHeaderRequestParams = `lb_traffic_extension.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateLbTrafficExtension = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.updateLbTrafficExtension(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.updateLbTrafficExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateLbTrafficExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createLbRouteExtension', () => { - it('invokes createLbRouteExtension without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateLbRouteExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateLbRouteExtensionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createLbRouteExtension = stubLongRunningCall(expectedResponse); - const [operation] = await client.createLbRouteExtension(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createLbRouteExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createLbRouteExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateLbTrafficExtension with LRO error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateLbTrafficExtensionRequest(), + ); + request.lbTrafficExtension ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateLbTrafficExtensionRequest', + ['lbTrafficExtension', 'name'], + ); + request.lbTrafficExtension.name = defaultValue1; + const expectedHeaderRequestParams = `lb_traffic_extension.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateLbTrafficExtension = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateLbTrafficExtension(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateLbTrafficExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateLbTrafficExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createLbRouteExtension without error using callback', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateLbRouteExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateLbRouteExtensionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createLbRouteExtension = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createLbRouteExtension( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createLbRouteExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createLbRouteExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateLbTrafficExtensionProgress without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateLbTrafficExtensionProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createLbRouteExtension with call error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateLbRouteExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateLbRouteExtensionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createLbRouteExtension = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createLbRouteExtension(request), expectedError); - const actualRequest = (client.innerApiCalls.createLbRouteExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createLbRouteExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateLbTrafficExtensionProgress with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateLbTrafficExtensionProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteLbTrafficExtension', () => { + it('invokes deleteLbTrafficExtension without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteLbTrafficExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteLbTrafficExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteLbTrafficExtension = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteLbTrafficExtension(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteLbTrafficExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteLbTrafficExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createLbRouteExtension with LRO error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateLbRouteExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateLbRouteExtensionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createLbRouteExtension = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createLbRouteExtension(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createLbRouteExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createLbRouteExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteLbTrafficExtension without error using callback', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteLbTrafficExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteLbTrafficExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteLbTrafficExtension = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteLbTrafficExtension( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteLbTrafficExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteLbTrafficExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateLbRouteExtensionProgress without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateLbRouteExtensionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteLbTrafficExtension with call error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteLbTrafficExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteLbTrafficExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteLbTrafficExtension = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.deleteLbTrafficExtension(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteLbTrafficExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteLbTrafficExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateLbRouteExtensionProgress with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateLbRouteExtensionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteLbTrafficExtension with LRO error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteLbTrafficExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteLbTrafficExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteLbTrafficExtension = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteLbTrafficExtension(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteLbTrafficExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteLbTrafficExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateLbRouteExtension', () => { - it('invokes updateLbRouteExtension without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateLbRouteExtensionRequest() - ); - request.lbRouteExtension ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateLbRouteExtensionRequest', ['lbRouteExtension', 'name']); - request.lbRouteExtension.name = defaultValue1; - const expectedHeaderRequestParams = `lb_route_extension.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateLbRouteExtension = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateLbRouteExtension(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateLbRouteExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateLbRouteExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteLbTrafficExtensionProgress without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteLbTrafficExtensionProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateLbRouteExtension without error using callback', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateLbRouteExtensionRequest() - ); - request.lbRouteExtension ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateLbRouteExtensionRequest', ['lbRouteExtension', 'name']); - request.lbRouteExtension.name = defaultValue1; - const expectedHeaderRequestParams = `lb_route_extension.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateLbRouteExtension = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateLbRouteExtension( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateLbRouteExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateLbRouteExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteLbTrafficExtensionProgress with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteLbTrafficExtensionProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createLbRouteExtension', () => { + it('invokes createLbRouteExtension without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateLbRouteExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateLbRouteExtensionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createLbRouteExtension = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createLbRouteExtension(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createLbRouteExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createLbRouteExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateLbRouteExtension with call error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateLbRouteExtensionRequest() - ); - request.lbRouteExtension ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateLbRouteExtensionRequest', ['lbRouteExtension', 'name']); - request.lbRouteExtension.name = defaultValue1; - const expectedHeaderRequestParams = `lb_route_extension.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateLbRouteExtension = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateLbRouteExtension(request), expectedError); - const actualRequest = (client.innerApiCalls.updateLbRouteExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateLbRouteExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createLbRouteExtension without error using callback', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateLbRouteExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateLbRouteExtensionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createLbRouteExtension = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createLbRouteExtension( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1.ILbRouteExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1.ILbRouteExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createLbRouteExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createLbRouteExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateLbRouteExtension with LRO error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateLbRouteExtensionRequest() - ); - request.lbRouteExtension ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateLbRouteExtensionRequest', ['lbRouteExtension', 'name']); - request.lbRouteExtension.name = defaultValue1; - const expectedHeaderRequestParams = `lb_route_extension.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateLbRouteExtension = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateLbRouteExtension(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateLbRouteExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateLbRouteExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createLbRouteExtension with call error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateLbRouteExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateLbRouteExtensionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createLbRouteExtension = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.createLbRouteExtension(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createLbRouteExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createLbRouteExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateLbRouteExtensionProgress without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateLbRouteExtensionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createLbRouteExtension with LRO error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateLbRouteExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateLbRouteExtensionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createLbRouteExtension = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createLbRouteExtension(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createLbRouteExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createLbRouteExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateLbRouteExtensionProgress with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateLbRouteExtensionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateLbRouteExtensionProgress without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateLbRouteExtensionProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('deleteLbRouteExtension', () => { - it('invokes deleteLbRouteExtension without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteLbRouteExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteLbRouteExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteLbRouteExtension = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteLbRouteExtension(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteLbRouteExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteLbRouteExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateLbRouteExtensionProgress with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateLbRouteExtensionProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateLbRouteExtension', () => { + it('invokes updateLbRouteExtension without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateLbRouteExtensionRequest(), + ); + request.lbRouteExtension ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateLbRouteExtensionRequest', + ['lbRouteExtension', 'name'], + ); + request.lbRouteExtension.name = defaultValue1; + const expectedHeaderRequestParams = `lb_route_extension.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateLbRouteExtension = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateLbRouteExtension(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateLbRouteExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateLbRouteExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteLbRouteExtension without error using callback', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteLbRouteExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteLbRouteExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteLbRouteExtension = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteLbRouteExtension( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteLbRouteExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteLbRouteExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateLbRouteExtension without error using callback', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateLbRouteExtensionRequest(), + ); + request.lbRouteExtension ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateLbRouteExtensionRequest', + ['lbRouteExtension', 'name'], + ); + request.lbRouteExtension.name = defaultValue1; + const expectedHeaderRequestParams = `lb_route_extension.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateLbRouteExtension = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateLbRouteExtension( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1.ILbRouteExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1.ILbRouteExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateLbRouteExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateLbRouteExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteLbRouteExtension with call error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteLbRouteExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteLbRouteExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteLbRouteExtension = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteLbRouteExtension(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteLbRouteExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteLbRouteExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateLbRouteExtension with call error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateLbRouteExtensionRequest(), + ); + request.lbRouteExtension ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateLbRouteExtensionRequest', + ['lbRouteExtension', 'name'], + ); + request.lbRouteExtension.name = defaultValue1; + const expectedHeaderRequestParams = `lb_route_extension.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateLbRouteExtension = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.updateLbRouteExtension(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.updateLbRouteExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateLbRouteExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteLbRouteExtension with LRO error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteLbRouteExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteLbRouteExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteLbRouteExtension = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteLbRouteExtension(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteLbRouteExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteLbRouteExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateLbRouteExtension with LRO error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateLbRouteExtensionRequest(), + ); + request.lbRouteExtension ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateLbRouteExtensionRequest', + ['lbRouteExtension', 'name'], + ); + request.lbRouteExtension.name = defaultValue1; + const expectedHeaderRequestParams = `lb_route_extension.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateLbRouteExtension = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateLbRouteExtension(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateLbRouteExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateLbRouteExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteLbRouteExtensionProgress without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteLbRouteExtensionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateLbRouteExtensionProgress without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateLbRouteExtensionProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteLbRouteExtensionProgress with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteLbRouteExtensionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpdateLbRouteExtensionProgress with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateLbRouteExtensionProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteLbRouteExtension', () => { + it('invokes deleteLbRouteExtension without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteLbRouteExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteLbRouteExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteLbRouteExtension = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteLbRouteExtension(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteLbRouteExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteLbRouteExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createLbEdgeExtension', () => { - it('invokes createLbEdgeExtension without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateLbEdgeExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateLbEdgeExtensionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createLbEdgeExtension = stubLongRunningCall(expectedResponse); - const [operation] = await client.createLbEdgeExtension(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createLbEdgeExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createLbEdgeExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteLbRouteExtension without error using callback', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteLbRouteExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteLbRouteExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteLbRouteExtension = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteLbRouteExtension( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteLbRouteExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteLbRouteExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createLbEdgeExtension without error using callback', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateLbEdgeExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateLbEdgeExtensionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createLbEdgeExtension = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createLbEdgeExtension( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createLbEdgeExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createLbEdgeExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteLbRouteExtension with call error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteLbRouteExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteLbRouteExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteLbRouteExtension = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.deleteLbRouteExtension(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteLbRouteExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteLbRouteExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createLbEdgeExtension with call error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateLbEdgeExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateLbEdgeExtensionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createLbEdgeExtension = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createLbEdgeExtension(request), expectedError); - const actualRequest = (client.innerApiCalls.createLbEdgeExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createLbEdgeExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteLbRouteExtension with LRO error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteLbRouteExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteLbRouteExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteLbRouteExtension = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteLbRouteExtension(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteLbRouteExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteLbRouteExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createLbEdgeExtension with LRO error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateLbEdgeExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateLbEdgeExtensionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createLbEdgeExtension = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createLbEdgeExtension(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createLbEdgeExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createLbEdgeExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteLbRouteExtensionProgress without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteLbRouteExtensionProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkCreateLbEdgeExtensionProgress without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateLbEdgeExtensionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkDeleteLbRouteExtensionProgress with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteLbRouteExtensionProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createLbEdgeExtension', () => { + it('invokes createLbEdgeExtension without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateLbEdgeExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateLbEdgeExtensionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createLbEdgeExtension = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createLbEdgeExtension(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createLbEdgeExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createLbEdgeExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateLbEdgeExtensionProgress with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateLbEdgeExtensionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createLbEdgeExtension without error using callback', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateLbEdgeExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateLbEdgeExtensionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createLbEdgeExtension = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createLbEdgeExtension( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1.ILbEdgeExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1.ILbEdgeExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createLbEdgeExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createLbEdgeExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateLbEdgeExtension', () => { - it('invokes updateLbEdgeExtension without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateLbEdgeExtensionRequest() - ); - request.lbEdgeExtension ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateLbEdgeExtensionRequest', ['lbEdgeExtension', 'name']); - request.lbEdgeExtension.name = defaultValue1; - const expectedHeaderRequestParams = `lb_edge_extension.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateLbEdgeExtension = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateLbEdgeExtension(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateLbEdgeExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateLbEdgeExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createLbEdgeExtension with call error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateLbEdgeExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateLbEdgeExtensionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createLbEdgeExtension = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.createLbEdgeExtension(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createLbEdgeExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createLbEdgeExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateLbEdgeExtension without error using callback', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateLbEdgeExtensionRequest() - ); - request.lbEdgeExtension ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateLbEdgeExtensionRequest', ['lbEdgeExtension', 'name']); - request.lbEdgeExtension.name = defaultValue1; - const expectedHeaderRequestParams = `lb_edge_extension.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateLbEdgeExtension = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateLbEdgeExtension( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateLbEdgeExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateLbEdgeExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createLbEdgeExtension with LRO error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateLbEdgeExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateLbEdgeExtensionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createLbEdgeExtension = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createLbEdgeExtension(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createLbEdgeExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createLbEdgeExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateLbEdgeExtension with call error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateLbEdgeExtensionRequest() - ); - request.lbEdgeExtension ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateLbEdgeExtensionRequest', ['lbEdgeExtension', 'name']); - request.lbEdgeExtension.name = defaultValue1; - const expectedHeaderRequestParams = `lb_edge_extension.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateLbEdgeExtension = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateLbEdgeExtension(request), expectedError); - const actualRequest = (client.innerApiCalls.updateLbEdgeExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateLbEdgeExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateLbEdgeExtensionProgress without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateLbEdgeExtensionProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateLbEdgeExtension with LRO error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateLbEdgeExtensionRequest() - ); - request.lbEdgeExtension ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateLbEdgeExtensionRequest', ['lbEdgeExtension', 'name']); - request.lbEdgeExtension.name = defaultValue1; - const expectedHeaderRequestParams = `lb_edge_extension.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateLbEdgeExtension = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateLbEdgeExtension(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateLbEdgeExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateLbEdgeExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateLbEdgeExtensionProgress with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateLbEdgeExtensionProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateLbEdgeExtension', () => { + it('invokes updateLbEdgeExtension without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateLbEdgeExtensionRequest(), + ); + request.lbEdgeExtension ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateLbEdgeExtensionRequest', + ['lbEdgeExtension', 'name'], + ); + request.lbEdgeExtension.name = defaultValue1; + const expectedHeaderRequestParams = `lb_edge_extension.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateLbEdgeExtension = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateLbEdgeExtension(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateLbEdgeExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateLbEdgeExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateLbEdgeExtensionProgress without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateLbEdgeExtensionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateLbEdgeExtension without error using callback', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateLbEdgeExtensionRequest(), + ); + request.lbEdgeExtension ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateLbEdgeExtensionRequest', + ['lbEdgeExtension', 'name'], + ); + request.lbEdgeExtension.name = defaultValue1; + const expectedHeaderRequestParams = `lb_edge_extension.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateLbEdgeExtension = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateLbEdgeExtension( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1.ILbEdgeExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1.ILbEdgeExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateLbEdgeExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateLbEdgeExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateLbEdgeExtensionProgress with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateLbEdgeExtensionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateLbEdgeExtension with call error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateLbEdgeExtensionRequest(), + ); + request.lbEdgeExtension ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateLbEdgeExtensionRequest', + ['lbEdgeExtension', 'name'], + ); + request.lbEdgeExtension.name = defaultValue1; + const expectedHeaderRequestParams = `lb_edge_extension.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateLbEdgeExtension = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.updateLbEdgeExtension(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.updateLbEdgeExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateLbEdgeExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteLbEdgeExtension', () => { - it('invokes deleteLbEdgeExtension without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteLbEdgeExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteLbEdgeExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteLbEdgeExtension = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteLbEdgeExtension(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteLbEdgeExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteLbEdgeExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateLbEdgeExtension with LRO error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateLbEdgeExtensionRequest(), + ); + request.lbEdgeExtension ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateLbEdgeExtensionRequest', + ['lbEdgeExtension', 'name'], + ); + request.lbEdgeExtension.name = defaultValue1; + const expectedHeaderRequestParams = `lb_edge_extension.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateLbEdgeExtension = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateLbEdgeExtension(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateLbEdgeExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateLbEdgeExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteLbEdgeExtension without error using callback', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteLbEdgeExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteLbEdgeExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteLbEdgeExtension = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteLbEdgeExtension( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteLbEdgeExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteLbEdgeExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateLbEdgeExtensionProgress without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateLbEdgeExtensionProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteLbEdgeExtension with call error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteLbEdgeExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteLbEdgeExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteLbEdgeExtension = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteLbEdgeExtension(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteLbEdgeExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteLbEdgeExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateLbEdgeExtensionProgress with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateLbEdgeExtensionProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteLbEdgeExtension', () => { + it('invokes deleteLbEdgeExtension without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteLbEdgeExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteLbEdgeExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteLbEdgeExtension = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteLbEdgeExtension(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteLbEdgeExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteLbEdgeExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteLbEdgeExtension with LRO error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteLbEdgeExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteLbEdgeExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteLbEdgeExtension = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteLbEdgeExtension(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteLbEdgeExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteLbEdgeExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteLbEdgeExtension without error using callback', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteLbEdgeExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteLbEdgeExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteLbEdgeExtension = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteLbEdgeExtension( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteLbEdgeExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteLbEdgeExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteLbEdgeExtensionProgress without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteLbEdgeExtensionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteLbEdgeExtension with call error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteLbEdgeExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteLbEdgeExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteLbEdgeExtension = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.deleteLbEdgeExtension(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteLbEdgeExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteLbEdgeExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteLbEdgeExtensionProgress with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteLbEdgeExtensionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteLbEdgeExtension with LRO error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteLbEdgeExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteLbEdgeExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteLbEdgeExtension = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteLbEdgeExtension(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteLbEdgeExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteLbEdgeExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createAuthzExtension', () => { - it('invokes createAuthzExtension without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateAuthzExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateAuthzExtensionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createAuthzExtension = stubLongRunningCall(expectedResponse); - const [operation] = await client.createAuthzExtension(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createAuthzExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createAuthzExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteLbEdgeExtensionProgress without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteLbEdgeExtensionProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createAuthzExtension without error using callback', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateAuthzExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateAuthzExtensionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createAuthzExtension = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createAuthzExtension( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createAuthzExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createAuthzExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteLbEdgeExtensionProgress with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteLbEdgeExtensionProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createAuthzExtension', () => { + it('invokes createAuthzExtension without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateAuthzExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateAuthzExtensionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createAuthzExtension = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createAuthzExtension(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createAuthzExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createAuthzExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createAuthzExtension with call error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateAuthzExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateAuthzExtensionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createAuthzExtension = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createAuthzExtension(request), expectedError); - const actualRequest = (client.innerApiCalls.createAuthzExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createAuthzExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createAuthzExtension without error using callback', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateAuthzExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateAuthzExtensionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createAuthzExtension = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createAuthzExtension( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1.IAuthzExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1.IAuthzExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createAuthzExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createAuthzExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createAuthzExtension with LRO error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateAuthzExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateAuthzExtensionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createAuthzExtension = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createAuthzExtension(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createAuthzExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createAuthzExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createAuthzExtension with call error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateAuthzExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateAuthzExtensionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createAuthzExtension = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createAuthzExtension(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createAuthzExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createAuthzExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateAuthzExtensionProgress without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateAuthzExtensionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createAuthzExtension with LRO error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateAuthzExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateAuthzExtensionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createAuthzExtension = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createAuthzExtension(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createAuthzExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createAuthzExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateAuthzExtensionProgress with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateAuthzExtensionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateAuthzExtensionProgress without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateAuthzExtensionProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('updateAuthzExtension', () => { - it('invokes updateAuthzExtension without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateAuthzExtensionRequest() - ); - request.authzExtension ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateAuthzExtensionRequest', ['authzExtension', 'name']); - request.authzExtension.name = defaultValue1; - const expectedHeaderRequestParams = `authz_extension.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateAuthzExtension = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateAuthzExtension(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateAuthzExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAuthzExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateAuthzExtensionProgress with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateAuthzExtensionProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateAuthzExtension', () => { + it('invokes updateAuthzExtension without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateAuthzExtensionRequest(), + ); + request.authzExtension ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateAuthzExtensionRequest', + ['authzExtension', 'name'], + ); + request.authzExtension.name = defaultValue1; + const expectedHeaderRequestParams = `authz_extension.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateAuthzExtension = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateAuthzExtension(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateAuthzExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateAuthzExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateAuthzExtension without error using callback', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateAuthzExtensionRequest() - ); - request.authzExtension ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateAuthzExtensionRequest', ['authzExtension', 'name']); - request.authzExtension.name = defaultValue1; - const expectedHeaderRequestParams = `authz_extension.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateAuthzExtension = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateAuthzExtension( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateAuthzExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAuthzExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateAuthzExtension without error using callback', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateAuthzExtensionRequest(), + ); + request.authzExtension ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateAuthzExtensionRequest', + ['authzExtension', 'name'], + ); + request.authzExtension.name = defaultValue1; + const expectedHeaderRequestParams = `authz_extension.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateAuthzExtension = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateAuthzExtension( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1.IAuthzExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1.IAuthzExtension, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateAuthzExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateAuthzExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateAuthzExtension with call error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateAuthzExtensionRequest() - ); - request.authzExtension ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateAuthzExtensionRequest', ['authzExtension', 'name']); - request.authzExtension.name = defaultValue1; - const expectedHeaderRequestParams = `authz_extension.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateAuthzExtension = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateAuthzExtension(request), expectedError); - const actualRequest = (client.innerApiCalls.updateAuthzExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAuthzExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateAuthzExtension with call error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateAuthzExtensionRequest(), + ); + request.authzExtension ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateAuthzExtensionRequest', + ['authzExtension', 'name'], + ); + request.authzExtension.name = defaultValue1; + const expectedHeaderRequestParams = `authz_extension.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateAuthzExtension = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateAuthzExtension(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateAuthzExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateAuthzExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateAuthzExtension with LRO error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateAuthzExtensionRequest() - ); - request.authzExtension ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateAuthzExtensionRequest', ['authzExtension', 'name']); - request.authzExtension.name = defaultValue1; - const expectedHeaderRequestParams = `authz_extension.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateAuthzExtension = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateAuthzExtension(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateAuthzExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAuthzExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateAuthzExtension with LRO error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateAuthzExtensionRequest(), + ); + request.authzExtension ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateAuthzExtensionRequest', + ['authzExtension', 'name'], + ); + request.authzExtension.name = defaultValue1; + const expectedHeaderRequestParams = `authz_extension.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateAuthzExtension = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateAuthzExtension(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateAuthzExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateAuthzExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateAuthzExtensionProgress without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateAuthzExtensionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateAuthzExtensionProgress without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateAuthzExtensionProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkUpdateAuthzExtensionProgress with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateAuthzExtensionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpdateAuthzExtensionProgress with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateAuthzExtensionProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteAuthzExtension', () => { + it('invokes deleteAuthzExtension without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteAuthzExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteAuthzExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteAuthzExtension = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteAuthzExtension(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteAuthzExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteAuthzExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteAuthzExtension', () => { - it('invokes deleteAuthzExtension without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteAuthzExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteAuthzExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteAuthzExtension = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteAuthzExtension(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteAuthzExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteAuthzExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteAuthzExtension without error using callback', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteAuthzExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteAuthzExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteAuthzExtension = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteAuthzExtension( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteAuthzExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteAuthzExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteAuthzExtension without error using callback', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteAuthzExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteAuthzExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteAuthzExtension = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteAuthzExtension( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteAuthzExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteAuthzExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteAuthzExtension with call error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteAuthzExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteAuthzExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteAuthzExtension = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteAuthzExtension(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteAuthzExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteAuthzExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteAuthzExtension with call error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteAuthzExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteAuthzExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteAuthzExtension = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteAuthzExtension(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteAuthzExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteAuthzExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteAuthzExtension with LRO error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteAuthzExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteAuthzExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteAuthzExtension = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteAuthzExtension(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteAuthzExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteAuthzExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteAuthzExtension with LRO error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteAuthzExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteAuthzExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteAuthzExtension = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteAuthzExtension(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteAuthzExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteAuthzExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteAuthzExtensionProgress without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteAuthzExtensionProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteAuthzExtensionProgress without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteAuthzExtensionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkDeleteAuthzExtensionProgress with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteAuthzExtensionProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listLbTrafficExtensions', () => { + it('invokes listLbTrafficExtensions without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListLbTrafficExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListLbTrafficExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbTrafficExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbTrafficExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbTrafficExtension(), + ), + ]; + client.innerApiCalls.listLbTrafficExtensions = + stubSimpleCall(expectedResponse); + const [response] = await client.listLbTrafficExtensions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listLbTrafficExtensions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listLbTrafficExtensions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteAuthzExtensionProgress with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteAuthzExtensionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes listLbTrafficExtensions without error using callback', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListLbTrafficExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListLbTrafficExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbTrafficExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbTrafficExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbTrafficExtension(), + ), + ]; + client.innerApiCalls.listLbTrafficExtensions = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listLbTrafficExtensions( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkservices.v1.ILbTrafficExtension[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listLbTrafficExtensions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listLbTrafficExtensions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listLbTrafficExtensions', () => { - it('invokes listLbTrafficExtensions without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListLbTrafficExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListLbTrafficExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbTrafficExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbTrafficExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbTrafficExtension()), - ]; - client.innerApiCalls.listLbTrafficExtensions = stubSimpleCall(expectedResponse); - const [response] = await client.listLbTrafficExtensions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listLbTrafficExtensions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listLbTrafficExtensions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listLbTrafficExtensions with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListLbTrafficExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListLbTrafficExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listLbTrafficExtensions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listLbTrafficExtensions(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listLbTrafficExtensions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listLbTrafficExtensions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listLbTrafficExtensions without error using callback', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListLbTrafficExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListLbTrafficExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbTrafficExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbTrafficExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbTrafficExtension()), - ]; - client.innerApiCalls.listLbTrafficExtensions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listLbTrafficExtensions( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.ILbTrafficExtension[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listLbTrafficExtensions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listLbTrafficExtensions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listLbTrafficExtensionsStream without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListLbTrafficExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListLbTrafficExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbTrafficExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbTrafficExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbTrafficExtension(), + ), + ]; + client.descriptors.page.listLbTrafficExtensions.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listLbTrafficExtensionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.LbTrafficExtension[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkservices.v1.LbTrafficExtension, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listLbTrafficExtensions + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listLbTrafficExtensions, request), + ); + assert( + ( + client.descriptors.page.listLbTrafficExtensions + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listLbTrafficExtensions with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListLbTrafficExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListLbTrafficExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listLbTrafficExtensions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listLbTrafficExtensions(request), expectedError); - const actualRequest = (client.innerApiCalls.listLbTrafficExtensions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listLbTrafficExtensions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listLbTrafficExtensionsStream with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListLbTrafficExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListLbTrafficExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listLbTrafficExtensions.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listLbTrafficExtensionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.LbTrafficExtension[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkservices.v1.LbTrafficExtension, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listLbTrafficExtensions + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listLbTrafficExtensions, request), + ); + assert( + ( + client.descriptors.page.listLbTrafficExtensions + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listLbTrafficExtensionsStream without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListLbTrafficExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListLbTrafficExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbTrafficExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbTrafficExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbTrafficExtension()), - ]; - client.descriptors.page.listLbTrafficExtensions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listLbTrafficExtensionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.LbTrafficExtension[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.LbTrafficExtension) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listLbTrafficExtensions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listLbTrafficExtensions, request)); - assert( - (client.descriptors.page.listLbTrafficExtensions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listLbTrafficExtensions without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListLbTrafficExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListLbTrafficExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbTrafficExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbTrafficExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbTrafficExtension(), + ), + ]; + client.descriptors.page.listLbTrafficExtensions.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkservices.v1.ILbTrafficExtension[] = + []; + const iterable = client.listLbTrafficExtensionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listLbTrafficExtensions + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listLbTrafficExtensions + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listLbTrafficExtensionsStream with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListLbTrafficExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListLbTrafficExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listLbTrafficExtensions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listLbTrafficExtensionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.LbTrafficExtension[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.LbTrafficExtension) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listLbTrafficExtensions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listLbTrafficExtensions, request)); - assert( - (client.descriptors.page.listLbTrafficExtensions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listLbTrafficExtensions with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListLbTrafficExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListLbTrafficExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listLbTrafficExtensions.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLbTrafficExtensionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkservices.v1.ILbTrafficExtension[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listLbTrafficExtensions + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listLbTrafficExtensions + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('listLbRouteExtensions', () => { + it('invokes listLbRouteExtensions without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListLbRouteExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListLbRouteExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbRouteExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbRouteExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbRouteExtension(), + ), + ]; + client.innerApiCalls.listLbRouteExtensions = + stubSimpleCall(expectedResponse); + const [response] = await client.listLbRouteExtensions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listLbRouteExtensions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listLbRouteExtensions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listLbTrafficExtensions without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListLbTrafficExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListLbTrafficExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbTrafficExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbTrafficExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbTrafficExtension()), - ]; - client.descriptors.page.listLbTrafficExtensions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkservices.v1.ILbTrafficExtension[] = []; - const iterable = client.listLbTrafficExtensionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listLbRouteExtensions without error using callback', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListLbRouteExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListLbRouteExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbRouteExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbRouteExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbRouteExtension(), + ), + ]; + client.innerApiCalls.listLbRouteExtensions = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listLbRouteExtensions( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkservices.v1.ILbRouteExtension[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listLbTrafficExtensions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listLbTrafficExtensions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listLbTrafficExtensions with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListLbTrafficExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListLbTrafficExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listLbTrafficExtensions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLbTrafficExtensionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkservices.v1.ILbTrafficExtension[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listLbTrafficExtensions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listLbTrafficExtensions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listLbRouteExtensions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listLbRouteExtensions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listLbRouteExtensions', () => { - it('invokes listLbRouteExtensions without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListLbRouteExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListLbRouteExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbRouteExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbRouteExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbRouteExtension()), - ]; - client.innerApiCalls.listLbRouteExtensions = stubSimpleCall(expectedResponse); - const [response] = await client.listLbRouteExtensions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listLbRouteExtensions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listLbRouteExtensions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listLbRouteExtensions with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListLbRouteExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListLbRouteExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listLbRouteExtensions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listLbRouteExtensions(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listLbRouteExtensions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listLbRouteExtensions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listLbRouteExtensions without error using callback', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListLbRouteExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListLbRouteExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbRouteExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbRouteExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbRouteExtension()), - ]; - client.innerApiCalls.listLbRouteExtensions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listLbRouteExtensions( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.ILbRouteExtension[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listLbRouteExtensions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listLbRouteExtensions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listLbRouteExtensionsStream without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListLbRouteExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListLbRouteExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbRouteExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbRouteExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbRouteExtension(), + ), + ]; + client.descriptors.page.listLbRouteExtensions.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listLbRouteExtensionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.LbRouteExtension[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkservices.v1.LbRouteExtension, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listLbRouteExtensions + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listLbRouteExtensions, request), + ); + assert( + ( + client.descriptors.page.listLbRouteExtensions + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listLbRouteExtensions with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListLbRouteExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListLbRouteExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listLbRouteExtensions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listLbRouteExtensions(request), expectedError); - const actualRequest = (client.innerApiCalls.listLbRouteExtensions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listLbRouteExtensions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listLbRouteExtensionsStream with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListLbRouteExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListLbRouteExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listLbRouteExtensions.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listLbRouteExtensionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.LbRouteExtension[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkservices.v1.LbRouteExtension, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listLbRouteExtensions + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listLbRouteExtensions, request), + ); + assert( + ( + client.descriptors.page.listLbRouteExtensions + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listLbRouteExtensionsStream without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListLbRouteExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListLbRouteExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbRouteExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbRouteExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbRouteExtension()), - ]; - client.descriptors.page.listLbRouteExtensions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listLbRouteExtensionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.LbRouteExtension[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.LbRouteExtension) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listLbRouteExtensions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listLbRouteExtensions, request)); - assert( - (client.descriptors.page.listLbRouteExtensions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listLbRouteExtensions without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListLbRouteExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListLbRouteExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbRouteExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbRouteExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbRouteExtension(), + ), + ]; + client.descriptors.page.listLbRouteExtensions.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkservices.v1.ILbRouteExtension[] = + []; + const iterable = client.listLbRouteExtensionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listLbRouteExtensions + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listLbRouteExtensions + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listLbRouteExtensionsStream with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListLbRouteExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListLbRouteExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listLbRouteExtensions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listLbRouteExtensionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.LbRouteExtension[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.LbRouteExtension) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listLbRouteExtensions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listLbRouteExtensions, request)); - assert( - (client.descriptors.page.listLbRouteExtensions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listLbRouteExtensions with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListLbRouteExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListLbRouteExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listLbRouteExtensions.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLbRouteExtensionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkservices.v1.ILbRouteExtension[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listLbRouteExtensions + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listLbRouteExtensions + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('listLbEdgeExtensions', () => { + it('invokes listLbEdgeExtensions without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListLbEdgeExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListLbEdgeExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbEdgeExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbEdgeExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbEdgeExtension(), + ), + ]; + client.innerApiCalls.listLbEdgeExtensions = + stubSimpleCall(expectedResponse); + const [response] = await client.listLbEdgeExtensions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listLbEdgeExtensions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listLbEdgeExtensions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listLbRouteExtensions without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListLbRouteExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListLbRouteExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbRouteExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbRouteExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbRouteExtension()), - ]; - client.descriptors.page.listLbRouteExtensions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkservices.v1.ILbRouteExtension[] = []; - const iterable = client.listLbRouteExtensionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listLbEdgeExtensions without error using callback', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListLbEdgeExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListLbEdgeExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbEdgeExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbEdgeExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbEdgeExtension(), + ), + ]; + client.innerApiCalls.listLbEdgeExtensions = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listLbEdgeExtensions( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkservices.v1.ILbEdgeExtension[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listLbRouteExtensions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listLbRouteExtensions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listLbRouteExtensions with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListLbRouteExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListLbRouteExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listLbRouteExtensions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLbRouteExtensionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkservices.v1.ILbRouteExtension[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listLbRouteExtensions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listLbRouteExtensions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listLbEdgeExtensions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listLbEdgeExtensions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listLbEdgeExtensions', () => { - it('invokes listLbEdgeExtensions without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListLbEdgeExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListLbEdgeExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbEdgeExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbEdgeExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbEdgeExtension()), - ]; - client.innerApiCalls.listLbEdgeExtensions = stubSimpleCall(expectedResponse); - const [response] = await client.listLbEdgeExtensions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listLbEdgeExtensions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listLbEdgeExtensions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listLbEdgeExtensions with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListLbEdgeExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListLbEdgeExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listLbEdgeExtensions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listLbEdgeExtensions(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listLbEdgeExtensions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listLbEdgeExtensions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listLbEdgeExtensions without error using callback', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListLbEdgeExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListLbEdgeExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbEdgeExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbEdgeExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbEdgeExtension()), - ]; - client.innerApiCalls.listLbEdgeExtensions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listLbEdgeExtensions( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.ILbEdgeExtension[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listLbEdgeExtensions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listLbEdgeExtensions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listLbEdgeExtensionsStream without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListLbEdgeExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListLbEdgeExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbEdgeExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbEdgeExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbEdgeExtension(), + ), + ]; + client.descriptors.page.listLbEdgeExtensions.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listLbEdgeExtensionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.LbEdgeExtension[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkservices.v1.LbEdgeExtension, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listLbEdgeExtensions.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listLbEdgeExtensions, request), + ); + assert( + (client.descriptors.page.listLbEdgeExtensions.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listLbEdgeExtensions with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListLbEdgeExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListLbEdgeExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listLbEdgeExtensions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listLbEdgeExtensions(request), expectedError); - const actualRequest = (client.innerApiCalls.listLbEdgeExtensions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listLbEdgeExtensions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listLbEdgeExtensionsStream with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListLbEdgeExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListLbEdgeExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listLbEdgeExtensions.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listLbEdgeExtensionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.LbEdgeExtension[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkservices.v1.LbEdgeExtension, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listLbEdgeExtensions.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listLbEdgeExtensions, request), + ); + assert( + (client.descriptors.page.listLbEdgeExtensions.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listLbEdgeExtensionsStream without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListLbEdgeExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListLbEdgeExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbEdgeExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbEdgeExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbEdgeExtension()), - ]; - client.descriptors.page.listLbEdgeExtensions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listLbEdgeExtensionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.LbEdgeExtension[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.LbEdgeExtension) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listLbEdgeExtensions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listLbEdgeExtensions, request)); - assert( - (client.descriptors.page.listLbEdgeExtensions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listLbEdgeExtensions without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListLbEdgeExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListLbEdgeExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbEdgeExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbEdgeExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.LbEdgeExtension(), + ), + ]; + client.descriptors.page.listLbEdgeExtensions.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkservices.v1.ILbEdgeExtension[] = + []; + const iterable = client.listLbEdgeExtensionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listLbEdgeExtensions.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listLbEdgeExtensions.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listLbEdgeExtensionsStream with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListLbEdgeExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListLbEdgeExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listLbEdgeExtensions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listLbEdgeExtensionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.LbEdgeExtension[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.LbEdgeExtension) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listLbEdgeExtensions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listLbEdgeExtensions, request)); - assert( - (client.descriptors.page.listLbEdgeExtensions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listLbEdgeExtensions with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListLbEdgeExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListLbEdgeExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listLbEdgeExtensions.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLbEdgeExtensionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkservices.v1.ILbEdgeExtension[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listLbEdgeExtensions.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listLbEdgeExtensions.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listAuthzExtensions', () => { + it('invokes listAuthzExtensions without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListAuthzExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListAuthzExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.AuthzExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.AuthzExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.AuthzExtension(), + ), + ]; + client.innerApiCalls.listAuthzExtensions = + stubSimpleCall(expectedResponse); + const [response] = await client.listAuthzExtensions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listAuthzExtensions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAuthzExtensions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listLbEdgeExtensions without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListLbEdgeExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListLbEdgeExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbEdgeExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbEdgeExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.LbEdgeExtension()), - ]; - client.descriptors.page.listLbEdgeExtensions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkservices.v1.ILbEdgeExtension[] = []; - const iterable = client.listLbEdgeExtensionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listAuthzExtensions without error using callback', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListAuthzExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListAuthzExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.AuthzExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.AuthzExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.AuthzExtension(), + ), + ]; + client.innerApiCalls.listAuthzExtensions = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listAuthzExtensions( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkservices.v1.IAuthzExtension[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listLbEdgeExtensions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listLbEdgeExtensions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listLbEdgeExtensions with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListLbEdgeExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListLbEdgeExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listLbEdgeExtensions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLbEdgeExtensionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkservices.v1.ILbEdgeExtension[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listLbEdgeExtensions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listLbEdgeExtensions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listAuthzExtensions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAuthzExtensions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listAuthzExtensions', () => { - it('invokes listAuthzExtensions without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListAuthzExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListAuthzExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.AuthzExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.AuthzExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.AuthzExtension()), - ]; - client.innerApiCalls.listAuthzExtensions = stubSimpleCall(expectedResponse); - const [response] = await client.listAuthzExtensions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listAuthzExtensions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAuthzExtensions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listAuthzExtensions without error using callback', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListAuthzExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListAuthzExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.AuthzExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.AuthzExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.AuthzExtension()), - ]; - client.innerApiCalls.listAuthzExtensions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listAuthzExtensions( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.IAuthzExtension[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listAuthzExtensions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAuthzExtensions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listAuthzExtensions with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListAuthzExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListAuthzExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listAuthzExtensions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listAuthzExtensions(request), expectedError); - const actualRequest = (client.innerApiCalls.listAuthzExtensions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAuthzExtensions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listAuthzExtensions with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListAuthzExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListAuthzExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listAuthzExtensions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listAuthzExtensions(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listAuthzExtensions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAuthzExtensions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listAuthzExtensionsStream without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListAuthzExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListAuthzExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.AuthzExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.AuthzExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.AuthzExtension()), - ]; - client.descriptors.page.listAuthzExtensions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listAuthzExtensionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.AuthzExtension[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.AuthzExtension) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listAuthzExtensions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAuthzExtensions, request)); - assert( - (client.descriptors.page.listAuthzExtensions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listAuthzExtensionsStream without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListAuthzExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListAuthzExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.AuthzExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.AuthzExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.AuthzExtension(), + ), + ]; + client.descriptors.page.listAuthzExtensions.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listAuthzExtensionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.AuthzExtension[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkservices.v1.AuthzExtension) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listAuthzExtensions.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listAuthzExtensions, request), + ); + assert( + (client.descriptors.page.listAuthzExtensions.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listAuthzExtensionsStream with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListAuthzExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListAuthzExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listAuthzExtensions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listAuthzExtensionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.AuthzExtension[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.AuthzExtension) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listAuthzExtensions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAuthzExtensions, request)); - assert( - (client.descriptors.page.listAuthzExtensions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listAuthzExtensionsStream with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListAuthzExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListAuthzExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listAuthzExtensions.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listAuthzExtensionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.AuthzExtension[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkservices.v1.AuthzExtension) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listAuthzExtensions.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listAuthzExtensions, request), + ); + assert( + (client.descriptors.page.listAuthzExtensions.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listAuthzExtensions without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListAuthzExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListAuthzExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.AuthzExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.AuthzExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.AuthzExtension()), - ]; - client.descriptors.page.listAuthzExtensions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkservices.v1.IAuthzExtension[] = []; - const iterable = client.listAuthzExtensionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listAuthzExtensions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listAuthzExtensions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listAuthzExtensions without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListAuthzExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListAuthzExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.AuthzExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.AuthzExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.AuthzExtension(), + ), + ]; + client.descriptors.page.listAuthzExtensions.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkservices.v1.IAuthzExtension[] = + []; + const iterable = client.listAuthzExtensionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listAuthzExtensions.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listAuthzExtensions.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listAuthzExtensions with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListAuthzExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListAuthzExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listAuthzExtensions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listAuthzExtensionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkservices.v1.IAuthzExtension[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listAuthzExtensions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listAuthzExtensions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listAuthzExtensions with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListAuthzExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListAuthzExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listAuthzExtensions.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAuthzExtensionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkservices.v1.IAuthzExtension[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listAuthzExtensions.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listAuthzExtensions.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy without error using callback', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes setIamPolicy with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); + }); + it('invokes testIamPermissions with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('authzExtension', async () => { + const fakePath = '/rendered/path/authzExtension'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + authz_extension: 'authzExtensionValue', + }; + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.authzExtensionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.authzExtensionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('authzExtensionPath', () => { + const result = client.authzExtensionPath( + 'projectValue', + 'locationValue', + 'authzExtensionValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.authzExtensionPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromAuthzExtensionName', () => { + const result = client.matchProjectFromAuthzExtensionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.authzExtensionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromAuthzExtensionName', () => { + const result = client.matchLocationFromAuthzExtensionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.authzExtensionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAuthzExtensionFromAuthzExtensionName', () => { + const result = + client.matchAuthzExtensionFromAuthzExtensionName(fakePath); + assert.strictEqual(result, 'authzExtensionValue'); + assert( + (client.pathTemplates.authzExtensionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('authzExtension', async () => { - const fakePath = "/rendered/path/authzExtension"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - authz_extension: "authzExtensionValue", - }; - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.authzExtensionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.authzExtensionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('authzExtensionPath', () => { - const result = client.authzExtensionPath("projectValue", "locationValue", "authzExtensionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.authzExtensionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAuthzExtensionName', () => { - const result = client.matchProjectFromAuthzExtensionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.authzExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAuthzExtensionName', () => { - const result = client.matchLocationFromAuthzExtensionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.authzExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAuthzExtensionFromAuthzExtensionName', () => { - const result = client.matchAuthzExtensionFromAuthzExtensionName(fakePath); - assert.strictEqual(result, "authzExtensionValue"); - assert((client.pathTemplates.authzExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('endpointPolicy', async () => { - const fakePath = "/rendered/path/endpointPolicy"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - endpoint_policy: "endpointPolicyValue", - }; - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.endpointPolicyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.endpointPolicyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('endpointPolicyPath', () => { - const result = client.endpointPolicyPath("projectValue", "locationValue", "endpointPolicyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.endpointPolicyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromEndpointPolicyName', () => { - const result = client.matchProjectFromEndpointPolicyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.endpointPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromEndpointPolicyName', () => { - const result = client.matchLocationFromEndpointPolicyName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.endpointPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEndpointPolicyFromEndpointPolicyName', () => { - const result = client.matchEndpointPolicyFromEndpointPolicyName(fakePath); - assert.strictEqual(result, "endpointPolicyValue"); - assert((client.pathTemplates.endpointPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('endpointPolicy', async () => { + const fakePath = '/rendered/path/endpointPolicy'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + endpoint_policy: 'endpointPolicyValue', + }; + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.endpointPolicyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.endpointPolicyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('endpointPolicyPath', () => { + const result = client.endpointPolicyPath( + 'projectValue', + 'locationValue', + 'endpointPolicyValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.endpointPolicyPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromEndpointPolicyName', () => { + const result = client.matchProjectFromEndpointPolicyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.endpointPolicyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromEndpointPolicyName', () => { + const result = client.matchLocationFromEndpointPolicyName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.endpointPolicyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEndpointPolicyFromEndpointPolicyName', () => { + const result = + client.matchEndpointPolicyFromEndpointPolicyName(fakePath); + assert.strictEqual(result, 'endpointPolicyValue'); + assert( + (client.pathTemplates.endpointPolicyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('gateway', async () => { - const fakePath = "/rendered/path/gateway"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - gateway: "gatewayValue", - }; - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.gatewayPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.gatewayPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('gatewayPath', () => { - const result = client.gatewayPath("projectValue", "locationValue", "gatewayValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.gatewayPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromGatewayName', () => { - const result = client.matchProjectFromGatewayName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.gatewayPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromGatewayName', () => { - const result = client.matchLocationFromGatewayName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.gatewayPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchGatewayFromGatewayName', () => { - const result = client.matchGatewayFromGatewayName(fakePath); - assert.strictEqual(result, "gatewayValue"); - assert((client.pathTemplates.gatewayPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('gateway', async () => { + const fakePath = '/rendered/path/gateway'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + gateway: 'gatewayValue', + }; + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.gatewayPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.gatewayPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('gatewayPath', () => { + const result = client.gatewayPath( + 'projectValue', + 'locationValue', + 'gatewayValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.gatewayPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromGatewayName', () => { + const result = client.matchProjectFromGatewayName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.gatewayPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromGatewayName', () => { + const result = client.matchLocationFromGatewayName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.gatewayPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchGatewayFromGatewayName', () => { + const result = client.matchGatewayFromGatewayName(fakePath); + assert.strictEqual(result, 'gatewayValue'); + assert( + (client.pathTemplates.gatewayPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('gatewayRouteView', async () => { - const fakePath = "/rendered/path/gatewayRouteView"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - gateway: "gatewayValue", - route_view: "routeViewValue", - }; - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.gatewayRouteViewPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.gatewayRouteViewPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('gatewayRouteViewPath', () => { - const result = client.gatewayRouteViewPath("projectValue", "locationValue", "gatewayValue", "routeViewValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.gatewayRouteViewPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromGatewayRouteViewName', () => { - const result = client.matchProjectFromGatewayRouteViewName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.gatewayRouteViewPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromGatewayRouteViewName', () => { - const result = client.matchLocationFromGatewayRouteViewName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.gatewayRouteViewPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchGatewayFromGatewayRouteViewName', () => { - const result = client.matchGatewayFromGatewayRouteViewName(fakePath); - assert.strictEqual(result, "gatewayValue"); - assert((client.pathTemplates.gatewayRouteViewPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRouteViewFromGatewayRouteViewName', () => { - const result = client.matchRouteViewFromGatewayRouteViewName(fakePath); - assert.strictEqual(result, "routeViewValue"); - assert((client.pathTemplates.gatewayRouteViewPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('gatewayRouteView', async () => { + const fakePath = '/rendered/path/gatewayRouteView'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + gateway: 'gatewayValue', + route_view: 'routeViewValue', + }; + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.gatewayRouteViewPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.gatewayRouteViewPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('gatewayRouteViewPath', () => { + const result = client.gatewayRouteViewPath( + 'projectValue', + 'locationValue', + 'gatewayValue', + 'routeViewValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.gatewayRouteViewPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromGatewayRouteViewName', () => { + const result = client.matchProjectFromGatewayRouteViewName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.gatewayRouteViewPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromGatewayRouteViewName', () => { + const result = client.matchLocationFromGatewayRouteViewName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.gatewayRouteViewPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchGatewayFromGatewayRouteViewName', () => { + const result = client.matchGatewayFromGatewayRouteViewName(fakePath); + assert.strictEqual(result, 'gatewayValue'); + assert( + (client.pathTemplates.gatewayRouteViewPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRouteViewFromGatewayRouteViewName', () => { + const result = client.matchRouteViewFromGatewayRouteViewName(fakePath); + assert.strictEqual(result, 'routeViewValue'); + assert( + (client.pathTemplates.gatewayRouteViewPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('grpcRoute', async () => { - const fakePath = "/rendered/path/grpcRoute"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - grpc_route: "grpcRouteValue", - }; - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.grpcRoutePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.grpcRoutePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('grpcRoutePath', () => { - const result = client.grpcRoutePath("projectValue", "locationValue", "grpcRouteValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.grpcRoutePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromGrpcRouteName', () => { - const result = client.matchProjectFromGrpcRouteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.grpcRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromGrpcRouteName', () => { - const result = client.matchLocationFromGrpcRouteName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.grpcRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchGrpcRouteFromGrpcRouteName', () => { - const result = client.matchGrpcRouteFromGrpcRouteName(fakePath); - assert.strictEqual(result, "grpcRouteValue"); - assert((client.pathTemplates.grpcRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('grpcRoute', async () => { + const fakePath = '/rendered/path/grpcRoute'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + grpc_route: 'grpcRouteValue', + }; + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.grpcRoutePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.grpcRoutePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('grpcRoutePath', () => { + const result = client.grpcRoutePath( + 'projectValue', + 'locationValue', + 'grpcRouteValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.grpcRoutePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromGrpcRouteName', () => { + const result = client.matchProjectFromGrpcRouteName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.grpcRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromGrpcRouteName', () => { + const result = client.matchLocationFromGrpcRouteName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.grpcRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchGrpcRouteFromGrpcRouteName', () => { + const result = client.matchGrpcRouteFromGrpcRouteName(fakePath); + assert.strictEqual(result, 'grpcRouteValue'); + assert( + (client.pathTemplates.grpcRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('httpRoute', async () => { - const fakePath = "/rendered/path/httpRoute"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - http_route: "httpRouteValue", - }; - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.httpRoutePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.httpRoutePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('httpRoutePath', () => { - const result = client.httpRoutePath("projectValue", "locationValue", "httpRouteValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.httpRoutePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromHttpRouteName', () => { - const result = client.matchProjectFromHttpRouteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.httpRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromHttpRouteName', () => { - const result = client.matchLocationFromHttpRouteName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.httpRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHttpRouteFromHttpRouteName', () => { - const result = client.matchHttpRouteFromHttpRouteName(fakePath); - assert.strictEqual(result, "httpRouteValue"); - assert((client.pathTemplates.httpRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('httpRoute', async () => { + const fakePath = '/rendered/path/httpRoute'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + http_route: 'httpRouteValue', + }; + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.httpRoutePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.httpRoutePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('httpRoutePath', () => { + const result = client.httpRoutePath( + 'projectValue', + 'locationValue', + 'httpRouteValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.httpRoutePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromHttpRouteName', () => { + const result = client.matchProjectFromHttpRouteName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.httpRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromHttpRouteName', () => { + const result = client.matchLocationFromHttpRouteName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.httpRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHttpRouteFromHttpRouteName', () => { + const result = client.matchHttpRouteFromHttpRouteName(fakePath); + assert.strictEqual(result, 'httpRouteValue'); + assert( + (client.pathTemplates.httpRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('lbEdgeExtension', async () => { - const fakePath = "/rendered/path/lbEdgeExtension"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - lb_edge_extension: "lbEdgeExtensionValue", - }; - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.lbEdgeExtensionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.lbEdgeExtensionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('lbEdgeExtensionPath', () => { - const result = client.lbEdgeExtensionPath("projectValue", "locationValue", "lbEdgeExtensionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.lbEdgeExtensionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLbEdgeExtensionName', () => { - const result = client.matchProjectFromLbEdgeExtensionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.lbEdgeExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLbEdgeExtensionName', () => { - const result = client.matchLocationFromLbEdgeExtensionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.lbEdgeExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLbEdgeExtensionFromLbEdgeExtensionName', () => { - const result = client.matchLbEdgeExtensionFromLbEdgeExtensionName(fakePath); - assert.strictEqual(result, "lbEdgeExtensionValue"); - assert((client.pathTemplates.lbEdgeExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('lbEdgeExtension', async () => { + const fakePath = '/rendered/path/lbEdgeExtension'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + lb_edge_extension: 'lbEdgeExtensionValue', + }; + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.lbEdgeExtensionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.lbEdgeExtensionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('lbEdgeExtensionPath', () => { + const result = client.lbEdgeExtensionPath( + 'projectValue', + 'locationValue', + 'lbEdgeExtensionValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.lbEdgeExtensionPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLbEdgeExtensionName', () => { + const result = client.matchProjectFromLbEdgeExtensionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.lbEdgeExtensionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLbEdgeExtensionName', () => { + const result = client.matchLocationFromLbEdgeExtensionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.lbEdgeExtensionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLbEdgeExtensionFromLbEdgeExtensionName', () => { + const result = + client.matchLbEdgeExtensionFromLbEdgeExtensionName(fakePath); + assert.strictEqual(result, 'lbEdgeExtensionValue'); + assert( + (client.pathTemplates.lbEdgeExtensionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('lbRouteExtension', async () => { - const fakePath = "/rendered/path/lbRouteExtension"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - lb_route_extension: "lbRouteExtensionValue", - }; - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.lbRouteExtensionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.lbRouteExtensionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('lbRouteExtensionPath', () => { - const result = client.lbRouteExtensionPath("projectValue", "locationValue", "lbRouteExtensionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.lbRouteExtensionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLbRouteExtensionName', () => { - const result = client.matchProjectFromLbRouteExtensionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.lbRouteExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLbRouteExtensionName', () => { - const result = client.matchLocationFromLbRouteExtensionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.lbRouteExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLbRouteExtensionFromLbRouteExtensionName', () => { - const result = client.matchLbRouteExtensionFromLbRouteExtensionName(fakePath); - assert.strictEqual(result, "lbRouteExtensionValue"); - assert((client.pathTemplates.lbRouteExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('lbRouteExtension', async () => { + const fakePath = '/rendered/path/lbRouteExtension'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + lb_route_extension: 'lbRouteExtensionValue', + }; + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.lbRouteExtensionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.lbRouteExtensionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('lbRouteExtensionPath', () => { + const result = client.lbRouteExtensionPath( + 'projectValue', + 'locationValue', + 'lbRouteExtensionValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.lbRouteExtensionPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLbRouteExtensionName', () => { + const result = client.matchProjectFromLbRouteExtensionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.lbRouteExtensionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLbRouteExtensionName', () => { + const result = client.matchLocationFromLbRouteExtensionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.lbRouteExtensionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLbRouteExtensionFromLbRouteExtensionName', () => { + const result = + client.matchLbRouteExtensionFromLbRouteExtensionName(fakePath); + assert.strictEqual(result, 'lbRouteExtensionValue'); + assert( + (client.pathTemplates.lbRouteExtensionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('lbTrafficExtension', async () => { - const fakePath = "/rendered/path/lbTrafficExtension"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - lb_traffic_extension: "lbTrafficExtensionValue", - }; - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.lbTrafficExtensionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.lbTrafficExtensionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('lbTrafficExtensionPath', () => { - const result = client.lbTrafficExtensionPath("projectValue", "locationValue", "lbTrafficExtensionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.lbTrafficExtensionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLbTrafficExtensionName', () => { - const result = client.matchProjectFromLbTrafficExtensionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.lbTrafficExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLbTrafficExtensionName', () => { - const result = client.matchLocationFromLbTrafficExtensionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.lbTrafficExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLbTrafficExtensionFromLbTrafficExtensionName', () => { - const result = client.matchLbTrafficExtensionFromLbTrafficExtensionName(fakePath); - assert.strictEqual(result, "lbTrafficExtensionValue"); - assert((client.pathTemplates.lbTrafficExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('lbTrafficExtension', async () => { + const fakePath = '/rendered/path/lbTrafficExtension'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + lb_traffic_extension: 'lbTrafficExtensionValue', + }; + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.lbTrafficExtensionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.lbTrafficExtensionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('lbTrafficExtensionPath', () => { + const result = client.lbTrafficExtensionPath( + 'projectValue', + 'locationValue', + 'lbTrafficExtensionValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.lbTrafficExtensionPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLbTrafficExtensionName', () => { + const result = client.matchProjectFromLbTrafficExtensionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.lbTrafficExtensionPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLbTrafficExtensionName', () => { + const result = client.matchLocationFromLbTrafficExtensionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.lbTrafficExtensionPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLbTrafficExtensionFromLbTrafficExtensionName', () => { + const result = + client.matchLbTrafficExtensionFromLbTrafficExtensionName(fakePath); + assert.strictEqual(result, 'lbTrafficExtensionValue'); + assert( + ( + client.pathTemplates.lbTrafficExtensionPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('mesh', async () => { - const fakePath = "/rendered/path/mesh"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - mesh: "meshValue", - }; - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.meshPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.meshPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('meshPath', () => { - const result = client.meshPath("projectValue", "locationValue", "meshValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.meshPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMeshName', () => { - const result = client.matchProjectFromMeshName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.meshPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMeshName', () => { - const result = client.matchLocationFromMeshName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.meshPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMeshFromMeshName', () => { - const result = client.matchMeshFromMeshName(fakePath); - assert.strictEqual(result, "meshValue"); - assert((client.pathTemplates.meshPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('mesh', async () => { + const fakePath = '/rendered/path/mesh'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + mesh: 'meshValue', + }; + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.meshPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.meshPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('meshPath', () => { + const result = client.meshPath( + 'projectValue', + 'locationValue', + 'meshValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.meshPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMeshName', () => { + const result = client.matchProjectFromMeshName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.meshPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMeshName', () => { + const result = client.matchLocationFromMeshName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.meshPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMeshFromMeshName', () => { + const result = client.matchMeshFromMeshName(fakePath); + assert.strictEqual(result, 'meshValue'); + assert( + (client.pathTemplates.meshPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('meshRouteView', async () => { - const fakePath = "/rendered/path/meshRouteView"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - mesh: "meshValue", - route_view: "routeViewValue", - }; - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.meshRouteViewPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.meshRouteViewPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('meshRouteViewPath', () => { - const result = client.meshRouteViewPath("projectValue", "locationValue", "meshValue", "routeViewValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.meshRouteViewPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMeshRouteViewName', () => { - const result = client.matchProjectFromMeshRouteViewName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.meshRouteViewPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMeshRouteViewName', () => { - const result = client.matchLocationFromMeshRouteViewName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.meshRouteViewPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMeshFromMeshRouteViewName', () => { - const result = client.matchMeshFromMeshRouteViewName(fakePath); - assert.strictEqual(result, "meshValue"); - assert((client.pathTemplates.meshRouteViewPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRouteViewFromMeshRouteViewName', () => { - const result = client.matchRouteViewFromMeshRouteViewName(fakePath); - assert.strictEqual(result, "routeViewValue"); - assert((client.pathTemplates.meshRouteViewPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('meshRouteView', async () => { + const fakePath = '/rendered/path/meshRouteView'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + mesh: 'meshValue', + route_view: 'routeViewValue', + }; + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.meshRouteViewPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.meshRouteViewPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('meshRouteViewPath', () => { + const result = client.meshRouteViewPath( + 'projectValue', + 'locationValue', + 'meshValue', + 'routeViewValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.meshRouteViewPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMeshRouteViewName', () => { + const result = client.matchProjectFromMeshRouteViewName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.meshRouteViewPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMeshRouteViewName', () => { + const result = client.matchLocationFromMeshRouteViewName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.meshRouteViewPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMeshFromMeshRouteViewName', () => { + const result = client.matchMeshFromMeshRouteViewName(fakePath); + assert.strictEqual(result, 'meshValue'); + assert( + (client.pathTemplates.meshRouteViewPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRouteViewFromMeshRouteViewName', () => { + const result = client.matchRouteViewFromMeshRouteViewName(fakePath); + assert.strictEqual(result, 'routeViewValue'); + assert( + (client.pathTemplates.meshRouteViewPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('serviceBinding', async () => { - const fakePath = "/rendered/path/serviceBinding"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service_binding: "serviceBindingValue", - }; - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.serviceBindingPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.serviceBindingPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('serviceBindingPath', () => { - const result = client.serviceBindingPath("projectValue", "locationValue", "serviceBindingValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.serviceBindingPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceBindingName', () => { - const result = client.matchProjectFromServiceBindingName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.serviceBindingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServiceBindingName', () => { - const result = client.matchLocationFromServiceBindingName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.serviceBindingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceBindingFromServiceBindingName', () => { - const result = client.matchServiceBindingFromServiceBindingName(fakePath); - assert.strictEqual(result, "serviceBindingValue"); - assert((client.pathTemplates.serviceBindingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('serviceBinding', async () => { + const fakePath = '/rendered/path/serviceBinding'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service_binding: 'serviceBindingValue', + }; + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.serviceBindingPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.serviceBindingPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('serviceBindingPath', () => { + const result = client.serviceBindingPath( + 'projectValue', + 'locationValue', + 'serviceBindingValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.serviceBindingPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceBindingName', () => { + const result = client.matchProjectFromServiceBindingName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.serviceBindingPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromServiceBindingName', () => { + const result = client.matchLocationFromServiceBindingName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.serviceBindingPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceBindingFromServiceBindingName', () => { + const result = + client.matchServiceBindingFromServiceBindingName(fakePath); + assert.strictEqual(result, 'serviceBindingValue'); + assert( + (client.pathTemplates.serviceBindingPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('serviceLbPolicy', async () => { - const fakePath = "/rendered/path/serviceLbPolicy"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service_lb_policy: "serviceLbPolicyValue", - }; - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.serviceLbPolicyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.serviceLbPolicyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('serviceLbPolicyPath', () => { - const result = client.serviceLbPolicyPath("projectValue", "locationValue", "serviceLbPolicyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.serviceLbPolicyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceLbPolicyName', () => { - const result = client.matchProjectFromServiceLbPolicyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.serviceLbPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServiceLbPolicyName', () => { - const result = client.matchLocationFromServiceLbPolicyName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.serviceLbPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceLbPolicyFromServiceLbPolicyName', () => { - const result = client.matchServiceLbPolicyFromServiceLbPolicyName(fakePath); - assert.strictEqual(result, "serviceLbPolicyValue"); - assert((client.pathTemplates.serviceLbPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('serviceLbPolicy', async () => { + const fakePath = '/rendered/path/serviceLbPolicy'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service_lb_policy: 'serviceLbPolicyValue', + }; + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.serviceLbPolicyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.serviceLbPolicyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('serviceLbPolicyPath', () => { + const result = client.serviceLbPolicyPath( + 'projectValue', + 'locationValue', + 'serviceLbPolicyValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.serviceLbPolicyPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceLbPolicyName', () => { + const result = client.matchProjectFromServiceLbPolicyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.serviceLbPolicyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromServiceLbPolicyName', () => { + const result = client.matchLocationFromServiceLbPolicyName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.serviceLbPolicyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceLbPolicyFromServiceLbPolicyName', () => { + const result = + client.matchServiceLbPolicyFromServiceLbPolicyName(fakePath); + assert.strictEqual(result, 'serviceLbPolicyValue'); + assert( + (client.pathTemplates.serviceLbPolicyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('tcpRoute', async () => { - const fakePath = "/rendered/path/tcpRoute"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - tcp_route: "tcpRouteValue", - }; - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.tcpRoutePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tcpRoutePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tcpRoutePath', () => { - const result = client.tcpRoutePath("projectValue", "locationValue", "tcpRouteValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tcpRoutePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTcpRouteName', () => { - const result = client.matchProjectFromTcpRouteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.tcpRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromTcpRouteName', () => { - const result = client.matchLocationFromTcpRouteName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.tcpRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTcpRouteFromTcpRouteName', () => { - const result = client.matchTcpRouteFromTcpRouteName(fakePath); - assert.strictEqual(result, "tcpRouteValue"); - assert((client.pathTemplates.tcpRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('tcpRoute', async () => { + const fakePath = '/rendered/path/tcpRoute'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + tcp_route: 'tcpRouteValue', + }; + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.tcpRoutePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.tcpRoutePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('tcpRoutePath', () => { + const result = client.tcpRoutePath( + 'projectValue', + 'locationValue', + 'tcpRouteValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.tcpRoutePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromTcpRouteName', () => { + const result = client.matchProjectFromTcpRouteName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.tcpRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromTcpRouteName', () => { + const result = client.matchLocationFromTcpRouteName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.tcpRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTcpRouteFromTcpRouteName', () => { + const result = client.matchTcpRouteFromTcpRouteName(fakePath); + assert.strictEqual(result, 'tcpRouteValue'); + assert( + (client.pathTemplates.tcpRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('tlsRoute', async () => { - const fakePath = "/rendered/path/tlsRoute"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - tls_route: "tlsRouteValue", - }; - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.tlsRoutePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tlsRoutePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tlsRoutePath', () => { - const result = client.tlsRoutePath("projectValue", "locationValue", "tlsRouteValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tlsRoutePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTlsRouteName', () => { - const result = client.matchProjectFromTlsRouteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.tlsRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromTlsRouteName', () => { - const result = client.matchLocationFromTlsRouteName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.tlsRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTlsRouteFromTlsRouteName', () => { - const result = client.matchTlsRouteFromTlsRouteName(fakePath); - assert.strictEqual(result, "tlsRouteValue"); - assert((client.pathTemplates.tlsRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('tlsRoute', async () => { + const fakePath = '/rendered/path/tlsRoute'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + tls_route: 'tlsRouteValue', + }; + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.tlsRoutePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.tlsRoutePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('tlsRoutePath', () => { + const result = client.tlsRoutePath( + 'projectValue', + 'locationValue', + 'tlsRouteValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.tlsRoutePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromTlsRouteName', () => { + const result = client.matchProjectFromTlsRouteName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.tlsRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromTlsRouteName', () => { + const result = client.matchLocationFromTlsRouteName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.tlsRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTlsRouteFromTlsRouteName', () => { + const result = client.matchTlsRouteFromTlsRouteName(fakePath); + assert.strictEqual(result, 'tlsRouteValue'); + assert( + (client.pathTemplates.tlsRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('wasmPlugin', async () => { - const fakePath = "/rendered/path/wasmPlugin"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - wasm_plugin: "wasmPluginValue", - }; - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.wasmPluginPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.wasmPluginPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('wasmPluginPath', () => { - const result = client.wasmPluginPath("projectValue", "locationValue", "wasmPluginValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.wasmPluginPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromWasmPluginName', () => { - const result = client.matchProjectFromWasmPluginName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.wasmPluginPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromWasmPluginName', () => { - const result = client.matchLocationFromWasmPluginName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.wasmPluginPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchWasmPluginFromWasmPluginName', () => { - const result = client.matchWasmPluginFromWasmPluginName(fakePath); - assert.strictEqual(result, "wasmPluginValue"); - assert((client.pathTemplates.wasmPluginPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('wasmPlugin', async () => { + const fakePath = '/rendered/path/wasmPlugin'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + wasm_plugin: 'wasmPluginValue', + }; + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.wasmPluginPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.wasmPluginPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('wasmPluginPath', () => { + const result = client.wasmPluginPath( + 'projectValue', + 'locationValue', + 'wasmPluginValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.wasmPluginPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromWasmPluginName', () => { + const result = client.matchProjectFromWasmPluginName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.wasmPluginPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromWasmPluginName', () => { + const result = client.matchLocationFromWasmPluginName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.wasmPluginPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchWasmPluginFromWasmPluginName', () => { + const result = client.matchWasmPluginFromWasmPluginName(fakePath); + assert.strictEqual(result, 'wasmPluginValue'); + assert( + (client.pathTemplates.wasmPluginPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('wasmPluginVersion', async () => { - const fakePath = "/rendered/path/wasmPluginVersion"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - wasm_plugin: "wasmPluginValue", - wasm_plugin_version: "wasmPluginVersionValue", - }; - const client = new depserviceModule.v1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.wasmPluginVersionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.wasmPluginVersionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('wasmPluginVersionPath', () => { - const result = client.wasmPluginVersionPath("projectValue", "locationValue", "wasmPluginValue", "wasmPluginVersionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.wasmPluginVersionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromWasmPluginVersionName', () => { - const result = client.matchProjectFromWasmPluginVersionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.wasmPluginVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromWasmPluginVersionName', () => { - const result = client.matchLocationFromWasmPluginVersionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.wasmPluginVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchWasmPluginFromWasmPluginVersionName', () => { - const result = client.matchWasmPluginFromWasmPluginVersionName(fakePath); - assert.strictEqual(result, "wasmPluginValue"); - assert((client.pathTemplates.wasmPluginVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchWasmPluginVersionFromWasmPluginVersionName', () => { - const result = client.matchWasmPluginVersionFromWasmPluginVersionName(fakePath); - assert.strictEqual(result, "wasmPluginVersionValue"); - assert((client.pathTemplates.wasmPluginVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('wasmPluginVersion', async () => { + const fakePath = '/rendered/path/wasmPluginVersion'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + wasm_plugin: 'wasmPluginValue', + wasm_plugin_version: 'wasmPluginVersionValue', + }; + const client = new depserviceModule.v1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.wasmPluginVersionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.wasmPluginVersionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('wasmPluginVersionPath', () => { + const result = client.wasmPluginVersionPath( + 'projectValue', + 'locationValue', + 'wasmPluginValue', + 'wasmPluginVersionValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.wasmPluginVersionPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromWasmPluginVersionName', () => { + const result = client.matchProjectFromWasmPluginVersionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.wasmPluginVersionPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromWasmPluginVersionName', () => { + const result = client.matchLocationFromWasmPluginVersionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.wasmPluginVersionPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchWasmPluginFromWasmPluginVersionName', () => { + const result = + client.matchWasmPluginFromWasmPluginVersionName(fakePath); + assert.strictEqual(result, 'wasmPluginValue'); + assert( + ( + client.pathTemplates.wasmPluginVersionPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchWasmPluginVersionFromWasmPluginVersionName', () => { + const result = + client.matchWasmPluginVersionFromWasmPluginVersionName(fakePath); + assert.strictEqual(result, 'wasmPluginVersionValue'); + assert( + ( + client.pathTemplates.wasmPluginVersionPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-networkservices/test/gapic_dep_service_v1beta1.ts b/packages/google-cloud-networkservices/test/gapic_dep_service_v1beta1.ts index cf1be3fb40cc..388e122be95a 100644 --- a/packages/google-cloud-networkservices/test/gapic_dep_service_v1beta1.ts +++ b/packages/google-cloud-networkservices/test/gapic_dep_service_v1beta1.ts @@ -19,2106 +19,2818 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as depserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos} from 'google-gax'; +import { protobuf, LROperation, operationsProtos } from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1beta1.DepServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new depserviceModule.v1beta1.DepServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkservices.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new depserviceModule.v1beta1.DepServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = depserviceModule.v1beta1.DepServiceClient.servicePath; - assert.strictEqual(servicePath, 'networkservices.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = depserviceModule.v1beta1.DepServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkservices.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new depserviceModule.v1beta1.DepServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkservices.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new depserviceModule.v1beta1.DepServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkservices.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new depserviceModule.v1beta1.DepServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkservices.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new depserviceModule.v1beta1.DepServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkservices.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new depserviceModule.v1beta1.DepServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = depserviceModule.v1beta1.DepServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new depserviceModule.v1beta1.DepServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - fallback: true, - }); - assert(client); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new depserviceModule.v1beta1.DepServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkservices.googleapis.com'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.depServiceStub, undefined); - await client.initialize(); - assert(client.depServiceStub); - }); + it('has universeDomain', () => { + const client = new depserviceModule.v1beta1.DepServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has close method for the initialized client', done => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.depServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + depserviceModule.v1beta1.DepServiceClient.servicePath; + assert.strictEqual(servicePath, 'networkservices.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + depserviceModule.v1beta1.DepServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkservices.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkservices.example.com'); + }); - it('has close method for the non-initialized client', done => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.depServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkservices.example.com'); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new depserviceModule.v1beta1.DepServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkservices.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new depserviceModule.v1beta1.DepServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'networkservices.configured.example.com', + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new depserviceModule.v1beta1.DepServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); + it('has port', () => { + const port = depserviceModule.v1beta1.DepServiceClient.port; + assert(port); + assert(typeof port === 'number'); }); - describe('getLbTrafficExtension', () => { - it('invokes getLbTrafficExtension without error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.GetLbTrafficExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.GetLbTrafficExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.LbTrafficExtension() - ); - client.innerApiCalls.getLbTrafficExtension = stubSimpleCall(expectedResponse); - const [response] = await client.getLbTrafficExtension(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getLbTrafficExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getLbTrafficExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('should create a client with no option', () => { + const client = new depserviceModule.v1beta1.DepServiceClient(); + assert(client); + }); - it('invokes getLbTrafficExtension without error using callback', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.GetLbTrafficExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.GetLbTrafficExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.LbTrafficExtension() - ); - client.innerApiCalls.getLbTrafficExtension = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLbTrafficExtension( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getLbTrafficExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getLbTrafficExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('should create a client with gRPC fallback', () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + fallback: true, + }); + assert(client); + }); - it('invokes getLbTrafficExtension with error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.GetLbTrafficExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.GetLbTrafficExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getLbTrafficExtension = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLbTrafficExtension(request), expectedError); - const actualRequest = (client.innerApiCalls.getLbTrafficExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getLbTrafficExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.depServiceStub, undefined); + await client.initialize(); + assert(client.depServiceStub); + }); - it('invokes getLbTrafficExtension with closed client', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.GetLbTrafficExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.GetLbTrafficExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getLbTrafficExtension(request), expectedError); + it('has close method for the initialized client', (done) => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.depServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('getLbRouteExtension', () => { - it('invokes getLbRouteExtension without error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.GetLbRouteExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.GetLbRouteExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.LbRouteExtension() - ); - client.innerApiCalls.getLbRouteExtension = stubSimpleCall(expectedResponse); - const [response] = await client.getLbRouteExtension(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getLbRouteExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getLbRouteExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the non-initialized client', (done) => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.depServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getLbRouteExtension without error using callback', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.GetLbRouteExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.GetLbRouteExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.LbRouteExtension() - ); - client.innerApiCalls.getLbRouteExtension = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLbRouteExtension( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1beta1.ILbRouteExtension|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getLbRouteExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getLbRouteExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('invokes getLbRouteExtension with error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.GetLbRouteExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.GetLbRouteExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getLbRouteExtension = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLbRouteExtension(request), expectedError); - const actualRequest = (client.innerApiCalls.getLbRouteExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getLbRouteExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getLbTrafficExtension', () => { + it('invokes getLbTrafficExtension without error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.GetLbTrafficExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.GetLbTrafficExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.LbTrafficExtension(), + ); + client.innerApiCalls.getLbTrafficExtension = + stubSimpleCall(expectedResponse); + const [response] = await client.getLbTrafficExtension(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getLbTrafficExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getLbTrafficExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getLbRouteExtension with closed client', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.GetLbRouteExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.GetLbRouteExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getLbRouteExtension(request), expectedError); - }); + it('invokes getLbTrafficExtension without error using callback', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.GetLbTrafficExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.GetLbTrafficExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.LbTrafficExtension(), + ); + client.innerApiCalls.getLbTrafficExtension = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLbTrafficExtension( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getLbTrafficExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getLbTrafficExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createLbTrafficExtension', () => { - it('invokes createLbTrafficExtension without error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.CreateLbTrafficExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.CreateLbTrafficExtensionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createLbTrafficExtension = stubLongRunningCall(expectedResponse); - const [operation] = await client.createLbTrafficExtension(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createLbTrafficExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createLbTrafficExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getLbTrafficExtension with error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.GetLbTrafficExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.GetLbTrafficExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getLbTrafficExtension = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLbTrafficExtension(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.getLbTrafficExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getLbTrafficExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createLbTrafficExtension without error using callback', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.CreateLbTrafficExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.CreateLbTrafficExtensionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createLbTrafficExtension = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createLbTrafficExtension( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createLbTrafficExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createLbTrafficExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getLbTrafficExtension with closed client', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.GetLbTrafficExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.GetLbTrafficExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.getLbTrafficExtension(request), + expectedError, + ); + }); + }); + + describe('getLbRouteExtension', () => { + it('invokes getLbRouteExtension without error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.GetLbRouteExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.GetLbRouteExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.LbRouteExtension(), + ); + client.innerApiCalls.getLbRouteExtension = + stubSimpleCall(expectedResponse); + const [response] = await client.getLbRouteExtension(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getLbRouteExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getLbRouteExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createLbTrafficExtension with call error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.CreateLbTrafficExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.CreateLbTrafficExtensionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createLbTrafficExtension = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createLbTrafficExtension(request), expectedError); - const actualRequest = (client.innerApiCalls.createLbTrafficExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createLbTrafficExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getLbRouteExtension without error using callback', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.GetLbRouteExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.GetLbRouteExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.LbRouteExtension(), + ); + client.innerApiCalls.getLbRouteExtension = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLbRouteExtension( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkservices.v1beta1.ILbRouteExtension | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getLbRouteExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getLbRouteExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createLbTrafficExtension with LRO error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.CreateLbTrafficExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.CreateLbTrafficExtensionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createLbTrafficExtension = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createLbTrafficExtension(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createLbTrafficExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createLbTrafficExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getLbRouteExtension with error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.GetLbRouteExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.GetLbRouteExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getLbRouteExtension = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getLbRouteExtension(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getLbRouteExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getLbRouteExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateLbTrafficExtensionProgress without error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateLbTrafficExtensionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes getLbRouteExtension with closed client', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.GetLbRouteExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.GetLbRouteExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getLbRouteExtension(request), expectedError); + }); + }); + + describe('createLbTrafficExtension', () => { + it('invokes createLbTrafficExtension without error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.CreateLbTrafficExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.CreateLbTrafficExtensionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createLbTrafficExtension = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createLbTrafficExtension(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createLbTrafficExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createLbTrafficExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateLbTrafficExtensionProgress with error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateLbTrafficExtensionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createLbTrafficExtension without error using callback', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.CreateLbTrafficExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.CreateLbTrafficExtensionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createLbTrafficExtension = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createLbTrafficExtension( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createLbTrafficExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createLbTrafficExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateLbTrafficExtension', () => { - it('invokes updateLbTrafficExtension without error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.UpdateLbTrafficExtensionRequest() - ); - request.lbTrafficExtension ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.UpdateLbTrafficExtensionRequest', ['lbTrafficExtension', 'name']); - request.lbTrafficExtension.name = defaultValue1; - const expectedHeaderRequestParams = `lb_traffic_extension.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateLbTrafficExtension = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateLbTrafficExtension(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateLbTrafficExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateLbTrafficExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createLbTrafficExtension with call error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.CreateLbTrafficExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.CreateLbTrafficExtensionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createLbTrafficExtension = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.createLbTrafficExtension(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createLbTrafficExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createLbTrafficExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateLbTrafficExtension without error using callback', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.UpdateLbTrafficExtensionRequest() - ); - request.lbTrafficExtension ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.UpdateLbTrafficExtensionRequest', ['lbTrafficExtension', 'name']); - request.lbTrafficExtension.name = defaultValue1; - const expectedHeaderRequestParams = `lb_traffic_extension.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateLbTrafficExtension = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateLbTrafficExtension( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateLbTrafficExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateLbTrafficExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createLbTrafficExtension with LRO error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.CreateLbTrafficExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.CreateLbTrafficExtensionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createLbTrafficExtension = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createLbTrafficExtension(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createLbTrafficExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createLbTrafficExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateLbTrafficExtension with call error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.UpdateLbTrafficExtensionRequest() - ); - request.lbTrafficExtension ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.UpdateLbTrafficExtensionRequest', ['lbTrafficExtension', 'name']); - request.lbTrafficExtension.name = defaultValue1; - const expectedHeaderRequestParams = `lb_traffic_extension.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateLbTrafficExtension = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateLbTrafficExtension(request), expectedError); - const actualRequest = (client.innerApiCalls.updateLbTrafficExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateLbTrafficExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateLbTrafficExtensionProgress without error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateLbTrafficExtensionProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateLbTrafficExtension with LRO error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.UpdateLbTrafficExtensionRequest() - ); - request.lbTrafficExtension ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.UpdateLbTrafficExtensionRequest', ['lbTrafficExtension', 'name']); - request.lbTrafficExtension.name = defaultValue1; - const expectedHeaderRequestParams = `lb_traffic_extension.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateLbTrafficExtension = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateLbTrafficExtension(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateLbTrafficExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateLbTrafficExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateLbTrafficExtensionProgress with error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateLbTrafficExtensionProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateLbTrafficExtension', () => { + it('invokes updateLbTrafficExtension without error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.UpdateLbTrafficExtensionRequest(), + ); + request.lbTrafficExtension ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.UpdateLbTrafficExtensionRequest', + ['lbTrafficExtension', 'name'], + ); + request.lbTrafficExtension.name = defaultValue1; + const expectedHeaderRequestParams = `lb_traffic_extension.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateLbTrafficExtension = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateLbTrafficExtension(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateLbTrafficExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateLbTrafficExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateLbTrafficExtensionProgress without error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateLbTrafficExtensionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateLbTrafficExtension without error using callback', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.UpdateLbTrafficExtensionRequest(), + ); + request.lbTrafficExtension ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.UpdateLbTrafficExtensionRequest', + ['lbTrafficExtension', 'name'], + ); + request.lbTrafficExtension.name = defaultValue1; + const expectedHeaderRequestParams = `lb_traffic_extension.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateLbTrafficExtension = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateLbTrafficExtension( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateLbTrafficExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateLbTrafficExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateLbTrafficExtensionProgress with error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateLbTrafficExtensionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateLbTrafficExtension with call error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.UpdateLbTrafficExtensionRequest(), + ); + request.lbTrafficExtension ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.UpdateLbTrafficExtensionRequest', + ['lbTrafficExtension', 'name'], + ); + request.lbTrafficExtension.name = defaultValue1; + const expectedHeaderRequestParams = `lb_traffic_extension.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateLbTrafficExtension = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.updateLbTrafficExtension(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.updateLbTrafficExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateLbTrafficExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteLbTrafficExtension', () => { - it('invokes deleteLbTrafficExtension without error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.DeleteLbTrafficExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.DeleteLbTrafficExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteLbTrafficExtension = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteLbTrafficExtension(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteLbTrafficExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteLbTrafficExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateLbTrafficExtension with LRO error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.UpdateLbTrafficExtensionRequest(), + ); + request.lbTrafficExtension ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.UpdateLbTrafficExtensionRequest', + ['lbTrafficExtension', 'name'], + ); + request.lbTrafficExtension.name = defaultValue1; + const expectedHeaderRequestParams = `lb_traffic_extension.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateLbTrafficExtension = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateLbTrafficExtension(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateLbTrafficExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateLbTrafficExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteLbTrafficExtension without error using callback', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.DeleteLbTrafficExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.DeleteLbTrafficExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteLbTrafficExtension = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteLbTrafficExtension( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteLbTrafficExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteLbTrafficExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateLbTrafficExtensionProgress without error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateLbTrafficExtensionProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteLbTrafficExtension with call error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.DeleteLbTrafficExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.DeleteLbTrafficExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteLbTrafficExtension = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteLbTrafficExtension(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteLbTrafficExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteLbTrafficExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateLbTrafficExtensionProgress with error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateLbTrafficExtensionProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteLbTrafficExtension', () => { + it('invokes deleteLbTrafficExtension without error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.DeleteLbTrafficExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.DeleteLbTrafficExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteLbTrafficExtension = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteLbTrafficExtension(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteLbTrafficExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteLbTrafficExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteLbTrafficExtension with LRO error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.DeleteLbTrafficExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.DeleteLbTrafficExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteLbTrafficExtension = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteLbTrafficExtension(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteLbTrafficExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteLbTrafficExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteLbTrafficExtension without error using callback', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.DeleteLbTrafficExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.DeleteLbTrafficExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteLbTrafficExtension = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteLbTrafficExtension( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteLbTrafficExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteLbTrafficExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteLbTrafficExtensionProgress without error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteLbTrafficExtensionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteLbTrafficExtension with call error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.DeleteLbTrafficExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.DeleteLbTrafficExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteLbTrafficExtension = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.deleteLbTrafficExtension(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteLbTrafficExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteLbTrafficExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteLbTrafficExtensionProgress with error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteLbTrafficExtensionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteLbTrafficExtension with LRO error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.DeleteLbTrafficExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.DeleteLbTrafficExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteLbTrafficExtension = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteLbTrafficExtension(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteLbTrafficExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteLbTrafficExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createLbRouteExtension', () => { - it('invokes createLbRouteExtension without error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.CreateLbRouteExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.CreateLbRouteExtensionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createLbRouteExtension = stubLongRunningCall(expectedResponse); - const [operation] = await client.createLbRouteExtension(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createLbRouteExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createLbRouteExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteLbTrafficExtensionProgress without error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteLbTrafficExtensionProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createLbRouteExtension without error using callback', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.CreateLbRouteExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.CreateLbRouteExtensionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createLbRouteExtension = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createLbRouteExtension( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createLbRouteExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createLbRouteExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteLbTrafficExtensionProgress with error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteLbTrafficExtensionProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createLbRouteExtension', () => { + it('invokes createLbRouteExtension without error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.CreateLbRouteExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.CreateLbRouteExtensionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createLbRouteExtension = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createLbRouteExtension(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createLbRouteExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createLbRouteExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createLbRouteExtension with call error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.CreateLbRouteExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.CreateLbRouteExtensionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createLbRouteExtension = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createLbRouteExtension(request), expectedError); - const actualRequest = (client.innerApiCalls.createLbRouteExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createLbRouteExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createLbRouteExtension without error using callback', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.CreateLbRouteExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.CreateLbRouteExtensionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createLbRouteExtension = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createLbRouteExtension( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createLbRouteExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createLbRouteExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createLbRouteExtension with LRO error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.CreateLbRouteExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.CreateLbRouteExtensionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createLbRouteExtension = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createLbRouteExtension(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createLbRouteExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createLbRouteExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createLbRouteExtension with call error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.CreateLbRouteExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.CreateLbRouteExtensionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createLbRouteExtension = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.createLbRouteExtension(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createLbRouteExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createLbRouteExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateLbRouteExtensionProgress without error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateLbRouteExtensionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createLbRouteExtension with LRO error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.CreateLbRouteExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.CreateLbRouteExtensionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createLbRouteExtension = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createLbRouteExtension(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createLbRouteExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createLbRouteExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateLbRouteExtensionProgress with error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateLbRouteExtensionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateLbRouteExtensionProgress without error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateLbRouteExtensionProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('updateLbRouteExtension', () => { - it('invokes updateLbRouteExtension without error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.UpdateLbRouteExtensionRequest() - ); - request.lbRouteExtension ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.UpdateLbRouteExtensionRequest', ['lbRouteExtension', 'name']); - request.lbRouteExtension.name = defaultValue1; - const expectedHeaderRequestParams = `lb_route_extension.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateLbRouteExtension = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateLbRouteExtension(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateLbRouteExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateLbRouteExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateLbRouteExtensionProgress with error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateLbRouteExtensionProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateLbRouteExtension', () => { + it('invokes updateLbRouteExtension without error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.UpdateLbRouteExtensionRequest(), + ); + request.lbRouteExtension ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.UpdateLbRouteExtensionRequest', + ['lbRouteExtension', 'name'], + ); + request.lbRouteExtension.name = defaultValue1; + const expectedHeaderRequestParams = `lb_route_extension.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateLbRouteExtension = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateLbRouteExtension(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateLbRouteExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateLbRouteExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateLbRouteExtension without error using callback', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.UpdateLbRouteExtensionRequest() - ); - request.lbRouteExtension ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.UpdateLbRouteExtensionRequest', ['lbRouteExtension', 'name']); - request.lbRouteExtension.name = defaultValue1; - const expectedHeaderRequestParams = `lb_route_extension.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateLbRouteExtension = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateLbRouteExtension( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateLbRouteExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateLbRouteExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateLbRouteExtension without error using callback', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.UpdateLbRouteExtensionRequest(), + ); + request.lbRouteExtension ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.UpdateLbRouteExtensionRequest', + ['lbRouteExtension', 'name'], + ); + request.lbRouteExtension.name = defaultValue1; + const expectedHeaderRequestParams = `lb_route_extension.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateLbRouteExtension = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateLbRouteExtension( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1beta1.ILbRouteExtension, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateLbRouteExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateLbRouteExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateLbRouteExtension with call error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.UpdateLbRouteExtensionRequest() - ); - request.lbRouteExtension ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.UpdateLbRouteExtensionRequest', ['lbRouteExtension', 'name']); - request.lbRouteExtension.name = defaultValue1; - const expectedHeaderRequestParams = `lb_route_extension.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateLbRouteExtension = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateLbRouteExtension(request), expectedError); - const actualRequest = (client.innerApiCalls.updateLbRouteExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateLbRouteExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateLbRouteExtension with call error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.UpdateLbRouteExtensionRequest(), + ); + request.lbRouteExtension ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.UpdateLbRouteExtensionRequest', + ['lbRouteExtension', 'name'], + ); + request.lbRouteExtension.name = defaultValue1; + const expectedHeaderRequestParams = `lb_route_extension.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateLbRouteExtension = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.updateLbRouteExtension(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.updateLbRouteExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateLbRouteExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateLbRouteExtension with LRO error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.UpdateLbRouteExtensionRequest() - ); - request.lbRouteExtension ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.UpdateLbRouteExtensionRequest', ['lbRouteExtension', 'name']); - request.lbRouteExtension.name = defaultValue1; - const expectedHeaderRequestParams = `lb_route_extension.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateLbRouteExtension = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateLbRouteExtension(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateLbRouteExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateLbRouteExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateLbRouteExtension with LRO error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.UpdateLbRouteExtensionRequest(), + ); + request.lbRouteExtension ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.UpdateLbRouteExtensionRequest', + ['lbRouteExtension', 'name'], + ); + request.lbRouteExtension.name = defaultValue1; + const expectedHeaderRequestParams = `lb_route_extension.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateLbRouteExtension = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateLbRouteExtension(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateLbRouteExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateLbRouteExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateLbRouteExtensionProgress without error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateLbRouteExtensionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateLbRouteExtensionProgress without error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateLbRouteExtensionProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkUpdateLbRouteExtensionProgress with error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateLbRouteExtensionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpdateLbRouteExtensionProgress with error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateLbRouteExtensionProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteLbRouteExtension', () => { + it('invokes deleteLbRouteExtension without error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.DeleteLbRouteExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.DeleteLbRouteExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteLbRouteExtension = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteLbRouteExtension(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteLbRouteExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteLbRouteExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteLbRouteExtension', () => { - it('invokes deleteLbRouteExtension without error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.DeleteLbRouteExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.DeleteLbRouteExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteLbRouteExtension = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteLbRouteExtension(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteLbRouteExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteLbRouteExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteLbRouteExtension without error using callback', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.DeleteLbRouteExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.DeleteLbRouteExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteLbRouteExtension = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteLbRouteExtension( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteLbRouteExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteLbRouteExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteLbRouteExtension without error using callback', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.DeleteLbRouteExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.DeleteLbRouteExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteLbRouteExtension = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteLbRouteExtension( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteLbRouteExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteLbRouteExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteLbRouteExtension with call error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.DeleteLbRouteExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.DeleteLbRouteExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteLbRouteExtension = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.deleteLbRouteExtension(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteLbRouteExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteLbRouteExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteLbRouteExtension with call error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.DeleteLbRouteExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.DeleteLbRouteExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteLbRouteExtension = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteLbRouteExtension(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteLbRouteExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteLbRouteExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteLbRouteExtension with LRO error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.DeleteLbRouteExtensionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.DeleteLbRouteExtensionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteLbRouteExtension = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteLbRouteExtension(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteLbRouteExtension as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteLbRouteExtension as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteLbRouteExtension with LRO error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.DeleteLbRouteExtensionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.DeleteLbRouteExtensionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteLbRouteExtension = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteLbRouteExtension(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteLbRouteExtension as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteLbRouteExtension as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteLbRouteExtensionProgress without error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteLbRouteExtensionProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteLbRouteExtensionProgress without error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteLbRouteExtensionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkDeleteLbRouteExtensionProgress with error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteLbRouteExtensionProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listLbTrafficExtensions', () => { + it('invokes listLbTrafficExtensions without error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.ListLbTrafficExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.ListLbTrafficExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.LbTrafficExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.LbTrafficExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.LbTrafficExtension(), + ), + ]; + client.innerApiCalls.listLbTrafficExtensions = + stubSimpleCall(expectedResponse); + const [response] = await client.listLbTrafficExtensions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listLbTrafficExtensions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listLbTrafficExtensions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteLbRouteExtensionProgress with error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteLbRouteExtensionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes listLbTrafficExtensions without error using callback', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.ListLbTrafficExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.ListLbTrafficExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.LbTrafficExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.LbTrafficExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.LbTrafficExtension(), + ), + ]; + client.innerApiCalls.listLbTrafficExtensions = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listLbTrafficExtensions( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listLbTrafficExtensions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listLbTrafficExtensions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listLbTrafficExtensions', () => { - it('invokes listLbTrafficExtensions without error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.ListLbTrafficExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.ListLbTrafficExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.LbTrafficExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.LbTrafficExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.LbTrafficExtension()), - ]; - client.innerApiCalls.listLbTrafficExtensions = stubSimpleCall(expectedResponse); - const [response] = await client.listLbTrafficExtensions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listLbTrafficExtensions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listLbTrafficExtensions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listLbTrafficExtensions with error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.ListLbTrafficExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.ListLbTrafficExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listLbTrafficExtensions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listLbTrafficExtensions(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listLbTrafficExtensions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listLbTrafficExtensions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listLbTrafficExtensions without error using callback', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.ListLbTrafficExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.ListLbTrafficExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.LbTrafficExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.LbTrafficExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.LbTrafficExtension()), - ]; - client.innerApiCalls.listLbTrafficExtensions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listLbTrafficExtensions( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listLbTrafficExtensions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listLbTrafficExtensions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listLbTrafficExtensionsStream without error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.ListLbTrafficExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.ListLbTrafficExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.LbTrafficExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.LbTrafficExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.LbTrafficExtension(), + ), + ]; + client.descriptors.page.listLbTrafficExtensions.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listLbTrafficExtensionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1beta1.LbTrafficExtension[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkservices.v1beta1.LbTrafficExtension, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listLbTrafficExtensions + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listLbTrafficExtensions, request), + ); + assert( + ( + client.descriptors.page.listLbTrafficExtensions + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listLbTrafficExtensions with error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.ListLbTrafficExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.ListLbTrafficExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listLbTrafficExtensions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listLbTrafficExtensions(request), expectedError); - const actualRequest = (client.innerApiCalls.listLbTrafficExtensions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listLbTrafficExtensions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listLbTrafficExtensionsStream with error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.ListLbTrafficExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.ListLbTrafficExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listLbTrafficExtensions.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listLbTrafficExtensionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1beta1.LbTrafficExtension[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkservices.v1beta1.LbTrafficExtension, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listLbTrafficExtensions + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listLbTrafficExtensions, request), + ); + assert( + ( + client.descriptors.page.listLbTrafficExtensions + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listLbTrafficExtensionsStream without error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.ListLbTrafficExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.ListLbTrafficExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.LbTrafficExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.LbTrafficExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.LbTrafficExtension()), - ]; - client.descriptors.page.listLbTrafficExtensions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listLbTrafficExtensionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1beta1.LbTrafficExtension[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1beta1.LbTrafficExtension) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listLbTrafficExtensions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listLbTrafficExtensions, request)); - assert( - (client.descriptors.page.listLbTrafficExtensions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listLbTrafficExtensions without error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.ListLbTrafficExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.ListLbTrafficExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.LbTrafficExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.LbTrafficExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.LbTrafficExtension(), + ), + ]; + client.descriptors.page.listLbTrafficExtensions.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension[] = + []; + const iterable = client.listLbTrafficExtensionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listLbTrafficExtensions + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listLbTrafficExtensions + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listLbTrafficExtensionsStream with error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.ListLbTrafficExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.ListLbTrafficExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listLbTrafficExtensions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listLbTrafficExtensionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1beta1.LbTrafficExtension[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1beta1.LbTrafficExtension) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listLbTrafficExtensions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listLbTrafficExtensions, request)); - assert( - (client.descriptors.page.listLbTrafficExtensions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listLbTrafficExtensions with error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.ListLbTrafficExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.ListLbTrafficExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listLbTrafficExtensions.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLbTrafficExtensionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listLbTrafficExtensions + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listLbTrafficExtensions + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('listLbRouteExtensions', () => { + it('invokes listLbRouteExtensions without error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.ListLbRouteExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.ListLbRouteExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.LbRouteExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.LbRouteExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.LbRouteExtension(), + ), + ]; + client.innerApiCalls.listLbRouteExtensions = + stubSimpleCall(expectedResponse); + const [response] = await client.listLbRouteExtensions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listLbRouteExtensions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listLbRouteExtensions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listLbTrafficExtensions without error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.ListLbTrafficExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.ListLbTrafficExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.LbTrafficExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.LbTrafficExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.LbTrafficExtension()), - ]; - client.descriptors.page.listLbTrafficExtensions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension[] = []; - const iterable = client.listLbTrafficExtensionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listLbRouteExtensions without error using callback', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.ListLbRouteExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.ListLbRouteExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.LbRouteExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.LbRouteExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.LbRouteExtension(), + ), + ]; + client.innerApiCalls.listLbRouteExtensions = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listLbRouteExtensions( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkservices.v1beta1.ILbRouteExtension[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listLbTrafficExtensions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listLbTrafficExtensions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listLbTrafficExtensions with error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.ListLbTrafficExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.ListLbTrafficExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listLbTrafficExtensions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLbTrafficExtensionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkservices.v1beta1.ILbTrafficExtension[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listLbTrafficExtensions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listLbTrafficExtensions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listLbRouteExtensions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listLbRouteExtensions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listLbRouteExtensions', () => { - it('invokes listLbRouteExtensions without error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.ListLbRouteExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.ListLbRouteExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.LbRouteExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.LbRouteExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.LbRouteExtension()), - ]; - client.innerApiCalls.listLbRouteExtensions = stubSimpleCall(expectedResponse); - const [response] = await client.listLbRouteExtensions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listLbRouteExtensions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listLbRouteExtensions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listLbRouteExtensions without error using callback', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.ListLbRouteExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.ListLbRouteExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.LbRouteExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.LbRouteExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.LbRouteExtension()), - ]; - client.innerApiCalls.listLbRouteExtensions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listLbRouteExtensions( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1beta1.ILbRouteExtension[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listLbRouteExtensions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listLbRouteExtensions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listLbRouteExtensions with error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.ListLbRouteExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.ListLbRouteExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listLbRouteExtensions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listLbRouteExtensions(request), expectedError); - const actualRequest = (client.innerApiCalls.listLbRouteExtensions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listLbRouteExtensions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listLbRouteExtensionsStream without error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.ListLbRouteExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.ListLbRouteExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.LbRouteExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.LbRouteExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.LbRouteExtension()), - ]; - client.descriptors.page.listLbRouteExtensions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listLbRouteExtensionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1beta1.LbRouteExtension[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1beta1.LbRouteExtension) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listLbRouteExtensions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listLbRouteExtensions, request)); - assert( - (client.descriptors.page.listLbRouteExtensions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listLbRouteExtensions with error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.ListLbRouteExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.ListLbRouteExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listLbRouteExtensions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listLbRouteExtensions(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listLbRouteExtensions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listLbRouteExtensions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listLbRouteExtensionsStream with error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.ListLbRouteExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.ListLbRouteExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listLbRouteExtensions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listLbRouteExtensionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1beta1.LbRouteExtension[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1beta1.LbRouteExtension) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listLbRouteExtensions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listLbRouteExtensions, request)); - assert( - (client.descriptors.page.listLbRouteExtensions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listLbRouteExtensionsStream without error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.ListLbRouteExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.ListLbRouteExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.LbRouteExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.LbRouteExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.LbRouteExtension(), + ), + ]; + client.descriptors.page.listLbRouteExtensions.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listLbRouteExtensionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1beta1.LbRouteExtension[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkservices.v1beta1.LbRouteExtension, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listLbRouteExtensions + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listLbRouteExtensions, request), + ); + assert( + ( + client.descriptors.page.listLbRouteExtensions + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('uses async iteration with listLbRouteExtensions without error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.ListLbRouteExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.ListLbRouteExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.LbRouteExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.LbRouteExtension()), - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.LbRouteExtension()), - ]; - client.descriptors.page.listLbRouteExtensions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkservices.v1beta1.ILbRouteExtension[] = []; - const iterable = client.listLbRouteExtensionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listLbRouteExtensions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listLbRouteExtensions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listLbRouteExtensionsStream with error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.ListLbRouteExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.ListLbRouteExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listLbRouteExtensions.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listLbRouteExtensionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1beta1.LbRouteExtension[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkservices.v1beta1.LbRouteExtension, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listLbRouteExtensions + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listLbRouteExtensions, request), + ); + assert( + ( + client.descriptors.page.listLbRouteExtensions + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('uses async iteration with listLbRouteExtensions with error', async () => { - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.ListLbRouteExtensionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.ListLbRouteExtensionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listLbRouteExtensions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLbRouteExtensionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkservices.v1beta1.ILbRouteExtension[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listLbRouteExtensions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listLbRouteExtensions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listLbRouteExtensions without error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.ListLbRouteExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.ListLbRouteExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.LbRouteExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.LbRouteExtension(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.LbRouteExtension(), + ), + ]; + client.descriptors.page.listLbRouteExtensions.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkservices.v1beta1.ILbRouteExtension[] = + []; + const iterable = client.listLbRouteExtensionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listLbRouteExtensions + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listLbRouteExtensions + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - describe('Path templates', () => { - - describe('endpointPolicy', async () => { - const fakePath = "/rendered/path/endpointPolicy"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - endpoint_policy: "endpointPolicyValue", - }; - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.endpointPolicyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.endpointPolicyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('endpointPolicyPath', () => { - const result = client.endpointPolicyPath("projectValue", "locationValue", "endpointPolicyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.endpointPolicyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromEndpointPolicyName', () => { - const result = client.matchProjectFromEndpointPolicyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.endpointPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromEndpointPolicyName', () => { - const result = client.matchLocationFromEndpointPolicyName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.endpointPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEndpointPolicyFromEndpointPolicyName', () => { - const result = client.matchEndpointPolicyFromEndpointPolicyName(fakePath); - assert.strictEqual(result, "endpointPolicyValue"); - assert((client.pathTemplates.endpointPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with listLbRouteExtensions with error', async () => { + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.ListLbRouteExtensionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.ListLbRouteExtensionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listLbRouteExtensions.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLbRouteExtensionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkservices.v1beta1.ILbRouteExtension[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listLbRouteExtensions + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listLbRouteExtensions + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('Path templates', () => { + describe('endpointPolicy', async () => { + const fakePath = '/rendered/path/endpointPolicy'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + endpoint_policy: 'endpointPolicyValue', + }; + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.endpointPolicyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.endpointPolicyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('endpointPolicyPath', () => { + const result = client.endpointPolicyPath( + 'projectValue', + 'locationValue', + 'endpointPolicyValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.endpointPolicyPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromEndpointPolicyName', () => { + const result = client.matchProjectFromEndpointPolicyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.endpointPolicyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromEndpointPolicyName', () => { + const result = client.matchLocationFromEndpointPolicyName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.endpointPolicyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEndpointPolicyFromEndpointPolicyName', () => { + const result = + client.matchEndpointPolicyFromEndpointPolicyName(fakePath); + assert.strictEqual(result, 'endpointPolicyValue'); + assert( + (client.pathTemplates.endpointPolicyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('lbRouteExtension', async () => { - const fakePath = "/rendered/path/lbRouteExtension"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - lb_route_extension: "lbRouteExtensionValue", - }; - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.lbRouteExtensionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.lbRouteExtensionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('lbRouteExtensionPath', () => { - const result = client.lbRouteExtensionPath("projectValue", "locationValue", "lbRouteExtensionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.lbRouteExtensionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLbRouteExtensionName', () => { - const result = client.matchProjectFromLbRouteExtensionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.lbRouteExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLbRouteExtensionName', () => { - const result = client.matchLocationFromLbRouteExtensionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.lbRouteExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLbRouteExtensionFromLbRouteExtensionName', () => { - const result = client.matchLbRouteExtensionFromLbRouteExtensionName(fakePath); - assert.strictEqual(result, "lbRouteExtensionValue"); - assert((client.pathTemplates.lbRouteExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('lbRouteExtension', async () => { + const fakePath = '/rendered/path/lbRouteExtension'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + lb_route_extension: 'lbRouteExtensionValue', + }; + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.lbRouteExtensionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.lbRouteExtensionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('lbRouteExtensionPath', () => { + const result = client.lbRouteExtensionPath( + 'projectValue', + 'locationValue', + 'lbRouteExtensionValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.lbRouteExtensionPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLbRouteExtensionName', () => { + const result = client.matchProjectFromLbRouteExtensionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.lbRouteExtensionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLbRouteExtensionName', () => { + const result = client.matchLocationFromLbRouteExtensionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.lbRouteExtensionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLbRouteExtensionFromLbRouteExtensionName', () => { + const result = + client.matchLbRouteExtensionFromLbRouteExtensionName(fakePath); + assert.strictEqual(result, 'lbRouteExtensionValue'); + assert( + (client.pathTemplates.lbRouteExtensionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('lbTrafficExtension', async () => { - const fakePath = "/rendered/path/lbTrafficExtension"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - lb_traffic_extension: "lbTrafficExtensionValue", - }; - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.lbTrafficExtensionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.lbTrafficExtensionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('lbTrafficExtensionPath', () => { - const result = client.lbTrafficExtensionPath("projectValue", "locationValue", "lbTrafficExtensionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.lbTrafficExtensionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLbTrafficExtensionName', () => { - const result = client.matchProjectFromLbTrafficExtensionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.lbTrafficExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLbTrafficExtensionName', () => { - const result = client.matchLocationFromLbTrafficExtensionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.lbTrafficExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLbTrafficExtensionFromLbTrafficExtensionName', () => { - const result = client.matchLbTrafficExtensionFromLbTrafficExtensionName(fakePath); - assert.strictEqual(result, "lbTrafficExtensionValue"); - assert((client.pathTemplates.lbTrafficExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('lbTrafficExtension', async () => { + const fakePath = '/rendered/path/lbTrafficExtension'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + lb_traffic_extension: 'lbTrafficExtensionValue', + }; + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.lbTrafficExtensionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.lbTrafficExtensionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('lbTrafficExtensionPath', () => { + const result = client.lbTrafficExtensionPath( + 'projectValue', + 'locationValue', + 'lbTrafficExtensionValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.lbTrafficExtensionPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLbTrafficExtensionName', () => { + const result = client.matchProjectFromLbTrafficExtensionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.lbTrafficExtensionPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLbTrafficExtensionName', () => { + const result = client.matchLocationFromLbTrafficExtensionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.lbTrafficExtensionPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLbTrafficExtensionFromLbTrafficExtensionName', () => { + const result = + client.matchLbTrafficExtensionFromLbTrafficExtensionName(fakePath); + assert.strictEqual(result, 'lbTrafficExtensionValue'); + assert( + ( + client.pathTemplates.lbTrafficExtensionPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new depserviceModule.v1beta1.DepServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new depserviceModule.v1beta1.DepServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-networkservices/test/gapic_network_services_v1.ts b/packages/google-cloud-networkservices/test/gapic_network_services_v1.ts index 1a3efa324c78..fd6188a20769 100644 --- a/packages/google-cloud-networkservices/test/gapic_network_services_v1.ts +++ b/packages/google-cloud-networkservices/test/gapic_network_services_v1.ts @@ -19,11322 +19,14696 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as networkservicesModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + IamProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1.NetworkServicesClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new networkservicesModule.v1.NetworkServicesClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkservices.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new networkservicesModule.v1.NetworkServicesClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkservices.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new networkservicesModule.v1.NetworkServicesClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new networkservicesModule.v1.NetworkServicesClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = networkservicesModule.v1.NetworkServicesClient.servicePath; - assert.strictEqual(servicePath, 'networkservices.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = networkservicesModule.v1.NetworkServicesClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkservices.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new networkservicesModule.v1.NetworkServicesClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkservices.example.com'); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + networkservicesModule.v1.NetworkServicesClient.servicePath; + assert.strictEqual(servicePath, 'networkservices.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + networkservicesModule.v1.NetworkServicesClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkservices.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkservices.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new networkservicesModule.v1.NetworkServicesClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkservices.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkservices.example.com'); + }); - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new networkservicesModule.v1.NetworkServicesClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkservices.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new networkservicesModule.v1.NetworkServicesClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkservices.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new networkservicesModule.v1.NetworkServicesClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new networkservicesModule.v1.NetworkServicesClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkservices.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new networkservicesModule.v1.NetworkServicesClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'networkservices.configured.example.com', + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new networkservicesModule.v1.NetworkServicesClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has port', () => { - const port = networkservicesModule.v1.NetworkServicesClient.port; - assert(port); - assert(typeof port === 'number'); - }); + it('has port', () => { + const port = networkservicesModule.v1.NetworkServicesClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('should create a client with no option', () => { - const client = new networkservicesModule.v1.NetworkServicesClient(); - assert(client); - }); + it('should create a client with no option', () => { + const client = new networkservicesModule.v1.NetworkServicesClient(); + assert(client); + }); - it('should create a client with gRPC fallback', () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - fallback: true, - }); - assert(client); - }); + it('should create a client with gRPC fallback', () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + fallback: true, + }); + assert(client); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.networkServicesStub, undefined); - await client.initialize(); - assert(client.networkServicesStub); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.networkServicesStub, undefined); + await client.initialize(); + assert(client.networkServicesStub); + }); - it('has close method for the initialized client', done => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.networkServicesStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the initialized client', (done) => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.networkServicesStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has close method for the non-initialized client', done => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.networkServicesStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the non-initialized client', (done) => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.networkServicesStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getEndpointPolicy', () => { + it('invokes getEndpointPolicy without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetEndpointPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetEndpointPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.EndpointPolicy(), + ); + client.innerApiCalls.getEndpointPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getEndpointPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getEndpointPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEndpointPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getEndpointPolicy', () => { - it('invokes getEndpointPolicy without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetEndpointPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetEndpointPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.EndpointPolicy() - ); - client.innerApiCalls.getEndpointPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getEndpointPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getEndpointPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEndpointPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getEndpointPolicy without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetEndpointPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetEndpointPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.EndpointPolicy(), + ); + client.innerApiCalls.getEndpointPolicy = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getEndpointPolicy( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkservices.v1.IEndpointPolicy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getEndpointPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEndpointPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getEndpointPolicy without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetEndpointPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetEndpointPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.EndpointPolicy() - ); - client.innerApiCalls.getEndpointPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getEndpointPolicy( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.IEndpointPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getEndpointPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEndpointPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getEndpointPolicy with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetEndpointPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetEndpointPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getEndpointPolicy = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getEndpointPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getEndpointPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEndpointPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getEndpointPolicy with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetEndpointPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetEndpointPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getEndpointPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getEndpointPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.getEndpointPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEndpointPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getEndpointPolicy with closed client', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetEndpointPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetEndpointPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getEndpointPolicy(request), expectedError); + }); + }); + + describe('getWasmPluginVersion', () => { + it('invokes getWasmPluginVersion without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetWasmPluginVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetWasmPluginVersionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.WasmPluginVersion(), + ); + client.innerApiCalls.getWasmPluginVersion = + stubSimpleCall(expectedResponse); + const [response] = await client.getWasmPluginVersion(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getWasmPluginVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getWasmPluginVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getEndpointPolicy with closed client', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetEndpointPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetEndpointPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getEndpointPolicy(request), expectedError); - }); + it('invokes getWasmPluginVersion without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetWasmPluginVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetWasmPluginVersionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.WasmPluginVersion(), + ); + client.innerApiCalls.getWasmPluginVersion = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getWasmPluginVersion( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkservices.v1.IWasmPluginVersion | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getWasmPluginVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getWasmPluginVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getWasmPluginVersion', () => { - it('invokes getWasmPluginVersion without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetWasmPluginVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetWasmPluginVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.WasmPluginVersion() - ); - client.innerApiCalls.getWasmPluginVersion = stubSimpleCall(expectedResponse); - const [response] = await client.getWasmPluginVersion(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getWasmPluginVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getWasmPluginVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getWasmPluginVersion with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetWasmPluginVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetWasmPluginVersionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getWasmPluginVersion = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getWasmPluginVersion(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getWasmPluginVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getWasmPluginVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getWasmPluginVersion without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetWasmPluginVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetWasmPluginVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.WasmPluginVersion() - ); - client.innerApiCalls.getWasmPluginVersion = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getWasmPluginVersion( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.IWasmPluginVersion|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getWasmPluginVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getWasmPluginVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getWasmPluginVersion with closed client', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetWasmPluginVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetWasmPluginVersionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getWasmPluginVersion(request), expectedError); + }); + }); + + describe('getWasmPlugin', () => { + it('invokes getWasmPlugin without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetWasmPluginRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetWasmPluginRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.WasmPlugin(), + ); + client.innerApiCalls.getWasmPlugin = stubSimpleCall(expectedResponse); + const [response] = await client.getWasmPlugin(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getWasmPlugin as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getWasmPlugin as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getWasmPluginVersion with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetWasmPluginVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetWasmPluginVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getWasmPluginVersion = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getWasmPluginVersion(request), expectedError); - const actualRequest = (client.innerApiCalls.getWasmPluginVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getWasmPluginVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getWasmPlugin without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetWasmPluginRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetWasmPluginRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.WasmPlugin(), + ); + client.innerApiCalls.getWasmPlugin = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getWasmPlugin( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkservices.v1.IWasmPlugin | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getWasmPlugin as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getWasmPlugin as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getWasmPluginVersion with closed client', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetWasmPluginVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetWasmPluginVersionRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getWasmPluginVersion(request), expectedError); - }); + it('invokes getWasmPlugin with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetWasmPluginRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetWasmPluginRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getWasmPlugin = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getWasmPlugin(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getWasmPlugin as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getWasmPlugin as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getWasmPlugin', () => { - it('invokes getWasmPlugin without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetWasmPluginRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetWasmPluginRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.WasmPlugin() - ); - client.innerApiCalls.getWasmPlugin = stubSimpleCall(expectedResponse); - const [response] = await client.getWasmPlugin(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getWasmPlugin as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getWasmPlugin as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getWasmPlugin with closed client', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetWasmPluginRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetWasmPluginRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getWasmPlugin(request), expectedError); + }); + }); + + describe('getGateway', () => { + it('invokes getGateway without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetGatewayRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetGatewayRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.Gateway(), + ); + client.innerApiCalls.getGateway = stubSimpleCall(expectedResponse); + const [response] = await client.getGateway(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getGateway as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getGateway as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getWasmPlugin without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetWasmPluginRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetWasmPluginRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.WasmPlugin() - ); - client.innerApiCalls.getWasmPlugin = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getWasmPlugin( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.IWasmPlugin|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getWasmPlugin as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getWasmPlugin as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getGateway without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetGatewayRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetGatewayRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.Gateway(), + ); + client.innerApiCalls.getGateway = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getGateway( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkservices.v1.IGateway | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getGateway as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getGateway as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getWasmPlugin with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetWasmPluginRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetWasmPluginRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getWasmPlugin = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getWasmPlugin(request), expectedError); - const actualRequest = (client.innerApiCalls.getWasmPlugin as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getWasmPlugin as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getGateway with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetGatewayRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetGatewayRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getGateway = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getGateway(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getGateway as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getGateway as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getWasmPlugin with closed client', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetWasmPluginRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetWasmPluginRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getWasmPlugin(request), expectedError); - }); + it('invokes getGateway with closed client', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetGatewayRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetGatewayRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getGateway(request), expectedError); + }); + }); + + describe('getGrpcRoute', () => { + it('invokes getGrpcRoute without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetGrpcRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetGrpcRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GrpcRoute(), + ); + client.innerApiCalls.getGrpcRoute = stubSimpleCall(expectedResponse); + const [response] = await client.getGrpcRoute(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getGrpcRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getGrpcRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getGateway', () => { - it('invokes getGateway without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetGatewayRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetGatewayRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.Gateway() - ); - client.innerApiCalls.getGateway = stubSimpleCall(expectedResponse); - const [response] = await client.getGateway(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getGateway as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getGateway as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getGrpcRoute without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetGrpcRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetGrpcRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GrpcRoute(), + ); + client.innerApiCalls.getGrpcRoute = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getGrpcRoute( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkservices.v1.IGrpcRoute | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getGrpcRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getGrpcRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getGateway without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetGatewayRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetGatewayRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.Gateway() - ); - client.innerApiCalls.getGateway = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getGateway( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.IGateway|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getGateway as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getGateway as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getGrpcRoute with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetGrpcRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetGrpcRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getGrpcRoute = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getGrpcRoute(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getGrpcRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getGrpcRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getGateway with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetGatewayRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetGatewayRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getGateway = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getGateway(request), expectedError); - const actualRequest = (client.innerApiCalls.getGateway as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getGateway as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getGrpcRoute with closed client', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetGrpcRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetGrpcRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getGrpcRoute(request), expectedError); + }); + }); + + describe('getHttpRoute', () => { + it('invokes getHttpRoute without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetHttpRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetHttpRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.HttpRoute(), + ); + client.innerApiCalls.getHttpRoute = stubSimpleCall(expectedResponse); + const [response] = await client.getHttpRoute(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getHttpRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getHttpRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getGateway with closed client', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetGatewayRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetGatewayRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getGateway(request), expectedError); - }); + it('invokes getHttpRoute without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetHttpRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetHttpRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.HttpRoute(), + ); + client.innerApiCalls.getHttpRoute = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getHttpRoute( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkservices.v1.IHttpRoute | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getHttpRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getHttpRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getGrpcRoute', () => { - it('invokes getGrpcRoute without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetGrpcRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetGrpcRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GrpcRoute() - ); - client.innerApiCalls.getGrpcRoute = stubSimpleCall(expectedResponse); - const [response] = await client.getGrpcRoute(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getGrpcRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getGrpcRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getHttpRoute with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetHttpRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetHttpRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getHttpRoute = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getHttpRoute(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getHttpRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getHttpRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getGrpcRoute without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetGrpcRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetGrpcRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GrpcRoute() - ); - client.innerApiCalls.getGrpcRoute = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getGrpcRoute( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.IGrpcRoute|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getGrpcRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getGrpcRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getHttpRoute with closed client', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetHttpRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetHttpRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getHttpRoute(request), expectedError); + }); + }); + + describe('getTcpRoute', () => { + it('invokes getTcpRoute without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetTcpRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetTcpRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.TcpRoute(), + ); + client.innerApiCalls.getTcpRoute = stubSimpleCall(expectedResponse); + const [response] = await client.getTcpRoute(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getTcpRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTcpRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getGrpcRoute with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetGrpcRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetGrpcRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getGrpcRoute = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getGrpcRoute(request), expectedError); - const actualRequest = (client.innerApiCalls.getGrpcRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getGrpcRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getTcpRoute without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetTcpRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetTcpRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.TcpRoute(), + ); + client.innerApiCalls.getTcpRoute = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getTcpRoute( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkservices.v1.ITcpRoute | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getTcpRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTcpRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getGrpcRoute with closed client', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetGrpcRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetGrpcRouteRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getGrpcRoute(request), expectedError); - }); + it('invokes getTcpRoute with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetTcpRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetTcpRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getTcpRoute = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getTcpRoute(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getTcpRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTcpRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getHttpRoute', () => { - it('invokes getHttpRoute without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetHttpRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetHttpRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.HttpRoute() - ); - client.innerApiCalls.getHttpRoute = stubSimpleCall(expectedResponse); - const [response] = await client.getHttpRoute(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getHttpRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getHttpRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getTcpRoute with closed client', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetTcpRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetTcpRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getTcpRoute(request), expectedError); + }); + }); + + describe('getTlsRoute', () => { + it('invokes getTlsRoute without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetTlsRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetTlsRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.TlsRoute(), + ); + client.innerApiCalls.getTlsRoute = stubSimpleCall(expectedResponse); + const [response] = await client.getTlsRoute(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getTlsRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTlsRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getHttpRoute without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetHttpRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetHttpRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.HttpRoute() - ); - client.innerApiCalls.getHttpRoute = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getHttpRoute( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.IHttpRoute|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getHttpRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getHttpRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getTlsRoute without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetTlsRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetTlsRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.TlsRoute(), + ); + client.innerApiCalls.getTlsRoute = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getTlsRoute( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkservices.v1.ITlsRoute | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getTlsRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTlsRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getHttpRoute with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetHttpRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetHttpRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getHttpRoute = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getHttpRoute(request), expectedError); - const actualRequest = (client.innerApiCalls.getHttpRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getHttpRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getTlsRoute with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetTlsRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetTlsRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getTlsRoute = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getTlsRoute(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getTlsRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTlsRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getHttpRoute with closed client', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetHttpRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetHttpRouteRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getHttpRoute(request), expectedError); - }); + it('invokes getTlsRoute with closed client', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetTlsRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetTlsRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getTlsRoute(request), expectedError); + }); + }); + + describe('getServiceBinding', () => { + it('invokes getServiceBinding without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetServiceBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetServiceBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ServiceBinding(), + ); + client.innerApiCalls.getServiceBinding = stubSimpleCall(expectedResponse); + const [response] = await client.getServiceBinding(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getServiceBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getServiceBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getTcpRoute', () => { - it('invokes getTcpRoute without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetTcpRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetTcpRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.TcpRoute() - ); - client.innerApiCalls.getTcpRoute = stubSimpleCall(expectedResponse); - const [response] = await client.getTcpRoute(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTcpRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTcpRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getServiceBinding without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetServiceBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetServiceBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ServiceBinding(), + ); + client.innerApiCalls.getServiceBinding = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getServiceBinding( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkservices.v1.IServiceBinding | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getServiceBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getServiceBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getTcpRoute without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetTcpRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetTcpRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.TcpRoute() - ); - client.innerApiCalls.getTcpRoute = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getTcpRoute( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.ITcpRoute|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTcpRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTcpRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getServiceBinding with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetServiceBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetServiceBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getServiceBinding = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getServiceBinding(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getServiceBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getServiceBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getTcpRoute with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetTcpRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetTcpRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getTcpRoute = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getTcpRoute(request), expectedError); - const actualRequest = (client.innerApiCalls.getTcpRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTcpRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getServiceBinding with closed client', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetServiceBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetServiceBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getServiceBinding(request), expectedError); + }); + }); + + describe('getMesh', () => { + it('invokes getMesh without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetMeshRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetMeshRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.Mesh(), + ); + client.innerApiCalls.getMesh = stubSimpleCall(expectedResponse); + const [response] = await client.getMesh(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getMesh as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMesh as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getTcpRoute with closed client', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetTcpRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetTcpRouteRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getTcpRoute(request), expectedError); - }); + it('invokes getMesh without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetMeshRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetMeshRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.Mesh(), + ); + client.innerApiCalls.getMesh = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getMesh( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkservices.v1.IMesh | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getMesh as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMesh as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getTlsRoute', () => { - it('invokes getTlsRoute without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetTlsRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetTlsRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.TlsRoute() - ); - client.innerApiCalls.getTlsRoute = stubSimpleCall(expectedResponse); - const [response] = await client.getTlsRoute(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTlsRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTlsRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getMesh with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetMeshRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetMeshRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getMesh = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getMesh(request), expectedError); + const actualRequest = (client.innerApiCalls.getMesh as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMesh as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getTlsRoute without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetTlsRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetTlsRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.TlsRoute() - ); - client.innerApiCalls.getTlsRoute = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getTlsRoute( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.ITlsRoute|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTlsRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTlsRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getMesh with closed client', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetMeshRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetMeshRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getMesh(request), expectedError); + }); + }); + + describe('getServiceLbPolicy', () => { + it('invokes getServiceLbPolicy without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetServiceLbPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetServiceLbPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ServiceLbPolicy(), + ); + client.innerApiCalls.getServiceLbPolicy = + stubSimpleCall(expectedResponse); + const [response] = await client.getServiceLbPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getServiceLbPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getServiceLbPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getTlsRoute with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetTlsRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetTlsRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getTlsRoute = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getTlsRoute(request), expectedError); - const actualRequest = (client.innerApiCalls.getTlsRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTlsRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getServiceLbPolicy without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetServiceLbPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetServiceLbPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ServiceLbPolicy(), + ); + client.innerApiCalls.getServiceLbPolicy = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getServiceLbPolicy( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkservices.v1.IServiceLbPolicy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getServiceLbPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getServiceLbPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getTlsRoute with closed client', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetTlsRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetTlsRouteRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getTlsRoute(request), expectedError); - }); + it('invokes getServiceLbPolicy with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetServiceLbPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetServiceLbPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getServiceLbPolicy = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getServiceLbPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getServiceLbPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getServiceLbPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getServiceBinding', () => { - it('invokes getServiceBinding without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetServiceBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetServiceBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ServiceBinding() - ); - client.innerApiCalls.getServiceBinding = stubSimpleCall(expectedResponse); - const [response] = await client.getServiceBinding(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getServiceBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServiceBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getServiceLbPolicy with closed client', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetServiceLbPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetServiceLbPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getServiceLbPolicy(request), expectedError); + }); + }); + + describe('getGatewayRouteView', () => { + it('invokes getGatewayRouteView without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetGatewayRouteViewRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetGatewayRouteViewRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GatewayRouteView(), + ); + client.innerApiCalls.getGatewayRouteView = + stubSimpleCall(expectedResponse); + const [response] = await client.getGatewayRouteView(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getGatewayRouteView as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getGatewayRouteView as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getServiceBinding without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetServiceBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetServiceBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ServiceBinding() - ); - client.innerApiCalls.getServiceBinding = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getServiceBinding( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.IServiceBinding|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getServiceBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServiceBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getGatewayRouteView without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetGatewayRouteViewRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetGatewayRouteViewRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GatewayRouteView(), + ); + client.innerApiCalls.getGatewayRouteView = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getGatewayRouteView( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkservices.v1.IGatewayRouteView | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getGatewayRouteView as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getGatewayRouteView as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getServiceBinding with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetServiceBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetServiceBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getServiceBinding = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getServiceBinding(request), expectedError); - const actualRequest = (client.innerApiCalls.getServiceBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServiceBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getGatewayRouteView with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetGatewayRouteViewRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetGatewayRouteViewRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getGatewayRouteView = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getGatewayRouteView(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getGatewayRouteView as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getGatewayRouteView as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getServiceBinding with closed client', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetServiceBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetServiceBindingRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getServiceBinding(request), expectedError); - }); + it('invokes getGatewayRouteView with closed client', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetGatewayRouteViewRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetGatewayRouteViewRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getGatewayRouteView(request), expectedError); + }); + }); + + describe('getMeshRouteView', () => { + it('invokes getMeshRouteView without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetMeshRouteViewRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetMeshRouteViewRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.MeshRouteView(), + ); + client.innerApiCalls.getMeshRouteView = stubSimpleCall(expectedResponse); + const [response] = await client.getMeshRouteView(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getMeshRouteView as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMeshRouteView as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getMesh', () => { - it('invokes getMesh without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetMeshRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetMeshRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.Mesh() - ); - client.innerApiCalls.getMesh = stubSimpleCall(expectedResponse); - const [response] = await client.getMesh(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMesh as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMesh as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getMeshRouteView without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetMeshRouteViewRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetMeshRouteViewRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1.MeshRouteView(), + ); + client.innerApiCalls.getMeshRouteView = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getMeshRouteView( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkservices.v1.IMeshRouteView | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getMeshRouteView as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMeshRouteView as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getMesh without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetMeshRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetMeshRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.Mesh() - ); - client.innerApiCalls.getMesh = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getMesh( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.IMesh|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMesh as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMesh as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getMeshRouteView with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetMeshRouteViewRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetMeshRouteViewRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getMeshRouteView = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getMeshRouteView(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getMeshRouteView as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMeshRouteView as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getMesh with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetMeshRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetMeshRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getMesh = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getMesh(request), expectedError); - const actualRequest = (client.innerApiCalls.getMesh as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMesh as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getMeshRouteView with closed client', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.GetMeshRouteViewRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.GetMeshRouteViewRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getMeshRouteView(request), expectedError); + }); + }); + + describe('createEndpointPolicy', () => { + it('invokes createEndpointPolicy without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateEndpointPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateEndpointPolicyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createEndpointPolicy = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createEndpointPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createEndpointPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEndpointPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getMesh with closed client', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetMeshRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetMeshRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getMesh(request), expectedError); - }); + it('invokes createEndpointPolicy without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateEndpointPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateEndpointPolicyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createEndpointPolicy = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createEndpointPolicy( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1.IEndpointPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1.IEndpointPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createEndpointPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEndpointPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getServiceLbPolicy', () => { - it('invokes getServiceLbPolicy without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetServiceLbPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetServiceLbPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ServiceLbPolicy() - ); - client.innerApiCalls.getServiceLbPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getServiceLbPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getServiceLbPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServiceLbPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createEndpointPolicy with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateEndpointPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateEndpointPolicyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createEndpointPolicy = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createEndpointPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createEndpointPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEndpointPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getServiceLbPolicy without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetServiceLbPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetServiceLbPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ServiceLbPolicy() - ); - client.innerApiCalls.getServiceLbPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getServiceLbPolicy( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.IServiceLbPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getServiceLbPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServiceLbPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createEndpointPolicy with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateEndpointPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateEndpointPolicyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createEndpointPolicy = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createEndpointPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createEndpointPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEndpointPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getServiceLbPolicy with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetServiceLbPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetServiceLbPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getServiceLbPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getServiceLbPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.getServiceLbPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServiceLbPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateEndpointPolicyProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateEndpointPolicyProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes getServiceLbPolicy with closed client', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetServiceLbPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetServiceLbPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getServiceLbPolicy(request), expectedError); - }); + it('invokes checkCreateEndpointPolicyProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateEndpointPolicyProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateEndpointPolicy', () => { + it('invokes updateEndpointPolicy without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateEndpointPolicyRequest(), + ); + request.endpointPolicy ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateEndpointPolicyRequest', + ['endpointPolicy', 'name'], + ); + request.endpointPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `endpoint_policy.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateEndpointPolicy = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateEndpointPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateEndpointPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEndpointPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getGatewayRouteView', () => { - it('invokes getGatewayRouteView without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetGatewayRouteViewRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetGatewayRouteViewRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GatewayRouteView() - ); - client.innerApiCalls.getGatewayRouteView = stubSimpleCall(expectedResponse); - const [response] = await client.getGatewayRouteView(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getGatewayRouteView as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getGatewayRouteView as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateEndpointPolicy without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateEndpointPolicyRequest(), + ); + request.endpointPolicy ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateEndpointPolicyRequest', + ['endpointPolicy', 'name'], + ); + request.endpointPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `endpoint_policy.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateEndpointPolicy = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateEndpointPolicy( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1.IEndpointPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1.IEndpointPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateEndpointPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEndpointPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getGatewayRouteView without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetGatewayRouteViewRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetGatewayRouteViewRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GatewayRouteView() - ); - client.innerApiCalls.getGatewayRouteView = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getGatewayRouteView( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.IGatewayRouteView|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getGatewayRouteView as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getGatewayRouteView as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateEndpointPolicy with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateEndpointPolicyRequest(), + ); + request.endpointPolicy ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateEndpointPolicyRequest', + ['endpointPolicy', 'name'], + ); + request.endpointPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `endpoint_policy.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateEndpointPolicy = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateEndpointPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateEndpointPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEndpointPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getGatewayRouteView with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetGatewayRouteViewRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetGatewayRouteViewRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getGatewayRouteView = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getGatewayRouteView(request), expectedError); - const actualRequest = (client.innerApiCalls.getGatewayRouteView as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getGatewayRouteView as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateEndpointPolicy with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateEndpointPolicyRequest(), + ); + request.endpointPolicy ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateEndpointPolicyRequest', + ['endpointPolicy', 'name'], + ); + request.endpointPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `endpoint_policy.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateEndpointPolicy = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateEndpointPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateEndpointPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEndpointPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getGatewayRouteView with closed client', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetGatewayRouteViewRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetGatewayRouteViewRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getGatewayRouteView(request), expectedError); - }); + it('invokes checkUpdateEndpointPolicyProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateEndpointPolicyProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('getMeshRouteView', () => { - it('invokes getMeshRouteView without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetMeshRouteViewRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetMeshRouteViewRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.MeshRouteView() - ); - client.innerApiCalls.getMeshRouteView = stubSimpleCall(expectedResponse); - const [response] = await client.getMeshRouteView(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMeshRouteView as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMeshRouteView as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateEndpointPolicyProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateEndpointPolicyProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteEndpointPolicy', () => { + it('invokes deleteEndpointPolicy without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteEndpointPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteEndpointPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteEndpointPolicy = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteEndpointPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteEndpointPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEndpointPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getMeshRouteView without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetMeshRouteViewRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetMeshRouteViewRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1.MeshRouteView() - ); - client.innerApiCalls.getMeshRouteView = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getMeshRouteView( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.IMeshRouteView|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMeshRouteView as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMeshRouteView as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteEndpointPolicy without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteEndpointPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteEndpointPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteEndpointPolicy = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteEndpointPolicy( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteEndpointPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEndpointPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getMeshRouteView with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetMeshRouteViewRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetMeshRouteViewRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getMeshRouteView = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getMeshRouteView(request), expectedError); - const actualRequest = (client.innerApiCalls.getMeshRouteView as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMeshRouteView as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteEndpointPolicy with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteEndpointPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteEndpointPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteEndpointPolicy = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteEndpointPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteEndpointPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEndpointPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getMeshRouteView with closed client', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.GetMeshRouteViewRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.GetMeshRouteViewRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getMeshRouteView(request), expectedError); - }); + it('invokes deleteEndpointPolicy with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteEndpointPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteEndpointPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteEndpointPolicy = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteEndpointPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteEndpointPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEndpointPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createEndpointPolicy', () => { - it('invokes createEndpointPolicy without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateEndpointPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateEndpointPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createEndpointPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.createEndpointPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createEndpointPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEndpointPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteEndpointPolicyProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteEndpointPolicyProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createEndpointPolicy without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateEndpointPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateEndpointPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createEndpointPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createEndpointPolicy( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createEndpointPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEndpointPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteEndpointPolicyProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteEndpointPolicyProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createWasmPluginVersion', () => { + it('invokes createWasmPluginVersion without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateWasmPluginVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateWasmPluginVersionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createWasmPluginVersion = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createWasmPluginVersion(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createWasmPluginVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createWasmPluginVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createEndpointPolicy with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateEndpointPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateEndpointPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createEndpointPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createEndpointPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.createEndpointPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEndpointPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createWasmPluginVersion without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateWasmPluginVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateWasmPluginVersionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createWasmPluginVersion = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createWasmPluginVersion( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1.IWasmPluginVersion, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1.IWasmPluginVersion, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createWasmPluginVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createWasmPluginVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createEndpointPolicy with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateEndpointPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateEndpointPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createEndpointPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createEndpointPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createEndpointPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEndpointPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createWasmPluginVersion with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateWasmPluginVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateWasmPluginVersionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createWasmPluginVersion = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.createWasmPluginVersion(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createWasmPluginVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createWasmPluginVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateEndpointPolicyProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateEndpointPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createWasmPluginVersion with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateWasmPluginVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateWasmPluginVersionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createWasmPluginVersion = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createWasmPluginVersion(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createWasmPluginVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createWasmPluginVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateEndpointPolicyProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateEndpointPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateWasmPluginVersionProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateWasmPluginVersionProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('updateEndpointPolicy', () => { - it('invokes updateEndpointPolicy without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateEndpointPolicyRequest() - ); - request.endpointPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateEndpointPolicyRequest', ['endpointPolicy', 'name']); - request.endpointPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `endpoint_policy.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateEndpointPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateEndpointPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateEndpointPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateEndpointPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateWasmPluginVersionProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateWasmPluginVersionProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteWasmPluginVersion', () => { + it('invokes deleteWasmPluginVersion without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteWasmPluginVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteWasmPluginVersionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteWasmPluginVersion = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteWasmPluginVersion(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteWasmPluginVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteWasmPluginVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateEndpointPolicy without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateEndpointPolicyRequest() - ); - request.endpointPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateEndpointPolicyRequest', ['endpointPolicy', 'name']); - request.endpointPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `endpoint_policy.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateEndpointPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateEndpointPolicy( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateEndpointPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateEndpointPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteWasmPluginVersion without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteWasmPluginVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteWasmPluginVersionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteWasmPluginVersion = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteWasmPluginVersion( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteWasmPluginVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteWasmPluginVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateEndpointPolicy with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateEndpointPolicyRequest() - ); - request.endpointPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateEndpointPolicyRequest', ['endpointPolicy', 'name']); - request.endpointPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `endpoint_policy.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateEndpointPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateEndpointPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.updateEndpointPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateEndpointPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteWasmPluginVersion with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteWasmPluginVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteWasmPluginVersionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteWasmPluginVersion = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.deleteWasmPluginVersion(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteWasmPluginVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteWasmPluginVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateEndpointPolicy with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateEndpointPolicyRequest() - ); - request.endpointPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateEndpointPolicyRequest', ['endpointPolicy', 'name']); - request.endpointPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `endpoint_policy.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateEndpointPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateEndpointPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateEndpointPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateEndpointPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteWasmPluginVersion with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteWasmPluginVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteWasmPluginVersionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteWasmPluginVersion = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteWasmPluginVersion(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteWasmPluginVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteWasmPluginVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateEndpointPolicyProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateEndpointPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkDeleteWasmPluginVersionProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteWasmPluginVersionProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkUpdateEndpointPolicyProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateEndpointPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteWasmPluginVersionProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteWasmPluginVersionProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createWasmPlugin', () => { + it('invokes createWasmPlugin without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateWasmPluginRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateWasmPluginRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createWasmPlugin = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createWasmPlugin(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createWasmPlugin as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createWasmPlugin as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteEndpointPolicy', () => { - it('invokes deleteEndpointPolicy without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteEndpointPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteEndpointPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteEndpointPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteEndpointPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteEndpointPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEndpointPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createWasmPlugin without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateWasmPluginRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateWasmPluginRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createWasmPlugin = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createWasmPlugin( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1.IWasmPlugin, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1.IWasmPlugin, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createWasmPlugin as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createWasmPlugin as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteEndpointPolicy without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteEndpointPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteEndpointPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteEndpointPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteEndpointPolicy( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteEndpointPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEndpointPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createWasmPlugin with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateWasmPluginRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateWasmPluginRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createWasmPlugin = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createWasmPlugin(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createWasmPlugin as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createWasmPlugin as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteEndpointPolicy with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteEndpointPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteEndpointPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteEndpointPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteEndpointPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteEndpointPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEndpointPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createWasmPlugin with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateWasmPluginRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateWasmPluginRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createWasmPlugin = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createWasmPlugin(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createWasmPlugin as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createWasmPlugin as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteEndpointPolicy with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteEndpointPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteEndpointPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteEndpointPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteEndpointPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteEndpointPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEndpointPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateWasmPluginProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateWasmPluginProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteEndpointPolicyProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteEndpointPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkCreateWasmPluginProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateWasmPluginProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateWasmPlugin', () => { + it('invokes updateWasmPlugin without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateWasmPluginRequest(), + ); + request.wasmPlugin ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateWasmPluginRequest', + ['wasmPlugin', 'name'], + ); + request.wasmPlugin.name = defaultValue1; + const expectedHeaderRequestParams = `wasm_plugin.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateWasmPlugin = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateWasmPlugin(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateWasmPlugin as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateWasmPlugin as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteEndpointPolicyProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteEndpointPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateWasmPlugin without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateWasmPluginRequest(), + ); + request.wasmPlugin ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateWasmPluginRequest', + ['wasmPlugin', 'name'], + ); + request.wasmPlugin.name = defaultValue1; + const expectedHeaderRequestParams = `wasm_plugin.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateWasmPlugin = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateWasmPlugin( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1.IWasmPlugin, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1.IWasmPlugin, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateWasmPlugin as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateWasmPlugin as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createWasmPluginVersion', () => { - it('invokes createWasmPluginVersion without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateWasmPluginVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateWasmPluginVersionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createWasmPluginVersion = stubLongRunningCall(expectedResponse); - const [operation] = await client.createWasmPluginVersion(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createWasmPluginVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createWasmPluginVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateWasmPlugin with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateWasmPluginRequest(), + ); + request.wasmPlugin ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateWasmPluginRequest', + ['wasmPlugin', 'name'], + ); + request.wasmPlugin.name = defaultValue1; + const expectedHeaderRequestParams = `wasm_plugin.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateWasmPlugin = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateWasmPlugin(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateWasmPlugin as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateWasmPlugin as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createWasmPluginVersion without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateWasmPluginVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateWasmPluginVersionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createWasmPluginVersion = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createWasmPluginVersion( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createWasmPluginVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createWasmPluginVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateWasmPlugin with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateWasmPluginRequest(), + ); + request.wasmPlugin ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateWasmPluginRequest', + ['wasmPlugin', 'name'], + ); + request.wasmPlugin.name = defaultValue1; + const expectedHeaderRequestParams = `wasm_plugin.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateWasmPlugin = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateWasmPlugin(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateWasmPlugin as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateWasmPlugin as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createWasmPluginVersion with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateWasmPluginVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateWasmPluginVersionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createWasmPluginVersion = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createWasmPluginVersion(request), expectedError); - const actualRequest = (client.innerApiCalls.createWasmPluginVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createWasmPluginVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateWasmPluginProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateWasmPluginProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createWasmPluginVersion with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateWasmPluginVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateWasmPluginVersionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createWasmPluginVersion = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createWasmPluginVersion(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createWasmPluginVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createWasmPluginVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateWasmPluginProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateWasmPluginProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteWasmPlugin', () => { + it('invokes deleteWasmPlugin without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteWasmPluginRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteWasmPluginRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteWasmPlugin = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteWasmPlugin(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteWasmPlugin as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteWasmPlugin as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateWasmPluginVersionProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateWasmPluginVersionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteWasmPlugin without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteWasmPluginRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteWasmPluginRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteWasmPlugin = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteWasmPlugin( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteWasmPlugin as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteWasmPlugin as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateWasmPluginVersionProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateWasmPluginVersionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteWasmPlugin with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteWasmPluginRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteWasmPluginRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteWasmPlugin = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteWasmPlugin(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteWasmPlugin as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteWasmPlugin as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteWasmPluginVersion', () => { - it('invokes deleteWasmPluginVersion without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteWasmPluginVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteWasmPluginVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteWasmPluginVersion = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteWasmPluginVersion(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteWasmPluginVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteWasmPluginVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteWasmPlugin with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteWasmPluginRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteWasmPluginRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteWasmPlugin = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteWasmPlugin(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteWasmPlugin as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteWasmPlugin as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteWasmPluginVersion without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteWasmPluginVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteWasmPluginVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteWasmPluginVersion = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteWasmPluginVersion( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteWasmPluginVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteWasmPluginVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteWasmPluginProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteWasmPluginProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteWasmPluginVersion with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteWasmPluginVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteWasmPluginVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteWasmPluginVersion = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteWasmPluginVersion(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteWasmPluginVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteWasmPluginVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteWasmPluginProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteWasmPluginProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createGateway', () => { + it('invokes createGateway without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateGatewayRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateGatewayRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createGateway = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createGateway(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createGateway as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createGateway as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteWasmPluginVersion with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteWasmPluginVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteWasmPluginVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteWasmPluginVersion = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteWasmPluginVersion(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteWasmPluginVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteWasmPluginVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createGateway without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateGatewayRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateGatewayRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createGateway = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createGateway( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1.IGateway, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1.IGateway, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createGateway as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createGateway as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteWasmPluginVersionProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteWasmPluginVersionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createGateway with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateGatewayRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateGatewayRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createGateway = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createGateway(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createGateway as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createGateway as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteWasmPluginVersionProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteWasmPluginVersionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createGateway with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateGatewayRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateGatewayRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createGateway = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createGateway(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createGateway as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createGateway as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createWasmPlugin', () => { - it('invokes createWasmPlugin without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateWasmPluginRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateWasmPluginRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createWasmPlugin = stubLongRunningCall(expectedResponse); - const [operation] = await client.createWasmPlugin(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createWasmPlugin as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createWasmPlugin as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateGatewayProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateGatewayProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createWasmPlugin without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateWasmPluginRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateWasmPluginRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createWasmPlugin = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createWasmPlugin( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createWasmPlugin as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createWasmPlugin as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateGatewayProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateGatewayProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateGateway', () => { + it('invokes updateGateway without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateGatewayRequest(), + ); + request.gateway ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateGatewayRequest', + ['gateway', 'name'], + ); + request.gateway.name = defaultValue1; + const expectedHeaderRequestParams = `gateway.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateGateway = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateGateway(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateGateway as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateGateway as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createWasmPlugin with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateWasmPluginRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateWasmPluginRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createWasmPlugin = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createWasmPlugin(request), expectedError); - const actualRequest = (client.innerApiCalls.createWasmPlugin as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createWasmPlugin as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateGateway without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateGatewayRequest(), + ); + request.gateway ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateGatewayRequest', + ['gateway', 'name'], + ); + request.gateway.name = defaultValue1; + const expectedHeaderRequestParams = `gateway.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateGateway = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateGateway( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1.IGateway, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1.IGateway, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateGateway as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateGateway as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createWasmPlugin with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateWasmPluginRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateWasmPluginRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createWasmPlugin = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createWasmPlugin(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createWasmPlugin as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createWasmPlugin as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateGateway with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateGatewayRequest(), + ); + request.gateway ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateGatewayRequest', + ['gateway', 'name'], + ); + request.gateway.name = defaultValue1; + const expectedHeaderRequestParams = `gateway.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateGateway = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateGateway(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateGateway as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateGateway as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateWasmPluginProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateWasmPluginProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateGateway with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateGatewayRequest(), + ); + request.gateway ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateGatewayRequest', + ['gateway', 'name'], + ); + request.gateway.name = defaultValue1; + const expectedHeaderRequestParams = `gateway.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateGateway = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateGateway(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateGateway as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateGateway as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateWasmPluginProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateWasmPluginProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpdateGatewayProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateGatewayProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('updateWasmPlugin', () => { - it('invokes updateWasmPlugin without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateWasmPluginRequest() - ); - request.wasmPlugin ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateWasmPluginRequest', ['wasmPlugin', 'name']); - request.wasmPlugin.name = defaultValue1; - const expectedHeaderRequestParams = `wasm_plugin.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateWasmPlugin = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateWasmPlugin(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateWasmPlugin as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateWasmPlugin as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateGatewayProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateGatewayProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteGateway', () => { + it('invokes deleteGateway without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteGatewayRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteGatewayRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteGateway = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteGateway(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteGateway as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteGateway as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateWasmPlugin without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateWasmPluginRequest() - ); - request.wasmPlugin ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateWasmPluginRequest', ['wasmPlugin', 'name']); - request.wasmPlugin.name = defaultValue1; - const expectedHeaderRequestParams = `wasm_plugin.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateWasmPlugin = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateWasmPlugin( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateWasmPlugin as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateWasmPlugin as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteGateway without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteGatewayRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteGatewayRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteGateway = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteGateway( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteGateway as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteGateway as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateWasmPlugin with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateWasmPluginRequest() - ); - request.wasmPlugin ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateWasmPluginRequest', ['wasmPlugin', 'name']); - request.wasmPlugin.name = defaultValue1; - const expectedHeaderRequestParams = `wasm_plugin.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateWasmPlugin = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateWasmPlugin(request), expectedError); - const actualRequest = (client.innerApiCalls.updateWasmPlugin as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateWasmPlugin as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteGateway with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteGatewayRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteGatewayRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteGateway = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteGateway(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteGateway as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteGateway as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateWasmPlugin with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateWasmPluginRequest() - ); - request.wasmPlugin ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateWasmPluginRequest', ['wasmPlugin', 'name']); - request.wasmPlugin.name = defaultValue1; - const expectedHeaderRequestParams = `wasm_plugin.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateWasmPlugin = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateWasmPlugin(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateWasmPlugin as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateWasmPlugin as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteGateway with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteGatewayRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteGatewayRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteGateway = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteGateway(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteGateway as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteGateway as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateWasmPluginProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateWasmPluginProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkDeleteGatewayProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteGatewayProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkUpdateWasmPluginProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateWasmPluginProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteGatewayProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteGatewayProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createGrpcRoute', () => { + it('invokes createGrpcRoute without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateGrpcRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateGrpcRouteRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createGrpcRoute = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createGrpcRoute(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createGrpcRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createGrpcRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteWasmPlugin', () => { - it('invokes deleteWasmPlugin without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteWasmPluginRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteWasmPluginRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteWasmPlugin = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteWasmPlugin(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteWasmPlugin as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteWasmPlugin as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createGrpcRoute without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateGrpcRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateGrpcRouteRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createGrpcRoute = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createGrpcRoute( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1.IGrpcRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1.IGrpcRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createGrpcRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createGrpcRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteWasmPlugin without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteWasmPluginRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteWasmPluginRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteWasmPlugin = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteWasmPlugin( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteWasmPlugin as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteWasmPlugin as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createGrpcRoute with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateGrpcRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateGrpcRouteRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createGrpcRoute = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createGrpcRoute(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createGrpcRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createGrpcRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteWasmPlugin with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteWasmPluginRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteWasmPluginRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteWasmPlugin = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteWasmPlugin(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteWasmPlugin as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteWasmPlugin as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteWasmPlugin with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteWasmPluginRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteWasmPluginRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteWasmPlugin = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteWasmPlugin(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteWasmPlugin as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteWasmPlugin as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createGrpcRoute with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateGrpcRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateGrpcRouteRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createGrpcRoute = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createGrpcRoute(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createGrpcRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createGrpcRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteWasmPluginProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteWasmPluginProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkCreateGrpcRouteProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateGrpcRouteProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteWasmPluginProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteWasmPluginProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateGrpcRouteProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateGrpcRouteProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateGrpcRoute', () => { + it('invokes updateGrpcRoute without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateGrpcRouteRequest(), + ); + request.grpcRoute ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateGrpcRouteRequest', + ['grpcRoute', 'name'], + ); + request.grpcRoute.name = defaultValue1; + const expectedHeaderRequestParams = `grpc_route.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateGrpcRoute = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateGrpcRoute(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateGrpcRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateGrpcRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createGateway', () => { - it('invokes createGateway without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateGatewayRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateGatewayRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createGateway = stubLongRunningCall(expectedResponse); - const [operation] = await client.createGateway(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createGateway as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createGateway as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateGrpcRoute without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateGrpcRouteRequest(), + ); + request.grpcRoute ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateGrpcRouteRequest', + ['grpcRoute', 'name'], + ); + request.grpcRoute.name = defaultValue1; + const expectedHeaderRequestParams = `grpc_route.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateGrpcRoute = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateGrpcRoute( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1.IGrpcRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1.IGrpcRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateGrpcRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateGrpcRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createGateway without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateGatewayRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateGatewayRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createGateway = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createGateway( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createGateway as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createGateway as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateGrpcRoute with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateGrpcRouteRequest(), + ); + request.grpcRoute ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateGrpcRouteRequest', + ['grpcRoute', 'name'], + ); + request.grpcRoute.name = defaultValue1; + const expectedHeaderRequestParams = `grpc_route.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateGrpcRoute = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateGrpcRoute(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateGrpcRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateGrpcRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createGateway with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateGatewayRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateGatewayRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createGateway = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createGateway(request), expectedError); - const actualRequest = (client.innerApiCalls.createGateway as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createGateway as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateGrpcRoute with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateGrpcRouteRequest(), + ); + request.grpcRoute ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateGrpcRouteRequest', + ['grpcRoute', 'name'], + ); + request.grpcRoute.name = defaultValue1; + const expectedHeaderRequestParams = `grpc_route.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateGrpcRoute = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateGrpcRoute(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateGrpcRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateGrpcRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createGateway with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateGatewayRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateGatewayRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createGateway = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createGateway(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createGateway as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createGateway as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateGrpcRouteProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateGrpcRouteProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkCreateGatewayProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateGatewayProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateGrpcRouteProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateGrpcRouteProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteGrpcRoute', () => { + it('invokes deleteGrpcRoute without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteGrpcRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteGrpcRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteGrpcRoute = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteGrpcRoute(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteGrpcRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteGrpcRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateGatewayProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateGatewayProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteGrpcRoute without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteGrpcRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteGrpcRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteGrpcRoute = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteGrpcRoute( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteGrpcRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteGrpcRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateGateway', () => { - it('invokes updateGateway without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateGatewayRequest() - ); - request.gateway ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateGatewayRequest', ['gateway', 'name']); - request.gateway.name = defaultValue1; - const expectedHeaderRequestParams = `gateway.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateGateway = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateGateway(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateGateway as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateGateway as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteGrpcRoute with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteGrpcRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteGrpcRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteGrpcRoute = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteGrpcRoute(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteGrpcRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteGrpcRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateGateway without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateGatewayRequest() - ); - request.gateway ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateGatewayRequest', ['gateway', 'name']); - request.gateway.name = defaultValue1; - const expectedHeaderRequestParams = `gateway.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateGateway = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateGateway( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateGateway as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateGateway as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteGrpcRoute with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteGrpcRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteGrpcRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteGrpcRoute = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteGrpcRoute(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteGrpcRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteGrpcRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateGateway with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateGatewayRequest() - ); - request.gateway ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateGatewayRequest', ['gateway', 'name']); - request.gateway.name = defaultValue1; - const expectedHeaderRequestParams = `gateway.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateGateway = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateGateway(request), expectedError); - const actualRequest = (client.innerApiCalls.updateGateway as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateGateway as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteGrpcRouteProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteGrpcRouteProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateGateway with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateGatewayRequest() - ); - request.gateway ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateGatewayRequest', ['gateway', 'name']); - request.gateway.name = defaultValue1; - const expectedHeaderRequestParams = `gateway.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateGateway = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateGateway(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateGateway as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateGateway as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteGrpcRouteProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteGrpcRouteProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createHttpRoute', () => { + it('invokes createHttpRoute without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateHttpRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateHttpRouteRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createHttpRoute = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createHttpRoute(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createHttpRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createHttpRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateGatewayProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateGatewayProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createHttpRoute without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateHttpRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateHttpRouteRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createHttpRoute = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createHttpRoute( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1.IHttpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1.IHttpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createHttpRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createHttpRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateGatewayProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateGatewayProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createHttpRoute with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateHttpRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateHttpRouteRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createHttpRoute = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createHttpRoute(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createHttpRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createHttpRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteGateway', () => { - it('invokes deleteGateway without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteGatewayRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteGatewayRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteGateway = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteGateway(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteGateway as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteGateway as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createHttpRoute with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateHttpRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateHttpRouteRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createHttpRoute = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createHttpRoute(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createHttpRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createHttpRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteGateway without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteGatewayRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteGatewayRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteGateway = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteGateway( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteGateway as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteGateway as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateHttpRouteProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateHttpRouteProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteGateway with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteGatewayRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteGatewayRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteGateway = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteGateway(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteGateway as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteGateway as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateHttpRouteProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateHttpRouteProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateHttpRoute', () => { + it('invokes updateHttpRoute without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateHttpRouteRequest(), + ); + request.httpRoute ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateHttpRouteRequest', + ['httpRoute', 'name'], + ); + request.httpRoute.name = defaultValue1; + const expectedHeaderRequestParams = `http_route.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateHttpRoute = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateHttpRoute(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateHttpRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateHttpRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteGateway with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteGatewayRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteGatewayRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteGateway = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteGateway(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteGateway as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteGateway as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateHttpRoute without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateHttpRouteRequest(), + ); + request.httpRoute ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateHttpRouteRequest', + ['httpRoute', 'name'], + ); + request.httpRoute.name = defaultValue1; + const expectedHeaderRequestParams = `http_route.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateHttpRoute = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateHttpRoute( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1.IHttpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1.IHttpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateHttpRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateHttpRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteGatewayProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteGatewayProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateHttpRoute with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateHttpRouteRequest(), + ); + request.httpRoute ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateHttpRouteRequest', + ['httpRoute', 'name'], + ); + request.httpRoute.name = defaultValue1; + const expectedHeaderRequestParams = `http_route.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateHttpRoute = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateHttpRoute(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateHttpRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateHttpRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteGatewayProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteGatewayProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateHttpRoute with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateHttpRouteRequest(), + ); + request.httpRoute ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateHttpRouteRequest', + ['httpRoute', 'name'], + ); + request.httpRoute.name = defaultValue1; + const expectedHeaderRequestParams = `http_route.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateHttpRoute = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateHttpRoute(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateHttpRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateHttpRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createGrpcRoute', () => { - it('invokes createGrpcRoute without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateGrpcRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateGrpcRouteRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createGrpcRoute = stubLongRunningCall(expectedResponse); - const [operation] = await client.createGrpcRoute(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createGrpcRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createGrpcRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateHttpRouteProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateHttpRouteProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createGrpcRoute without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateGrpcRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateGrpcRouteRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createGrpcRoute = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createGrpcRoute( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createGrpcRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createGrpcRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateHttpRouteProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateHttpRouteProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteHttpRoute', () => { + it('invokes deleteHttpRoute without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteHttpRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteHttpRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteHttpRoute = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteHttpRoute(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteHttpRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteHttpRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createGrpcRoute with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateGrpcRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateGrpcRouteRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createGrpcRoute = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createGrpcRoute(request), expectedError); - const actualRequest = (client.innerApiCalls.createGrpcRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createGrpcRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteHttpRoute without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteHttpRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteHttpRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteHttpRoute = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteHttpRoute( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteHttpRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteHttpRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createGrpcRoute with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateGrpcRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateGrpcRouteRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createGrpcRoute = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createGrpcRoute(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createGrpcRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createGrpcRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteHttpRoute with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteHttpRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteHttpRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteHttpRoute = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteHttpRoute(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteHttpRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteHttpRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateGrpcRouteProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateGrpcRouteProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteHttpRoute with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteHttpRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteHttpRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteHttpRoute = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteHttpRoute(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteHttpRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteHttpRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateGrpcRouteProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateGrpcRouteProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteHttpRouteProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteHttpRouteProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('updateGrpcRoute', () => { - it('invokes updateGrpcRoute without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateGrpcRouteRequest() - ); - request.grpcRoute ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateGrpcRouteRequest', ['grpcRoute', 'name']); - request.grpcRoute.name = defaultValue1; - const expectedHeaderRequestParams = `grpc_route.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateGrpcRoute = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateGrpcRoute(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateGrpcRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateGrpcRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteHttpRouteProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteHttpRouteProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createTcpRoute', () => { + it('invokes createTcpRoute without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateTcpRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateTcpRouteRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createTcpRoute = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createTcpRoute(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createTcpRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTcpRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateGrpcRoute without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateGrpcRouteRequest() - ); - request.grpcRoute ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateGrpcRouteRequest', ['grpcRoute', 'name']); - request.grpcRoute.name = defaultValue1; - const expectedHeaderRequestParams = `grpc_route.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateGrpcRoute = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateGrpcRoute( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateGrpcRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateGrpcRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createTcpRoute without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateTcpRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateTcpRouteRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createTcpRoute = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createTcpRoute( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1.ITcpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1.ITcpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createTcpRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTcpRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateGrpcRoute with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateGrpcRouteRequest() - ); - request.grpcRoute ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateGrpcRouteRequest', ['grpcRoute', 'name']); - request.grpcRoute.name = defaultValue1; - const expectedHeaderRequestParams = `grpc_route.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateGrpcRoute = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateGrpcRoute(request), expectedError); - const actualRequest = (client.innerApiCalls.updateGrpcRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateGrpcRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createTcpRoute with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateTcpRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateTcpRouteRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createTcpRoute = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createTcpRoute(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createTcpRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTcpRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateGrpcRoute with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateGrpcRouteRequest() - ); - request.grpcRoute ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateGrpcRouteRequest', ['grpcRoute', 'name']); - request.grpcRoute.name = defaultValue1; - const expectedHeaderRequestParams = `grpc_route.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateGrpcRoute = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateGrpcRoute(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateGrpcRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateGrpcRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createTcpRoute with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateTcpRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateTcpRouteRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createTcpRoute = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createTcpRoute(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createTcpRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTcpRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateGrpcRouteProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateGrpcRouteProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkCreateTcpRouteProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateTcpRouteProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkUpdateGrpcRouteProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateGrpcRouteProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateTcpRouteProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateTcpRouteProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateTcpRoute', () => { + it('invokes updateTcpRoute without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateTcpRouteRequest(), + ); + request.tcpRoute ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateTcpRouteRequest', + ['tcpRoute', 'name'], + ); + request.tcpRoute.name = defaultValue1; + const expectedHeaderRequestParams = `tcp_route.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateTcpRoute = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateTcpRoute(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateTcpRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTcpRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteGrpcRoute', () => { - it('invokes deleteGrpcRoute without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteGrpcRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteGrpcRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteGrpcRoute = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteGrpcRoute(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteGrpcRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteGrpcRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateTcpRoute without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateTcpRouteRequest(), + ); + request.tcpRoute ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateTcpRouteRequest', + ['tcpRoute', 'name'], + ); + request.tcpRoute.name = defaultValue1; + const expectedHeaderRequestParams = `tcp_route.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateTcpRoute = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateTcpRoute( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1.ITcpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1.ITcpRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateTcpRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTcpRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteGrpcRoute without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteGrpcRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteGrpcRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteGrpcRoute = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteGrpcRoute( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteGrpcRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteGrpcRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateTcpRoute with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateTcpRouteRequest(), + ); + request.tcpRoute ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateTcpRouteRequest', + ['tcpRoute', 'name'], + ); + request.tcpRoute.name = defaultValue1; + const expectedHeaderRequestParams = `tcp_route.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateTcpRoute = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateTcpRoute(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateTcpRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTcpRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteGrpcRoute with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteGrpcRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteGrpcRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteGrpcRoute = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteGrpcRoute(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteGrpcRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteGrpcRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateTcpRoute with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateTcpRouteRequest(), + ); + request.tcpRoute ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateTcpRouteRequest', + ['tcpRoute', 'name'], + ); + request.tcpRoute.name = defaultValue1; + const expectedHeaderRequestParams = `tcp_route.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateTcpRoute = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateTcpRoute(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateTcpRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTcpRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteGrpcRoute with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteGrpcRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteGrpcRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteGrpcRoute = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteGrpcRoute(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteGrpcRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteGrpcRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateTcpRouteProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateTcpRouteProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteGrpcRouteProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteGrpcRouteProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateTcpRouteProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateTcpRouteProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteTcpRoute', () => { + it('invokes deleteTcpRoute without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteTcpRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteTcpRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteTcpRoute = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteTcpRoute(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteTcpRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTcpRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteGrpcRouteProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteGrpcRouteProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteTcpRoute without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteTcpRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteTcpRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteTcpRoute = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteTcpRoute( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteTcpRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTcpRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createHttpRoute', () => { - it('invokes createHttpRoute without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateHttpRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateHttpRouteRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createHttpRoute = stubLongRunningCall(expectedResponse); - const [operation] = await client.createHttpRoute(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createHttpRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createHttpRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteTcpRoute with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteTcpRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteTcpRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteTcpRoute = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteTcpRoute(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteTcpRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTcpRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createHttpRoute without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateHttpRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateHttpRouteRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createHttpRoute = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createHttpRoute( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createHttpRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createHttpRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteTcpRoute with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteTcpRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteTcpRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteTcpRoute = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteTcpRoute(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteTcpRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTcpRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createHttpRoute with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateHttpRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateHttpRouteRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createHttpRoute = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createHttpRoute(request), expectedError); - const actualRequest = (client.innerApiCalls.createHttpRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createHttpRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteTcpRouteProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteTcpRouteProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createHttpRoute with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateHttpRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateHttpRouteRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createHttpRoute = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createHttpRoute(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createHttpRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createHttpRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteTcpRouteProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteTcpRouteProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createTlsRoute', () => { + it('invokes createTlsRoute without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateTlsRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateTlsRouteRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createTlsRoute = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createTlsRoute(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createTlsRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTlsRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateHttpRouteProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateHttpRouteProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createTlsRoute without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateTlsRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateTlsRouteRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createTlsRoute = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createTlsRoute( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1.ITlsRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1.ITlsRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createTlsRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTlsRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateHttpRouteProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateHttpRouteProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createTlsRoute with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateTlsRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateTlsRouteRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createTlsRoute = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createTlsRoute(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createTlsRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTlsRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateHttpRoute', () => { - it('invokes updateHttpRoute without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateHttpRouteRequest() - ); - request.httpRoute ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateHttpRouteRequest', ['httpRoute', 'name']); - request.httpRoute.name = defaultValue1; - const expectedHeaderRequestParams = `http_route.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateHttpRoute = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateHttpRoute(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateHttpRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateHttpRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createTlsRoute with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateTlsRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateTlsRouteRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createTlsRoute = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createTlsRoute(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createTlsRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTlsRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateHttpRoute without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateHttpRouteRequest() - ); - request.httpRoute ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateHttpRouteRequest', ['httpRoute', 'name']); - request.httpRoute.name = defaultValue1; - const expectedHeaderRequestParams = `http_route.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateHttpRoute = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateHttpRoute( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateHttpRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateHttpRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateTlsRouteProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateTlsRouteProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateHttpRoute with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateHttpRouteRequest() - ); - request.httpRoute ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateHttpRouteRequest', ['httpRoute', 'name']); - request.httpRoute.name = defaultValue1; - const expectedHeaderRequestParams = `http_route.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateHttpRoute = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateHttpRoute(request), expectedError); - const actualRequest = (client.innerApiCalls.updateHttpRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateHttpRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateTlsRouteProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateTlsRouteProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateTlsRoute', () => { + it('invokes updateTlsRoute without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateTlsRouteRequest(), + ); + request.tlsRoute ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateTlsRouteRequest', + ['tlsRoute', 'name'], + ); + request.tlsRoute.name = defaultValue1; + const expectedHeaderRequestParams = `tls_route.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateTlsRoute = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateTlsRoute(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateTlsRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTlsRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateHttpRoute with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateHttpRouteRequest() - ); - request.httpRoute ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateHttpRouteRequest', ['httpRoute', 'name']); - request.httpRoute.name = defaultValue1; - const expectedHeaderRequestParams = `http_route.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateHttpRoute = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateHttpRoute(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateHttpRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateHttpRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateTlsRoute without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateTlsRouteRequest(), + ); + request.tlsRoute ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateTlsRouteRequest', + ['tlsRoute', 'name'], + ); + request.tlsRoute.name = defaultValue1; + const expectedHeaderRequestParams = `tls_route.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateTlsRoute = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateTlsRoute( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1.ITlsRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1.ITlsRoute, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateTlsRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTlsRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateHttpRouteProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateHttpRouteProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateTlsRoute with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateTlsRouteRequest(), + ); + request.tlsRoute ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateTlsRouteRequest', + ['tlsRoute', 'name'], + ); + request.tlsRoute.name = defaultValue1; + const expectedHeaderRequestParams = `tls_route.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateTlsRoute = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateTlsRoute(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateTlsRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTlsRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateHttpRouteProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateHttpRouteProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateTlsRoute with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateTlsRouteRequest(), + ); + request.tlsRoute ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateTlsRouteRequest', + ['tlsRoute', 'name'], + ); + request.tlsRoute.name = defaultValue1; + const expectedHeaderRequestParams = `tls_route.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateTlsRoute = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateTlsRoute(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateTlsRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTlsRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteHttpRoute', () => { - it('invokes deleteHttpRoute without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteHttpRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteHttpRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteHttpRoute = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteHttpRoute(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteHttpRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteHttpRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateTlsRouteProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateTlsRouteProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteHttpRoute without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteHttpRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteHttpRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteHttpRoute = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteHttpRoute( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteHttpRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteHttpRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateTlsRouteProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateTlsRouteProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteTlsRoute', () => { + it('invokes deleteTlsRoute without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteTlsRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteTlsRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteTlsRoute = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteTlsRoute(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteTlsRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTlsRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteHttpRoute with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteHttpRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteHttpRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteHttpRoute = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteHttpRoute(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteHttpRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteHttpRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteTlsRoute without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteTlsRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteTlsRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteTlsRoute = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteTlsRoute( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteTlsRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTlsRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteHttpRoute with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteHttpRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteHttpRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteHttpRoute = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteHttpRoute(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteHttpRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteHttpRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteTlsRoute with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteTlsRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteTlsRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteTlsRoute = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteTlsRoute(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteTlsRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTlsRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteHttpRouteProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteHttpRouteProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteTlsRoute with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteTlsRouteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteTlsRouteRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteTlsRoute = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteTlsRoute(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteTlsRoute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTlsRoute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteHttpRouteProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteHttpRouteProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteTlsRouteProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteTlsRouteProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('createTcpRoute', () => { - it('invokes createTcpRoute without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateTcpRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateTcpRouteRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createTcpRoute = stubLongRunningCall(expectedResponse); - const [operation] = await client.createTcpRoute(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createTcpRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTcpRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteTlsRouteProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteTlsRouteProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createServiceBinding', () => { + it('invokes createServiceBinding without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateServiceBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateServiceBindingRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createServiceBinding = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createServiceBinding(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createServiceBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createServiceBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createTcpRoute without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateTcpRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateTcpRouteRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createTcpRoute = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createTcpRoute( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createTcpRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTcpRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createServiceBinding without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateServiceBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateServiceBindingRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createServiceBinding = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createServiceBinding( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1.IServiceBinding, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1.IServiceBinding, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createServiceBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createServiceBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createTcpRoute with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateTcpRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateTcpRouteRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createTcpRoute = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createTcpRoute(request), expectedError); - const actualRequest = (client.innerApiCalls.createTcpRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTcpRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createServiceBinding with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateServiceBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateServiceBindingRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createServiceBinding = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createServiceBinding(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createServiceBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createServiceBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createTcpRoute with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateTcpRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateTcpRouteRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createTcpRoute = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createTcpRoute(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createTcpRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTcpRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createServiceBinding with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateServiceBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateServiceBindingRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createServiceBinding = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createServiceBinding(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createServiceBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createServiceBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateTcpRouteProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateTcpRouteProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkCreateServiceBindingProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateServiceBindingProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkCreateTcpRouteProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateTcpRouteProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateServiceBindingProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateServiceBindingProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateServiceBinding', () => { + it('invokes updateServiceBinding without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateServiceBindingRequest(), + ); + request.serviceBinding ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateServiceBindingRequest', + ['serviceBinding', 'name'], + ); + request.serviceBinding.name = defaultValue1; + const expectedHeaderRequestParams = `service_binding.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateServiceBinding = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateServiceBinding(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateServiceBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateServiceBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateTcpRoute', () => { - it('invokes updateTcpRoute without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateTcpRouteRequest() - ); - request.tcpRoute ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateTcpRouteRequest', ['tcpRoute', 'name']); - request.tcpRoute.name = defaultValue1; - const expectedHeaderRequestParams = `tcp_route.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateTcpRoute = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateTcpRoute(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateTcpRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTcpRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateServiceBinding without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateServiceBindingRequest(), + ); + request.serviceBinding ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateServiceBindingRequest', + ['serviceBinding', 'name'], + ); + request.serviceBinding.name = defaultValue1; + const expectedHeaderRequestParams = `service_binding.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateServiceBinding = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateServiceBinding( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1.IServiceBinding, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1.IServiceBinding, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateServiceBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateServiceBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateTcpRoute without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateTcpRouteRequest() - ); - request.tcpRoute ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateTcpRouteRequest', ['tcpRoute', 'name']); - request.tcpRoute.name = defaultValue1; - const expectedHeaderRequestParams = `tcp_route.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateTcpRoute = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateTcpRoute( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateTcpRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTcpRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateServiceBinding with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateServiceBindingRequest(), + ); + request.serviceBinding ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateServiceBindingRequest', + ['serviceBinding', 'name'], + ); + request.serviceBinding.name = defaultValue1; + const expectedHeaderRequestParams = `service_binding.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateServiceBinding = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateServiceBinding(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateServiceBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateServiceBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateTcpRoute with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateTcpRouteRequest() - ); - request.tcpRoute ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateTcpRouteRequest', ['tcpRoute', 'name']); - request.tcpRoute.name = defaultValue1; - const expectedHeaderRequestParams = `tcp_route.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateTcpRoute = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateTcpRoute(request), expectedError); - const actualRequest = (client.innerApiCalls.updateTcpRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTcpRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateServiceBinding with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateServiceBindingRequest(), + ); + request.serviceBinding ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateServiceBindingRequest', + ['serviceBinding', 'name'], + ); + request.serviceBinding.name = defaultValue1; + const expectedHeaderRequestParams = `service_binding.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateServiceBinding = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateServiceBinding(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateServiceBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateServiceBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateTcpRoute with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateTcpRouteRequest() - ); - request.tcpRoute ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateTcpRouteRequest', ['tcpRoute', 'name']); - request.tcpRoute.name = defaultValue1; - const expectedHeaderRequestParams = `tcp_route.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateTcpRoute = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateTcpRoute(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateTcpRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTcpRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateServiceBindingProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateServiceBindingProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkUpdateTcpRouteProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateTcpRouteProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateServiceBindingProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateServiceBindingProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteServiceBinding', () => { + it('invokes deleteServiceBinding without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteServiceBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteServiceBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteServiceBinding = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteServiceBinding(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteServiceBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServiceBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateTcpRouteProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateTcpRouteProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteServiceBinding without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteServiceBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteServiceBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteServiceBinding = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteServiceBinding( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteServiceBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServiceBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteTcpRoute', () => { - it('invokes deleteTcpRoute without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteTcpRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteTcpRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteTcpRoute = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteTcpRoute(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteTcpRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTcpRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteServiceBinding with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteServiceBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteServiceBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteServiceBinding = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteServiceBinding(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteServiceBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServiceBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTcpRoute without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteTcpRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteTcpRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteTcpRoute = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteTcpRoute( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteTcpRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTcpRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteServiceBinding with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteServiceBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteServiceBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteServiceBinding = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteServiceBinding(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteServiceBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServiceBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTcpRoute with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteTcpRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteTcpRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteTcpRoute = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteTcpRoute(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteTcpRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTcpRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteServiceBindingProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteServiceBindingProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteTcpRoute with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteTcpRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteTcpRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteTcpRoute = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteTcpRoute(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteTcpRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTcpRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteServiceBindingProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteServiceBindingProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createMesh', () => { + it('invokes createMesh without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateMeshRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateMeshRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createMesh = stubLongRunningCall(expectedResponse); + const [operation] = await client.createMesh(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createMesh as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMesh as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteTcpRouteProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteTcpRouteProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createMesh without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateMeshRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateMeshRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createMesh = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createMesh( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1.IMesh, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1.IMesh, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createMesh as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMesh as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteTcpRouteProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteTcpRouteProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createMesh with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateMeshRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateMeshRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createMesh = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createMesh(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createMesh as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMesh as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createTlsRoute', () => { - it('invokes createTlsRoute without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateTlsRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateTlsRouteRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createTlsRoute = stubLongRunningCall(expectedResponse); - const [operation] = await client.createTlsRoute(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createTlsRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTlsRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createMesh with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateMeshRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateMeshRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createMesh = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createMesh(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createMesh as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMesh as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createTlsRoute without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateTlsRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateTlsRouteRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createTlsRoute = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createTlsRoute( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createTlsRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTlsRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateMeshProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateMeshProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createTlsRoute with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateTlsRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateTlsRouteRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createTlsRoute = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createTlsRoute(request), expectedError); - const actualRequest = (client.innerApiCalls.createTlsRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTlsRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateMeshProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkCreateMeshProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateMesh', () => { + it('invokes updateMesh without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateMeshRequest(), + ); + request.mesh ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateMeshRequest', + ['mesh', 'name'], + ); + request.mesh.name = defaultValue1; + const expectedHeaderRequestParams = `mesh.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateMesh = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateMesh(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateMesh as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMesh as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createTlsRoute with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateTlsRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateTlsRouteRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createTlsRoute = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createTlsRoute(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createTlsRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTlsRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateMesh without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateMeshRequest(), + ); + request.mesh ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateMeshRequest', + ['mesh', 'name'], + ); + request.mesh.name = defaultValue1; + const expectedHeaderRequestParams = `mesh.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateMesh = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateMesh( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1.IMesh, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1.IMesh, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateMesh as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMesh as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateTlsRouteProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateTlsRouteProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateMesh with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateMeshRequest(), + ); + request.mesh ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateMeshRequest', + ['mesh', 'name'], + ); + request.mesh.name = defaultValue1; + const expectedHeaderRequestParams = `mesh.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateMesh = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateMesh(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateMesh as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMesh as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateTlsRouteProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateTlsRouteProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateMesh with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateMeshRequest(), + ); + request.mesh ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateMeshRequest', + ['mesh', 'name'], + ); + request.mesh.name = defaultValue1; + const expectedHeaderRequestParams = `mesh.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateMesh = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateMesh(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateMesh as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMesh as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateTlsRoute', () => { - it('invokes updateTlsRoute without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateTlsRouteRequest() - ); - request.tlsRoute ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateTlsRouteRequest', ['tlsRoute', 'name']); - request.tlsRoute.name = defaultValue1; - const expectedHeaderRequestParams = `tls_route.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateTlsRoute = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateTlsRoute(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateTlsRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTlsRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateMeshProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateMeshProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateTlsRoute without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateTlsRouteRequest() - ); - request.tlsRoute ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateTlsRouteRequest', ['tlsRoute', 'name']); - request.tlsRoute.name = defaultValue1; - const expectedHeaderRequestParams = `tls_route.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateTlsRoute = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateTlsRoute( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateTlsRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTlsRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateMeshProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkUpdateMeshProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteMesh', () => { + it('invokes deleteMesh without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteMeshRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteMeshRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteMesh = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteMesh(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteMesh as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMesh as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateTlsRoute with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateTlsRouteRequest() - ); - request.tlsRoute ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateTlsRouteRequest', ['tlsRoute', 'name']); - request.tlsRoute.name = defaultValue1; - const expectedHeaderRequestParams = `tls_route.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateTlsRoute = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateTlsRoute(request), expectedError); - const actualRequest = (client.innerApiCalls.updateTlsRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTlsRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteMesh without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteMeshRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteMeshRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteMesh = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteMesh( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteMesh as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMesh as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateTlsRoute with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateTlsRouteRequest() - ); - request.tlsRoute ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateTlsRouteRequest', ['tlsRoute', 'name']); - request.tlsRoute.name = defaultValue1; - const expectedHeaderRequestParams = `tls_route.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateTlsRoute = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateTlsRoute(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateTlsRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTlsRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteMesh with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteMeshRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteMeshRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteMesh = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteMesh(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteMesh as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMesh as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateTlsRouteProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateTlsRouteProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteMesh with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteMeshRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteMeshRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteMesh = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteMesh(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteMesh as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMesh as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateTlsRouteProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateTlsRouteProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteMeshProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteMeshProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('deleteTlsRoute', () => { - it('invokes deleteTlsRoute without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteTlsRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteTlsRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteTlsRoute = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteTlsRoute(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteTlsRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTlsRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteMeshProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkDeleteMeshProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createServiceLbPolicy', () => { + it('invokes createServiceLbPolicy without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateServiceLbPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateServiceLbPolicyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createServiceLbPolicy = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createServiceLbPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createServiceLbPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createServiceLbPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTlsRoute without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteTlsRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteTlsRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteTlsRoute = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteTlsRoute( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteTlsRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTlsRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createServiceLbPolicy without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateServiceLbPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateServiceLbPolicyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createServiceLbPolicy = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createServiceLbPolicy( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1.IServiceLbPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1.IServiceLbPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createServiceLbPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createServiceLbPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTlsRoute with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteTlsRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteTlsRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteTlsRoute = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteTlsRoute(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteTlsRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTlsRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createServiceLbPolicy with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateServiceLbPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateServiceLbPolicyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createServiceLbPolicy = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.createServiceLbPolicy(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createServiceLbPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createServiceLbPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTlsRoute with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteTlsRouteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteTlsRouteRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteTlsRoute = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteTlsRoute(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteTlsRoute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTlsRoute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createServiceLbPolicy with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.CreateServiceLbPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.CreateServiceLbPolicyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createServiceLbPolicy = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createServiceLbPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createServiceLbPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createServiceLbPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteTlsRouteProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteTlsRouteProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkCreateServiceLbPolicyProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateServiceLbPolicyProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteTlsRouteProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteTlsRouteProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateServiceLbPolicyProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateServiceLbPolicyProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateServiceLbPolicy', () => { + it('invokes updateServiceLbPolicy without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateServiceLbPolicyRequest(), + ); + request.serviceLbPolicy ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateServiceLbPolicyRequest', + ['serviceLbPolicy', 'name'], + ); + request.serviceLbPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `service_lb_policy.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateServiceLbPolicy = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateServiceLbPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateServiceLbPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateServiceLbPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createServiceBinding', () => { - it('invokes createServiceBinding without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateServiceBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateServiceBindingRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createServiceBinding = stubLongRunningCall(expectedResponse); - const [operation] = await client.createServiceBinding(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createServiceBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServiceBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateServiceLbPolicy without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateServiceLbPolicyRequest(), + ); + request.serviceLbPolicy ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateServiceLbPolicyRequest', + ['serviceLbPolicy', 'name'], + ); + request.serviceLbPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `service_lb_policy.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateServiceLbPolicy = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateServiceLbPolicy( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1.IServiceLbPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1.IServiceLbPolicy, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateServiceLbPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateServiceLbPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createServiceBinding without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateServiceBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateServiceBindingRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createServiceBinding = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createServiceBinding( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createServiceBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServiceBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateServiceLbPolicy with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateServiceLbPolicyRequest(), + ); + request.serviceLbPolicy ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateServiceLbPolicyRequest', + ['serviceLbPolicy', 'name'], + ); + request.serviceLbPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `service_lb_policy.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateServiceLbPolicy = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.updateServiceLbPolicy(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.updateServiceLbPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateServiceLbPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createServiceBinding with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateServiceBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateServiceBindingRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createServiceBinding = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createServiceBinding(request), expectedError); - const actualRequest = (client.innerApiCalls.createServiceBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServiceBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateServiceLbPolicy with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.UpdateServiceLbPolicyRequest(), + ); + request.serviceLbPolicy ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.UpdateServiceLbPolicyRequest', + ['serviceLbPolicy', 'name'], + ); + request.serviceLbPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `service_lb_policy.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateServiceLbPolicy = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateServiceLbPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateServiceLbPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateServiceLbPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createServiceBinding with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateServiceBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateServiceBindingRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createServiceBinding = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createServiceBinding(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createServiceBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServiceBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateServiceLbPolicyProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateServiceLbPolicyProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkCreateServiceBindingProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateServiceBindingProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateServiceLbPolicyProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateServiceLbPolicyProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteServiceLbPolicy', () => { + it('invokes deleteServiceLbPolicy without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteServiceLbPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteServiceLbPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteServiceLbPolicy = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteServiceLbPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteServiceLbPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServiceLbPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateServiceBindingProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateServiceBindingProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteServiceLbPolicy without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteServiceLbPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteServiceLbPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteServiceLbPolicy = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteServiceLbPolicy( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteServiceLbPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServiceLbPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateServiceBinding', () => { - it('invokes updateServiceBinding without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateServiceBindingRequest() - ); - request.serviceBinding ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateServiceBindingRequest', ['serviceBinding', 'name']); - request.serviceBinding.name = defaultValue1; - const expectedHeaderRequestParams = `service_binding.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateServiceBinding = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateServiceBinding(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateServiceBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServiceBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteServiceLbPolicy with call error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteServiceLbPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteServiceLbPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteServiceLbPolicy = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.deleteServiceLbPolicy(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteServiceLbPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServiceLbPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateServiceBinding without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateServiceBindingRequest() - ); - request.serviceBinding ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateServiceBindingRequest', ['serviceBinding', 'name']); - request.serviceBinding.name = defaultValue1; - const expectedHeaderRequestParams = `service_binding.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateServiceBinding = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateServiceBinding( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateServiceBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServiceBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteServiceLbPolicy with LRO error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.DeleteServiceLbPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.DeleteServiceLbPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteServiceLbPolicy = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteServiceLbPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteServiceLbPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServiceLbPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateServiceBinding with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateServiceBindingRequest() - ); - request.serviceBinding ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateServiceBindingRequest', ['serviceBinding', 'name']); - request.serviceBinding.name = defaultValue1; - const expectedHeaderRequestParams = `service_binding.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateServiceBinding = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateServiceBinding(request), expectedError); - const actualRequest = (client.innerApiCalls.updateServiceBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServiceBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteServiceLbPolicyProgress without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteServiceLbPolicyProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateServiceBinding with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateServiceBindingRequest() - ); - request.serviceBinding ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateServiceBindingRequest', ['serviceBinding', 'name']); - request.serviceBinding.name = defaultValue1; - const expectedHeaderRequestParams = `service_binding.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateServiceBinding = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateServiceBinding(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateServiceBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServiceBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteServiceLbPolicyProgress with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteServiceLbPolicyProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listEndpointPolicies', () => { + it('invokes listEndpointPolicies without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListEndpointPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListEndpointPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.EndpointPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.EndpointPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.EndpointPolicy(), + ), + ]; + client.innerApiCalls.listEndpointPolicies = + stubSimpleCall(expectedResponse); + const [response] = await client.listEndpointPolicies(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listEndpointPolicies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEndpointPolicies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateServiceBindingProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateServiceBindingProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes listEndpointPolicies without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListEndpointPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListEndpointPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.EndpointPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.EndpointPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.EndpointPolicy(), + ), + ]; + client.innerApiCalls.listEndpointPolicies = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listEndpointPolicies( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkservices.v1.IEndpointPolicy[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listEndpointPolicies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEndpointPolicies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateServiceBindingProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateServiceBindingProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes listEndpointPolicies with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListEndpointPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListEndpointPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listEndpointPolicies = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listEndpointPolicies(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listEndpointPolicies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEndpointPolicies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteServiceBinding', () => { - it('invokes deleteServiceBinding without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteServiceBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteServiceBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteServiceBinding = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteServiceBinding(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteServiceBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServiceBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listEndpointPoliciesStream without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListEndpointPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListEndpointPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.EndpointPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.EndpointPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.EndpointPolicy(), + ), + ]; + client.descriptors.page.listEndpointPolicies.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listEndpointPoliciesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.EndpointPolicy[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkservices.v1.EndpointPolicy) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listEndpointPolicies.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listEndpointPolicies, request), + ); + assert( + (client.descriptors.page.listEndpointPolicies.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes deleteServiceBinding without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteServiceBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteServiceBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteServiceBinding = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteServiceBinding( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteServiceBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServiceBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listEndpointPoliciesStream with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListEndpointPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListEndpointPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listEndpointPolicies.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listEndpointPoliciesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.EndpointPolicy[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkservices.v1.EndpointPolicy) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listEndpointPolicies.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listEndpointPolicies, request), + ); + assert( + (client.descriptors.page.listEndpointPolicies.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes deleteServiceBinding with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteServiceBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteServiceBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteServiceBinding = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteServiceBinding(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteServiceBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServiceBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('uses async iteration with listEndpointPolicies without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListEndpointPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListEndpointPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.EndpointPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.EndpointPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.EndpointPolicy(), + ), + ]; + client.descriptors.page.listEndpointPolicies.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkservices.v1.IEndpointPolicy[] = + []; + const iterable = client.listEndpointPoliciesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listEndpointPolicies.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listEndpointPolicies.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes deleteServiceBinding with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteServiceBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteServiceBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteServiceBinding = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteServiceBinding(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteServiceBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServiceBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('uses async iteration with listEndpointPolicies with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListEndpointPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListEndpointPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listEndpointPolicies.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listEndpointPoliciesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkservices.v1.IEndpointPolicy[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listEndpointPolicies.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listEndpointPolicies.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listWasmPluginVersions', () => { + it('invokes listWasmPluginVersions without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListWasmPluginVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListWasmPluginVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.WasmPluginVersion(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.WasmPluginVersion(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.WasmPluginVersion(), + ), + ]; + client.innerApiCalls.listWasmPluginVersions = + stubSimpleCall(expectedResponse); + const [response] = await client.listWasmPluginVersions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listWasmPluginVersions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listWasmPluginVersions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteServiceBindingProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteServiceBindingProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes listWasmPluginVersions without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListWasmPluginVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListWasmPluginVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.WasmPluginVersion(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.WasmPluginVersion(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.WasmPluginVersion(), + ), + ]; + client.innerApiCalls.listWasmPluginVersions = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listWasmPluginVersions( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkservices.v1.IWasmPluginVersion[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listWasmPluginVersions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listWasmPluginVersions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteServiceBindingProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteServiceBindingProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes listWasmPluginVersions with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListWasmPluginVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListWasmPluginVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listWasmPluginVersions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listWasmPluginVersions(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listWasmPluginVersions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listWasmPluginVersions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createMesh', () => { - it('invokes createMesh without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateMeshRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateMeshRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createMesh = stubLongRunningCall(expectedResponse); - const [operation] = await client.createMesh(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createMesh as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMesh as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listWasmPluginVersionsStream without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListWasmPluginVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListWasmPluginVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.WasmPluginVersion(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.WasmPluginVersion(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.WasmPluginVersion(), + ), + ]; + client.descriptors.page.listWasmPluginVersions.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listWasmPluginVersionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.WasmPluginVersion[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkservices.v1.WasmPluginVersion, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listWasmPluginVersions + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listWasmPluginVersions, request), + ); + assert( + ( + client.descriptors.page.listWasmPluginVersions + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes createMesh without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateMeshRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateMeshRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createMesh = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createMesh( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createMesh as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMesh as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listWasmPluginVersionsStream with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListWasmPluginVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListWasmPluginVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listWasmPluginVersions.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listWasmPluginVersionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.WasmPluginVersion[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkservices.v1.WasmPluginVersion, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listWasmPluginVersions + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listWasmPluginVersions, request), + ); + assert( + ( + client.descriptors.page.listWasmPluginVersions + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes createMesh with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateMeshRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateMeshRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createMesh = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createMesh(request), expectedError); - const actualRequest = (client.innerApiCalls.createMesh as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMesh as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('uses async iteration with listWasmPluginVersions without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListWasmPluginVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListWasmPluginVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.WasmPluginVersion(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.WasmPluginVersion(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.WasmPluginVersion(), + ), + ]; + client.descriptors.page.listWasmPluginVersions.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkservices.v1.IWasmPluginVersion[] = + []; + const iterable = client.listWasmPluginVersionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listWasmPluginVersions + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listWasmPluginVersions + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes createMesh with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateMeshRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateMeshRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createMesh = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createMesh(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createMesh as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMesh as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateMeshProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateMeshProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateMeshProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateMeshProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('uses async iteration with listWasmPluginVersions with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListWasmPluginVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListWasmPluginVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listWasmPluginVersions.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listWasmPluginVersionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkservices.v1.IWasmPluginVersion[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listWasmPluginVersions + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listWasmPluginVersions + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - - describe('updateMesh', () => { - it('invokes updateMesh without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateMeshRequest() - ); - request.mesh ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateMeshRequest', ['mesh', 'name']); - request.mesh.name = defaultValue1; - const expectedHeaderRequestParams = `mesh.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateMesh = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateMesh(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateMesh as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMesh as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateMesh without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateMeshRequest() - ); - request.mesh ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateMeshRequest', ['mesh', 'name']); - request.mesh.name = defaultValue1; - const expectedHeaderRequestParams = `mesh.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateMesh = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateMesh( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateMesh as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMesh as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateMesh with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateMeshRequest() - ); - request.mesh ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateMeshRequest', ['mesh', 'name']); - request.mesh.name = defaultValue1; - const expectedHeaderRequestParams = `mesh.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateMesh = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateMesh(request), expectedError); - const actualRequest = (client.innerApiCalls.updateMesh as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMesh as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateMesh with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateMeshRequest() - ); - request.mesh ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateMeshRequest', ['mesh', 'name']); - request.mesh.name = defaultValue1; - const expectedHeaderRequestParams = `mesh.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateMesh = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateMesh(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateMesh as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMesh as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateMeshProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateMeshProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateMeshProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateMeshProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + }); + + describe('listWasmPlugins', () => { + it('invokes listWasmPlugins without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListWasmPluginsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListWasmPluginsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.WasmPlugin(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.WasmPlugin(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.WasmPlugin(), + ), + ]; + client.innerApiCalls.listWasmPlugins = stubSimpleCall(expectedResponse); + const [response] = await client.listWasmPlugins(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listWasmPlugins as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listWasmPlugins as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteMesh', () => { - it('invokes deleteMesh without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteMeshRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteMeshRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteMesh = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteMesh(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteMesh as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMesh as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteMesh without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteMeshRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteMeshRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteMesh = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteMesh( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteMesh as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMesh as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteMesh with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteMeshRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteMeshRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteMesh = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteMesh(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteMesh as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMesh as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteMesh with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteMeshRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteMeshRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteMesh = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteMesh(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteMesh as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMesh as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteMeshProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteMeshProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteMeshProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteMeshProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes listWasmPlugins without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListWasmPluginsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListWasmPluginsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.WasmPlugin(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.WasmPlugin(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.WasmPlugin(), + ), + ]; + client.innerApiCalls.listWasmPlugins = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listWasmPlugins( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkservices.v1.IWasmPlugin[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listWasmPlugins as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listWasmPlugins as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createServiceLbPolicy', () => { - it('invokes createServiceLbPolicy without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateServiceLbPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateServiceLbPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createServiceLbPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.createServiceLbPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createServiceLbPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServiceLbPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createServiceLbPolicy without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateServiceLbPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateServiceLbPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createServiceLbPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createServiceLbPolicy( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createServiceLbPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServiceLbPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createServiceLbPolicy with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateServiceLbPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateServiceLbPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createServiceLbPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createServiceLbPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.createServiceLbPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServiceLbPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createServiceLbPolicy with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.CreateServiceLbPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.CreateServiceLbPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createServiceLbPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createServiceLbPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createServiceLbPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServiceLbPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateServiceLbPolicyProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateServiceLbPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateServiceLbPolicyProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateServiceLbPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes listWasmPlugins with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListWasmPluginsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListWasmPluginsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listWasmPlugins = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listWasmPlugins(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listWasmPlugins as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listWasmPlugins as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateServiceLbPolicy', () => { - it('invokes updateServiceLbPolicy without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateServiceLbPolicyRequest() - ); - request.serviceLbPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateServiceLbPolicyRequest', ['serviceLbPolicy', 'name']); - request.serviceLbPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `service_lb_policy.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateServiceLbPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateServiceLbPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateServiceLbPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServiceLbPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateServiceLbPolicy without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateServiceLbPolicyRequest() - ); - request.serviceLbPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateServiceLbPolicyRequest', ['serviceLbPolicy', 'name']); - request.serviceLbPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `service_lb_policy.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateServiceLbPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateServiceLbPolicy( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateServiceLbPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServiceLbPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateServiceLbPolicy with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateServiceLbPolicyRequest() - ); - request.serviceLbPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateServiceLbPolicyRequest', ['serviceLbPolicy', 'name']); - request.serviceLbPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `service_lb_policy.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateServiceLbPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateServiceLbPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.updateServiceLbPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServiceLbPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateServiceLbPolicy with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.UpdateServiceLbPolicyRequest() - ); - request.serviceLbPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.UpdateServiceLbPolicyRequest', ['serviceLbPolicy', 'name']); - request.serviceLbPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `service_lb_policy.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateServiceLbPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateServiceLbPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateServiceLbPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServiceLbPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateServiceLbPolicyProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateServiceLbPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateServiceLbPolicyProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateServiceLbPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes listWasmPluginsStream without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListWasmPluginsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListWasmPluginsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.WasmPlugin(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.WasmPlugin(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.WasmPlugin(), + ), + ]; + client.descriptors.page.listWasmPlugins.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listWasmPluginsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.WasmPlugin[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkservices.v1.WasmPlugin) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listWasmPlugins.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listWasmPlugins, request), + ); + assert( + (client.descriptors.page.listWasmPlugins.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('deleteServiceLbPolicy', () => { - it('invokes deleteServiceLbPolicy without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteServiceLbPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteServiceLbPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteServiceLbPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteServiceLbPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteServiceLbPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServiceLbPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteServiceLbPolicy without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteServiceLbPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteServiceLbPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteServiceLbPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteServiceLbPolicy( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteServiceLbPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServiceLbPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteServiceLbPolicy with call error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteServiceLbPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteServiceLbPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteServiceLbPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteServiceLbPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteServiceLbPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServiceLbPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteServiceLbPolicy with LRO error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.DeleteServiceLbPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.DeleteServiceLbPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteServiceLbPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteServiceLbPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteServiceLbPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServiceLbPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteServiceLbPolicyProgress without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteServiceLbPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteServiceLbPolicyProgress with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteServiceLbPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes listWasmPluginsStream with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListWasmPluginsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListWasmPluginsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listWasmPlugins.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listWasmPluginsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.WasmPlugin[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkservices.v1.WasmPlugin) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listWasmPlugins.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listWasmPlugins, request), + ); + assert( + (client.descriptors.page.listWasmPlugins.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('listEndpointPolicies', () => { - it('invokes listEndpointPolicies without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListEndpointPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListEndpointPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.EndpointPolicy()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.EndpointPolicy()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.EndpointPolicy()), - ]; - client.innerApiCalls.listEndpointPolicies = stubSimpleCall(expectedResponse); - const [response] = await client.listEndpointPolicies(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEndpointPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEndpointPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEndpointPolicies without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListEndpointPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListEndpointPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.EndpointPolicy()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.EndpointPolicy()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.EndpointPolicy()), - ]; - client.innerApiCalls.listEndpointPolicies = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listEndpointPolicies( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.IEndpointPolicy[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEndpointPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEndpointPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEndpointPolicies with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListEndpointPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListEndpointPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listEndpointPolicies = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listEndpointPolicies(request), expectedError); - const actualRequest = (client.innerApiCalls.listEndpointPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEndpointPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEndpointPoliciesStream without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListEndpointPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListEndpointPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.EndpointPolicy()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.EndpointPolicy()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.EndpointPolicy()), - ]; - client.descriptors.page.listEndpointPolicies.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listEndpointPoliciesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.EndpointPolicy[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.EndpointPolicy) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listEndpointPolicies.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listEndpointPolicies, request)); - assert( - (client.descriptors.page.listEndpointPolicies.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listEndpointPoliciesStream with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListEndpointPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListEndpointPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listEndpointPolicies.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listEndpointPoliciesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.EndpointPolicy[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.EndpointPolicy) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listEndpointPolicies.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listEndpointPolicies, request)); - assert( - (client.descriptors.page.listEndpointPolicies.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listEndpointPolicies without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListEndpointPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListEndpointPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.EndpointPolicy()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.EndpointPolicy()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.EndpointPolicy()), - ]; - client.descriptors.page.listEndpointPolicies.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkservices.v1.IEndpointPolicy[] = []; - const iterable = client.listEndpointPoliciesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listEndpointPolicies.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listEndpointPolicies.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listEndpointPolicies with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListEndpointPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListEndpointPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listEndpointPolicies.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listEndpointPoliciesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkservices.v1.IEndpointPolicy[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listEndpointPolicies.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listEndpointPolicies.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listWasmPlugins without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListWasmPluginsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListWasmPluginsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.WasmPlugin(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.WasmPlugin(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.WasmPlugin(), + ), + ]; + client.descriptors.page.listWasmPlugins.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkservices.v1.IWasmPlugin[] = + []; + const iterable = client.listWasmPluginsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listWasmPlugins.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listWasmPlugins.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('listWasmPluginVersions', () => { - it('invokes listWasmPluginVersions without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListWasmPluginVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListWasmPluginVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.WasmPluginVersion()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.WasmPluginVersion()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.WasmPluginVersion()), - ]; - client.innerApiCalls.listWasmPluginVersions = stubSimpleCall(expectedResponse); - const [response] = await client.listWasmPluginVersions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listWasmPluginVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listWasmPluginVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listWasmPluginVersions without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListWasmPluginVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListWasmPluginVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.WasmPluginVersion()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.WasmPluginVersion()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.WasmPluginVersion()), - ]; - client.innerApiCalls.listWasmPluginVersions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listWasmPluginVersions( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.IWasmPluginVersion[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listWasmPluginVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listWasmPluginVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listWasmPluginVersions with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListWasmPluginVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListWasmPluginVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listWasmPluginVersions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listWasmPluginVersions(request), expectedError); - const actualRequest = (client.innerApiCalls.listWasmPluginVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listWasmPluginVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listWasmPluginVersionsStream without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListWasmPluginVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListWasmPluginVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.WasmPluginVersion()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.WasmPluginVersion()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.WasmPluginVersion()), - ]; - client.descriptors.page.listWasmPluginVersions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listWasmPluginVersionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.WasmPluginVersion[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.WasmPluginVersion) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listWasmPluginVersions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listWasmPluginVersions, request)); - assert( - (client.descriptors.page.listWasmPluginVersions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listWasmPluginVersionsStream with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListWasmPluginVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListWasmPluginVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listWasmPluginVersions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listWasmPluginVersionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.WasmPluginVersion[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.WasmPluginVersion) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listWasmPluginVersions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listWasmPluginVersions, request)); - assert( - (client.descriptors.page.listWasmPluginVersions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listWasmPluginVersions without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListWasmPluginVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListWasmPluginVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.WasmPluginVersion()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.WasmPluginVersion()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.WasmPluginVersion()), - ]; - client.descriptors.page.listWasmPluginVersions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkservices.v1.IWasmPluginVersion[] = []; - const iterable = client.listWasmPluginVersionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listWasmPluginVersions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listWasmPluginVersions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listWasmPluginVersions with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListWasmPluginVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListWasmPluginVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listWasmPluginVersions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listWasmPluginVersionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkservices.v1.IWasmPluginVersion[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listWasmPluginVersions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listWasmPluginVersions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listWasmPlugins with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListWasmPluginsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListWasmPluginsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listWasmPlugins.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listWasmPluginsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkservices.v1.IWasmPlugin[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listWasmPlugins.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listWasmPlugins.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listGateways', () => { + it('invokes listGateways without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListGatewaysRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListGatewaysRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.Gateway(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.Gateway(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.Gateway(), + ), + ]; + client.innerApiCalls.listGateways = stubSimpleCall(expectedResponse); + const [response] = await client.listGateways(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listGateways as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listGateways as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listWasmPlugins', () => { - it('invokes listWasmPlugins without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListWasmPluginsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListWasmPluginsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.WasmPlugin()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.WasmPlugin()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.WasmPlugin()), - ]; - client.innerApiCalls.listWasmPlugins = stubSimpleCall(expectedResponse); - const [response] = await client.listWasmPlugins(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listWasmPlugins as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listWasmPlugins as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listWasmPlugins without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListWasmPluginsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListWasmPluginsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.WasmPlugin()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.WasmPlugin()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.WasmPlugin()), - ]; - client.innerApiCalls.listWasmPlugins = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listWasmPlugins( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.IWasmPlugin[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listWasmPlugins as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listWasmPlugins as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listWasmPlugins with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListWasmPluginsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListWasmPluginsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listWasmPlugins = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listWasmPlugins(request), expectedError); - const actualRequest = (client.innerApiCalls.listWasmPlugins as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listWasmPlugins as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listWasmPluginsStream without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListWasmPluginsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListWasmPluginsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.WasmPlugin()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.WasmPlugin()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.WasmPlugin()), - ]; - client.descriptors.page.listWasmPlugins.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listWasmPluginsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.WasmPlugin[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.WasmPlugin) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listWasmPlugins.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listWasmPlugins, request)); - assert( - (client.descriptors.page.listWasmPlugins.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listWasmPluginsStream with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListWasmPluginsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListWasmPluginsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listWasmPlugins.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listWasmPluginsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.WasmPlugin[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.WasmPlugin) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listWasmPlugins.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listWasmPlugins, request)); - assert( - (client.descriptors.page.listWasmPlugins.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listWasmPlugins without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListWasmPluginsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListWasmPluginsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.WasmPlugin()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.WasmPlugin()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.WasmPlugin()), - ]; - client.descriptors.page.listWasmPlugins.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkservices.v1.IWasmPlugin[] = []; - const iterable = client.listWasmPluginsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listGateways without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListGatewaysRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListGatewaysRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.Gateway(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.Gateway(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.Gateway(), + ), + ]; + client.innerApiCalls.listGateways = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listGateways( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkservices.v1.IGateway[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listWasmPlugins.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listWasmPlugins.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listWasmPlugins with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListWasmPluginsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListWasmPluginsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listWasmPlugins.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listWasmPluginsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkservices.v1.IWasmPlugin[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listWasmPlugins.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listWasmPlugins.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listGateways as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listGateways as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listGateways', () => { - it('invokes listGateways without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListGatewaysRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListGatewaysRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.Gateway()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.Gateway()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.Gateway()), - ]; - client.innerApiCalls.listGateways = stubSimpleCall(expectedResponse); - const [response] = await client.listGateways(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listGateways as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listGateways as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listGateways with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListGatewaysRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListGatewaysRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listGateways = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listGateways(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listGateways as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listGateways as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listGateways without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListGatewaysRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListGatewaysRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.Gateway()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.Gateway()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.Gateway()), - ]; - client.innerApiCalls.listGateways = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listGateways( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.IGateway[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listGateways as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listGateways as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listGatewaysStream without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListGatewaysRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListGatewaysRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.Gateway(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.Gateway(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.Gateway(), + ), + ]; + client.descriptors.page.listGateways.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listGatewaysStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.Gateway[] = []; + stream.on( + 'data', + (response: protos.google.cloud.networkservices.v1.Gateway) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listGateways.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listGateways, request), + ); + assert( + (client.descriptors.page.listGateways.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listGateways with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListGatewaysRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListGatewaysRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listGateways = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listGateways(request), expectedError); - const actualRequest = (client.innerApiCalls.listGateways as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listGateways as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listGatewaysStream with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListGatewaysRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListGatewaysRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listGateways.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listGatewaysStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.Gateway[] = []; + stream.on( + 'data', + (response: protos.google.cloud.networkservices.v1.Gateway) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listGateways.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listGateways, request), + ); + assert( + (client.descriptors.page.listGateways.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listGatewaysStream without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListGatewaysRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListGatewaysRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.Gateway()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.Gateway()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.Gateway()), - ]; - client.descriptors.page.listGateways.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listGatewaysStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.Gateway[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.Gateway) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listGateways.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listGateways, request)); - assert( - (client.descriptors.page.listGateways.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listGateways without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListGatewaysRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListGatewaysRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.Gateway(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.Gateway(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.Gateway(), + ), + ]; + client.descriptors.page.listGateways.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkservices.v1.IGateway[] = []; + const iterable = client.listGatewaysAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listGateways.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listGateways.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listGatewaysStream with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListGatewaysRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListGatewaysRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listGateways.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listGatewaysStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.Gateway[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.Gateway) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listGateways.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listGateways, request)); - assert( - (client.descriptors.page.listGateways.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listGateways with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListGatewaysRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListGatewaysRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listGateways.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listGatewaysAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkservices.v1.IGateway[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listGateways.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listGateways.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listGrpcRoutes', () => { + it('invokes listGrpcRoutes without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListGrpcRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListGrpcRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.GrpcRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.GrpcRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.GrpcRoute(), + ), + ]; + client.innerApiCalls.listGrpcRoutes = stubSimpleCall(expectedResponse); + const [response] = await client.listGrpcRoutes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listGrpcRoutes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listGrpcRoutes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listGateways without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListGatewaysRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListGatewaysRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.Gateway()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.Gateway()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.Gateway()), - ]; - client.descriptors.page.listGateways.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkservices.v1.IGateway[] = []; - const iterable = client.listGatewaysAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listGrpcRoutes without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListGrpcRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListGrpcRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.GrpcRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.GrpcRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.GrpcRoute(), + ), + ]; + client.innerApiCalls.listGrpcRoutes = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listGrpcRoutes( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkservices.v1.IGrpcRoute[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listGateways.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listGateways.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listGateways with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListGatewaysRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListGatewaysRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listGateways.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listGatewaysAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkservices.v1.IGateway[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listGateways.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listGateways.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listGrpcRoutes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listGrpcRoutes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listGrpcRoutes', () => { - it('invokes listGrpcRoutes without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListGrpcRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListGrpcRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.GrpcRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.GrpcRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.GrpcRoute()), - ]; - client.innerApiCalls.listGrpcRoutes = stubSimpleCall(expectedResponse); - const [response] = await client.listGrpcRoutes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listGrpcRoutes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listGrpcRoutes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listGrpcRoutes with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListGrpcRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListGrpcRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listGrpcRoutes = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listGrpcRoutes(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listGrpcRoutes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listGrpcRoutes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listGrpcRoutes without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListGrpcRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListGrpcRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.GrpcRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.GrpcRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.GrpcRoute()), - ]; - client.innerApiCalls.listGrpcRoutes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listGrpcRoutes( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.IGrpcRoute[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listGrpcRoutes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listGrpcRoutes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listGrpcRoutesStream without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListGrpcRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListGrpcRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.GrpcRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.GrpcRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.GrpcRoute(), + ), + ]; + client.descriptors.page.listGrpcRoutes.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listGrpcRoutesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.GrpcRoute[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkservices.v1.GrpcRoute) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listGrpcRoutes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listGrpcRoutes, request), + ); + assert( + (client.descriptors.page.listGrpcRoutes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listGrpcRoutes with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListGrpcRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListGrpcRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listGrpcRoutes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listGrpcRoutes(request), expectedError); - const actualRequest = (client.innerApiCalls.listGrpcRoutes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listGrpcRoutes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listGrpcRoutesStream with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListGrpcRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListGrpcRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listGrpcRoutes.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listGrpcRoutesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.GrpcRoute[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkservices.v1.GrpcRoute) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listGrpcRoutes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listGrpcRoutes, request), + ); + assert( + (client.descriptors.page.listGrpcRoutes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listGrpcRoutesStream without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListGrpcRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListGrpcRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.GrpcRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.GrpcRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.GrpcRoute()), - ]; - client.descriptors.page.listGrpcRoutes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listGrpcRoutesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.GrpcRoute[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.GrpcRoute) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listGrpcRoutes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listGrpcRoutes, request)); - assert( - (client.descriptors.page.listGrpcRoutes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listGrpcRoutes without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListGrpcRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListGrpcRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.GrpcRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.GrpcRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.GrpcRoute(), + ), + ]; + client.descriptors.page.listGrpcRoutes.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkservices.v1.IGrpcRoute[] = []; + const iterable = client.listGrpcRoutesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listGrpcRoutes.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listGrpcRoutes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listGrpcRoutesStream with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListGrpcRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListGrpcRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listGrpcRoutes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listGrpcRoutesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.GrpcRoute[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.GrpcRoute) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listGrpcRoutes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listGrpcRoutes, request)); - assert( - (client.descriptors.page.listGrpcRoutes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listGrpcRoutes with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListGrpcRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListGrpcRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listGrpcRoutes.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listGrpcRoutesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkservices.v1.IGrpcRoute[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listGrpcRoutes.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listGrpcRoutes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listHttpRoutes', () => { + it('invokes listHttpRoutes without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListHttpRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListHttpRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.HttpRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.HttpRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.HttpRoute(), + ), + ]; + client.innerApiCalls.listHttpRoutes = stubSimpleCall(expectedResponse); + const [response] = await client.listHttpRoutes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listHttpRoutes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listHttpRoutes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listGrpcRoutes without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListGrpcRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListGrpcRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.GrpcRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.GrpcRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.GrpcRoute()), - ]; - client.descriptors.page.listGrpcRoutes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkservices.v1.IGrpcRoute[] = []; - const iterable = client.listGrpcRoutesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listHttpRoutes without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListHttpRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListHttpRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.HttpRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.HttpRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.HttpRoute(), + ), + ]; + client.innerApiCalls.listHttpRoutes = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listHttpRoutes( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkservices.v1.IHttpRoute[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listGrpcRoutes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listGrpcRoutes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listGrpcRoutes with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListGrpcRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListGrpcRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listGrpcRoutes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listGrpcRoutesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkservices.v1.IGrpcRoute[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listGrpcRoutes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listGrpcRoutes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listHttpRoutes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listHttpRoutes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listHttpRoutes', () => { - it('invokes listHttpRoutes without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListHttpRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListHttpRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.HttpRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.HttpRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.HttpRoute()), - ]; - client.innerApiCalls.listHttpRoutes = stubSimpleCall(expectedResponse); - const [response] = await client.listHttpRoutes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listHttpRoutes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listHttpRoutes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listHttpRoutes with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListHttpRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListHttpRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listHttpRoutes = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listHttpRoutes(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listHttpRoutes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listHttpRoutes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listHttpRoutes without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListHttpRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListHttpRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.HttpRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.HttpRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.HttpRoute()), - ]; - client.innerApiCalls.listHttpRoutes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listHttpRoutes( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.IHttpRoute[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listHttpRoutes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listHttpRoutes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listHttpRoutesStream without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListHttpRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListHttpRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.HttpRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.HttpRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.HttpRoute(), + ), + ]; + client.descriptors.page.listHttpRoutes.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listHttpRoutesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.HttpRoute[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkservices.v1.HttpRoute) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listHttpRoutes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listHttpRoutes, request), + ); + assert( + (client.descriptors.page.listHttpRoutes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listHttpRoutes with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListHttpRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListHttpRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listHttpRoutes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listHttpRoutes(request), expectedError); - const actualRequest = (client.innerApiCalls.listHttpRoutes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listHttpRoutes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listHttpRoutesStream with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListHttpRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListHttpRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listHttpRoutes.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listHttpRoutesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.HttpRoute[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkservices.v1.HttpRoute) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listHttpRoutes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listHttpRoutes, request), + ); + assert( + (client.descriptors.page.listHttpRoutes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listHttpRoutesStream without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListHttpRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListHttpRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.HttpRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.HttpRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.HttpRoute()), - ]; - client.descriptors.page.listHttpRoutes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listHttpRoutesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.HttpRoute[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.HttpRoute) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listHttpRoutes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listHttpRoutes, request)); - assert( - (client.descriptors.page.listHttpRoutes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listHttpRoutes without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListHttpRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListHttpRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.HttpRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.HttpRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.HttpRoute(), + ), + ]; + client.descriptors.page.listHttpRoutes.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkservices.v1.IHttpRoute[] = []; + const iterable = client.listHttpRoutesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listHttpRoutes.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listHttpRoutes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listHttpRoutesStream with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListHttpRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListHttpRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listHttpRoutes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listHttpRoutesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.HttpRoute[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.HttpRoute) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listHttpRoutes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listHttpRoutes, request)); - assert( - (client.descriptors.page.listHttpRoutes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listHttpRoutes with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListHttpRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListHttpRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listHttpRoutes.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listHttpRoutesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkservices.v1.IHttpRoute[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listHttpRoutes.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listHttpRoutes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listTcpRoutes', () => { + it('invokes listTcpRoutes without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListTcpRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListTcpRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.TcpRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.TcpRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.TcpRoute(), + ), + ]; + client.innerApiCalls.listTcpRoutes = stubSimpleCall(expectedResponse); + const [response] = await client.listTcpRoutes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listTcpRoutes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTcpRoutes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listHttpRoutes without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListHttpRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListHttpRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.HttpRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.HttpRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.HttpRoute()), - ]; - client.descriptors.page.listHttpRoutes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkservices.v1.IHttpRoute[] = []; - const iterable = client.listHttpRoutesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listTcpRoutes without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListTcpRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListTcpRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.TcpRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.TcpRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.TcpRoute(), + ), + ]; + client.innerApiCalls.listTcpRoutes = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listTcpRoutes( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkservices.v1.ITcpRoute[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listHttpRoutes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listHttpRoutes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listHttpRoutes with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListHttpRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListHttpRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listHttpRoutes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listHttpRoutesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkservices.v1.IHttpRoute[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listHttpRoutes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listHttpRoutes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listTcpRoutes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTcpRoutes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listTcpRoutes', () => { - it('invokes listTcpRoutes without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListTcpRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListTcpRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.TcpRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.TcpRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.TcpRoute()), - ]; - client.innerApiCalls.listTcpRoutes = stubSimpleCall(expectedResponse); - const [response] = await client.listTcpRoutes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTcpRoutes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTcpRoutes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listTcpRoutes with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListTcpRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListTcpRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listTcpRoutes = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listTcpRoutes(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listTcpRoutes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTcpRoutes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listTcpRoutes without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListTcpRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListTcpRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.TcpRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.TcpRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.TcpRoute()), - ]; - client.innerApiCalls.listTcpRoutes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listTcpRoutes( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.ITcpRoute[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTcpRoutes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTcpRoutes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listTcpRoutesStream without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListTcpRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListTcpRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.TcpRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.TcpRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.TcpRoute(), + ), + ]; + client.descriptors.page.listTcpRoutes.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listTcpRoutesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.TcpRoute[] = []; + stream.on( + 'data', + (response: protos.google.cloud.networkservices.v1.TcpRoute) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listTcpRoutes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listTcpRoutes, request), + ); + assert( + (client.descriptors.page.listTcpRoutes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listTcpRoutes with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListTcpRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListTcpRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listTcpRoutes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listTcpRoutes(request), expectedError); - const actualRequest = (client.innerApiCalls.listTcpRoutes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTcpRoutes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listTcpRoutesStream with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListTcpRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListTcpRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTcpRoutes.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listTcpRoutesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.TcpRoute[] = []; + stream.on( + 'data', + (response: protos.google.cloud.networkservices.v1.TcpRoute) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listTcpRoutes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listTcpRoutes, request), + ); + assert( + (client.descriptors.page.listTcpRoutes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listTcpRoutesStream without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListTcpRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListTcpRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.TcpRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.TcpRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.TcpRoute()), - ]; - client.descriptors.page.listTcpRoutes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listTcpRoutesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.TcpRoute[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.TcpRoute) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listTcpRoutes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTcpRoutes, request)); - assert( - (client.descriptors.page.listTcpRoutes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listTcpRoutes without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListTcpRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListTcpRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.TcpRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.TcpRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.TcpRoute(), + ), + ]; + client.descriptors.page.listTcpRoutes.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkservices.v1.ITcpRoute[] = []; + const iterable = client.listTcpRoutesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listTcpRoutes.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listTcpRoutes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listTcpRoutesStream with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListTcpRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListTcpRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listTcpRoutes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listTcpRoutesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.TcpRoute[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.TcpRoute) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listTcpRoutes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTcpRoutes, request)); - assert( - (client.descriptors.page.listTcpRoutes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listTcpRoutes with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListTcpRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListTcpRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTcpRoutes.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listTcpRoutesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkservices.v1.ITcpRoute[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listTcpRoutes.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listTcpRoutes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listTlsRoutes', () => { + it('invokes listTlsRoutes without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListTlsRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListTlsRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.TlsRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.TlsRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.TlsRoute(), + ), + ]; + client.innerApiCalls.listTlsRoutes = stubSimpleCall(expectedResponse); + const [response] = await client.listTlsRoutes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listTlsRoutes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTlsRoutes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listTcpRoutes without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListTcpRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListTcpRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.TcpRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.TcpRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.TcpRoute()), - ]; - client.descriptors.page.listTcpRoutes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkservices.v1.ITcpRoute[] = []; - const iterable = client.listTcpRoutesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listTlsRoutes without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListTlsRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListTlsRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.TlsRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.TlsRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.TlsRoute(), + ), + ]; + client.innerApiCalls.listTlsRoutes = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listTlsRoutes( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkservices.v1.ITlsRoute[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listTcpRoutes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTcpRoutes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listTcpRoutes with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListTcpRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListTcpRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listTcpRoutes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listTcpRoutesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkservices.v1.ITcpRoute[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listTcpRoutes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTcpRoutes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listTlsRoutes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTlsRoutes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listTlsRoutes', () => { - it('invokes listTlsRoutes without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListTlsRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListTlsRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.TlsRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.TlsRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.TlsRoute()), - ]; - client.innerApiCalls.listTlsRoutes = stubSimpleCall(expectedResponse); - const [response] = await client.listTlsRoutes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTlsRoutes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTlsRoutes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listTlsRoutes with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListTlsRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListTlsRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listTlsRoutes = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listTlsRoutes(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listTlsRoutes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTlsRoutes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listTlsRoutes without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListTlsRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListTlsRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.TlsRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.TlsRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.TlsRoute()), - ]; - client.innerApiCalls.listTlsRoutes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listTlsRoutes( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.ITlsRoute[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTlsRoutes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTlsRoutes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listTlsRoutesStream without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListTlsRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListTlsRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.TlsRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.TlsRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.TlsRoute(), + ), + ]; + client.descriptors.page.listTlsRoutes.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listTlsRoutesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.TlsRoute[] = []; + stream.on( + 'data', + (response: protos.google.cloud.networkservices.v1.TlsRoute) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listTlsRoutes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listTlsRoutes, request), + ); + assert( + (client.descriptors.page.listTlsRoutes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listTlsRoutes with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListTlsRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListTlsRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listTlsRoutes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listTlsRoutes(request), expectedError); - const actualRequest = (client.innerApiCalls.listTlsRoutes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTlsRoutes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listTlsRoutesStream with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListTlsRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListTlsRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTlsRoutes.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listTlsRoutesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.TlsRoute[] = []; + stream.on( + 'data', + (response: protos.google.cloud.networkservices.v1.TlsRoute) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listTlsRoutes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listTlsRoutes, request), + ); + assert( + (client.descriptors.page.listTlsRoutes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listTlsRoutesStream without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListTlsRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListTlsRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.TlsRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.TlsRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.TlsRoute()), - ]; - client.descriptors.page.listTlsRoutes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listTlsRoutesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.TlsRoute[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.TlsRoute) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listTlsRoutes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTlsRoutes, request)); - assert( - (client.descriptors.page.listTlsRoutes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listTlsRoutes without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListTlsRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListTlsRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.TlsRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.TlsRoute(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.TlsRoute(), + ), + ]; + client.descriptors.page.listTlsRoutes.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkservices.v1.ITlsRoute[] = []; + const iterable = client.listTlsRoutesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listTlsRoutes.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listTlsRoutes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listTlsRoutesStream with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListTlsRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListTlsRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listTlsRoutes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listTlsRoutesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.TlsRoute[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.TlsRoute) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listTlsRoutes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTlsRoutes, request)); - assert( - (client.descriptors.page.listTlsRoutes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listTlsRoutes with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListTlsRoutesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListTlsRoutesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTlsRoutes.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listTlsRoutesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkservices.v1.ITlsRoute[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listTlsRoutes.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listTlsRoutes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listServiceBindings', () => { + it('invokes listServiceBindings without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListServiceBindingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListServiceBindingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.ServiceBinding(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.ServiceBinding(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.ServiceBinding(), + ), + ]; + client.innerApiCalls.listServiceBindings = + stubSimpleCall(expectedResponse); + const [response] = await client.listServiceBindings(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServiceBindings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServiceBindings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listTlsRoutes without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListTlsRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListTlsRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.TlsRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.TlsRoute()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.TlsRoute()), - ]; - client.descriptors.page.listTlsRoutes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkservices.v1.ITlsRoute[] = []; - const iterable = client.listTlsRoutesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listServiceBindings without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListServiceBindingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListServiceBindingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.ServiceBinding(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.ServiceBinding(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.ServiceBinding(), + ), + ]; + client.innerApiCalls.listServiceBindings = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listServiceBindings( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkservices.v1.IServiceBinding[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listTlsRoutes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTlsRoutes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listTlsRoutes with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListTlsRoutesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListTlsRoutesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listTlsRoutes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listTlsRoutesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkservices.v1.ITlsRoute[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listTlsRoutes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTlsRoutes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServiceBindings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServiceBindings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listServiceBindings', () => { - it('invokes listServiceBindings without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListServiceBindingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListServiceBindingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.ServiceBinding()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.ServiceBinding()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.ServiceBinding()), - ]; - client.innerApiCalls.listServiceBindings = stubSimpleCall(expectedResponse); - const [response] = await client.listServiceBindings(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServiceBindings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServiceBindings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listServiceBindings with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListServiceBindingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListServiceBindingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listServiceBindings = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listServiceBindings(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listServiceBindings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServiceBindings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listServiceBindings without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListServiceBindingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListServiceBindingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.ServiceBinding()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.ServiceBinding()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.ServiceBinding()), - ]; - client.innerApiCalls.listServiceBindings = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listServiceBindings( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.IServiceBinding[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServiceBindings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServiceBindings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listServiceBindingsStream without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListServiceBindingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListServiceBindingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.ServiceBinding(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.ServiceBinding(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.ServiceBinding(), + ), + ]; + client.descriptors.page.listServiceBindings.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listServiceBindingsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.ServiceBinding[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkservices.v1.ServiceBinding) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listServiceBindings.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listServiceBindings, request), + ); + assert( + (client.descriptors.page.listServiceBindings.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listServiceBindings with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListServiceBindingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListServiceBindingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listServiceBindings = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listServiceBindings(request), expectedError); - const actualRequest = (client.innerApiCalls.listServiceBindings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServiceBindings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listServiceBindingsStream with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListServiceBindingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListServiceBindingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listServiceBindings.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listServiceBindingsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.ServiceBinding[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkservices.v1.ServiceBinding) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listServiceBindings.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listServiceBindings, request), + ); + assert( + (client.descriptors.page.listServiceBindings.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listServiceBindingsStream without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListServiceBindingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListServiceBindingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.ServiceBinding()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.ServiceBinding()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.ServiceBinding()), - ]; - client.descriptors.page.listServiceBindings.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listServiceBindingsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.ServiceBinding[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.ServiceBinding) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listServiceBindings.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServiceBindings, request)); - assert( - (client.descriptors.page.listServiceBindings.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listServiceBindings without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListServiceBindingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListServiceBindingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.ServiceBinding(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.ServiceBinding(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.ServiceBinding(), + ), + ]; + client.descriptors.page.listServiceBindings.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkservices.v1.IServiceBinding[] = + []; + const iterable = client.listServiceBindingsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listServiceBindings.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listServiceBindings.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listServiceBindingsStream with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListServiceBindingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListServiceBindingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listServiceBindings.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listServiceBindingsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.ServiceBinding[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.ServiceBinding) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listServiceBindings.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServiceBindings, request)); - assert( - (client.descriptors.page.listServiceBindings.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listServiceBindings with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListServiceBindingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListServiceBindingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listServiceBindings.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listServiceBindingsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkservices.v1.IServiceBinding[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listServiceBindings.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listServiceBindings.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listMeshes', () => { + it('invokes listMeshes without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListMeshesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListMeshesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.Mesh(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.Mesh(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.Mesh(), + ), + ]; + client.innerApiCalls.listMeshes = stubSimpleCall(expectedResponse); + const [response] = await client.listMeshes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listMeshes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMeshes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listServiceBindings without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListServiceBindingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListServiceBindingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.ServiceBinding()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.ServiceBinding()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.ServiceBinding()), - ]; - client.descriptors.page.listServiceBindings.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkservices.v1.IServiceBinding[] = []; - const iterable = client.listServiceBindingsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listMeshes without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListMeshesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListMeshesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.Mesh(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.Mesh(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.Mesh(), + ), + ]; + client.innerApiCalls.listMeshes = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listMeshes( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkservices.v1.IMesh[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listServiceBindings.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listServiceBindings.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listServiceBindings with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListServiceBindingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListServiceBindingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listServiceBindings.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listServiceBindingsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkservices.v1.IServiceBinding[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listServiceBindings.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listServiceBindings.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listMeshes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMeshes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listMeshes', () => { - it('invokes listMeshes without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListMeshesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListMeshesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.Mesh()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.Mesh()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.Mesh()), - ]; - client.innerApiCalls.listMeshes = stubSimpleCall(expectedResponse); - const [response] = await client.listMeshes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMeshes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMeshes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listMeshes with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListMeshesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListMeshesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listMeshes = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listMeshes(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listMeshes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMeshes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listMeshes without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListMeshesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListMeshesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.Mesh()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.Mesh()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.Mesh()), - ]; - client.innerApiCalls.listMeshes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listMeshes( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.IMesh[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMeshes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMeshes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listMeshesStream without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListMeshesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListMeshesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.Mesh(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.Mesh(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.Mesh(), + ), + ]; + client.descriptors.page.listMeshes.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listMeshesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.Mesh[] = []; + stream.on( + 'data', + (response: protos.google.cloud.networkservices.v1.Mesh) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listMeshes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listMeshes, request), + ); + assert( + (client.descriptors.page.listMeshes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listMeshes with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListMeshesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListMeshesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listMeshes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listMeshes(request), expectedError); - const actualRequest = (client.innerApiCalls.listMeshes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMeshes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listMeshesStream with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListMeshesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListMeshesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMeshes.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listMeshesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.Mesh[] = []; + stream.on( + 'data', + (response: protos.google.cloud.networkservices.v1.Mesh) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listMeshes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listMeshes, request), + ); + assert( + (client.descriptors.page.listMeshes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listMeshesStream without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListMeshesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListMeshesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.Mesh()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.Mesh()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.Mesh()), - ]; - client.descriptors.page.listMeshes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listMeshesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.Mesh[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.Mesh) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listMeshes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMeshes, request)); - assert( - (client.descriptors.page.listMeshes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listMeshes without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListMeshesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListMeshesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.Mesh(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.Mesh(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.Mesh(), + ), + ]; + client.descriptors.page.listMeshes.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkservices.v1.IMesh[] = []; + const iterable = client.listMeshesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listMeshes.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listMeshes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listMeshesStream with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListMeshesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListMeshesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMeshes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listMeshesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.Mesh[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.Mesh) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listMeshes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMeshes, request)); - assert( - (client.descriptors.page.listMeshes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listMeshes with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListMeshesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListMeshesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMeshes.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listMeshesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkservices.v1.IMesh[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listMeshes.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listMeshes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listServiceLbPolicies', () => { + it('invokes listServiceLbPolicies without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListServiceLbPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListServiceLbPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.ServiceLbPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.ServiceLbPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.ServiceLbPolicy(), + ), + ]; + client.innerApiCalls.listServiceLbPolicies = + stubSimpleCall(expectedResponse); + const [response] = await client.listServiceLbPolicies(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServiceLbPolicies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServiceLbPolicies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listMeshes without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListMeshesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListMeshesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.Mesh()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.Mesh()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.Mesh()), - ]; - client.descriptors.page.listMeshes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkservices.v1.IMesh[] = []; - const iterable = client.listMeshesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listServiceLbPolicies without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListServiceLbPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListServiceLbPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.ServiceLbPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.ServiceLbPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.ServiceLbPolicy(), + ), + ]; + client.innerApiCalls.listServiceLbPolicies = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listServiceLbPolicies( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkservices.v1.IServiceLbPolicy[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listMeshes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMeshes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listMeshes with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListMeshesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListMeshesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMeshes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listMeshesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkservices.v1.IMesh[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listMeshes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMeshes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServiceLbPolicies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServiceLbPolicies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listServiceLbPolicies', () => { - it('invokes listServiceLbPolicies without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListServiceLbPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListServiceLbPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.ServiceLbPolicy()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.ServiceLbPolicy()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.ServiceLbPolicy()), - ]; - client.innerApiCalls.listServiceLbPolicies = stubSimpleCall(expectedResponse); - const [response] = await client.listServiceLbPolicies(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServiceLbPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServiceLbPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listServiceLbPolicies with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListServiceLbPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListServiceLbPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listServiceLbPolicies = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listServiceLbPolicies(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listServiceLbPolicies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServiceLbPolicies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listServiceLbPolicies without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListServiceLbPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListServiceLbPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.ServiceLbPolicy()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.ServiceLbPolicy()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.ServiceLbPolicy()), - ]; - client.innerApiCalls.listServiceLbPolicies = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listServiceLbPolicies( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.IServiceLbPolicy[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServiceLbPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServiceLbPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listServiceLbPoliciesStream without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListServiceLbPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListServiceLbPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.ServiceLbPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.ServiceLbPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.ServiceLbPolicy(), + ), + ]; + client.descriptors.page.listServiceLbPolicies.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listServiceLbPoliciesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.ServiceLbPolicy[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkservices.v1.ServiceLbPolicy, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listServiceLbPolicies + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listServiceLbPolicies, request), + ); + assert( + ( + client.descriptors.page.listServiceLbPolicies + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listServiceLbPolicies with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListServiceLbPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListServiceLbPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listServiceLbPolicies = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listServiceLbPolicies(request), expectedError); - const actualRequest = (client.innerApiCalls.listServiceLbPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServiceLbPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listServiceLbPoliciesStream with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListServiceLbPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListServiceLbPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listServiceLbPolicies.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listServiceLbPoliciesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.ServiceLbPolicy[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkservices.v1.ServiceLbPolicy, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listServiceLbPolicies + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listServiceLbPolicies, request), + ); + assert( + ( + client.descriptors.page.listServiceLbPolicies + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listServiceLbPoliciesStream without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListServiceLbPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListServiceLbPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.ServiceLbPolicy()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.ServiceLbPolicy()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.ServiceLbPolicy()), - ]; - client.descriptors.page.listServiceLbPolicies.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listServiceLbPoliciesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.ServiceLbPolicy[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.ServiceLbPolicy) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listServiceLbPolicies.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServiceLbPolicies, request)); - assert( - (client.descriptors.page.listServiceLbPolicies.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listServiceLbPolicies without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListServiceLbPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListServiceLbPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.ServiceLbPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.ServiceLbPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.ServiceLbPolicy(), + ), + ]; + client.descriptors.page.listServiceLbPolicies.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkservices.v1.IServiceLbPolicy[] = + []; + const iterable = client.listServiceLbPoliciesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listServiceLbPolicies + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listServiceLbPolicies + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listServiceLbPoliciesStream with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListServiceLbPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListServiceLbPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listServiceLbPolicies.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listServiceLbPoliciesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.ServiceLbPolicy[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.ServiceLbPolicy) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listServiceLbPolicies.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServiceLbPolicies, request)); - assert( - (client.descriptors.page.listServiceLbPolicies.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listServiceLbPolicies with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListServiceLbPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListServiceLbPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listServiceLbPolicies.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listServiceLbPoliciesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkservices.v1.IServiceLbPolicy[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listServiceLbPolicies + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listServiceLbPolicies + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('listGatewayRouteViews', () => { + it('invokes listGatewayRouteViews without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListGatewayRouteViewsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListGatewayRouteViewsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.GatewayRouteView(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.GatewayRouteView(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.GatewayRouteView(), + ), + ]; + client.innerApiCalls.listGatewayRouteViews = + stubSimpleCall(expectedResponse); + const [response] = await client.listGatewayRouteViews(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listGatewayRouteViews as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listGatewayRouteViews as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listServiceLbPolicies without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListServiceLbPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListServiceLbPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.ServiceLbPolicy()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.ServiceLbPolicy()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.ServiceLbPolicy()), - ]; - client.descriptors.page.listServiceLbPolicies.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkservices.v1.IServiceLbPolicy[] = []; - const iterable = client.listServiceLbPoliciesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listGatewayRouteViews without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListGatewayRouteViewsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListGatewayRouteViewsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.GatewayRouteView(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.GatewayRouteView(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.GatewayRouteView(), + ), + ]; + client.innerApiCalls.listGatewayRouteViews = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listGatewayRouteViews( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkservices.v1.IGatewayRouteView[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listServiceLbPolicies.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listServiceLbPolicies.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listServiceLbPolicies with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListServiceLbPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListServiceLbPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listServiceLbPolicies.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listServiceLbPoliciesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkservices.v1.IServiceLbPolicy[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listServiceLbPolicies.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listServiceLbPolicies.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listGatewayRouteViews as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listGatewayRouteViews as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listGatewayRouteViews', () => { - it('invokes listGatewayRouteViews without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListGatewayRouteViewsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListGatewayRouteViewsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.GatewayRouteView()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.GatewayRouteView()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.GatewayRouteView()), - ]; - client.innerApiCalls.listGatewayRouteViews = stubSimpleCall(expectedResponse); - const [response] = await client.listGatewayRouteViews(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listGatewayRouteViews as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listGatewayRouteViews as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listGatewayRouteViews with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListGatewayRouteViewsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListGatewayRouteViewsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listGatewayRouteViews = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listGatewayRouteViews(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listGatewayRouteViews as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listGatewayRouteViews as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listGatewayRouteViews without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListGatewayRouteViewsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListGatewayRouteViewsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.GatewayRouteView()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.GatewayRouteView()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.GatewayRouteView()), - ]; - client.innerApiCalls.listGatewayRouteViews = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listGatewayRouteViews( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.IGatewayRouteView[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listGatewayRouteViews as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listGatewayRouteViews as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listGatewayRouteViewsStream without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListGatewayRouteViewsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListGatewayRouteViewsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.GatewayRouteView(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.GatewayRouteView(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.GatewayRouteView(), + ), + ]; + client.descriptors.page.listGatewayRouteViews.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listGatewayRouteViewsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.GatewayRouteView[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkservices.v1.GatewayRouteView, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listGatewayRouteViews + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listGatewayRouteViews, request), + ); + assert( + ( + client.descriptors.page.listGatewayRouteViews + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listGatewayRouteViews with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListGatewayRouteViewsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListGatewayRouteViewsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listGatewayRouteViews = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listGatewayRouteViews(request), expectedError); - const actualRequest = (client.innerApiCalls.listGatewayRouteViews as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listGatewayRouteViews as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listGatewayRouteViewsStream with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListGatewayRouteViewsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListGatewayRouteViewsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listGatewayRouteViews.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listGatewayRouteViewsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.GatewayRouteView[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkservices.v1.GatewayRouteView, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listGatewayRouteViews + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listGatewayRouteViews, request), + ); + assert( + ( + client.descriptors.page.listGatewayRouteViews + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listGatewayRouteViewsStream without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListGatewayRouteViewsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListGatewayRouteViewsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.GatewayRouteView()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.GatewayRouteView()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.GatewayRouteView()), - ]; - client.descriptors.page.listGatewayRouteViews.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listGatewayRouteViewsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.GatewayRouteView[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.GatewayRouteView) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listGatewayRouteViews.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listGatewayRouteViews, request)); - assert( - (client.descriptors.page.listGatewayRouteViews.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listGatewayRouteViews without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListGatewayRouteViewsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListGatewayRouteViewsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.GatewayRouteView(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.GatewayRouteView(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.GatewayRouteView(), + ), + ]; + client.descriptors.page.listGatewayRouteViews.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkservices.v1.IGatewayRouteView[] = + []; + const iterable = client.listGatewayRouteViewsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listGatewayRouteViews + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listGatewayRouteViews + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listGatewayRouteViewsStream with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListGatewayRouteViewsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListGatewayRouteViewsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listGatewayRouteViews.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listGatewayRouteViewsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.GatewayRouteView[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.GatewayRouteView) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listGatewayRouteViews.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listGatewayRouteViews, request)); - assert( - (client.descriptors.page.listGatewayRouteViews.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listGatewayRouteViews with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListGatewayRouteViewsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListGatewayRouteViewsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listGatewayRouteViews.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listGatewayRouteViewsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkservices.v1.IGatewayRouteView[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listGatewayRouteViews + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listGatewayRouteViews + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('listMeshRouteViews', () => { + it('invokes listMeshRouteViews without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListMeshRouteViewsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListMeshRouteViewsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.MeshRouteView(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.MeshRouteView(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.MeshRouteView(), + ), + ]; + client.innerApiCalls.listMeshRouteViews = + stubSimpleCall(expectedResponse); + const [response] = await client.listMeshRouteViews(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listMeshRouteViews as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMeshRouteViews as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listGatewayRouteViews without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListGatewayRouteViewsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListGatewayRouteViewsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.GatewayRouteView()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.GatewayRouteView()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.GatewayRouteView()), - ]; - client.descriptors.page.listGatewayRouteViews.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkservices.v1.IGatewayRouteView[] = []; - const iterable = client.listGatewayRouteViewsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listMeshRouteViews without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListMeshRouteViewsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListMeshRouteViewsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.MeshRouteView(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.MeshRouteView(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.MeshRouteView(), + ), + ]; + client.innerApiCalls.listMeshRouteViews = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listMeshRouteViews( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkservices.v1.IMeshRouteView[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listGatewayRouteViews.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listGatewayRouteViews.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listGatewayRouteViews with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListGatewayRouteViewsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListGatewayRouteViewsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listGatewayRouteViews.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listGatewayRouteViewsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkservices.v1.IGatewayRouteView[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listGatewayRouteViews.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listGatewayRouteViews.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listMeshRouteViews as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMeshRouteViews as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listMeshRouteViews', () => { - it('invokes listMeshRouteViews without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListMeshRouteViewsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListMeshRouteViewsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.MeshRouteView()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.MeshRouteView()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.MeshRouteView()), - ]; - client.innerApiCalls.listMeshRouteViews = stubSimpleCall(expectedResponse); - const [response] = await client.listMeshRouteViews(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMeshRouteViews as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMeshRouteViews as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listMeshRouteViews without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListMeshRouteViewsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListMeshRouteViewsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.MeshRouteView()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.MeshRouteView()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.MeshRouteView()), - ]; - client.innerApiCalls.listMeshRouteViews = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listMeshRouteViews( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1.IMeshRouteView[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMeshRouteViews as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMeshRouteViews as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listMeshRouteViews with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListMeshRouteViewsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListMeshRouteViewsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listMeshRouteViews = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listMeshRouteViews(request), expectedError); - const actualRequest = (client.innerApiCalls.listMeshRouteViews as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMeshRouteViews as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listMeshRouteViews with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListMeshRouteViewsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListMeshRouteViewsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listMeshRouteViews = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listMeshRouteViews(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listMeshRouteViews as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMeshRouteViews as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listMeshRouteViewsStream without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListMeshRouteViewsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListMeshRouteViewsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.MeshRouteView()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.MeshRouteView()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.MeshRouteView()), - ]; - client.descriptors.page.listMeshRouteViews.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listMeshRouteViewsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.MeshRouteView[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.MeshRouteView) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listMeshRouteViews.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMeshRouteViews, request)); - assert( - (client.descriptors.page.listMeshRouteViews.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listMeshRouteViewsStream without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListMeshRouteViewsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListMeshRouteViewsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.MeshRouteView(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.MeshRouteView(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.MeshRouteView(), + ), + ]; + client.descriptors.page.listMeshRouteViews.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listMeshRouteViewsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.MeshRouteView[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkservices.v1.MeshRouteView) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listMeshRouteViews.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listMeshRouteViews, request), + ); + assert( + (client.descriptors.page.listMeshRouteViews.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listMeshRouteViewsStream with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListMeshRouteViewsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListMeshRouteViewsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMeshRouteViews.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listMeshRouteViewsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1.MeshRouteView[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1.MeshRouteView) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listMeshRouteViews.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMeshRouteViews, request)); - assert( - (client.descriptors.page.listMeshRouteViews.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listMeshRouteViewsStream with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListMeshRouteViewsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListMeshRouteViewsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMeshRouteViews.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listMeshRouteViewsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1.MeshRouteView[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.networkservices.v1.MeshRouteView) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listMeshRouteViews.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listMeshRouteViews, request), + ); + assert( + (client.descriptors.page.listMeshRouteViews.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listMeshRouteViews without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListMeshRouteViewsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListMeshRouteViewsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1.MeshRouteView()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.MeshRouteView()), - generateSampleMessage(new protos.google.cloud.networkservices.v1.MeshRouteView()), - ]; - client.descriptors.page.listMeshRouteViews.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkservices.v1.IMeshRouteView[] = []; - const iterable = client.listMeshRouteViewsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listMeshRouteViews.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMeshRouteViews.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listMeshRouteViews without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListMeshRouteViewsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListMeshRouteViewsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1.MeshRouteView(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.MeshRouteView(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1.MeshRouteView(), + ), + ]; + client.descriptors.page.listMeshRouteViews.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkservices.v1.IMeshRouteView[] = + []; + const iterable = client.listMeshRouteViewsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listMeshRouteViews.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listMeshRouteViews.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listMeshRouteViews with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1.ListMeshRouteViewsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1.ListMeshRouteViewsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMeshRouteViews.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listMeshRouteViewsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkservices.v1.IMeshRouteView[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listMeshRouteViews.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMeshRouteViews.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listMeshRouteViews with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1.ListMeshRouteViewsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1.ListMeshRouteViewsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMeshRouteViews.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listMeshRouteViewsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkservices.v1.IMeshRouteView[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listMeshRouteViews.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listMeshRouteViews.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes setIamPolicy with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); + }); + it('invokes testIamPermissions with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('authzExtension', async () => { + const fakePath = '/rendered/path/authzExtension'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + authz_extension: 'authzExtensionValue', + }; + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.authzExtensionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.authzExtensionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('authzExtensionPath', () => { + const result = client.authzExtensionPath( + 'projectValue', + 'locationValue', + 'authzExtensionValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.authzExtensionPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromAuthzExtensionName', () => { + const result = client.matchProjectFromAuthzExtensionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.authzExtensionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromAuthzExtensionName', () => { + const result = client.matchLocationFromAuthzExtensionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.authzExtensionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAuthzExtensionFromAuthzExtensionName', () => { + const result = + client.matchAuthzExtensionFromAuthzExtensionName(fakePath); + assert.strictEqual(result, 'authzExtensionValue'); + assert( + (client.pathTemplates.authzExtensionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('authzExtension', async () => { - const fakePath = "/rendered/path/authzExtension"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - authz_extension: "authzExtensionValue", - }; - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.authzExtensionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.authzExtensionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('authzExtensionPath', () => { - const result = client.authzExtensionPath("projectValue", "locationValue", "authzExtensionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.authzExtensionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAuthzExtensionName', () => { - const result = client.matchProjectFromAuthzExtensionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.authzExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAuthzExtensionName', () => { - const result = client.matchLocationFromAuthzExtensionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.authzExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAuthzExtensionFromAuthzExtensionName', () => { - const result = client.matchAuthzExtensionFromAuthzExtensionName(fakePath); - assert.strictEqual(result, "authzExtensionValue"); - assert((client.pathTemplates.authzExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('endpointPolicy', async () => { - const fakePath = "/rendered/path/endpointPolicy"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - endpoint_policy: "endpointPolicyValue", - }; - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.endpointPolicyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.endpointPolicyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('endpointPolicyPath', () => { - const result = client.endpointPolicyPath("projectValue", "locationValue", "endpointPolicyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.endpointPolicyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromEndpointPolicyName', () => { - const result = client.matchProjectFromEndpointPolicyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.endpointPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromEndpointPolicyName', () => { - const result = client.matchLocationFromEndpointPolicyName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.endpointPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEndpointPolicyFromEndpointPolicyName', () => { - const result = client.matchEndpointPolicyFromEndpointPolicyName(fakePath); - assert.strictEqual(result, "endpointPolicyValue"); - assert((client.pathTemplates.endpointPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('endpointPolicy', async () => { + const fakePath = '/rendered/path/endpointPolicy'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + endpoint_policy: 'endpointPolicyValue', + }; + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.endpointPolicyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.endpointPolicyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('endpointPolicyPath', () => { + const result = client.endpointPolicyPath( + 'projectValue', + 'locationValue', + 'endpointPolicyValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.endpointPolicyPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromEndpointPolicyName', () => { + const result = client.matchProjectFromEndpointPolicyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.endpointPolicyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromEndpointPolicyName', () => { + const result = client.matchLocationFromEndpointPolicyName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.endpointPolicyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEndpointPolicyFromEndpointPolicyName', () => { + const result = + client.matchEndpointPolicyFromEndpointPolicyName(fakePath); + assert.strictEqual(result, 'endpointPolicyValue'); + assert( + (client.pathTemplates.endpointPolicyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('gateway', async () => { - const fakePath = "/rendered/path/gateway"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - gateway: "gatewayValue", - }; - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.gatewayPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.gatewayPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('gatewayPath', () => { - const result = client.gatewayPath("projectValue", "locationValue", "gatewayValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.gatewayPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromGatewayName', () => { - const result = client.matchProjectFromGatewayName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.gatewayPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromGatewayName', () => { - const result = client.matchLocationFromGatewayName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.gatewayPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchGatewayFromGatewayName', () => { - const result = client.matchGatewayFromGatewayName(fakePath); - assert.strictEqual(result, "gatewayValue"); - assert((client.pathTemplates.gatewayPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('gateway', async () => { + const fakePath = '/rendered/path/gateway'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + gateway: 'gatewayValue', + }; + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.gatewayPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.gatewayPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('gatewayPath', () => { + const result = client.gatewayPath( + 'projectValue', + 'locationValue', + 'gatewayValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.gatewayPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromGatewayName', () => { + const result = client.matchProjectFromGatewayName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.gatewayPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromGatewayName', () => { + const result = client.matchLocationFromGatewayName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.gatewayPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchGatewayFromGatewayName', () => { + const result = client.matchGatewayFromGatewayName(fakePath); + assert.strictEqual(result, 'gatewayValue'); + assert( + (client.pathTemplates.gatewayPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('gatewayRouteView', async () => { - const fakePath = "/rendered/path/gatewayRouteView"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - gateway: "gatewayValue", - route_view: "routeViewValue", - }; - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.gatewayRouteViewPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.gatewayRouteViewPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('gatewayRouteViewPath', () => { - const result = client.gatewayRouteViewPath("projectValue", "locationValue", "gatewayValue", "routeViewValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.gatewayRouteViewPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromGatewayRouteViewName', () => { - const result = client.matchProjectFromGatewayRouteViewName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.gatewayRouteViewPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromGatewayRouteViewName', () => { - const result = client.matchLocationFromGatewayRouteViewName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.gatewayRouteViewPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchGatewayFromGatewayRouteViewName', () => { - const result = client.matchGatewayFromGatewayRouteViewName(fakePath); - assert.strictEqual(result, "gatewayValue"); - assert((client.pathTemplates.gatewayRouteViewPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRouteViewFromGatewayRouteViewName', () => { - const result = client.matchRouteViewFromGatewayRouteViewName(fakePath); - assert.strictEqual(result, "routeViewValue"); - assert((client.pathTemplates.gatewayRouteViewPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('gatewayRouteView', async () => { + const fakePath = '/rendered/path/gatewayRouteView'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + gateway: 'gatewayValue', + route_view: 'routeViewValue', + }; + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.gatewayRouteViewPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.gatewayRouteViewPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('gatewayRouteViewPath', () => { + const result = client.gatewayRouteViewPath( + 'projectValue', + 'locationValue', + 'gatewayValue', + 'routeViewValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.gatewayRouteViewPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromGatewayRouteViewName', () => { + const result = client.matchProjectFromGatewayRouteViewName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.gatewayRouteViewPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromGatewayRouteViewName', () => { + const result = client.matchLocationFromGatewayRouteViewName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.gatewayRouteViewPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchGatewayFromGatewayRouteViewName', () => { + const result = client.matchGatewayFromGatewayRouteViewName(fakePath); + assert.strictEqual(result, 'gatewayValue'); + assert( + (client.pathTemplates.gatewayRouteViewPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRouteViewFromGatewayRouteViewName', () => { + const result = client.matchRouteViewFromGatewayRouteViewName(fakePath); + assert.strictEqual(result, 'routeViewValue'); + assert( + (client.pathTemplates.gatewayRouteViewPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('grpcRoute', async () => { - const fakePath = "/rendered/path/grpcRoute"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - grpc_route: "grpcRouteValue", - }; - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.grpcRoutePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.grpcRoutePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('grpcRoutePath', () => { - const result = client.grpcRoutePath("projectValue", "locationValue", "grpcRouteValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.grpcRoutePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromGrpcRouteName', () => { - const result = client.matchProjectFromGrpcRouteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.grpcRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromGrpcRouteName', () => { - const result = client.matchLocationFromGrpcRouteName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.grpcRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchGrpcRouteFromGrpcRouteName', () => { - const result = client.matchGrpcRouteFromGrpcRouteName(fakePath); - assert.strictEqual(result, "grpcRouteValue"); - assert((client.pathTemplates.grpcRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('grpcRoute', async () => { + const fakePath = '/rendered/path/grpcRoute'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + grpc_route: 'grpcRouteValue', + }; + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.grpcRoutePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.grpcRoutePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('grpcRoutePath', () => { + const result = client.grpcRoutePath( + 'projectValue', + 'locationValue', + 'grpcRouteValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.grpcRoutePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromGrpcRouteName', () => { + const result = client.matchProjectFromGrpcRouteName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.grpcRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromGrpcRouteName', () => { + const result = client.matchLocationFromGrpcRouteName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.grpcRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchGrpcRouteFromGrpcRouteName', () => { + const result = client.matchGrpcRouteFromGrpcRouteName(fakePath); + assert.strictEqual(result, 'grpcRouteValue'); + assert( + (client.pathTemplates.grpcRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('httpRoute', async () => { - const fakePath = "/rendered/path/httpRoute"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - http_route: "httpRouteValue", - }; - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.httpRoutePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.httpRoutePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('httpRoutePath', () => { - const result = client.httpRoutePath("projectValue", "locationValue", "httpRouteValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.httpRoutePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromHttpRouteName', () => { - const result = client.matchProjectFromHttpRouteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.httpRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromHttpRouteName', () => { - const result = client.matchLocationFromHttpRouteName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.httpRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHttpRouteFromHttpRouteName', () => { - const result = client.matchHttpRouteFromHttpRouteName(fakePath); - assert.strictEqual(result, "httpRouteValue"); - assert((client.pathTemplates.httpRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('httpRoute', async () => { + const fakePath = '/rendered/path/httpRoute'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + http_route: 'httpRouteValue', + }; + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.httpRoutePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.httpRoutePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('httpRoutePath', () => { + const result = client.httpRoutePath( + 'projectValue', + 'locationValue', + 'httpRouteValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.httpRoutePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromHttpRouteName', () => { + const result = client.matchProjectFromHttpRouteName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.httpRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromHttpRouteName', () => { + const result = client.matchLocationFromHttpRouteName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.httpRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchHttpRouteFromHttpRouteName', () => { + const result = client.matchHttpRouteFromHttpRouteName(fakePath); + assert.strictEqual(result, 'httpRouteValue'); + assert( + (client.pathTemplates.httpRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('lbEdgeExtension', async () => { - const fakePath = "/rendered/path/lbEdgeExtension"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - lb_edge_extension: "lbEdgeExtensionValue", - }; - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.lbEdgeExtensionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.lbEdgeExtensionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('lbEdgeExtensionPath', () => { - const result = client.lbEdgeExtensionPath("projectValue", "locationValue", "lbEdgeExtensionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.lbEdgeExtensionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLbEdgeExtensionName', () => { - const result = client.matchProjectFromLbEdgeExtensionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.lbEdgeExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLbEdgeExtensionName', () => { - const result = client.matchLocationFromLbEdgeExtensionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.lbEdgeExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLbEdgeExtensionFromLbEdgeExtensionName', () => { - const result = client.matchLbEdgeExtensionFromLbEdgeExtensionName(fakePath); - assert.strictEqual(result, "lbEdgeExtensionValue"); - assert((client.pathTemplates.lbEdgeExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('lbEdgeExtension', async () => { + const fakePath = '/rendered/path/lbEdgeExtension'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + lb_edge_extension: 'lbEdgeExtensionValue', + }; + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.lbEdgeExtensionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.lbEdgeExtensionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('lbEdgeExtensionPath', () => { + const result = client.lbEdgeExtensionPath( + 'projectValue', + 'locationValue', + 'lbEdgeExtensionValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.lbEdgeExtensionPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLbEdgeExtensionName', () => { + const result = client.matchProjectFromLbEdgeExtensionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.lbEdgeExtensionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLbEdgeExtensionName', () => { + const result = client.matchLocationFromLbEdgeExtensionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.lbEdgeExtensionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLbEdgeExtensionFromLbEdgeExtensionName', () => { + const result = + client.matchLbEdgeExtensionFromLbEdgeExtensionName(fakePath); + assert.strictEqual(result, 'lbEdgeExtensionValue'); + assert( + (client.pathTemplates.lbEdgeExtensionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('lbRouteExtension', async () => { - const fakePath = "/rendered/path/lbRouteExtension"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - lb_route_extension: "lbRouteExtensionValue", - }; - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.lbRouteExtensionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.lbRouteExtensionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('lbRouteExtensionPath', () => { - const result = client.lbRouteExtensionPath("projectValue", "locationValue", "lbRouteExtensionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.lbRouteExtensionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLbRouteExtensionName', () => { - const result = client.matchProjectFromLbRouteExtensionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.lbRouteExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLbRouteExtensionName', () => { - const result = client.matchLocationFromLbRouteExtensionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.lbRouteExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLbRouteExtensionFromLbRouteExtensionName', () => { - const result = client.matchLbRouteExtensionFromLbRouteExtensionName(fakePath); - assert.strictEqual(result, "lbRouteExtensionValue"); - assert((client.pathTemplates.lbRouteExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('lbRouteExtension', async () => { + const fakePath = '/rendered/path/lbRouteExtension'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + lb_route_extension: 'lbRouteExtensionValue', + }; + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.lbRouteExtensionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.lbRouteExtensionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('lbRouteExtensionPath', () => { + const result = client.lbRouteExtensionPath( + 'projectValue', + 'locationValue', + 'lbRouteExtensionValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.lbRouteExtensionPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLbRouteExtensionName', () => { + const result = client.matchProjectFromLbRouteExtensionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.lbRouteExtensionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLbRouteExtensionName', () => { + const result = client.matchLocationFromLbRouteExtensionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.lbRouteExtensionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLbRouteExtensionFromLbRouteExtensionName', () => { + const result = + client.matchLbRouteExtensionFromLbRouteExtensionName(fakePath); + assert.strictEqual(result, 'lbRouteExtensionValue'); + assert( + (client.pathTemplates.lbRouteExtensionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('lbTrafficExtension', async () => { - const fakePath = "/rendered/path/lbTrafficExtension"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - lb_traffic_extension: "lbTrafficExtensionValue", - }; - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.lbTrafficExtensionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.lbTrafficExtensionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('lbTrafficExtensionPath', () => { - const result = client.lbTrafficExtensionPath("projectValue", "locationValue", "lbTrafficExtensionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.lbTrafficExtensionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLbTrafficExtensionName', () => { - const result = client.matchProjectFromLbTrafficExtensionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.lbTrafficExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLbTrafficExtensionName', () => { - const result = client.matchLocationFromLbTrafficExtensionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.lbTrafficExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLbTrafficExtensionFromLbTrafficExtensionName', () => { - const result = client.matchLbTrafficExtensionFromLbTrafficExtensionName(fakePath); - assert.strictEqual(result, "lbTrafficExtensionValue"); - assert((client.pathTemplates.lbTrafficExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('lbTrafficExtension', async () => { + const fakePath = '/rendered/path/lbTrafficExtension'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + lb_traffic_extension: 'lbTrafficExtensionValue', + }; + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.lbTrafficExtensionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.lbTrafficExtensionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('lbTrafficExtensionPath', () => { + const result = client.lbTrafficExtensionPath( + 'projectValue', + 'locationValue', + 'lbTrafficExtensionValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.lbTrafficExtensionPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLbTrafficExtensionName', () => { + const result = client.matchProjectFromLbTrafficExtensionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.lbTrafficExtensionPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLbTrafficExtensionName', () => { + const result = client.matchLocationFromLbTrafficExtensionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.lbTrafficExtensionPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLbTrafficExtensionFromLbTrafficExtensionName', () => { + const result = + client.matchLbTrafficExtensionFromLbTrafficExtensionName(fakePath); + assert.strictEqual(result, 'lbTrafficExtensionValue'); + assert( + ( + client.pathTemplates.lbTrafficExtensionPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('mesh', async () => { - const fakePath = "/rendered/path/mesh"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - mesh: "meshValue", - }; - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.meshPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.meshPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('meshPath', () => { - const result = client.meshPath("projectValue", "locationValue", "meshValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.meshPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMeshName', () => { - const result = client.matchProjectFromMeshName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.meshPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMeshName', () => { - const result = client.matchLocationFromMeshName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.meshPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMeshFromMeshName', () => { - const result = client.matchMeshFromMeshName(fakePath); - assert.strictEqual(result, "meshValue"); - assert((client.pathTemplates.meshPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('mesh', async () => { + const fakePath = '/rendered/path/mesh'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + mesh: 'meshValue', + }; + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.meshPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.meshPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('meshPath', () => { + const result = client.meshPath( + 'projectValue', + 'locationValue', + 'meshValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.meshPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMeshName', () => { + const result = client.matchProjectFromMeshName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.meshPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMeshName', () => { + const result = client.matchLocationFromMeshName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.meshPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMeshFromMeshName', () => { + const result = client.matchMeshFromMeshName(fakePath); + assert.strictEqual(result, 'meshValue'); + assert( + (client.pathTemplates.meshPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('meshRouteView', async () => { - const fakePath = "/rendered/path/meshRouteView"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - mesh: "meshValue", - route_view: "routeViewValue", - }; - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.meshRouteViewPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.meshRouteViewPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('meshRouteViewPath', () => { - const result = client.meshRouteViewPath("projectValue", "locationValue", "meshValue", "routeViewValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.meshRouteViewPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMeshRouteViewName', () => { - const result = client.matchProjectFromMeshRouteViewName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.meshRouteViewPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMeshRouteViewName', () => { - const result = client.matchLocationFromMeshRouteViewName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.meshRouteViewPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMeshFromMeshRouteViewName', () => { - const result = client.matchMeshFromMeshRouteViewName(fakePath); - assert.strictEqual(result, "meshValue"); - assert((client.pathTemplates.meshRouteViewPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRouteViewFromMeshRouteViewName', () => { - const result = client.matchRouteViewFromMeshRouteViewName(fakePath); - assert.strictEqual(result, "routeViewValue"); - assert((client.pathTemplates.meshRouteViewPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('meshRouteView', async () => { + const fakePath = '/rendered/path/meshRouteView'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + mesh: 'meshValue', + route_view: 'routeViewValue', + }; + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.meshRouteViewPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.meshRouteViewPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('meshRouteViewPath', () => { + const result = client.meshRouteViewPath( + 'projectValue', + 'locationValue', + 'meshValue', + 'routeViewValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.meshRouteViewPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMeshRouteViewName', () => { + const result = client.matchProjectFromMeshRouteViewName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.meshRouteViewPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMeshRouteViewName', () => { + const result = client.matchLocationFromMeshRouteViewName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.meshRouteViewPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMeshFromMeshRouteViewName', () => { + const result = client.matchMeshFromMeshRouteViewName(fakePath); + assert.strictEqual(result, 'meshValue'); + assert( + (client.pathTemplates.meshRouteViewPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRouteViewFromMeshRouteViewName', () => { + const result = client.matchRouteViewFromMeshRouteViewName(fakePath); + assert.strictEqual(result, 'routeViewValue'); + assert( + (client.pathTemplates.meshRouteViewPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('serviceBinding', async () => { - const fakePath = "/rendered/path/serviceBinding"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service_binding: "serviceBindingValue", - }; - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.serviceBindingPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.serviceBindingPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('serviceBindingPath', () => { - const result = client.serviceBindingPath("projectValue", "locationValue", "serviceBindingValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.serviceBindingPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceBindingName', () => { - const result = client.matchProjectFromServiceBindingName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.serviceBindingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServiceBindingName', () => { - const result = client.matchLocationFromServiceBindingName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.serviceBindingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceBindingFromServiceBindingName', () => { - const result = client.matchServiceBindingFromServiceBindingName(fakePath); - assert.strictEqual(result, "serviceBindingValue"); - assert((client.pathTemplates.serviceBindingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('serviceBinding', async () => { + const fakePath = '/rendered/path/serviceBinding'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service_binding: 'serviceBindingValue', + }; + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.serviceBindingPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.serviceBindingPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('serviceBindingPath', () => { + const result = client.serviceBindingPath( + 'projectValue', + 'locationValue', + 'serviceBindingValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.serviceBindingPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceBindingName', () => { + const result = client.matchProjectFromServiceBindingName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.serviceBindingPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromServiceBindingName', () => { + const result = client.matchLocationFromServiceBindingName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.serviceBindingPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceBindingFromServiceBindingName', () => { + const result = + client.matchServiceBindingFromServiceBindingName(fakePath); + assert.strictEqual(result, 'serviceBindingValue'); + assert( + (client.pathTemplates.serviceBindingPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('serviceLbPolicy', async () => { - const fakePath = "/rendered/path/serviceLbPolicy"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service_lb_policy: "serviceLbPolicyValue", - }; - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.serviceLbPolicyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.serviceLbPolicyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('serviceLbPolicyPath', () => { - const result = client.serviceLbPolicyPath("projectValue", "locationValue", "serviceLbPolicyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.serviceLbPolicyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceLbPolicyName', () => { - const result = client.matchProjectFromServiceLbPolicyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.serviceLbPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServiceLbPolicyName', () => { - const result = client.matchLocationFromServiceLbPolicyName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.serviceLbPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceLbPolicyFromServiceLbPolicyName', () => { - const result = client.matchServiceLbPolicyFromServiceLbPolicyName(fakePath); - assert.strictEqual(result, "serviceLbPolicyValue"); - assert((client.pathTemplates.serviceLbPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('serviceLbPolicy', async () => { + const fakePath = '/rendered/path/serviceLbPolicy'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + service_lb_policy: 'serviceLbPolicyValue', + }; + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.serviceLbPolicyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.serviceLbPolicyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('serviceLbPolicyPath', () => { + const result = client.serviceLbPolicyPath( + 'projectValue', + 'locationValue', + 'serviceLbPolicyValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.serviceLbPolicyPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromServiceLbPolicyName', () => { + const result = client.matchProjectFromServiceLbPolicyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.serviceLbPolicyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromServiceLbPolicyName', () => { + const result = client.matchLocationFromServiceLbPolicyName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.serviceLbPolicyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceLbPolicyFromServiceLbPolicyName', () => { + const result = + client.matchServiceLbPolicyFromServiceLbPolicyName(fakePath); + assert.strictEqual(result, 'serviceLbPolicyValue'); + assert( + (client.pathTemplates.serviceLbPolicyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('tcpRoute', async () => { - const fakePath = "/rendered/path/tcpRoute"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - tcp_route: "tcpRouteValue", - }; - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.tcpRoutePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tcpRoutePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tcpRoutePath', () => { - const result = client.tcpRoutePath("projectValue", "locationValue", "tcpRouteValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tcpRoutePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTcpRouteName', () => { - const result = client.matchProjectFromTcpRouteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.tcpRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromTcpRouteName', () => { - const result = client.matchLocationFromTcpRouteName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.tcpRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTcpRouteFromTcpRouteName', () => { - const result = client.matchTcpRouteFromTcpRouteName(fakePath); - assert.strictEqual(result, "tcpRouteValue"); - assert((client.pathTemplates.tcpRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('tcpRoute', async () => { + const fakePath = '/rendered/path/tcpRoute'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + tcp_route: 'tcpRouteValue', + }; + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.tcpRoutePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.tcpRoutePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('tcpRoutePath', () => { + const result = client.tcpRoutePath( + 'projectValue', + 'locationValue', + 'tcpRouteValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.tcpRoutePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromTcpRouteName', () => { + const result = client.matchProjectFromTcpRouteName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.tcpRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromTcpRouteName', () => { + const result = client.matchLocationFromTcpRouteName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.tcpRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTcpRouteFromTcpRouteName', () => { + const result = client.matchTcpRouteFromTcpRouteName(fakePath); + assert.strictEqual(result, 'tcpRouteValue'); + assert( + (client.pathTemplates.tcpRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('tlsRoute', async () => { - const fakePath = "/rendered/path/tlsRoute"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - tls_route: "tlsRouteValue", - }; - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.tlsRoutePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tlsRoutePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tlsRoutePath', () => { - const result = client.tlsRoutePath("projectValue", "locationValue", "tlsRouteValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tlsRoutePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTlsRouteName', () => { - const result = client.matchProjectFromTlsRouteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.tlsRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromTlsRouteName', () => { - const result = client.matchLocationFromTlsRouteName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.tlsRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTlsRouteFromTlsRouteName', () => { - const result = client.matchTlsRouteFromTlsRouteName(fakePath); - assert.strictEqual(result, "tlsRouteValue"); - assert((client.pathTemplates.tlsRoutePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('tlsRoute', async () => { + const fakePath = '/rendered/path/tlsRoute'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + tls_route: 'tlsRouteValue', + }; + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.tlsRoutePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.tlsRoutePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('tlsRoutePath', () => { + const result = client.tlsRoutePath( + 'projectValue', + 'locationValue', + 'tlsRouteValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.tlsRoutePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromTlsRouteName', () => { + const result = client.matchProjectFromTlsRouteName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.tlsRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromTlsRouteName', () => { + const result = client.matchLocationFromTlsRouteName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.tlsRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTlsRouteFromTlsRouteName', () => { + const result = client.matchTlsRouteFromTlsRouteName(fakePath); + assert.strictEqual(result, 'tlsRouteValue'); + assert( + (client.pathTemplates.tlsRoutePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('wasmPlugin', async () => { - const fakePath = "/rendered/path/wasmPlugin"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - wasm_plugin: "wasmPluginValue", - }; - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.wasmPluginPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.wasmPluginPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('wasmPluginPath', () => { - const result = client.wasmPluginPath("projectValue", "locationValue", "wasmPluginValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.wasmPluginPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromWasmPluginName', () => { - const result = client.matchProjectFromWasmPluginName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.wasmPluginPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromWasmPluginName', () => { - const result = client.matchLocationFromWasmPluginName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.wasmPluginPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchWasmPluginFromWasmPluginName', () => { - const result = client.matchWasmPluginFromWasmPluginName(fakePath); - assert.strictEqual(result, "wasmPluginValue"); - assert((client.pathTemplates.wasmPluginPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('wasmPlugin', async () => { + const fakePath = '/rendered/path/wasmPlugin'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + wasm_plugin: 'wasmPluginValue', + }; + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.wasmPluginPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.wasmPluginPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('wasmPluginPath', () => { + const result = client.wasmPluginPath( + 'projectValue', + 'locationValue', + 'wasmPluginValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.wasmPluginPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromWasmPluginName', () => { + const result = client.matchProjectFromWasmPluginName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.wasmPluginPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromWasmPluginName', () => { + const result = client.matchLocationFromWasmPluginName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.wasmPluginPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchWasmPluginFromWasmPluginName', () => { + const result = client.matchWasmPluginFromWasmPluginName(fakePath); + assert.strictEqual(result, 'wasmPluginValue'); + assert( + (client.pathTemplates.wasmPluginPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('wasmPluginVersion', async () => { - const fakePath = "/rendered/path/wasmPluginVersion"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - wasm_plugin: "wasmPluginValue", - wasm_plugin_version: "wasmPluginVersionValue", - }; - const client = new networkservicesModule.v1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.wasmPluginVersionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.wasmPluginVersionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('wasmPluginVersionPath', () => { - const result = client.wasmPluginVersionPath("projectValue", "locationValue", "wasmPluginValue", "wasmPluginVersionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.wasmPluginVersionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromWasmPluginVersionName', () => { - const result = client.matchProjectFromWasmPluginVersionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.wasmPluginVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromWasmPluginVersionName', () => { - const result = client.matchLocationFromWasmPluginVersionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.wasmPluginVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchWasmPluginFromWasmPluginVersionName', () => { - const result = client.matchWasmPluginFromWasmPluginVersionName(fakePath); - assert.strictEqual(result, "wasmPluginValue"); - assert((client.pathTemplates.wasmPluginVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchWasmPluginVersionFromWasmPluginVersionName', () => { - const result = client.matchWasmPluginVersionFromWasmPluginVersionName(fakePath); - assert.strictEqual(result, "wasmPluginVersionValue"); - assert((client.pathTemplates.wasmPluginVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('wasmPluginVersion', async () => { + const fakePath = '/rendered/path/wasmPluginVersion'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + wasm_plugin: 'wasmPluginValue', + wasm_plugin_version: 'wasmPluginVersionValue', + }; + const client = new networkservicesModule.v1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.wasmPluginVersionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.wasmPluginVersionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('wasmPluginVersionPath', () => { + const result = client.wasmPluginVersionPath( + 'projectValue', + 'locationValue', + 'wasmPluginValue', + 'wasmPluginVersionValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.wasmPluginVersionPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromWasmPluginVersionName', () => { + const result = client.matchProjectFromWasmPluginVersionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.wasmPluginVersionPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromWasmPluginVersionName', () => { + const result = client.matchLocationFromWasmPluginVersionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.wasmPluginVersionPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchWasmPluginFromWasmPluginVersionName', () => { + const result = + client.matchWasmPluginFromWasmPluginVersionName(fakePath); + assert.strictEqual(result, 'wasmPluginValue'); + assert( + ( + client.pathTemplates.wasmPluginVersionPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchWasmPluginVersionFromWasmPluginVersionName', () => { + const result = + client.matchWasmPluginVersionFromWasmPluginVersionName(fakePath); + assert.strictEqual(result, 'wasmPluginVersionValue'); + assert( + ( + client.pathTemplates.wasmPluginVersionPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-networkservices/test/gapic_network_services_v1beta1.ts b/packages/google-cloud-networkservices/test/gapic_network_services_v1beta1.ts index 6fd18f2ad2fa..fa4306ac9cea 100644 --- a/packages/google-cloud-networkservices/test/gapic_network_services_v1beta1.ts +++ b/packages/google-cloud-networkservices/test/gapic_network_services_v1beta1.ts @@ -19,1219 +19,1604 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as networkservicesModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos} from 'google-gax'; +import { protobuf, LROperation, operationsProtos } from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1beta1.NetworkServicesClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkservices.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = networkservicesModule.v1beta1.NetworkServicesClient.servicePath; - assert.strictEqual(servicePath, 'networkservices.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = networkservicesModule.v1beta1.NetworkServicesClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkservices.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkservices.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkservices.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new networkservicesModule.v1beta1.NetworkServicesClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkservices.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new networkservicesModule.v1beta1.NetworkServicesClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkservices.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new networkservicesModule.v1beta1.NetworkServicesClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = networkservicesModule.v1beta1.NetworkServicesClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient(); - assert(client); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkservices.googleapis.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - fallback: true, - }); - assert(client); - }); + it('has universeDomain', () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.networkServicesStub, undefined); - await client.initialize(); - assert(client.networkServicesStub); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + networkservicesModule.v1beta1.NetworkServicesClient.servicePath; + assert.strictEqual(servicePath, 'networkservices.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + networkservicesModule.v1beta1.NetworkServicesClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkservices.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkservices.example.com'); + }); - it('has close method for the initialized client', done => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.networkServicesStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkservices.example.com'); + }); - it('has close method for the non-initialized client', done => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.networkServicesStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new networkservicesModule.v1beta1.NetworkServicesClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkservices.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new networkservicesModule.v1beta1.NetworkServicesClient({ + universeDomain: 'configured.example.com', }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'networkservices.configured.example.com', + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new networkservicesModule.v1beta1.NetworkServicesClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); }); - describe('getEndpointPolicy', () => { - it('invokes getEndpointPolicy without error', async () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.GetEndpointPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.GetEndpointPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.EndpointPolicy() - ); - client.innerApiCalls.getEndpointPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getEndpointPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getEndpointPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEndpointPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getEndpointPolicy without error using callback', async () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.GetEndpointPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.GetEndpointPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.EndpointPolicy() - ); - client.innerApiCalls.getEndpointPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getEndpointPolicy( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1beta1.IEndpointPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getEndpointPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEndpointPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has port', () => { + const port = networkservicesModule.v1beta1.NetworkServicesClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('invokes getEndpointPolicy with error', async () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.GetEndpointPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.GetEndpointPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getEndpointPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getEndpointPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.getEndpointPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEndpointPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('should create a client with no option', () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient(); + assert(client); + }); - it('invokes getEndpointPolicy with closed client', async () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.GetEndpointPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.GetEndpointPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getEndpointPolicy(request), expectedError); - }); + it('should create a client with gRPC fallback', () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + fallback: true, + }); + assert(client); }); - describe('createEndpointPolicy', () => { - it('invokes createEndpointPolicy without error', async () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.CreateEndpointPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.CreateEndpointPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createEndpointPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.createEndpointPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createEndpointPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEndpointPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.networkServicesStub, undefined); + await client.initialize(); + assert(client.networkServicesStub); + }); - it('invokes createEndpointPolicy without error using callback', async () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.CreateEndpointPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.CreateEndpointPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createEndpointPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createEndpointPolicy( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createEndpointPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEndpointPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the initialized client', (done) => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.networkServicesStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes createEndpointPolicy with call error', async () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.CreateEndpointPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.CreateEndpointPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createEndpointPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createEndpointPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.createEndpointPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEndpointPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the non-initialized client', (done) => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.networkServicesStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes createEndpointPolicy with LRO error', async () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.CreateEndpointPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.CreateEndpointPolicyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createEndpointPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createEndpointPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createEndpointPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEndpointPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('invokes checkCreateEndpointPolicyProgress without error', async () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateEndpointPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getEndpointPolicy', () => { + it('invokes getEndpointPolicy without error', async () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.GetEndpointPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.GetEndpointPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.EndpointPolicy(), + ); + client.innerApiCalls.getEndpointPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getEndpointPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getEndpointPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEndpointPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateEndpointPolicyProgress with error', async () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateEndpointPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes getEndpointPolicy without error using callback', async () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.GetEndpointPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.GetEndpointPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.EndpointPolicy(), + ); + client.innerApiCalls.getEndpointPolicy = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getEndpointPolicy( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkservices.v1beta1.IEndpointPolicy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getEndpointPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEndpointPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateEndpointPolicy', () => { - it('invokes updateEndpointPolicy without error', async () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.UpdateEndpointPolicyRequest() - ); - request.endpointPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.UpdateEndpointPolicyRequest', ['endpointPolicy', 'name']); - request.endpointPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `endpoint_policy.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateEndpointPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateEndpointPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateEndpointPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateEndpointPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getEndpointPolicy with error', async () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.GetEndpointPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.GetEndpointPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getEndpointPolicy = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getEndpointPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getEndpointPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEndpointPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateEndpointPolicy without error using callback', async () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.UpdateEndpointPolicyRequest() - ); - request.endpointPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.UpdateEndpointPolicyRequest', ['endpointPolicy', 'name']); - request.endpointPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `endpoint_policy.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateEndpointPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateEndpointPolicy( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateEndpointPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateEndpointPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getEndpointPolicy with closed client', async () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.GetEndpointPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.GetEndpointPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getEndpointPolicy(request), expectedError); + }); + }); + + describe('createEndpointPolicy', () => { + it('invokes createEndpointPolicy without error', async () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.CreateEndpointPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.CreateEndpointPolicyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createEndpointPolicy = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createEndpointPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createEndpointPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEndpointPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateEndpointPolicy with call error', async () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.UpdateEndpointPolicyRequest() - ); - request.endpointPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.UpdateEndpointPolicyRequest', ['endpointPolicy', 'name']); - request.endpointPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `endpoint_policy.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateEndpointPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateEndpointPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.updateEndpointPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateEndpointPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createEndpointPolicy without error using callback', async () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.CreateEndpointPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.CreateEndpointPolicyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createEndpointPolicy = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createEndpointPolicy( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createEndpointPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEndpointPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateEndpointPolicy with LRO error', async () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.UpdateEndpointPolicyRequest() - ); - request.endpointPolicy ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.UpdateEndpointPolicyRequest', ['endpointPolicy', 'name']); - request.endpointPolicy.name = defaultValue1; - const expectedHeaderRequestParams = `endpoint_policy.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateEndpointPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateEndpointPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateEndpointPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateEndpointPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createEndpointPolicy with call error', async () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.CreateEndpointPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.CreateEndpointPolicyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createEndpointPolicy = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createEndpointPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createEndpointPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEndpointPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateEndpointPolicyProgress without error', async () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateEndpointPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createEndpointPolicy with LRO error', async () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.CreateEndpointPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.CreateEndpointPolicyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createEndpointPolicy = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createEndpointPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createEndpointPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEndpointPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateEndpointPolicyProgress with error', async () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes checkCreateEndpointPolicyProgress without error', async () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateEndpointPolicyProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateEndpointPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateEndpointPolicyProgress with error', async () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateEndpointPolicyProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateEndpointPolicy', () => { + it('invokes updateEndpointPolicy without error', async () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.UpdateEndpointPolicyRequest(), + ); + request.endpointPolicy ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.UpdateEndpointPolicyRequest', + ['endpointPolicy', 'name'], + ); + request.endpointPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `endpoint_policy.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateEndpointPolicy = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateEndpointPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateEndpointPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEndpointPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteEndpointPolicy', () => { - it('invokes deleteEndpointPolicy without error', async () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.DeleteEndpointPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.DeleteEndpointPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteEndpointPolicy = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteEndpointPolicy(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteEndpointPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEndpointPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateEndpointPolicy without error using callback', async () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.UpdateEndpointPolicyRequest(), + ); + request.endpointPolicy ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.UpdateEndpointPolicyRequest', + ['endpointPolicy', 'name'], + ); + request.endpointPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `endpoint_policy.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateEndpointPolicy = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateEndpointPolicy( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkservices.v1beta1.IEndpointPolicy, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateEndpointPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEndpointPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteEndpointPolicy without error using callback', async () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.DeleteEndpointPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.DeleteEndpointPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteEndpointPolicy = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteEndpointPolicy( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteEndpointPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEndpointPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateEndpointPolicy with call error', async () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.UpdateEndpointPolicyRequest(), + ); + request.endpointPolicy ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.UpdateEndpointPolicyRequest', + ['endpointPolicy', 'name'], + ); + request.endpointPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `endpoint_policy.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateEndpointPolicy = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateEndpointPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateEndpointPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEndpointPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteEndpointPolicy with call error', async () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.DeleteEndpointPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.DeleteEndpointPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteEndpointPolicy = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteEndpointPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteEndpointPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEndpointPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateEndpointPolicy with LRO error', async () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.UpdateEndpointPolicyRequest(), + ); + request.endpointPolicy ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.UpdateEndpointPolicyRequest', + ['endpointPolicy', 'name'], + ); + request.endpointPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `endpoint_policy.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateEndpointPolicy = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateEndpointPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateEndpointPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEndpointPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteEndpointPolicy with LRO error', async () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.DeleteEndpointPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.DeleteEndpointPolicyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteEndpointPolicy = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteEndpointPolicy(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteEndpointPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEndpointPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateEndpointPolicyProgress without error', async () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateEndpointPolicyProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteEndpointPolicyProgress without error', async () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteEndpointPolicyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateEndpointPolicyProgress with error', async () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateEndpointPolicyProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteEndpointPolicy', () => { + it('invokes deleteEndpointPolicy without error', async () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.DeleteEndpointPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.DeleteEndpointPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteEndpointPolicy = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteEndpointPolicy(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteEndpointPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEndpointPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteEndpointPolicyProgress with error', async () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes deleteEndpointPolicy without error using callback', async () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.DeleteEndpointPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.DeleteEndpointPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteEndpointPolicy = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteEndpointPolicy( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkservices.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteEndpointPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEndpointPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteEndpointPolicyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteEndpointPolicy with call error', async () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.DeleteEndpointPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.DeleteEndpointPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteEndpointPolicy = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteEndpointPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteEndpointPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEndpointPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listEndpointPolicies', () => { - it('invokes listEndpointPolicies without error', async () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.ListEndpointPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.ListEndpointPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.EndpointPolicy()), - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.EndpointPolicy()), - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.EndpointPolicy()), - ]; - client.innerApiCalls.listEndpointPolicies = stubSimpleCall(expectedResponse); - const [response] = await client.listEndpointPolicies(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEndpointPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEndpointPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteEndpointPolicy with LRO error', async () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.DeleteEndpointPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.DeleteEndpointPolicyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteEndpointPolicy = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteEndpointPolicy(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteEndpointPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEndpointPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listEndpointPolicies without error using callback', async () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.ListEndpointPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.ListEndpointPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.EndpointPolicy()), - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.EndpointPolicy()), - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.EndpointPolicy()), - ]; - client.innerApiCalls.listEndpointPolicies = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listEndpointPolicies( - request, - (err?: Error|null, result?: protos.google.cloud.networkservices.v1beta1.IEndpointPolicy[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEndpointPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEndpointPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteEndpointPolicyProgress without error', async () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteEndpointPolicyProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes listEndpointPolicies with error', async () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.ListEndpointPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.ListEndpointPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listEndpointPolicies = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listEndpointPolicies(request), expectedError); - const actualRequest = (client.innerApiCalls.listEndpointPolicies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEndpointPolicies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteEndpointPolicyProgress with error', async () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteEndpointPolicyProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listEndpointPolicies', () => { + it('invokes listEndpointPolicies without error', async () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.ListEndpointPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.ListEndpointPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.EndpointPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.EndpointPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.EndpointPolicy(), + ), + ]; + client.innerApiCalls.listEndpointPolicies = + stubSimpleCall(expectedResponse); + const [response] = await client.listEndpointPolicies(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listEndpointPolicies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEndpointPolicies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listEndpointPoliciesStream without error', async () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.ListEndpointPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.ListEndpointPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.EndpointPolicy()), - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.EndpointPolicy()), - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.EndpointPolicy()), - ]; - client.descriptors.page.listEndpointPolicies.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listEndpointPoliciesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1beta1.EndpointPolicy[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1beta1.EndpointPolicy) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listEndpointPolicies.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listEndpointPolicies, request)); - assert( - (client.descriptors.page.listEndpointPolicies.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listEndpointPolicies without error using callback', async () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.ListEndpointPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.ListEndpointPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.EndpointPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.EndpointPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.EndpointPolicy(), + ), + ]; + client.innerApiCalls.listEndpointPolicies = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listEndpointPolicies( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkservices.v1beta1.IEndpointPolicy[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listEndpointPolicies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEndpointPolicies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listEndpointPoliciesStream with error', async () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.ListEndpointPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.ListEndpointPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listEndpointPolicies.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listEndpointPoliciesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkservices.v1beta1.EndpointPolicy[] = []; - stream.on('data', (response: protos.google.cloud.networkservices.v1beta1.EndpointPolicy) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listEndpointPolicies.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listEndpointPolicies, request)); - assert( - (client.descriptors.page.listEndpointPolicies.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listEndpointPolicies with error', async () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.ListEndpointPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.ListEndpointPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listEndpointPolicies = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listEndpointPolicies(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listEndpointPolicies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEndpointPolicies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listEndpointPolicies without error', async () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.ListEndpointPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.ListEndpointPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.EndpointPolicy()), - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.EndpointPolicy()), - generateSampleMessage(new protos.google.cloud.networkservices.v1beta1.EndpointPolicy()), - ]; - client.descriptors.page.listEndpointPolicies.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkservices.v1beta1.IEndpointPolicy[] = []; - const iterable = client.listEndpointPoliciesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listEndpointPolicies.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listEndpointPolicies.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('invokes listEndpointPoliciesStream without error', async () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.ListEndpointPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.ListEndpointPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.EndpointPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.EndpointPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.EndpointPolicy(), + ), + ]; + client.descriptors.page.listEndpointPolicies.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listEndpointPoliciesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1beta1.EndpointPolicy[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkservices.v1beta1.EndpointPolicy, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('uses async iteration with listEndpointPolicies with error', async () => { - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkservices.v1beta1.ListEndpointPoliciesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkservices.v1beta1.ListEndpointPoliciesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listEndpointPolicies.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listEndpointPoliciesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkservices.v1beta1.IEndpointPolicy[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listEndpointPolicies.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listEndpointPolicies.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + stream.on('error', (err: Error) => { + reject(err); }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listEndpointPolicies.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listEndpointPolicies, request), + ); + assert( + (client.descriptors.page.listEndpointPolicies.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('Path templates', () => { - - describe('endpointPolicy', async () => { - const fakePath = "/rendered/path/endpointPolicy"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - endpoint_policy: "endpointPolicyValue", - }; - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.endpointPolicyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.endpointPolicyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('endpointPolicyPath', () => { - const result = client.endpointPolicyPath("projectValue", "locationValue", "endpointPolicyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.endpointPolicyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromEndpointPolicyName', () => { - const result = client.matchProjectFromEndpointPolicyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.endpointPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromEndpointPolicyName', () => { - const result = client.matchLocationFromEndpointPolicyName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.endpointPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEndpointPolicyFromEndpointPolicyName', () => { - const result = client.matchEndpointPolicyFromEndpointPolicyName(fakePath); - assert.strictEqual(result, "endpointPolicyValue"); - assert((client.pathTemplates.endpointPolicyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listEndpointPoliciesStream with error', async () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.ListEndpointPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.ListEndpointPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listEndpointPolicies.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listEndpointPoliciesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkservices.v1beta1.EndpointPolicy[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkservices.v1beta1.EndpointPolicy, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - describe('lbRouteExtension', async () => { - const fakePath = "/rendered/path/lbRouteExtension"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - lb_route_extension: "lbRouteExtensionValue", - }; - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.lbRouteExtensionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.lbRouteExtensionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('lbRouteExtensionPath', () => { - const result = client.lbRouteExtensionPath("projectValue", "locationValue", "lbRouteExtensionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.lbRouteExtensionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLbRouteExtensionName', () => { - const result = client.matchProjectFromLbRouteExtensionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.lbRouteExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLbRouteExtensionName', () => { - const result = client.matchLocationFromLbRouteExtensionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.lbRouteExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLbRouteExtensionFromLbRouteExtensionName', () => { - const result = client.matchLbRouteExtensionFromLbRouteExtensionName(fakePath); - assert.strictEqual(result, "lbRouteExtensionValue"); - assert((client.pathTemplates.lbRouteExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + stream.on('error', (err: Error) => { + reject(err); }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listEndpointPolicies.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listEndpointPolicies, request), + ); + assert( + (client.descriptors.page.listEndpointPolicies.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - describe('lbTrafficExtension', async () => { - const fakePath = "/rendered/path/lbTrafficExtension"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - lb_traffic_extension: "lbTrafficExtensionValue", - }; - const client = new networkservicesModule.v1beta1.NetworkServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.lbTrafficExtensionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.lbTrafficExtensionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('lbTrafficExtensionPath', () => { - const result = client.lbTrafficExtensionPath("projectValue", "locationValue", "lbTrafficExtensionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.lbTrafficExtensionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('uses async iteration with listEndpointPolicies without error', async () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.ListEndpointPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.ListEndpointPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.EndpointPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.EndpointPolicy(), + ), + generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.EndpointPolicy(), + ), + ]; + client.descriptors.page.listEndpointPolicies.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkservices.v1beta1.IEndpointPolicy[] = + []; + const iterable = client.listEndpointPoliciesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listEndpointPolicies.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listEndpointPolicies.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('matchProjectFromLbTrafficExtensionName', () => { - const result = client.matchProjectFromLbTrafficExtensionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.lbTrafficExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('uses async iteration with listEndpointPolicies with error', async () => { + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkservices.v1beta1.ListEndpointPoliciesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkservices.v1beta1.ListEndpointPoliciesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listEndpointPolicies.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listEndpointPoliciesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkservices.v1beta1.IEndpointPolicy[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listEndpointPolicies.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listEndpointPolicies.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('Path templates', () => { + describe('endpointPolicy', async () => { + const fakePath = '/rendered/path/endpointPolicy'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + endpoint_policy: 'endpointPolicyValue', + }; + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.endpointPolicyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.endpointPolicyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('endpointPolicyPath', () => { + const result = client.endpointPolicyPath( + 'projectValue', + 'locationValue', + 'endpointPolicyValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.endpointPolicyPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromEndpointPolicyName', () => { + const result = client.matchProjectFromEndpointPolicyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.endpointPolicyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromEndpointPolicyName', () => { + const result = client.matchLocationFromEndpointPolicyName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.endpointPolicyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEndpointPolicyFromEndpointPolicyName', () => { + const result = + client.matchEndpointPolicyFromEndpointPolicyName(fakePath); + assert.strictEqual(result, 'endpointPolicyValue'); + assert( + (client.pathTemplates.endpointPolicyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchLocationFromLbTrafficExtensionName', () => { - const result = client.matchLocationFromLbTrafficExtensionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.lbTrafficExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('lbRouteExtension', async () => { + const fakePath = '/rendered/path/lbRouteExtension'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + lb_route_extension: 'lbRouteExtensionValue', + }; + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.lbRouteExtensionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.lbRouteExtensionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('lbRouteExtensionPath', () => { + const result = client.lbRouteExtensionPath( + 'projectValue', + 'locationValue', + 'lbRouteExtensionValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.lbRouteExtensionPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLbRouteExtensionName', () => { + const result = client.matchProjectFromLbRouteExtensionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.lbRouteExtensionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLbRouteExtensionName', () => { + const result = client.matchLocationFromLbRouteExtensionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.lbRouteExtensionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLbRouteExtensionFromLbRouteExtensionName', () => { + const result = + client.matchLbRouteExtensionFromLbRouteExtensionName(fakePath); + assert.strictEqual(result, 'lbRouteExtensionValue'); + assert( + (client.pathTemplates.lbRouteExtensionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchLbTrafficExtensionFromLbTrafficExtensionName', () => { - const result = client.matchLbTrafficExtensionFromLbTrafficExtensionName(fakePath); - assert.strictEqual(result, "lbTrafficExtensionValue"); - assert((client.pathTemplates.lbTrafficExtensionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('lbTrafficExtension', async () => { + const fakePath = '/rendered/path/lbTrafficExtension'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + lb_traffic_extension: 'lbTrafficExtensionValue', + }; + const client = new networkservicesModule.v1beta1.NetworkServicesClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.lbTrafficExtensionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.lbTrafficExtensionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('lbTrafficExtensionPath', () => { + const result = client.lbTrafficExtensionPath( + 'projectValue', + 'locationValue', + 'lbTrafficExtensionValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.lbTrafficExtensionPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLbTrafficExtensionName', () => { + const result = client.matchProjectFromLbTrafficExtensionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.lbTrafficExtensionPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLbTrafficExtensionName', () => { + const result = client.matchLocationFromLbTrafficExtensionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.lbTrafficExtensionPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLbTrafficExtensionFromLbTrafficExtensionName', () => { + const result = + client.matchLbTrafficExtensionFromLbTrafficExtensionName(fakePath); + assert.strictEqual(result, 'lbTrafficExtensionValue'); + assert( + ( + client.pathTemplates.lbTrafficExtensionPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-networkservices/webpack.config.js b/packages/google-cloud-networkservices/webpack.config.js index 64403f45fa5e..bb1632c89fcb 100644 --- a/packages/google-cloud-networkservices/webpack.config.js +++ b/packages/google-cloud-networkservices/webpack.config.js @@ -1,4 +1,4 @@ -// Copyright 2026 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-notebooks/.eslintignore b/packages/google-cloud-notebooks/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-notebooks/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-notebooks/.eslintrc.json b/packages/google-cloud-notebooks/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-notebooks/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-notebooks/README.md b/packages/google-cloud-notebooks/README.md index b832ccbef93d..04be394c0dfe 100644 --- a/packages/google-cloud-notebooks/README.md +++ b/packages/google-cloud-notebooks/README.md @@ -172,7 +172,7 @@ More Information: [Google Cloud Platform Launch Stages][launch_stages] ## Contributing -Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-notebooks/CONTRIBUTING.md). +Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/CONTRIBUTING.md). Please note that this `README.md` and a variety of configuration files in this repository (including `.nycrc` and `tsconfig.json`) @@ -182,7 +182,7 @@ are generated from a central template. Apache Version 2.0 -See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-notebooks/LICENSE) +See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/LICENSE) [shell_img]: https://gstatic.com/cloudssh/images/open-btn.png [projects]: https://console.cloud.google.com/project diff --git a/packages/google-cloud-notebooks/protos/protos.d.ts b/packages/google-cloud-notebooks/protos/protos.d.ts index 336b30bc4977..21731afb1f55 100644 --- a/packages/google-cloud-notebooks/protos/protos.d.ts +++ b/packages/google-cloud-notebooks/protos/protos.d.ts @@ -19512,6 +19512,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -19529,6 +19532,9 @@ export namespace google { /** CommonLanguageSettings destinations. */ public destinations: google.api.ClientLibraryDestination[]; + /** CommonLanguageSettings selectiveGapicGeneration. */ + public selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); + /** * Creates a new CommonLanguageSettings instance using the specified properties. * @param [properties] Properties to set @@ -20229,6 +20235,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -20243,6 +20252,9 @@ export namespace google { /** PythonSettings common. */ public common?: (google.api.ICommonLanguageSettings|null); + /** PythonSettings experimentalFeatures. */ + public experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); + /** * Creates a new PythonSettings instance using the specified properties. * @param [properties] Properties to set @@ -20321,6 +20333,118 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + namespace PythonSettings { + + /** Properties of an ExperimentalFeatures. */ + interface IExperimentalFeatures { + + /** ExperimentalFeatures restAsyncIoEnabled */ + restAsyncIoEnabled?: (boolean|null); + + /** ExperimentalFeatures protobufPythonicTypesEnabled */ + protobufPythonicTypesEnabled?: (boolean|null); + + /** ExperimentalFeatures unversionedPackageDisabled */ + unversionedPackageDisabled?: (boolean|null); + } + + /** Represents an ExperimentalFeatures. */ + class ExperimentalFeatures implements IExperimentalFeatures { + + /** + * Constructs a new ExperimentalFeatures. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.PythonSettings.IExperimentalFeatures); + + /** ExperimentalFeatures restAsyncIoEnabled. */ + public restAsyncIoEnabled: boolean; + + /** ExperimentalFeatures protobufPythonicTypesEnabled. */ + public protobufPythonicTypesEnabled: boolean; + + /** ExperimentalFeatures unversionedPackageDisabled. */ + public unversionedPackageDisabled: boolean; + + /** + * Creates a new ExperimentalFeatures instance using the specified properties. + * @param [properties] Properties to set + * @returns ExperimentalFeatures instance + */ + public static create(properties?: google.api.PythonSettings.IExperimentalFeatures): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Encodes the specified ExperimentalFeatures message. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @param message ExperimentalFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.PythonSettings.IExperimentalFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExperimentalFeatures message, length delimited. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @param message ExperimentalFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.PythonSettings.IExperimentalFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExperimentalFeatures + * @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.api.PythonSettings.ExperimentalFeatures; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExperimentalFeatures + * @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.api.PythonSettings.ExperimentalFeatures; + + /** + * Verifies an ExperimentalFeatures 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 an ExperimentalFeatures message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExperimentalFeatures + */ + public static fromObject(object: { [k: string]: any }): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Creates a plain object from an ExperimentalFeatures message. Also converts values to other types if specified. + * @param message ExperimentalFeatures + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.PythonSettings.ExperimentalFeatures, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExperimentalFeatures to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExperimentalFeatures + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + /** Properties of a NodeSettings. */ interface INodeSettings { @@ -20647,6 +20771,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -20661,6 +20788,9 @@ export namespace google { /** GoSettings common. */ public common?: (google.api.ICommonLanguageSettings|null); + /** GoSettings renamedServices. */ + public renamedServices: { [k: string]: string }; + /** * Creates a new GoSettings instance using the specified properties. * @param [properties] Properties to set @@ -20985,6 +21115,109 @@ export namespace google { PACKAGE_MANAGER = 20 } + /** Properties of a SelectiveGapicGeneration. */ + interface ISelectiveGapicGeneration { + + /** SelectiveGapicGeneration methods */ + methods?: (string[]|null); + + /** SelectiveGapicGeneration generateOmittedAsInternal */ + generateOmittedAsInternal?: (boolean|null); + } + + /** Represents a SelectiveGapicGeneration. */ + class SelectiveGapicGeneration implements ISelectiveGapicGeneration { + + /** + * Constructs a new SelectiveGapicGeneration. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.ISelectiveGapicGeneration); + + /** SelectiveGapicGeneration methods. */ + public methods: string[]; + + /** SelectiveGapicGeneration generateOmittedAsInternal. */ + public generateOmittedAsInternal: boolean; + + /** + * Creates a new SelectiveGapicGeneration instance using the specified properties. + * @param [properties] Properties to set + * @returns SelectiveGapicGeneration instance + */ + public static create(properties?: google.api.ISelectiveGapicGeneration): google.api.SelectiveGapicGeneration; + + /** + * Encodes the specified SelectiveGapicGeneration message. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @param message SelectiveGapicGeneration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.ISelectiveGapicGeneration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SelectiveGapicGeneration message, length delimited. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @param message SelectiveGapicGeneration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.ISelectiveGapicGeneration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SelectiveGapicGeneration + * @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.api.SelectiveGapicGeneration; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SelectiveGapicGeneration + * @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.api.SelectiveGapicGeneration; + + /** + * Verifies a SelectiveGapicGeneration 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 SelectiveGapicGeneration message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SelectiveGapicGeneration + */ + public static fromObject(object: { [k: string]: any }): google.api.SelectiveGapicGeneration; + + /** + * Creates a plain object from a SelectiveGapicGeneration message. Also converts values to other types if specified. + * @param message SelectiveGapicGeneration + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.SelectiveGapicGeneration, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SelectiveGapicGeneration to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SelectiveGapicGeneration + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** LaunchStage enum. */ enum LaunchStage { LAUNCH_STAGE_UNSPECIFIED = 0, @@ -21101,6 +21334,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -21131,6 +21365,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -21180,6 +21417,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -21314,6 +21554,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -21355,6 +21598,9 @@ export namespace google { /** DescriptorProto reservedName. */ public reservedName: string[]; + /** DescriptorProto visibility. */ + public visibility: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility); + /** * Creates a new DescriptorProto instance using the specified properties. * @param [properties] Properties to set @@ -22202,6 +22448,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -22228,6 +22477,9 @@ export namespace google { /** EnumDescriptorProto reservedName. */ public reservedName: string[]; + /** EnumDescriptorProto visibility. */ + public visibility: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility); + /** * Creates a new EnumDescriptorProto instance using the specified properties. * @param [properties] Properties to set @@ -23162,6 +23414,9 @@ export namespace google { /** FieldOptions features */ features?: (google.protobuf.IFeatureSet|null); + /** FieldOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** FieldOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); @@ -23217,6 +23472,9 @@ export namespace google { /** FieldOptions features. */ public features?: (google.protobuf.IFeatureSet|null); + /** FieldOptions featureSupport. */ + public featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** FieldOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; @@ -23437,6 +23695,121 @@ export namespace google { */ public static getTypeUrl(typeUrlPrefix?: string): string; } + + /** Properties of a FeatureSupport. */ + interface IFeatureSupport { + + /** FeatureSupport editionIntroduced */ + editionIntroduced?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSupport editionDeprecated */ + editionDeprecated?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSupport deprecationWarning */ + deprecationWarning?: (string|null); + + /** FeatureSupport editionRemoved */ + editionRemoved?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + } + + /** Represents a FeatureSupport. */ + class FeatureSupport implements IFeatureSupport { + + /** + * Constructs a new FeatureSupport. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.FieldOptions.IFeatureSupport); + + /** FeatureSupport editionIntroduced. */ + public editionIntroduced: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSupport editionDeprecated. */ + public editionDeprecated: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSupport deprecationWarning. */ + public deprecationWarning: string; + + /** FeatureSupport editionRemoved. */ + public editionRemoved: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** + * Creates a new FeatureSupport instance using the specified properties. + * @param [properties] Properties to set + * @returns FeatureSupport instance + */ + public static create(properties?: google.protobuf.FieldOptions.IFeatureSupport): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Encodes the specified FeatureSupport message. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @param message FeatureSupport message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.FieldOptions.IFeatureSupport, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FeatureSupport message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @param message FeatureSupport message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.FieldOptions.IFeatureSupport, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FeatureSupport + * @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.protobuf.FieldOptions.FeatureSupport; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FeatureSupport + * @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.protobuf.FieldOptions.FeatureSupport; + + /** + * Verifies a FeatureSupport 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 FeatureSupport message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FeatureSupport + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Creates a plain object from a FeatureSupport message. Also converts values to other types if specified. + * @param message FeatureSupport + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldOptions.FeatureSupport, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FeatureSupport to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FeatureSupport + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } } /** Properties of an OneofOptions. */ @@ -23675,6 +24048,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -23697,6 +24073,9 @@ export namespace google { /** EnumValueOptions debugRedact. */ public debugRedact: boolean; + /** EnumValueOptions featureSupport. */ + public featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; @@ -24289,6 +24668,12 @@ export namespace google { /** FeatureSet jsonFormat */ jsonFormat?: (google.protobuf.FeatureSet.JsonFormat|keyof typeof google.protobuf.FeatureSet.JsonFormat|null); + + /** FeatureSet enforceNamingStyle */ + enforceNamingStyle?: (google.protobuf.FeatureSet.EnforceNamingStyle|keyof typeof google.protobuf.FeatureSet.EnforceNamingStyle|null); + + /** FeatureSet defaultSymbolVisibility */ + defaultSymbolVisibility?: (google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|keyof typeof google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|null); } /** Represents a FeatureSet. */ @@ -24318,6 +24703,12 @@ export namespace google { /** FeatureSet jsonFormat. */ public jsonFormat: (google.protobuf.FeatureSet.JsonFormat|keyof typeof google.protobuf.FeatureSet.JsonFormat); + /** FeatureSet enforceNamingStyle. */ + public enforceNamingStyle: (google.protobuf.FeatureSet.EnforceNamingStyle|keyof typeof google.protobuf.FeatureSet.EnforceNamingStyle); + + /** FeatureSet defaultSymbolVisibility. */ + public defaultSymbolVisibility: (google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|keyof typeof google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility); + /** * Creates a new FeatureSet instance using the specified properties. * @param [properties] Properties to set @@ -24440,6 +24831,116 @@ export namespace google { ALLOW = 1, LEGACY_BEST_EFFORT = 2 } + + /** EnforceNamingStyle enum. */ + enum EnforceNamingStyle { + ENFORCE_NAMING_STYLE_UNKNOWN = 0, + STYLE2024 = 1, + STYLE_LEGACY = 2 + } + + /** Properties of a VisibilityFeature. */ + interface IVisibilityFeature { + } + + /** Represents a VisibilityFeature. */ + class VisibilityFeature implements IVisibilityFeature { + + /** + * Constructs a new VisibilityFeature. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.FeatureSet.IVisibilityFeature); + + /** + * Creates a new VisibilityFeature instance using the specified properties. + * @param [properties] Properties to set + * @returns VisibilityFeature instance + */ + public static create(properties?: google.protobuf.FeatureSet.IVisibilityFeature): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Encodes the specified VisibilityFeature message. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @param message VisibilityFeature message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.FeatureSet.IVisibilityFeature, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified VisibilityFeature message, length delimited. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @param message VisibilityFeature message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.FeatureSet.IVisibilityFeature, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns VisibilityFeature + * @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.protobuf.FeatureSet.VisibilityFeature; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns VisibilityFeature + * @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.protobuf.FeatureSet.VisibilityFeature; + + /** + * Verifies a VisibilityFeature 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 VisibilityFeature message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns VisibilityFeature + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Creates a plain object from a VisibilityFeature message. Also converts values to other types if specified. + * @param message VisibilityFeature + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FeatureSet.VisibilityFeature, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this VisibilityFeature to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for VisibilityFeature + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace VisibilityFeature { + + /** DefaultSymbolVisibility enum. */ + enum DefaultSymbolVisibility { + DEFAULT_SYMBOL_VISIBILITY_UNKNOWN = 0, + EXPORT_ALL = 1, + EXPORT_TOP_LEVEL = 2, + LOCAL_ALL = 3, + STRICT = 4 + } + } } /** Properties of a FeatureSetDefaults. */ @@ -24559,8 +25060,11 @@ export namespace google { /** FeatureSetEditionDefault edition */ edition?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); - /** FeatureSetEditionDefault features */ - features?: (google.protobuf.IFeatureSet|null); + /** FeatureSetEditionDefault overridableFeatures */ + overridableFeatures?: (google.protobuf.IFeatureSet|null); + + /** FeatureSetEditionDefault fixedFeatures */ + fixedFeatures?: (google.protobuf.IFeatureSet|null); } /** Represents a FeatureSetEditionDefault. */ @@ -24575,8 +25079,11 @@ export namespace google { /** FeatureSetEditionDefault edition. */ public edition: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); - /** FeatureSetEditionDefault features. */ - public features?: (google.protobuf.IFeatureSet|null); + /** FeatureSetEditionDefault overridableFeatures. */ + public overridableFeatures?: (google.protobuf.IFeatureSet|null); + + /** FeatureSetEditionDefault fixedFeatures. */ + public fixedFeatures?: (google.protobuf.IFeatureSet|null); /** * Creates a new FeatureSetEditionDefault instance using the specified properties. @@ -25109,6 +25616,13 @@ export namespace google { } } + /** SymbolVisibility enum. */ + enum SymbolVisibility { + VISIBILITY_UNSET = 0, + VISIBILITY_LOCAL = 1, + VISIBILITY_EXPORT = 2 + } + /** Properties of a Timestamp. */ interface ITimestamp { diff --git a/packages/google-cloud-notebooks/protos/protos.js b/packages/google-cloud-notebooks/protos/protos.js index f72ae15ae12b..8734ea082b3b 100644 --- a/packages/google-cloud-notebooks/protos/protos.js +++ b/packages/google-cloud-notebooks/protos/protos.js @@ -48987,6 +48987,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -49021,6 +49022,14 @@ */ CommonLanguageSettings.prototype.destinations = $util.emptyArray; + /** + * CommonLanguageSettings selectiveGapicGeneration. + * @member {google.api.ISelectiveGapicGeneration|null|undefined} selectiveGapicGeneration + * @memberof google.api.CommonLanguageSettings + * @instance + */ + CommonLanguageSettings.prototype.selectiveGapicGeneration = null; + /** * Creates a new CommonLanguageSettings instance using the specified properties. * @function create @@ -49053,6 +49062,8 @@ writer.int32(message.destinations[i]); writer.ldelim(); } + if (message.selectiveGapicGeneration != null && Object.hasOwnProperty.call(message, "selectiveGapicGeneration")) + $root.google.api.SelectiveGapicGeneration.encode(message.selectiveGapicGeneration, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); return writer; }; @@ -49104,6 +49115,10 @@ message.destinations.push(reader.int32()); break; } + case 3: { + message.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -49155,6 +49170,11 @@ break; } } + if (message.selectiveGapicGeneration != null && message.hasOwnProperty("selectiveGapicGeneration")) { + var error = $root.google.api.SelectiveGapicGeneration.verify(message.selectiveGapicGeneration); + if (error) + return "selectiveGapicGeneration." + error; + } return null; }; @@ -49197,6 +49217,11 @@ break; } } + if (object.selectiveGapicGeneration != null) { + if (typeof object.selectiveGapicGeneration !== "object") + throw TypeError(".google.api.CommonLanguageSettings.selectiveGapicGeneration: object expected"); + message.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.fromObject(object.selectiveGapicGeneration); + } return message; }; @@ -49215,8 +49240,10 @@ var object = {}; if (options.arrays || options.defaults) object.destinations = []; - if (options.defaults) + if (options.defaults) { object.referenceDocsUri = ""; + object.selectiveGapicGeneration = null; + } if (message.referenceDocsUri != null && message.hasOwnProperty("referenceDocsUri")) object.referenceDocsUri = message.referenceDocsUri; if (message.destinations && message.destinations.length) { @@ -49224,6 +49251,8 @@ for (var j = 0; j < message.destinations.length; ++j) object.destinations[j] = options.enums === String ? $root.google.api.ClientLibraryDestination[message.destinations[j]] === undefined ? message.destinations[j] : $root.google.api.ClientLibraryDestination[message.destinations[j]] : message.destinations[j]; } + if (message.selectiveGapicGeneration != null && message.hasOwnProperty("selectiveGapicGeneration")) + object.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.toObject(message.selectiveGapicGeneration, options); return object; }; @@ -51046,6 +51075,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -51071,6 +51101,14 @@ */ PythonSettings.prototype.common = null; + /** + * PythonSettings experimentalFeatures. + * @member {google.api.PythonSettings.IExperimentalFeatures|null|undefined} experimentalFeatures + * @memberof google.api.PythonSettings + * @instance + */ + PythonSettings.prototype.experimentalFeatures = null; + /** * Creates a new PythonSettings instance using the specified properties. * @function create @@ -51097,6 +51135,8 @@ writer = $Writer.create(); if (message.common != null && Object.hasOwnProperty.call(message, "common")) $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.experimentalFeatures != null && Object.hasOwnProperty.call(message, "experimentalFeatures")) + $root.google.api.PythonSettings.ExperimentalFeatures.encode(message.experimentalFeatures, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; @@ -51137,6 +51177,10 @@ message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); break; } + case 2: { + message.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -51177,6 +51221,11 @@ if (error) return "common." + error; } + if (message.experimentalFeatures != null && message.hasOwnProperty("experimentalFeatures")) { + var error = $root.google.api.PythonSettings.ExperimentalFeatures.verify(message.experimentalFeatures); + if (error) + return "experimentalFeatures." + error; + } return null; }; @@ -51197,6 +51246,11 @@ throw TypeError(".google.api.PythonSettings.common: object expected"); message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); } + if (object.experimentalFeatures != null) { + if (typeof object.experimentalFeatures !== "object") + throw TypeError(".google.api.PythonSettings.experimentalFeatures: object expected"); + message.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.fromObject(object.experimentalFeatures); + } return message; }; @@ -51213,10 +51267,14 @@ if (!options) options = {}; var object = {}; - if (options.defaults) + if (options.defaults) { object.common = null; + object.experimentalFeatures = null; + } if (message.common != null && message.hasOwnProperty("common")) object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + if (message.experimentalFeatures != null && message.hasOwnProperty("experimentalFeatures")) + object.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.toObject(message.experimentalFeatures, options); return object; }; @@ -51246,6 +51304,258 @@ return typeUrlPrefix + "/google.api.PythonSettings"; }; + PythonSettings.ExperimentalFeatures = (function() { + + /** + * Properties of an ExperimentalFeatures. + * @memberof google.api.PythonSettings + * @interface IExperimentalFeatures + * @property {boolean|null} [restAsyncIoEnabled] ExperimentalFeatures restAsyncIoEnabled + * @property {boolean|null} [protobufPythonicTypesEnabled] ExperimentalFeatures protobufPythonicTypesEnabled + * @property {boolean|null} [unversionedPackageDisabled] ExperimentalFeatures unversionedPackageDisabled + */ + + /** + * Constructs a new ExperimentalFeatures. + * @memberof google.api.PythonSettings + * @classdesc Represents an ExperimentalFeatures. + * @implements IExperimentalFeatures + * @constructor + * @param {google.api.PythonSettings.IExperimentalFeatures=} [properties] Properties to set + */ + function ExperimentalFeatures(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]]; + } + + /** + * ExperimentalFeatures restAsyncIoEnabled. + * @member {boolean} restAsyncIoEnabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.restAsyncIoEnabled = false; + + /** + * ExperimentalFeatures protobufPythonicTypesEnabled. + * @member {boolean} protobufPythonicTypesEnabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.protobufPythonicTypesEnabled = false; + + /** + * ExperimentalFeatures unversionedPackageDisabled. + * @member {boolean} unversionedPackageDisabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.unversionedPackageDisabled = false; + + /** + * Creates a new ExperimentalFeatures instance using the specified properties. + * @function create + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures=} [properties] Properties to set + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures instance + */ + ExperimentalFeatures.create = function create(properties) { + return new ExperimentalFeatures(properties); + }; + + /** + * Encodes the specified ExperimentalFeatures message. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @function encode + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures} message ExperimentalFeatures message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExperimentalFeatures.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.restAsyncIoEnabled != null && Object.hasOwnProperty.call(message, "restAsyncIoEnabled")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.restAsyncIoEnabled); + if (message.protobufPythonicTypesEnabled != null && Object.hasOwnProperty.call(message, "protobufPythonicTypesEnabled")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.protobufPythonicTypesEnabled); + if (message.unversionedPackageDisabled != null && Object.hasOwnProperty.call(message, "unversionedPackageDisabled")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.unversionedPackageDisabled); + return writer; + }; + + /** + * Encodes the specified ExperimentalFeatures message, length delimited. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures} message ExperimentalFeatures message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExperimentalFeatures.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer. + * @function decode + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExperimentalFeatures.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.PythonSettings.ExperimentalFeatures(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.restAsyncIoEnabled = reader.bool(); + break; + } + case 2: { + message.protobufPythonicTypesEnabled = reader.bool(); + break; + } + case 3: { + message.unversionedPackageDisabled = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExperimentalFeatures.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExperimentalFeatures message. + * @function verify + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExperimentalFeatures.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.restAsyncIoEnabled != null && message.hasOwnProperty("restAsyncIoEnabled")) + if (typeof message.restAsyncIoEnabled !== "boolean") + return "restAsyncIoEnabled: boolean expected"; + if (message.protobufPythonicTypesEnabled != null && message.hasOwnProperty("protobufPythonicTypesEnabled")) + if (typeof message.protobufPythonicTypesEnabled !== "boolean") + return "protobufPythonicTypesEnabled: boolean expected"; + if (message.unversionedPackageDisabled != null && message.hasOwnProperty("unversionedPackageDisabled")) + if (typeof message.unversionedPackageDisabled !== "boolean") + return "unversionedPackageDisabled: boolean expected"; + return null; + }; + + /** + * Creates an ExperimentalFeatures message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {Object.} object Plain object + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + */ + ExperimentalFeatures.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.PythonSettings.ExperimentalFeatures) + return object; + var message = new $root.google.api.PythonSettings.ExperimentalFeatures(); + if (object.restAsyncIoEnabled != null) + message.restAsyncIoEnabled = Boolean(object.restAsyncIoEnabled); + if (object.protobufPythonicTypesEnabled != null) + message.protobufPythonicTypesEnabled = Boolean(object.protobufPythonicTypesEnabled); + if (object.unversionedPackageDisabled != null) + message.unversionedPackageDisabled = Boolean(object.unversionedPackageDisabled); + return message; + }; + + /** + * Creates a plain object from an ExperimentalFeatures message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.ExperimentalFeatures} message ExperimentalFeatures + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExperimentalFeatures.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.restAsyncIoEnabled = false; + object.protobufPythonicTypesEnabled = false; + object.unversionedPackageDisabled = false; + } + if (message.restAsyncIoEnabled != null && message.hasOwnProperty("restAsyncIoEnabled")) + object.restAsyncIoEnabled = message.restAsyncIoEnabled; + if (message.protobufPythonicTypesEnabled != null && message.hasOwnProperty("protobufPythonicTypesEnabled")) + object.protobufPythonicTypesEnabled = message.protobufPythonicTypesEnabled; + if (message.unversionedPackageDisabled != null && message.hasOwnProperty("unversionedPackageDisabled")) + object.unversionedPackageDisabled = message.unversionedPackageDisabled; + return object; + }; + + /** + * Converts this ExperimentalFeatures to JSON. + * @function toJSON + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + * @returns {Object.} JSON object + */ + ExperimentalFeatures.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExperimentalFeatures + * @function getTypeUrl + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExperimentalFeatures.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.PythonSettings.ExperimentalFeatures"; + }; + + return ExperimentalFeatures; + })(); + return PythonSettings; })(); @@ -52122,6 +52432,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -52133,6 +52444,7 @@ * @param {google.api.IGoSettings=} [properties] Properties to set */ function GoSettings(properties) { + this.renamedServices = {}; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -52147,6 +52459,14 @@ */ GoSettings.prototype.common = null; + /** + * GoSettings renamedServices. + * @member {Object.} renamedServices + * @memberof google.api.GoSettings + * @instance + */ + GoSettings.prototype.renamedServices = $util.emptyObject; + /** * Creates a new GoSettings instance using the specified properties. * @function create @@ -52173,6 +52493,9 @@ writer = $Writer.create(); if (message.common != null && Object.hasOwnProperty.call(message, "common")) $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.renamedServices != null && Object.hasOwnProperty.call(message, "renamedServices")) + for (var keys = Object.keys(message.renamedServices), i = 0; i < keys.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.renamedServices[keys[i]]).ldelim(); return writer; }; @@ -52203,7 +52526,7 @@ GoSettings.decode = function decode(reader, length, error) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.GoSettings(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.GoSettings(), key, value; while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) @@ -52213,6 +52536,29 @@ message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); break; } + case 2: { + if (message.renamedServices === $util.emptyObject) + message.renamedServices = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = ""; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = reader.string(); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.renamedServices[key] = value; + break; + } default: reader.skipType(tag & 7); break; @@ -52253,6 +52599,14 @@ if (error) return "common." + error; } + if (message.renamedServices != null && message.hasOwnProperty("renamedServices")) { + if (!$util.isObject(message.renamedServices)) + return "renamedServices: object expected"; + var key = Object.keys(message.renamedServices); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.renamedServices[key[i]])) + return "renamedServices: string{k:string} expected"; + } return null; }; @@ -52273,6 +52627,13 @@ throw TypeError(".google.api.GoSettings.common: object expected"); message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); } + if (object.renamedServices) { + if (typeof object.renamedServices !== "object") + throw TypeError(".google.api.GoSettings.renamedServices: object expected"); + message.renamedServices = {}; + for (var keys = Object.keys(object.renamedServices), i = 0; i < keys.length; ++i) + message.renamedServices[keys[i]] = String(object.renamedServices[keys[i]]); + } return message; }; @@ -52289,10 +52650,18 @@ if (!options) options = {}; var object = {}; + if (options.objects || options.defaults) + object.renamedServices = {}; if (options.defaults) object.common = null; if (message.common != null && message.hasOwnProperty("common")) object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + var keys2; + if (message.renamedServices && (keys2 = Object.keys(message.renamedServices)).length) { + object.renamedServices = {}; + for (var j = 0; j < keys2.length; ++j) + object.renamedServices[keys2[j]] = message.renamedServices[keys2[j]]; + } return object; }; @@ -52931,29 +53300,274 @@ return values; })(); - /** - * LaunchStage enum. - * @name google.api.LaunchStage - * @enum {number} - * @property {number} LAUNCH_STAGE_UNSPECIFIED=0 LAUNCH_STAGE_UNSPECIFIED value - * @property {number} UNIMPLEMENTED=6 UNIMPLEMENTED value - * @property {number} PRELAUNCH=7 PRELAUNCH value - * @property {number} EARLY_ACCESS=1 EARLY_ACCESS value - * @property {number} ALPHA=2 ALPHA value - * @property {number} BETA=3 BETA value - * @property {number} GA=4 GA value - * @property {number} DEPRECATED=5 DEPRECATED value - */ - api.LaunchStage = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "LAUNCH_STAGE_UNSPECIFIED"] = 0; - values[valuesById[6] = "UNIMPLEMENTED"] = 6; - values[valuesById[7] = "PRELAUNCH"] = 7; - values[valuesById[1] = "EARLY_ACCESS"] = 1; - values[valuesById[2] = "ALPHA"] = 2; - values[valuesById[3] = "BETA"] = 3; - values[valuesById[4] = "GA"] = 4; - values[valuesById[5] = "DEPRECATED"] = 5; + api.SelectiveGapicGeneration = (function() { + + /** + * Properties of a SelectiveGapicGeneration. + * @memberof google.api + * @interface ISelectiveGapicGeneration + * @property {Array.|null} [methods] SelectiveGapicGeneration methods + * @property {boolean|null} [generateOmittedAsInternal] SelectiveGapicGeneration generateOmittedAsInternal + */ + + /** + * Constructs a new SelectiveGapicGeneration. + * @memberof google.api + * @classdesc Represents a SelectiveGapicGeneration. + * @implements ISelectiveGapicGeneration + * @constructor + * @param {google.api.ISelectiveGapicGeneration=} [properties] Properties to set + */ + function SelectiveGapicGeneration(properties) { + this.methods = []; + 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]]; + } + + /** + * SelectiveGapicGeneration methods. + * @member {Array.} methods + * @memberof google.api.SelectiveGapicGeneration + * @instance + */ + SelectiveGapicGeneration.prototype.methods = $util.emptyArray; + + /** + * SelectiveGapicGeneration generateOmittedAsInternal. + * @member {boolean} generateOmittedAsInternal + * @memberof google.api.SelectiveGapicGeneration + * @instance + */ + SelectiveGapicGeneration.prototype.generateOmittedAsInternal = false; + + /** + * Creates a new SelectiveGapicGeneration instance using the specified properties. + * @function create + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration=} [properties] Properties to set + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration instance + */ + SelectiveGapicGeneration.create = function create(properties) { + return new SelectiveGapicGeneration(properties); + }; + + /** + * Encodes the specified SelectiveGapicGeneration message. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @function encode + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration} message SelectiveGapicGeneration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SelectiveGapicGeneration.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.methods != null && message.methods.length) + for (var i = 0; i < message.methods.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.methods[i]); + if (message.generateOmittedAsInternal != null && Object.hasOwnProperty.call(message, "generateOmittedAsInternal")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.generateOmittedAsInternal); + return writer; + }; + + /** + * Encodes the specified SelectiveGapicGeneration message, length delimited. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration} message SelectiveGapicGeneration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SelectiveGapicGeneration.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer. + * @function decode + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SelectiveGapicGeneration.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.SelectiveGapicGeneration(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + if (!(message.methods && message.methods.length)) + message.methods = []; + message.methods.push(reader.string()); + break; + } + case 2: { + message.generateOmittedAsInternal = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SelectiveGapicGeneration.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SelectiveGapicGeneration message. + * @function verify + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SelectiveGapicGeneration.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.methods != null && message.hasOwnProperty("methods")) { + if (!Array.isArray(message.methods)) + return "methods: array expected"; + for (var i = 0; i < message.methods.length; ++i) + if (!$util.isString(message.methods[i])) + return "methods: string[] expected"; + } + if (message.generateOmittedAsInternal != null && message.hasOwnProperty("generateOmittedAsInternal")) + if (typeof message.generateOmittedAsInternal !== "boolean") + return "generateOmittedAsInternal: boolean expected"; + return null; + }; + + /** + * Creates a SelectiveGapicGeneration message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {Object.} object Plain object + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + */ + SelectiveGapicGeneration.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.SelectiveGapicGeneration) + return object; + var message = new $root.google.api.SelectiveGapicGeneration(); + if (object.methods) { + if (!Array.isArray(object.methods)) + throw TypeError(".google.api.SelectiveGapicGeneration.methods: array expected"); + message.methods = []; + for (var i = 0; i < object.methods.length; ++i) + message.methods[i] = String(object.methods[i]); + } + if (object.generateOmittedAsInternal != null) + message.generateOmittedAsInternal = Boolean(object.generateOmittedAsInternal); + return message; + }; + + /** + * Creates a plain object from a SelectiveGapicGeneration message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.SelectiveGapicGeneration} message SelectiveGapicGeneration + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SelectiveGapicGeneration.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.methods = []; + if (options.defaults) + object.generateOmittedAsInternal = false; + if (message.methods && message.methods.length) { + object.methods = []; + for (var j = 0; j < message.methods.length; ++j) + object.methods[j] = message.methods[j]; + } + if (message.generateOmittedAsInternal != null && message.hasOwnProperty("generateOmittedAsInternal")) + object.generateOmittedAsInternal = message.generateOmittedAsInternal; + return object; + }; + + /** + * Converts this SelectiveGapicGeneration to JSON. + * @function toJSON + * @memberof google.api.SelectiveGapicGeneration + * @instance + * @returns {Object.} JSON object + */ + SelectiveGapicGeneration.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SelectiveGapicGeneration + * @function getTypeUrl + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SelectiveGapicGeneration.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.SelectiveGapicGeneration"; + }; + + return SelectiveGapicGeneration; + })(); + + /** + * LaunchStage enum. + * @name google.api.LaunchStage + * @enum {number} + * @property {number} LAUNCH_STAGE_UNSPECIFIED=0 LAUNCH_STAGE_UNSPECIFIED value + * @property {number} UNIMPLEMENTED=6 UNIMPLEMENTED value + * @property {number} PRELAUNCH=7 PRELAUNCH value + * @property {number} EARLY_ACCESS=1 EARLY_ACCESS value + * @property {number} ALPHA=2 ALPHA value + * @property {number} BETA=3 BETA value + * @property {number} GA=4 GA value + * @property {number} DEPRECATED=5 DEPRECATED value + */ + api.LaunchStage = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "LAUNCH_STAGE_UNSPECIFIED"] = 0; + values[valuesById[6] = "UNIMPLEMENTED"] = 6; + values[valuesById[7] = "PRELAUNCH"] = 7; + values[valuesById[1] = "EARLY_ACCESS"] = 1; + values[valuesById[2] = "ALPHA"] = 2; + values[valuesById[3] = "BETA"] = 3; + values[valuesById[4] = "GA"] = 4; + values[valuesById[5] = "DEPRECATED"] = 5; return values; })(); @@ -53200,6 +53814,7 @@ * @name google.protobuf.Edition * @enum {number} * @property {number} EDITION_UNKNOWN=0 EDITION_UNKNOWN value + * @property {number} EDITION_LEGACY=900 EDITION_LEGACY value * @property {number} EDITION_PROTO2=998 EDITION_PROTO2 value * @property {number} EDITION_PROTO3=999 EDITION_PROTO3 value * @property {number} EDITION_2023=1000 EDITION_2023 value @@ -53214,6 +53829,7 @@ protobuf.Edition = (function() { var valuesById = {}, values = Object.create(valuesById); values[valuesById[0] = "EDITION_UNKNOWN"] = 0; + values[valuesById[900] = "EDITION_LEGACY"] = 900; values[valuesById[998] = "EDITION_PROTO2"] = 998; values[valuesById[999] = "EDITION_PROTO3"] = 999; values[valuesById[1000] = "EDITION_2023"] = 1000; @@ -53238,6 +53854,7 @@ * @property {Array.|null} [dependency] FileDescriptorProto dependency * @property {Array.|null} [publicDependency] FileDescriptorProto publicDependency * @property {Array.|null} [weakDependency] FileDescriptorProto weakDependency + * @property {Array.|null} [optionDependency] FileDescriptorProto optionDependency * @property {Array.|null} [messageType] FileDescriptorProto messageType * @property {Array.|null} [enumType] FileDescriptorProto enumType * @property {Array.|null} [service] FileDescriptorProto service @@ -53260,6 +53877,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -53310,6 +53928,14 @@ */ FileDescriptorProto.prototype.weakDependency = $util.emptyArray; + /** + * FileDescriptorProto optionDependency. + * @member {Array.} optionDependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.optionDependency = $util.emptyArray; + /** * FileDescriptorProto messageType. * @member {Array.} messageType @@ -53431,6 +54057,9 @@ writer.uint32(/* id 12, wireType 2 =*/98).string(message.syntax); if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) writer.uint32(/* id 14, wireType 0 =*/112).int32(message.edition); + if (message.optionDependency != null && message.optionDependency.length) + for (var i = 0; i < message.optionDependency.length; ++i) + writer.uint32(/* id 15, wireType 2 =*/122).string(message.optionDependency[i]); return writer; }; @@ -53503,6 +54132,12 @@ message.weakDependency.push(reader.int32()); break; } + case 15: { + if (!(message.optionDependency && message.optionDependency.length)) + message.optionDependency = []; + message.optionDependency.push(reader.string()); + break; + } case 4: { if (!(message.messageType && message.messageType.length)) message.messageType = []; @@ -53605,6 +54240,13 @@ if (!$util.isInteger(message.weakDependency[i])) return "weakDependency: integer[] expected"; } + if (message.optionDependency != null && message.hasOwnProperty("optionDependency")) { + if (!Array.isArray(message.optionDependency)) + return "optionDependency: array expected"; + for (var i = 0; i < message.optionDependency.length; ++i) + if (!$util.isString(message.optionDependency[i])) + return "optionDependency: string[] expected"; + } if (message.messageType != null && message.hasOwnProperty("messageType")) { if (!Array.isArray(message.messageType)) return "messageType: array expected"; @@ -53659,6 +54301,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -53711,6 +54354,13 @@ for (var i = 0; i < object.weakDependency.length; ++i) message.weakDependency[i] = object.weakDependency[i] | 0; } + if (object.optionDependency) { + if (!Array.isArray(object.optionDependency)) + throw TypeError(".google.protobuf.FileDescriptorProto.optionDependency: array expected"); + message.optionDependency = []; + for (var i = 0; i < object.optionDependency.length; ++i) + message.optionDependency[i] = String(object.optionDependency[i]); + } if (object.messageType) { if (!Array.isArray(object.messageType)) throw TypeError(".google.protobuf.FileDescriptorProto.messageType: array expected"); @@ -53774,6 +54424,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -53839,6 +54493,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -53895,6 +54550,11 @@ object.syntax = message.syntax; if (message.edition != null && message.hasOwnProperty("edition")) object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.optionDependency && message.optionDependency.length) { + object.optionDependency = []; + for (var j = 0; j < message.optionDependency.length; ++j) + object.optionDependency[j] = message.optionDependency[j]; + } return object; }; @@ -53943,6 +54603,7 @@ * @property {google.protobuf.IMessageOptions|null} [options] DescriptorProto options * @property {Array.|null} [reservedRange] DescriptorProto reservedRange * @property {Array.|null} [reservedName] DescriptorProto reservedName + * @property {google.protobuf.SymbolVisibility|null} [visibility] DescriptorProto visibility */ /** @@ -54048,6 +54709,14 @@ */ DescriptorProto.prototype.reservedName = $util.emptyArray; + /** + * DescriptorProto visibility. + * @member {google.protobuf.SymbolVisibility} visibility + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.visibility = 0; + /** * Creates a new DescriptorProto instance using the specified properties. * @function create @@ -54100,6 +54769,8 @@ if (message.reservedName != null && message.reservedName.length) for (var i = 0; i < message.reservedName.length; ++i) writer.uint32(/* id 10, wireType 2 =*/82).string(message.reservedName[i]); + if (message.visibility != null && Object.hasOwnProperty.call(message, "visibility")) + writer.uint32(/* id 11, wireType 0 =*/88).int32(message.visibility); return writer; }; @@ -54192,6 +54863,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -54305,6 +54980,15 @@ if (!$util.isString(message.reservedName[i])) return "reservedName: string[] expected"; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + switch (message.visibility) { + default: + return "visibility: enum value expected"; + case 0: + case 1: + case 2: + break; + } return null; }; @@ -54404,6 +55088,26 @@ for (var i = 0; i < object.reservedName.length; ++i) message.reservedName[i] = String(object.reservedName[i]); } + switch (object.visibility) { + default: + if (typeof object.visibility === "number") { + message.visibility = object.visibility; + break; + } + break; + case "VISIBILITY_UNSET": + case 0: + message.visibility = 0; + break; + case "VISIBILITY_LOCAL": + case 1: + message.visibility = 1; + break; + case "VISIBILITY_EXPORT": + case 2: + message.visibility = 2; + break; + } return message; }; @@ -54433,6 +55137,7 @@ if (options.defaults) { object.name = ""; object.options = null; + object.visibility = options.enums === String ? "VISIBILITY_UNSET" : 0; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -54478,6 +55183,8 @@ for (var j = 0; j < message.reservedName.length; ++j) object.reservedName[j] = message.reservedName[j]; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + object.visibility = options.enums === String ? $root.google.protobuf.SymbolVisibility[message.visibility] === undefined ? message.visibility : $root.google.protobuf.SymbolVisibility[message.visibility] : message.visibility; return object; }; @@ -56522,6 +57229,7 @@ * @property {google.protobuf.IEnumOptions|null} [options] EnumDescriptorProto options * @property {Array.|null} [reservedRange] EnumDescriptorProto reservedRange * @property {Array.|null} [reservedName] EnumDescriptorProto reservedName + * @property {google.protobuf.SymbolVisibility|null} [visibility] EnumDescriptorProto visibility */ /** @@ -56582,6 +57290,14 @@ */ EnumDescriptorProto.prototype.reservedName = $util.emptyArray; + /** + * EnumDescriptorProto visibility. + * @member {google.protobuf.SymbolVisibility} visibility + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.visibility = 0; + /** * Creates a new EnumDescriptorProto instance using the specified properties. * @function create @@ -56619,6 +57335,8 @@ if (message.reservedName != null && message.reservedName.length) for (var i = 0; i < message.reservedName.length; ++i) writer.uint32(/* id 5, wireType 2 =*/42).string(message.reservedName[i]); + if (message.visibility != null && Object.hasOwnProperty.call(message, "visibility")) + writer.uint32(/* id 6, wireType 0 =*/48).int32(message.visibility); return writer; }; @@ -56681,6 +57399,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -56749,6 +57471,15 @@ if (!$util.isString(message.reservedName[i])) return "reservedName: string[] expected"; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + switch (message.visibility) { + default: + return "visibility: enum value expected"; + case 0: + case 1: + case 2: + break; + } return null; }; @@ -56798,6 +57529,26 @@ for (var i = 0; i < object.reservedName.length; ++i) message.reservedName[i] = String(object.reservedName[i]); } + switch (object.visibility) { + default: + if (typeof object.visibility === "number") { + message.visibility = object.visibility; + break; + } + break; + case "VISIBILITY_UNSET": + case 0: + message.visibility = 0; + break; + case "VISIBILITY_LOCAL": + case 1: + message.visibility = 1; + break; + case "VISIBILITY_EXPORT": + case 2: + message.visibility = 2; + break; + } return message; }; @@ -56822,6 +57573,7 @@ if (options.defaults) { object.name = ""; object.options = null; + object.visibility = options.enums === String ? "VISIBILITY_UNSET" : 0; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -56842,6 +57594,8 @@ for (var j = 0; j < message.reservedName.length; ++j) object.reservedName[j] = message.reservedName[j]; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + object.visibility = options.enums === String ? $root.google.protobuf.SymbolVisibility[message.visibility] === undefined ? message.visibility : $root.google.protobuf.SymbolVisibility[message.visibility] : message.visibility; return object; }; @@ -59160,6 +59914,7 @@ * @property {Array.|null} [targets] FieldOptions targets * @property {Array.|null} [editionDefaults] FieldOptions editionDefaults * @property {google.protobuf.IFeatureSet|null} [features] FieldOptions features + * @property {google.protobuf.FieldOptions.IFeatureSupport|null} [featureSupport] FieldOptions featureSupport * @property {Array.|null} [uninterpretedOption] FieldOptions uninterpretedOption * @property {Array.|null} [".google.api.fieldBehavior"] FieldOptions .google.api.fieldBehavior * @property {google.api.IResourceReference|null} [".google.api.resourceReference"] FieldOptions .google.api.resourceReference @@ -59280,6 +60035,14 @@ */ FieldOptions.prototype.features = null; + /** + * FieldOptions featureSupport. + * @member {google.protobuf.FieldOptions.IFeatureSupport|null|undefined} featureSupport + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.featureSupport = null; + /** * FieldOptions uninterpretedOption. * @member {Array.} uninterpretedOption @@ -59354,6 +60117,8 @@ $root.google.protobuf.FieldOptions.EditionDefault.encode(message.editionDefaults[i], writer.uint32(/* id 20, wireType 2 =*/162).fork()).ldelim(); if (message.features != null && Object.hasOwnProperty.call(message, "features")) $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 21, wireType 2 =*/170).fork()).ldelim(); + if (message.featureSupport != null && Object.hasOwnProperty.call(message, "featureSupport")) + $root.google.protobuf.FieldOptions.FeatureSupport.encode(message.featureSupport, writer.uint32(/* id 22, wireType 2 =*/178).fork()).ldelim(); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); @@ -59455,6 +60220,10 @@ message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); break; } + case 22: { + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.decode(reader, reader.uint32()); + break; + } case 999: { if (!(message.uninterpretedOption && message.uninterpretedOption.length)) message.uninterpretedOption = []; @@ -59590,6 +60359,11 @@ if (error) return "features." + error; } + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) { + var error = $root.google.protobuf.FieldOptions.FeatureSupport.verify(message.featureSupport); + if (error) + return "featureSupport." + error; + } if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { if (!Array.isArray(message.uninterpretedOption)) return "uninterpretedOption: array expected"; @@ -59778,6 +60552,11 @@ throw TypeError(".google.protobuf.FieldOptions.features: object expected"); message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); } + if (object.featureSupport != null) { + if (typeof object.featureSupport !== "object") + throw TypeError(".google.protobuf.FieldOptions.featureSupport: object expected"); + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.fromObject(object.featureSupport); + } if (object.uninterpretedOption) { if (!Array.isArray(object.uninterpretedOption)) throw TypeError(".google.protobuf.FieldOptions.uninterpretedOption: array expected"); @@ -59875,6 +60654,7 @@ object.debugRedact = false; object.retention = options.enums === String ? "RETENTION_UNKNOWN" : 0; object.features = null; + object.featureSupport = null; object[".google.api.resourceReference"] = null; } if (message.ctype != null && message.hasOwnProperty("ctype")) @@ -59907,6 +60687,8 @@ } if (message.features != null && message.hasOwnProperty("features")) object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) + object.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.toObject(message.featureSupport, options); if (message.uninterpretedOption && message.uninterpretedOption.length) { object.uninterpretedOption = []; for (var j = 0; j < message.uninterpretedOption.length; ++j) @@ -60179,6 +60961,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -60220,103 +61003,589 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; + case "EDITION_PROTO2": + case 998: + message.edition = 998; + break; + case "EDITION_PROTO3": + case 999: + message.edition = 999; + break; + case "EDITION_2023": + case 1000: + message.edition = 1000; + break; + case "EDITION_2024": + case 1001: + message.edition = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.edition = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.edition = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.edition = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.edition = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.edition = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.edition = 2147483647; + break; + } + if (object.value != null) + message.value = String(object.value); + return message; + }; + + /** + * Creates a plain object from an EditionDefault message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {google.protobuf.FieldOptions.EditionDefault} message EditionDefault + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EditionDefault.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.value = ""; + object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + } + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + if (message.edition != null && message.hasOwnProperty("edition")) + object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + return object; + }; + + /** + * Converts this EditionDefault to JSON. + * @function toJSON + * @memberof google.protobuf.FieldOptions.EditionDefault + * @instance + * @returns {Object.} JSON object + */ + EditionDefault.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for EditionDefault + * @function getTypeUrl + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + EditionDefault.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FieldOptions.EditionDefault"; + }; + + return EditionDefault; + })(); + + FieldOptions.FeatureSupport = (function() { + + /** + * Properties of a FeatureSupport. + * @memberof google.protobuf.FieldOptions + * @interface IFeatureSupport + * @property {google.protobuf.Edition|null} [editionIntroduced] FeatureSupport editionIntroduced + * @property {google.protobuf.Edition|null} [editionDeprecated] FeatureSupport editionDeprecated + * @property {string|null} [deprecationWarning] FeatureSupport deprecationWarning + * @property {google.protobuf.Edition|null} [editionRemoved] FeatureSupport editionRemoved + */ + + /** + * Constructs a new FeatureSupport. + * @memberof google.protobuf.FieldOptions + * @classdesc Represents a FeatureSupport. + * @implements IFeatureSupport + * @constructor + * @param {google.protobuf.FieldOptions.IFeatureSupport=} [properties] Properties to set + */ + function FeatureSupport(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]]; + } + + /** + * FeatureSupport editionIntroduced. + * @member {google.protobuf.Edition} editionIntroduced + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionIntroduced = 0; + + /** + * FeatureSupport editionDeprecated. + * @member {google.protobuf.Edition} editionDeprecated + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionDeprecated = 0; + + /** + * FeatureSupport deprecationWarning. + * @member {string} deprecationWarning + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.deprecationWarning = ""; + + /** + * FeatureSupport editionRemoved. + * @member {google.protobuf.Edition} editionRemoved + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionRemoved = 0; + + /** + * Creates a new FeatureSupport instance using the specified properties. + * @function create + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport=} [properties] Properties to set + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport instance + */ + FeatureSupport.create = function create(properties) { + return new FeatureSupport(properties); + }; + + /** + * Encodes the specified FeatureSupport message. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport} message FeatureSupport message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSupport.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.editionIntroduced != null && Object.hasOwnProperty.call(message, "editionIntroduced")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.editionIntroduced); + if (message.editionDeprecated != null && Object.hasOwnProperty.call(message, "editionDeprecated")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.editionDeprecated); + if (message.deprecationWarning != null && Object.hasOwnProperty.call(message, "deprecationWarning")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.deprecationWarning); + if (message.editionRemoved != null && Object.hasOwnProperty.call(message, "editionRemoved")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.editionRemoved); + return writer; + }; + + /** + * Encodes the specified FeatureSupport message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport} message FeatureSupport message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSupport.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSupport.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FieldOptions.FeatureSupport(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.editionIntroduced = reader.int32(); + break; + } + case 2: { + message.editionDeprecated = reader.int32(); + break; + } + case 3: { + message.deprecationWarning = reader.string(); + break; + } + case 4: { + message.editionRemoved = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSupport.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FeatureSupport message. + * @function verify + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FeatureSupport.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.editionIntroduced != null && message.hasOwnProperty("editionIntroduced")) + switch (message.editionIntroduced) { + default: + return "editionIntroduced: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + if (message.editionDeprecated != null && message.hasOwnProperty("editionDeprecated")) + switch (message.editionDeprecated) { + default: + return "editionDeprecated: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + if (message.deprecationWarning != null && message.hasOwnProperty("deprecationWarning")) + if (!$util.isString(message.deprecationWarning)) + return "deprecationWarning: string expected"; + if (message.editionRemoved != null && message.hasOwnProperty("editionRemoved")) + switch (message.editionRemoved) { + default: + return "editionRemoved: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + return null; + }; + + /** + * Creates a FeatureSupport message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + */ + FeatureSupport.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FieldOptions.FeatureSupport) + return object; + var message = new $root.google.protobuf.FieldOptions.FeatureSupport(); + switch (object.editionIntroduced) { + default: + if (typeof object.editionIntroduced === "number") { + message.editionIntroduced = object.editionIntroduced; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionIntroduced = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionIntroduced = 900; + break; + case "EDITION_PROTO2": + case 998: + message.editionIntroduced = 998; + break; + case "EDITION_PROTO3": + case 999: + message.editionIntroduced = 999; + break; + case "EDITION_2023": + case 1000: + message.editionIntroduced = 1000; + break; + case "EDITION_2024": + case 1001: + message.editionIntroduced = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.editionIntroduced = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.editionIntroduced = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.editionIntroduced = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.editionIntroduced = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.editionIntroduced = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.editionIntroduced = 2147483647; + break; + } + switch (object.editionDeprecated) { + default: + if (typeof object.editionDeprecated === "number") { + message.editionDeprecated = object.editionDeprecated; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionDeprecated = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionDeprecated = 900; + break; + case "EDITION_PROTO2": + case 998: + message.editionDeprecated = 998; + break; + case "EDITION_PROTO3": + case 999: + message.editionDeprecated = 999; + break; + case "EDITION_2023": + case 1000: + message.editionDeprecated = 1000; + break; + case "EDITION_2024": + case 1001: + message.editionDeprecated = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.editionDeprecated = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.editionDeprecated = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.editionDeprecated = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.editionDeprecated = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.editionDeprecated = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.editionDeprecated = 2147483647; + break; + } + if (object.deprecationWarning != null) + message.deprecationWarning = String(object.deprecationWarning); + switch (object.editionRemoved) { + default: + if (typeof object.editionRemoved === "number") { + message.editionRemoved = object.editionRemoved; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionRemoved = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionRemoved = 900; + break; case "EDITION_PROTO2": case 998: - message.edition = 998; + message.editionRemoved = 998; break; case "EDITION_PROTO3": case 999: - message.edition = 999; + message.editionRemoved = 999; break; case "EDITION_2023": case 1000: - message.edition = 1000; + message.editionRemoved = 1000; break; case "EDITION_2024": case 1001: - message.edition = 1001; + message.editionRemoved = 1001; break; case "EDITION_1_TEST_ONLY": case 1: - message.edition = 1; + message.editionRemoved = 1; break; case "EDITION_2_TEST_ONLY": case 2: - message.edition = 2; + message.editionRemoved = 2; break; case "EDITION_99997_TEST_ONLY": case 99997: - message.edition = 99997; + message.editionRemoved = 99997; break; case "EDITION_99998_TEST_ONLY": case 99998: - message.edition = 99998; + message.editionRemoved = 99998; break; case "EDITION_99999_TEST_ONLY": case 99999: - message.edition = 99999; + message.editionRemoved = 99999; break; case "EDITION_MAX": case 2147483647: - message.edition = 2147483647; + message.editionRemoved = 2147483647; break; } - if (object.value != null) - message.value = String(object.value); return message; }; /** - * Creates a plain object from an EditionDefault message. Also converts values to other types if specified. + * Creates a plain object from a FeatureSupport message. Also converts values to other types if specified. * @function toObject - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @static - * @param {google.protobuf.FieldOptions.EditionDefault} message EditionDefault + * @param {google.protobuf.FieldOptions.FeatureSupport} message FeatureSupport * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - EditionDefault.toObject = function toObject(message, options) { + FeatureSupport.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { - object.value = ""; - object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.editionIntroduced = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.editionDeprecated = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.deprecationWarning = ""; + object.editionRemoved = options.enums === String ? "EDITION_UNKNOWN" : 0; } - if (message.value != null && message.hasOwnProperty("value")) - object.value = message.value; - if (message.edition != null && message.hasOwnProperty("edition")) - object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.editionIntroduced != null && message.hasOwnProperty("editionIntroduced")) + object.editionIntroduced = options.enums === String ? $root.google.protobuf.Edition[message.editionIntroduced] === undefined ? message.editionIntroduced : $root.google.protobuf.Edition[message.editionIntroduced] : message.editionIntroduced; + if (message.editionDeprecated != null && message.hasOwnProperty("editionDeprecated")) + object.editionDeprecated = options.enums === String ? $root.google.protobuf.Edition[message.editionDeprecated] === undefined ? message.editionDeprecated : $root.google.protobuf.Edition[message.editionDeprecated] : message.editionDeprecated; + if (message.deprecationWarning != null && message.hasOwnProperty("deprecationWarning")) + object.deprecationWarning = message.deprecationWarning; + if (message.editionRemoved != null && message.hasOwnProperty("editionRemoved")) + object.editionRemoved = options.enums === String ? $root.google.protobuf.Edition[message.editionRemoved] === undefined ? message.editionRemoved : $root.google.protobuf.Edition[message.editionRemoved] : message.editionRemoved; return object; }; /** - * Converts this EditionDefault to JSON. + * Converts this FeatureSupport to JSON. * @function toJSON - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @instance * @returns {Object.} JSON object */ - EditionDefault.prototype.toJSON = function toJSON() { + FeatureSupport.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for EditionDefault + * Gets the default type url for FeatureSupport * @function getTypeUrl - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - EditionDefault.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + FeatureSupport.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.protobuf.FieldOptions.EditionDefault"; + return typeUrlPrefix + "/google.protobuf.FieldOptions.FeatureSupport"; }; - return EditionDefault; + return FeatureSupport; })(); return FieldOptions; @@ -60911,6 +62180,7 @@ * @property {boolean|null} [deprecated] EnumValueOptions deprecated * @property {google.protobuf.IFeatureSet|null} [features] EnumValueOptions features * @property {boolean|null} [debugRedact] EnumValueOptions debugRedact + * @property {google.protobuf.FieldOptions.IFeatureSupport|null} [featureSupport] EnumValueOptions featureSupport * @property {Array.|null} [uninterpretedOption] EnumValueOptions uninterpretedOption */ @@ -60954,6 +62224,14 @@ */ EnumValueOptions.prototype.debugRedact = false; + /** + * EnumValueOptions featureSupport. + * @member {google.protobuf.FieldOptions.IFeatureSupport|null|undefined} featureSupport + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.featureSupport = null; + /** * EnumValueOptions uninterpretedOption. * @member {Array.} uninterpretedOption @@ -60992,6 +62270,8 @@ $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.debugRedact != null && Object.hasOwnProperty.call(message, "debugRedact")) writer.uint32(/* id 3, wireType 0 =*/24).bool(message.debugRedact); + if (message.featureSupport != null && Object.hasOwnProperty.call(message, "featureSupport")) + $root.google.protobuf.FieldOptions.FeatureSupport.encode(message.featureSupport, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); @@ -61043,6 +62323,10 @@ message.debugRedact = reader.bool(); break; } + case 4: { + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.decode(reader, reader.uint32()); + break; + } case 999: { if (!(message.uninterpretedOption && message.uninterpretedOption.length)) message.uninterpretedOption = []; @@ -61095,6 +62379,11 @@ if (message.debugRedact != null && message.hasOwnProperty("debugRedact")) if (typeof message.debugRedact !== "boolean") return "debugRedact: boolean expected"; + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) { + var error = $root.google.protobuf.FieldOptions.FeatureSupport.verify(message.featureSupport); + if (error) + return "featureSupport." + error; + } if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { if (!Array.isArray(message.uninterpretedOption)) return "uninterpretedOption: array expected"; @@ -61128,6 +62417,11 @@ } if (object.debugRedact != null) message.debugRedact = Boolean(object.debugRedact); + if (object.featureSupport != null) { + if (typeof object.featureSupport !== "object") + throw TypeError(".google.protobuf.EnumValueOptions.featureSupport: object expected"); + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.fromObject(object.featureSupport); + } if (object.uninterpretedOption) { if (!Array.isArray(object.uninterpretedOption)) throw TypeError(".google.protobuf.EnumValueOptions.uninterpretedOption: array expected"); @@ -61160,6 +62454,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -61167,6 +62462,8 @@ object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); if (message.debugRedact != null && message.hasOwnProperty("debugRedact")) object.debugRedact = message.debugRedact; + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) + object.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.toObject(message.featureSupport, options); if (message.uninterpretedOption && message.uninterpretedOption.length) { object.uninterpretedOption = []; for (var j = 0; j < message.uninterpretedOption.length; ++j) @@ -62634,6 +63931,8 @@ * @property {google.protobuf.FeatureSet.Utf8Validation|null} [utf8Validation] FeatureSet utf8Validation * @property {google.protobuf.FeatureSet.MessageEncoding|null} [messageEncoding] FeatureSet messageEncoding * @property {google.protobuf.FeatureSet.JsonFormat|null} [jsonFormat] FeatureSet jsonFormat + * @property {google.protobuf.FeatureSet.EnforceNamingStyle|null} [enforceNamingStyle] FeatureSet enforceNamingStyle + * @property {google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|null} [defaultSymbolVisibility] FeatureSet defaultSymbolVisibility */ /** @@ -62699,6 +63998,22 @@ */ FeatureSet.prototype.jsonFormat = 0; + /** + * FeatureSet enforceNamingStyle. + * @member {google.protobuf.FeatureSet.EnforceNamingStyle} enforceNamingStyle + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.enforceNamingStyle = 0; + + /** + * FeatureSet defaultSymbolVisibility. + * @member {google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility} defaultSymbolVisibility + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.defaultSymbolVisibility = 0; + /** * Creates a new FeatureSet instance using the specified properties. * @function create @@ -62735,6 +64050,10 @@ writer.uint32(/* id 5, wireType 0 =*/40).int32(message.messageEncoding); if (message.jsonFormat != null && Object.hasOwnProperty.call(message, "jsonFormat")) writer.uint32(/* id 6, wireType 0 =*/48).int32(message.jsonFormat); + if (message.enforceNamingStyle != null && Object.hasOwnProperty.call(message, "enforceNamingStyle")) + writer.uint32(/* id 7, wireType 0 =*/56).int32(message.enforceNamingStyle); + if (message.defaultSymbolVisibility != null && Object.hasOwnProperty.call(message, "defaultSymbolVisibility")) + writer.uint32(/* id 8, wireType 0 =*/64).int32(message.defaultSymbolVisibility); return writer; }; @@ -62795,6 +64114,14 @@ message.jsonFormat = reader.int32(); break; } + case 7: { + message.enforceNamingStyle = reader.int32(); + break; + } + case 8: { + message.defaultSymbolVisibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -62885,6 +64212,26 @@ case 2: break; } + if (message.enforceNamingStyle != null && message.hasOwnProperty("enforceNamingStyle")) + switch (message.enforceNamingStyle) { + default: + return "enforceNamingStyle: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.defaultSymbolVisibility != null && message.hasOwnProperty("defaultSymbolVisibility")) + switch (message.defaultSymbolVisibility) { + default: + return "defaultSymbolVisibility: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } return null; }; @@ -63024,6 +64371,54 @@ message.jsonFormat = 2; break; } + switch (object.enforceNamingStyle) { + default: + if (typeof object.enforceNamingStyle === "number") { + message.enforceNamingStyle = object.enforceNamingStyle; + break; + } + break; + case "ENFORCE_NAMING_STYLE_UNKNOWN": + case 0: + message.enforceNamingStyle = 0; + break; + case "STYLE2024": + case 1: + message.enforceNamingStyle = 1; + break; + case "STYLE_LEGACY": + case 2: + message.enforceNamingStyle = 2; + break; + } + switch (object.defaultSymbolVisibility) { + default: + if (typeof object.defaultSymbolVisibility === "number") { + message.defaultSymbolVisibility = object.defaultSymbolVisibility; + break; + } + break; + case "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN": + case 0: + message.defaultSymbolVisibility = 0; + break; + case "EXPORT_ALL": + case 1: + message.defaultSymbolVisibility = 1; + break; + case "EXPORT_TOP_LEVEL": + case 2: + message.defaultSymbolVisibility = 2; + break; + case "LOCAL_ALL": + case 3: + message.defaultSymbolVisibility = 3; + break; + case "STRICT": + case 4: + message.defaultSymbolVisibility = 4; + break; + } return message; }; @@ -63047,6 +64442,8 @@ object.utf8Validation = options.enums === String ? "UTF8_VALIDATION_UNKNOWN" : 0; object.messageEncoding = options.enums === String ? "MESSAGE_ENCODING_UNKNOWN" : 0; object.jsonFormat = options.enums === String ? "JSON_FORMAT_UNKNOWN" : 0; + object.enforceNamingStyle = options.enums === String ? "ENFORCE_NAMING_STYLE_UNKNOWN" : 0; + object.defaultSymbolVisibility = options.enums === String ? "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN" : 0; } if (message.fieldPresence != null && message.hasOwnProperty("fieldPresence")) object.fieldPresence = options.enums === String ? $root.google.protobuf.FeatureSet.FieldPresence[message.fieldPresence] === undefined ? message.fieldPresence : $root.google.protobuf.FeatureSet.FieldPresence[message.fieldPresence] : message.fieldPresence; @@ -63060,6 +64457,10 @@ object.messageEncoding = options.enums === String ? $root.google.protobuf.FeatureSet.MessageEncoding[message.messageEncoding] === undefined ? message.messageEncoding : $root.google.protobuf.FeatureSet.MessageEncoding[message.messageEncoding] : message.messageEncoding; if (message.jsonFormat != null && message.hasOwnProperty("jsonFormat")) object.jsonFormat = options.enums === String ? $root.google.protobuf.FeatureSet.JsonFormat[message.jsonFormat] === undefined ? message.jsonFormat : $root.google.protobuf.FeatureSet.JsonFormat[message.jsonFormat] : message.jsonFormat; + if (message.enforceNamingStyle != null && message.hasOwnProperty("enforceNamingStyle")) + object.enforceNamingStyle = options.enums === String ? $root.google.protobuf.FeatureSet.EnforceNamingStyle[message.enforceNamingStyle] === undefined ? message.enforceNamingStyle : $root.google.protobuf.FeatureSet.EnforceNamingStyle[message.enforceNamingStyle] : message.enforceNamingStyle; + if (message.defaultSymbolVisibility != null && message.hasOwnProperty("defaultSymbolVisibility")) + object.defaultSymbolVisibility = options.enums === String ? $root.google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility[message.defaultSymbolVisibility] === undefined ? message.defaultSymbolVisibility : $root.google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility[message.defaultSymbolVisibility] : message.defaultSymbolVisibility; return object; }; @@ -63187,6 +64588,219 @@ return values; })(); + /** + * EnforceNamingStyle enum. + * @name google.protobuf.FeatureSet.EnforceNamingStyle + * @enum {number} + * @property {number} ENFORCE_NAMING_STYLE_UNKNOWN=0 ENFORCE_NAMING_STYLE_UNKNOWN value + * @property {number} STYLE2024=1 STYLE2024 value + * @property {number} STYLE_LEGACY=2 STYLE_LEGACY value + */ + FeatureSet.EnforceNamingStyle = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "ENFORCE_NAMING_STYLE_UNKNOWN"] = 0; + values[valuesById[1] = "STYLE2024"] = 1; + values[valuesById[2] = "STYLE_LEGACY"] = 2; + return values; + })(); + + FeatureSet.VisibilityFeature = (function() { + + /** + * Properties of a VisibilityFeature. + * @memberof google.protobuf.FeatureSet + * @interface IVisibilityFeature + */ + + /** + * Constructs a new VisibilityFeature. + * @memberof google.protobuf.FeatureSet + * @classdesc Represents a VisibilityFeature. + * @implements IVisibilityFeature + * @constructor + * @param {google.protobuf.FeatureSet.IVisibilityFeature=} [properties] Properties to set + */ + function VisibilityFeature(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]]; + } + + /** + * Creates a new VisibilityFeature instance using the specified properties. + * @function create + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature=} [properties] Properties to set + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature instance + */ + VisibilityFeature.create = function create(properties) { + return new VisibilityFeature(properties); + }; + + /** + * Encodes the specified VisibilityFeature message. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature} message VisibilityFeature message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VisibilityFeature.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified VisibilityFeature message, length delimited. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature} message VisibilityFeature message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VisibilityFeature.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VisibilityFeature.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FeatureSet.VisibilityFeature(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VisibilityFeature.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a VisibilityFeature message. + * @function verify + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + VisibilityFeature.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a VisibilityFeature message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + */ + VisibilityFeature.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FeatureSet.VisibilityFeature) + return object; + return new $root.google.protobuf.FeatureSet.VisibilityFeature(); + }; + + /** + * Creates a plain object from a VisibilityFeature message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.VisibilityFeature} message VisibilityFeature + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + VisibilityFeature.toObject = function toObject() { + return {}; + }; + + /** + * Converts this VisibilityFeature to JSON. + * @function toJSON + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @instance + * @returns {Object.} JSON object + */ + VisibilityFeature.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for VisibilityFeature + * @function getTypeUrl + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + VisibilityFeature.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FeatureSet.VisibilityFeature"; + }; + + /** + * DefaultSymbolVisibility enum. + * @name google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility + * @enum {number} + * @property {number} DEFAULT_SYMBOL_VISIBILITY_UNKNOWN=0 DEFAULT_SYMBOL_VISIBILITY_UNKNOWN value + * @property {number} EXPORT_ALL=1 EXPORT_ALL value + * @property {number} EXPORT_TOP_LEVEL=2 EXPORT_TOP_LEVEL value + * @property {number} LOCAL_ALL=3 LOCAL_ALL value + * @property {number} STRICT=4 STRICT value + */ + VisibilityFeature.DefaultSymbolVisibility = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN"] = 0; + values[valuesById[1] = "EXPORT_ALL"] = 1; + values[valuesById[2] = "EXPORT_TOP_LEVEL"] = 2; + values[valuesById[3] = "LOCAL_ALL"] = 3; + values[valuesById[4] = "STRICT"] = 4; + return values; + })(); + + return VisibilityFeature; + })(); + return FeatureSet; })(); @@ -63371,6 +64985,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -63388,6 +65003,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -63436,6 +65052,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -63488,6 +65108,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -63596,7 +65220,8 @@ * @memberof google.protobuf.FeatureSetDefaults * @interface IFeatureSetEditionDefault * @property {google.protobuf.Edition|null} [edition] FeatureSetEditionDefault edition - * @property {google.protobuf.IFeatureSet|null} [features] FeatureSetEditionDefault features + * @property {google.protobuf.IFeatureSet|null} [overridableFeatures] FeatureSetEditionDefault overridableFeatures + * @property {google.protobuf.IFeatureSet|null} [fixedFeatures] FeatureSetEditionDefault fixedFeatures */ /** @@ -63623,12 +65248,20 @@ FeatureSetEditionDefault.prototype.edition = 0; /** - * FeatureSetEditionDefault features. - * @member {google.protobuf.IFeatureSet|null|undefined} features + * FeatureSetEditionDefault overridableFeatures. + * @member {google.protobuf.IFeatureSet|null|undefined} overridableFeatures + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @instance + */ + FeatureSetEditionDefault.prototype.overridableFeatures = null; + + /** + * FeatureSetEditionDefault fixedFeatures. + * @member {google.protobuf.IFeatureSet|null|undefined} fixedFeatures * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault * @instance */ - FeatureSetEditionDefault.prototype.features = null; + FeatureSetEditionDefault.prototype.fixedFeatures = null; /** * Creates a new FeatureSetEditionDefault instance using the specified properties. @@ -63654,10 +65287,12 @@ FeatureSetEditionDefault.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.features != null && Object.hasOwnProperty.call(message, "features")) - $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) writer.uint32(/* id 3, wireType 0 =*/24).int32(message.edition); + if (message.overridableFeatures != null && Object.hasOwnProperty.call(message, "overridableFeatures")) + $root.google.protobuf.FeatureSet.encode(message.overridableFeatures, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.fixedFeatures != null && Object.hasOwnProperty.call(message, "fixedFeatures")) + $root.google.protobuf.FeatureSet.encode(message.fixedFeatures, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); return writer; }; @@ -63698,8 +65333,12 @@ message.edition = reader.int32(); break; } - case 2: { - message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + case 4: { + message.overridableFeatures = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + break; + } + case 5: { + message.fixedFeatures = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); break; } default: @@ -63742,6 +65381,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -63754,10 +65394,15 @@ case 2147483647: break; } - if (message.features != null && message.hasOwnProperty("features")) { - var error = $root.google.protobuf.FeatureSet.verify(message.features); + if (message.overridableFeatures != null && message.hasOwnProperty("overridableFeatures")) { + var error = $root.google.protobuf.FeatureSet.verify(message.overridableFeatures); + if (error) + return "overridableFeatures." + error; + } + if (message.fixedFeatures != null && message.hasOwnProperty("fixedFeatures")) { + var error = $root.google.protobuf.FeatureSet.verify(message.fixedFeatures); if (error) - return "features." + error; + return "fixedFeatures." + error; } return null; }; @@ -63785,6 +65430,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -63826,10 +65475,15 @@ message.edition = 2147483647; break; } - if (object.features != null) { - if (typeof object.features !== "object") - throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.features: object expected"); - message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); + if (object.overridableFeatures != null) { + if (typeof object.overridableFeatures !== "object") + throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.overridableFeatures: object expected"); + message.overridableFeatures = $root.google.protobuf.FeatureSet.fromObject(object.overridableFeatures); + } + if (object.fixedFeatures != null) { + if (typeof object.fixedFeatures !== "object") + throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.fixedFeatures: object expected"); + message.fixedFeatures = $root.google.protobuf.FeatureSet.fromObject(object.fixedFeatures); } return message; }; @@ -63848,13 +65502,16 @@ options = {}; var object = {}; if (options.defaults) { - object.features = null; object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.overridableFeatures = null; + object.fixedFeatures = null; } - if (message.features != null && message.hasOwnProperty("features")) - object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); if (message.edition != null && message.hasOwnProperty("edition")) object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.overridableFeatures != null && message.hasOwnProperty("overridableFeatures")) + object.overridableFeatures = $root.google.protobuf.FeatureSet.toObject(message.overridableFeatures, options); + if (message.fixedFeatures != null && message.hasOwnProperty("fixedFeatures")) + object.fixedFeatures = $root.google.protobuf.FeatureSet.toObject(message.fixedFeatures, options); return object; }; @@ -65069,6 +66726,22 @@ return GeneratedCodeInfo; })(); + /** + * SymbolVisibility enum. + * @name google.protobuf.SymbolVisibility + * @enum {number} + * @property {number} VISIBILITY_UNSET=0 VISIBILITY_UNSET value + * @property {number} VISIBILITY_LOCAL=1 VISIBILITY_LOCAL value + * @property {number} VISIBILITY_EXPORT=2 VISIBILITY_EXPORT value + */ + protobuf.SymbolVisibility = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "VISIBILITY_UNSET"] = 0; + values[valuesById[1] = "VISIBILITY_LOCAL"] = 1; + values[valuesById[2] = "VISIBILITY_EXPORT"] = 2; + return values; + })(); + protobuf.Timestamp = (function() { /** diff --git a/packages/google-cloud-notebooks/protos/protos.json b/packages/google-cloud-notebooks/protos/protos.json index 215943293362..fa27d17ed5c4 100644 --- a/packages/google-cloud-notebooks/protos/protos.json +++ b/packages/google-cloud-notebooks/protos/protos.json @@ -6267,8 +6267,7 @@ "java_multiple_files": true, "java_outer_classname": "LaunchStageProto", "java_package": "com.google.api", - "objc_class_prefix": "GAPI", - "cc_enable_arenas": true + "objc_class_prefix": "GAPI" }, "nested": { "fieldBehavior": { @@ -6491,6 +6490,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -6631,6 +6634,28 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "experimentalFeatures": { + "type": "ExperimentalFeatures", + "id": 2 + } + }, + "nested": { + "ExperimentalFeatures": { + "fields": { + "restAsyncIoEnabled": { + "type": "bool", + "id": 1 + }, + "protobufPythonicTypesEnabled": { + "type": "bool", + "id": 2 + }, + "unversionedPackageDisabled": { + "type": "bool", + "id": 3 + } + } } } }, @@ -6688,6 +6713,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -6749,6 +6779,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -6782,12 +6825,19 @@ "type": "FileDescriptorProto", "id": 1 } - } + }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ] }, "Edition": { "edition": "proto2", "values": { "EDITION_UNKNOWN": 0, + "EDITION_LEGACY": 900, "EDITION_PROTO2": 998, "EDITION_PROTO3": 999, "EDITION_2023": 1000, @@ -6826,6 +6876,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -6914,6 +6969,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -7139,6 +7198,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -7189,7 +7252,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -7353,6 +7423,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -7488,7 +7559,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -7516,6 +7588,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -7585,6 +7661,26 @@ "id": 2 } } + }, + "FeatureSupport": { + "fields": { + "editionIntroduced": { + "type": "Edition", + "id": 1 + }, + "editionDeprecated": { + "type": "Edition", + "id": 2 + }, + "deprecationWarning": { + "type": "string", + "id": 3 + }, + "editionRemoved": { + "type": "Edition", + "id": 4 + } + } } } }, @@ -7673,6 +7769,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -7815,6 +7915,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -7825,6 +7926,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -7835,6 +7937,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -7845,6 +7948,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -7855,7 +7959,8 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", - "edition_defaults.edition": "EDITION_PROTO2", + "feature_support.edition_introduced": "EDITION_2023", + "edition_defaults.edition": "EDITION_LEGACY", "edition_defaults.value": "LENGTH_PREFIXED" } }, @@ -7865,27 +7970,38 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "ALLOW" } + }, + "enforceNamingStyle": { + "type": "EnforceNamingStyle", + "id": 7, + "options": { + "retention": "RETENTION_SOURCE", + "targets": "TARGET_TYPE_METHOD", + "feature_support.edition_introduced": "EDITION_2024", + "edition_defaults.edition": "EDITION_2024", + "edition_defaults.value": "STYLE2024" + } + }, + "defaultSymbolVisibility": { + "type": "VisibilityFeature.DefaultSymbolVisibility", + "id": 8, + "options": { + "retention": "RETENTION_SOURCE", + "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2024", + "edition_defaults.edition": "EDITION_2024", + "edition_defaults.value": "EXPORT_TOP_LEVEL" + } } }, "extensions": [ [ 1000, - 1000 - ], - [ - 1001, - 1001 - ], - [ - 1002, - 1002 - ], - [ - 9990, - 9990 + 9994 ], [ 9995, @@ -7930,7 +8046,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -7945,6 +8067,33 @@ "ALLOW": 1, "LEGACY_BEST_EFFORT": 2 } + }, + "EnforceNamingStyle": { + "values": { + "ENFORCE_NAMING_STYLE_UNKNOWN": 0, + "STYLE2024": 1, + "STYLE_LEGACY": 2 + } + }, + "VisibilityFeature": { + "fields": {}, + "reserved": [ + [ + 1, + 536870911 + ] + ], + "nested": { + "DefaultSymbolVisibility": { + "values": { + "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN": 0, + "EXPORT_ALL": 1, + "EXPORT_TOP_LEVEL": 2, + "LOCAL_ALL": 3, + "STRICT": 4 + } + } + } } } }, @@ -7972,11 +8121,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -7989,6 +8153,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -8074,6 +8244,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Timestamp": { "fields": { "seconds": { @@ -8132,6 +8310,7 @@ "java_multiple_files": true, "java_outer_classname": "OperationsProto", "java_package": "com.google.longrunning", + "objc_class_prefix": "GLRUN", "php_namespace": "Google\\LongRunning" }, "nested": { diff --git a/packages/google-cloud-notebooks/samples/generated/v1/snippet_metadata_google.cloud.notebooks.v1.json b/packages/google-cloud-notebooks/samples/generated/v1/snippet_metadata_google.cloud.notebooks.v1.json index a7a3b34ceeb8..48fb0a043d94 100644 --- a/packages/google-cloud-notebooks/samples/generated/v1/snippet_metadata_google.cloud.notebooks.v1.json +++ b/packages/google-cloud-notebooks/samples/generated/v1/snippet_metadata_google.cloud.notebooks.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-notebooks", - "version": "4.2.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-notebooks/samples/generated/v1beta1/snippet_metadata_google.cloud.notebooks.v1beta1.json b/packages/google-cloud-notebooks/samples/generated/v1beta1/snippet_metadata_google.cloud.notebooks.v1beta1.json index a74a9faa4303..e4feeb81fd35 100644 --- a/packages/google-cloud-notebooks/samples/generated/v1beta1/snippet_metadata_google.cloud.notebooks.v1beta1.json +++ b/packages/google-cloud-notebooks/samples/generated/v1beta1/snippet_metadata_google.cloud.notebooks.v1beta1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-notebooks", - "version": "4.2.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-notebooks/samples/generated/v2/snippet_metadata_google.cloud.notebooks.v2.json b/packages/google-cloud-notebooks/samples/generated/v2/snippet_metadata_google.cloud.notebooks.v2.json index 9adce341a132..51586370b43e 100644 --- a/packages/google-cloud-notebooks/samples/generated/v2/snippet_metadata_google.cloud.notebooks.v2.json +++ b/packages/google-cloud-notebooks/samples/generated/v2/snippet_metadata_google.cloud.notebooks.v2.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-notebooks", - "version": "4.2.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-notebooks/src/v1/index.ts b/packages/google-cloud-notebooks/src/v1/index.ts index 23e1032a7702..c0397c7e7582 100644 --- a/packages/google-cloud-notebooks/src/v1/index.ts +++ b/packages/google-cloud-notebooks/src/v1/index.ts @@ -16,5 +16,5 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {ManagedNotebookServiceClient} from './managed_notebook_service_client'; -export {NotebookServiceClient} from './notebook_service_client'; +export { ManagedNotebookServiceClient } from './managed_notebook_service_client'; +export { NotebookServiceClient } from './notebook_service_client'; diff --git a/packages/google-cloud-notebooks/src/v1/managed_notebook_service_client.ts b/packages/google-cloud-notebooks/src/v1/managed_notebook_service_client.ts index 17e8f34a141d..fdefca6e62a2 100644 --- a/packages/google-cloud-notebooks/src/v1/managed_notebook_service_client.ts +++ b/packages/google-cloud-notebooks/src/v1/managed_notebook_service_client.ts @@ -18,11 +18,24 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -44,7 +57,7 @@ export class ManagedNotebookServiceClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('notebooks'); @@ -57,12 +70,12 @@ export class ManagedNotebookServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - managedNotebookServiceStub?: Promise<{[name: string]: Function}>; + managedNotebookServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of ManagedNotebookServiceClient. @@ -103,21 +116,43 @@ export class ManagedNotebookServiceClient { * const client = new ManagedNotebookServiceClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof ManagedNotebookServiceClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + const staticMembers = this + .constructor as typeof ManagedNotebookServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'notebooks.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -142,7 +177,7 @@ export class ManagedNotebookServiceClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -155,18 +190,14 @@ export class ManagedNotebookServiceClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -188,25 +219,25 @@ export class ManagedNotebookServiceClient { // Create useful helper objects for these. this.pathTemplates = { environmentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/environments/{environment}' + 'projects/{project}/environments/{environment}', ), executionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/location/{location}/executions/{execution}' + 'projects/{project}/location/{location}/executions/{execution}', ), instancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/instances/{instance}' + 'projects/{project}/instances/{instance}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), runtimePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/runtimes/{runtime}' + 'projects/{project}/locations/{location}/runtimes/{runtime}', ), schedulePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/location/{location}/schedules/{schedule}' + 'projects/{project}/location/{location}/schedules/{schedule}', ), }; @@ -214,8 +245,11 @@ export class ManagedNotebookServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listRuntimes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'runtimes') + listRuntimes: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'runtimes', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -224,104 +258,193 @@ export class ManagedNotebookServiceClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1/{resource=projects/*/locations/*/instances/*}:getIamPolicy',additional_bindings: [{get: '/v1/{resource=projects/*/locations/*/runtimes/*}:getIamPolicy',}], - },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1/{resource=projects/*/locations/*/instances/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/runtimes/*}:setIamPolicy',body: '*',}], - },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1/{resource=projects/*/locations/*/instances/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/runtimes/*}:testIamPermissions',body: '*',}], - },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1/{resource=projects/*/locations/*/instances/*}:getIamPolicy', + additional_bindings: [ + { + get: '/v1/{resource=projects/*/locations/*/runtimes/*}:getIamPolicy', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1/{resource=projects/*/locations/*/instances/*}:setIamPolicy', + body: '*', + additional_bindings: [ + { + post: '/v1/{resource=projects/*/locations/*/runtimes/*}:setIamPolicy', + body: '*', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1/{resource=projects/*/locations/*/instances/*}:testIamPermissions', + body: '*', + additional_bindings: [ + { + post: '/v1/{resource=projects/*/locations/*/runtimes/*}:testIamPermissions', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createRuntimeResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Runtime') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.Runtime', + ) as gax.protobuf.Type; const createRuntimeMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateRuntimeResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Runtime') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.Runtime', + ) as gax.protobuf.Type; const updateRuntimeMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteRuntimeResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteRuntimeMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; const startRuntimeResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Runtime') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.Runtime', + ) as gax.protobuf.Type; const startRuntimeMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; const stopRuntimeResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Runtime') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.Runtime', + ) as gax.protobuf.Type; const stopRuntimeMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; const switchRuntimeResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Runtime') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.Runtime', + ) as gax.protobuf.Type; const switchRuntimeMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; const resetRuntimeResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Runtime') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.Runtime', + ) as gax.protobuf.Type; const resetRuntimeMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; const upgradeRuntimeResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Runtime') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.Runtime', + ) as gax.protobuf.Type; const upgradeRuntimeMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; const reportRuntimeEventResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Runtime') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.Runtime', + ) as gax.protobuf.Type; const reportRuntimeEventMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; const diagnoseRuntimeResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Runtime') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.Runtime', + ) as gax.protobuf.Type; const diagnoseRuntimeMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createRuntime: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createRuntimeResponse.decode.bind(createRuntimeResponse), - createRuntimeMetadata.decode.bind(createRuntimeMetadata)), + createRuntimeMetadata.decode.bind(createRuntimeMetadata), + ), updateRuntime: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateRuntimeResponse.decode.bind(updateRuntimeResponse), - updateRuntimeMetadata.decode.bind(updateRuntimeMetadata)), + updateRuntimeMetadata.decode.bind(updateRuntimeMetadata), + ), deleteRuntime: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteRuntimeResponse.decode.bind(deleteRuntimeResponse), - deleteRuntimeMetadata.decode.bind(deleteRuntimeMetadata)), + deleteRuntimeMetadata.decode.bind(deleteRuntimeMetadata), + ), startRuntime: new this._gaxModule.LongrunningDescriptor( this.operationsClient, startRuntimeResponse.decode.bind(startRuntimeResponse), - startRuntimeMetadata.decode.bind(startRuntimeMetadata)), + startRuntimeMetadata.decode.bind(startRuntimeMetadata), + ), stopRuntime: new this._gaxModule.LongrunningDescriptor( this.operationsClient, stopRuntimeResponse.decode.bind(stopRuntimeResponse), - stopRuntimeMetadata.decode.bind(stopRuntimeMetadata)), + stopRuntimeMetadata.decode.bind(stopRuntimeMetadata), + ), switchRuntime: new this._gaxModule.LongrunningDescriptor( this.operationsClient, switchRuntimeResponse.decode.bind(switchRuntimeResponse), - switchRuntimeMetadata.decode.bind(switchRuntimeMetadata)), + switchRuntimeMetadata.decode.bind(switchRuntimeMetadata), + ), resetRuntime: new this._gaxModule.LongrunningDescriptor( this.operationsClient, resetRuntimeResponse.decode.bind(resetRuntimeResponse), - resetRuntimeMetadata.decode.bind(resetRuntimeMetadata)), + resetRuntimeMetadata.decode.bind(resetRuntimeMetadata), + ), upgradeRuntime: new this._gaxModule.LongrunningDescriptor( this.operationsClient, upgradeRuntimeResponse.decode.bind(upgradeRuntimeResponse), - upgradeRuntimeMetadata.decode.bind(upgradeRuntimeMetadata)), + upgradeRuntimeMetadata.decode.bind(upgradeRuntimeMetadata), + ), reportRuntimeEvent: new this._gaxModule.LongrunningDescriptor( this.operationsClient, reportRuntimeEventResponse.decode.bind(reportRuntimeEventResponse), - reportRuntimeEventMetadata.decode.bind(reportRuntimeEventMetadata)), + reportRuntimeEventMetadata.decode.bind(reportRuntimeEventMetadata), + ), diagnoseRuntime: new this._gaxModule.LongrunningDescriptor( this.operationsClient, diagnoseRuntimeResponse.decode.bind(diagnoseRuntimeResponse), - diagnoseRuntimeMetadata.decode.bind(diagnoseRuntimeMetadata)) + diagnoseRuntimeMetadata.decode.bind(diagnoseRuntimeMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.notebooks.v1.ManagedNotebookService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.notebooks.v1.ManagedNotebookService', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -352,28 +475,48 @@ export class ManagedNotebookServiceClient { // Put together the "service stub" for // google.cloud.notebooks.v1.ManagedNotebookService. this.managedNotebookServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.notebooks.v1.ManagedNotebookService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.notebooks.v1.ManagedNotebookService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.notebooks.v1.ManagedNotebookService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.notebooks.v1 + .ManagedNotebookService, + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const managedNotebookServiceStubMethods = - ['listRuntimes', 'getRuntime', 'createRuntime', 'updateRuntime', 'deleteRuntime', 'startRuntime', 'stopRuntime', 'switchRuntime', 'resetRuntime', 'upgradeRuntime', 'reportRuntimeEvent', 'refreshRuntimeTokenInternal', 'diagnoseRuntime']; + const managedNotebookServiceStubMethods = [ + 'listRuntimes', + 'getRuntime', + 'createRuntime', + 'updateRuntime', + 'deleteRuntime', + 'startRuntime', + 'stopRuntime', + 'switchRuntime', + 'resetRuntime', + 'upgradeRuntime', + 'reportRuntimeEvent', + 'refreshRuntimeTokenInternal', + 'diagnoseRuntime', + ]; for (const methodName of managedNotebookServiceStubMethods) { const callPromise = this.managedNotebookServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -383,7 +526,7 @@ export class ManagedNotebookServiceClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -398,8 +541,14 @@ export class ManagedNotebookServiceClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'notebooks.googleapis.com'; } @@ -410,8 +559,14 @@ export class ManagedNotebookServiceClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'notebooks.googleapis.com'; } @@ -442,9 +597,7 @@ export class ManagedNotebookServiceClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -453,8 +606,9 @@ export class ManagedNotebookServiceClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -465,1427 +619,2149 @@ export class ManagedNotebookServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets details of a single Runtime. The location must be a regional endpoint - * rather than zonal. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - * @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 {@link protos.google.cloud.notebooks.v1.Runtime|Runtime}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/managed_notebook_service.get_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_GetRuntime_async - */ + /** + * Gets details of a single Runtime. The location must be a regional endpoint + * rather than zonal. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + * @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 {@link protos.google.cloud.notebooks.v1.Runtime|Runtime}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/managed_notebook_service.get_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_GetRuntime_async + */ getRuntime( - request?: protos.google.cloud.notebooks.v1.IGetRuntimeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1.IRuntime, - protos.google.cloud.notebooks.v1.IGetRuntimeRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IGetRuntimeRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IGetRuntimeRequest | undefined, + {} | undefined, + ] + >; getRuntime( - request: protos.google.cloud.notebooks.v1.IGetRuntimeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.notebooks.v1.IRuntime, - protos.google.cloud.notebooks.v1.IGetRuntimeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IGetRuntimeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IGetRuntimeRequest | null | undefined, + {} | null | undefined + >, + ): void; getRuntime( - request: protos.google.cloud.notebooks.v1.IGetRuntimeRequest, - callback: Callback< - protos.google.cloud.notebooks.v1.IRuntime, - protos.google.cloud.notebooks.v1.IGetRuntimeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IGetRuntimeRequest, + callback: Callback< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IGetRuntimeRequest | null | undefined, + {} | null | undefined + >, + ): void; getRuntime( - request?: protos.google.cloud.notebooks.v1.IGetRuntimeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.notebooks.v1.IRuntime, - protos.google.cloud.notebooks.v1.IGetRuntimeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.notebooks.v1.IGetRuntimeRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.notebooks.v1.IRuntime, - protos.google.cloud.notebooks.v1.IGetRuntimeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.notebooks.v1.IRuntime, - protos.google.cloud.notebooks.v1.IGetRuntimeRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.notebooks.v1.IGetRuntimeRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IGetRuntimeRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IGetRuntimeRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getRuntime request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.notebooks.v1.IRuntime, - protos.google.cloud.notebooks.v1.IGetRuntimeRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.notebooks.v1.IRuntime, + | protos.google.cloud.notebooks.v1.IGetRuntimeRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getRuntime response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getRuntime(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.notebooks.v1.IRuntime, - protos.google.cloud.notebooks.v1.IGetRuntimeRequest|undefined, - {}|undefined - ]) => { - this._log.info('getRuntime response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getRuntime(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IGetRuntimeRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getRuntime response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets an access token for the consumer service account that the customer - * attached to the runtime. Only accessible from the tenant instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - * @param {string} request.vmId - * Required. The VM hardware token for authenticating the VM. - * https://cloud.google.com/compute/docs/instances/verifying-instance-identity - * @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 {@link protos.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalResponse|RefreshRuntimeTokenInternalResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/managed_notebook_service.refresh_runtime_token_internal.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_RefreshRuntimeTokenInternal_async - */ + /** + * Gets an access token for the consumer service account that the customer + * attached to the runtime. Only accessible from the tenant instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + * @param {string} request.vmId + * Required. The VM hardware token for authenticating the VM. + * https://cloud.google.com/compute/docs/instances/verifying-instance-identity + * @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 {@link protos.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalResponse|RefreshRuntimeTokenInternalResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/managed_notebook_service.refresh_runtime_token_internal.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_RefreshRuntimeTokenInternal_async + */ refreshRuntimeTokenInternal( - request?: protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalResponse, - protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalResponse, + ( + | protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest + | undefined + ), + {} | undefined, + ] + >; refreshRuntimeTokenInternal( - request: protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalResponse, - protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalResponse, + | protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest + | null + | undefined, + {} | null | undefined + >, + ): void; refreshRuntimeTokenInternal( - request: protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest, - callback: Callback< - protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalResponse, - protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest, + callback: Callback< + protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalResponse, + | protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest + | null + | undefined, + {} | null | undefined + >, + ): void; refreshRuntimeTokenInternal( - request?: protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalResponse, - protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalResponse, - protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalResponse, - protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalResponse, + | protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalResponse, + ( + | protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('refreshRuntimeTokenInternal request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalResponse, - protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalResponse, + | protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('refreshRuntimeTokenInternal response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.refreshRuntimeTokenInternal(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalResponse, - protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest|undefined, - {}|undefined - ]) => { - this._log.info('refreshRuntimeTokenInternal response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .refreshRuntimeTokenInternal(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalResponse, + ( + | protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('refreshRuntimeTokenInternal response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a new Runtime in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {string} request.runtimeId - * Required. User-defined unique ID of this Runtime. - * @param {google.cloud.notebooks.v1.Runtime} request.runtime - * Required. The Runtime to be created. - * @param {string} request.requestId - * Idempotent request UUID. - * @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/managed_notebook_service.create_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_CreateRuntime_async - */ + /** + * Creates a new Runtime in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {string} request.runtimeId + * Required. User-defined unique ID of this Runtime. + * @param {google.cloud.notebooks.v1.Runtime} request.runtime + * Required. The Runtime to be created. + * @param {string} request.requestId + * Idempotent request UUID. + * @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/managed_notebook_service.create_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_CreateRuntime_async + */ createRuntime( - request?: protos.google.cloud.notebooks.v1.ICreateRuntimeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.ICreateRuntimeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createRuntime( - request: protos.google.cloud.notebooks.v1.ICreateRuntimeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.ICreateRuntimeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createRuntime( - request: protos.google.cloud.notebooks.v1.ICreateRuntimeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.ICreateRuntimeRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createRuntime( - request?: protos.google.cloud.notebooks.v1.ICreateRuntimeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.ICreateRuntimeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createRuntime response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createRuntime request %j', request); - return this.innerApiCalls.createRuntime(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createRuntime response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createRuntime(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createRuntime response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createRuntime()`. - * @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/managed_notebook_service.create_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_CreateRuntime_async - */ - async checkCreateRuntimeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createRuntime()`. + * @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/managed_notebook_service.create_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_CreateRuntime_async + */ + async checkCreateRuntimeProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1.Runtime, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('createRuntime long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createRuntime, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createRuntime, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1.Runtime, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } -/** - * Update Notebook Runtime configuration. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.notebooks.v1.Runtime} request.runtime - * Required. The Runtime to be updated. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Specifies the path, relative to `Runtime`, of - * the field to update. For example, to change the software configuration - * kernels, the `update_mask` parameter would be - * specified as `software_config.kernels`, - * and the `PATCH` request body would specify the new value, as follows: - * - * { - * "software_config":{ - * "kernels": [{ - * 'repository': - * 'gcr.io/deeplearning-platform-release/pytorch-gpu', 'tag': - * 'latest' }], - * } - * } - * - * - * Currently, only the following fields can be updated: - * - `software_config.kernels` - * - `software_config.post_startup_script` - * - `software_config.custom_gpu_driver_path` - * - `software_config.idle_shutdown` - * - `software_config.idle_shutdown_timeout` - * - `software_config.disable_terminal` - * @param {string} request.requestId - * Idempotent request UUID. - * @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/managed_notebook_service.update_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_UpdateRuntime_async - */ + /** + * Update Notebook Runtime configuration. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.notebooks.v1.Runtime} request.runtime + * Required. The Runtime to be updated. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Specifies the path, relative to `Runtime`, of + * the field to update. For example, to change the software configuration + * kernels, the `update_mask` parameter would be + * specified as `software_config.kernels`, + * and the `PATCH` request body would specify the new value, as follows: + * + * { + * "software_config":{ + * "kernels": [{ + * 'repository': + * 'gcr.io/deeplearning-platform-release/pytorch-gpu', 'tag': + * 'latest' }], + * } + * } + * + * + * Currently, only the following fields can be updated: + * - `software_config.kernels` + * - `software_config.post_startup_script` + * - `software_config.custom_gpu_driver_path` + * - `software_config.idle_shutdown` + * - `software_config.idle_shutdown_timeout` + * - `software_config.disable_terminal` + * @param {string} request.requestId + * Idempotent request UUID. + * @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/managed_notebook_service.update_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_UpdateRuntime_async + */ updateRuntime( - request?: protos.google.cloud.notebooks.v1.IUpdateRuntimeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IUpdateRuntimeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateRuntime( - request: protos.google.cloud.notebooks.v1.IUpdateRuntimeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IUpdateRuntimeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateRuntime( - request: protos.google.cloud.notebooks.v1.IUpdateRuntimeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IUpdateRuntimeRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateRuntime( - request?: protos.google.cloud.notebooks.v1.IUpdateRuntimeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.IUpdateRuntimeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'runtime.name': request.runtime!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'runtime.name': request.runtime!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateRuntime response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateRuntime request %j', request); - return this.innerApiCalls.updateRuntime(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateRuntime response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateRuntime(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateRuntime response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateRuntime()`. - * @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/managed_notebook_service.update_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_UpdateRuntime_async - */ - async checkUpdateRuntimeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateRuntime()`. + * @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/managed_notebook_service.update_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_UpdateRuntime_async + */ + async checkUpdateRuntimeProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1.Runtime, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('updateRuntime long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateRuntime, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateRuntime, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1.Runtime, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } -/** - * Deletes a single Runtime. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - * @param {string} request.requestId - * Idempotent request UUID. - * @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/managed_notebook_service.delete_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_DeleteRuntime_async - */ + /** + * Deletes a single Runtime. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + * @param {string} request.requestId + * Idempotent request UUID. + * @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/managed_notebook_service.delete_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_DeleteRuntime_async + */ deleteRuntime( - request?: protos.google.cloud.notebooks.v1.IDeleteRuntimeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IDeleteRuntimeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteRuntime( - request: protos.google.cloud.notebooks.v1.IDeleteRuntimeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IDeleteRuntimeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteRuntime( - request: protos.google.cloud.notebooks.v1.IDeleteRuntimeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IDeleteRuntimeRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteRuntime( - request?: protos.google.cloud.notebooks.v1.IDeleteRuntimeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.IDeleteRuntimeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteRuntime response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteRuntime request %j', request); - return this.innerApiCalls.deleteRuntime(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteRuntime response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteRuntime(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteRuntime response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteRuntime()`. - * @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/managed_notebook_service.delete_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_DeleteRuntime_async - */ - async checkDeleteRuntimeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteRuntime()`. + * @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/managed_notebook_service.delete_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_DeleteRuntime_async + */ + async checkDeleteRuntimeProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('deleteRuntime long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteRuntime, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteRuntime, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } -/** - * Starts a Managed Notebook Runtime. - * Perform "Start" on GPU instances; "Resume" on CPU instances - * See: - * https://cloud.google.com/compute/docs/instances/stop-start-instance - * https://cloud.google.com/compute/docs/instances/suspend-resume-instance - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - * @param {string} request.requestId - * Idempotent request UUID. - * @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/managed_notebook_service.start_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_StartRuntime_async - */ + /** + * Starts a Managed Notebook Runtime. + * Perform "Start" on GPU instances; "Resume" on CPU instances + * See: + * https://cloud.google.com/compute/docs/instances/stop-start-instance + * https://cloud.google.com/compute/docs/instances/suspend-resume-instance + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + * @param {string} request.requestId + * Idempotent request UUID. + * @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/managed_notebook_service.start_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_StartRuntime_async + */ startRuntime( - request?: protos.google.cloud.notebooks.v1.IStartRuntimeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IStartRuntimeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; startRuntime( - request: protos.google.cloud.notebooks.v1.IStartRuntimeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IStartRuntimeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; startRuntime( - request: protos.google.cloud.notebooks.v1.IStartRuntimeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IStartRuntimeRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; startRuntime( - request?: protos.google.cloud.notebooks.v1.IStartRuntimeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.IStartRuntimeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('startRuntime response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('startRuntime request %j', request); - return this.innerApiCalls.startRuntime(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('startRuntime response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .startRuntime(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('startRuntime response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `startRuntime()`. - * @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/managed_notebook_service.start_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_StartRuntime_async - */ - async checkStartRuntimeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `startRuntime()`. + * @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/managed_notebook_service.start_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_StartRuntime_async + */ + async checkStartRuntimeProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1.Runtime, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('startRuntime long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.startRuntime, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.startRuntime, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1.Runtime, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } -/** - * Stops a Managed Notebook Runtime. - * Perform "Stop" on GPU instances; "Suspend" on CPU instances - * See: - * https://cloud.google.com/compute/docs/instances/stop-start-instance - * https://cloud.google.com/compute/docs/instances/suspend-resume-instance - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - * @param {string} request.requestId - * Idempotent request UUID. - * @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/managed_notebook_service.stop_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_StopRuntime_async - */ + /** + * Stops a Managed Notebook Runtime. + * Perform "Stop" on GPU instances; "Suspend" on CPU instances + * See: + * https://cloud.google.com/compute/docs/instances/stop-start-instance + * https://cloud.google.com/compute/docs/instances/suspend-resume-instance + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + * @param {string} request.requestId + * Idempotent request UUID. + * @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/managed_notebook_service.stop_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_StopRuntime_async + */ stopRuntime( - request?: protos.google.cloud.notebooks.v1.IStopRuntimeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IStopRuntimeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; stopRuntime( - request: protos.google.cloud.notebooks.v1.IStopRuntimeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IStopRuntimeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; stopRuntime( - request: protos.google.cloud.notebooks.v1.IStopRuntimeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IStopRuntimeRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; stopRuntime( - request?: protos.google.cloud.notebooks.v1.IStopRuntimeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.IStopRuntimeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('stopRuntime response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('stopRuntime request %j', request); - return this.innerApiCalls.stopRuntime(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('stopRuntime response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .stopRuntime(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('stopRuntime response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `stopRuntime()`. - * @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/managed_notebook_service.stop_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_StopRuntime_async - */ - async checkStopRuntimeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `stopRuntime()`. + * @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/managed_notebook_service.stop_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_StopRuntime_async + */ + async checkStopRuntimeProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1.Runtime, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('stopRuntime long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.stopRuntime, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.stopRuntime, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1.Runtime, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } -/** - * Switch a Managed Notebook Runtime. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - * @param {string} request.machineType - * machine type. - * @param {google.cloud.notebooks.v1.RuntimeAcceleratorConfig} request.acceleratorConfig - * accelerator config. - * @param {string} request.requestId - * Idempotent request UUID. - * @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/managed_notebook_service.switch_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_SwitchRuntime_async - */ + /** + * Switch a Managed Notebook Runtime. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + * @param {string} request.machineType + * machine type. + * @param {google.cloud.notebooks.v1.RuntimeAcceleratorConfig} request.acceleratorConfig + * accelerator config. + * @param {string} request.requestId + * Idempotent request UUID. + * @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/managed_notebook_service.switch_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_SwitchRuntime_async + */ switchRuntime( - request?: protos.google.cloud.notebooks.v1.ISwitchRuntimeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.ISwitchRuntimeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; switchRuntime( - request: protos.google.cloud.notebooks.v1.ISwitchRuntimeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.ISwitchRuntimeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; switchRuntime( - request: protos.google.cloud.notebooks.v1.ISwitchRuntimeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.ISwitchRuntimeRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; switchRuntime( - request?: protos.google.cloud.notebooks.v1.ISwitchRuntimeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.ISwitchRuntimeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('switchRuntime response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('switchRuntime request %j', request); - return this.innerApiCalls.switchRuntime(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('switchRuntime response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .switchRuntime(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('switchRuntime response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `switchRuntime()`. - * @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/managed_notebook_service.switch_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_SwitchRuntime_async - */ - async checkSwitchRuntimeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `switchRuntime()`. + * @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/managed_notebook_service.switch_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_SwitchRuntime_async + */ + async checkSwitchRuntimeProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1.Runtime, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('switchRuntime long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.switchRuntime, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.switchRuntime, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1.Runtime, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } -/** - * Resets a Managed Notebook Runtime. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - * @param {string} request.requestId - * Idempotent request UUID. - * @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/managed_notebook_service.reset_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_ResetRuntime_async - */ + /** + * Resets a Managed Notebook Runtime. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + * @param {string} request.requestId + * Idempotent request UUID. + * @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/managed_notebook_service.reset_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_ResetRuntime_async + */ resetRuntime( - request?: protos.google.cloud.notebooks.v1.IResetRuntimeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IResetRuntimeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; resetRuntime( - request: protos.google.cloud.notebooks.v1.IResetRuntimeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IResetRuntimeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; resetRuntime( - request: protos.google.cloud.notebooks.v1.IResetRuntimeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IResetRuntimeRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; resetRuntime( - request?: protos.google.cloud.notebooks.v1.IResetRuntimeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.IResetRuntimeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('resetRuntime response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('resetRuntime request %j', request); - return this.innerApiCalls.resetRuntime(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('resetRuntime response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .resetRuntime(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('resetRuntime response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `resetRuntime()`. - * @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/managed_notebook_service.reset_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_ResetRuntime_async - */ - async checkResetRuntimeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `resetRuntime()`. + * @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/managed_notebook_service.reset_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_ResetRuntime_async + */ + async checkResetRuntimeProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1.Runtime, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('resetRuntime long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.resetRuntime, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.resetRuntime, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1.Runtime, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } -/** - * Upgrades a Managed Notebook Runtime to the latest version. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - * @param {string} request.requestId - * Idempotent request UUID. - * @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/managed_notebook_service.upgrade_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_UpgradeRuntime_async - */ + /** + * Upgrades a Managed Notebook Runtime to the latest version. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + * @param {string} request.requestId + * Idempotent request UUID. + * @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/managed_notebook_service.upgrade_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_UpgradeRuntime_async + */ upgradeRuntime( - request?: protos.google.cloud.notebooks.v1.IUpgradeRuntimeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IUpgradeRuntimeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; upgradeRuntime( - request: protos.google.cloud.notebooks.v1.IUpgradeRuntimeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IUpgradeRuntimeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; upgradeRuntime( - request: protos.google.cloud.notebooks.v1.IUpgradeRuntimeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IUpgradeRuntimeRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; upgradeRuntime( - request?: protos.google.cloud.notebooks.v1.IUpgradeRuntimeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.IUpgradeRuntimeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('upgradeRuntime response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('upgradeRuntime request %j', request); - return this.innerApiCalls.upgradeRuntime(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('upgradeRuntime response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .upgradeRuntime(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('upgradeRuntime response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `upgradeRuntime()`. - * @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/managed_notebook_service.upgrade_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_UpgradeRuntime_async - */ - async checkUpgradeRuntimeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `upgradeRuntime()`. + * @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/managed_notebook_service.upgrade_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_UpgradeRuntime_async + */ + async checkUpgradeRuntimeProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1.Runtime, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('upgradeRuntime long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.upgradeRuntime, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.upgradeRuntime, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1.Runtime, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } -/** - * Report and process a runtime event. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` - * @param {string} request.vmId - * Required. The VM hardware token for authenticating the VM. - * https://cloud.google.com/compute/docs/instances/verifying-instance-identity - * @param {google.cloud.notebooks.v1.Event} request.event - * Required. The Event to be reported. - * @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/managed_notebook_service.report_runtime_event.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_ReportRuntimeEvent_async - */ + /** + * Report and process a runtime event. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}` + * @param {string} request.vmId + * Required. The VM hardware token for authenticating the VM. + * https://cloud.google.com/compute/docs/instances/verifying-instance-identity + * @param {google.cloud.notebooks.v1.Event} request.event + * Required. The Event to be reported. + * @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/managed_notebook_service.report_runtime_event.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_ReportRuntimeEvent_async + */ reportRuntimeEvent( - request?: protos.google.cloud.notebooks.v1.IReportRuntimeEventRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IReportRuntimeEventRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; reportRuntimeEvent( - request: protos.google.cloud.notebooks.v1.IReportRuntimeEventRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IReportRuntimeEventRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; reportRuntimeEvent( - request: protos.google.cloud.notebooks.v1.IReportRuntimeEventRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IReportRuntimeEventRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; reportRuntimeEvent( - request?: protos.google.cloud.notebooks.v1.IReportRuntimeEventRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.IReportRuntimeEventRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('reportRuntimeEvent response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('reportRuntimeEvent request %j', request); - return this.innerApiCalls.reportRuntimeEvent(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('reportRuntimeEvent response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .reportRuntimeEvent(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('reportRuntimeEvent response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `reportRuntimeEvent()`. - * @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/managed_notebook_service.report_runtime_event.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_ReportRuntimeEvent_async - */ - async checkReportRuntimeEventProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `reportRuntimeEvent()`. + * @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/managed_notebook_service.report_runtime_event.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_ReportRuntimeEvent_async + */ + async checkReportRuntimeEventProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1.Runtime, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('reportRuntimeEvent long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.reportRuntimeEvent, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.reportRuntimeEvent, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1.Runtime, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } -/** - * Creates a Diagnostic File and runs Diagnostic Tool given a Runtime. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/runtimes/{runtimes_id}` - * @param {google.cloud.notebooks.v1.DiagnosticConfig} request.diagnosticConfig - * Required. Defines flags that are used to run the diagnostic tool - * @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/managed_notebook_service.diagnose_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_DiagnoseRuntime_async - */ + /** + * Creates a Diagnostic File and runs Diagnostic Tool given a Runtime. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/runtimes/{runtimes_id}` + * @param {google.cloud.notebooks.v1.DiagnosticConfig} request.diagnosticConfig + * Required. Defines flags that are used to run the diagnostic tool + * @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/managed_notebook_service.diagnose_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_DiagnoseRuntime_async + */ diagnoseRuntime( - request?: protos.google.cloud.notebooks.v1.IDiagnoseRuntimeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IDiagnoseRuntimeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; diagnoseRuntime( - request: protos.google.cloud.notebooks.v1.IDiagnoseRuntimeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IDiagnoseRuntimeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; diagnoseRuntime( - request: protos.google.cloud.notebooks.v1.IDiagnoseRuntimeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IDiagnoseRuntimeRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; diagnoseRuntime( - request?: protos.google.cloud.notebooks.v1.IDiagnoseRuntimeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.IDiagnoseRuntimeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('diagnoseRuntime response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('diagnoseRuntime request %j', request); - return this.innerApiCalls.diagnoseRuntime(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('diagnoseRuntime response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .diagnoseRuntime(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('diagnoseRuntime response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `diagnoseRuntime()`. - * @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/managed_notebook_service.diagnose_runtime.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_DiagnoseRuntime_async - */ - async checkDiagnoseRuntimeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `diagnoseRuntime()`. + * @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/managed_notebook_service.diagnose_runtime.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_DiagnoseRuntime_async + */ + async checkDiagnoseRuntimeProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1.Runtime, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('diagnoseRuntime long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.diagnoseRuntime, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists Runtimes in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing - * from the last result. - * @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 Array of {@link protos.google.cloud.notebooks.v1.Runtime|Runtime}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listRuntimesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.diagnoseRuntime, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1.Runtime, + protos.google.cloud.notebooks.v1.OperationMetadata + >; + } + /** + * Lists Runtimes in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing + * from the last result. + * @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 Array of {@link protos.google.cloud.notebooks.v1.Runtime|Runtime}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listRuntimesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listRuntimes( - request?: protos.google.cloud.notebooks.v1.IListRuntimesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1.IRuntime[], - protos.google.cloud.notebooks.v1.IListRuntimesRequest|null, - protos.google.cloud.notebooks.v1.IListRuntimesResponse - ]>; + request?: protos.google.cloud.notebooks.v1.IListRuntimesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.notebooks.v1.IRuntime[], + protos.google.cloud.notebooks.v1.IListRuntimesRequest | null, + protos.google.cloud.notebooks.v1.IListRuntimesResponse, + ] + >; listRuntimes( - request: protos.google.cloud.notebooks.v1.IListRuntimesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.notebooks.v1.IListRuntimesRequest, - protos.google.cloud.notebooks.v1.IListRuntimesResponse|null|undefined, - protos.google.cloud.notebooks.v1.IRuntime>): void; + request: protos.google.cloud.notebooks.v1.IListRuntimesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.notebooks.v1.IListRuntimesRequest, + protos.google.cloud.notebooks.v1.IListRuntimesResponse | null | undefined, + protos.google.cloud.notebooks.v1.IRuntime + >, + ): void; listRuntimes( - request: protos.google.cloud.notebooks.v1.IListRuntimesRequest, - callback: PaginationCallback< - protos.google.cloud.notebooks.v1.IListRuntimesRequest, - protos.google.cloud.notebooks.v1.IListRuntimesResponse|null|undefined, - protos.google.cloud.notebooks.v1.IRuntime>): void; + request: protos.google.cloud.notebooks.v1.IListRuntimesRequest, + callback: PaginationCallback< + protos.google.cloud.notebooks.v1.IListRuntimesRequest, + protos.google.cloud.notebooks.v1.IListRuntimesResponse | null | undefined, + protos.google.cloud.notebooks.v1.IRuntime + >, + ): void; listRuntimes( - request?: protos.google.cloud.notebooks.v1.IListRuntimesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.notebooks.v1.IListRuntimesRequest, - protos.google.cloud.notebooks.v1.IListRuntimesResponse|null|undefined, - protos.google.cloud.notebooks.v1.IRuntime>, - callback?: PaginationCallback< + request?: protos.google.cloud.notebooks.v1.IListRuntimesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.notebooks.v1.IListRuntimesRequest, - protos.google.cloud.notebooks.v1.IListRuntimesResponse|null|undefined, - protos.google.cloud.notebooks.v1.IRuntime>): - Promise<[ - protos.google.cloud.notebooks.v1.IRuntime[], - protos.google.cloud.notebooks.v1.IListRuntimesRequest|null, - protos.google.cloud.notebooks.v1.IListRuntimesResponse - ]>|void { + | protos.google.cloud.notebooks.v1.IListRuntimesResponse + | null + | undefined, + protos.google.cloud.notebooks.v1.IRuntime + >, + callback?: PaginationCallback< + protos.google.cloud.notebooks.v1.IListRuntimesRequest, + protos.google.cloud.notebooks.v1.IListRuntimesResponse | null | undefined, + protos.google.cloud.notebooks.v1.IRuntime + >, + ): Promise< + [ + protos.google.cloud.notebooks.v1.IRuntime[], + protos.google.cloud.notebooks.v1.IListRuntimesRequest | null, + protos.google.cloud.notebooks.v1.IListRuntimesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.notebooks.v1.IListRuntimesRequest, - protos.google.cloud.notebooks.v1.IListRuntimesResponse|null|undefined, - protos.google.cloud.notebooks.v1.IRuntime>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.notebooks.v1.IListRuntimesRequest, + | protos.google.cloud.notebooks.v1.IListRuntimesResponse + | null + | undefined, + protos.google.cloud.notebooks.v1.IRuntime + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listRuntimes values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1894,137 +2770,141 @@ export class ManagedNotebookServiceClient { this._log.info('listRuntimes request %j', request); return this.innerApiCalls .listRuntimes(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.notebooks.v1.IRuntime[], - protos.google.cloud.notebooks.v1.IListRuntimesRequest|null, - protos.google.cloud.notebooks.v1.IListRuntimesResponse - ]) => { - this._log.info('listRuntimes values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.notebooks.v1.IRuntime[], + protos.google.cloud.notebooks.v1.IListRuntimesRequest | null, + protos.google.cloud.notebooks.v1.IListRuntimesResponse, + ]) => { + this._log.info('listRuntimes values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listRuntimes`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing - * from the last result. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.notebooks.v1.Runtime|Runtime} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listRuntimesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listRuntimes`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing + * from the last result. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.notebooks.v1.Runtime|Runtime} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listRuntimesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listRuntimesStream( - request?: protos.google.cloud.notebooks.v1.IListRuntimesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.notebooks.v1.IListRuntimesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listRuntimes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listRuntimes stream %j', request); return this.descriptors.page.listRuntimes.createStream( this.innerApiCalls.listRuntimes as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listRuntimes`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing - * from the last result. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.notebooks.v1.Runtime|Runtime}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/managed_notebook_service.list_runtimes.js - * region_tag:notebooks_v1_generated_ManagedNotebookService_ListRuntimes_async - */ + /** + * Equivalent to `listRuntimes`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing + * from the last result. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.notebooks.v1.Runtime|Runtime}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/managed_notebook_service.list_runtimes.js + * region_tag:notebooks_v1_generated_ManagedNotebookService_ListRuntimes_async + */ listRuntimesAsync( - request?: protos.google.cloud.notebooks.v1.IListRuntimesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.notebooks.v1.IListRuntimesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listRuntimes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listRuntimes iterate %j', request); return this.descriptors.page.listRuntimes.asyncIterate( this.innerApiCalls['listRuntimes'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -2038,40 +2918,40 @@ export class ManagedNotebookServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -2085,41 +2965,41 @@ export class ManagedNotebookServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -2133,12 +3013,12 @@ export class ManagedNotebookServiceClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -2173,12 +3053,11 @@ export class ManagedNotebookServiceClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -2211,12 +3090,12 @@ export class ManagedNotebookServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -2259,22 +3138,22 @@ export class ManagedNotebookServiceClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -2309,15 +3188,15 @@ export class ManagedNotebookServiceClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - 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 ?? '', - }); + 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 ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -2351,7 +3230,7 @@ export class ManagedNotebookServiceClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -2364,25 +3243,24 @@ export class ManagedNotebookServiceClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -2421,22 +3299,22 @@ export class ManagedNotebookServiceClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -2451,7 +3329,7 @@ export class ManagedNotebookServiceClient { * @param {string} environment * @returns {string} Resource name string. */ - environmentPath(project:string,environment:string) { + environmentPath(project: string, environment: string) { return this.pathTemplates.environmentPathTemplate.render({ project: project, environment: environment, @@ -2466,7 +3344,8 @@ export class ManagedNotebookServiceClient { * @returns {string} A string representing the project. */ matchProjectFromEnvironmentName(environmentName: string) { - return this.pathTemplates.environmentPathTemplate.match(environmentName).project; + return this.pathTemplates.environmentPathTemplate.match(environmentName) + .project; } /** @@ -2477,7 +3356,8 @@ export class ManagedNotebookServiceClient { * @returns {string} A string representing the environment. */ matchEnvironmentFromEnvironmentName(environmentName: string) { - return this.pathTemplates.environmentPathTemplate.match(environmentName).environment; + return this.pathTemplates.environmentPathTemplate.match(environmentName) + .environment; } /** @@ -2488,7 +3368,7 @@ export class ManagedNotebookServiceClient { * @param {string} execution * @returns {string} Resource name string. */ - executionPath(project:string,location:string,execution:string) { + executionPath(project: string, location: string, execution: string) { return this.pathTemplates.executionPathTemplate.render({ project: project, location: location, @@ -2504,7 +3384,8 @@ export class ManagedNotebookServiceClient { * @returns {string} A string representing the project. */ matchProjectFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).project; + return this.pathTemplates.executionPathTemplate.match(executionName) + .project; } /** @@ -2515,7 +3396,8 @@ export class ManagedNotebookServiceClient { * @returns {string} A string representing the location. */ matchLocationFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).location; + return this.pathTemplates.executionPathTemplate.match(executionName) + .location; } /** @@ -2526,7 +3408,8 @@ export class ManagedNotebookServiceClient { * @returns {string} A string representing the execution. */ matchExecutionFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).execution; + return this.pathTemplates.executionPathTemplate.match(executionName) + .execution; } /** @@ -2536,7 +3419,7 @@ export class ManagedNotebookServiceClient { * @param {string} instance * @returns {string} Resource name string. */ - instancePath(project:string,instance:string) { + instancePath(project: string, instance: string) { return this.pathTemplates.instancePathTemplate.render({ project: project, instance: instance, @@ -2572,7 +3455,7 @@ export class ManagedNotebookServiceClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -2607,7 +3490,7 @@ export class ManagedNotebookServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -2632,7 +3515,7 @@ export class ManagedNotebookServiceClient { * @param {string} runtime * @returns {string} Resource name string. */ - runtimePath(project:string,location:string,runtime:string) { + runtimePath(project: string, location: string, runtime: string) { return this.pathTemplates.runtimePathTemplate.render({ project: project, location: location, @@ -2681,7 +3564,7 @@ export class ManagedNotebookServiceClient { * @param {string} schedule * @returns {string} Resource name string. */ - schedulePath(project:string,location:string,schedule:string) { + schedulePath(project: string, location: string, schedule: string) { return this.pathTemplates.schedulePathTemplate.render({ project: project, location: location, @@ -2730,15 +3613,19 @@ export class ManagedNotebookServiceClient { */ close(): Promise { if (this.managedNotebookServiceStub && !this._terminated) { - return this.managedNotebookServiceStub.then(stub => { + return this.managedNotebookServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-notebooks/src/v1/notebook_service_client.ts b/packages/google-cloud-notebooks/src/v1/notebook_service_client.ts index c59b90527c7d..7d429fff5d9f 100644 --- a/packages/google-cloud-notebooks/src/v1/notebook_service_client.ts +++ b/packages/google-cloud-notebooks/src/v1/notebook_service_client.ts @@ -18,11 +18,24 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -44,7 +57,7 @@ export class NotebookServiceClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('notebooks'); @@ -57,12 +70,12 @@ export class NotebookServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - notebookServiceStub?: Promise<{[name: string]: Function}>; + notebookServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of NotebookServiceClient. @@ -103,21 +116,42 @@ export class NotebookServiceClient { * const client = new NotebookServiceClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof NotebookServiceClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'notebooks.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -142,7 +176,7 @@ export class NotebookServiceClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -155,18 +189,14 @@ export class NotebookServiceClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -188,19 +218,19 @@ export class NotebookServiceClient { // Create useful helper objects for these. this.pathTemplates = { environmentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/environments/{environment}' + 'projects/{project}/environments/{environment}', ), executionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/location/{location}/executions/{execution}' + 'projects/{project}/location/{location}/executions/{execution}', ), instancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/instances/{instance}' + 'projects/{project}/instances/{instance}', ), runtimePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/runtimes/{runtime}' + 'projects/{project}/locations/{location}/runtimes/{runtime}', ), schedulePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/location/{location}/schedules/{schedule}' + 'projects/{project}/location/{location}/schedules/{schedule}', ), }; @@ -208,14 +238,26 @@ export class NotebookServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listInstances: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'instances'), - listEnvironments: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'environments'), - listSchedules: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'schedules'), - listExecutions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'executions') + listInstances: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'instances', + ), + listEnvironments: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'environments', + ), + listSchedules: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'schedules', + ), + listExecutions: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'executions', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -224,208 +266,352 @@ export class NotebookServiceClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1/{resource=projects/*/locations/*/instances/*}:getIamPolicy',additional_bindings: [{get: '/v1/{resource=projects/*/locations/*/runtimes/*}:getIamPolicy',}], - },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1/{resource=projects/*/locations/*/instances/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/runtimes/*}:setIamPolicy',body: '*',}], - },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1/{resource=projects/*/locations/*/instances/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/runtimes/*}:testIamPermissions',body: '*',}], - },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1/{resource=projects/*/locations/*/instances/*}:getIamPolicy', + additional_bindings: [ + { + get: '/v1/{resource=projects/*/locations/*/runtimes/*}:getIamPolicy', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1/{resource=projects/*/locations/*/instances/*}:setIamPolicy', + body: '*', + additional_bindings: [ + { + post: '/v1/{resource=projects/*/locations/*/runtimes/*}:setIamPolicy', + body: '*', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1/{resource=projects/*/locations/*/instances/*}:testIamPermissions', + body: '*', + additional_bindings: [ + { + post: '/v1/{resource=projects/*/locations/*/runtimes/*}:testIamPermissions', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.Instance', + ) as gax.protobuf.Type; const createInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; const registerInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.Instance', + ) as gax.protobuf.Type; const registerInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; const setInstanceAcceleratorResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.Instance', + ) as gax.protobuf.Type; const setInstanceAcceleratorMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; const setInstanceMachineTypeResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.Instance', + ) as gax.protobuf.Type; const setInstanceMachineTypeMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateInstanceConfigResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.Instance', + ) as gax.protobuf.Type; const updateInstanceConfigMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateShieldedInstanceConfigResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.Instance', + ) as gax.protobuf.Type; const updateShieldedInstanceConfigMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; const setInstanceLabelsResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.Instance', + ) as gax.protobuf.Type; const setInstanceLabelsMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteInstanceResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; const startInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.Instance', + ) as gax.protobuf.Type; const startInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; const stopInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.Instance', + ) as gax.protobuf.Type; const stopInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; const resetInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.Instance', + ) as gax.protobuf.Type; const resetInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; const reportInstanceInfoResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.Instance', + ) as gax.protobuf.Type; const reportInstanceInfoMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; const upgradeInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.Instance', + ) as gax.protobuf.Type; const upgradeInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; const rollbackInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.Instance', + ) as gax.protobuf.Type; const rollbackInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; const diagnoseInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.Instance', + ) as gax.protobuf.Type; const diagnoseInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; const upgradeInstanceInternalResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.Instance', + ) as gax.protobuf.Type; const upgradeInstanceInternalMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; const createEnvironmentResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Environment') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.Environment', + ) as gax.protobuf.Type; const createEnvironmentMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteEnvironmentResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteEnvironmentMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteScheduleResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteScheduleMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; const createScheduleResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Schedule') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.Schedule', + ) as gax.protobuf.Type; const createScheduleMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; const triggerScheduleResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Schedule') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.Schedule', + ) as gax.protobuf.Type; const triggerScheduleMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteExecutionResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteExecutionMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; const createExecutionResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.Execution') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.Execution', + ) as gax.protobuf.Type; const createExecutionMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createInstanceResponse.decode.bind(createInstanceResponse), - createInstanceMetadata.decode.bind(createInstanceMetadata)), + createInstanceMetadata.decode.bind(createInstanceMetadata), + ), registerInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, registerInstanceResponse.decode.bind(registerInstanceResponse), - registerInstanceMetadata.decode.bind(registerInstanceMetadata)), + registerInstanceMetadata.decode.bind(registerInstanceMetadata), + ), setInstanceAccelerator: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - setInstanceAcceleratorResponse.decode.bind(setInstanceAcceleratorResponse), - setInstanceAcceleratorMetadata.decode.bind(setInstanceAcceleratorMetadata)), + setInstanceAcceleratorResponse.decode.bind( + setInstanceAcceleratorResponse, + ), + setInstanceAcceleratorMetadata.decode.bind( + setInstanceAcceleratorMetadata, + ), + ), setInstanceMachineType: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - setInstanceMachineTypeResponse.decode.bind(setInstanceMachineTypeResponse), - setInstanceMachineTypeMetadata.decode.bind(setInstanceMachineTypeMetadata)), + setInstanceMachineTypeResponse.decode.bind( + setInstanceMachineTypeResponse, + ), + setInstanceMachineTypeMetadata.decode.bind( + setInstanceMachineTypeMetadata, + ), + ), updateInstanceConfig: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateInstanceConfigResponse.decode.bind(updateInstanceConfigResponse), - updateInstanceConfigMetadata.decode.bind(updateInstanceConfigMetadata)), + updateInstanceConfigMetadata.decode.bind(updateInstanceConfigMetadata), + ), updateShieldedInstanceConfig: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - updateShieldedInstanceConfigResponse.decode.bind(updateShieldedInstanceConfigResponse), - updateShieldedInstanceConfigMetadata.decode.bind(updateShieldedInstanceConfigMetadata)), + updateShieldedInstanceConfigResponse.decode.bind( + updateShieldedInstanceConfigResponse, + ), + updateShieldedInstanceConfigMetadata.decode.bind( + updateShieldedInstanceConfigMetadata, + ), + ), setInstanceLabels: new this._gaxModule.LongrunningDescriptor( this.operationsClient, setInstanceLabelsResponse.decode.bind(setInstanceLabelsResponse), - setInstanceLabelsMetadata.decode.bind(setInstanceLabelsMetadata)), + setInstanceLabelsMetadata.decode.bind(setInstanceLabelsMetadata), + ), deleteInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteInstanceResponse.decode.bind(deleteInstanceResponse), - deleteInstanceMetadata.decode.bind(deleteInstanceMetadata)), + deleteInstanceMetadata.decode.bind(deleteInstanceMetadata), + ), startInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, startInstanceResponse.decode.bind(startInstanceResponse), - startInstanceMetadata.decode.bind(startInstanceMetadata)), + startInstanceMetadata.decode.bind(startInstanceMetadata), + ), stopInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, stopInstanceResponse.decode.bind(stopInstanceResponse), - stopInstanceMetadata.decode.bind(stopInstanceMetadata)), + stopInstanceMetadata.decode.bind(stopInstanceMetadata), + ), resetInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, resetInstanceResponse.decode.bind(resetInstanceResponse), - resetInstanceMetadata.decode.bind(resetInstanceMetadata)), + resetInstanceMetadata.decode.bind(resetInstanceMetadata), + ), reportInstanceInfo: new this._gaxModule.LongrunningDescriptor( this.operationsClient, reportInstanceInfoResponse.decode.bind(reportInstanceInfoResponse), - reportInstanceInfoMetadata.decode.bind(reportInstanceInfoMetadata)), + reportInstanceInfoMetadata.decode.bind(reportInstanceInfoMetadata), + ), upgradeInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, upgradeInstanceResponse.decode.bind(upgradeInstanceResponse), - upgradeInstanceMetadata.decode.bind(upgradeInstanceMetadata)), + upgradeInstanceMetadata.decode.bind(upgradeInstanceMetadata), + ), rollbackInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, rollbackInstanceResponse.decode.bind(rollbackInstanceResponse), - rollbackInstanceMetadata.decode.bind(rollbackInstanceMetadata)), + rollbackInstanceMetadata.decode.bind(rollbackInstanceMetadata), + ), diagnoseInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, diagnoseInstanceResponse.decode.bind(diagnoseInstanceResponse), - diagnoseInstanceMetadata.decode.bind(diagnoseInstanceMetadata)), + diagnoseInstanceMetadata.decode.bind(diagnoseInstanceMetadata), + ), upgradeInstanceInternal: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - upgradeInstanceInternalResponse.decode.bind(upgradeInstanceInternalResponse), - upgradeInstanceInternalMetadata.decode.bind(upgradeInstanceInternalMetadata)), + upgradeInstanceInternalResponse.decode.bind( + upgradeInstanceInternalResponse, + ), + upgradeInstanceInternalMetadata.decode.bind( + upgradeInstanceInternalMetadata, + ), + ), createEnvironment: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createEnvironmentResponse.decode.bind(createEnvironmentResponse), - createEnvironmentMetadata.decode.bind(createEnvironmentMetadata)), + createEnvironmentMetadata.decode.bind(createEnvironmentMetadata), + ), deleteEnvironment: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteEnvironmentResponse.decode.bind(deleteEnvironmentResponse), - deleteEnvironmentMetadata.decode.bind(deleteEnvironmentMetadata)), + deleteEnvironmentMetadata.decode.bind(deleteEnvironmentMetadata), + ), deleteSchedule: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteScheduleResponse.decode.bind(deleteScheduleResponse), - deleteScheduleMetadata.decode.bind(deleteScheduleMetadata)), + deleteScheduleMetadata.decode.bind(deleteScheduleMetadata), + ), createSchedule: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createScheduleResponse.decode.bind(createScheduleResponse), - createScheduleMetadata.decode.bind(createScheduleMetadata)), + createScheduleMetadata.decode.bind(createScheduleMetadata), + ), triggerSchedule: new this._gaxModule.LongrunningDescriptor( this.operationsClient, triggerScheduleResponse.decode.bind(triggerScheduleResponse), - triggerScheduleMetadata.decode.bind(triggerScheduleMetadata)), + triggerScheduleMetadata.decode.bind(triggerScheduleMetadata), + ), deleteExecution: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteExecutionResponse.decode.bind(deleteExecutionResponse), - deleteExecutionMetadata.decode.bind(deleteExecutionMetadata)), + deleteExecutionMetadata.decode.bind(deleteExecutionMetadata), + ), createExecution: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createExecutionResponse.decode.bind(createExecutionResponse), - createExecutionMetadata.decode.bind(createExecutionMetadata)) + createExecutionMetadata.decode.bind(createExecutionMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.notebooks.v1.NotebookService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.notebooks.v1.NotebookService', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -456,28 +642,68 @@ export class NotebookServiceClient { // Put together the "service stub" for // google.cloud.notebooks.v1.NotebookService. this.notebookServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.notebooks.v1.NotebookService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.notebooks.v1.NotebookService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.notebooks.v1.NotebookService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const notebookServiceStubMethods = - ['listInstances', 'getInstance', 'createInstance', 'registerInstance', 'setInstanceAccelerator', 'setInstanceMachineType', 'updateInstanceConfig', 'updateShieldedInstanceConfig', 'setInstanceLabels', 'updateInstanceMetadataItems', 'deleteInstance', 'startInstance', 'stopInstance', 'resetInstance', 'reportInstanceInfo', 'isInstanceUpgradeable', 'getInstanceHealth', 'upgradeInstance', 'rollbackInstance', 'diagnoseInstance', 'upgradeInstanceInternal', 'listEnvironments', 'getEnvironment', 'createEnvironment', 'deleteEnvironment', 'listSchedules', 'getSchedule', 'deleteSchedule', 'createSchedule', 'triggerSchedule', 'listExecutions', 'getExecution', 'deleteExecution', 'createExecution']; + const notebookServiceStubMethods = [ + 'listInstances', + 'getInstance', + 'createInstance', + 'registerInstance', + 'setInstanceAccelerator', + 'setInstanceMachineType', + 'updateInstanceConfig', + 'updateShieldedInstanceConfig', + 'setInstanceLabels', + 'updateInstanceMetadataItems', + 'deleteInstance', + 'startInstance', + 'stopInstance', + 'resetInstance', + 'reportInstanceInfo', + 'isInstanceUpgradeable', + 'getInstanceHealth', + 'upgradeInstance', + 'rollbackInstance', + 'diagnoseInstance', + 'upgradeInstanceInternal', + 'listEnvironments', + 'getEnvironment', + 'createEnvironment', + 'deleteEnvironment', + 'listSchedules', + 'getSchedule', + 'deleteSchedule', + 'createSchedule', + 'triggerSchedule', + 'listExecutions', + 'getExecution', + 'deleteExecution', + 'createExecution', + ]; for (const methodName of notebookServiceStubMethods) { const callPromise = this.notebookServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -487,7 +713,7 @@ export class NotebookServiceClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -502,8 +728,14 @@ export class NotebookServiceClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'notebooks.googleapis.com'; } @@ -514,8 +746,14 @@ export class NotebookServiceClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'notebooks.googleapis.com'; } @@ -546,9 +784,7 @@ export class NotebookServiceClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -557,8 +793,9 @@ export class NotebookServiceClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -569,3311 +806,5051 @@ export class NotebookServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets details of a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @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 {@link protos.google.cloud.notebooks.v1.Instance|Instance}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.get_instance.js - * region_tag:notebooks_v1_generated_NotebookService_GetInstance_async - */ + /** + * Gets details of a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @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 {@link protos.google.cloud.notebooks.v1.Instance|Instance}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.get_instance.js + * region_tag:notebooks_v1_generated_NotebookService_GetInstance_async + */ getInstance( - request?: protos.google.cloud.notebooks.v1.IGetInstanceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1.IInstance, - protos.google.cloud.notebooks.v1.IGetInstanceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IGetInstanceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IGetInstanceRequest | undefined, + {} | undefined, + ] + >; getInstance( - request: protos.google.cloud.notebooks.v1.IGetInstanceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.notebooks.v1.IInstance, - protos.google.cloud.notebooks.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IGetInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IGetInstanceRequest | null | undefined, + {} | null | undefined + >, + ): void; getInstance( - request: protos.google.cloud.notebooks.v1.IGetInstanceRequest, - callback: Callback< - protos.google.cloud.notebooks.v1.IInstance, - protos.google.cloud.notebooks.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IGetInstanceRequest, + callback: Callback< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IGetInstanceRequest | null | undefined, + {} | null | undefined + >, + ): void; getInstance( - request?: protos.google.cloud.notebooks.v1.IGetInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.notebooks.v1.IInstance, - protos.google.cloud.notebooks.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.notebooks.v1.IGetInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.notebooks.v1.IInstance, - protos.google.cloud.notebooks.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.notebooks.v1.IInstance, - protos.google.cloud.notebooks.v1.IGetInstanceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.notebooks.v1.IGetInstanceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IGetInstanceRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IGetInstanceRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getInstance request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.notebooks.v1.IInstance, - protos.google.cloud.notebooks.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.notebooks.v1.IInstance, + | protos.google.cloud.notebooks.v1.IGetInstanceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getInstance response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getInstance(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.notebooks.v1.IInstance, - protos.google.cloud.notebooks.v1.IGetInstanceRequest|undefined, - {}|undefined - ]) => { - this._log.info('getInstance response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getInstance(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IGetInstanceRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getInstance response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Add/update metadata items for an instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {number[]} request.items - * Metadata items to add/update for the instance. - * @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 {@link protos.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsResponse|UpdateInstanceMetadataItemsResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.update_instance_metadata_items.js - * region_tag:notebooks_v1_generated_NotebookService_UpdateInstanceMetadataItems_async - */ + /** + * Add/update metadata items for an instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {number[]} request.items + * Metadata items to add/update for the instance. + * @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 {@link protos.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsResponse|UpdateInstanceMetadataItemsResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.update_instance_metadata_items.js + * region_tag:notebooks_v1_generated_NotebookService_UpdateInstanceMetadataItems_async + */ updateInstanceMetadataItems( - request?: protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsResponse, - protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsResponse, + ( + | protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest + | undefined + ), + {} | undefined, + ] + >; updateInstanceMetadataItems( - request: protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsResponse, - protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsResponse, + | protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateInstanceMetadataItems( - request: protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest, - callback: Callback< - protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsResponse, - protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest, + callback: Callback< + protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsResponse, + | protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateInstanceMetadataItems( - request?: protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsResponse, - protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsResponse, - protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsResponse, - protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsResponse, + | protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsResponse, + ( + | protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateInstanceMetadataItems request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsResponse, - protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsResponse, + | protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateInstanceMetadataItems response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateInstanceMetadataItems(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsResponse, - protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateInstanceMetadataItems response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .updateInstanceMetadataItems(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsResponse, + ( + | protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateInstanceMetadataItems response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Check if a notebook instance is upgradable. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.notebookInstance - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {google.cloud.notebooks.v1.UpgradeType} [request.type] - * Optional. The optional UpgradeType. Setting this field will search for additional - * compute images to upgrade this instance. - * @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 {@link protos.google.cloud.notebooks.v1.IsInstanceUpgradeableResponse|IsInstanceUpgradeableResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.is_instance_upgradeable.js - * region_tag:notebooks_v1_generated_NotebookService_IsInstanceUpgradeable_async - */ + /** + * Check if a notebook instance is upgradable. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.notebookInstance + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {google.cloud.notebooks.v1.UpgradeType} [request.type] + * Optional. The optional UpgradeType. Setting this field will search for additional + * compute images to upgrade this instance. + * @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 {@link protos.google.cloud.notebooks.v1.IsInstanceUpgradeableResponse|IsInstanceUpgradeableResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.is_instance_upgradeable.js + * region_tag:notebooks_v1_generated_NotebookService_IsInstanceUpgradeable_async + */ isInstanceUpgradeable( - request?: protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableResponse, - protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableResponse, + ( + | protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest + | undefined + ), + {} | undefined, + ] + >; isInstanceUpgradeable( - request: protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableResponse, - protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableResponse, + | protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest + | null + | undefined, + {} | null | undefined + >, + ): void; isInstanceUpgradeable( - request: protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest, - callback: Callback< - protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableResponse, - protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest, + callback: Callback< + protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableResponse, + | protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest + | null + | undefined, + {} | null | undefined + >, + ): void; isInstanceUpgradeable( - request?: protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableResponse, - protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableResponse, - protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableResponse, - protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableResponse, + | protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableResponse, + ( + | protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'notebook_instance': request.notebookInstance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + notebook_instance: request.notebookInstance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('isInstanceUpgradeable request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableResponse, - protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableResponse, + | protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('isInstanceUpgradeable response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.isInstanceUpgradeable(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableResponse, - protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest|undefined, - {}|undefined - ]) => { - this._log.info('isInstanceUpgradeable response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .isInstanceUpgradeable(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableResponse, + ( + | protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('isInstanceUpgradeable response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Check if a notebook instance is healthy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @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 {@link protos.google.cloud.notebooks.v1.GetInstanceHealthResponse|GetInstanceHealthResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.get_instance_health.js - * region_tag:notebooks_v1_generated_NotebookService_GetInstanceHealth_async - */ + /** + * Check if a notebook instance is healthy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @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 {@link protos.google.cloud.notebooks.v1.GetInstanceHealthResponse|GetInstanceHealthResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.get_instance_health.js + * region_tag:notebooks_v1_generated_NotebookService_GetInstanceHealth_async + */ getInstanceHealth( - request?: protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1.IGetInstanceHealthResponse, - protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.notebooks.v1.IGetInstanceHealthResponse, + protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest | undefined, + {} | undefined, + ] + >; getInstanceHealth( - request: protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.notebooks.v1.IGetInstanceHealthResponse, - protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.notebooks.v1.IGetInstanceHealthResponse, + | protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getInstanceHealth( - request: protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest, - callback: Callback< - protos.google.cloud.notebooks.v1.IGetInstanceHealthResponse, - protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest, + callback: Callback< + protos.google.cloud.notebooks.v1.IGetInstanceHealthResponse, + | protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getInstanceHealth( - request?: protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.notebooks.v1.IGetInstanceHealthResponse, - protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.notebooks.v1.IGetInstanceHealthResponse, - protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.notebooks.v1.IGetInstanceHealthResponse, - protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.notebooks.v1.IGetInstanceHealthResponse, + | protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.notebooks.v1.IGetInstanceHealthResponse, + protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getInstanceHealth request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.notebooks.v1.IGetInstanceHealthResponse, - protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.notebooks.v1.IGetInstanceHealthResponse, + | protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getInstanceHealth response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getInstanceHealth(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.notebooks.v1.IGetInstanceHealthResponse, - protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest|undefined, - {}|undefined - ]) => { - this._log.info('getInstanceHealth response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getInstanceHealth(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.notebooks.v1.IGetInstanceHealthResponse, + ( + | protos.google.cloud.notebooks.v1.IGetInstanceHealthRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getInstanceHealth response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single Environment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/environments/{environment_id}` - * @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 {@link protos.google.cloud.notebooks.v1.Environment|Environment}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.get_environment.js - * region_tag:notebooks_v1_generated_NotebookService_GetEnvironment_async - */ + /** + * Gets details of a single Environment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/environments/{environment_id}` + * @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 {@link protos.google.cloud.notebooks.v1.Environment|Environment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.get_environment.js + * region_tag:notebooks_v1_generated_NotebookService_GetEnvironment_async + */ getEnvironment( - request?: protos.google.cloud.notebooks.v1.IGetEnvironmentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1.IEnvironment, - protos.google.cloud.notebooks.v1.IGetEnvironmentRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IGetEnvironmentRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.notebooks.v1.IEnvironment, + protos.google.cloud.notebooks.v1.IGetEnvironmentRequest | undefined, + {} | undefined, + ] + >; getEnvironment( - request: protos.google.cloud.notebooks.v1.IGetEnvironmentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.notebooks.v1.IEnvironment, - protos.google.cloud.notebooks.v1.IGetEnvironmentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IGetEnvironmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.notebooks.v1.IEnvironment, + | protos.google.cloud.notebooks.v1.IGetEnvironmentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getEnvironment( - request: protos.google.cloud.notebooks.v1.IGetEnvironmentRequest, - callback: Callback< - protos.google.cloud.notebooks.v1.IEnvironment, - protos.google.cloud.notebooks.v1.IGetEnvironmentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IGetEnvironmentRequest, + callback: Callback< + protos.google.cloud.notebooks.v1.IEnvironment, + | protos.google.cloud.notebooks.v1.IGetEnvironmentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getEnvironment( - request?: protos.google.cloud.notebooks.v1.IGetEnvironmentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.notebooks.v1.IEnvironment, - protos.google.cloud.notebooks.v1.IGetEnvironmentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.notebooks.v1.IGetEnvironmentRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.notebooks.v1.IEnvironment, - protos.google.cloud.notebooks.v1.IGetEnvironmentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.notebooks.v1.IEnvironment, - protos.google.cloud.notebooks.v1.IGetEnvironmentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; + | protos.google.cloud.notebooks.v1.IGetEnvironmentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.notebooks.v1.IEnvironment, + | protos.google.cloud.notebooks.v1.IGetEnvironmentRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.notebooks.v1.IEnvironment, + protos.google.cloud.notebooks.v1.IGetEnvironmentRequest | undefined, + {} | undefined, + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getEnvironment request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.notebooks.v1.IEnvironment, - protos.google.cloud.notebooks.v1.IGetEnvironmentRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.notebooks.v1.IEnvironment, + | protos.google.cloud.notebooks.v1.IGetEnvironmentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getEnvironment response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getEnvironment(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.notebooks.v1.IEnvironment, - protos.google.cloud.notebooks.v1.IGetEnvironmentRequest|undefined, - {}|undefined - ]) => { - this._log.info('getEnvironment response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getEnvironment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.notebooks.v1.IEnvironment, + protos.google.cloud.notebooks.v1.IGetEnvironmentRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getEnvironment response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of schedule - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/schedules/{schedule_id}` - * @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 {@link protos.google.cloud.notebooks.v1.Schedule|Schedule}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.get_schedule.js - * region_tag:notebooks_v1_generated_NotebookService_GetSchedule_async - */ + /** + * Gets details of schedule + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/schedules/{schedule_id}` + * @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 {@link protos.google.cloud.notebooks.v1.Schedule|Schedule}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.get_schedule.js + * region_tag:notebooks_v1_generated_NotebookService_GetSchedule_async + */ getSchedule( - request?: protos.google.cloud.notebooks.v1.IGetScheduleRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1.ISchedule, - protos.google.cloud.notebooks.v1.IGetScheduleRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IGetScheduleRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IGetScheduleRequest | undefined, + {} | undefined, + ] + >; getSchedule( - request: protos.google.cloud.notebooks.v1.IGetScheduleRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.notebooks.v1.ISchedule, - protos.google.cloud.notebooks.v1.IGetScheduleRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IGetScheduleRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IGetScheduleRequest | null | undefined, + {} | null | undefined + >, + ): void; getSchedule( - request: protos.google.cloud.notebooks.v1.IGetScheduleRequest, - callback: Callback< - protos.google.cloud.notebooks.v1.ISchedule, - protos.google.cloud.notebooks.v1.IGetScheduleRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IGetScheduleRequest, + callback: Callback< + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IGetScheduleRequest | null | undefined, + {} | null | undefined + >, + ): void; getSchedule( - request?: protos.google.cloud.notebooks.v1.IGetScheduleRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.notebooks.v1.ISchedule, - protos.google.cloud.notebooks.v1.IGetScheduleRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.notebooks.v1.IGetScheduleRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.notebooks.v1.ISchedule, - protos.google.cloud.notebooks.v1.IGetScheduleRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.notebooks.v1.ISchedule, - protos.google.cloud.notebooks.v1.IGetScheduleRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.notebooks.v1.IGetScheduleRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IGetScheduleRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IGetScheduleRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getSchedule request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.notebooks.v1.ISchedule, - protos.google.cloud.notebooks.v1.IGetScheduleRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.notebooks.v1.ISchedule, + | protos.google.cloud.notebooks.v1.IGetScheduleRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getSchedule response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getSchedule(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.notebooks.v1.ISchedule, - protos.google.cloud.notebooks.v1.IGetScheduleRequest|undefined, - {}|undefined - ]) => { - this._log.info('getSchedule response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getSchedule(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IGetScheduleRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getSchedule response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of executions - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/executions/{execution_id}` - * @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 {@link protos.google.cloud.notebooks.v1.Execution|Execution}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.get_execution.js - * region_tag:notebooks_v1_generated_NotebookService_GetExecution_async - */ + /** + * Gets details of executions + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/executions/{execution_id}` + * @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 {@link protos.google.cloud.notebooks.v1.Execution|Execution}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.get_execution.js + * region_tag:notebooks_v1_generated_NotebookService_GetExecution_async + */ getExecution( - request?: protos.google.cloud.notebooks.v1.IGetExecutionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1.IExecution, - protos.google.cloud.notebooks.v1.IGetExecutionRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IGetExecutionRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.notebooks.v1.IExecution, + protos.google.cloud.notebooks.v1.IGetExecutionRequest | undefined, + {} | undefined, + ] + >; getExecution( - request: protos.google.cloud.notebooks.v1.IGetExecutionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.notebooks.v1.IExecution, - protos.google.cloud.notebooks.v1.IGetExecutionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IGetExecutionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.notebooks.v1.IExecution, + protos.google.cloud.notebooks.v1.IGetExecutionRequest | null | undefined, + {} | null | undefined + >, + ): void; getExecution( - request: protos.google.cloud.notebooks.v1.IGetExecutionRequest, - callback: Callback< - protos.google.cloud.notebooks.v1.IExecution, - protos.google.cloud.notebooks.v1.IGetExecutionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IGetExecutionRequest, + callback: Callback< + protos.google.cloud.notebooks.v1.IExecution, + protos.google.cloud.notebooks.v1.IGetExecutionRequest | null | undefined, + {} | null | undefined + >, + ): void; getExecution( - request?: protos.google.cloud.notebooks.v1.IGetExecutionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.notebooks.v1.IExecution, - protos.google.cloud.notebooks.v1.IGetExecutionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.notebooks.v1.IGetExecutionRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.notebooks.v1.IExecution, - protos.google.cloud.notebooks.v1.IGetExecutionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.notebooks.v1.IExecution, - protos.google.cloud.notebooks.v1.IGetExecutionRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.notebooks.v1.IGetExecutionRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.notebooks.v1.IExecution, + protos.google.cloud.notebooks.v1.IGetExecutionRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.notebooks.v1.IExecution, + protos.google.cloud.notebooks.v1.IGetExecutionRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getExecution request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.notebooks.v1.IExecution, - protos.google.cloud.notebooks.v1.IGetExecutionRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.notebooks.v1.IExecution, + | protos.google.cloud.notebooks.v1.IGetExecutionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getExecution response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getExecution(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.notebooks.v1.IExecution, - protos.google.cloud.notebooks.v1.IGetExecutionRequest|undefined, - {}|undefined - ]) => { - this._log.info('getExecution response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getExecution(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.notebooks.v1.IExecution, + protos.google.cloud.notebooks.v1.IGetExecutionRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getExecution response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a new Instance in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {string} request.instanceId - * Required. User-defined unique ID of this instance. - * @param {google.cloud.notebooks.v1.Instance} request.instance - * Required. The instance to be created. - * @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/notebook_service.create_instance.js - * region_tag:notebooks_v1_generated_NotebookService_CreateInstance_async - */ + /** + * Creates a new Instance in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {string} request.instanceId + * Required. User-defined unique ID of this instance. + * @param {google.cloud.notebooks.v1.Instance} request.instance + * Required. The instance to be created. + * @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/notebook_service.create_instance.js + * region_tag:notebooks_v1_generated_NotebookService_CreateInstance_async + */ createInstance( - request?: protos.google.cloud.notebooks.v1.ICreateInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.ICreateInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createInstance( - request: protos.google.cloud.notebooks.v1.ICreateInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.ICreateInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createInstance( - request: protos.google.cloud.notebooks.v1.ICreateInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.ICreateInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createInstance( - request?: protos.google.cloud.notebooks.v1.ICreateInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.ICreateInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createInstance request %j', request); - return this.innerApiCalls.createInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createInstance()`. - * @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/notebook_service.create_instance.js - * region_tag:notebooks_v1_generated_NotebookService_CreateInstance_async - */ - async checkCreateInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createInstance()`. + * @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/notebook_service.create_instance.js + * region_tag:notebooks_v1_generated_NotebookService_CreateInstance_async + */ + async checkCreateInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1.Instance, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('createInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1.Instance, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } -/** - * Registers an existing legacy notebook instance to the Notebooks API server. - * Legacy instances are instances created with the legacy Compute Engine - * calls. They are not manageable by the Notebooks API out of the box. This - * call makes these instances manageable by the Notebooks API. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {string} request.instanceId - * Required. User defined unique ID of this instance. The `instance_id` must - * be 1 to 63 characters long and contain only lowercase letters, - * numeric characters, and dashes. The first character must be a lowercase - * letter and the last character cannot be a dash. - * @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/notebook_service.register_instance.js - * region_tag:notebooks_v1_generated_NotebookService_RegisterInstance_async - */ + /** + * Registers an existing legacy notebook instance to the Notebooks API server. + * Legacy instances are instances created with the legacy Compute Engine + * calls. They are not manageable by the Notebooks API out of the box. This + * call makes these instances manageable by the Notebooks API. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {string} request.instanceId + * Required. User defined unique ID of this instance. The `instance_id` must + * be 1 to 63 characters long and contain only lowercase letters, + * numeric characters, and dashes. The first character must be a lowercase + * letter and the last character cannot be a dash. + * @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/notebook_service.register_instance.js + * region_tag:notebooks_v1_generated_NotebookService_RegisterInstance_async + */ registerInstance( - request?: protos.google.cloud.notebooks.v1.IRegisterInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IRegisterInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; registerInstance( - request: protos.google.cloud.notebooks.v1.IRegisterInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IRegisterInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; registerInstance( - request: protos.google.cloud.notebooks.v1.IRegisterInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IRegisterInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; registerInstance( - request?: protos.google.cloud.notebooks.v1.IRegisterInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.IRegisterInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('registerInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('registerInstance request %j', request); - return this.innerApiCalls.registerInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('registerInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .registerInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('registerInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `registerInstance()`. - * @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/notebook_service.register_instance.js - * region_tag:notebooks_v1_generated_NotebookService_RegisterInstance_async - */ - async checkRegisterInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `registerInstance()`. + * @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/notebook_service.register_instance.js + * region_tag:notebooks_v1_generated_NotebookService_RegisterInstance_async + */ + async checkRegisterInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1.Instance, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('registerInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.registerInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.registerInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1.Instance, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } -/** - * Updates the guest accelerators of a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {google.cloud.notebooks.v1.Instance.AcceleratorType} request.type - * Required. Type of this accelerator. - * @param {number} request.coreCount - * Required. Count of cores of this accelerator. Note that not all combinations - * of `type` and `core_count` are valid. Check [GPUs on - * Compute Engine](https://cloud.google.com/compute/docs/gpus/#gpus-list) to - * find a valid combination. TPUs are not supported. - * @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/notebook_service.set_instance_accelerator.js - * region_tag:notebooks_v1_generated_NotebookService_SetInstanceAccelerator_async - */ + /** + * Updates the guest accelerators of a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {google.cloud.notebooks.v1.Instance.AcceleratorType} request.type + * Required. Type of this accelerator. + * @param {number} request.coreCount + * Required. Count of cores of this accelerator. Note that not all combinations + * of `type` and `core_count` are valid. Check [GPUs on + * Compute Engine](https://cloud.google.com/compute/docs/gpus/#gpus-list) to + * find a valid combination. TPUs are not supported. + * @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/notebook_service.set_instance_accelerator.js + * region_tag:notebooks_v1_generated_NotebookService_SetInstanceAccelerator_async + */ setInstanceAccelerator( - request?: protos.google.cloud.notebooks.v1.ISetInstanceAcceleratorRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.ISetInstanceAcceleratorRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; setInstanceAccelerator( - request: protos.google.cloud.notebooks.v1.ISetInstanceAcceleratorRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.ISetInstanceAcceleratorRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; setInstanceAccelerator( - request: protos.google.cloud.notebooks.v1.ISetInstanceAcceleratorRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.ISetInstanceAcceleratorRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; setInstanceAccelerator( - request?: protos.google.cloud.notebooks.v1.ISetInstanceAcceleratorRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.ISetInstanceAcceleratorRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('setInstanceAccelerator response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('setInstanceAccelerator request %j', request); - return this.innerApiCalls.setInstanceAccelerator(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('setInstanceAccelerator response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .setInstanceAccelerator(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('setInstanceAccelerator response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `setInstanceAccelerator()`. - * @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/notebook_service.set_instance_accelerator.js - * region_tag:notebooks_v1_generated_NotebookService_SetInstanceAccelerator_async - */ - async checkSetInstanceAcceleratorProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `setInstanceAccelerator()`. + * @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/notebook_service.set_instance_accelerator.js + * region_tag:notebooks_v1_generated_NotebookService_SetInstanceAccelerator_async + */ + async checkSetInstanceAcceleratorProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1.Instance, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('setInstanceAccelerator long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.setInstanceAccelerator, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.setInstanceAccelerator, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1.Instance, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } -/** - * Updates the machine type of a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {string} request.machineType - * Required. The [Compute Engine machine - * type](https://cloud.google.com/compute/docs/machine-types). - * @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/notebook_service.set_instance_machine_type.js - * region_tag:notebooks_v1_generated_NotebookService_SetInstanceMachineType_async - */ + /** + * Updates the machine type of a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {string} request.machineType + * Required. The [Compute Engine machine + * type](https://cloud.google.com/compute/docs/machine-types). + * @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/notebook_service.set_instance_machine_type.js + * region_tag:notebooks_v1_generated_NotebookService_SetInstanceMachineType_async + */ setInstanceMachineType( - request?: protos.google.cloud.notebooks.v1.ISetInstanceMachineTypeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.ISetInstanceMachineTypeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; setInstanceMachineType( - request: protos.google.cloud.notebooks.v1.ISetInstanceMachineTypeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.ISetInstanceMachineTypeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; setInstanceMachineType( - request: protos.google.cloud.notebooks.v1.ISetInstanceMachineTypeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.ISetInstanceMachineTypeRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; setInstanceMachineType( - request?: protos.google.cloud.notebooks.v1.ISetInstanceMachineTypeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.ISetInstanceMachineTypeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('setInstanceMachineType response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('setInstanceMachineType request %j', request); - return this.innerApiCalls.setInstanceMachineType(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('setInstanceMachineType response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .setInstanceMachineType(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('setInstanceMachineType response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `setInstanceMachineType()`. - * @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/notebook_service.set_instance_machine_type.js - * region_tag:notebooks_v1_generated_NotebookService_SetInstanceMachineType_async - */ - async checkSetInstanceMachineTypeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `setInstanceMachineType()`. + * @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/notebook_service.set_instance_machine_type.js + * region_tag:notebooks_v1_generated_NotebookService_SetInstanceMachineType_async + */ + async checkSetInstanceMachineTypeProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1.Instance, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('setInstanceMachineType long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.setInstanceMachineType, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.setInstanceMachineType, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1.Instance, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } -/** - * Update Notebook Instance configurations. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {google.cloud.notebooks.v1.InstanceConfig} request.config - * The instance configurations to be updated. - * @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/notebook_service.update_instance_config.js - * region_tag:notebooks_v1_generated_NotebookService_UpdateInstanceConfig_async - */ + /** + * Update Notebook Instance configurations. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {google.cloud.notebooks.v1.InstanceConfig} request.config + * The instance configurations to be updated. + * @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/notebook_service.update_instance_config.js + * region_tag:notebooks_v1_generated_NotebookService_UpdateInstanceConfig_async + */ updateInstanceConfig( - request?: protos.google.cloud.notebooks.v1.IUpdateInstanceConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IUpdateInstanceConfigRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateInstanceConfig( - request: protos.google.cloud.notebooks.v1.IUpdateInstanceConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IUpdateInstanceConfigRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateInstanceConfig( - request: protos.google.cloud.notebooks.v1.IUpdateInstanceConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IUpdateInstanceConfigRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateInstanceConfig( - request?: protos.google.cloud.notebooks.v1.IUpdateInstanceConfigRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.IUpdateInstanceConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateInstanceConfig response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateInstanceConfig request %j', request); - return this.innerApiCalls.updateInstanceConfig(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateInstanceConfig response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateInstanceConfig(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateInstanceConfig response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateInstanceConfig()`. - * @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/notebook_service.update_instance_config.js - * region_tag:notebooks_v1_generated_NotebookService_UpdateInstanceConfig_async - */ - async checkUpdateInstanceConfigProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateInstanceConfig()`. + * @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/notebook_service.update_instance_config.js + * region_tag:notebooks_v1_generated_NotebookService_UpdateInstanceConfig_async + */ + async checkUpdateInstanceConfigProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1.Instance, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('updateInstanceConfig long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateInstanceConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateInstanceConfig, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1.Instance, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } -/** - * Updates the Shielded instance configuration of a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {google.cloud.notebooks.v1.Instance.ShieldedInstanceConfig} request.shieldedInstanceConfig - * ShieldedInstance configuration to be updated. - * @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/notebook_service.update_shielded_instance_config.js - * region_tag:notebooks_v1_generated_NotebookService_UpdateShieldedInstanceConfig_async - */ + /** + * Updates the Shielded instance configuration of a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {google.cloud.notebooks.v1.Instance.ShieldedInstanceConfig} request.shieldedInstanceConfig + * ShieldedInstance configuration to be updated. + * @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/notebook_service.update_shielded_instance_config.js + * region_tag:notebooks_v1_generated_NotebookService_UpdateShieldedInstanceConfig_async + */ updateShieldedInstanceConfig( - request?: protos.google.cloud.notebooks.v1.IUpdateShieldedInstanceConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IUpdateShieldedInstanceConfigRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateShieldedInstanceConfig( - request: protos.google.cloud.notebooks.v1.IUpdateShieldedInstanceConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IUpdateShieldedInstanceConfigRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateShieldedInstanceConfig( - request: protos.google.cloud.notebooks.v1.IUpdateShieldedInstanceConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IUpdateShieldedInstanceConfigRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateShieldedInstanceConfig( - request?: protos.google.cloud.notebooks.v1.IUpdateShieldedInstanceConfigRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.IUpdateShieldedInstanceConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { - this._log.info('updateShieldedInstanceConfig response %j', rawResponse); + this._log.info( + 'updateShieldedInstanceConfig response %j', + rawResponse, + ); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateShieldedInstanceConfig request %j', request); - return this.innerApiCalls.updateShieldedInstanceConfig(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateShieldedInstanceConfig response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateShieldedInstanceConfig(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info( + 'updateShieldedInstanceConfig response %j', + rawResponse, + ); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateShieldedInstanceConfig()`. - * @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/notebook_service.update_shielded_instance_config.js - * region_tag:notebooks_v1_generated_NotebookService_UpdateShieldedInstanceConfig_async - */ - async checkUpdateShieldedInstanceConfigProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateShieldedInstanceConfig()`. + * @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/notebook_service.update_shielded_instance_config.js + * region_tag:notebooks_v1_generated_NotebookService_UpdateShieldedInstanceConfig_async + */ + async checkUpdateShieldedInstanceConfigProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1.Instance, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('updateShieldedInstanceConfig long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateShieldedInstanceConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateShieldedInstanceConfig, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1.Instance, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } -/** - * Replaces all the labels of an Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {number[]} request.labels - * Labels to apply to this instance. - * These can be later modified by the setLabels method - * @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/notebook_service.set_instance_labels.js - * region_tag:notebooks_v1_generated_NotebookService_SetInstanceLabels_async - */ + /** + * Replaces all the labels of an Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {number[]} request.labels + * Labels to apply to this instance. + * These can be later modified by the setLabels method + * @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/notebook_service.set_instance_labels.js + * region_tag:notebooks_v1_generated_NotebookService_SetInstanceLabels_async + */ setInstanceLabels( - request?: protos.google.cloud.notebooks.v1.ISetInstanceLabelsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.ISetInstanceLabelsRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; setInstanceLabels( - request: protos.google.cloud.notebooks.v1.ISetInstanceLabelsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.ISetInstanceLabelsRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; setInstanceLabels( - request: protos.google.cloud.notebooks.v1.ISetInstanceLabelsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.ISetInstanceLabelsRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; setInstanceLabels( - request?: protos.google.cloud.notebooks.v1.ISetInstanceLabelsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.ISetInstanceLabelsRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('setInstanceLabels response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('setInstanceLabels request %j', request); - return this.innerApiCalls.setInstanceLabels(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('setInstanceLabels response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .setInstanceLabels(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('setInstanceLabels response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `setInstanceLabels()`. - * @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/notebook_service.set_instance_labels.js - * region_tag:notebooks_v1_generated_NotebookService_SetInstanceLabels_async - */ - async checkSetInstanceLabelsProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `setInstanceLabels()`. + * @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/notebook_service.set_instance_labels.js + * region_tag:notebooks_v1_generated_NotebookService_SetInstanceLabels_async + */ + async checkSetInstanceLabelsProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1.Instance, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('setInstanceLabels long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.setInstanceLabels, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.setInstanceLabels, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1.Instance, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } -/** - * Deletes a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @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/notebook_service.delete_instance.js - * region_tag:notebooks_v1_generated_NotebookService_DeleteInstance_async - */ + /** + * Deletes a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @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/notebook_service.delete_instance.js + * region_tag:notebooks_v1_generated_NotebookService_DeleteInstance_async + */ deleteInstance( - request?: protos.google.cloud.notebooks.v1.IDeleteInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IDeleteInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteInstance( - request: protos.google.cloud.notebooks.v1.IDeleteInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IDeleteInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteInstance( - request: protos.google.cloud.notebooks.v1.IDeleteInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IDeleteInstanceRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteInstance( - request?: protos.google.cloud.notebooks.v1.IDeleteInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.IDeleteInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteInstance request %j', request); - return this.innerApiCalls.deleteInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteInstance()`. - * @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/notebook_service.delete_instance.js - * region_tag:notebooks_v1_generated_NotebookService_DeleteInstance_async - */ - async checkDeleteInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteInstance()`. + * @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/notebook_service.delete_instance.js + * region_tag:notebooks_v1_generated_NotebookService_DeleteInstance_async + */ + async checkDeleteInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('deleteInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } -/** - * Starts a notebook instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @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/notebook_service.start_instance.js - * region_tag:notebooks_v1_generated_NotebookService_StartInstance_async - */ + /** + * Starts a notebook instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @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/notebook_service.start_instance.js + * region_tag:notebooks_v1_generated_NotebookService_StartInstance_async + */ startInstance( - request?: protos.google.cloud.notebooks.v1.IStartInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IStartInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; startInstance( - request: protos.google.cloud.notebooks.v1.IStartInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IStartInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; startInstance( - request: protos.google.cloud.notebooks.v1.IStartInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IStartInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; startInstance( - request?: protos.google.cloud.notebooks.v1.IStartInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.IStartInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('startInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('startInstance request %j', request); - return this.innerApiCalls.startInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('startInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .startInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('startInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `startInstance()`. - * @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/notebook_service.start_instance.js - * region_tag:notebooks_v1_generated_NotebookService_StartInstance_async - */ - async checkStartInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `startInstance()`. + * @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/notebook_service.start_instance.js + * region_tag:notebooks_v1_generated_NotebookService_StartInstance_async + */ + async checkStartInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1.Instance, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('startInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.startInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.startInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1.Instance, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } -/** - * Stops a notebook instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @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/notebook_service.stop_instance.js - * region_tag:notebooks_v1_generated_NotebookService_StopInstance_async - */ + /** + * Stops a notebook instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @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/notebook_service.stop_instance.js + * region_tag:notebooks_v1_generated_NotebookService_StopInstance_async + */ stopInstance( - request?: protos.google.cloud.notebooks.v1.IStopInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IStopInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; stopInstance( - request: protos.google.cloud.notebooks.v1.IStopInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IStopInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; stopInstance( - request: protos.google.cloud.notebooks.v1.IStopInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IStopInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; stopInstance( - request?: protos.google.cloud.notebooks.v1.IStopInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.IStopInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('stopInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('stopInstance request %j', request); - return this.innerApiCalls.stopInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('stopInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .stopInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('stopInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `stopInstance()`. - * @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/notebook_service.stop_instance.js - * region_tag:notebooks_v1_generated_NotebookService_StopInstance_async - */ - async checkStopInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `stopInstance()`. + * @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/notebook_service.stop_instance.js + * region_tag:notebooks_v1_generated_NotebookService_StopInstance_async + */ + async checkStopInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1.Instance, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('stopInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.stopInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.stopInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1.Instance, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } -/** - * Resets a notebook instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @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/notebook_service.reset_instance.js - * region_tag:notebooks_v1_generated_NotebookService_ResetInstance_async - */ + /** + * Resets a notebook instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @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/notebook_service.reset_instance.js + * region_tag:notebooks_v1_generated_NotebookService_ResetInstance_async + */ resetInstance( - request?: protos.google.cloud.notebooks.v1.IResetInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IResetInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; resetInstance( - request: protos.google.cloud.notebooks.v1.IResetInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IResetInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; resetInstance( - request: protos.google.cloud.notebooks.v1.IResetInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IResetInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; resetInstance( - request?: protos.google.cloud.notebooks.v1.IResetInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.IResetInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('resetInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('resetInstance request %j', request); - return this.innerApiCalls.resetInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('resetInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .resetInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('resetInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `resetInstance()`. - * @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/notebook_service.reset_instance.js - * region_tag:notebooks_v1_generated_NotebookService_ResetInstance_async - */ - async checkResetInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `resetInstance()`. + * @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/notebook_service.reset_instance.js + * region_tag:notebooks_v1_generated_NotebookService_ResetInstance_async + */ + async checkResetInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1.Instance, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('resetInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.resetInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.resetInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1.Instance, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } -/** - * Allows notebook instances to - * report their latest instance information to the Notebooks - * API server. The server will merge the reported information to - * the instance metadata store. Do not use this method directly. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {string} request.vmId - * Required. The VM hardware token for authenticating the VM. - * https://cloud.google.com/compute/docs/instances/verifying-instance-identity - * @param {number[]} request.metadata - * The metadata reported to Notebooks API. This will be merged to the instance - * metadata store - * @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/notebook_service.report_instance_info.js - * region_tag:notebooks_v1_generated_NotebookService_ReportInstanceInfo_async - */ + /** + * Allows notebook instances to + * report their latest instance information to the Notebooks + * API server. The server will merge the reported information to + * the instance metadata store. Do not use this method directly. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {string} request.vmId + * Required. The VM hardware token for authenticating the VM. + * https://cloud.google.com/compute/docs/instances/verifying-instance-identity + * @param {number[]} request.metadata + * The metadata reported to Notebooks API. This will be merged to the instance + * metadata store + * @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/notebook_service.report_instance_info.js + * region_tag:notebooks_v1_generated_NotebookService_ReportInstanceInfo_async + */ reportInstanceInfo( - request?: protos.google.cloud.notebooks.v1.IReportInstanceInfoRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IReportInstanceInfoRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; reportInstanceInfo( - request: protos.google.cloud.notebooks.v1.IReportInstanceInfoRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IReportInstanceInfoRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; reportInstanceInfo( - request: protos.google.cloud.notebooks.v1.IReportInstanceInfoRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IReportInstanceInfoRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; reportInstanceInfo( - request?: protos.google.cloud.notebooks.v1.IReportInstanceInfoRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.IReportInstanceInfoRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('reportInstanceInfo response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('reportInstanceInfo request %j', request); - return this.innerApiCalls.reportInstanceInfo(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('reportInstanceInfo response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .reportInstanceInfo(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('reportInstanceInfo response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `reportInstanceInfo()`. - * @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/notebook_service.report_instance_info.js - * region_tag:notebooks_v1_generated_NotebookService_ReportInstanceInfo_async - */ - async checkReportInstanceInfoProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `reportInstanceInfo()`. + * @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/notebook_service.report_instance_info.js + * region_tag:notebooks_v1_generated_NotebookService_ReportInstanceInfo_async + */ + async checkReportInstanceInfoProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1.Instance, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('reportInstanceInfo long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.reportInstanceInfo, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.reportInstanceInfo, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1.Instance, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } -/** - * Upgrades a notebook instance to the latest version. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {google.cloud.notebooks.v1.UpgradeType} [request.type] - * Optional. The optional UpgradeType. Setting this field will search for additional - * compute images to upgrade this instance. - * @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/notebook_service.upgrade_instance.js - * region_tag:notebooks_v1_generated_NotebookService_UpgradeInstance_async - */ + /** + * Upgrades a notebook instance to the latest version. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {google.cloud.notebooks.v1.UpgradeType} [request.type] + * Optional. The optional UpgradeType. Setting this field will search for additional + * compute images to upgrade this instance. + * @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/notebook_service.upgrade_instance.js + * region_tag:notebooks_v1_generated_NotebookService_UpgradeInstance_async + */ upgradeInstance( - request?: protos.google.cloud.notebooks.v1.IUpgradeInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IUpgradeInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; upgradeInstance( - request: protos.google.cloud.notebooks.v1.IUpgradeInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IUpgradeInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; upgradeInstance( - request: protos.google.cloud.notebooks.v1.IUpgradeInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IUpgradeInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; upgradeInstance( - request?: protos.google.cloud.notebooks.v1.IUpgradeInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.IUpgradeInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('upgradeInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('upgradeInstance request %j', request); - return this.innerApiCalls.upgradeInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('upgradeInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .upgradeInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('upgradeInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `upgradeInstance()`. - * @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/notebook_service.upgrade_instance.js - * region_tag:notebooks_v1_generated_NotebookService_UpgradeInstance_async - */ - async checkUpgradeInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `upgradeInstance()`. + * @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/notebook_service.upgrade_instance.js + * region_tag:notebooks_v1_generated_NotebookService_UpgradeInstance_async + */ + async checkUpgradeInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1.Instance, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('upgradeInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.upgradeInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.upgradeInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1.Instance, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } -/** - * Rollbacks a notebook instance to the previous version. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {string} request.targetSnapshot - * Required. The snapshot for rollback. - * Example: `projects/test-project/global/snapshots/krwlzipynril`. - * @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/notebook_service.rollback_instance.js - * region_tag:notebooks_v1_generated_NotebookService_RollbackInstance_async - */ + /** + * Rollbacks a notebook instance to the previous version. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {string} request.targetSnapshot + * Required. The snapshot for rollback. + * Example: `projects/test-project/global/snapshots/krwlzipynril`. + * @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/notebook_service.rollback_instance.js + * region_tag:notebooks_v1_generated_NotebookService_RollbackInstance_async + */ rollbackInstance( - request?: protos.google.cloud.notebooks.v1.IRollbackInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IRollbackInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; rollbackInstance( - request: protos.google.cloud.notebooks.v1.IRollbackInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IRollbackInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; rollbackInstance( - request: protos.google.cloud.notebooks.v1.IRollbackInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IRollbackInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; rollbackInstance( - request?: protos.google.cloud.notebooks.v1.IRollbackInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.IRollbackInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('rollbackInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('rollbackInstance request %j', request); - return this.innerApiCalls.rollbackInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('rollbackInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .rollbackInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('rollbackInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `rollbackInstance()`. - * @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/notebook_service.rollback_instance.js - * region_tag:notebooks_v1_generated_NotebookService_RollbackInstance_async - */ - async checkRollbackInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `rollbackInstance()`. + * @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/notebook_service.rollback_instance.js + * region_tag:notebooks_v1_generated_NotebookService_RollbackInstance_async + */ + async checkRollbackInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1.Instance, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('rollbackInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.rollbackInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.rollbackInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1.Instance, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } -/** - * Creates a Diagnostic File and runs Diagnostic Tool given an Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {google.cloud.notebooks.v1.DiagnosticConfig} request.diagnosticConfig - * Required. Defines flags that are used to run the diagnostic tool - * @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/notebook_service.diagnose_instance.js - * region_tag:notebooks_v1_generated_NotebookService_DiagnoseInstance_async - */ + /** + * Creates a Diagnostic File and runs Diagnostic Tool given an Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {google.cloud.notebooks.v1.DiagnosticConfig} request.diagnosticConfig + * Required. Defines flags that are used to run the diagnostic tool + * @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/notebook_service.diagnose_instance.js + * region_tag:notebooks_v1_generated_NotebookService_DiagnoseInstance_async + */ diagnoseInstance( - request?: protos.google.cloud.notebooks.v1.IDiagnoseInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IDiagnoseInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; diagnoseInstance( - request: protos.google.cloud.notebooks.v1.IDiagnoseInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IDiagnoseInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; diagnoseInstance( - request: protos.google.cloud.notebooks.v1.IDiagnoseInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IDiagnoseInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; diagnoseInstance( - request?: protos.google.cloud.notebooks.v1.IDiagnoseInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.IDiagnoseInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('diagnoseInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('diagnoseInstance request %j', request); - return this.innerApiCalls.diagnoseInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('diagnoseInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .diagnoseInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('diagnoseInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `diagnoseInstance()`. - * @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/notebook_service.diagnose_instance.js - * region_tag:notebooks_v1_generated_NotebookService_DiagnoseInstance_async - */ - async checkDiagnoseInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `diagnoseInstance()`. + * @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/notebook_service.diagnose_instance.js + * region_tag:notebooks_v1_generated_NotebookService_DiagnoseInstance_async + */ + async checkDiagnoseInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1.Instance, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('diagnoseInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.diagnoseInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.diagnoseInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1.Instance, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } -/** - * Allows notebook instances to - * call this endpoint to upgrade themselves. Do not use this method directly. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {string} request.vmId - * Required. The VM hardware token for authenticating the VM. - * https://cloud.google.com/compute/docs/instances/verifying-instance-identity - * @param {google.cloud.notebooks.v1.UpgradeType} [request.type] - * Optional. The optional UpgradeType. Setting this field will search for additional - * compute images to upgrade this instance. - * @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/notebook_service.upgrade_instance_internal.js - * region_tag:notebooks_v1_generated_NotebookService_UpgradeInstanceInternal_async - */ + /** + * Allows notebook instances to + * call this endpoint to upgrade themselves. Do not use this method directly. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {string} request.vmId + * Required. The VM hardware token for authenticating the VM. + * https://cloud.google.com/compute/docs/instances/verifying-instance-identity + * @param {google.cloud.notebooks.v1.UpgradeType} [request.type] + * Optional. The optional UpgradeType. Setting this field will search for additional + * compute images to upgrade this instance. + * @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/notebook_service.upgrade_instance_internal.js + * region_tag:notebooks_v1_generated_NotebookService_UpgradeInstanceInternal_async + */ upgradeInstanceInternal( - request?: protos.google.cloud.notebooks.v1.IUpgradeInstanceInternalRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IUpgradeInstanceInternalRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; upgradeInstanceInternal( - request: protos.google.cloud.notebooks.v1.IUpgradeInstanceInternalRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IUpgradeInstanceInternalRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; upgradeInstanceInternal( - request: protos.google.cloud.notebooks.v1.IUpgradeInstanceInternalRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IUpgradeInstanceInternalRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; upgradeInstanceInternal( - request?: protos.google.cloud.notebooks.v1.IUpgradeInstanceInternalRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.IUpgradeInstanceInternalRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('upgradeInstanceInternal response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('upgradeInstanceInternal request %j', request); - return this.innerApiCalls.upgradeInstanceInternal(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('upgradeInstanceInternal response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .upgradeInstanceInternal(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('upgradeInstanceInternal response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `upgradeInstanceInternal()`. - * @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/notebook_service.upgrade_instance_internal.js - * region_tag:notebooks_v1_generated_NotebookService_UpgradeInstanceInternal_async - */ - async checkUpgradeInstanceInternalProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `upgradeInstanceInternal()`. + * @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/notebook_service.upgrade_instance_internal.js + * region_tag:notebooks_v1_generated_NotebookService_UpgradeInstanceInternal_async + */ + async checkUpgradeInstanceInternalProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1.Instance, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('upgradeInstanceInternal long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.upgradeInstanceInternal, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.upgradeInstanceInternal, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1.Instance, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } -/** - * Creates a new Environment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: `projects/{project_id}/locations/{location}` - * @param {string} request.environmentId - * Required. User-defined unique ID of this environment. The `environment_id` must - * be 1 to 63 characters long and contain only lowercase letters, - * numeric characters, and dashes. The first character must be a lowercase - * letter and the last character cannot be a dash. - * @param {google.cloud.notebooks.v1.Environment} request.environment - * Required. The environment to be created. - * @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/notebook_service.create_environment.js - * region_tag:notebooks_v1_generated_NotebookService_CreateEnvironment_async - */ + /** + * Creates a new Environment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: `projects/{project_id}/locations/{location}` + * @param {string} request.environmentId + * Required. User-defined unique ID of this environment. The `environment_id` must + * be 1 to 63 characters long and contain only lowercase letters, + * numeric characters, and dashes. The first character must be a lowercase + * letter and the last character cannot be a dash. + * @param {google.cloud.notebooks.v1.Environment} request.environment + * Required. The environment to be created. + * @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/notebook_service.create_environment.js + * region_tag:notebooks_v1_generated_NotebookService_CreateEnvironment_async + */ createEnvironment( - request?: protos.google.cloud.notebooks.v1.ICreateEnvironmentRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.ICreateEnvironmentRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IEnvironment, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createEnvironment( - request: protos.google.cloud.notebooks.v1.ICreateEnvironmentRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.ICreateEnvironmentRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IEnvironment, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createEnvironment( - request: protos.google.cloud.notebooks.v1.ICreateEnvironmentRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.ICreateEnvironmentRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IEnvironment, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createEnvironment( - request?: protos.google.cloud.notebooks.v1.ICreateEnvironmentRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.ICreateEnvironmentRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IEnvironment, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IEnvironment, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IEnvironment, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IEnvironment, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createEnvironment response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createEnvironment request %j', request); - return this.innerApiCalls.createEnvironment(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createEnvironment response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createEnvironment(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1.IEnvironment, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createEnvironment response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createEnvironment()`. - * @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/notebook_service.create_environment.js - * region_tag:notebooks_v1_generated_NotebookService_CreateEnvironment_async - */ - async checkCreateEnvironmentProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createEnvironment()`. + * @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/notebook_service.create_environment.js + * region_tag:notebooks_v1_generated_NotebookService_CreateEnvironment_async + */ + async checkCreateEnvironmentProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1.Environment, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('createEnvironment long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createEnvironment, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createEnvironment, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1.Environment, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } -/** - * Deletes a single Environment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/environments/{environment_id}` - * @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/notebook_service.delete_environment.js - * region_tag:notebooks_v1_generated_NotebookService_DeleteEnvironment_async - */ + /** + * Deletes a single Environment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/environments/{environment_id}` + * @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/notebook_service.delete_environment.js + * region_tag:notebooks_v1_generated_NotebookService_DeleteEnvironment_async + */ deleteEnvironment( - request?: protos.google.cloud.notebooks.v1.IDeleteEnvironmentRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IDeleteEnvironmentRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteEnvironment( - request: protos.google.cloud.notebooks.v1.IDeleteEnvironmentRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IDeleteEnvironmentRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteEnvironment( - request: protos.google.cloud.notebooks.v1.IDeleteEnvironmentRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IDeleteEnvironmentRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteEnvironment( - request?: protos.google.cloud.notebooks.v1.IDeleteEnvironmentRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.IDeleteEnvironmentRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteEnvironment response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteEnvironment request %j', request); - return this.innerApiCalls.deleteEnvironment(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteEnvironment response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteEnvironment(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteEnvironment response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteEnvironment()`. - * @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/notebook_service.delete_environment.js - * region_tag:notebooks_v1_generated_NotebookService_DeleteEnvironment_async - */ - async checkDeleteEnvironmentProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteEnvironment()`. + * @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/notebook_service.delete_environment.js + * region_tag:notebooks_v1_generated_NotebookService_DeleteEnvironment_async + */ + async checkDeleteEnvironmentProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('deleteEnvironment long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteEnvironment, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteEnvironment, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } -/** - * Deletes schedule and all underlying jobs - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/schedules/{schedule_id}` - * @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/notebook_service.delete_schedule.js - * region_tag:notebooks_v1_generated_NotebookService_DeleteSchedule_async - */ + /** + * Deletes schedule and all underlying jobs + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/schedules/{schedule_id}` + * @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/notebook_service.delete_schedule.js + * region_tag:notebooks_v1_generated_NotebookService_DeleteSchedule_async + */ deleteSchedule( - request?: protos.google.cloud.notebooks.v1.IDeleteScheduleRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IDeleteScheduleRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteSchedule( - request: protos.google.cloud.notebooks.v1.IDeleteScheduleRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IDeleteScheduleRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteSchedule( - request: protos.google.cloud.notebooks.v1.IDeleteScheduleRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IDeleteScheduleRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteSchedule( - request?: protos.google.cloud.notebooks.v1.IDeleteScheduleRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.IDeleteScheduleRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteSchedule response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteSchedule request %j', request); - return this.innerApiCalls.deleteSchedule(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteSchedule response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteSchedule(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteSchedule response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteSchedule()`. - * @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/notebook_service.delete_schedule.js - * region_tag:notebooks_v1_generated_NotebookService_DeleteSchedule_async - */ - async checkDeleteScheduleProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteSchedule()`. + * @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/notebook_service.delete_schedule.js + * region_tag:notebooks_v1_generated_NotebookService_DeleteSchedule_async + */ + async checkDeleteScheduleProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('deleteSchedule long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteSchedule, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteSchedule, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } -/** - * Creates a new Scheduled Notebook in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {string} request.scheduleId - * Required. User-defined unique ID of this schedule. - * @param {google.cloud.notebooks.v1.Schedule} request.schedule - * Required. The schedule to be created. - * @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/notebook_service.create_schedule.js - * region_tag:notebooks_v1_generated_NotebookService_CreateSchedule_async - */ + /** + * Creates a new Scheduled Notebook in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {string} request.scheduleId + * Required. User-defined unique ID of this schedule. + * @param {google.cloud.notebooks.v1.Schedule} request.schedule + * Required. The schedule to be created. + * @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/notebook_service.create_schedule.js + * region_tag:notebooks_v1_generated_NotebookService_CreateSchedule_async + */ createSchedule( - request?: protos.google.cloud.notebooks.v1.ICreateScheduleRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.ICreateScheduleRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createSchedule( - request: protos.google.cloud.notebooks.v1.ICreateScheduleRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.ICreateScheduleRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createSchedule( - request: protos.google.cloud.notebooks.v1.ICreateScheduleRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.ICreateScheduleRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createSchedule( - request?: protos.google.cloud.notebooks.v1.ICreateScheduleRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.ICreateScheduleRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createSchedule response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createSchedule request %j', request); - return this.innerApiCalls.createSchedule(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createSchedule response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createSchedule(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createSchedule response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createSchedule()`. - * @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/notebook_service.create_schedule.js - * region_tag:notebooks_v1_generated_NotebookService_CreateSchedule_async - */ - async checkCreateScheduleProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createSchedule()`. + * @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/notebook_service.create_schedule.js + * region_tag:notebooks_v1_generated_NotebookService_CreateSchedule_async + */ + async checkCreateScheduleProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1.Schedule, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('createSchedule long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createSchedule, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createSchedule, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1.Schedule, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } -/** - * Triggers execution of an existing schedule. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `parent=projects/{project_id}/locations/{location}/schedules/{schedule_id}` - * @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/notebook_service.trigger_schedule.js - * region_tag:notebooks_v1_generated_NotebookService_TriggerSchedule_async - */ + /** + * Triggers execution of an existing schedule. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `parent=projects/{project_id}/locations/{location}/schedules/{schedule_id}` + * @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/notebook_service.trigger_schedule.js + * region_tag:notebooks_v1_generated_NotebookService_TriggerSchedule_async + */ triggerSchedule( - request?: protos.google.cloud.notebooks.v1.ITriggerScheduleRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.ITriggerScheduleRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; triggerSchedule( - request: protos.google.cloud.notebooks.v1.ITriggerScheduleRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.ITriggerScheduleRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; triggerSchedule( - request: protos.google.cloud.notebooks.v1.ITriggerScheduleRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.ITriggerScheduleRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; triggerSchedule( - request?: protos.google.cloud.notebooks.v1.ITriggerScheduleRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.ITriggerScheduleRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('triggerSchedule response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('triggerSchedule request %j', request); - return this.innerApiCalls.triggerSchedule(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('triggerSchedule response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .triggerSchedule(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('triggerSchedule response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `triggerSchedule()`. - * @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/notebook_service.trigger_schedule.js - * region_tag:notebooks_v1_generated_NotebookService_TriggerSchedule_async - */ - async checkTriggerScheduleProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `triggerSchedule()`. + * @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/notebook_service.trigger_schedule.js + * region_tag:notebooks_v1_generated_NotebookService_TriggerSchedule_async + */ + async checkTriggerScheduleProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1.Schedule, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('triggerSchedule long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.triggerSchedule, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.triggerSchedule, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1.Schedule, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } -/** - * Deletes execution - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/executions/{execution_id}` - * @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/notebook_service.delete_execution.js - * region_tag:notebooks_v1_generated_NotebookService_DeleteExecution_async - */ + /** + * Deletes execution + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/executions/{execution_id}` + * @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/notebook_service.delete_execution.js + * region_tag:notebooks_v1_generated_NotebookService_DeleteExecution_async + */ deleteExecution( - request?: protos.google.cloud.notebooks.v1.IDeleteExecutionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.IDeleteExecutionRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteExecution( - request: protos.google.cloud.notebooks.v1.IDeleteExecutionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IDeleteExecutionRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteExecution( - request: protos.google.cloud.notebooks.v1.IDeleteExecutionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.IDeleteExecutionRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteExecution( - request?: protos.google.cloud.notebooks.v1.IDeleteExecutionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.IDeleteExecutionRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteExecution response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteExecution request %j', request); - return this.innerApiCalls.deleteExecution(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteExecution response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteExecution(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteExecution response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteExecution()`. - * @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/notebook_service.delete_execution.js - * region_tag:notebooks_v1_generated_NotebookService_DeleteExecution_async - */ - async checkDeleteExecutionProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteExecution()`. + * @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/notebook_service.delete_execution.js + * region_tag:notebooks_v1_generated_NotebookService_DeleteExecution_async + */ + async checkDeleteExecutionProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('deleteExecution long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteExecution, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteExecution, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } -/** - * Creates a new Execution in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {string} request.executionId - * Required. User-defined unique ID of this execution. - * @param {google.cloud.notebooks.v1.Execution} request.execution - * Required. The execution to be created. - * @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/notebook_service.create_execution.js - * region_tag:notebooks_v1_generated_NotebookService_CreateExecution_async - */ + /** + * Creates a new Execution in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {string} request.executionId + * Required. User-defined unique ID of this execution. + * @param {google.cloud.notebooks.v1.Execution} request.execution + * Required. The execution to be created. + * @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/notebook_service.create_execution.js + * region_tag:notebooks_v1_generated_NotebookService_CreateExecution_async + */ createExecution( - request?: protos.google.cloud.notebooks.v1.ICreateExecutionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1.ICreateExecutionRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IExecution, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createExecution( - request: protos.google.cloud.notebooks.v1.ICreateExecutionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.ICreateExecutionRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IExecution, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createExecution( - request: protos.google.cloud.notebooks.v1.ICreateExecutionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1.ICreateExecutionRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IExecution, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createExecution( - request?: protos.google.cloud.notebooks.v1.ICreateExecutionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1.ICreateExecutionRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IExecution, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1.IExecution, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1.IExecution, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1.IExecution, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createExecution response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createExecution request %j', request); - return this.innerApiCalls.createExecution(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createExecution response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createExecution(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1.IExecution, + protos.google.cloud.notebooks.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createExecution response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createExecution()`. - * @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/notebook_service.create_execution.js - * region_tag:notebooks_v1_generated_NotebookService_CreateExecution_async - */ - async checkCreateExecutionProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createExecution()`. + * @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/notebook_service.create_execution.js + * region_tag:notebooks_v1_generated_NotebookService_CreateExecution_async + */ + async checkCreateExecutionProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1.Execution, + protos.google.cloud.notebooks.v1.OperationMetadata + > + > { this._log.info('createExecution long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createExecution, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createExecution, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1.Execution, + protos.google.cloud.notebooks.v1.OperationMetadata + >; } - /** - * Lists instances in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing - * from the last result. - * @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 Array of {@link protos.google.cloud.notebooks.v1.Instance|Instance}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listInstancesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists instances in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing + * from the last result. + * @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 Array of {@link protos.google.cloud.notebooks.v1.Instance|Instance}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listInstances( - request?: protos.google.cloud.notebooks.v1.IListInstancesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1.IInstance[], - protos.google.cloud.notebooks.v1.IListInstancesRequest|null, - protos.google.cloud.notebooks.v1.IListInstancesResponse - ]>; + request?: protos.google.cloud.notebooks.v1.IListInstancesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.notebooks.v1.IInstance[], + protos.google.cloud.notebooks.v1.IListInstancesRequest | null, + protos.google.cloud.notebooks.v1.IListInstancesResponse, + ] + >; listInstances( - request: protos.google.cloud.notebooks.v1.IListInstancesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.notebooks.v1.IListInstancesRequest, - protos.google.cloud.notebooks.v1.IListInstancesResponse|null|undefined, - protos.google.cloud.notebooks.v1.IInstance>): void; + request: protos.google.cloud.notebooks.v1.IListInstancesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.notebooks.v1.IListInstancesRequest, + | protos.google.cloud.notebooks.v1.IListInstancesResponse + | null + | undefined, + protos.google.cloud.notebooks.v1.IInstance + >, + ): void; listInstances( - request: protos.google.cloud.notebooks.v1.IListInstancesRequest, - callback: PaginationCallback< - protos.google.cloud.notebooks.v1.IListInstancesRequest, - protos.google.cloud.notebooks.v1.IListInstancesResponse|null|undefined, - protos.google.cloud.notebooks.v1.IInstance>): void; + request: protos.google.cloud.notebooks.v1.IListInstancesRequest, + callback: PaginationCallback< + protos.google.cloud.notebooks.v1.IListInstancesRequest, + | protos.google.cloud.notebooks.v1.IListInstancesResponse + | null + | undefined, + protos.google.cloud.notebooks.v1.IInstance + >, + ): void; listInstances( - request?: protos.google.cloud.notebooks.v1.IListInstancesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.notebooks.v1.IListInstancesRequest, - protos.google.cloud.notebooks.v1.IListInstancesResponse|null|undefined, - protos.google.cloud.notebooks.v1.IInstance>, - callback?: PaginationCallback< + request?: protos.google.cloud.notebooks.v1.IListInstancesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.notebooks.v1.IListInstancesRequest, - protos.google.cloud.notebooks.v1.IListInstancesResponse|null|undefined, - protos.google.cloud.notebooks.v1.IInstance>): - Promise<[ - protos.google.cloud.notebooks.v1.IInstance[], - protos.google.cloud.notebooks.v1.IListInstancesRequest|null, - protos.google.cloud.notebooks.v1.IListInstancesResponse - ]>|void { + | protos.google.cloud.notebooks.v1.IListInstancesResponse + | null + | undefined, + protos.google.cloud.notebooks.v1.IInstance + >, + callback?: PaginationCallback< + protos.google.cloud.notebooks.v1.IListInstancesRequest, + | protos.google.cloud.notebooks.v1.IListInstancesResponse + | null + | undefined, + protos.google.cloud.notebooks.v1.IInstance + >, + ): Promise< + [ + protos.google.cloud.notebooks.v1.IInstance[], + protos.google.cloud.notebooks.v1.IListInstancesRequest | null, + protos.google.cloud.notebooks.v1.IListInstancesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.notebooks.v1.IListInstancesRequest, - protos.google.cloud.notebooks.v1.IListInstancesResponse|null|undefined, - protos.google.cloud.notebooks.v1.IInstance>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.notebooks.v1.IListInstancesRequest, + | protos.google.cloud.notebooks.v1.IListInstancesResponse + | null + | undefined, + protos.google.cloud.notebooks.v1.IInstance + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listInstances values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -3882,194 +5859,223 @@ export class NotebookServiceClient { this._log.info('listInstances request %j', request); return this.innerApiCalls .listInstances(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.notebooks.v1.IInstance[], - protos.google.cloud.notebooks.v1.IListInstancesRequest|null, - protos.google.cloud.notebooks.v1.IListInstancesResponse - ]) => { - this._log.info('listInstances values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.notebooks.v1.IInstance[], + protos.google.cloud.notebooks.v1.IListInstancesRequest | null, + protos.google.cloud.notebooks.v1.IListInstancesResponse, + ]) => { + this._log.info('listInstances values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listInstances`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing - * from the last result. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.notebooks.v1.Instance|Instance} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listInstancesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listInstances`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing + * from the last result. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.notebooks.v1.Instance|Instance} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listInstancesStream( - request?: protos.google.cloud.notebooks.v1.IListInstancesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.notebooks.v1.IListInstancesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listInstances']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listInstances stream %j', request); return this.descriptors.page.listInstances.createStream( this.innerApiCalls.listInstances as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listInstances`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing - * from the last result. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.notebooks.v1.Instance|Instance}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.list_instances.js - * region_tag:notebooks_v1_generated_NotebookService_ListInstances_async - */ + /** + * Equivalent to `listInstances`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing + * from the last result. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.notebooks.v1.Instance|Instance}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.list_instances.js + * region_tag:notebooks_v1_generated_NotebookService_ListInstances_async + */ listInstancesAsync( - request?: protos.google.cloud.notebooks.v1.IListInstancesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.notebooks.v1.IListInstancesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listInstances']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listInstances iterate %j', request); return this.descriptors.page.listInstances.asyncIterate( this.innerApiCalls['listInstances'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists environments in a project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: `projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing from - * the last result. - * @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 Array of {@link protos.google.cloud.notebooks.v1.Environment|Environment}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listEnvironmentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists environments in a project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: `projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing from + * the last result. + * @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 Array of {@link protos.google.cloud.notebooks.v1.Environment|Environment}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listEnvironmentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listEnvironments( - request?: protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1.IEnvironment[], - protos.google.cloud.notebooks.v1.IListEnvironmentsRequest|null, - protos.google.cloud.notebooks.v1.IListEnvironmentsResponse - ]>; + request?: protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.notebooks.v1.IEnvironment[], + protos.google.cloud.notebooks.v1.IListEnvironmentsRequest | null, + protos.google.cloud.notebooks.v1.IListEnvironmentsResponse, + ] + >; listEnvironments( - request: protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, - protos.google.cloud.notebooks.v1.IListEnvironmentsResponse|null|undefined, - protos.google.cloud.notebooks.v1.IEnvironment>): void; + request: protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, + | protos.google.cloud.notebooks.v1.IListEnvironmentsResponse + | null + | undefined, + protos.google.cloud.notebooks.v1.IEnvironment + >, + ): void; listEnvironments( - request: protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, - callback: PaginationCallback< - protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, - protos.google.cloud.notebooks.v1.IListEnvironmentsResponse|null|undefined, - protos.google.cloud.notebooks.v1.IEnvironment>): void; + request: protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, + callback: PaginationCallback< + protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, + | protos.google.cloud.notebooks.v1.IListEnvironmentsResponse + | null + | undefined, + protos.google.cloud.notebooks.v1.IEnvironment + >, + ): void; listEnvironments( - request?: protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, - protos.google.cloud.notebooks.v1.IListEnvironmentsResponse|null|undefined, - protos.google.cloud.notebooks.v1.IEnvironment>, - callback?: PaginationCallback< + request?: protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, - protos.google.cloud.notebooks.v1.IListEnvironmentsResponse|null|undefined, - protos.google.cloud.notebooks.v1.IEnvironment>): - Promise<[ - protos.google.cloud.notebooks.v1.IEnvironment[], - protos.google.cloud.notebooks.v1.IListEnvironmentsRequest|null, - protos.google.cloud.notebooks.v1.IListEnvironmentsResponse - ]>|void { + | protos.google.cloud.notebooks.v1.IListEnvironmentsResponse + | null + | undefined, + protos.google.cloud.notebooks.v1.IEnvironment + >, + callback?: PaginationCallback< + protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, + | protos.google.cloud.notebooks.v1.IListEnvironmentsResponse + | null + | undefined, + protos.google.cloud.notebooks.v1.IEnvironment + >, + ): Promise< + [ + protos.google.cloud.notebooks.v1.IEnvironment[], + protos.google.cloud.notebooks.v1.IListEnvironmentsRequest | null, + protos.google.cloud.notebooks.v1.IListEnvironmentsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, - protos.google.cloud.notebooks.v1.IListEnvironmentsResponse|null|undefined, - protos.google.cloud.notebooks.v1.IEnvironment>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, + | protos.google.cloud.notebooks.v1.IListEnvironmentsResponse + | null + | undefined, + protos.google.cloud.notebooks.v1.IEnvironment + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listEnvironments values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -4078,197 +6084,226 @@ export class NotebookServiceClient { this._log.info('listEnvironments request %j', request); return this.innerApiCalls .listEnvironments(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.notebooks.v1.IEnvironment[], - protos.google.cloud.notebooks.v1.IListEnvironmentsRequest|null, - protos.google.cloud.notebooks.v1.IListEnvironmentsResponse - ]) => { - this._log.info('listEnvironments values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.notebooks.v1.IEnvironment[], + protos.google.cloud.notebooks.v1.IListEnvironmentsRequest | null, + protos.google.cloud.notebooks.v1.IListEnvironmentsResponse, + ]) => { + this._log.info('listEnvironments values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listEnvironments`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: `projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing from - * the last result. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.notebooks.v1.Environment|Environment} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listEnvironmentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listEnvironments`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: `projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing from + * the last result. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.notebooks.v1.Environment|Environment} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listEnvironmentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listEnvironmentsStream( - request?: protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listEnvironments']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listEnvironments stream %j', request); return this.descriptors.page.listEnvironments.createStream( this.innerApiCalls.listEnvironments as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listEnvironments`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: `projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing from - * the last result. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.notebooks.v1.Environment|Environment}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.list_environments.js - * region_tag:notebooks_v1_generated_NotebookService_ListEnvironments_async - */ + /** + * Equivalent to `listEnvironments`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: `projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing from + * the last result. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.notebooks.v1.Environment|Environment}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.list_environments.js + * region_tag:notebooks_v1_generated_NotebookService_ListEnvironments_async + */ listEnvironmentsAsync( - request?: protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.notebooks.v1.IListEnvironmentsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listEnvironments']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listEnvironments iterate %j', request); return this.descriptors.page.listEnvironments.asyncIterate( this.innerApiCalls['listEnvironments'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists schedules in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing - * from the last result. - * @param {string} request.filter - * Filter applied to resulting schedules. - * @param {string} request.orderBy - * Field to order results by. - * @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 Array of {@link protos.google.cloud.notebooks.v1.Schedule|Schedule}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listSchedulesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists schedules in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing + * from the last result. + * @param {string} request.filter + * Filter applied to resulting schedules. + * @param {string} request.orderBy + * Field to order results by. + * @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 Array of {@link protos.google.cloud.notebooks.v1.Schedule|Schedule}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listSchedulesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listSchedules( - request?: protos.google.cloud.notebooks.v1.IListSchedulesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1.ISchedule[], - protos.google.cloud.notebooks.v1.IListSchedulesRequest|null, - protos.google.cloud.notebooks.v1.IListSchedulesResponse - ]>; + request?: protos.google.cloud.notebooks.v1.IListSchedulesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.notebooks.v1.ISchedule[], + protos.google.cloud.notebooks.v1.IListSchedulesRequest | null, + protos.google.cloud.notebooks.v1.IListSchedulesResponse, + ] + >; listSchedules( - request: protos.google.cloud.notebooks.v1.IListSchedulesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.notebooks.v1.IListSchedulesRequest, - protos.google.cloud.notebooks.v1.IListSchedulesResponse|null|undefined, - protos.google.cloud.notebooks.v1.ISchedule>): void; + request: protos.google.cloud.notebooks.v1.IListSchedulesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.notebooks.v1.IListSchedulesRequest, + | protos.google.cloud.notebooks.v1.IListSchedulesResponse + | null + | undefined, + protos.google.cloud.notebooks.v1.ISchedule + >, + ): void; listSchedules( - request: protos.google.cloud.notebooks.v1.IListSchedulesRequest, - callback: PaginationCallback< - protos.google.cloud.notebooks.v1.IListSchedulesRequest, - protos.google.cloud.notebooks.v1.IListSchedulesResponse|null|undefined, - protos.google.cloud.notebooks.v1.ISchedule>): void; + request: protos.google.cloud.notebooks.v1.IListSchedulesRequest, + callback: PaginationCallback< + protos.google.cloud.notebooks.v1.IListSchedulesRequest, + | protos.google.cloud.notebooks.v1.IListSchedulesResponse + | null + | undefined, + protos.google.cloud.notebooks.v1.ISchedule + >, + ): void; listSchedules( - request?: protos.google.cloud.notebooks.v1.IListSchedulesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.notebooks.v1.IListSchedulesRequest, - protos.google.cloud.notebooks.v1.IListSchedulesResponse|null|undefined, - protos.google.cloud.notebooks.v1.ISchedule>, - callback?: PaginationCallback< + request?: protos.google.cloud.notebooks.v1.IListSchedulesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.notebooks.v1.IListSchedulesRequest, - protos.google.cloud.notebooks.v1.IListSchedulesResponse|null|undefined, - protos.google.cloud.notebooks.v1.ISchedule>): - Promise<[ - protos.google.cloud.notebooks.v1.ISchedule[], - protos.google.cloud.notebooks.v1.IListSchedulesRequest|null, - protos.google.cloud.notebooks.v1.IListSchedulesResponse - ]>|void { + | protos.google.cloud.notebooks.v1.IListSchedulesResponse + | null + | undefined, + protos.google.cloud.notebooks.v1.ISchedule + >, + callback?: PaginationCallback< + protos.google.cloud.notebooks.v1.IListSchedulesRequest, + | protos.google.cloud.notebooks.v1.IListSchedulesResponse + | null + | undefined, + protos.google.cloud.notebooks.v1.ISchedule + >, + ): Promise< + [ + protos.google.cloud.notebooks.v1.ISchedule[], + protos.google.cloud.notebooks.v1.IListSchedulesRequest | null, + protos.google.cloud.notebooks.v1.IListSchedulesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.notebooks.v1.IListSchedulesRequest, - protos.google.cloud.notebooks.v1.IListSchedulesResponse|null|undefined, - protos.google.cloud.notebooks.v1.ISchedule>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.notebooks.v1.IListSchedulesRequest, + | protos.google.cloud.notebooks.v1.IListSchedulesResponse + | null + | undefined, + protos.google.cloud.notebooks.v1.ISchedule + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listSchedules values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -4277,209 +6312,238 @@ export class NotebookServiceClient { this._log.info('listSchedules request %j', request); return this.innerApiCalls .listSchedules(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.notebooks.v1.ISchedule[], - protos.google.cloud.notebooks.v1.IListSchedulesRequest|null, - protos.google.cloud.notebooks.v1.IListSchedulesResponse - ]) => { - this._log.info('listSchedules values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.notebooks.v1.ISchedule[], + protos.google.cloud.notebooks.v1.IListSchedulesRequest | null, + protos.google.cloud.notebooks.v1.IListSchedulesResponse, + ]) => { + this._log.info('listSchedules values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listSchedules`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing - * from the last result. - * @param {string} request.filter - * Filter applied to resulting schedules. - * @param {string} request.orderBy - * Field to order results by. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.notebooks.v1.Schedule|Schedule} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listSchedulesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listSchedules`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing + * from the last result. + * @param {string} request.filter + * Filter applied to resulting schedules. + * @param {string} request.orderBy + * Field to order results by. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.notebooks.v1.Schedule|Schedule} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listSchedulesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listSchedulesStream( - request?: protos.google.cloud.notebooks.v1.IListSchedulesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.notebooks.v1.IListSchedulesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listSchedules']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listSchedules stream %j', request); return this.descriptors.page.listSchedules.createStream( this.innerApiCalls.listSchedules as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listSchedules`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing - * from the last result. - * @param {string} request.filter - * Filter applied to resulting schedules. - * @param {string} request.orderBy - * Field to order results by. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.notebooks.v1.Schedule|Schedule}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.list_schedules.js - * region_tag:notebooks_v1_generated_NotebookService_ListSchedules_async - */ + /** + * Equivalent to `listSchedules`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing + * from the last result. + * @param {string} request.filter + * Filter applied to resulting schedules. + * @param {string} request.orderBy + * Field to order results by. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.notebooks.v1.Schedule|Schedule}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.list_schedules.js + * region_tag:notebooks_v1_generated_NotebookService_ListSchedules_async + */ listSchedulesAsync( - request?: protos.google.cloud.notebooks.v1.IListSchedulesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.notebooks.v1.IListSchedulesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listSchedules']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listSchedules iterate %j', request); return this.descriptors.page.listSchedules.asyncIterate( this.innerApiCalls['listSchedules'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists executions in a given project and location - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing - * from the last result. - * @param {string} request.filter - * Filter applied to resulting executions. Currently only supports filtering - * executions by a specified `schedule_id`. - * Format: `schedule_id=` - * @param {string} request.orderBy - * Sort by field. - * @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 Array of {@link protos.google.cloud.notebooks.v1.Execution|Execution}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listExecutionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists executions in a given project and location + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing + * from the last result. + * @param {string} request.filter + * Filter applied to resulting executions. Currently only supports filtering + * executions by a specified `schedule_id`. + * Format: `schedule_id=` + * @param {string} request.orderBy + * Sort by field. + * @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 Array of {@link protos.google.cloud.notebooks.v1.Execution|Execution}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listExecutionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listExecutions( - request?: protos.google.cloud.notebooks.v1.IListExecutionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1.IExecution[], - protos.google.cloud.notebooks.v1.IListExecutionsRequest|null, - protos.google.cloud.notebooks.v1.IListExecutionsResponse - ]>; + request?: protos.google.cloud.notebooks.v1.IListExecutionsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.notebooks.v1.IExecution[], + protos.google.cloud.notebooks.v1.IListExecutionsRequest | null, + protos.google.cloud.notebooks.v1.IListExecutionsResponse, + ] + >; listExecutions( - request: protos.google.cloud.notebooks.v1.IListExecutionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.notebooks.v1.IListExecutionsRequest, - protos.google.cloud.notebooks.v1.IListExecutionsResponse|null|undefined, - protos.google.cloud.notebooks.v1.IExecution>): void; + request: protos.google.cloud.notebooks.v1.IListExecutionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.notebooks.v1.IListExecutionsRequest, + | protos.google.cloud.notebooks.v1.IListExecutionsResponse + | null + | undefined, + protos.google.cloud.notebooks.v1.IExecution + >, + ): void; listExecutions( - request: protos.google.cloud.notebooks.v1.IListExecutionsRequest, - callback: PaginationCallback< - protos.google.cloud.notebooks.v1.IListExecutionsRequest, - protos.google.cloud.notebooks.v1.IListExecutionsResponse|null|undefined, - protos.google.cloud.notebooks.v1.IExecution>): void; + request: protos.google.cloud.notebooks.v1.IListExecutionsRequest, + callback: PaginationCallback< + protos.google.cloud.notebooks.v1.IListExecutionsRequest, + | protos.google.cloud.notebooks.v1.IListExecutionsResponse + | null + | undefined, + protos.google.cloud.notebooks.v1.IExecution + >, + ): void; listExecutions( - request?: protos.google.cloud.notebooks.v1.IListExecutionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.notebooks.v1.IListExecutionsRequest, - protos.google.cloud.notebooks.v1.IListExecutionsResponse|null|undefined, - protos.google.cloud.notebooks.v1.IExecution>, - callback?: PaginationCallback< + request?: protos.google.cloud.notebooks.v1.IListExecutionsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.notebooks.v1.IListExecutionsRequest, - protos.google.cloud.notebooks.v1.IListExecutionsResponse|null|undefined, - protos.google.cloud.notebooks.v1.IExecution>): - Promise<[ - protos.google.cloud.notebooks.v1.IExecution[], - protos.google.cloud.notebooks.v1.IListExecutionsRequest|null, - protos.google.cloud.notebooks.v1.IListExecutionsResponse - ]>|void { + | protos.google.cloud.notebooks.v1.IListExecutionsResponse + | null + | undefined, + protos.google.cloud.notebooks.v1.IExecution + >, + callback?: PaginationCallback< + protos.google.cloud.notebooks.v1.IListExecutionsRequest, + | protos.google.cloud.notebooks.v1.IListExecutionsResponse + | null + | undefined, + protos.google.cloud.notebooks.v1.IExecution + >, + ): Promise< + [ + protos.google.cloud.notebooks.v1.IExecution[], + protos.google.cloud.notebooks.v1.IListExecutionsRequest | null, + protos.google.cloud.notebooks.v1.IListExecutionsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.notebooks.v1.IListExecutionsRequest, - protos.google.cloud.notebooks.v1.IListExecutionsResponse|null|undefined, - protos.google.cloud.notebooks.v1.IExecution>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.notebooks.v1.IListExecutionsRequest, + | protos.google.cloud.notebooks.v1.IListExecutionsResponse + | null + | undefined, + protos.google.cloud.notebooks.v1.IExecution + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listExecutions values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -4488,149 +6552,153 @@ export class NotebookServiceClient { this._log.info('listExecutions request %j', request); return this.innerApiCalls .listExecutions(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.notebooks.v1.IExecution[], - protos.google.cloud.notebooks.v1.IListExecutionsRequest|null, - protos.google.cloud.notebooks.v1.IListExecutionsResponse - ]) => { - this._log.info('listExecutions values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.notebooks.v1.IExecution[], + protos.google.cloud.notebooks.v1.IListExecutionsRequest | null, + protos.google.cloud.notebooks.v1.IListExecutionsResponse, + ]) => { + this._log.info('listExecutions values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listExecutions`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing - * from the last result. - * @param {string} request.filter - * Filter applied to resulting executions. Currently only supports filtering - * executions by a specified `schedule_id`. - * Format: `schedule_id=` - * @param {string} request.orderBy - * Sort by field. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.notebooks.v1.Execution|Execution} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listExecutionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listExecutions`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing + * from the last result. + * @param {string} request.filter + * Filter applied to resulting executions. Currently only supports filtering + * executions by a specified `schedule_id`. + * Format: `schedule_id=` + * @param {string} request.orderBy + * Sort by field. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.notebooks.v1.Execution|Execution} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listExecutionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listExecutionsStream( - request?: protos.google.cloud.notebooks.v1.IListExecutionsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.notebooks.v1.IListExecutionsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listExecutions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listExecutions stream %j', request); return this.descriptors.page.listExecutions.createStream( this.innerApiCalls.listExecutions as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listExecutions`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing - * from the last result. - * @param {string} request.filter - * Filter applied to resulting executions. Currently only supports filtering - * executions by a specified `schedule_id`. - * Format: `schedule_id=` - * @param {string} request.orderBy - * Sort by field. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.notebooks.v1.Execution|Execution}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/notebook_service.list_executions.js - * region_tag:notebooks_v1_generated_NotebookService_ListExecutions_async - */ + /** + * Equivalent to `listExecutions`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing + * from the last result. + * @param {string} request.filter + * Filter applied to resulting executions. Currently only supports filtering + * executions by a specified `schedule_id`. + * Format: `schedule_id=` + * @param {string} request.orderBy + * Sort by field. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.notebooks.v1.Execution|Execution}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/notebook_service.list_executions.js + * region_tag:notebooks_v1_generated_NotebookService_ListExecutions_async + */ listExecutionsAsync( - request?: protos.google.cloud.notebooks.v1.IListExecutionsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.notebooks.v1.IListExecutionsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listExecutions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listExecutions iterate %j', request); return this.descriptors.page.listExecutions.asyncIterate( this.innerApiCalls['listExecutions'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -4644,40 +6712,40 @@ export class NotebookServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -4691,41 +6759,41 @@ export class NotebookServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -4739,12 +6807,12 @@ export class NotebookServiceClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -4779,12 +6847,11 @@ export class NotebookServiceClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -4817,12 +6884,12 @@ export class NotebookServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -4865,22 +6932,22 @@ export class NotebookServiceClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -4915,15 +6982,15 @@ export class NotebookServiceClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - 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 ?? '', - }); + 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 ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -4957,7 +7024,7 @@ export class NotebookServiceClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -4970,25 +7037,24 @@ export class NotebookServiceClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -5027,22 +7093,22 @@ export class NotebookServiceClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -5057,7 +7123,7 @@ export class NotebookServiceClient { * @param {string} environment * @returns {string} Resource name string. */ - environmentPath(project:string,environment:string) { + environmentPath(project: string, environment: string) { return this.pathTemplates.environmentPathTemplate.render({ project: project, environment: environment, @@ -5072,7 +7138,8 @@ export class NotebookServiceClient { * @returns {string} A string representing the project. */ matchProjectFromEnvironmentName(environmentName: string) { - return this.pathTemplates.environmentPathTemplate.match(environmentName).project; + return this.pathTemplates.environmentPathTemplate.match(environmentName) + .project; } /** @@ -5083,7 +7150,8 @@ export class NotebookServiceClient { * @returns {string} A string representing the environment. */ matchEnvironmentFromEnvironmentName(environmentName: string) { - return this.pathTemplates.environmentPathTemplate.match(environmentName).environment; + return this.pathTemplates.environmentPathTemplate.match(environmentName) + .environment; } /** @@ -5094,7 +7162,7 @@ export class NotebookServiceClient { * @param {string} execution * @returns {string} Resource name string. */ - executionPath(project:string,location:string,execution:string) { + executionPath(project: string, location: string, execution: string) { return this.pathTemplates.executionPathTemplate.render({ project: project, location: location, @@ -5110,7 +7178,8 @@ export class NotebookServiceClient { * @returns {string} A string representing the project. */ matchProjectFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).project; + return this.pathTemplates.executionPathTemplate.match(executionName) + .project; } /** @@ -5121,7 +7190,8 @@ export class NotebookServiceClient { * @returns {string} A string representing the location. */ matchLocationFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).location; + return this.pathTemplates.executionPathTemplate.match(executionName) + .location; } /** @@ -5132,7 +7202,8 @@ export class NotebookServiceClient { * @returns {string} A string representing the execution. */ matchExecutionFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).execution; + return this.pathTemplates.executionPathTemplate.match(executionName) + .execution; } /** @@ -5142,7 +7213,7 @@ export class NotebookServiceClient { * @param {string} instance * @returns {string} Resource name string. */ - instancePath(project:string,instance:string) { + instancePath(project: string, instance: string) { return this.pathTemplates.instancePathTemplate.render({ project: project, instance: instance, @@ -5179,7 +7250,7 @@ export class NotebookServiceClient { * @param {string} runtime * @returns {string} Resource name string. */ - runtimePath(project:string,location:string,runtime:string) { + runtimePath(project: string, location: string, runtime: string) { return this.pathTemplates.runtimePathTemplate.render({ project: project, location: location, @@ -5228,7 +7299,7 @@ export class NotebookServiceClient { * @param {string} schedule * @returns {string} Resource name string. */ - schedulePath(project:string,location:string,schedule:string) { + schedulePath(project: string, location: string, schedule: string) { return this.pathTemplates.schedulePathTemplate.render({ project: project, location: location, @@ -5277,15 +7348,19 @@ export class NotebookServiceClient { */ close(): Promise { if (this.notebookServiceStub && !this._terminated) { - return this.notebookServiceStub.then(stub => { + return this.notebookServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-notebooks/src/v1beta1/index.ts b/packages/google-cloud-notebooks/src/v1beta1/index.ts index 50a68eec5cd3..fc4fecc6e53a 100644 --- a/packages/google-cloud-notebooks/src/v1beta1/index.ts +++ b/packages/google-cloud-notebooks/src/v1beta1/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {NotebookServiceClient} from './notebook_service_client'; +export { NotebookServiceClient } from './notebook_service_client'; diff --git a/packages/google-cloud-notebooks/src/v1beta1/notebook_service_client.ts b/packages/google-cloud-notebooks/src/v1beta1/notebook_service_client.ts index 31f1d21293d1..3ae02d03fd20 100644 --- a/packages/google-cloud-notebooks/src/v1beta1/notebook_service_client.ts +++ b/packages/google-cloud-notebooks/src/v1beta1/notebook_service_client.ts @@ -18,11 +18,24 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -44,7 +57,7 @@ export class NotebookServiceClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('notebooks'); @@ -57,12 +70,12 @@ export class NotebookServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - notebookServiceStub?: Promise<{[name: string]: Function}>; + notebookServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of NotebookServiceClient. @@ -103,21 +116,42 @@ export class NotebookServiceClient { * const client = new NotebookServiceClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof NotebookServiceClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'notebooks.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -142,7 +176,7 @@ export class NotebookServiceClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -155,18 +189,14 @@ export class NotebookServiceClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -188,10 +218,10 @@ export class NotebookServiceClient { // Create useful helper objects for these. this.pathTemplates = { environmentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/environments/{environment}' + 'projects/{project}/environments/{environment}', ), instancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/instances/{instance}' + 'projects/{project}/instances/{instance}', ), }; @@ -199,10 +229,16 @@ export class NotebookServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listInstances: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'instances'), - listEnvironments: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'environments') + listInstances: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'instances', + ), + listEnvironments: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'environments', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -211,133 +247,232 @@ export class NotebookServiceClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1beta1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1beta1/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1beta1/{resource=projects/*/locations/*/instances/*}:getIamPolicy',},{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1beta1/{resource=projects/*/locations/*/instances/*}:setIamPolicy',body: '*',},{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1beta1/{resource=projects/*/locations/*/instances/*}:testIamPermissions',body: '*',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1beta1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1beta1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta1/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1beta1/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1beta1/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1beta1/{resource=projects/*/locations/*/instances/*}:getIamPolicy', + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1beta1/{resource=projects/*/locations/*/instances/*}:setIamPolicy', + body: '*', + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1beta1/{resource=projects/*/locations/*/instances/*}:testIamPermissions', + body: '*', + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1beta1/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1beta1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1beta1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1beta1/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v1beta1.Instance', + ) as gax.protobuf.Type; const createInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; const registerInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v1beta1.Instance', + ) as gax.protobuf.Type; const registerInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; const setInstanceAcceleratorResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v1beta1.Instance', + ) as gax.protobuf.Type; const setInstanceAcceleratorMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; const setInstanceMachineTypeResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v1beta1.Instance', + ) as gax.protobuf.Type; const setInstanceMachineTypeMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; const setInstanceLabelsResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v1beta1.Instance', + ) as gax.protobuf.Type; const setInstanceLabelsMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; const deleteInstanceResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; const startInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v1beta1.Instance', + ) as gax.protobuf.Type; const startInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; const stopInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v1beta1.Instance', + ) as gax.protobuf.Type; const stopInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; const resetInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v1beta1.Instance', + ) as gax.protobuf.Type; const resetInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; const reportInstanceInfoResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v1beta1.Instance', + ) as gax.protobuf.Type; const reportInstanceInfoMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; const upgradeInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v1beta1.Instance', + ) as gax.protobuf.Type; const upgradeInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; const upgradeInstanceInternalResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v1beta1.Instance', + ) as gax.protobuf.Type; const upgradeInstanceInternalMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; const createEnvironmentResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.Environment') as gax.protobuf.Type; + '.google.cloud.notebooks.v1beta1.Environment', + ) as gax.protobuf.Type; const createEnvironmentMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; const deleteEnvironmentResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteEnvironmentMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createInstanceResponse.decode.bind(createInstanceResponse), - createInstanceMetadata.decode.bind(createInstanceMetadata)), + createInstanceMetadata.decode.bind(createInstanceMetadata), + ), registerInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, registerInstanceResponse.decode.bind(registerInstanceResponse), - registerInstanceMetadata.decode.bind(registerInstanceMetadata)), + registerInstanceMetadata.decode.bind(registerInstanceMetadata), + ), setInstanceAccelerator: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - setInstanceAcceleratorResponse.decode.bind(setInstanceAcceleratorResponse), - setInstanceAcceleratorMetadata.decode.bind(setInstanceAcceleratorMetadata)), + setInstanceAcceleratorResponse.decode.bind( + setInstanceAcceleratorResponse, + ), + setInstanceAcceleratorMetadata.decode.bind( + setInstanceAcceleratorMetadata, + ), + ), setInstanceMachineType: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - setInstanceMachineTypeResponse.decode.bind(setInstanceMachineTypeResponse), - setInstanceMachineTypeMetadata.decode.bind(setInstanceMachineTypeMetadata)), + setInstanceMachineTypeResponse.decode.bind( + setInstanceMachineTypeResponse, + ), + setInstanceMachineTypeMetadata.decode.bind( + setInstanceMachineTypeMetadata, + ), + ), setInstanceLabels: new this._gaxModule.LongrunningDescriptor( this.operationsClient, setInstanceLabelsResponse.decode.bind(setInstanceLabelsResponse), - setInstanceLabelsMetadata.decode.bind(setInstanceLabelsMetadata)), + setInstanceLabelsMetadata.decode.bind(setInstanceLabelsMetadata), + ), deleteInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteInstanceResponse.decode.bind(deleteInstanceResponse), - deleteInstanceMetadata.decode.bind(deleteInstanceMetadata)), + deleteInstanceMetadata.decode.bind(deleteInstanceMetadata), + ), startInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, startInstanceResponse.decode.bind(startInstanceResponse), - startInstanceMetadata.decode.bind(startInstanceMetadata)), + startInstanceMetadata.decode.bind(startInstanceMetadata), + ), stopInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, stopInstanceResponse.decode.bind(stopInstanceResponse), - stopInstanceMetadata.decode.bind(stopInstanceMetadata)), + stopInstanceMetadata.decode.bind(stopInstanceMetadata), + ), resetInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, resetInstanceResponse.decode.bind(resetInstanceResponse), - resetInstanceMetadata.decode.bind(resetInstanceMetadata)), + resetInstanceMetadata.decode.bind(resetInstanceMetadata), + ), reportInstanceInfo: new this._gaxModule.LongrunningDescriptor( this.operationsClient, reportInstanceInfoResponse.decode.bind(reportInstanceInfoResponse), - reportInstanceInfoMetadata.decode.bind(reportInstanceInfoMetadata)), + reportInstanceInfoMetadata.decode.bind(reportInstanceInfoMetadata), + ), upgradeInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, upgradeInstanceResponse.decode.bind(upgradeInstanceResponse), - upgradeInstanceMetadata.decode.bind(upgradeInstanceMetadata)), + upgradeInstanceMetadata.decode.bind(upgradeInstanceMetadata), + ), upgradeInstanceInternal: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - upgradeInstanceInternalResponse.decode.bind(upgradeInstanceInternalResponse), - upgradeInstanceInternalMetadata.decode.bind(upgradeInstanceInternalMetadata)), + upgradeInstanceInternalResponse.decode.bind( + upgradeInstanceInternalResponse, + ), + upgradeInstanceInternalMetadata.decode.bind( + upgradeInstanceInternalMetadata, + ), + ), createEnvironment: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createEnvironmentResponse.decode.bind(createEnvironmentResponse), - createEnvironmentMetadata.decode.bind(createEnvironmentMetadata)), + createEnvironmentMetadata.decode.bind(createEnvironmentMetadata), + ), deleteEnvironment: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteEnvironmentResponse.decode.bind(deleteEnvironmentResponse), - deleteEnvironmentMetadata.decode.bind(deleteEnvironmentMetadata)) + deleteEnvironmentMetadata.decode.bind(deleteEnvironmentMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.notebooks.v1beta1.NotebookService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.notebooks.v1beta1.NotebookService', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -368,28 +503,53 @@ export class NotebookServiceClient { // Put together the "service stub" for // google.cloud.notebooks.v1beta1.NotebookService. this.notebookServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.notebooks.v1beta1.NotebookService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.notebooks.v1beta1.NotebookService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.notebooks.v1beta1.NotebookService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const notebookServiceStubMethods = - ['listInstances', 'getInstance', 'createInstance', 'registerInstance', 'setInstanceAccelerator', 'setInstanceMachineType', 'setInstanceLabels', 'deleteInstance', 'startInstance', 'stopInstance', 'resetInstance', 'reportInstanceInfo', 'isInstanceUpgradeable', 'upgradeInstance', 'upgradeInstanceInternal', 'listEnvironments', 'getEnvironment', 'createEnvironment', 'deleteEnvironment']; + const notebookServiceStubMethods = [ + 'listInstances', + 'getInstance', + 'createInstance', + 'registerInstance', + 'setInstanceAccelerator', + 'setInstanceMachineType', + 'setInstanceLabels', + 'deleteInstance', + 'startInstance', + 'stopInstance', + 'resetInstance', + 'reportInstanceInfo', + 'isInstanceUpgradeable', + 'upgradeInstance', + 'upgradeInstanceInternal', + 'listEnvironments', + 'getEnvironment', + 'createEnvironment', + 'deleteEnvironment', + ]; for (const methodName of notebookServiceStubMethods) { const callPromise = this.notebookServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -399,7 +559,7 @@ export class NotebookServiceClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -414,8 +574,14 @@ export class NotebookServiceClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'notebooks.googleapis.com'; } @@ -426,8 +592,14 @@ export class NotebookServiceClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'notebooks.googleapis.com'; } @@ -458,9 +630,7 @@ export class NotebookServiceClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -469,8 +639,9 @@ export class NotebookServiceClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -481,1944 +652,2989 @@ export class NotebookServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets details of a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @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 {@link protos.google.cloud.notebooks.v1beta1.Instance|Instance}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.get_instance.js - * region_tag:notebooks_v1beta1_generated_NotebookService_GetInstance_async - */ + /** + * Gets details of a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @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 {@link protos.google.cloud.notebooks.v1beta1.Instance|Instance}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.get_instance.js + * region_tag:notebooks_v1beta1_generated_NotebookService_GetInstance_async + */ getInstance( - request?: protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1beta1.IInstance, - protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest | undefined, + {} | undefined, + ] + >; getInstance( - request: protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.notebooks.v1beta1.IInstance, - protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.notebooks.v1beta1.IInstance, + | protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getInstance( - request: protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest, - callback: Callback< - protos.google.cloud.notebooks.v1beta1.IInstance, - protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest, + callback: Callback< + protos.google.cloud.notebooks.v1beta1.IInstance, + | protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getInstance( - request?: protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.notebooks.v1beta1.IInstance, - protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.notebooks.v1beta1.IInstance, - protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.notebooks.v1beta1.IInstance, - protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.notebooks.v1beta1.IInstance, + | protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getInstance request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.notebooks.v1beta1.IInstance, - protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.notebooks.v1beta1.IInstance, + | protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getInstance response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getInstance(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.notebooks.v1beta1.IInstance, - protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest|undefined, - {}|undefined - ]) => { - this._log.info('getInstance response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getInstance(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IGetInstanceRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getInstance response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Check if a notebook instance is upgradable. - * Deprecated. Please consider using v1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.notebookInstance - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @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 {@link protos.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableResponse|IsInstanceUpgradeableResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.is_instance_upgradeable.js - * region_tag:notebooks_v1beta1_generated_NotebookService_IsInstanceUpgradeable_async - * @deprecated IsInstanceUpgradeable is deprecated and may be removed in a future version. - */ + /** + * Check if a notebook instance is upgradable. + * Deprecated. Please consider using v1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.notebookInstance + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @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 {@link protos.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableResponse|IsInstanceUpgradeableResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.is_instance_upgradeable.js + * region_tag:notebooks_v1beta1_generated_NotebookService_IsInstanceUpgradeable_async + * @deprecated IsInstanceUpgradeable is deprecated and may be removed in a future version. + */ isInstanceUpgradeable( - request?: protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableResponse, - protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableResponse, + ( + | protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest + | undefined + ), + {} | undefined, + ] + >; isInstanceUpgradeable( - request: protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableResponse, - protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableResponse, + | protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest + | null + | undefined, + {} | null | undefined + >, + ): void; isInstanceUpgradeable( - request: protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest, - callback: Callback< - protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableResponse, - protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest, + callback: Callback< + protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableResponse, + | protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest + | null + | undefined, + {} | null | undefined + >, + ): void; isInstanceUpgradeable( - request?: protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableResponse, - protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableResponse, - protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableResponse, - protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableResponse, + | protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableResponse, + ( + | protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'notebook_instance': request.notebookInstance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + notebook_instance: request.notebookInstance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - this.warn('DEP$NotebookService-$IsInstanceUpgradeable','IsInstanceUpgradeable is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.warn( + 'DEP$NotebookService-$IsInstanceUpgradeable', + 'IsInstanceUpgradeable is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('isInstanceUpgradeable request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableResponse, - protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableResponse, + | protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('isInstanceUpgradeable response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.isInstanceUpgradeable(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableResponse, - protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest|undefined, - {}|undefined - ]) => { - this._log.info('isInstanceUpgradeable response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .isInstanceUpgradeable(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableResponse, + ( + | protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('isInstanceUpgradeable response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single Environment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/environments/{environment_id}` - * @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 {@link protos.google.cloud.notebooks.v1beta1.Environment|Environment}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.get_environment.js - * region_tag:notebooks_v1beta1_generated_NotebookService_GetEnvironment_async - */ + /** + * Gets details of a single Environment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/environments/{environment_id}` + * @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 {@link protos.google.cloud.notebooks.v1beta1.Environment|Environment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.get_environment.js + * region_tag:notebooks_v1beta1_generated_NotebookService_GetEnvironment_async + */ getEnvironment( - request?: protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1beta1.IEnvironment, - protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.notebooks.v1beta1.IEnvironment, + protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest | undefined, + {} | undefined, + ] + >; getEnvironment( - request: protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.notebooks.v1beta1.IEnvironment, - protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.notebooks.v1beta1.IEnvironment, + | protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getEnvironment( - request: protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest, - callback: Callback< - protos.google.cloud.notebooks.v1beta1.IEnvironment, - protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest, + callback: Callback< + protos.google.cloud.notebooks.v1beta1.IEnvironment, + | protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getEnvironment( - request?: protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.notebooks.v1beta1.IEnvironment, - protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.notebooks.v1beta1.IEnvironment, - protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.notebooks.v1beta1.IEnvironment, - protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.notebooks.v1beta1.IEnvironment, + | protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.notebooks.v1beta1.IEnvironment, + protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getEnvironment request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.notebooks.v1beta1.IEnvironment, - protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.notebooks.v1beta1.IEnvironment, + | protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getEnvironment response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getEnvironment(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.notebooks.v1beta1.IEnvironment, - protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest|undefined, - {}|undefined - ]) => { - this._log.info('getEnvironment response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getEnvironment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.notebooks.v1beta1.IEnvironment, + ( + | protos.google.cloud.notebooks.v1beta1.IGetEnvironmentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getEnvironment response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a new Instance in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {string} request.instanceId - * Required. User-defined unique ID of this instance. - * @param {google.cloud.notebooks.v1beta1.Instance} request.instance - * Required. The instance to be created. - * @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/v1beta1/notebook_service.create_instance.js - * region_tag:notebooks_v1beta1_generated_NotebookService_CreateInstance_async - */ + /** + * Creates a new Instance in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {string} request.instanceId + * Required. User-defined unique ID of this instance. + * @param {google.cloud.notebooks.v1beta1.Instance} request.instance + * Required. The instance to be created. + * @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/v1beta1/notebook_service.create_instance.js + * region_tag:notebooks_v1beta1_generated_NotebookService_CreateInstance_async + */ createInstance( - request?: protos.google.cloud.notebooks.v1beta1.ICreateInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1beta1.ICreateInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createInstance( - request: protos.google.cloud.notebooks.v1beta1.ICreateInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.ICreateInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createInstance( - request: protos.google.cloud.notebooks.v1beta1.ICreateInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.ICreateInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createInstance( - request?: protos.google.cloud.notebooks.v1beta1.ICreateInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1beta1.ICreateInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createInstance request %j', request); - return this.innerApiCalls.createInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createInstance()`. - * @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/v1beta1/notebook_service.create_instance.js - * region_tag:notebooks_v1beta1_generated_NotebookService_CreateInstance_async - */ - async checkCreateInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createInstance()`. + * @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/v1beta1/notebook_service.create_instance.js + * region_tag:notebooks_v1beta1_generated_NotebookService_CreateInstance_async + */ + async checkCreateInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1beta1.Instance, + protos.google.cloud.notebooks.v1beta1.OperationMetadata + > + > { this._log.info('createInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1beta1.Instance, + protos.google.cloud.notebooks.v1beta1.OperationMetadata + >; } -/** - * Registers an existing legacy notebook instance to the Notebooks API server. - * Legacy instances are instances created with the legacy Compute Engine - * calls. They are not manageable by the Notebooks API out of the box. This - * call makes these instances manageable by the Notebooks API. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {string} request.instanceId - * Required. User defined unique ID of this instance. The `instance_id` must - * be 1 to 63 characters long and contain only lowercase letters, - * numeric characters, and dashes. The first character must be a lowercase - * letter and the last character cannot be a dash. - * @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/v1beta1/notebook_service.register_instance.js - * region_tag:notebooks_v1beta1_generated_NotebookService_RegisterInstance_async - */ + /** + * Registers an existing legacy notebook instance to the Notebooks API server. + * Legacy instances are instances created with the legacy Compute Engine + * calls. They are not manageable by the Notebooks API out of the box. This + * call makes these instances manageable by the Notebooks API. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {string} request.instanceId + * Required. User defined unique ID of this instance. The `instance_id` must + * be 1 to 63 characters long and contain only lowercase letters, + * numeric characters, and dashes. The first character must be a lowercase + * letter and the last character cannot be a dash. + * @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/v1beta1/notebook_service.register_instance.js + * region_tag:notebooks_v1beta1_generated_NotebookService_RegisterInstance_async + */ registerInstance( - request?: protos.google.cloud.notebooks.v1beta1.IRegisterInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1beta1.IRegisterInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; registerInstance( - request: protos.google.cloud.notebooks.v1beta1.IRegisterInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.IRegisterInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; registerInstance( - request: protos.google.cloud.notebooks.v1beta1.IRegisterInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.IRegisterInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; registerInstance( - request?: protos.google.cloud.notebooks.v1beta1.IRegisterInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1beta1.IRegisterInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('registerInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('registerInstance request %j', request); - return this.innerApiCalls.registerInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('registerInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); - } -/** - * Check the status of the long running operation returned by `registerInstance()`. - * @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/v1beta1/notebook_service.register_instance.js - * region_tag:notebooks_v1beta1_generated_NotebookService_RegisterInstance_async - */ - async checkRegisterInstanceProgress(name: string): Promise>{ + return this.innerApiCalls + .registerInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('registerInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); + } + /** + * Check the status of the long running operation returned by `registerInstance()`. + * @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/v1beta1/notebook_service.register_instance.js + * region_tag:notebooks_v1beta1_generated_NotebookService_RegisterInstance_async + */ + async checkRegisterInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1beta1.Instance, + protos.google.cloud.notebooks.v1beta1.OperationMetadata + > + > { this._log.info('registerInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.registerInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.registerInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1beta1.Instance, + protos.google.cloud.notebooks.v1beta1.OperationMetadata + >; } -/** - * Updates the guest accelerators of a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {google.cloud.notebooks.v1beta1.Instance.AcceleratorType} request.type - * Required. Type of this accelerator. - * @param {number} request.coreCount - * Required. Count of cores of this accelerator. Note that not all combinations - * of `type` and `core_count` are valid. Check [GPUs on - * Compute Engine](https://cloud.google.com/compute/docs/gpus/#gpus-list) to - * find a valid combination. TPUs are not supported. - * @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/v1beta1/notebook_service.set_instance_accelerator.js - * region_tag:notebooks_v1beta1_generated_NotebookService_SetInstanceAccelerator_async - */ + /** + * Updates the guest accelerators of a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {google.cloud.notebooks.v1beta1.Instance.AcceleratorType} request.type + * Required. Type of this accelerator. + * @param {number} request.coreCount + * Required. Count of cores of this accelerator. Note that not all combinations + * of `type` and `core_count` are valid. Check [GPUs on + * Compute Engine](https://cloud.google.com/compute/docs/gpus/#gpus-list) to + * find a valid combination. TPUs are not supported. + * @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/v1beta1/notebook_service.set_instance_accelerator.js + * region_tag:notebooks_v1beta1_generated_NotebookService_SetInstanceAccelerator_async + */ setInstanceAccelerator( - request?: protos.google.cloud.notebooks.v1beta1.ISetInstanceAcceleratorRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1beta1.ISetInstanceAcceleratorRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; setInstanceAccelerator( - request: protos.google.cloud.notebooks.v1beta1.ISetInstanceAcceleratorRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.ISetInstanceAcceleratorRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; setInstanceAccelerator( - request: protos.google.cloud.notebooks.v1beta1.ISetInstanceAcceleratorRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.ISetInstanceAcceleratorRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; setInstanceAccelerator( - request?: protos.google.cloud.notebooks.v1beta1.ISetInstanceAcceleratorRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1beta1.ISetInstanceAcceleratorRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('setInstanceAccelerator response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('setInstanceAccelerator request %j', request); - return this.innerApiCalls.setInstanceAccelerator(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('setInstanceAccelerator response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .setInstanceAccelerator(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('setInstanceAccelerator response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `setInstanceAccelerator()`. - * @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/v1beta1/notebook_service.set_instance_accelerator.js - * region_tag:notebooks_v1beta1_generated_NotebookService_SetInstanceAccelerator_async - */ - async checkSetInstanceAcceleratorProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `setInstanceAccelerator()`. + * @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/v1beta1/notebook_service.set_instance_accelerator.js + * region_tag:notebooks_v1beta1_generated_NotebookService_SetInstanceAccelerator_async + */ + async checkSetInstanceAcceleratorProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1beta1.Instance, + protos.google.cloud.notebooks.v1beta1.OperationMetadata + > + > { this._log.info('setInstanceAccelerator long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.setInstanceAccelerator, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.setInstanceAccelerator, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1beta1.Instance, + protos.google.cloud.notebooks.v1beta1.OperationMetadata + >; } -/** - * Updates the machine type of a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {string} request.machineType - * Required. The [Compute Engine machine - * type](https://cloud.google.com/compute/docs/machine-types). - * @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/v1beta1/notebook_service.set_instance_machine_type.js - * region_tag:notebooks_v1beta1_generated_NotebookService_SetInstanceMachineType_async - */ + /** + * Updates the machine type of a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {string} request.machineType + * Required. The [Compute Engine machine + * type](https://cloud.google.com/compute/docs/machine-types). + * @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/v1beta1/notebook_service.set_instance_machine_type.js + * region_tag:notebooks_v1beta1_generated_NotebookService_SetInstanceMachineType_async + */ setInstanceMachineType( - request?: protos.google.cloud.notebooks.v1beta1.ISetInstanceMachineTypeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1beta1.ISetInstanceMachineTypeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; setInstanceMachineType( - request: protos.google.cloud.notebooks.v1beta1.ISetInstanceMachineTypeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.ISetInstanceMachineTypeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; setInstanceMachineType( - request: protos.google.cloud.notebooks.v1beta1.ISetInstanceMachineTypeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.ISetInstanceMachineTypeRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; setInstanceMachineType( - request?: protos.google.cloud.notebooks.v1beta1.ISetInstanceMachineTypeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1beta1.ISetInstanceMachineTypeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('setInstanceMachineType response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('setInstanceMachineType request %j', request); - return this.innerApiCalls.setInstanceMachineType(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('setInstanceMachineType response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .setInstanceMachineType(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('setInstanceMachineType response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `setInstanceMachineType()`. - * @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/v1beta1/notebook_service.set_instance_machine_type.js - * region_tag:notebooks_v1beta1_generated_NotebookService_SetInstanceMachineType_async - */ - async checkSetInstanceMachineTypeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `setInstanceMachineType()`. + * @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/v1beta1/notebook_service.set_instance_machine_type.js + * region_tag:notebooks_v1beta1_generated_NotebookService_SetInstanceMachineType_async + */ + async checkSetInstanceMachineTypeProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1beta1.Instance, + protos.google.cloud.notebooks.v1beta1.OperationMetadata + > + > { this._log.info('setInstanceMachineType long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.setInstanceMachineType, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.setInstanceMachineType, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1beta1.Instance, + protos.google.cloud.notebooks.v1beta1.OperationMetadata + >; } -/** - * Updates the labels of an Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {number[]} request.labels - * Labels to apply to this instance. - * These can be later modified by the setLabels method - * @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/v1beta1/notebook_service.set_instance_labels.js - * region_tag:notebooks_v1beta1_generated_NotebookService_SetInstanceLabels_async - */ + /** + * Updates the labels of an Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {number[]} request.labels + * Labels to apply to this instance. + * These can be later modified by the setLabels method + * @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/v1beta1/notebook_service.set_instance_labels.js + * region_tag:notebooks_v1beta1_generated_NotebookService_SetInstanceLabels_async + */ setInstanceLabels( - request?: protos.google.cloud.notebooks.v1beta1.ISetInstanceLabelsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1beta1.ISetInstanceLabelsRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; setInstanceLabels( - request: protos.google.cloud.notebooks.v1beta1.ISetInstanceLabelsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.ISetInstanceLabelsRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; setInstanceLabels( - request: protos.google.cloud.notebooks.v1beta1.ISetInstanceLabelsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.ISetInstanceLabelsRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; setInstanceLabels( - request?: protos.google.cloud.notebooks.v1beta1.ISetInstanceLabelsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1beta1.ISetInstanceLabelsRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('setInstanceLabels response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('setInstanceLabels request %j', request); - return this.innerApiCalls.setInstanceLabels(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('setInstanceLabels response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .setInstanceLabels(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('setInstanceLabels response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `setInstanceLabels()`. - * @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/v1beta1/notebook_service.set_instance_labels.js - * region_tag:notebooks_v1beta1_generated_NotebookService_SetInstanceLabels_async - */ - async checkSetInstanceLabelsProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `setInstanceLabels()`. + * @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/v1beta1/notebook_service.set_instance_labels.js + * region_tag:notebooks_v1beta1_generated_NotebookService_SetInstanceLabels_async + */ + async checkSetInstanceLabelsProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1beta1.Instance, + protos.google.cloud.notebooks.v1beta1.OperationMetadata + > + > { this._log.info('setInstanceLabels long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.setInstanceLabels, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.setInstanceLabels, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1beta1.Instance, + protos.google.cloud.notebooks.v1beta1.OperationMetadata + >; } -/** - * Deletes a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @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/v1beta1/notebook_service.delete_instance.js - * region_tag:notebooks_v1beta1_generated_NotebookService_DeleteInstance_async - */ + /** + * Deletes a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @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/v1beta1/notebook_service.delete_instance.js + * region_tag:notebooks_v1beta1_generated_NotebookService_DeleteInstance_async + */ deleteInstance( - request?: protos.google.cloud.notebooks.v1beta1.IDeleteInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1beta1.IDeleteInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteInstance( - request: protos.google.cloud.notebooks.v1beta1.IDeleteInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.IDeleteInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteInstance( - request: protos.google.cloud.notebooks.v1beta1.IDeleteInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.IDeleteInstanceRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteInstance( - request?: protos.google.cloud.notebooks.v1beta1.IDeleteInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1beta1.IDeleteInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteInstance request %j', request); - return this.innerApiCalls.deleteInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteInstance()`. - * @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/v1beta1/notebook_service.delete_instance.js - * region_tag:notebooks_v1beta1_generated_NotebookService_DeleteInstance_async - */ - async checkDeleteInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteInstance()`. + * @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/v1beta1/notebook_service.delete_instance.js + * region_tag:notebooks_v1beta1_generated_NotebookService_DeleteInstance_async + */ + async checkDeleteInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.notebooks.v1beta1.OperationMetadata + > + > { this._log.info('deleteInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.notebooks.v1beta1.OperationMetadata + >; } -/** - * Starts a notebook instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @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/v1beta1/notebook_service.start_instance.js - * region_tag:notebooks_v1beta1_generated_NotebookService_StartInstance_async - */ + /** + * Starts a notebook instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @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/v1beta1/notebook_service.start_instance.js + * region_tag:notebooks_v1beta1_generated_NotebookService_StartInstance_async + */ startInstance( - request?: protos.google.cloud.notebooks.v1beta1.IStartInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1beta1.IStartInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; startInstance( - request: protos.google.cloud.notebooks.v1beta1.IStartInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.IStartInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; startInstance( - request: protos.google.cloud.notebooks.v1beta1.IStartInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.IStartInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; startInstance( - request?: protos.google.cloud.notebooks.v1beta1.IStartInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1beta1.IStartInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('startInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('startInstance request %j', request); - return this.innerApiCalls.startInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('startInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .startInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('startInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `startInstance()`. - * @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/v1beta1/notebook_service.start_instance.js - * region_tag:notebooks_v1beta1_generated_NotebookService_StartInstance_async - */ - async checkStartInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `startInstance()`. + * @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/v1beta1/notebook_service.start_instance.js + * region_tag:notebooks_v1beta1_generated_NotebookService_StartInstance_async + */ + async checkStartInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1beta1.Instance, + protos.google.cloud.notebooks.v1beta1.OperationMetadata + > + > { this._log.info('startInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.startInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.startInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1beta1.Instance, + protos.google.cloud.notebooks.v1beta1.OperationMetadata + >; } -/** - * Stops a notebook instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @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/v1beta1/notebook_service.stop_instance.js - * region_tag:notebooks_v1beta1_generated_NotebookService_StopInstance_async - */ + /** + * Stops a notebook instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @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/v1beta1/notebook_service.stop_instance.js + * region_tag:notebooks_v1beta1_generated_NotebookService_StopInstance_async + */ stopInstance( - request?: protos.google.cloud.notebooks.v1beta1.IStopInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1beta1.IStopInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; stopInstance( - request: protos.google.cloud.notebooks.v1beta1.IStopInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.IStopInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; stopInstance( - request: protos.google.cloud.notebooks.v1beta1.IStopInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.IStopInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; stopInstance( - request?: protos.google.cloud.notebooks.v1beta1.IStopInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1beta1.IStopInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('stopInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('stopInstance request %j', request); - return this.innerApiCalls.stopInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('stopInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .stopInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('stopInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `stopInstance()`. - * @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/v1beta1/notebook_service.stop_instance.js - * region_tag:notebooks_v1beta1_generated_NotebookService_StopInstance_async - */ - async checkStopInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `stopInstance()`. + * @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/v1beta1/notebook_service.stop_instance.js + * region_tag:notebooks_v1beta1_generated_NotebookService_StopInstance_async + */ + async checkStopInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1beta1.Instance, + protos.google.cloud.notebooks.v1beta1.OperationMetadata + > + > { this._log.info('stopInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.stopInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.stopInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1beta1.Instance, + protos.google.cloud.notebooks.v1beta1.OperationMetadata + >; } -/** - * Resets a notebook instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @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/v1beta1/notebook_service.reset_instance.js - * region_tag:notebooks_v1beta1_generated_NotebookService_ResetInstance_async - */ + /** + * Resets a notebook instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @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/v1beta1/notebook_service.reset_instance.js + * region_tag:notebooks_v1beta1_generated_NotebookService_ResetInstance_async + */ resetInstance( - request?: protos.google.cloud.notebooks.v1beta1.IResetInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1beta1.IResetInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; resetInstance( - request: protos.google.cloud.notebooks.v1beta1.IResetInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.IResetInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; resetInstance( - request: protos.google.cloud.notebooks.v1beta1.IResetInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.IResetInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; resetInstance( - request?: protos.google.cloud.notebooks.v1beta1.IResetInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1beta1.IResetInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('resetInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('resetInstance request %j', request); - return this.innerApiCalls.resetInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('resetInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .resetInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('resetInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `resetInstance()`. - * @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/v1beta1/notebook_service.reset_instance.js - * region_tag:notebooks_v1beta1_generated_NotebookService_ResetInstance_async - */ - async checkResetInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `resetInstance()`. + * @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/v1beta1/notebook_service.reset_instance.js + * region_tag:notebooks_v1beta1_generated_NotebookService_ResetInstance_async + */ + async checkResetInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1beta1.Instance, + protos.google.cloud.notebooks.v1beta1.OperationMetadata + > + > { this._log.info('resetInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.resetInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.resetInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1beta1.Instance, + protos.google.cloud.notebooks.v1beta1.OperationMetadata + >; } -/** - * Allows notebook instances to - * report their latest instance information to the Notebooks - * API server. The server will merge the reported information to - * the instance metadata store. Do not use this method directly. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {string} request.vmId - * Required. The VM hardware token for authenticating the VM. - * https://cloud.google.com/compute/docs/instances/verifying-instance-identity - * @param {number[]} request.metadata - * The metadata reported to Notebooks API. This will be merged to the instance - * metadata store - * @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/v1beta1/notebook_service.report_instance_info.js - * region_tag:notebooks_v1beta1_generated_NotebookService_ReportInstanceInfo_async - */ + /** + * Allows notebook instances to + * report their latest instance information to the Notebooks + * API server. The server will merge the reported information to + * the instance metadata store. Do not use this method directly. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {string} request.vmId + * Required. The VM hardware token for authenticating the VM. + * https://cloud.google.com/compute/docs/instances/verifying-instance-identity + * @param {number[]} request.metadata + * The metadata reported to Notebooks API. This will be merged to the instance + * metadata store + * @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/v1beta1/notebook_service.report_instance_info.js + * region_tag:notebooks_v1beta1_generated_NotebookService_ReportInstanceInfo_async + */ reportInstanceInfo( - request?: protos.google.cloud.notebooks.v1beta1.IReportInstanceInfoRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1beta1.IReportInstanceInfoRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; reportInstanceInfo( - request: protos.google.cloud.notebooks.v1beta1.IReportInstanceInfoRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.IReportInstanceInfoRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; reportInstanceInfo( - request: protos.google.cloud.notebooks.v1beta1.IReportInstanceInfoRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.IReportInstanceInfoRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; reportInstanceInfo( - request?: protos.google.cloud.notebooks.v1beta1.IReportInstanceInfoRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1beta1.IReportInstanceInfoRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('reportInstanceInfo response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('reportInstanceInfo request %j', request); - return this.innerApiCalls.reportInstanceInfo(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('reportInstanceInfo response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .reportInstanceInfo(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('reportInstanceInfo response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `reportInstanceInfo()`. - * @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/v1beta1/notebook_service.report_instance_info.js - * region_tag:notebooks_v1beta1_generated_NotebookService_ReportInstanceInfo_async - */ - async checkReportInstanceInfoProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `reportInstanceInfo()`. + * @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/v1beta1/notebook_service.report_instance_info.js + * region_tag:notebooks_v1beta1_generated_NotebookService_ReportInstanceInfo_async + */ + async checkReportInstanceInfoProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1beta1.Instance, + protos.google.cloud.notebooks.v1beta1.OperationMetadata + > + > { this._log.info('reportInstanceInfo long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.reportInstanceInfo, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.reportInstanceInfo, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1beta1.Instance, + protos.google.cloud.notebooks.v1beta1.OperationMetadata + >; } -/** - * Upgrades a notebook instance to the latest version. - * Deprecated. Please consider using v1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @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/v1beta1/notebook_service.upgrade_instance.js - * region_tag:notebooks_v1beta1_generated_NotebookService_UpgradeInstance_async - * @deprecated UpgradeInstance is deprecated and may be removed in a future version. - */ + /** + * Upgrades a notebook instance to the latest version. + * Deprecated. Please consider using v1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @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/v1beta1/notebook_service.upgrade_instance.js + * region_tag:notebooks_v1beta1_generated_NotebookService_UpgradeInstance_async + * @deprecated UpgradeInstance is deprecated and may be removed in a future version. + */ upgradeInstance( - request?: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; upgradeInstance( - request: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; upgradeInstance( - request: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; upgradeInstance( - request?: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - this.warn('DEP$NotebookService-$UpgradeInstance','UpgradeInstance is deprecated and may be removed in a future version.', 'DeprecationWarning'); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + this.warn( + 'DEP$NotebookService-$UpgradeInstance', + 'UpgradeInstance is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('upgradeInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('upgradeInstance request %j', request); - return this.innerApiCalls.upgradeInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('upgradeInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .upgradeInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('upgradeInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `upgradeInstance()`. - * @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/v1beta1/notebook_service.upgrade_instance.js - * region_tag:notebooks_v1beta1_generated_NotebookService_UpgradeInstance_async - * @deprecated UpgradeInstance is deprecated and may be removed in a future version. - */ - async checkUpgradeInstanceProgress(name: string): Promise>{ - this.warn('DEP$NotebookService-$checkUpgradeInstanceProgress','checkUpgradeInstanceProgress is deprecated and may be removed in a future version.', 'DeprecationWarning'); + /** + * Check the status of the long running operation returned by `upgradeInstance()`. + * @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/v1beta1/notebook_service.upgrade_instance.js + * region_tag:notebooks_v1beta1_generated_NotebookService_UpgradeInstance_async + * @deprecated UpgradeInstance is deprecated and may be removed in a future version. + */ + async checkUpgradeInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1beta1.Instance, + protos.google.cloud.notebooks.v1beta1.OperationMetadata + > + > { + this.warn( + 'DEP$NotebookService-$checkUpgradeInstanceProgress', + 'checkUpgradeInstanceProgress is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('upgradeInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.upgradeInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.upgradeInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1beta1.Instance, + protos.google.cloud.notebooks.v1beta1.OperationMetadata + >; } -/** - * Allows notebook instances to - * call this endpoint to upgrade themselves. Do not use this method directly. - * Deprecated. Please consider using v1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {string} request.vmId - * Required. The VM hardware token for authenticating the VM. - * https://cloud.google.com/compute/docs/instances/verifying-instance-identity - * @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/v1beta1/notebook_service.upgrade_instance_internal.js - * region_tag:notebooks_v1beta1_generated_NotebookService_UpgradeInstanceInternal_async - * @deprecated UpgradeInstanceInternal is deprecated and may be removed in a future version. - */ + /** + * Allows notebook instances to + * call this endpoint to upgrade themselves. Do not use this method directly. + * Deprecated. Please consider using v1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {string} request.vmId + * Required. The VM hardware token for authenticating the VM. + * https://cloud.google.com/compute/docs/instances/verifying-instance-identity + * @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/v1beta1/notebook_service.upgrade_instance_internal.js + * region_tag:notebooks_v1beta1_generated_NotebookService_UpgradeInstanceInternal_async + * @deprecated UpgradeInstanceInternal is deprecated and may be removed in a future version. + */ upgradeInstanceInternal( - request?: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceInternalRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceInternalRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; upgradeInstanceInternal( - request: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceInternalRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceInternalRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; upgradeInstanceInternal( - request: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceInternalRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceInternalRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; upgradeInstanceInternal( - request?: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceInternalRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1beta1.IUpgradeInstanceInternalRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - this.warn('DEP$NotebookService-$UpgradeInstanceInternal','UpgradeInstanceInternal is deprecated and may be removed in a future version.', 'DeprecationWarning'); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + this.warn( + 'DEP$NotebookService-$UpgradeInstanceInternal', + 'UpgradeInstanceInternal is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('upgradeInstanceInternal response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('upgradeInstanceInternal request %j', request); - return this.innerApiCalls.upgradeInstanceInternal(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('upgradeInstanceInternal response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .upgradeInstanceInternal(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('upgradeInstanceInternal response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `upgradeInstanceInternal()`. - * @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/v1beta1/notebook_service.upgrade_instance_internal.js - * region_tag:notebooks_v1beta1_generated_NotebookService_UpgradeInstanceInternal_async - * @deprecated UpgradeInstanceInternal is deprecated and may be removed in a future version. - */ - async checkUpgradeInstanceInternalProgress(name: string): Promise>{ - this.warn('DEP$NotebookService-$checkUpgradeInstanceInternalProgress','checkUpgradeInstanceInternalProgress is deprecated and may be removed in a future version.', 'DeprecationWarning'); + /** + * Check the status of the long running operation returned by `upgradeInstanceInternal()`. + * @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/v1beta1/notebook_service.upgrade_instance_internal.js + * region_tag:notebooks_v1beta1_generated_NotebookService_UpgradeInstanceInternal_async + * @deprecated UpgradeInstanceInternal is deprecated and may be removed in a future version. + */ + async checkUpgradeInstanceInternalProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1beta1.Instance, + protos.google.cloud.notebooks.v1beta1.OperationMetadata + > + > { + this.warn( + 'DEP$NotebookService-$checkUpgradeInstanceInternalProgress', + 'checkUpgradeInstanceInternalProgress is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('upgradeInstanceInternal long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.upgradeInstanceInternal, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.upgradeInstanceInternal, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1beta1.Instance, + protos.google.cloud.notebooks.v1beta1.OperationMetadata + >; } -/** - * Creates a new Environment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: `projects/{project_id}/locations/{location}` - * @param {string} request.environmentId - * Required. User-defined unique ID of this environment. The `environment_id` must - * be 1 to 63 characters long and contain only lowercase letters, - * numeric characters, and dashes. The first character must be a lowercase - * letter and the last character cannot be a dash. - * @param {google.cloud.notebooks.v1beta1.Environment} request.environment - * Required. The environment to be created. - * @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/v1beta1/notebook_service.create_environment.js - * region_tag:notebooks_v1beta1_generated_NotebookService_CreateEnvironment_async - */ + /** + * Creates a new Environment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: `projects/{project_id}/locations/{location}` + * @param {string} request.environmentId + * Required. User-defined unique ID of this environment. The `environment_id` must + * be 1 to 63 characters long and contain only lowercase letters, + * numeric characters, and dashes. The first character must be a lowercase + * letter and the last character cannot be a dash. + * @param {google.cloud.notebooks.v1beta1.Environment} request.environment + * Required. The environment to be created. + * @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/v1beta1/notebook_service.create_environment.js + * region_tag:notebooks_v1beta1_generated_NotebookService_CreateEnvironment_async + */ createEnvironment( - request?: protos.google.cloud.notebooks.v1beta1.ICreateEnvironmentRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1beta1.ICreateEnvironmentRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IEnvironment, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createEnvironment( - request: protos.google.cloud.notebooks.v1beta1.ICreateEnvironmentRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.ICreateEnvironmentRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IEnvironment, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createEnvironment( - request: protos.google.cloud.notebooks.v1beta1.ICreateEnvironmentRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.ICreateEnvironmentRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IEnvironment, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createEnvironment( - request?: protos.google.cloud.notebooks.v1beta1.ICreateEnvironmentRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1beta1.ICreateEnvironmentRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IEnvironment, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IEnvironment, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IEnvironment, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v1beta1.IEnvironment, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createEnvironment response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createEnvironment request %j', request); - return this.innerApiCalls.createEnvironment(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createEnvironment response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createEnvironment(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v1beta1.IEnvironment, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createEnvironment response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createEnvironment()`. - * @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/v1beta1/notebook_service.create_environment.js - * region_tag:notebooks_v1beta1_generated_NotebookService_CreateEnvironment_async - */ - async checkCreateEnvironmentProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createEnvironment()`. + * @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/v1beta1/notebook_service.create_environment.js + * region_tag:notebooks_v1beta1_generated_NotebookService_CreateEnvironment_async + */ + async checkCreateEnvironmentProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v1beta1.Environment, + protos.google.cloud.notebooks.v1beta1.OperationMetadata + > + > { this._log.info('createEnvironment long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createEnvironment, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createEnvironment, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v1beta1.Environment, + protos.google.cloud.notebooks.v1beta1.OperationMetadata + >; } -/** - * Deletes a single Environment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/environments/{environment_id}` - * @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/v1beta1/notebook_service.delete_environment.js - * region_tag:notebooks_v1beta1_generated_NotebookService_DeleteEnvironment_async - */ + /** + * Deletes a single Environment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/environments/{environment_id}` + * @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/v1beta1/notebook_service.delete_environment.js + * region_tag:notebooks_v1beta1_generated_NotebookService_DeleteEnvironment_async + */ deleteEnvironment( - request?: protos.google.cloud.notebooks.v1beta1.IDeleteEnvironmentRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v1beta1.IDeleteEnvironmentRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteEnvironment( - request: protos.google.cloud.notebooks.v1beta1.IDeleteEnvironmentRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.IDeleteEnvironmentRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteEnvironment( - request: protos.google.cloud.notebooks.v1beta1.IDeleteEnvironmentRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v1beta1.IDeleteEnvironmentRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteEnvironment( - request?: protos.google.cloud.notebooks.v1beta1.IDeleteEnvironmentRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v1beta1.IDeleteEnvironmentRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteEnvironment response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteEnvironment request %j', request); - return this.innerApiCalls.deleteEnvironment(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteEnvironment response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteEnvironment(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteEnvironment response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteEnvironment()`. - * @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/v1beta1/notebook_service.delete_environment.js - * region_tag:notebooks_v1beta1_generated_NotebookService_DeleteEnvironment_async - */ - async checkDeleteEnvironmentProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteEnvironment()`. + * @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/v1beta1/notebook_service.delete_environment.js + * region_tag:notebooks_v1beta1_generated_NotebookService_DeleteEnvironment_async + */ + async checkDeleteEnvironmentProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.notebooks.v1beta1.OperationMetadata + > + > { this._log.info('deleteEnvironment long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteEnvironment, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteEnvironment, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.notebooks.v1beta1.OperationMetadata + >; } - /** - * Lists instances in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing - * from the last result. - * @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 Array of {@link protos.google.cloud.notebooks.v1beta1.Instance|Instance}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listInstancesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists instances in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing + * from the last result. + * @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 Array of {@link protos.google.cloud.notebooks.v1beta1.Instance|Instance}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listInstances( - request?: protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1beta1.IInstance[], - protos.google.cloud.notebooks.v1beta1.IListInstancesRequest|null, - protos.google.cloud.notebooks.v1beta1.IListInstancesResponse - ]>; + request?: protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.notebooks.v1beta1.IInstance[], + protos.google.cloud.notebooks.v1beta1.IListInstancesRequest | null, + protos.google.cloud.notebooks.v1beta1.IListInstancesResponse, + ] + >; listInstances( - request: protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, - protos.google.cloud.notebooks.v1beta1.IListInstancesResponse|null|undefined, - protos.google.cloud.notebooks.v1beta1.IInstance>): void; + request: protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, + | protos.google.cloud.notebooks.v1beta1.IListInstancesResponse + | null + | undefined, + protos.google.cloud.notebooks.v1beta1.IInstance + >, + ): void; listInstances( - request: protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, - callback: PaginationCallback< - protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, - protos.google.cloud.notebooks.v1beta1.IListInstancesResponse|null|undefined, - protos.google.cloud.notebooks.v1beta1.IInstance>): void; + request: protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, + callback: PaginationCallback< + protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, + | protos.google.cloud.notebooks.v1beta1.IListInstancesResponse + | null + | undefined, + protos.google.cloud.notebooks.v1beta1.IInstance + >, + ): void; listInstances( - request?: protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, - protos.google.cloud.notebooks.v1beta1.IListInstancesResponse|null|undefined, - protos.google.cloud.notebooks.v1beta1.IInstance>, - callback?: PaginationCallback< + request?: protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, - protos.google.cloud.notebooks.v1beta1.IListInstancesResponse|null|undefined, - protos.google.cloud.notebooks.v1beta1.IInstance>): - Promise<[ - protos.google.cloud.notebooks.v1beta1.IInstance[], - protos.google.cloud.notebooks.v1beta1.IListInstancesRequest|null, - protos.google.cloud.notebooks.v1beta1.IListInstancesResponse - ]>|void { + | protos.google.cloud.notebooks.v1beta1.IListInstancesResponse + | null + | undefined, + protos.google.cloud.notebooks.v1beta1.IInstance + >, + callback?: PaginationCallback< + protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, + | protos.google.cloud.notebooks.v1beta1.IListInstancesResponse + | null + | undefined, + protos.google.cloud.notebooks.v1beta1.IInstance + >, + ): Promise< + [ + protos.google.cloud.notebooks.v1beta1.IInstance[], + protos.google.cloud.notebooks.v1beta1.IListInstancesRequest | null, + protos.google.cloud.notebooks.v1beta1.IListInstancesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, - protos.google.cloud.notebooks.v1beta1.IListInstancesResponse|null|undefined, - protos.google.cloud.notebooks.v1beta1.IInstance>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, + | protos.google.cloud.notebooks.v1beta1.IListInstancesResponse + | null + | undefined, + protos.google.cloud.notebooks.v1beta1.IInstance + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listInstances values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2427,194 +3643,223 @@ export class NotebookServiceClient { this._log.info('listInstances request %j', request); return this.innerApiCalls .listInstances(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.notebooks.v1beta1.IInstance[], - protos.google.cloud.notebooks.v1beta1.IListInstancesRequest|null, - protos.google.cloud.notebooks.v1beta1.IListInstancesResponse - ]) => { - this._log.info('listInstances values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.notebooks.v1beta1.IInstance[], + protos.google.cloud.notebooks.v1beta1.IListInstancesRequest | null, + protos.google.cloud.notebooks.v1beta1.IListInstancesResponse, + ]) => { + this._log.info('listInstances values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listInstances`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing - * from the last result. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.notebooks.v1beta1.Instance|Instance} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listInstancesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listInstances`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing + * from the last result. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.notebooks.v1beta1.Instance|Instance} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listInstancesStream( - request?: protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listInstances']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listInstances stream %j', request); return this.descriptors.page.listInstances.createStream( this.innerApiCalls.listInstances as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listInstances`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing - * from the last result. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.notebooks.v1beta1.Instance|Instance}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.list_instances.js - * region_tag:notebooks_v1beta1_generated_NotebookService_ListInstances_async - */ + /** + * Equivalent to `listInstances`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing + * from the last result. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.notebooks.v1beta1.Instance|Instance}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.list_instances.js + * region_tag:notebooks_v1beta1_generated_NotebookService_ListInstances_async + */ listInstancesAsync( - request?: protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.notebooks.v1beta1.IListInstancesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listInstances']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listInstances iterate %j', request); return this.descriptors.page.listInstances.asyncIterate( this.innerApiCalls['listInstances'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists environments in a project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: `projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing from - * the last result. - * @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 Array of {@link protos.google.cloud.notebooks.v1beta1.Environment|Environment}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listEnvironmentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists environments in a project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: `projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing from + * the last result. + * @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 Array of {@link protos.google.cloud.notebooks.v1beta1.Environment|Environment}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listEnvironmentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listEnvironments( - request?: protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v1beta1.IEnvironment[], - protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest|null, - protos.google.cloud.notebooks.v1beta1.IListEnvironmentsResponse - ]>; + request?: protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.notebooks.v1beta1.IEnvironment[], + protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest | null, + protos.google.cloud.notebooks.v1beta1.IListEnvironmentsResponse, + ] + >; listEnvironments( - request: protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, - protos.google.cloud.notebooks.v1beta1.IListEnvironmentsResponse|null|undefined, - protos.google.cloud.notebooks.v1beta1.IEnvironment>): void; + request: protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, + | protos.google.cloud.notebooks.v1beta1.IListEnvironmentsResponse + | null + | undefined, + protos.google.cloud.notebooks.v1beta1.IEnvironment + >, + ): void; listEnvironments( - request: protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, - callback: PaginationCallback< - protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, - protos.google.cloud.notebooks.v1beta1.IListEnvironmentsResponse|null|undefined, - protos.google.cloud.notebooks.v1beta1.IEnvironment>): void; + request: protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, + callback: PaginationCallback< + protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, + | protos.google.cloud.notebooks.v1beta1.IListEnvironmentsResponse + | null + | undefined, + protos.google.cloud.notebooks.v1beta1.IEnvironment + >, + ): void; listEnvironments( - request?: protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, - protos.google.cloud.notebooks.v1beta1.IListEnvironmentsResponse|null|undefined, - protos.google.cloud.notebooks.v1beta1.IEnvironment>, - callback?: PaginationCallback< + request?: protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, - protos.google.cloud.notebooks.v1beta1.IListEnvironmentsResponse|null|undefined, - protos.google.cloud.notebooks.v1beta1.IEnvironment>): - Promise<[ - protos.google.cloud.notebooks.v1beta1.IEnvironment[], - protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest|null, - protos.google.cloud.notebooks.v1beta1.IListEnvironmentsResponse - ]>|void { + | protos.google.cloud.notebooks.v1beta1.IListEnvironmentsResponse + | null + | undefined, + protos.google.cloud.notebooks.v1beta1.IEnvironment + >, + callback?: PaginationCallback< + protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, + | protos.google.cloud.notebooks.v1beta1.IListEnvironmentsResponse + | null + | undefined, + protos.google.cloud.notebooks.v1beta1.IEnvironment + >, + ): Promise< + [ + protos.google.cloud.notebooks.v1beta1.IEnvironment[], + protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest | null, + protos.google.cloud.notebooks.v1beta1.IListEnvironmentsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, - protos.google.cloud.notebooks.v1beta1.IListEnvironmentsResponse|null|undefined, - protos.google.cloud.notebooks.v1beta1.IEnvironment>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, + | protos.google.cloud.notebooks.v1beta1.IListEnvironmentsResponse + | null + | undefined, + protos.google.cloud.notebooks.v1beta1.IEnvironment + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listEnvironments values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2623,135 +3868,139 @@ export class NotebookServiceClient { this._log.info('listEnvironments request %j', request); return this.innerApiCalls .listEnvironments(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.notebooks.v1beta1.IEnvironment[], - protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest|null, - protos.google.cloud.notebooks.v1beta1.IListEnvironmentsResponse - ]) => { - this._log.info('listEnvironments values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.notebooks.v1beta1.IEnvironment[], + protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest | null, + protos.google.cloud.notebooks.v1beta1.IListEnvironmentsResponse, + ]) => { + this._log.info('listEnvironments values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listEnvironments`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: `projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing from - * the last result. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.notebooks.v1beta1.Environment|Environment} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listEnvironmentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listEnvironments`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: `projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing from + * the last result. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.notebooks.v1beta1.Environment|Environment} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listEnvironmentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listEnvironmentsStream( - request?: protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listEnvironments']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listEnvironments stream %j', request); return this.descriptors.page.listEnvironments.createStream( this.innerApiCalls.listEnvironments as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listEnvironments`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: `projects/{project_id}/locations/{location}` - * @param {number} request.pageSize - * Maximum return size of the list call. - * @param {string} request.pageToken - * A previous returned page token that can be used to continue listing from - * the last result. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.notebooks.v1beta1.Environment|Environment}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/notebook_service.list_environments.js - * region_tag:notebooks_v1beta1_generated_NotebookService_ListEnvironments_async - */ + /** + * Equivalent to `listEnvironments`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: `projects/{project_id}/locations/{location}` + * @param {number} request.pageSize + * Maximum return size of the list call. + * @param {string} request.pageToken + * A previous returned page token that can be used to continue listing from + * the last result. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.notebooks.v1beta1.Environment|Environment}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/notebook_service.list_environments.js + * region_tag:notebooks_v1beta1_generated_NotebookService_ListEnvironments_async + */ listEnvironmentsAsync( - request?: protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.notebooks.v1beta1.IListEnvironmentsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listEnvironments']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listEnvironments iterate %j', request); return this.descriptors.page.listEnvironments.asyncIterate( this.innerApiCalls['listEnvironments'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -2765,40 +4014,40 @@ export class NotebookServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -2812,41 +4061,41 @@ export class NotebookServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -2860,12 +4109,12 @@ export class NotebookServiceClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -2900,12 +4149,11 @@ export class NotebookServiceClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -2938,12 +4186,12 @@ export class NotebookServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -2986,22 +4234,22 @@ export class NotebookServiceClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -3036,15 +4284,15 @@ export class NotebookServiceClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - 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 ?? '', - }); + 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 ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -3078,7 +4326,7 @@ export class NotebookServiceClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -3091,25 +4339,24 @@ export class NotebookServiceClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -3148,22 +4395,22 @@ export class NotebookServiceClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -3178,7 +4425,7 @@ export class NotebookServiceClient { * @param {string} environment * @returns {string} Resource name string. */ - environmentPath(project:string,environment:string) { + environmentPath(project: string, environment: string) { return this.pathTemplates.environmentPathTemplate.render({ project: project, environment: environment, @@ -3193,7 +4440,8 @@ export class NotebookServiceClient { * @returns {string} A string representing the project. */ matchProjectFromEnvironmentName(environmentName: string) { - return this.pathTemplates.environmentPathTemplate.match(environmentName).project; + return this.pathTemplates.environmentPathTemplate.match(environmentName) + .project; } /** @@ -3204,7 +4452,8 @@ export class NotebookServiceClient { * @returns {string} A string representing the environment. */ matchEnvironmentFromEnvironmentName(environmentName: string) { - return this.pathTemplates.environmentPathTemplate.match(environmentName).environment; + return this.pathTemplates.environmentPathTemplate.match(environmentName) + .environment; } /** @@ -3214,7 +4463,7 @@ export class NotebookServiceClient { * @param {string} instance * @returns {string} Resource name string. */ - instancePath(project:string,instance:string) { + instancePath(project: string, instance: string) { return this.pathTemplates.instancePathTemplate.render({ project: project, instance: instance, @@ -3251,15 +4500,19 @@ export class NotebookServiceClient { */ close(): Promise { if (this.notebookServiceStub && !this._terminated) { - return this.notebookServiceStub.then(stub => { + return this.notebookServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-notebooks/src/v2/index.ts b/packages/google-cloud-notebooks/src/v2/index.ts index 50a68eec5cd3..fc4fecc6e53a 100644 --- a/packages/google-cloud-notebooks/src/v2/index.ts +++ b/packages/google-cloud-notebooks/src/v2/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {NotebookServiceClient} from './notebook_service_client'; +export { NotebookServiceClient } from './notebook_service_client'; diff --git a/packages/google-cloud-notebooks/src/v2/notebook_service_client.ts b/packages/google-cloud-notebooks/src/v2/notebook_service_client.ts index 46aaa4c0f8ae..872ba1761569 100644 --- a/packages/google-cloud-notebooks/src/v2/notebook_service_client.ts +++ b/packages/google-cloud-notebooks/src/v2/notebook_service_client.ts @@ -18,11 +18,24 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -44,7 +57,7 @@ export class NotebookServiceClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('notebooks'); @@ -57,12 +70,12 @@ export class NotebookServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - notebookServiceStub?: Promise<{[name: string]: Function}>; + notebookServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of NotebookServiceClient. @@ -103,21 +116,42 @@ export class NotebookServiceClient { * const client = new NotebookServiceClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof NotebookServiceClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'notebooks.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -142,7 +176,7 @@ export class NotebookServiceClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -155,18 +189,14 @@ export class NotebookServiceClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -188,13 +218,13 @@ export class NotebookServiceClient { // Create useful helper objects for these. this.pathTemplates = { instancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/instances/{instance}' + 'projects/{project}/locations/{location}/instances/{instance}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), }; @@ -202,8 +232,11 @@ export class NotebookServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listInstances: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'instances') + listInstances: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'instances', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -212,93 +245,165 @@ export class NotebookServiceClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v2/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v2/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v2/{resource=projects/*/locations/*/instances/*}:getIamPolicy',},{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v2/{resource=projects/*/locations/*/instances/*}:setIamPolicy',body: '*',},{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v2/{resource=projects/*/locations/*/instances/*}:testIamPermissions',body: '*',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v2/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v2/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v2/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v2/{resource=projects/*/locations/*/instances/*}:getIamPolicy', + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v2/{resource=projects/*/locations/*/instances/*}:setIamPolicy', + body: '*', + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v2/{resource=projects/*/locations/*/instances/*}:testIamPermissions', + body: '*', + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v2/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v2/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v2/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v2/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v2.Instance', + ) as gax.protobuf.Type; const createInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v2.OperationMetadata', + ) as gax.protobuf.Type; const updateInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v2.Instance', + ) as gax.protobuf.Type; const updateInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v2.OperationMetadata', + ) as gax.protobuf.Type; const deleteInstanceResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v2.OperationMetadata', + ) as gax.protobuf.Type; const startInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v2.Instance', + ) as gax.protobuf.Type; const startInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v2.OperationMetadata', + ) as gax.protobuf.Type; const stopInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v2.Instance', + ) as gax.protobuf.Type; const stopInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v2.OperationMetadata', + ) as gax.protobuf.Type; const resetInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v2.Instance', + ) as gax.protobuf.Type; const resetInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v2.OperationMetadata', + ) as gax.protobuf.Type; const upgradeInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v2.Instance', + ) as gax.protobuf.Type; const upgradeInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v2.OperationMetadata', + ) as gax.protobuf.Type; const rollbackInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v2.Instance', + ) as gax.protobuf.Type; const rollbackInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v2.OperationMetadata', + ) as gax.protobuf.Type; const diagnoseInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.Instance') as gax.protobuf.Type; + '.google.cloud.notebooks.v2.Instance', + ) as gax.protobuf.Type; const diagnoseInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.notebooks.v2.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.notebooks.v2.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createInstanceResponse.decode.bind(createInstanceResponse), - createInstanceMetadata.decode.bind(createInstanceMetadata)), + createInstanceMetadata.decode.bind(createInstanceMetadata), + ), updateInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateInstanceResponse.decode.bind(updateInstanceResponse), - updateInstanceMetadata.decode.bind(updateInstanceMetadata)), + updateInstanceMetadata.decode.bind(updateInstanceMetadata), + ), deleteInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteInstanceResponse.decode.bind(deleteInstanceResponse), - deleteInstanceMetadata.decode.bind(deleteInstanceMetadata)), + deleteInstanceMetadata.decode.bind(deleteInstanceMetadata), + ), startInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, startInstanceResponse.decode.bind(startInstanceResponse), - startInstanceMetadata.decode.bind(startInstanceMetadata)), + startInstanceMetadata.decode.bind(startInstanceMetadata), + ), stopInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, stopInstanceResponse.decode.bind(stopInstanceResponse), - stopInstanceMetadata.decode.bind(stopInstanceMetadata)), + stopInstanceMetadata.decode.bind(stopInstanceMetadata), + ), resetInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, resetInstanceResponse.decode.bind(resetInstanceResponse), - resetInstanceMetadata.decode.bind(resetInstanceMetadata)), + resetInstanceMetadata.decode.bind(resetInstanceMetadata), + ), upgradeInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, upgradeInstanceResponse.decode.bind(upgradeInstanceResponse), - upgradeInstanceMetadata.decode.bind(upgradeInstanceMetadata)), + upgradeInstanceMetadata.decode.bind(upgradeInstanceMetadata), + ), rollbackInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, rollbackInstanceResponse.decode.bind(rollbackInstanceResponse), - rollbackInstanceMetadata.decode.bind(rollbackInstanceMetadata)), + rollbackInstanceMetadata.decode.bind(rollbackInstanceMetadata), + ), diagnoseInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, diagnoseInstanceResponse.decode.bind(diagnoseInstanceResponse), - diagnoseInstanceMetadata.decode.bind(diagnoseInstanceMetadata)) + diagnoseInstanceMetadata.decode.bind(diagnoseInstanceMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.notebooks.v2.NotebookService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.notebooks.v2.NotebookService', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -329,28 +434,46 @@ export class NotebookServiceClient { // Put together the "service stub" for // google.cloud.notebooks.v2.NotebookService. this.notebookServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.notebooks.v2.NotebookService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.notebooks.v2.NotebookService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.notebooks.v2.NotebookService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const notebookServiceStubMethods = - ['listInstances', 'getInstance', 'createInstance', 'updateInstance', 'deleteInstance', 'startInstance', 'stopInstance', 'resetInstance', 'checkInstanceUpgradability', 'upgradeInstance', 'rollbackInstance', 'diagnoseInstance']; + const notebookServiceStubMethods = [ + 'listInstances', + 'getInstance', + 'createInstance', + 'updateInstance', + 'deleteInstance', + 'startInstance', + 'stopInstance', + 'resetInstance', + 'checkInstanceUpgradability', + 'upgradeInstance', + 'rollbackInstance', + 'diagnoseInstance', + ]; for (const methodName of notebookServiceStubMethods) { const callPromise = this.notebookServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -360,7 +483,7 @@ export class NotebookServiceClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -375,8 +498,14 @@ export class NotebookServiceClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'notebooks.googleapis.com'; } @@ -387,8 +516,14 @@ export class NotebookServiceClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'notebooks.googleapis.com'; } @@ -419,9 +554,7 @@ export class NotebookServiceClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -430,8 +563,9 @@ export class NotebookServiceClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -442,1277 +576,1943 @@ export class NotebookServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets details of a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @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 {@link protos.google.cloud.notebooks.v2.Instance|Instance}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2/notebook_service.get_instance.js - * region_tag:notebooks_v2_generated_NotebookService_GetInstance_async - */ + /** + * Gets details of a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @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 {@link protos.google.cloud.notebooks.v2.Instance|Instance}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2/notebook_service.get_instance.js + * region_tag:notebooks_v2_generated_NotebookService_GetInstance_async + */ getInstance( - request?: protos.google.cloud.notebooks.v2.IGetInstanceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v2.IInstance, - protos.google.cloud.notebooks.v2.IGetInstanceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v2.IGetInstanceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IGetInstanceRequest | undefined, + {} | undefined, + ] + >; getInstance( - request: protos.google.cloud.notebooks.v2.IGetInstanceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.notebooks.v2.IInstance, - protos.google.cloud.notebooks.v2.IGetInstanceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v2.IGetInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IGetInstanceRequest | null | undefined, + {} | null | undefined + >, + ): void; getInstance( - request: protos.google.cloud.notebooks.v2.IGetInstanceRequest, - callback: Callback< - protos.google.cloud.notebooks.v2.IInstance, - protos.google.cloud.notebooks.v2.IGetInstanceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v2.IGetInstanceRequest, + callback: Callback< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IGetInstanceRequest | null | undefined, + {} | null | undefined + >, + ): void; getInstance( - request?: protos.google.cloud.notebooks.v2.IGetInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.notebooks.v2.IInstance, - protos.google.cloud.notebooks.v2.IGetInstanceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.notebooks.v2.IGetInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.notebooks.v2.IInstance, - protos.google.cloud.notebooks.v2.IGetInstanceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.notebooks.v2.IInstance, - protos.google.cloud.notebooks.v2.IGetInstanceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.notebooks.v2.IGetInstanceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IGetInstanceRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IGetInstanceRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getInstance request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.notebooks.v2.IInstance, - protos.google.cloud.notebooks.v2.IGetInstanceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.notebooks.v2.IInstance, + | protos.google.cloud.notebooks.v2.IGetInstanceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getInstance response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getInstance(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.notebooks.v2.IInstance, - protos.google.cloud.notebooks.v2.IGetInstanceRequest|undefined, - {}|undefined - ]) => { - this._log.info('getInstance response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getInstance(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IGetInstanceRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getInstance response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Checks whether a notebook instance is upgradable. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.notebookInstance - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @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 {@link protos.google.cloud.notebooks.v2.CheckInstanceUpgradabilityResponse|CheckInstanceUpgradabilityResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2/notebook_service.check_instance_upgradability.js - * region_tag:notebooks_v2_generated_NotebookService_CheckInstanceUpgradability_async - */ + /** + * Checks whether a notebook instance is upgradable. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.notebookInstance + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @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 {@link protos.google.cloud.notebooks.v2.CheckInstanceUpgradabilityResponse|CheckInstanceUpgradabilityResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2/notebook_service.check_instance_upgradability.js + * region_tag:notebooks_v2_generated_NotebookService_CheckInstanceUpgradability_async + */ checkInstanceUpgradability( - request?: protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityResponse, - protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityResponse, + ( + | protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest + | undefined + ), + {} | undefined, + ] + >; checkInstanceUpgradability( - request: protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityResponse, - protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityResponse, + | protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest + | null + | undefined, + {} | null | undefined + >, + ): void; checkInstanceUpgradability( - request: protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest, - callback: Callback< - protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityResponse, - protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest, + callback: Callback< + protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityResponse, + | protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest + | null + | undefined, + {} | null | undefined + >, + ): void; checkInstanceUpgradability( - request?: protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityResponse, - protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityResponse, - protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityResponse, - protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityResponse, + | protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityResponse, + ( + | protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'notebook_instance': request.notebookInstance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + notebook_instance: request.notebookInstance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('checkInstanceUpgradability request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityResponse, - protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityResponse, + | protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('checkInstanceUpgradability response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.checkInstanceUpgradability(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityResponse, - protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest|undefined, - {}|undefined - ]) => { - this._log.info('checkInstanceUpgradability response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .checkInstanceUpgradability(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityResponse, + ( + | protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('checkInstanceUpgradability response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a new Instance in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {string} request.instanceId - * Required. User-defined unique ID of this instance. - * @param {google.cloud.notebooks.v2.Instance} request.instance - * Required. The instance to be created. - * @param {string} [request.requestId] - * Optional. Idempotent request UUID. - * @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/v2/notebook_service.create_instance.js - * region_tag:notebooks_v2_generated_NotebookService_CreateInstance_async - */ + /** + * Creates a new Instance in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {string} request.instanceId + * Required. User-defined unique ID of this instance. + * @param {google.cloud.notebooks.v2.Instance} request.instance + * Required. The instance to be created. + * @param {string} [request.requestId] + * Optional. Idempotent request UUID. + * @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/v2/notebook_service.create_instance.js + * region_tag:notebooks_v2_generated_NotebookService_CreateInstance_async + */ createInstance( - request?: protos.google.cloud.notebooks.v2.ICreateInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v2.ICreateInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createInstance( - request: protos.google.cloud.notebooks.v2.ICreateInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v2.ICreateInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createInstance( - request: protos.google.cloud.notebooks.v2.ICreateInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v2.ICreateInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createInstance( - request?: protos.google.cloud.notebooks.v2.ICreateInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v2.ICreateInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createInstance request %j', request); - return this.innerApiCalls.createInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createInstance()`. - * @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/v2/notebook_service.create_instance.js - * region_tag:notebooks_v2_generated_NotebookService_CreateInstance_async - */ - async checkCreateInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createInstance()`. + * @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/v2/notebook_service.create_instance.js + * region_tag:notebooks_v2_generated_NotebookService_CreateInstance_async + */ + async checkCreateInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v2.Instance, + protos.google.cloud.notebooks.v2.OperationMetadata + > + > { this._log.info('createInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v2.Instance, + protos.google.cloud.notebooks.v2.OperationMetadata + >; } -/** - * UpdateInstance updates an Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.notebooks.v2.Instance} request.instance - * Required. A representation of an instance. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Mask used to update an instance - * @param {string} [request.requestId] - * Optional. Idempotent request UUID. - * @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/v2/notebook_service.update_instance.js - * region_tag:notebooks_v2_generated_NotebookService_UpdateInstance_async - */ + /** + * UpdateInstance updates an Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.notebooks.v2.Instance} request.instance + * Required. A representation of an instance. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Mask used to update an instance + * @param {string} [request.requestId] + * Optional. Idempotent request UUID. + * @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/v2/notebook_service.update_instance.js + * region_tag:notebooks_v2_generated_NotebookService_UpdateInstance_async + */ updateInstance( - request?: protos.google.cloud.notebooks.v2.IUpdateInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v2.IUpdateInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateInstance( - request: protos.google.cloud.notebooks.v2.IUpdateInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v2.IUpdateInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateInstance( - request: protos.google.cloud.notebooks.v2.IUpdateInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v2.IUpdateInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateInstance( - request?: protos.google.cloud.notebooks.v2.IUpdateInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v2.IUpdateInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'instance.name': request.instance!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'instance.name': request.instance!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateInstance request %j', request); - return this.innerApiCalls.updateInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateInstance()`. - * @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/v2/notebook_service.update_instance.js - * region_tag:notebooks_v2_generated_NotebookService_UpdateInstance_async - */ - async checkUpdateInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateInstance()`. + * @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/v2/notebook_service.update_instance.js + * region_tag:notebooks_v2_generated_NotebookService_UpdateInstance_async + */ + async checkUpdateInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v2.Instance, + protos.google.cloud.notebooks.v2.OperationMetadata + > + > { this._log.info('updateInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v2.Instance, + protos.google.cloud.notebooks.v2.OperationMetadata + >; } -/** - * Deletes a single Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {string} [request.requestId] - * Optional. Idempotent request UUID. - * @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/v2/notebook_service.delete_instance.js - * region_tag:notebooks_v2_generated_NotebookService_DeleteInstance_async - */ + /** + * Deletes a single Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {string} [request.requestId] + * Optional. Idempotent request UUID. + * @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/v2/notebook_service.delete_instance.js + * region_tag:notebooks_v2_generated_NotebookService_DeleteInstance_async + */ deleteInstance( - request?: protos.google.cloud.notebooks.v2.IDeleteInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v2.IDeleteInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteInstance( - request: protos.google.cloud.notebooks.v2.IDeleteInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v2.IDeleteInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteInstance( - request: protos.google.cloud.notebooks.v2.IDeleteInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v2.IDeleteInstanceRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteInstance( - request?: protos.google.cloud.notebooks.v2.IDeleteInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v2.IDeleteInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteInstance request %j', request); - return this.innerApiCalls.deleteInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteInstance()`. - * @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/v2/notebook_service.delete_instance.js - * region_tag:notebooks_v2_generated_NotebookService_DeleteInstance_async - */ - async checkDeleteInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteInstance()`. + * @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/v2/notebook_service.delete_instance.js + * region_tag:notebooks_v2_generated_NotebookService_DeleteInstance_async + */ + async checkDeleteInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.notebooks.v2.OperationMetadata + > + > { this._log.info('deleteInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.notebooks.v2.OperationMetadata + >; } -/** - * Starts a notebook instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @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/v2/notebook_service.start_instance.js - * region_tag:notebooks_v2_generated_NotebookService_StartInstance_async - */ + /** + * Starts a notebook instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @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/v2/notebook_service.start_instance.js + * region_tag:notebooks_v2_generated_NotebookService_StartInstance_async + */ startInstance( - request?: protos.google.cloud.notebooks.v2.IStartInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v2.IStartInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; startInstance( - request: protos.google.cloud.notebooks.v2.IStartInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v2.IStartInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; startInstance( - request: protos.google.cloud.notebooks.v2.IStartInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v2.IStartInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; startInstance( - request?: protos.google.cloud.notebooks.v2.IStartInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v2.IStartInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('startInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('startInstance request %j', request); - return this.innerApiCalls.startInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('startInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .startInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('startInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `startInstance()`. - * @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/v2/notebook_service.start_instance.js - * region_tag:notebooks_v2_generated_NotebookService_StartInstance_async - */ - async checkStartInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `startInstance()`. + * @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/v2/notebook_service.start_instance.js + * region_tag:notebooks_v2_generated_NotebookService_StartInstance_async + */ + async checkStartInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v2.Instance, + protos.google.cloud.notebooks.v2.OperationMetadata + > + > { this._log.info('startInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.startInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.startInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v2.Instance, + protos.google.cloud.notebooks.v2.OperationMetadata + >; } -/** - * Stops a notebook instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @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/v2/notebook_service.stop_instance.js - * region_tag:notebooks_v2_generated_NotebookService_StopInstance_async - */ + /** + * Stops a notebook instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @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/v2/notebook_service.stop_instance.js + * region_tag:notebooks_v2_generated_NotebookService_StopInstance_async + */ stopInstance( - request?: protos.google.cloud.notebooks.v2.IStopInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v2.IStopInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; stopInstance( - request: protos.google.cloud.notebooks.v2.IStopInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v2.IStopInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; stopInstance( - request: protos.google.cloud.notebooks.v2.IStopInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v2.IStopInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; stopInstance( - request?: protos.google.cloud.notebooks.v2.IStopInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v2.IStopInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('stopInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('stopInstance request %j', request); - return this.innerApiCalls.stopInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('stopInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .stopInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('stopInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `stopInstance()`. - * @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/v2/notebook_service.stop_instance.js - * region_tag:notebooks_v2_generated_NotebookService_StopInstance_async - */ - async checkStopInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `stopInstance()`. + * @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/v2/notebook_service.stop_instance.js + * region_tag:notebooks_v2_generated_NotebookService_StopInstance_async + */ + async checkStopInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v2.Instance, + protos.google.cloud.notebooks.v2.OperationMetadata + > + > { this._log.info('stopInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.stopInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.stopInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v2.Instance, + protos.google.cloud.notebooks.v2.OperationMetadata + >; } -/** - * Resets a notebook instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @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/v2/notebook_service.reset_instance.js - * region_tag:notebooks_v2_generated_NotebookService_ResetInstance_async - */ + /** + * Resets a notebook instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @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/v2/notebook_service.reset_instance.js + * region_tag:notebooks_v2_generated_NotebookService_ResetInstance_async + */ resetInstance( - request?: protos.google.cloud.notebooks.v2.IResetInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v2.IResetInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; resetInstance( - request: protos.google.cloud.notebooks.v2.IResetInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v2.IResetInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; resetInstance( - request: protos.google.cloud.notebooks.v2.IResetInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v2.IResetInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; resetInstance( - request?: protos.google.cloud.notebooks.v2.IResetInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v2.IResetInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('resetInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('resetInstance request %j', request); - return this.innerApiCalls.resetInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('resetInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .resetInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('resetInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `resetInstance()`. - * @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/v2/notebook_service.reset_instance.js - * region_tag:notebooks_v2_generated_NotebookService_ResetInstance_async - */ - async checkResetInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `resetInstance()`. + * @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/v2/notebook_service.reset_instance.js + * region_tag:notebooks_v2_generated_NotebookService_ResetInstance_async + */ + async checkResetInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v2.Instance, + protos.google.cloud.notebooks.v2.OperationMetadata + > + > { this._log.info('resetInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.resetInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.resetInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v2.Instance, + protos.google.cloud.notebooks.v2.OperationMetadata + >; } -/** - * Upgrades a notebook instance to the latest version. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @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/v2/notebook_service.upgrade_instance.js - * region_tag:notebooks_v2_generated_NotebookService_UpgradeInstance_async - */ + /** + * Upgrades a notebook instance to the latest version. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @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/v2/notebook_service.upgrade_instance.js + * region_tag:notebooks_v2_generated_NotebookService_UpgradeInstance_async + */ upgradeInstance( - request?: protos.google.cloud.notebooks.v2.IUpgradeInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v2.IUpgradeInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; upgradeInstance( - request: protos.google.cloud.notebooks.v2.IUpgradeInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v2.IUpgradeInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; upgradeInstance( - request: protos.google.cloud.notebooks.v2.IUpgradeInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v2.IUpgradeInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; upgradeInstance( - request?: protos.google.cloud.notebooks.v2.IUpgradeInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v2.IUpgradeInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('upgradeInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('upgradeInstance request %j', request); - return this.innerApiCalls.upgradeInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('upgradeInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .upgradeInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('upgradeInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `upgradeInstance()`. - * @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/v2/notebook_service.upgrade_instance.js - * region_tag:notebooks_v2_generated_NotebookService_UpgradeInstance_async - */ - async checkUpgradeInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `upgradeInstance()`. + * @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/v2/notebook_service.upgrade_instance.js + * region_tag:notebooks_v2_generated_NotebookService_UpgradeInstance_async + */ + async checkUpgradeInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v2.Instance, + protos.google.cloud.notebooks.v2.OperationMetadata + > + > { this._log.info('upgradeInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.upgradeInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.upgradeInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v2.Instance, + protos.google.cloud.notebooks.v2.OperationMetadata + >; } -/** - * Rollbacks a notebook instance to the previous version. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {string} request.targetSnapshot - * Required. The snapshot for rollback. - * Example: "projects/test-project/global/snapshots/krwlzipynril". - * @param {string} request.revisionId - * Required. Output only. Revision Id - * @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/v2/notebook_service.rollback_instance.js - * region_tag:notebooks_v2_generated_NotebookService_RollbackInstance_async - */ + /** + * Rollbacks a notebook instance to the previous version. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {string} request.targetSnapshot + * Required. The snapshot for rollback. + * Example: "projects/test-project/global/snapshots/krwlzipynril". + * @param {string} request.revisionId + * Required. Output only. Revision Id + * @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/v2/notebook_service.rollback_instance.js + * region_tag:notebooks_v2_generated_NotebookService_RollbackInstance_async + */ rollbackInstance( - request?: protos.google.cloud.notebooks.v2.IRollbackInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v2.IRollbackInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; rollbackInstance( - request: protos.google.cloud.notebooks.v2.IRollbackInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v2.IRollbackInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; rollbackInstance( - request: protos.google.cloud.notebooks.v2.IRollbackInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v2.IRollbackInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; rollbackInstance( - request?: protos.google.cloud.notebooks.v2.IRollbackInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v2.IRollbackInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('rollbackInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('rollbackInstance request %j', request); - return this.innerApiCalls.rollbackInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('rollbackInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .rollbackInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('rollbackInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `rollbackInstance()`. - * @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/v2/notebook_service.rollback_instance.js - * region_tag:notebooks_v2_generated_NotebookService_RollbackInstance_async - */ - async checkRollbackInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `rollbackInstance()`. + * @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/v2/notebook_service.rollback_instance.js + * region_tag:notebooks_v2_generated_NotebookService_RollbackInstance_async + */ + async checkRollbackInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v2.Instance, + protos.google.cloud.notebooks.v2.OperationMetadata + > + > { this._log.info('rollbackInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.rollbackInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.rollbackInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v2.Instance, + protos.google.cloud.notebooks.v2.OperationMetadata + >; } -/** - * Creates a Diagnostic File and runs Diagnostic Tool given an Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Format: - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param {google.cloud.notebooks.v2.DiagnosticConfig} request.diagnosticConfig - * Required. Defines flags that are used to run the diagnostic tool - * @param {number} [request.timeoutMinutes] - * Optional. Maxmium amount of time in minutes before the operation times out. - * @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/v2/notebook_service.diagnose_instance.js - * region_tag:notebooks_v2_generated_NotebookService_DiagnoseInstance_async - */ + /** + * Creates a Diagnostic File and runs Diagnostic Tool given an Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Format: + * `projects/{project_id}/locations/{location}/instances/{instance_id}` + * @param {google.cloud.notebooks.v2.DiagnosticConfig} request.diagnosticConfig + * Required. Defines flags that are used to run the diagnostic tool + * @param {number} [request.timeoutMinutes] + * Optional. Maxmium amount of time in minutes before the operation times out. + * @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/v2/notebook_service.diagnose_instance.js + * region_tag:notebooks_v2_generated_NotebookService_DiagnoseInstance_async + */ diagnoseInstance( - request?: protos.google.cloud.notebooks.v2.IDiagnoseInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.notebooks.v2.IDiagnoseInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; diagnoseInstance( - request: protos.google.cloud.notebooks.v2.IDiagnoseInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v2.IDiagnoseInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; diagnoseInstance( - request: protos.google.cloud.notebooks.v2.IDiagnoseInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.notebooks.v2.IDiagnoseInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; diagnoseInstance( - request?: protos.google.cloud.notebooks.v2.IDiagnoseInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.notebooks.v2.IDiagnoseInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('diagnoseInstance response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('diagnoseInstance request %j', request); - return this.innerApiCalls.diagnoseInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('diagnoseInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .diagnoseInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('diagnoseInstance response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `diagnoseInstance()`. - * @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/v2/notebook_service.diagnose_instance.js - * region_tag:notebooks_v2_generated_NotebookService_DiagnoseInstance_async - */ - async checkDiagnoseInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `diagnoseInstance()`. + * @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/v2/notebook_service.diagnose_instance.js + * region_tag:notebooks_v2_generated_NotebookService_DiagnoseInstance_async + */ + async checkDiagnoseInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.notebooks.v2.Instance, + protos.google.cloud.notebooks.v2.OperationMetadata + > + > { this._log.info('diagnoseInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.diagnoseInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.diagnoseInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.notebooks.v2.Instance, + protos.google.cloud.notebooks.v2.OperationMetadata + >; } - /** - * Lists instances in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} [request.pageSize] - * Optional. Maximum return size of the list call. - * @param {string} [request.pageToken] - * Optional. A previous returned page token that can be used to continue - * listing from the last result. - * @param {string} [request.orderBy] - * Optional. Sort results. Supported values are "name", "name desc" or "" - * (unsorted). - * @param {string} [request.filter] - * Optional. List filter. - * @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 Array of {@link protos.google.cloud.notebooks.v2.Instance|Instance}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listInstancesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists instances in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} [request.pageSize] + * Optional. Maximum return size of the list call. + * @param {string} [request.pageToken] + * Optional. A previous returned page token that can be used to continue + * listing from the last result. + * @param {string} [request.orderBy] + * Optional. Sort results. Supported values are "name", "name desc" or "" + * (unsorted). + * @param {string} [request.filter] + * Optional. List filter. + * @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 Array of {@link protos.google.cloud.notebooks.v2.Instance|Instance}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listInstances( - request?: protos.google.cloud.notebooks.v2.IListInstancesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.notebooks.v2.IInstance[], - protos.google.cloud.notebooks.v2.IListInstancesRequest|null, - protos.google.cloud.notebooks.v2.IListInstancesResponse - ]>; + request?: protos.google.cloud.notebooks.v2.IListInstancesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.notebooks.v2.IInstance[], + protos.google.cloud.notebooks.v2.IListInstancesRequest | null, + protos.google.cloud.notebooks.v2.IListInstancesResponse, + ] + >; listInstances( - request: protos.google.cloud.notebooks.v2.IListInstancesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.notebooks.v2.IListInstancesRequest, - protos.google.cloud.notebooks.v2.IListInstancesResponse|null|undefined, - protos.google.cloud.notebooks.v2.IInstance>): void; + request: protos.google.cloud.notebooks.v2.IListInstancesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.notebooks.v2.IListInstancesRequest, + | protos.google.cloud.notebooks.v2.IListInstancesResponse + | null + | undefined, + protos.google.cloud.notebooks.v2.IInstance + >, + ): void; listInstances( - request: protos.google.cloud.notebooks.v2.IListInstancesRequest, - callback: PaginationCallback< - protos.google.cloud.notebooks.v2.IListInstancesRequest, - protos.google.cloud.notebooks.v2.IListInstancesResponse|null|undefined, - protos.google.cloud.notebooks.v2.IInstance>): void; + request: protos.google.cloud.notebooks.v2.IListInstancesRequest, + callback: PaginationCallback< + protos.google.cloud.notebooks.v2.IListInstancesRequest, + | protos.google.cloud.notebooks.v2.IListInstancesResponse + | null + | undefined, + protos.google.cloud.notebooks.v2.IInstance + >, + ): void; listInstances( - request?: protos.google.cloud.notebooks.v2.IListInstancesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.notebooks.v2.IListInstancesRequest, - protos.google.cloud.notebooks.v2.IListInstancesResponse|null|undefined, - protos.google.cloud.notebooks.v2.IInstance>, - callback?: PaginationCallback< + request?: protos.google.cloud.notebooks.v2.IListInstancesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.notebooks.v2.IListInstancesRequest, - protos.google.cloud.notebooks.v2.IListInstancesResponse|null|undefined, - protos.google.cloud.notebooks.v2.IInstance>): - Promise<[ - protos.google.cloud.notebooks.v2.IInstance[], - protos.google.cloud.notebooks.v2.IListInstancesRequest|null, - protos.google.cloud.notebooks.v2.IListInstancesResponse - ]>|void { + | protos.google.cloud.notebooks.v2.IListInstancesResponse + | null + | undefined, + protos.google.cloud.notebooks.v2.IInstance + >, + callback?: PaginationCallback< + protos.google.cloud.notebooks.v2.IListInstancesRequest, + | protos.google.cloud.notebooks.v2.IListInstancesResponse + | null + | undefined, + protos.google.cloud.notebooks.v2.IInstance + >, + ): Promise< + [ + protos.google.cloud.notebooks.v2.IInstance[], + protos.google.cloud.notebooks.v2.IListInstancesRequest | null, + protos.google.cloud.notebooks.v2.IListInstancesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.notebooks.v2.IListInstancesRequest, - protos.google.cloud.notebooks.v2.IListInstancesResponse|null|undefined, - protos.google.cloud.notebooks.v2.IInstance>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.notebooks.v2.IListInstancesRequest, + | protos.google.cloud.notebooks.v2.IListInstancesResponse + | null + | undefined, + protos.google.cloud.notebooks.v2.IInstance + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listInstances values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1721,147 +2521,151 @@ export class NotebookServiceClient { this._log.info('listInstances request %j', request); return this.innerApiCalls .listInstances(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.notebooks.v2.IInstance[], - protos.google.cloud.notebooks.v2.IListInstancesRequest|null, - protos.google.cloud.notebooks.v2.IListInstancesResponse - ]) => { - this._log.info('listInstances values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.notebooks.v2.IInstance[], + protos.google.cloud.notebooks.v2.IListInstancesRequest | null, + protos.google.cloud.notebooks.v2.IListInstancesResponse, + ]) => { + this._log.info('listInstances values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listInstances`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} [request.pageSize] - * Optional. Maximum return size of the list call. - * @param {string} [request.pageToken] - * Optional. A previous returned page token that can be used to continue - * listing from the last result. - * @param {string} [request.orderBy] - * Optional. Sort results. Supported values are "name", "name desc" or "" - * (unsorted). - * @param {string} [request.filter] - * Optional. List filter. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.notebooks.v2.Instance|Instance} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listInstancesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listInstances`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} [request.pageSize] + * Optional. Maximum return size of the list call. + * @param {string} [request.pageToken] + * Optional. A previous returned page token that can be used to continue + * listing from the last result. + * @param {string} [request.orderBy] + * Optional. Sort results. Supported values are "name", "name desc" or "" + * (unsorted). + * @param {string} [request.filter] + * Optional. List filter. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.notebooks.v2.Instance|Instance} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listInstancesStream( - request?: protos.google.cloud.notebooks.v2.IListInstancesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.notebooks.v2.IListInstancesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listInstances']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listInstances stream %j', request); return this.descriptors.page.listInstances.createStream( this.innerApiCalls.listInstances as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listInstances`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: - * `parent=projects/{project_id}/locations/{location}` - * @param {number} [request.pageSize] - * Optional. Maximum return size of the list call. - * @param {string} [request.pageToken] - * Optional. A previous returned page token that can be used to continue - * listing from the last result. - * @param {string} [request.orderBy] - * Optional. Sort results. Supported values are "name", "name desc" or "" - * (unsorted). - * @param {string} [request.filter] - * Optional. List filter. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.notebooks.v2.Instance|Instance}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v2/notebook_service.list_instances.js - * region_tag:notebooks_v2_generated_NotebookService_ListInstances_async - */ + /** + * Equivalent to `listInstances`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: + * `parent=projects/{project_id}/locations/{location}` + * @param {number} [request.pageSize] + * Optional. Maximum return size of the list call. + * @param {string} [request.pageToken] + * Optional. A previous returned page token that can be used to continue + * listing from the last result. + * @param {string} [request.orderBy] + * Optional. Sort results. Supported values are "name", "name desc" or "" + * (unsorted). + * @param {string} [request.filter] + * Optional. List filter. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.notebooks.v2.Instance|Instance}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v2/notebook_service.list_instances.js + * region_tag:notebooks_v2_generated_NotebookService_ListInstances_async + */ listInstancesAsync( - request?: protos.google.cloud.notebooks.v2.IListInstancesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.notebooks.v2.IListInstancesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listInstances']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listInstances iterate %j', request); return this.descriptors.page.listInstances.asyncIterate( this.innerApiCalls['listInstances'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -1875,40 +2679,40 @@ export class NotebookServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -1922,41 +2726,41 @@ export class NotebookServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -1970,12 +2774,12 @@ export class NotebookServiceClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -2010,12 +2814,11 @@ export class NotebookServiceClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -2048,12 +2851,12 @@ export class NotebookServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -2096,22 +2899,22 @@ export class NotebookServiceClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -2146,15 +2949,15 @@ export class NotebookServiceClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - 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 ?? '', - }); + 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 ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -2188,7 +2991,7 @@ export class NotebookServiceClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -2201,25 +3004,24 @@ export class NotebookServiceClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -2258,22 +3060,22 @@ export class NotebookServiceClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -2289,7 +3091,7 @@ export class NotebookServiceClient { * @param {string} instance * @returns {string} Resource name string. */ - instancePath(project:string,location:string,instance:string) { + instancePath(project: string, location: string, instance: string) { return this.pathTemplates.instancePathTemplate.render({ project: project, location: location, @@ -2337,7 +3139,7 @@ export class NotebookServiceClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -2372,7 +3174,7 @@ export class NotebookServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -2397,15 +3199,19 @@ export class NotebookServiceClient { */ close(): Promise { if (this.notebookServiceStub && !this._terminated) { - return this.notebookServiceStub.then(stub => { + return this.notebookServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-notebooks/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-notebooks/system-test/fixtures/sample/src/index.ts index 850111b27db1..eff1a87ec22f 100644 --- a/packages/google-cloud-notebooks/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-notebooks/system-test/fixtures/sample/src/index.ts @@ -16,10 +16,15 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {ManagedNotebookServiceClient, NotebookServiceClient} from '@google-cloud/notebooks'; +import { + ManagedNotebookServiceClient, + NotebookServiceClient, +} from '@google-cloud/notebooks'; // check that the client class type name can be used -function doStuffWithManagedNotebookServiceClient(client: ManagedNotebookServiceClient) { +function doStuffWithManagedNotebookServiceClient( + client: ManagedNotebookServiceClient, +) { client.close(); } function doStuffWithNotebookServiceClient(client: NotebookServiceClient) { diff --git a/packages/google-cloud-notebooks/system-test/install.ts b/packages/google-cloud-notebooks/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-notebooks/system-test/install.ts +++ b/packages/google-cloud-notebooks/system-test/install.ts @@ -16,34 +16,36 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {packNTest} from 'pack-n-play'; -import {readFileSync} from 'fs'; -import {describe, it} from 'mocha'; +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; +import { describe, it } from 'mocha'; describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { + it('TypeScript code', async function () { this.timeout(300000); const options = { packageDir: process.cwd(), sample: { description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } + ts: readFileSync( + './system-test/fixtures/sample/src/index.ts', + ).toString(), + }, }; await packNTest(options); }); - it('JavaScript code', async function() { + it('JavaScript code', async function () { this.timeout(300000); const options = { packageDir: process.cwd(), sample: { description: 'JavaScript user can use the library', - cjs: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } + cjs: readFileSync( + './system-test/fixtures/sample/src/index.js', + ).toString(), + }, }; await packNTest(options); }); - }); diff --git a/packages/google-cloud-notebooks/test/gapic_managed_notebook_service_v1.ts b/packages/google-cloud-notebooks/test/gapic_managed_notebook_service_v1.ts index 393d1dd3ed78..d07edcf0d6ad 100644 --- a/packages/google-cloud-notebooks/test/gapic_managed_notebook_service_v1.ts +++ b/packages/google-cloud-notebooks/test/gapic_managed_notebook_service_v1.ts @@ -19,3246 +19,4199 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as managednotebookserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + IamProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1.ManagedNotebookServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'notebooks.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = managednotebookserviceModule.v1.ManagedNotebookServiceClient.servicePath; - assert.strictEqual(servicePath, 'notebooks.googleapis.com'); - assert(stub.called); - stub.restore(); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'notebooks.googleapis.com'); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = managednotebookserviceModule.v1.ManagedNotebookServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'notebooks.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'notebooks.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'notebooks.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'notebooks.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'notebooks.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new managednotebookserviceModule.v1.ManagedNotebookServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); + it('has universeDomain', () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + managednotebookserviceModule.v1.ManagedNotebookServiceClient + .servicePath; + assert.strictEqual(servicePath, 'notebooks.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + managednotebookserviceModule.v1.ManagedNotebookServiceClient + .apiEndpoint; + assert.strictEqual(apiEndpoint, 'notebooks.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + universeDomain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'notebooks.example.com'); + }); - it('has port', () => { - const port = managednotebookserviceModule.v1.ManagedNotebookServiceClient.port; - assert(port); - assert(typeof port === 'number'); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + universe_domain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'notebooks.example.com'); + }); - it('should create a client with no option', () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient(); - assert(client); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'notebooks.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('should create a client with gRPC fallback', () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - fallback: true, - }); - assert(client); + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'notebooks.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.managedNotebookServiceStub, undefined); - await client.initialize(); - assert(client.managedNotebookServiceStub); + it('has port', () => { + const port = + managednotebookserviceModule.v1.ManagedNotebookServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + fallback: true, }); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.managedNotebookServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has initialize method and supports deferred initialization', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.managedNotebookServiceStub, undefined); + await client.initialize(); + assert(client.managedNotebookServiceStub); + }); - it('has close method for the non-initialized client', done => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.managedNotebookServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the initialized client', (done) => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.managedNotebookServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; + }); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + it('has close method for the non-initialized client', (done) => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.managedNotebookServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; + }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); }); - describe('getRuntime', () => { - it('invokes getRuntime without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.Runtime() - ); - client.innerApiCalls.getRuntime = stubSimpleCall(expectedResponse); - const [response] = await client.getRuntime(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRuntime without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.Runtime() - ); - client.innerApiCalls.getRuntime = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getRuntime( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IRuntime|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRuntime with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getRuntime = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getRuntime(request), expectedError); - const actualRequest = (client.innerApiCalls.getRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRuntime with closed client', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getRuntime(request), expectedError); - }); - }); - - describe('refreshRuntimeTokenInternal', () => { - it('invokes refreshRuntimeTokenInternal without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalResponse() - ); - client.innerApiCalls.refreshRuntimeTokenInternal = stubSimpleCall(expectedResponse); - const [response] = await client.refreshRuntimeTokenInternal(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.refreshRuntimeTokenInternal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.refreshRuntimeTokenInternal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes refreshRuntimeTokenInternal without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalResponse() - ); - client.innerApiCalls.refreshRuntimeTokenInternal = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.refreshRuntimeTokenInternal( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.refreshRuntimeTokenInternal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.refreshRuntimeTokenInternal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes refreshRuntimeTokenInternal with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.refreshRuntimeTokenInternal = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.refreshRuntimeTokenInternal(request), expectedError); - const actualRequest = (client.innerApiCalls.refreshRuntimeTokenInternal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.refreshRuntimeTokenInternal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes refreshRuntimeTokenInternal with closed client', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.refreshRuntimeTokenInternal(request), expectedError); - }); - }); - - describe('createRuntime', () => { - it('invokes createRuntime without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateRuntimeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createRuntime = stubLongRunningCall(expectedResponse); - const [operation] = await client.createRuntime(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createRuntime without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateRuntimeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createRuntime = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createRuntime( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createRuntime with call error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateRuntimeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createRuntime = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createRuntime(request), expectedError); - const actualRequest = (client.innerApiCalls.createRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createRuntime with LRO error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateRuntimeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createRuntime = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createRuntime(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateRuntimeProgress without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateRuntimeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateRuntimeProgress with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getRuntime', () => { + it('invokes getRuntime without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.GetRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.Runtime(), + ); + client.innerApiCalls.getRuntime = stubSimpleCall(expectedResponse); + const [response] = await client.getRuntime(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateRuntimeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); + it('invokes getRuntime without error using callback', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.GetRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.Runtime(), + ); + client.innerApiCalls.getRuntime = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getRuntime( + request, + ( + err?: Error | null, + result?: protos.google.cloud.notebooks.v1.IRuntime | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateRuntime', () => { - it('invokes updateRuntime without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateRuntimeRequest() - ); - request.runtime ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateRuntimeRequest', ['runtime', 'name']); - request.runtime.name = defaultValue1; - const expectedHeaderRequestParams = `runtime.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateRuntime = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateRuntime(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateRuntime without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateRuntimeRequest() - ); - request.runtime ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateRuntimeRequest', ['runtime', 'name']); - request.runtime.name = defaultValue1; - const expectedHeaderRequestParams = `runtime.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateRuntime = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateRuntime( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateRuntime with call error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateRuntimeRequest() - ); - request.runtime ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateRuntimeRequest', ['runtime', 'name']); - request.runtime.name = defaultValue1; - const expectedHeaderRequestParams = `runtime.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateRuntime = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateRuntime(request), expectedError); - const actualRequest = (client.innerApiCalls.updateRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateRuntime with LRO error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateRuntimeRequest() - ); - request.runtime ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateRuntimeRequest', ['runtime', 'name']); - request.runtime.name = defaultValue1; - const expectedHeaderRequestParams = `runtime.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateRuntime = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateRuntime(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateRuntimeProgress without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateRuntimeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateRuntimeProgress with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes getRuntime with error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.GetRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getRuntime = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getRuntime(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateRuntimeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); + it('invokes getRuntime with closed client', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.GetRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getRuntime(request), expectedError); + }); + }); + + describe('refreshRuntimeTokenInternal', () => { + it('invokes refreshRuntimeTokenInternal without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalResponse(), + ); + client.innerApiCalls.refreshRuntimeTokenInternal = + stubSimpleCall(expectedResponse); + const [response] = await client.refreshRuntimeTokenInternal(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.refreshRuntimeTokenInternal as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.refreshRuntimeTokenInternal as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteRuntime', () => { - it('invokes deleteRuntime without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteRuntime = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteRuntime(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteRuntime without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteRuntime = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteRuntime( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteRuntime with call error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteRuntime = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteRuntime(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteRuntime with LRO error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteRuntime = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteRuntime(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteRuntimeProgress without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteRuntimeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteRuntimeProgress with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes refreshRuntimeTokenInternal without error using callback', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalResponse(), + ); + client.innerApiCalls.refreshRuntimeTokenInternal = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.refreshRuntimeTokenInternal( + request, + ( + err?: Error | null, + result?: protos.google.cloud.notebooks.v1.IRefreshRuntimeTokenInternalResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.refreshRuntimeTokenInternal as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.refreshRuntimeTokenInternal as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteRuntimeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); + it('invokes refreshRuntimeTokenInternal with error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.refreshRuntimeTokenInternal = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.refreshRuntimeTokenInternal(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.refreshRuntimeTokenInternal as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.refreshRuntimeTokenInternal as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('startRuntime', () => { - it('invokes startRuntime without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StartRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StartRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.startRuntime = stubLongRunningCall(expectedResponse); - const [operation] = await client.startRuntime(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.startRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes startRuntime without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StartRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StartRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.startRuntime = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.startRuntime( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.startRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes startRuntime with call error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StartRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StartRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.startRuntime = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.startRuntime(request), expectedError); - const actualRequest = (client.innerApiCalls.startRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes startRuntime with LRO error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StartRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StartRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.startRuntime = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.startRuntime(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.startRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkStartRuntimeProgress without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkStartRuntimeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkStartRuntimeProgress with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes refreshRuntimeTokenInternal with closed client', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.RefreshRuntimeTokenInternalRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.refreshRuntimeTokenInternal(request), + expectedError, + ); + }); + }); + + describe('createRuntime', () => { + it('invokes createRuntime without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.CreateRuntimeRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createRuntime = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createRuntime(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkStartRuntimeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); + it('invokes createRuntime without error using callback', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.CreateRuntimeRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createRuntime = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createRuntime( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('stopRuntime', () => { - it('invokes stopRuntime without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StopRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StopRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.stopRuntime = stubLongRunningCall(expectedResponse); - const [operation] = await client.stopRuntime(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.stopRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopRuntime without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StopRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StopRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.stopRuntime = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.stopRuntime( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.stopRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopRuntime with call error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StopRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StopRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.stopRuntime = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.stopRuntime(request), expectedError); - const actualRequest = (client.innerApiCalls.stopRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopRuntime with LRO error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StopRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StopRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.stopRuntime = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.stopRuntime(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.stopRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkStopRuntimeProgress without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkStopRuntimeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkStopRuntimeProgress with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes createRuntime with call error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.CreateRuntimeRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createRuntime = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createRuntime(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkStopRuntimeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); + it('invokes createRuntime with LRO error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.CreateRuntimeRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createRuntime = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createRuntime(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('switchRuntime', () => { - it('invokes switchRuntime without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SwitchRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SwitchRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.switchRuntime = stubLongRunningCall(expectedResponse); - const [operation] = await client.switchRuntime(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.switchRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.switchRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes switchRuntime without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SwitchRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SwitchRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.switchRuntime = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.switchRuntime( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.switchRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.switchRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes switchRuntime with call error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SwitchRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SwitchRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.switchRuntime = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.switchRuntime(request), expectedError); - const actualRequest = (client.innerApiCalls.switchRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.switchRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes switchRuntime with LRO error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SwitchRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SwitchRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.switchRuntime = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.switchRuntime(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.switchRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.switchRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkSwitchRuntimeProgress without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkSwitchRuntimeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkSwitchRuntimeProgress with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes checkCreateRuntimeProgress without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateRuntimeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkSwitchRuntimeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); + it('invokes checkCreateRuntimeProgress with error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateRuntimeProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateRuntime', () => { + it('invokes updateRuntime without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateRuntimeRequest(), + ); + request.runtime ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.UpdateRuntimeRequest', + ['runtime', 'name'], + ); + request.runtime.name = defaultValue1; + const expectedHeaderRequestParams = `runtime.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateRuntime = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateRuntime(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('resetRuntime', () => { - it('invokes resetRuntime without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ResetRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ResetRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.resetRuntime = stubLongRunningCall(expectedResponse); - const [operation] = await client.resetRuntime(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resetRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resetRuntime without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ResetRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ResetRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.resetRuntime = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.resetRuntime( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resetRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resetRuntime with call error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ResetRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ResetRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.resetRuntime = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.resetRuntime(request), expectedError); - const actualRequest = (client.innerApiCalls.resetRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resetRuntime with LRO error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ResetRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ResetRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.resetRuntime = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.resetRuntime(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.resetRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkResetRuntimeProgress without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkResetRuntimeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkResetRuntimeProgress with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes updateRuntime without error using callback', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateRuntimeRequest(), + ); + request.runtime ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.UpdateRuntimeRequest', + ['runtime', 'name'], + ); + request.runtime.name = defaultValue1; + const expectedHeaderRequestParams = `runtime.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateRuntime = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateRuntime( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkResetRuntimeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); + it('invokes updateRuntime with call error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateRuntimeRequest(), + ); + request.runtime ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.UpdateRuntimeRequest', + ['runtime', 'name'], + ); + request.runtime.name = defaultValue1; + const expectedHeaderRequestParams = `runtime.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateRuntime = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateRuntime(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('upgradeRuntime', () => { - it('invokes upgradeRuntime without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpgradeRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.upgradeRuntime = stubLongRunningCall(expectedResponse); - const [operation] = await client.upgradeRuntime(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.upgradeRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeRuntime without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpgradeRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.upgradeRuntime = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.upgradeRuntime( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.upgradeRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeRuntime with call error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpgradeRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.upgradeRuntime = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.upgradeRuntime(request), expectedError); - const actualRequest = (client.innerApiCalls.upgradeRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeRuntime with LRO error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpgradeRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.upgradeRuntime = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.upgradeRuntime(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.upgradeRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpgradeRuntimeProgress without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpgradeRuntimeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpgradeRuntimeProgress with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes updateRuntime with LRO error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateRuntimeRequest(), + ); + request.runtime ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.UpdateRuntimeRequest', + ['runtime', 'name'], + ); + request.runtime.name = defaultValue1; + const expectedHeaderRequestParams = `runtime.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateRuntime = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateRuntime(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpgradeRuntimeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); + it('invokes checkUpdateRuntimeProgress without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await 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.checkUpdateRuntimeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('reportRuntimeEvent', () => { - it('invokes reportRuntimeEvent without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ReportRuntimeEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ReportRuntimeEventRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.reportRuntimeEvent = stubLongRunningCall(expectedResponse); - const [operation] = await client.reportRuntimeEvent(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.reportRuntimeEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reportRuntimeEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes reportRuntimeEvent without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ReportRuntimeEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ReportRuntimeEventRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.reportRuntimeEvent = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.reportRuntimeEvent( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.reportRuntimeEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reportRuntimeEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes reportRuntimeEvent with call error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ReportRuntimeEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ReportRuntimeEventRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.reportRuntimeEvent = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.reportRuntimeEvent(request), expectedError); - const actualRequest = (client.innerApiCalls.reportRuntimeEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reportRuntimeEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes reportRuntimeEvent with LRO error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ReportRuntimeEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ReportRuntimeEventRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.reportRuntimeEvent = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.reportRuntimeEvent(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.reportRuntimeEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reportRuntimeEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkReportRuntimeEventProgress without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkReportRuntimeEventProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkReportRuntimeEventProgress with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes checkUpdateRuntimeProgress with error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateRuntimeProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteRuntime', () => { + it('invokes deleteRuntime without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.DeleteRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteRuntime = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteRuntime(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkReportRuntimeEventProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); + it('invokes deleteRuntime without error using callback', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.DeleteRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteRuntime = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteRuntime( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('diagnoseRuntime', () => { - it('invokes diagnoseRuntime without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DiagnoseRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DiagnoseRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.diagnoseRuntime = stubLongRunningCall(expectedResponse); - const [operation] = await client.diagnoseRuntime(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.diagnoseRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.diagnoseRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes diagnoseRuntime without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DiagnoseRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DiagnoseRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.diagnoseRuntime = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.diagnoseRuntime( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.diagnoseRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.diagnoseRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes diagnoseRuntime with call error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DiagnoseRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DiagnoseRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.diagnoseRuntime = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.diagnoseRuntime(request), expectedError); - const actualRequest = (client.innerApiCalls.diagnoseRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.diagnoseRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes diagnoseRuntime with LRO error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DiagnoseRuntimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DiagnoseRuntimeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.diagnoseRuntime = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.diagnoseRuntime(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.diagnoseRuntime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.diagnoseRuntime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDiagnoseRuntimeProgress without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDiagnoseRuntimeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDiagnoseRuntimeProgress with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes deleteRuntime with call error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.DeleteRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteRuntime = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteRuntime(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDiagnoseRuntimeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); + it('invokes deleteRuntime with LRO error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.DeleteRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteRuntime = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteRuntime(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listRuntimes', () => { - it('invokes listRuntimes without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListRuntimesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListRuntimesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), - ]; - client.innerApiCalls.listRuntimes = stubSimpleCall(expectedResponse); - const [response] = await client.listRuntimes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRuntimes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRuntimes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listRuntimes without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListRuntimesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListRuntimesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), - ]; - client.innerApiCalls.listRuntimes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listRuntimes( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IRuntime[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRuntimes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRuntimes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listRuntimes with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListRuntimesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListRuntimesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listRuntimes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listRuntimes(request), expectedError); - const actualRequest = (client.innerApiCalls.listRuntimes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRuntimes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listRuntimesStream without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListRuntimesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListRuntimesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), - ]; - client.descriptors.page.listRuntimes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listRuntimesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v1.Runtime[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v1.Runtime) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listRuntimes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRuntimes, request)); - assert( - (client.descriptors.page.listRuntimes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listRuntimesStream with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListRuntimesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListRuntimesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listRuntimes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listRuntimesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v1.Runtime[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v1.Runtime) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listRuntimes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRuntimes, request)); - assert( - (client.descriptors.page.listRuntimes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listRuntimes without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListRuntimesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListRuntimesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), - ]; - client.descriptors.page.listRuntimes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.notebooks.v1.IRuntime[] = []; - const iterable = client.listRuntimesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes checkDeleteRuntimeProgress without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteRuntimeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteRuntimeProgress with error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteRuntimeProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('startRuntime', () => { + it('invokes startRuntime without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StartRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.StartRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.startRuntime = stubLongRunningCall(expectedResponse); + const [operation] = await client.startRuntime(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.startRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startRuntime without error using callback', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StartRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.StartRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.startRuntime = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.startRuntime( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listRuntimes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRuntimes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listRuntimes with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListRuntimesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListRuntimesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listRuntimes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listRuntimesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.notebooks.v1.IRuntime[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listRuntimes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRuntimes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.startRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startRuntime with call error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StartRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.StartRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.startRuntime = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.startRuntime(request), expectedError); + const actualRequest = ( + client.innerApiCalls.startRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startRuntime with LRO error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StartRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.StartRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.startRuntime = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.startRuntime(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.startRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkStartRuntimeProgress without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkStartRuntimeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkStartRuntimeProgress with error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkStartRuntimeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('stopRuntime', () => { + it('invokes stopRuntime without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StopRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.StopRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.stopRuntime = stubLongRunningCall(expectedResponse); + const [operation] = await client.stopRuntime(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.stopRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopRuntime without error using callback', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StopRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.StopRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.stopRuntime = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.stopRuntime( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.stopRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopRuntime with call error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StopRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.StopRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.stopRuntime = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.stopRuntime(request), expectedError); + const actualRequest = ( + client.innerApiCalls.stopRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopRuntime with LRO error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StopRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.StopRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.stopRuntime = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.stopRuntime(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.stopRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkStopRuntimeProgress without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkStopRuntimeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkStopRuntimeProgress with error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkStopRuntimeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('switchRuntime', () => { + it('invokes switchRuntime without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SwitchRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.SwitchRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.switchRuntime = + stubLongRunningCall(expectedResponse); + const [operation] = await client.switchRuntime(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.switchRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.switchRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes switchRuntime without error using callback', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SwitchRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.SwitchRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.switchRuntime = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.switchRuntime( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.switchRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.switchRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes switchRuntime with call error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SwitchRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.SwitchRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.switchRuntime = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.switchRuntime(request), expectedError); + const actualRequest = ( + client.innerApiCalls.switchRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.switchRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('Path templates', () => { + it('invokes switchRuntime with LRO error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SwitchRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.SwitchRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.switchRuntime = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.switchRuntime(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.switchRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.switchRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('environment', async () => { - const fakePath = "/rendered/path/environment"; - const expectedParameters = { - project: "projectValue", - environment: "environmentValue", - }; - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.environmentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.environmentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('environmentPath', () => { - const result = client.environmentPath("projectValue", "environmentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.environmentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes checkSwitchRuntimeProgress without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkSwitchRuntimeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('matchProjectFromEnvironmentName', () => { - const result = client.matchProjectFromEnvironmentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkSwitchRuntimeProgress with error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkSwitchRuntimeProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('resetRuntime', () => { + it('invokes resetRuntime without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ResetRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ResetRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.resetRuntime = stubLongRunningCall(expectedResponse); + const [operation] = await client.resetRuntime(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resetRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resetRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchEnvironmentFromEnvironmentName', () => { - const result = client.matchEnvironmentFromEnvironmentName(fakePath); - assert.strictEqual(result, "environmentValue"); - assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes resetRuntime without error using callback', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ResetRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ResetRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.resetRuntime = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resetRuntime( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resetRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resetRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('execution', async () => { - const fakePath = "/rendered/path/execution"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - execution: "executionValue", - }; - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.executionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.executionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('executionPath', () => { - const result = client.executionPath("projectValue", "locationValue", "executionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.executionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes resetRuntime with call error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ResetRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ResetRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resetRuntime = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.resetRuntime(request), expectedError); + const actualRequest = ( + client.innerApiCalls.resetRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resetRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromExecutionName', () => { - const result = client.matchProjectFromExecutionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes resetRuntime with LRO error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ResetRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ResetRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resetRuntime = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.resetRuntime(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.resetRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resetRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromExecutionName', () => { - const result = client.matchLocationFromExecutionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkResetRuntimeProgress without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkResetRuntimeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('matchExecutionFromExecutionName', () => { - const result = client.matchExecutionFromExecutionName(fakePath); - assert.strictEqual(result, "executionValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkResetRuntimeProgress with error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkResetRuntimeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('upgradeRuntime', () => { + it('invokes upgradeRuntime without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpgradeRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.UpgradeRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.upgradeRuntime = + stubLongRunningCall(expectedResponse); + const [operation] = await client.upgradeRuntime(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.upgradeRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.upgradeRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('instance', async () => { - const fakePath = "/rendered/path/instance"; - const expectedParameters = { - project: "projectValue", - instance: "instanceValue", - }; - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.instancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.instancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('instancePath', () => { - const result = client.instancePath("projectValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.instancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes upgradeRuntime without error using callback', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpgradeRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.UpgradeRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.upgradeRuntime = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.upgradeRuntime( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.upgradeRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.upgradeRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromInstanceName', () => { - const result = client.matchProjectFromInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes upgradeRuntime with call error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpgradeRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.UpgradeRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.upgradeRuntime = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.upgradeRuntime(request), expectedError); + const actualRequest = ( + client.innerApiCalls.upgradeRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.upgradeRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchInstanceFromInstanceName', () => { - const result = client.matchInstanceFromInstanceName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes upgradeRuntime with LRO error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpgradeRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.UpgradeRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.upgradeRuntime = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.upgradeRuntime(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.upgradeRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.upgradeRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes checkUpgradeRuntimeProgress without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpgradeRuntimeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkUpgradeRuntimeProgress with error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpgradeRuntimeProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('reportRuntimeEvent', () => { + it('invokes reportRuntimeEvent without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ReportRuntimeEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ReportRuntimeEventRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.reportRuntimeEvent = + stubLongRunningCall(expectedResponse); + const [operation] = await client.reportRuntimeEvent(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.reportRuntimeEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reportRuntimeEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes reportRuntimeEvent without error using callback', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ReportRuntimeEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ReportRuntimeEventRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.reportRuntimeEvent = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.reportRuntimeEvent( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.reportRuntimeEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reportRuntimeEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes reportRuntimeEvent with call error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ReportRuntimeEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ReportRuntimeEventRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.reportRuntimeEvent = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.reportRuntimeEvent(request), expectedError); + const actualRequest = ( + client.innerApiCalls.reportRuntimeEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reportRuntimeEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes reportRuntimeEvent with LRO error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ReportRuntimeEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ReportRuntimeEventRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.reportRuntimeEvent = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.reportRuntimeEvent(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.reportRuntimeEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reportRuntimeEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('runtime', async () => { - const fakePath = "/rendered/path/runtime"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - runtime: "runtimeValue", - }; - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.runtimePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.runtimePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('runtimePath', () => { - const result = client.runtimePath("projectValue", "locationValue", "runtimeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.runtimePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes checkReportRuntimeEventProgress without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkReportRuntimeEventProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('matchProjectFromRuntimeName', () => { - const result = client.matchProjectFromRuntimeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.runtimePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkReportRuntimeEventProgress with error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkReportRuntimeEventProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('diagnoseRuntime', () => { + it('invokes diagnoseRuntime without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DiagnoseRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.DiagnoseRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.diagnoseRuntime = + stubLongRunningCall(expectedResponse); + const [operation] = await client.diagnoseRuntime(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.diagnoseRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.diagnoseRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromRuntimeName', () => { - const result = client.matchLocationFromRuntimeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.runtimePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes diagnoseRuntime without error using callback', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DiagnoseRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.DiagnoseRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.diagnoseRuntime = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.diagnoseRuntime( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1.IRuntime, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.diagnoseRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.diagnoseRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchRuntimeFromRuntimeName', () => { - const result = client.matchRuntimeFromRuntimeName(fakePath); - assert.strictEqual(result, "runtimeValue"); - assert((client.pathTemplates.runtimePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes diagnoseRuntime with call error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DiagnoseRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.DiagnoseRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.diagnoseRuntime = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.diagnoseRuntime(request), expectedError); + const actualRequest = ( + client.innerApiCalls.diagnoseRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.diagnoseRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('schedule', async () => { - const fakePath = "/rendered/path/schedule"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - schedule: "scheduleValue", - }; - const client = new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.schedulePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.schedulePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('schedulePath', () => { - const result = client.schedulePath("projectValue", "locationValue", "scheduleValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.schedulePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes diagnoseRuntime with LRO error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DiagnoseRuntimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.DiagnoseRuntimeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.diagnoseRuntime = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.diagnoseRuntime(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.diagnoseRuntime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.diagnoseRuntime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromScheduleName', () => { - const result = client.matchProjectFromScheduleName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.schedulePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkDiagnoseRuntimeProgress without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDiagnoseRuntimeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('matchLocationFromScheduleName', () => { - const result = client.matchLocationFromScheduleName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.schedulePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkDiagnoseRuntimeProgress with error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDiagnoseRuntimeProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listRuntimes', () => { + it('invokes listRuntimes without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListRuntimesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListRuntimesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), + ]; + client.innerApiCalls.listRuntimes = stubSimpleCall(expectedResponse); + const [response] = await client.listRuntimes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listRuntimes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listRuntimes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchScheduleFromScheduleName', () => { - const result = client.matchScheduleFromScheduleName(fakePath); - assert.strictEqual(result, "scheduleValue"); - assert((client.pathTemplates.schedulePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listRuntimes without error using callback', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListRuntimesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListRuntimesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), + ]; + client.innerApiCalls.listRuntimes = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listRuntimes( + request, + ( + err?: Error | null, + result?: protos.google.cloud.notebooks.v1.IRuntime[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listRuntimes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listRuntimes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listRuntimes with error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListRuntimesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListRuntimesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listRuntimes = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listRuntimes(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listRuntimes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listRuntimes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listRuntimesStream without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListRuntimesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListRuntimesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), + ]; + client.descriptors.page.listRuntimes.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listRuntimesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v1.Runtime[] = []; + stream.on( + 'data', + (response: protos.google.cloud.notebooks.v1.Runtime) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listRuntimes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listRuntimes, request), + ); + assert( + (client.descriptors.page.listRuntimes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + + it('invokes listRuntimesStream with error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListRuntimesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListRuntimesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRuntimes.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listRuntimesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v1.Runtime[] = []; + stream.on( + 'data', + (response: protos.google.cloud.notebooks.v1.Runtime) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listRuntimes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listRuntimes, request), + ); + assert( + (client.descriptors.page.listRuntimes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + + it('uses async iteration with listRuntimes without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListRuntimesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListRuntimesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Runtime()), + ]; + client.descriptors.page.listRuntimes.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.notebooks.v1.IRuntime[] = []; + const iterable = client.listRuntimesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listRuntimes.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listRuntimes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + + it('uses async iteration with listRuntimes with error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListRuntimesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListRuntimesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRuntimes.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listRuntimesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.notebooks.v1.IRuntime[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listRuntimes.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listRuntimes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getIamPolicy without error using callback', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); + }); + it('invokes getIamPolicy with error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes setIamPolicy without error using callback', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); + }); + it('invokes setIamPolicy with error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes testIamPermissions without error using callback', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); + }); + it('invokes testIamPermissions with error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('environment', async () => { + const fakePath = '/rendered/path/environment'; + const expectedParameters = { + project: 'projectValue', + environment: 'environmentValue', + }; + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.environmentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.environmentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('environmentPath', () => { + const result = client.environmentPath( + 'projectValue', + 'environmentValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.environmentPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromEnvironmentName', () => { + const result = client.matchProjectFromEnvironmentName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.environmentPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEnvironmentFromEnvironmentName', () => { + const result = client.matchEnvironmentFromEnvironmentName(fakePath); + assert.strictEqual(result, 'environmentValue'); + assert( + (client.pathTemplates.environmentPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('execution', async () => { + const fakePath = '/rendered/path/execution'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + execution: 'executionValue', + }; + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.executionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.executionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('executionPath', () => { + const result = client.executionPath( + 'projectValue', + 'locationValue', + 'executionValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.executionPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromExecutionName', () => { + const result = client.matchProjectFromExecutionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromExecutionName', () => { + const result = client.matchLocationFromExecutionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchExecutionFromExecutionName', () => { + const result = client.matchExecutionFromExecutionName(fakePath); + assert.strictEqual(result, 'executionValue'); + assert( + (client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('instance', async () => { + const fakePath = '/rendered/path/instance'; + const expectedParameters = { + project: 'projectValue', + instance: 'instanceValue', + }; + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.instancePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.instancePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('instancePath', () => { + const result = client.instancePath('projectValue', 'instanceValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.instancePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromInstanceName', () => { + const result = client.matchProjectFromInstanceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchInstanceFromInstanceName', () => { + const result = client.matchInstanceFromInstanceName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('runtime', async () => { + const fakePath = '/rendered/path/runtime'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + runtime: 'runtimeValue', + }; + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.runtimePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.runtimePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('runtimePath', () => { + const result = client.runtimePath( + 'projectValue', + 'locationValue', + 'runtimeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.runtimePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromRuntimeName', () => { + const result = client.matchProjectFromRuntimeName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.runtimePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromRuntimeName', () => { + const result = client.matchLocationFromRuntimeName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.runtimePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRuntimeFromRuntimeName', () => { + const result = client.matchRuntimeFromRuntimeName(fakePath); + assert.strictEqual(result, 'runtimeValue'); + assert( + (client.pathTemplates.runtimePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('schedule', async () => { + const fakePath = '/rendered/path/schedule'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + schedule: 'scheduleValue', + }; + const client = + new managednotebookserviceModule.v1.ManagedNotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + client.pathTemplates.schedulePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.schedulePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('schedulePath', () => { + const result = client.schedulePath( + 'projectValue', + 'locationValue', + 'scheduleValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.schedulePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromScheduleName', () => { + const result = client.matchProjectFromScheduleName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.schedulePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromScheduleName', () => { + const result = client.matchLocationFromScheduleName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.schedulePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchScheduleFromScheduleName', () => { + const result = client.matchScheduleFromScheduleName(fakePath); + assert.strictEqual(result, 'scheduleValue'); + assert( + (client.pathTemplates.schedulePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-notebooks/test/gapic_notebook_service_v1.ts b/packages/google-cloud-notebooks/test/gapic_notebook_service_v1.ts index a66f880835ea..6b495d1bccec 100644 --- a/packages/google-cloud-notebooks/test/gapic_notebook_service_v1.ts +++ b/packages/google-cloud-notebooks/test/gapic_notebook_service_v1.ts @@ -19,6451 +19,8121 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as notebookserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + IamProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1.NotebookServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new notebookserviceModule.v1.NotebookServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'notebooks.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new notebookserviceModule.v1.NotebookServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = notebookserviceModule.v1.NotebookServiceClient.servicePath; - assert.strictEqual(servicePath, 'notebooks.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = notebookserviceModule.v1.NotebookServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'notebooks.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'notebooks.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'notebooks.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new notebookserviceModule.v1.NotebookServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'notebooks.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new notebookserviceModule.v1.NotebookServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'notebooks.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new notebookserviceModule.v1.NotebookServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = notebookserviceModule.v1.NotebookServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new notebookserviceModule.v1.NotebookServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.notebookServiceStub, undefined); - await client.initialize(); - assert(client.notebookServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.notebookServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has close method for the non-initialized client', done => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.notebookServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new notebookserviceModule.v1.NotebookServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'notebooks.googleapis.com'); }); - describe('getInstance', () => { - it('invokes getInstance without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.Instance() - ); - client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); - const [response] = await client.getInstance(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstance without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.Instance() - ); - client.innerApiCalls.getInstance = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getInstance( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IInstance|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstance with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getInstance = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstance with closed client', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getInstance(request), expectedError); - }); + it('has universeDomain', () => { + const client = new notebookserviceModule.v1.NotebookServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); }); - describe('updateInstanceMetadataItems', () => { - it('invokes updateInstanceMetadataItems without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsResponse() - ); - client.innerApiCalls.updateInstanceMetadataItems = stubSimpleCall(expectedResponse); - const [response] = await client.updateInstanceMetadataItems(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateInstanceMetadataItems as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstanceMetadataItems as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInstanceMetadataItems without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsResponse() - ); - client.innerApiCalls.updateInstanceMetadataItems = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateInstanceMetadataItems( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateInstanceMetadataItems as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstanceMetadataItems as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInstanceMetadataItems with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateInstanceMetadataItems = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateInstanceMetadataItems(request), expectedError); - const actualRequest = (client.innerApiCalls.updateInstanceMetadataItems as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstanceMetadataItems as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInstanceMetadataItems with closed client', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateInstanceMetadataItems(request), expectedError); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + notebookserviceModule.v1.NotebookServiceClient.servicePath; + assert.strictEqual(servicePath, 'notebooks.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + notebookserviceModule.v1.NotebookServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'notebooks.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'notebooks.example.com'); }); - describe('isInstanceUpgradeable', () => { - it('invokes isInstanceUpgradeable without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest', ['notebookInstance']); - request.notebookInstance = defaultValue1; - const expectedHeaderRequestParams = `notebook_instance=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.IsInstanceUpgradeableResponse() - ); - client.innerApiCalls.isInstanceUpgradeable = stubSimpleCall(expectedResponse); - const [response] = await client.isInstanceUpgradeable(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes isInstanceUpgradeable without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest', ['notebookInstance']); - request.notebookInstance = defaultValue1; - const expectedHeaderRequestParams = `notebook_instance=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.IsInstanceUpgradeableResponse() - ); - client.innerApiCalls.isInstanceUpgradeable = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.isInstanceUpgradeable( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes isInstanceUpgradeable with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest', ['notebookInstance']); - request.notebookInstance = defaultValue1; - const expectedHeaderRequestParams = `notebook_instance=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.isInstanceUpgradeable = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.isInstanceUpgradeable(request), expectedError); - const actualRequest = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes isInstanceUpgradeable with closed client', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest', ['notebookInstance']); - request.notebookInstance = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.isInstanceUpgradeable(request), expectedError); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'notebooks.example.com'); }); - describe('getInstanceHealth', () => { - it('invokes getInstanceHealth without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetInstanceHealthRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetInstanceHealthRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetInstanceHealthResponse() - ); - client.innerApiCalls.getInstanceHealth = stubSimpleCall(expectedResponse); - const [response] = await client.getInstanceHealth(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstanceHealth as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstanceHealth as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstanceHealth without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetInstanceHealthRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetInstanceHealthRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetInstanceHealthResponse() - ); - client.innerApiCalls.getInstanceHealth = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getInstanceHealth( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IGetInstanceHealthResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstanceHealth as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstanceHealth as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstanceHealth with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetInstanceHealthRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetInstanceHealthRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getInstanceHealth = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getInstanceHealth(request), expectedError); - const actualRequest = (client.innerApiCalls.getInstanceHealth as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstanceHealth as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstanceHealth with closed client', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetInstanceHealthRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetInstanceHealthRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getInstanceHealth(request), expectedError); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new notebookserviceModule.v1.NotebookServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'notebooks.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new notebookserviceModule.v1.NotebookServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'notebooks.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new notebookserviceModule.v1.NotebookServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); }); - describe('getEnvironment', () => { - it('invokes getEnvironment without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.Environment() - ); - client.innerApiCalls.getEnvironment = stubSimpleCall(expectedResponse); - const [response] = await client.getEnvironment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getEnvironment without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.Environment() - ); - client.innerApiCalls.getEnvironment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getEnvironment( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IEnvironment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getEnvironment with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getEnvironment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getEnvironment(request), expectedError); - const actualRequest = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getEnvironment with closed client', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getEnvironment(request), expectedError); - }); + it('has port', () => { + const port = notebookserviceModule.v1.NotebookServiceClient.port; + assert(port); + assert(typeof port === 'number'); }); - describe('getSchedule', () => { - it('invokes getSchedule without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetScheduleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.Schedule() - ); - client.innerApiCalls.getSchedule = stubSimpleCall(expectedResponse); - const [response] = await client.getSchedule(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSchedule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSchedule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getSchedule without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetScheduleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.Schedule() - ); - client.innerApiCalls.getSchedule = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getSchedule( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1.ISchedule|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSchedule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSchedule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getSchedule with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetScheduleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getSchedule = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getSchedule(request), expectedError); - const actualRequest = (client.innerApiCalls.getSchedule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSchedule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('should create a client with no option', () => { + const client = new notebookserviceModule.v1.NotebookServiceClient(); + assert(client); + }); - it('invokes getSchedule with closed client', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetScheduleRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getSchedule(request), expectedError); - }); + it('should create a client with gRPC fallback', () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + fallback: true, + }); + assert(client); }); - describe('getExecution', () => { - it('invokes getExecution without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetExecutionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.Execution() - ); - client.innerApiCalls.getExecution = stubSimpleCall(expectedResponse); - const [response] = await client.getExecution(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getExecution as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getExecution as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.notebookServiceStub, undefined); + await client.initialize(); + assert(client.notebookServiceStub); + }); - it('invokes getExecution without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetExecutionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1.Execution() - ); - client.innerApiCalls.getExecution = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getExecution( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IExecution|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getExecution as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getExecution as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the initialized client', (done) => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.notebookServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getExecution with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetExecutionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getExecution = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getExecution(request), expectedError); - const actualRequest = (client.innerApiCalls.getExecution as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getExecution as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the non-initialized client', (done) => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.notebookServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getExecution with closed client', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.GetExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.GetExecutionRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getExecution(request), expectedError); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); }); - describe('createInstance', () => { - it('invokes createInstance without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.createInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getInstance', () => { + it('invokes getInstance without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.Instance(), + ); + client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); + const [response] = await client.getInstance(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createInstance without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getInstance without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.Instance(), + ); + client.innerApiCalls.getInstance = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getInstance( + request, + ( + err?: Error | null, + result?: protos.google.cloud.notebooks.v1.IInstance | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createInstance with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getInstance with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getInstance = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createInstance with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getInstance with closed client', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getInstance(request), expectedError); + }); + }); + + describe('updateInstanceMetadataItems', () => { + it('invokes updateInstanceMetadataItems without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsResponse(), + ); + client.innerApiCalls.updateInstanceMetadataItems = + stubSimpleCall(expectedResponse); + const [response] = await client.updateInstanceMetadataItems(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateInstanceMetadataItems as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstanceMetadataItems as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateInstanceMetadataItems without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsResponse(), + ); + client.innerApiCalls.updateInstanceMetadataItems = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateInstanceMetadataItems( + request, + ( + err?: Error | null, + result?: protos.google.cloud.notebooks.v1.IUpdateInstanceMetadataItemsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateInstanceMetadataItems as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstanceMetadataItems as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateInstanceMetadataItems with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInstanceMetadataItems = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.updateInstanceMetadataItems(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.updateInstanceMetadataItems as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstanceMetadataItems as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('registerInstance', () => { - it('invokes registerInstance without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.RegisterInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.RegisterInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.registerInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.registerInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.registerInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.registerInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateInstanceMetadataItems with closed client', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.UpdateInstanceMetadataItemsRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.updateInstanceMetadataItems(request), + expectedError, + ); + }); + }); + + describe('isInstanceUpgradeable', () => { + it('invokes isInstanceUpgradeable without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest', + ['notebookInstance'], + ); + request.notebookInstance = defaultValue1; + const expectedHeaderRequestParams = `notebook_instance=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.IsInstanceUpgradeableResponse(), + ); + client.innerApiCalls.isInstanceUpgradeable = + stubSimpleCall(expectedResponse); + const [response] = await client.isInstanceUpgradeable(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.isInstanceUpgradeable as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.isInstanceUpgradeable as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes registerInstance without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.RegisterInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.RegisterInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.registerInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.registerInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.registerInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.registerInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes isInstanceUpgradeable without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest', + ['notebookInstance'], + ); + request.notebookInstance = defaultValue1; + const expectedHeaderRequestParams = `notebook_instance=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.IsInstanceUpgradeableResponse(), + ); + client.innerApiCalls.isInstanceUpgradeable = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.isInstanceUpgradeable( + request, + ( + err?: Error | null, + result?: protos.google.cloud.notebooks.v1.IIsInstanceUpgradeableResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.isInstanceUpgradeable as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.isInstanceUpgradeable as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes registerInstance with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.RegisterInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.RegisterInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.registerInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.registerInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.registerInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.registerInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes isInstanceUpgradeable with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest', + ['notebookInstance'], + ); + request.notebookInstance = defaultValue1; + const expectedHeaderRequestParams = `notebook_instance=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.isInstanceUpgradeable = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.isInstanceUpgradeable(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.isInstanceUpgradeable as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.isInstanceUpgradeable as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes registerInstance with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.RegisterInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.RegisterInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.registerInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.registerInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.registerInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.registerInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes isInstanceUpgradeable with closed client', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.IsInstanceUpgradeableRequest', + ['notebookInstance'], + ); + request.notebookInstance = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.isInstanceUpgradeable(request), + expectedError, + ); + }); + }); + + describe('getInstanceHealth', () => { + it('invokes getInstanceHealth without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetInstanceHealthRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.GetInstanceHealthRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetInstanceHealthResponse(), + ); + client.innerApiCalls.getInstanceHealth = stubSimpleCall(expectedResponse); + const [response] = await client.getInstanceHealth(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getInstanceHealth as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstanceHealth as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRegisterInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkRegisterInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes getInstanceHealth without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetInstanceHealthRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.GetInstanceHealthRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetInstanceHealthResponse(), + ); + client.innerApiCalls.getInstanceHealth = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getInstanceHealth( + request, + ( + err?: Error | null, + result?: protos.google.cloud.notebooks.v1.IGetInstanceHealthResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getInstanceHealth as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstanceHealth as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRegisterInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRegisterInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes getInstanceHealth with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetInstanceHealthRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.GetInstanceHealthRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getInstanceHealth = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getInstanceHealth(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getInstanceHealth as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstanceHealth as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('setInstanceAccelerator', () => { - it('invokes setInstanceAccelerator without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.setInstanceAccelerator = stubLongRunningCall(expectedResponse); - const [operation] = await client.setInstanceAccelerator(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setInstanceAccelerator as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceAccelerator as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getInstanceHealth with closed client', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetInstanceHealthRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.GetInstanceHealthRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getInstanceHealth(request), expectedError); + }); + }); + + describe('getEnvironment', () => { + it('invokes getEnvironment without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.GetEnvironmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.Environment(), + ); + client.innerApiCalls.getEnvironment = stubSimpleCall(expectedResponse); + const [response] = await client.getEnvironment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getEnvironment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEnvironment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes setInstanceAccelerator without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.setInstanceAccelerator = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setInstanceAccelerator( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setInstanceAccelerator as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceAccelerator as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getEnvironment without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.GetEnvironmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.Environment(), + ); + client.innerApiCalls.getEnvironment = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getEnvironment( + request, + ( + err?: Error | null, + result?: protos.google.cloud.notebooks.v1.IEnvironment | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getEnvironment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEnvironment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes setInstanceAccelerator with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.setInstanceAccelerator = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.setInstanceAccelerator(request), expectedError); - const actualRequest = (client.innerApiCalls.setInstanceAccelerator as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceAccelerator as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getEnvironment with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.GetEnvironmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getEnvironment = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getEnvironment(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getEnvironment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEnvironment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes setInstanceAccelerator with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.setInstanceAccelerator = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.setInstanceAccelerator(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.setInstanceAccelerator as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceAccelerator as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getEnvironment with closed client', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.GetEnvironmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getEnvironment(request), expectedError); + }); + }); + + describe('getSchedule', () => { + it('invokes getSchedule without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetScheduleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.GetScheduleRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.Schedule(), + ); + client.innerApiCalls.getSchedule = stubSimpleCall(expectedResponse); + const [response] = await client.getSchedule(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getSchedule as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSchedule as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkSetInstanceAcceleratorProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkSetInstanceAcceleratorProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes getSchedule without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetScheduleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.GetScheduleRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.Schedule(), + ); + client.innerApiCalls.getSchedule = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getSchedule( + request, + ( + err?: Error | null, + result?: protos.google.cloud.notebooks.v1.ISchedule | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getSchedule as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSchedule as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkSetInstanceAcceleratorProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkSetInstanceAcceleratorProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes getSchedule with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetScheduleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.GetScheduleRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getSchedule = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getSchedule(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getSchedule as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSchedule as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('setInstanceMachineType', () => { - it('invokes setInstanceMachineType without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.setInstanceMachineType = stubLongRunningCall(expectedResponse); - const [operation] = await client.setInstanceMachineType(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setInstanceMachineType as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceMachineType as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getSchedule with closed client', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetScheduleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.GetScheduleRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getSchedule(request), expectedError); + }); + }); + + describe('getExecution', () => { + it('invokes getExecution without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetExecutionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.GetExecutionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.Execution(), + ); + client.innerApiCalls.getExecution = stubSimpleCall(expectedResponse); + const [response] = await client.getExecution(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes setInstanceMachineType without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.setInstanceMachineType = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setInstanceMachineType( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setInstanceMachineType as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceMachineType as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getExecution without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetExecutionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.GetExecutionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1.Execution(), + ); + client.innerApiCalls.getExecution = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getExecution( + request, + ( + err?: Error | null, + result?: protos.google.cloud.notebooks.v1.IExecution | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes setInstanceMachineType with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.setInstanceMachineType = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.setInstanceMachineType(request), expectedError); - const actualRequest = (client.innerApiCalls.setInstanceMachineType as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceMachineType as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getExecution with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetExecutionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.GetExecutionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getExecution = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getExecution(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes setInstanceMachineType with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.setInstanceMachineType = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.setInstanceMachineType(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.setInstanceMachineType as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceMachineType as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getExecution with closed client', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.GetExecutionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.GetExecutionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getExecution(request), expectedError); + }); + }); + + describe('createInstance', () => { + it('invokes createInstance without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.CreateInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkSetInstanceMachineTypeProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkSetInstanceMachineTypeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createInstance without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.CreateInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkSetInstanceMachineTypeProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkSetInstanceMachineTypeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createInstance with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.CreateInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateInstanceConfig', () => { - it('invokes updateInstanceConfig without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateInstanceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateInstanceConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateInstanceConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateInstanceConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateInstanceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstanceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createInstance with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.CreateInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateInstanceConfig without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateInstanceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateInstanceConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateInstanceConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateInstanceConfig( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateInstanceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstanceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateInstanceConfig with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateInstanceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateInstanceConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateInstanceConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateInstanceConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.updateInstanceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstanceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('registerInstance', () => { + it('invokes registerInstance without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.RegisterInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.RegisterInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.registerInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.registerInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.registerInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.registerInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateInstanceConfig with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateInstanceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateInstanceConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateInstanceConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateInstanceConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateInstanceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstanceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes registerInstance without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.RegisterInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.RegisterInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.registerInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.registerInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.registerInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.registerInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateInstanceConfigProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateInstanceConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes registerInstance with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.RegisterInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.RegisterInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.registerInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.registerInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.registerInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.registerInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateInstanceConfigProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateInstanceConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes registerInstance with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.RegisterInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.RegisterInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.registerInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.registerInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.registerInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.registerInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateShieldedInstanceConfig', () => { - it('invokes updateShieldedInstanceConfig without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateShieldedInstanceConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateShieldedInstanceConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateShieldedInstanceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateShieldedInstanceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRegisterInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkRegisterInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateShieldedInstanceConfig without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateShieldedInstanceConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateShieldedInstanceConfig( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateShieldedInstanceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateShieldedInstanceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRegisterInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkRegisterInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('setInstanceAccelerator', () => { + it('invokes setInstanceAccelerator without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.setInstanceAccelerator = + stubLongRunningCall(expectedResponse); + const [operation] = await client.setInstanceAccelerator(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setInstanceAccelerator as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInstanceAccelerator as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateShieldedInstanceConfig with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateShieldedInstanceConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateShieldedInstanceConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.updateShieldedInstanceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateShieldedInstanceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes setInstanceAccelerator without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.setInstanceAccelerator = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setInstanceAccelerator( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setInstanceAccelerator as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInstanceAccelerator as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateShieldedInstanceConfig with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateShieldedInstanceConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateShieldedInstanceConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateShieldedInstanceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateShieldedInstanceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes setInstanceAccelerator with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInstanceAccelerator = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.setInstanceAccelerator(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.setInstanceAccelerator as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInstanceAccelerator as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateShieldedInstanceConfigProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateShieldedInstanceConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes setInstanceAccelerator with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.SetInstanceAcceleratorRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInstanceAccelerator = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.setInstanceAccelerator(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.setInstanceAccelerator as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInstanceAccelerator as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateShieldedInstanceConfigProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateShieldedInstanceConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkSetInstanceAcceleratorProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkSetInstanceAcceleratorProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('setInstanceLabels', () => { - it('invokes setInstanceLabels without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SetInstanceLabelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceLabelsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.setInstanceLabels = stubLongRunningCall(expectedResponse); - const [operation] = await client.setInstanceLabels(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setInstanceLabels as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceLabels as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkSetInstanceAcceleratorProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkSetInstanceAcceleratorProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('setInstanceMachineType', () => { + it('invokes setInstanceMachineType without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.setInstanceMachineType = + stubLongRunningCall(expectedResponse); + const [operation] = await client.setInstanceMachineType(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setInstanceMachineType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInstanceMachineType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes setInstanceLabels without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SetInstanceLabelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceLabelsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.setInstanceLabels = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setInstanceLabels( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setInstanceLabels as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceLabels as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes setInstanceMachineType without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.setInstanceMachineType = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setInstanceMachineType( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setInstanceMachineType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInstanceMachineType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes setInstanceLabels with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SetInstanceLabelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceLabelsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.setInstanceLabels = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.setInstanceLabels(request), expectedError); - const actualRequest = (client.innerApiCalls.setInstanceLabels as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceLabels as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes setInstanceMachineType with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInstanceMachineType = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.setInstanceMachineType(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.setInstanceMachineType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInstanceMachineType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes setInstanceLabels with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.SetInstanceLabelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.SetInstanceLabelsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.setInstanceLabels = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.setInstanceLabels(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.setInstanceLabels as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceLabels as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes setInstanceMachineType with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.SetInstanceMachineTypeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInstanceMachineType = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.setInstanceMachineType(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.setInstanceMachineType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInstanceMachineType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkSetInstanceLabelsProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkSetInstanceLabelsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkSetInstanceMachineTypeProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkSetInstanceMachineTypeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkSetInstanceLabelsProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkSetInstanceLabelsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkSetInstanceMachineTypeProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkSetInstanceMachineTypeProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateInstanceConfig', () => { + it('invokes updateInstanceConfig without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateInstanceConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.UpdateInstanceConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateInstanceConfig = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateInstanceConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateInstanceConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstanceConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteInstance', () => { - it('invokes deleteInstance without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateInstanceConfig without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateInstanceConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.UpdateInstanceConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateInstanceConfig = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateInstanceConfig( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateInstanceConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstanceConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteInstance without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateInstanceConfig with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateInstanceConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.UpdateInstanceConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInstanceConfig = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateInstanceConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateInstanceConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstanceConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteInstance with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateInstanceConfig with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateInstanceConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.UpdateInstanceConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInstanceConfig = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateInstanceConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateInstanceConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstanceConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteInstance with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateInstanceConfigProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateInstanceConfigProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateInstanceConfigProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateInstanceConfigProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateShieldedInstanceConfig', () => { + it('invokes updateShieldedInstanceConfig without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateShieldedInstanceConfig = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateShieldedInstanceConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateShieldedInstanceConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateShieldedInstanceConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateShieldedInstanceConfig without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateShieldedInstanceConfig = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateShieldedInstanceConfig( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateShieldedInstanceConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateShieldedInstanceConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('startInstance', () => { - it('invokes startInstance without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StartInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StartInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.startInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.startInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateShieldedInstanceConfig with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateShieldedInstanceConfig = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.updateShieldedInstanceConfig(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.updateShieldedInstanceConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateShieldedInstanceConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes startInstance without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StartInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StartInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.startInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.startInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateShieldedInstanceConfig with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.UpdateShieldedInstanceConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateShieldedInstanceConfig = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateShieldedInstanceConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateShieldedInstanceConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateShieldedInstanceConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes startInstance with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StartInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StartInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.startInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.startInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateShieldedInstanceConfigProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateShieldedInstanceConfigProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes startInstance with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StartInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StartInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.startInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.startInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateShieldedInstanceConfigProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateShieldedInstanceConfigProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('setInstanceLabels', () => { + it('invokes setInstanceLabels without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SetInstanceLabelsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.SetInstanceLabelsRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.setInstanceLabels = + stubLongRunningCall(expectedResponse); + const [operation] = await client.setInstanceLabels(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setInstanceLabels as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInstanceLabels as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkStartInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkStartInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes setInstanceLabels without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SetInstanceLabelsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.SetInstanceLabelsRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.setInstanceLabels = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setInstanceLabels( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setInstanceLabels as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInstanceLabels as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkStartInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkStartInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes setInstanceLabels with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SetInstanceLabelsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.SetInstanceLabelsRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInstanceLabels = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.setInstanceLabels(request), expectedError); + const actualRequest = ( + client.innerApiCalls.setInstanceLabels as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInstanceLabels as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('stopInstance', () => { - it('invokes stopInstance without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StopInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StopInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.stopInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.stopInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes setInstanceLabels with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.SetInstanceLabelsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.SetInstanceLabelsRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInstanceLabels = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.setInstanceLabels(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.setInstanceLabels as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInstanceLabels as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes stopInstance without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StopInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StopInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.stopInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.stopInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkSetInstanceLabelsProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkSetInstanceLabelsProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes stopInstance with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StopInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StopInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.stopInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.stopInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkSetInstanceLabelsProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkSetInstanceLabelsProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteInstance', () => { + it('invokes deleteInstance without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.DeleteInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes stopInstance with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.StopInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.StopInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.stopInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.stopInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteInstance without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.DeleteInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkStopInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkStopInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteInstance with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.DeleteInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkStopInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkStopInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteInstance with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.DeleteInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('resetInstance', () => { - it('invokes resetInstance without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ResetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ResetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.resetInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.resetInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes resetInstance without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ResetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ResetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.resetInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.resetInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('startInstance', () => { + it('invokes startInstance without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StartInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.StartInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.startInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.startInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.startInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes resetInstance with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ResetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ResetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.resetInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.resetInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes startInstance without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StartInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.StartInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.startInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.startInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.startInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes resetInstance with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ResetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ResetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.resetInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.resetInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes startInstance with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StartInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.StartInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.startInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.startInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.startInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkResetInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkResetInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes startInstance with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StartInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.StartInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.startInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.startInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.startInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkResetInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkResetInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkStartInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkStartInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('reportInstanceInfo', () => { - it('invokes reportInstanceInfo without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ReportInstanceInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ReportInstanceInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.reportInstanceInfo = stubLongRunningCall(expectedResponse); - const [operation] = await client.reportInstanceInfo(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.reportInstanceInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reportInstanceInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkStartInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkStartInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('stopInstance', () => { + it('invokes stopInstance without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StopInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.StopInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.stopInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.stopInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.stopInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes reportInstanceInfo without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ReportInstanceInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ReportInstanceInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.reportInstanceInfo = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.reportInstanceInfo( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.reportInstanceInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reportInstanceInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes stopInstance without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StopInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.StopInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.stopInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.stopInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.stopInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes reportInstanceInfo with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ReportInstanceInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ReportInstanceInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.reportInstanceInfo = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.reportInstanceInfo(request), expectedError); - const actualRequest = (client.innerApiCalls.reportInstanceInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reportInstanceInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes stopInstance with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StopInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.StopInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.stopInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.stopInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.stopInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes reportInstanceInfo with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ReportInstanceInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ReportInstanceInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.reportInstanceInfo = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.reportInstanceInfo(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.reportInstanceInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reportInstanceInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes stopInstance with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.StopInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.StopInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.stopInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.stopInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.stopInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkReportInstanceInfoProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkReportInstanceInfoProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkStopInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkStopInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkReportInstanceInfoProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkReportInstanceInfoProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkStopInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkStopInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('resetInstance', () => { + it('invokes resetInstance without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ResetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ResetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.resetInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.resetInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resetInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resetInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('upgradeInstance', () => { - it('invokes upgradeInstance without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.upgradeInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.upgradeInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes resetInstance without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ResetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ResetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.resetInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resetInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resetInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resetInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes upgradeInstance without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.upgradeInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.upgradeInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes resetInstance with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ResetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ResetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resetInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.resetInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.resetInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resetInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes upgradeInstance with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.upgradeInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.upgradeInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes resetInstance with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ResetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ResetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resetInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.resetInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.resetInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resetInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes upgradeInstance with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.upgradeInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.upgradeInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkResetInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkResetInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkUpgradeInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpgradeInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkResetInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkResetInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('reportInstanceInfo', () => { + it('invokes reportInstanceInfo without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ReportInstanceInfoRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ReportInstanceInfoRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.reportInstanceInfo = + stubLongRunningCall(expectedResponse); + const [operation] = await client.reportInstanceInfo(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.reportInstanceInfo as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reportInstanceInfo as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpgradeInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpgradeInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes reportInstanceInfo without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ReportInstanceInfoRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ReportInstanceInfoRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.reportInstanceInfo = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.reportInstanceInfo( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.reportInstanceInfo as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reportInstanceInfo as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('rollbackInstance', () => { - it('invokes rollbackInstance without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.RollbackInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.RollbackInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.rollbackInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.rollbackInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rollbackInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rollbackInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes reportInstanceInfo with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ReportInstanceInfoRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ReportInstanceInfoRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.reportInstanceInfo = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.reportInstanceInfo(request), expectedError); + const actualRequest = ( + client.innerApiCalls.reportInstanceInfo as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reportInstanceInfo as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes rollbackInstance without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.RollbackInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.RollbackInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.rollbackInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rollbackInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rollbackInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rollbackInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes reportInstanceInfo with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ReportInstanceInfoRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ReportInstanceInfoRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.reportInstanceInfo = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.reportInstanceInfo(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.reportInstanceInfo as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reportInstanceInfo as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes rollbackInstance with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.RollbackInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.RollbackInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rollbackInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.rollbackInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.rollbackInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rollbackInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkReportInstanceInfoProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkReportInstanceInfoProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes rollbackInstance with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.RollbackInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.RollbackInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rollbackInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.rollbackInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.rollbackInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rollbackInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkReportInstanceInfoProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkReportInstanceInfoProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('upgradeInstance', () => { + it('invokes upgradeInstance without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpgradeInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.UpgradeInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.upgradeInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.upgradeInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.upgradeInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.upgradeInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRollbackInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkRollbackInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes upgradeInstance without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpgradeInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.UpgradeInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.upgradeInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.upgradeInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.upgradeInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.upgradeInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRollbackInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRollbackInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes upgradeInstance with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpgradeInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.UpgradeInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.upgradeInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.upgradeInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.upgradeInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.upgradeInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('diagnoseInstance', () => { - it('invokes diagnoseInstance without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DiagnoseInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DiagnoseInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.diagnoseInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.diagnoseInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.diagnoseInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.diagnoseInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes upgradeInstance with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpgradeInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.UpgradeInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.upgradeInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.upgradeInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.upgradeInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.upgradeInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes diagnoseInstance without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DiagnoseInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DiagnoseInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.diagnoseInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.diagnoseInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.diagnoseInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.diagnoseInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpgradeInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpgradeInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes diagnoseInstance with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DiagnoseInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DiagnoseInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.diagnoseInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.diagnoseInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.diagnoseInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.diagnoseInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpgradeInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpgradeInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('rollbackInstance', () => { + it('invokes rollbackInstance without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.RollbackInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.RollbackInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.rollbackInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.rollbackInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rollbackInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rollbackInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes diagnoseInstance with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DiagnoseInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DiagnoseInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.diagnoseInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.diagnoseInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.diagnoseInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.diagnoseInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes rollbackInstance without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.RollbackInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.RollbackInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.rollbackInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rollbackInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rollbackInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rollbackInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDiagnoseInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDiagnoseInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes rollbackInstance with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.RollbackInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.RollbackInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rollbackInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.rollbackInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.rollbackInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rollbackInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDiagnoseInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDiagnoseInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes rollbackInstance with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.RollbackInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.RollbackInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rollbackInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.rollbackInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.rollbackInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rollbackInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('upgradeInstanceInternal', () => { - it('invokes upgradeInstanceInternal without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.upgradeInstanceInternal = stubLongRunningCall(expectedResponse); - const [operation] = await client.upgradeInstanceInternal(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRollbackInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkRollbackInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes upgradeInstanceInternal without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.upgradeInstanceInternal = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.upgradeInstanceInternal( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRollbackInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkRollbackInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('diagnoseInstance', () => { + it('invokes diagnoseInstance without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DiagnoseInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.DiagnoseInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.diagnoseInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.diagnoseInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.diagnoseInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.diagnoseInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes upgradeInstanceInternal with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.upgradeInstanceInternal = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.upgradeInstanceInternal(request), expectedError); - const actualRequest = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes diagnoseInstance without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DiagnoseInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.DiagnoseInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.diagnoseInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.diagnoseInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.diagnoseInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.diagnoseInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes upgradeInstanceInternal with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.upgradeInstanceInternal = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.upgradeInstanceInternal(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes diagnoseInstance with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DiagnoseInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.DiagnoseInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.diagnoseInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.diagnoseInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.diagnoseInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.diagnoseInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpgradeInstanceInternalProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpgradeInstanceInternalProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes diagnoseInstance with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DiagnoseInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.DiagnoseInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.diagnoseInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.diagnoseInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.diagnoseInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.diagnoseInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpgradeInstanceInternalProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpgradeInstanceInternalProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDiagnoseInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDiagnoseInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('createEnvironment', () => { - it('invokes createEnvironment without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateEnvironmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createEnvironment = stubLongRunningCall(expectedResponse); - const [operation] = await client.createEnvironment(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDiagnoseInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDiagnoseInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('upgradeInstanceInternal', () => { + it('invokes upgradeInstanceInternal without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.upgradeInstanceInternal = + stubLongRunningCall(expectedResponse); + const [operation] = await client.upgradeInstanceInternal(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.upgradeInstanceInternal as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.upgradeInstanceInternal as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createEnvironment without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateEnvironmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createEnvironment = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createEnvironment( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes upgradeInstanceInternal without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.upgradeInstanceInternal = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.upgradeInstanceInternal( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1.IInstance, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.upgradeInstanceInternal as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.upgradeInstanceInternal as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createEnvironment with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateEnvironmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createEnvironment = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createEnvironment(request), expectedError); - const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes upgradeInstanceInternal with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.upgradeInstanceInternal = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.upgradeInstanceInternal(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.upgradeInstanceInternal as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.upgradeInstanceInternal as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createEnvironment with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateEnvironmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createEnvironment = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createEnvironment(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes upgradeInstanceInternal with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.UpgradeInstanceInternalRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.upgradeInstanceInternal = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.upgradeInstanceInternal(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.upgradeInstanceInternal as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.upgradeInstanceInternal as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateEnvironmentProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateEnvironmentProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpgradeInstanceInternalProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpgradeInstanceInternalProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkCreateEnvironmentProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateEnvironmentProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpgradeInstanceInternalProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpgradeInstanceInternalProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createEnvironment', () => { + it('invokes createEnvironment without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.CreateEnvironmentRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createEnvironment = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createEnvironment(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createEnvironment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEnvironment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteEnvironment', () => { - it('invokes deleteEnvironment without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteEnvironment = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteEnvironment(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createEnvironment without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.CreateEnvironmentRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createEnvironment = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createEnvironment( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1.IEnvironment, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1.IEnvironment, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createEnvironment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEnvironment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteEnvironment without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteEnvironment = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteEnvironment( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createEnvironment with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.CreateEnvironmentRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createEnvironment = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createEnvironment(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createEnvironment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEnvironment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteEnvironment with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteEnvironment = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteEnvironment(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createEnvironment with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.CreateEnvironmentRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createEnvironment = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createEnvironment(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createEnvironment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEnvironment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteEnvironment with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteEnvironment = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteEnvironment(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateEnvironmentProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateEnvironmentProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteEnvironmentProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteEnvironmentProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkCreateEnvironmentProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateEnvironmentProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteEnvironment', () => { + it('invokes deleteEnvironment without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.DeleteEnvironmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteEnvironment = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteEnvironment(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteEnvironment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEnvironment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteEnvironmentProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteEnvironmentProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteEnvironment without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.DeleteEnvironmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteEnvironment = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteEnvironment( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteEnvironment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEnvironment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteSchedule', () => { - it('invokes deleteSchedule without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteScheduleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteSchedule = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteSchedule(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteSchedule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSchedule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteEnvironment with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.DeleteEnvironmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteEnvironment = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteEnvironment(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteEnvironment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEnvironment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteSchedule without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteScheduleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteSchedule = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteSchedule( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteSchedule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSchedule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteEnvironment with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.DeleteEnvironmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteEnvironment = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteEnvironment(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteEnvironment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEnvironment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteSchedule with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteScheduleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteSchedule = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteSchedule(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteSchedule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSchedule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteEnvironmentProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteEnvironmentProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteSchedule with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteScheduleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteSchedule = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteSchedule(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteSchedule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSchedule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteEnvironmentProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteEnvironmentProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteSchedule', () => { + it('invokes deleteSchedule without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteScheduleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.DeleteScheduleRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteSchedule = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteSchedule(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteSchedule as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSchedule as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteScheduleProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteScheduleProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteSchedule without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteScheduleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.DeleteScheduleRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteSchedule = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteSchedule( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteSchedule as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSchedule as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteScheduleProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteScheduleProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteSchedule with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteScheduleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.DeleteScheduleRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteSchedule = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteSchedule(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteSchedule as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSchedule as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createSchedule', () => { - it('invokes createSchedule without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateScheduleRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createSchedule = stubLongRunningCall(expectedResponse); - const [operation] = await client.createSchedule(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createSchedule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSchedule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteSchedule with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteScheduleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.DeleteScheduleRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteSchedule = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteSchedule(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteSchedule as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSchedule as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createSchedule without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateScheduleRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createSchedule = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createSchedule( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createSchedule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSchedule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteScheduleProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteScheduleProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createSchedule with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateScheduleRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createSchedule = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createSchedule(request), expectedError); - const actualRequest = (client.innerApiCalls.createSchedule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSchedule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteScheduleProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteScheduleProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createSchedule', () => { + it('invokes createSchedule without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateScheduleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.CreateScheduleRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createSchedule = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createSchedule(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createSchedule as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSchedule as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createSchedule with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateScheduleRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createSchedule = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createSchedule(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createSchedule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSchedule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createSchedule without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateScheduleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.CreateScheduleRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createSchedule = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createSchedule( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createSchedule as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSchedule as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateScheduleProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateScheduleProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createSchedule with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateScheduleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.CreateScheduleRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createSchedule = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createSchedule(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createSchedule as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSchedule as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateScheduleProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateScheduleProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createSchedule with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateScheduleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.CreateScheduleRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createSchedule = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createSchedule(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createSchedule as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSchedule as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('triggerSchedule', () => { - it('invokes triggerSchedule without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.TriggerScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.TriggerScheduleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.triggerSchedule = stubLongRunningCall(expectedResponse); - const [operation] = await client.triggerSchedule(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.triggerSchedule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.triggerSchedule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateScheduleProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateScheduleProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes triggerSchedule without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.TriggerScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.TriggerScheduleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.triggerSchedule = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.triggerSchedule( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.triggerSchedule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.triggerSchedule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateScheduleProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateScheduleProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('triggerSchedule', () => { + it('invokes triggerSchedule without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.TriggerScheduleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.TriggerScheduleRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.triggerSchedule = + stubLongRunningCall(expectedResponse); + const [operation] = await client.triggerSchedule(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.triggerSchedule as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.triggerSchedule as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes triggerSchedule with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.TriggerScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.TriggerScheduleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.triggerSchedule = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.triggerSchedule(request), expectedError); - const actualRequest = (client.innerApiCalls.triggerSchedule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.triggerSchedule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes triggerSchedule without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.TriggerScheduleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.TriggerScheduleRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.triggerSchedule = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.triggerSchedule( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1.ISchedule, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.triggerSchedule as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.triggerSchedule as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes triggerSchedule with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.TriggerScheduleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.TriggerScheduleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.triggerSchedule = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.triggerSchedule(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.triggerSchedule as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.triggerSchedule as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes triggerSchedule with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.TriggerScheduleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.TriggerScheduleRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.triggerSchedule = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.triggerSchedule(request), expectedError); + const actualRequest = ( + client.innerApiCalls.triggerSchedule as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.triggerSchedule as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkTriggerScheduleProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkTriggerScheduleProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes triggerSchedule with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.TriggerScheduleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.TriggerScheduleRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.triggerSchedule = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.triggerSchedule(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.triggerSchedule as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.triggerSchedule as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkTriggerScheduleProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkTriggerScheduleProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkTriggerScheduleProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkTriggerScheduleProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('deleteExecution', () => { - it('invokes deleteExecution without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteExecutionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteExecution = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteExecution(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteExecution as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteExecution as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkTriggerScheduleProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkTriggerScheduleProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteExecution', () => { + it('invokes deleteExecution without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteExecutionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.DeleteExecutionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteExecution = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteExecution(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteExecution without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteExecutionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteExecution = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteExecution( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteExecution as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteExecution as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteExecution without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteExecutionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.DeleteExecutionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteExecution = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteExecution( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteExecution with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteExecutionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteExecution = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteExecution(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteExecution as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteExecution as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteExecution with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteExecutionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.DeleteExecutionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteExecution = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteExecution(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteExecution with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.DeleteExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.DeleteExecutionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteExecution = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteExecution(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteExecution as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteExecution as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteExecution with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.DeleteExecutionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.DeleteExecutionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteExecution = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteExecution(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteExecutionProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteExecutionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkDeleteExecutionProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteExecutionProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteExecutionProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteExecutionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteExecutionProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteExecutionProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createExecution', () => { + it('invokes createExecution without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateExecutionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.CreateExecutionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createExecution = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createExecution(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createExecution', () => { - it('invokes createExecution without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateExecutionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createExecution = stubLongRunningCall(expectedResponse); - const [operation] = await client.createExecution(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createExecution as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createExecution as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createExecution without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateExecutionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.CreateExecutionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createExecution = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createExecution( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1.IExecution, + protos.google.cloud.notebooks.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1.IExecution, + protos.google.cloud.notebooks.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createExecution without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateExecutionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createExecution = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createExecution( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createExecution as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createExecution as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createExecution with call error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateExecutionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.CreateExecutionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createExecution = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createExecution(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createExecution with call error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateExecutionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createExecution = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createExecution(request), expectedError); - const actualRequest = (client.innerApiCalls.createExecution as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createExecution as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createExecution with LRO error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.CreateExecutionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.CreateExecutionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createExecution = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createExecution(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createExecution with LRO error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.CreateExecutionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.CreateExecutionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createExecution = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createExecution(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createExecution as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createExecution as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateExecutionProgress without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateExecutionProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkCreateExecutionProgress without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateExecutionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkCreateExecutionProgress with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateExecutionProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listInstances', () => { + it('invokes listInstances without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), + ]; + client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); + const [response] = await client.listInstances(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateExecutionProgress with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateExecutionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes listInstances without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), + ]; + client.innerApiCalls.listInstances = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listInstances( + request, + ( + err?: Error | null, + result?: protos.google.cloud.notebooks.v1.IInstance[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listInstances', () => { - it('invokes listInstances without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), - ]; - client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); - const [response] = await client.listInstances(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listInstances with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listInstances = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listInstances(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listInstances without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), - ]; - client.innerApiCalls.listInstances = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listInstances( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IInstance[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listInstancesStream without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), + ]; + client.descriptors.page.listInstances.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v1.Instance[] = []; + stream.on( + 'data', + (response: protos.google.cloud.notebooks.v1.Instance) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listInstances, request), + ); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listInstances with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listInstances = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listInstances(request), expectedError); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listInstancesStream with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstances.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v1.Instance[] = []; + stream.on( + 'data', + (response: protos.google.cloud.notebooks.v1.Instance) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listInstances, request), + ); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listInstancesStream without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), - ]; - client.descriptors.page.listInstances.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listInstancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v1.Instance[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v1.Instance) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); - assert( - (client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listInstances without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), + ]; + client.descriptors.page.listInstances.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.notebooks.v1.IInstance[] = []; + const iterable = client.listInstancesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listInstances.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listInstancesStream with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstances.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listInstancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v1.Instance[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v1.Instance) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); - assert( - (client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listInstances with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstances.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listInstancesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.notebooks.v1.IInstance[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listInstances.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listEnvironments', () => { + it('invokes listEnvironments without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListEnvironmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListEnvironmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.notebooks.v1.Environment(), + ), + generateSampleMessage( + new protos.google.cloud.notebooks.v1.Environment(), + ), + generateSampleMessage( + new protos.google.cloud.notebooks.v1.Environment(), + ), + ]; + client.innerApiCalls.listEnvironments = stubSimpleCall(expectedResponse); + const [response] = await client.listEnvironments(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listEnvironments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEnvironments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listInstances without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Instance()), - ]; - client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.notebooks.v1.IInstance[] = []; - const iterable = client.listInstancesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listEnvironments without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListEnvironmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListEnvironmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.notebooks.v1.Environment(), + ), + generateSampleMessage( + new protos.google.cloud.notebooks.v1.Environment(), + ), + generateSampleMessage( + new protos.google.cloud.notebooks.v1.Environment(), + ), + ]; + client.innerApiCalls.listEnvironments = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listEnvironments( + request, + ( + err?: Error | null, + result?: protos.google.cloud.notebooks.v1.IEnvironment[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listInstances with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listInstancesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.notebooks.v1.IInstance[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listEnvironments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEnvironments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listEnvironments', () => { - it('invokes listEnvironments without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), - ]; - client.innerApiCalls.listEnvironments = stubSimpleCall(expectedResponse); - const [response] = await client.listEnvironments(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listEnvironments with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListEnvironmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListEnvironmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listEnvironments = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listEnvironments(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listEnvironments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEnvironments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listEnvironments without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), - ]; - client.innerApiCalls.listEnvironments = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listEnvironments( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IEnvironment[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listEnvironmentsStream without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListEnvironmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListEnvironmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.notebooks.v1.Environment(), + ), + generateSampleMessage( + new protos.google.cloud.notebooks.v1.Environment(), + ), + generateSampleMessage( + new protos.google.cloud.notebooks.v1.Environment(), + ), + ]; + client.descriptors.page.listEnvironments.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listEnvironmentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v1.Environment[] = []; + stream.on( + 'data', + (response: protos.google.cloud.notebooks.v1.Environment) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listEnvironments.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listEnvironments, request), + ); + assert( + (client.descriptors.page.listEnvironments.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listEnvironments with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listEnvironments = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listEnvironments(request), expectedError); - const actualRequest = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listEnvironmentsStream with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListEnvironmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListEnvironmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listEnvironments.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listEnvironmentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v1.Environment[] = []; + stream.on( + 'data', + (response: protos.google.cloud.notebooks.v1.Environment) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listEnvironments.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listEnvironments, request), + ); + assert( + (client.descriptors.page.listEnvironments.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listEnvironmentsStream without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), - ]; - client.descriptors.page.listEnvironments.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listEnvironmentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v1.Environment[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v1.Environment) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listEnvironments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listEnvironments, request)); - assert( - (client.descriptors.page.listEnvironments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listEnvironments without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListEnvironmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListEnvironmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.notebooks.v1.Environment(), + ), + generateSampleMessage( + new protos.google.cloud.notebooks.v1.Environment(), + ), + generateSampleMessage( + new protos.google.cloud.notebooks.v1.Environment(), + ), + ]; + client.descriptors.page.listEnvironments.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.notebooks.v1.IEnvironment[] = []; + const iterable = client.listEnvironmentsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listEnvironments.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listEnvironmentsStream with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listEnvironments.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listEnvironmentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v1.Environment[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v1.Environment) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listEnvironments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listEnvironments, request)); - assert( - (client.descriptors.page.listEnvironments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listEnvironments with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListEnvironmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListEnvironmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listEnvironments.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listEnvironmentsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.notebooks.v1.IEnvironment[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listEnvironments.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listSchedules', () => { + it('invokes listSchedules without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListSchedulesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListSchedulesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), + ]; + client.innerApiCalls.listSchedules = stubSimpleCall(expectedResponse); + const [response] = await client.listSchedules(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listSchedules as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSchedules as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listEnvironments without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Environment()), - ]; - client.descriptors.page.listEnvironments.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.notebooks.v1.IEnvironment[] = []; - const iterable = client.listEnvironmentsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listSchedules without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListSchedulesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListSchedulesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), + ]; + client.innerApiCalls.listSchedules = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listSchedules( + request, + ( + err?: Error | null, + result?: protos.google.cloud.notebooks.v1.ISchedule[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listEnvironments with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listEnvironments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listEnvironmentsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.notebooks.v1.IEnvironment[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listSchedules as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSchedules as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listSchedules', () => { - it('invokes listSchedules without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListSchedulesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListSchedulesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), - ]; - client.innerApiCalls.listSchedules = stubSimpleCall(expectedResponse); - const [response] = await client.listSchedules(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSchedules as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSchedules as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listSchedules with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListSchedulesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListSchedulesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listSchedules = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listSchedules(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listSchedules as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSchedules as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listSchedules without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListSchedulesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListSchedulesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), - ]; - client.innerApiCalls.listSchedules = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listSchedules( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1.ISchedule[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSchedules as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSchedules as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listSchedulesStream without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListSchedulesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListSchedulesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), + ]; + client.descriptors.page.listSchedules.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listSchedulesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v1.Schedule[] = []; + stream.on( + 'data', + (response: protos.google.cloud.notebooks.v1.Schedule) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listSchedules.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listSchedules, request), + ); + assert( + (client.descriptors.page.listSchedules.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listSchedules with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListSchedulesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListSchedulesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listSchedules = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listSchedules(request), expectedError); - const actualRequest = (client.innerApiCalls.listSchedules as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSchedules as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listSchedulesStream with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListSchedulesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListSchedulesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSchedules.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listSchedulesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v1.Schedule[] = []; + stream.on( + 'data', + (response: protos.google.cloud.notebooks.v1.Schedule) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listSchedules.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listSchedules, request), + ); + assert( + (client.descriptors.page.listSchedules.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listSchedulesStream without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListSchedulesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListSchedulesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), - ]; - client.descriptors.page.listSchedules.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listSchedulesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v1.Schedule[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v1.Schedule) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listSchedules.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSchedules, request)); - assert( - (client.descriptors.page.listSchedules.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listSchedules without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListSchedulesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListSchedulesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), + ]; + client.descriptors.page.listSchedules.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.notebooks.v1.ISchedule[] = []; + const iterable = client.listSchedulesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listSchedules.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listSchedules.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listSchedulesStream with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListSchedulesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListSchedulesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listSchedules.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listSchedulesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v1.Schedule[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v1.Schedule) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listSchedules.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSchedules, request)); - assert( - (client.descriptors.page.listSchedules.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listSchedules with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListSchedulesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListSchedulesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSchedules.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listSchedulesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.notebooks.v1.ISchedule[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listSchedules.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listSchedules.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listExecutions', () => { + it('invokes listExecutions without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListExecutionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListExecutionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), + ]; + client.innerApiCalls.listExecutions = stubSimpleCall(expectedResponse); + const [response] = await client.listExecutions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listExecutions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listExecutions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listSchedules without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListSchedulesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListSchedulesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Schedule()), - ]; - client.descriptors.page.listSchedules.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.notebooks.v1.ISchedule[] = []; - const iterable = client.listSchedulesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listExecutions without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListExecutionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListExecutionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), + ]; + client.innerApiCalls.listExecutions = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listExecutions( + request, + ( + err?: Error | null, + result?: protos.google.cloud.notebooks.v1.IExecution[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listSchedules.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSchedules.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listSchedules with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListSchedulesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListSchedulesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listSchedules.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listSchedulesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.notebooks.v1.ISchedule[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listSchedules.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSchedules.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listExecutions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listExecutions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listExecutions', () => { - it('invokes listExecutions without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListExecutionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListExecutionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), - ]; - client.innerApiCalls.listExecutions = stubSimpleCall(expectedResponse); - const [response] = await client.listExecutions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listExecutions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listExecutions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listExecutions without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListExecutionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListExecutionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), - ]; - client.innerApiCalls.listExecutions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listExecutions( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1.IExecution[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listExecutions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listExecutions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listExecutions with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListExecutionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListExecutionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listExecutions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listExecutions(request), expectedError); - const actualRequest = (client.innerApiCalls.listExecutions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listExecutions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listExecutions with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListExecutionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListExecutionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listExecutions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listExecutions(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listExecutions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listExecutions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listExecutionsStream without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListExecutionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListExecutionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), - ]; - client.descriptors.page.listExecutions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listExecutionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v1.Execution[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v1.Execution) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listExecutions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listExecutions, request)); - assert( - (client.descriptors.page.listExecutions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listExecutionsStream without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListExecutionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListExecutionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), + ]; + client.descriptors.page.listExecutions.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listExecutionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v1.Execution[] = []; + stream.on( + 'data', + (response: protos.google.cloud.notebooks.v1.Execution) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listExecutions.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listExecutions, request), + ); + assert( + (client.descriptors.page.listExecutions.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listExecutionsStream with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListExecutionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListExecutionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listExecutions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listExecutionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v1.Execution[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v1.Execution) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listExecutions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listExecutions, request)); - assert( - (client.descriptors.page.listExecutions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listExecutionsStream with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListExecutionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListExecutionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listExecutions.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listExecutionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v1.Execution[] = []; + stream.on( + 'data', + (response: protos.google.cloud.notebooks.v1.Execution) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listExecutions.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listExecutions, request), + ); + assert( + (client.descriptors.page.listExecutions.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listExecutions without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListExecutionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListExecutionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), - generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), - ]; - client.descriptors.page.listExecutions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.notebooks.v1.IExecution[] = []; - const iterable = client.listExecutionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listExecutions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listExecutions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listExecutions without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListExecutionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListExecutionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), + generateSampleMessage(new protos.google.cloud.notebooks.v1.Execution()), + ]; + client.descriptors.page.listExecutions.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.notebooks.v1.IExecution[] = []; + const iterable = client.listExecutionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listExecutions.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listExecutions.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listExecutions with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1.ListExecutionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1.ListExecutionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listExecutions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listExecutionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.notebooks.v1.IExecution[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listExecutions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listExecutions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listExecutions with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1.ListExecutionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1.ListExecutionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listExecutions.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listExecutionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.notebooks.v1.IExecution[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listExecutions.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listExecutions.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes setIamPolicy with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); + }); + it('invokes testIamPermissions with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('environment', async () => { + const fakePath = '/rendered/path/environment'; + const expectedParameters = { + project: 'projectValue', + environment: 'environmentValue', + }; + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.environmentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.environmentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('environmentPath', () => { + const result = client.environmentPath( + 'projectValue', + 'environmentValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.environmentPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromEnvironmentName', () => { + const result = client.matchProjectFromEnvironmentName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.environmentPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEnvironmentFromEnvironmentName', () => { + const result = client.matchEnvironmentFromEnvironmentName(fakePath); + assert.strictEqual(result, 'environmentValue'); + assert( + (client.pathTemplates.environmentPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('environment', async () => { - const fakePath = "/rendered/path/environment"; - const expectedParameters = { - project: "projectValue", - environment: "environmentValue", - }; - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.environmentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.environmentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('environmentPath', () => { - const result = client.environmentPath("projectValue", "environmentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.environmentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromEnvironmentName', () => { - const result = client.matchProjectFromEnvironmentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEnvironmentFromEnvironmentName', () => { - const result = client.matchEnvironmentFromEnvironmentName(fakePath); - assert.strictEqual(result, "environmentValue"); - assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('execution', async () => { - const fakePath = "/rendered/path/execution"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - execution: "executionValue", - }; - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.executionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.executionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('executionPath', () => { - const result = client.executionPath("projectValue", "locationValue", "executionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.executionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromExecutionName', () => { - const result = client.matchProjectFromExecutionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromExecutionName', () => { - const result = client.matchLocationFromExecutionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchExecutionFromExecutionName', () => { - const result = client.matchExecutionFromExecutionName(fakePath); - assert.strictEqual(result, "executionValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('execution', async () => { + const fakePath = '/rendered/path/execution'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + execution: 'executionValue', + }; + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.executionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.executionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('executionPath', () => { + const result = client.executionPath( + 'projectValue', + 'locationValue', + 'executionValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.executionPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromExecutionName', () => { + const result = client.matchProjectFromExecutionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromExecutionName', () => { + const result = client.matchLocationFromExecutionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchExecutionFromExecutionName', () => { + const result = client.matchExecutionFromExecutionName(fakePath); + assert.strictEqual(result, 'executionValue'); + assert( + (client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('instance', async () => { - const fakePath = "/rendered/path/instance"; - const expectedParameters = { - project: "projectValue", - instance: "instanceValue", - }; - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.instancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.instancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('instancePath', () => { - const result = client.instancePath("projectValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.instancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInstanceName', () => { - const result = client.matchProjectFromInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromInstanceName', () => { - const result = client.matchInstanceFromInstanceName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('instance', async () => { + const fakePath = '/rendered/path/instance'; + const expectedParameters = { + project: 'projectValue', + instance: 'instanceValue', + }; + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.instancePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.instancePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('instancePath', () => { + const result = client.instancePath('projectValue', 'instanceValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.instancePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromInstanceName', () => { + const result = client.matchProjectFromInstanceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchInstanceFromInstanceName', () => { + const result = client.matchInstanceFromInstanceName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('runtime', async () => { - const fakePath = "/rendered/path/runtime"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - runtime: "runtimeValue", - }; - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.runtimePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.runtimePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('runtimePath', () => { - const result = client.runtimePath("projectValue", "locationValue", "runtimeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.runtimePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRuntimeName', () => { - const result = client.matchProjectFromRuntimeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.runtimePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromRuntimeName', () => { - const result = client.matchLocationFromRuntimeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.runtimePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRuntimeFromRuntimeName', () => { - const result = client.matchRuntimeFromRuntimeName(fakePath); - assert.strictEqual(result, "runtimeValue"); - assert((client.pathTemplates.runtimePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('runtime', async () => { + const fakePath = '/rendered/path/runtime'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + runtime: 'runtimeValue', + }; + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.runtimePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.runtimePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('runtimePath', () => { + const result = client.runtimePath( + 'projectValue', + 'locationValue', + 'runtimeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.runtimePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromRuntimeName', () => { + const result = client.matchProjectFromRuntimeName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.runtimePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromRuntimeName', () => { + const result = client.matchLocationFromRuntimeName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.runtimePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRuntimeFromRuntimeName', () => { + const result = client.matchRuntimeFromRuntimeName(fakePath); + assert.strictEqual(result, 'runtimeValue'); + assert( + (client.pathTemplates.runtimePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('schedule', async () => { - const fakePath = "/rendered/path/schedule"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - schedule: "scheduleValue", - }; - const client = new notebookserviceModule.v1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.schedulePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.schedulePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('schedulePath', () => { - const result = client.schedulePath("projectValue", "locationValue", "scheduleValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.schedulePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromScheduleName', () => { - const result = client.matchProjectFromScheduleName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.schedulePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromScheduleName', () => { - const result = client.matchLocationFromScheduleName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.schedulePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchScheduleFromScheduleName', () => { - const result = client.matchScheduleFromScheduleName(fakePath); - assert.strictEqual(result, "scheduleValue"); - assert((client.pathTemplates.schedulePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('schedule', async () => { + const fakePath = '/rendered/path/schedule'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + schedule: 'scheduleValue', + }; + const client = new notebookserviceModule.v1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.schedulePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.schedulePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('schedulePath', () => { + const result = client.schedulePath( + 'projectValue', + 'locationValue', + 'scheduleValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.schedulePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromScheduleName', () => { + const result = client.matchProjectFromScheduleName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.schedulePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromScheduleName', () => { + const result = client.matchLocationFromScheduleName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.schedulePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchScheduleFromScheduleName', () => { + const result = client.matchScheduleFromScheduleName(fakePath); + assert.strictEqual(result, 'scheduleValue'); + assert( + (client.pathTemplates.schedulePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-notebooks/test/gapic_notebook_service_v1beta1.ts b/packages/google-cloud-notebooks/test/gapic_notebook_service_v1beta1.ts index 6d8a1a63234b..02796fb74afa 100644 --- a/packages/google-cloud-notebooks/test/gapic_notebook_service_v1beta1.ts +++ b/packages/google-cloud-notebooks/test/gapic_notebook_service_v1beta1.ts @@ -19,4037 +19,5106 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as notebookserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + IamProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1beta1.NotebookServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'notebooks.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'notebooks.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = notebookserviceModule.v1beta1.NotebookServiceClient.servicePath; - assert.strictEqual(servicePath, 'notebooks.googleapis.com'); - assert(stub.called); - stub.restore(); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + notebookserviceModule.v1beta1.NotebookServiceClient.servicePath; + assert.strictEqual(servicePath, 'notebooks.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + notebookserviceModule.v1beta1.NotebookServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'notebooks.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'notebooks.example.com'); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = notebookserviceModule.v1beta1.NotebookServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'notebooks.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'notebooks.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'notebooks.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'notebooks.example.com'); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new notebookserviceModule.v1beta1.NotebookServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'notebooks.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new notebookserviceModule.v1beta1.NotebookServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'notebooks.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new notebookserviceModule.v1beta1.NotebookServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new notebookserviceModule.v1beta1.NotebookServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'notebooks.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'notebooks.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new notebookserviceModule.v1beta1.NotebookServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + it('has port', () => { + const port = notebookserviceModule.v1beta1.NotebookServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has port', () => { - const port = notebookserviceModule.v1beta1.NotebookServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); + it('should create a client with no option', () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient(); + assert(client); + }); - it('should create a client with no option', () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient(); - assert(client); - }); + it('should create a client with gRPC fallback', () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + fallback: true, + }); + assert(client); + }); - it('should create a client with gRPC fallback', () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - fallback: true, - }); - assert(client); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.notebookServiceStub, undefined); + await client.initialize(); + assert(client.notebookServiceStub); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.notebookServiceStub, undefined); - await client.initialize(); - assert(client.notebookServiceStub); + it('has close method for the initialized client', (done) => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.notebookServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has close method for the initialized client', done => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.notebookServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the non-initialized client', (done) => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.notebookServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has close method for the non-initialized client', done => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.notebookServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getInstance', () => { + it('invokes getInstance without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Instance(), + ); + client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); + const [response] = await client.getInstance(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); + it('invokes getInstance without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Instance(), + ); + client.innerApiCalls.getInstance = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getInstance( + request, + ( + err?: Error | null, + result?: protos.google.cloud.notebooks.v1beta1.IInstance | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getInstance', () => { - it('invokes getInstance without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.Instance() - ); - client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); - const [response] = await client.getInstance(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getInstance with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getInstance = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getInstance without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.Instance() - ); - client.innerApiCalls.getInstance = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getInstance( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1beta1.IInstance|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getInstance with closed client', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getInstance(request), expectedError); + }); + }); + + describe('isInstanceUpgradeable', () => { + it('invokes isInstanceUpgradeable without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest', + ['notebookInstance'], + ); + request.notebookInstance = defaultValue1; + const expectedHeaderRequestParams = `notebook_instance=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableResponse(), + ); + client.innerApiCalls.isInstanceUpgradeable = + stubSimpleCall(expectedResponse); + const [response] = await client.isInstanceUpgradeable(request); + assert(stub.calledOnce); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.isInstanceUpgradeable as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.isInstanceUpgradeable as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getInstance with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getInstance = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes isInstanceUpgradeable without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest', + ['notebookInstance'], + ); + request.notebookInstance = defaultValue1; + const expectedHeaderRequestParams = `notebook_instance=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableResponse(), + ); + client.innerApiCalls.isInstanceUpgradeable = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.isInstanceUpgradeable( + request, + ( + err?: Error | null, + result?: protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert(stub.calledOnce); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.isInstanceUpgradeable as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.isInstanceUpgradeable as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getInstance with closed client', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getInstance(request), expectedError); - }); + it('invokes isInstanceUpgradeable with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest', + ['notebookInstance'], + ); + request.notebookInstance = defaultValue1; + const expectedHeaderRequestParams = `notebook_instance=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.isInstanceUpgradeable = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.isInstanceUpgradeable(request), + expectedError, + ); + assert(stub.calledOnce); + const actualRequest = ( + client.innerApiCalls.isInstanceUpgradeable as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.isInstanceUpgradeable as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('isInstanceUpgradeable', () => { - it('invokes isInstanceUpgradeable without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest', ['notebookInstance']); - request.notebookInstance = defaultValue1; - const expectedHeaderRequestParams = `notebook_instance=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableResponse() - ); - client.innerApiCalls.isInstanceUpgradeable = stubSimpleCall(expectedResponse); - const [response] = await client.isInstanceUpgradeable(request); - assert(stub.calledOnce); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes isInstanceUpgradeable with closed client', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest', + ['notebookInstance'], + ); + request.notebookInstance = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.isInstanceUpgradeable(request), + expectedError, + ); + assert(stub.calledOnce); + }); + }); + + describe('getEnvironment', () => { + it('invokes getEnvironment without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.GetEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.GetEnvironmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Environment(), + ); + client.innerApiCalls.getEnvironment = stubSimpleCall(expectedResponse); + const [response] = await client.getEnvironment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getEnvironment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEnvironment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes isInstanceUpgradeable without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest', ['notebookInstance']); - request.notebookInstance = defaultValue1; - const expectedHeaderRequestParams = `notebook_instance=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableResponse() - ); - client.innerApiCalls.isInstanceUpgradeable = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.isInstanceUpgradeable( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1beta1.IIsInstanceUpgradeableResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert(stub.calledOnce); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getEnvironment without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.GetEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.GetEnvironmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Environment(), + ); + client.innerApiCalls.getEnvironment = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getEnvironment( + request, + ( + err?: Error | null, + result?: protos.google.cloud.notebooks.v1beta1.IEnvironment | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getEnvironment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEnvironment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes isInstanceUpgradeable with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest', ['notebookInstance']); - request.notebookInstance = defaultValue1; - const expectedHeaderRequestParams = `notebook_instance=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.isInstanceUpgradeable = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.isInstanceUpgradeable(request), expectedError); - assert(stub.calledOnce); - const actualRequest = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.isInstanceUpgradeable as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getEnvironment with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.GetEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.GetEnvironmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getEnvironment = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getEnvironment(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getEnvironment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEnvironment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes isInstanceUpgradeable with closed client', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.IsInstanceUpgradeableRequest', ['notebookInstance']); - request.notebookInstance = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.isInstanceUpgradeable(request), expectedError); - assert(stub.calledOnce); - }); + it('invokes getEnvironment with closed client', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.GetEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.GetEnvironmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getEnvironment(request), expectedError); + }); + }); + + describe('createInstance', () => { + it('invokes createInstance without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.CreateInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.CreateInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getEnvironment', () => { - it('invokes getEnvironment without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.GetEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.GetEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.Environment() - ); - client.innerApiCalls.getEnvironment = stubSimpleCall(expectedResponse); - const [response] = await client.getEnvironment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createInstance without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.CreateInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.CreateInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getEnvironment without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.GetEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.GetEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.Environment() - ); - client.innerApiCalls.getEnvironment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getEnvironment( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1beta1.IEnvironment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createInstance with call error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.CreateInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.CreateInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getEnvironment with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.GetEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.GetEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getEnvironment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getEnvironment(request), expectedError); - const actualRequest = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createInstance with LRO error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.CreateInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.CreateInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getEnvironment with closed client', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.GetEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.GetEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getEnvironment(request), expectedError); - }); + it('invokes checkCreateInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('createInstance', () => { - it('invokes createInstance without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.createInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('registerInstance', () => { + it('invokes registerInstance without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.RegisterInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.RegisterInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.registerInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.registerInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.registerInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.registerInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createInstance without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes registerInstance without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.RegisterInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.RegisterInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.registerInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.registerInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.registerInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.registerInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createInstance with call error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes registerInstance with call error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.RegisterInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.RegisterInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.registerInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.registerInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.registerInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.registerInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createInstance with LRO error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes registerInstance with LRO error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.RegisterInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.RegisterInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.registerInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.registerInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.registerInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.registerInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkRegisterInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkRegisterInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkCreateInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes checkRegisterInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkRegisterInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('setInstanceAccelerator', () => { + it('invokes setInstanceAccelerator without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.setInstanceAccelerator = + stubLongRunningCall(expectedResponse); + const [operation] = await client.setInstanceAccelerator(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setInstanceAccelerator as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInstanceAccelerator as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes setInstanceAccelerator without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.setInstanceAccelerator = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setInstanceAccelerator( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setInstanceAccelerator as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInstanceAccelerator as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('registerInstance', () => { - it('invokes registerInstance without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.RegisterInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.RegisterInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.registerInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.registerInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.registerInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.registerInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes setInstanceAccelerator with call error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInstanceAccelerator = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.setInstanceAccelerator(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.setInstanceAccelerator as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInstanceAccelerator as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes registerInstance without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.RegisterInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.RegisterInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.registerInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.registerInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.registerInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.registerInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes setInstanceAccelerator with LRO error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInstanceAccelerator = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.setInstanceAccelerator(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.setInstanceAccelerator as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInstanceAccelerator as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes registerInstance with call error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.RegisterInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.RegisterInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.registerInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.registerInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.registerInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.registerInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkSetInstanceAcceleratorProgress without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkSetInstanceAcceleratorProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes registerInstance with LRO error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.RegisterInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.RegisterInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.registerInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.registerInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.registerInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.registerInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkSetInstanceAcceleratorProgress with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkSetInstanceAcceleratorProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('setInstanceMachineType', () => { + it('invokes setInstanceMachineType without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.setInstanceMachineType = + stubLongRunningCall(expectedResponse); + const [operation] = await client.setInstanceMachineType(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setInstanceMachineType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInstanceMachineType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRegisterInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkRegisterInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes setInstanceMachineType without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.setInstanceMachineType = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setInstanceMachineType( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setInstanceMachineType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInstanceMachineType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRegisterInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes setInstanceMachineType with call error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInstanceMachineType = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.setInstanceMachineType(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.setInstanceMachineType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInstanceMachineType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRegisterInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes setInstanceMachineType with LRO error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInstanceMachineType = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.setInstanceMachineType(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.setInstanceMachineType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInstanceMachineType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('setInstanceAccelerator', () => { - it('invokes setInstanceAccelerator without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.setInstanceAccelerator = stubLongRunningCall(expectedResponse); - const [operation] = await client.setInstanceAccelerator(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setInstanceAccelerator as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceAccelerator as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkSetInstanceMachineTypeProgress without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkSetInstanceMachineTypeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes setInstanceAccelerator without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.setInstanceAccelerator = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setInstanceAccelerator( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setInstanceAccelerator as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceAccelerator as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkSetInstanceMachineTypeProgress with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkSetInstanceMachineTypeProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('setInstanceLabels', () => { + it('invokes setInstanceLabels without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.setInstanceLabels = + stubLongRunningCall(expectedResponse); + const [operation] = await client.setInstanceLabels(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setInstanceLabels as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInstanceLabels as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes setInstanceAccelerator with call error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.setInstanceAccelerator = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.setInstanceAccelerator(request), expectedError); - const actualRequest = (client.innerApiCalls.setInstanceAccelerator as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceAccelerator as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes setInstanceLabels without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.setInstanceLabels = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setInstanceLabels( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setInstanceLabels as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInstanceLabels as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes setInstanceAccelerator with LRO error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.setInstanceAccelerator = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.setInstanceAccelerator(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.setInstanceAccelerator as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceAccelerator as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes setInstanceLabels with call error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInstanceLabels = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.setInstanceLabels(request), expectedError); + const actualRequest = ( + client.innerApiCalls.setInstanceLabels as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInstanceLabels as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkSetInstanceAcceleratorProgress without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkSetInstanceAcceleratorProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes setInstanceLabels with LRO error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInstanceLabels = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.setInstanceLabels(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.setInstanceLabels as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInstanceLabels as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkSetInstanceAcceleratorProgress with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes checkSetInstanceLabelsProgress without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkSetInstanceLabelsProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkSetInstanceAcceleratorProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkSetInstanceLabelsProgress with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkSetInstanceLabelsProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteInstance', () => { + it('invokes deleteInstance without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.DeleteInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.DeleteInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('setInstanceMachineType', () => { - it('invokes setInstanceMachineType without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.setInstanceMachineType = stubLongRunningCall(expectedResponse); - const [operation] = await client.setInstanceMachineType(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setInstanceMachineType as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceMachineType as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteInstance without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.DeleteInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.DeleteInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes setInstanceMachineType without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.setInstanceMachineType = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setInstanceMachineType( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setInstanceMachineType as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceMachineType as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteInstance with call error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.DeleteInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.DeleteInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes setInstanceMachineType with call error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.setInstanceMachineType = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.setInstanceMachineType(request), expectedError); - const actualRequest = (client.innerApiCalls.setInstanceMachineType as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceMachineType as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteInstance with LRO error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.DeleteInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.DeleteInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes setInstanceMachineType with LRO error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.setInstanceMachineType = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.setInstanceMachineType(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.setInstanceMachineType as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceMachineType as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkSetInstanceMachineTypeProgress without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkSetInstanceMachineTypeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkDeleteInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('startInstance', () => { + it('invokes startInstance without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.StartInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.StartInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.startInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.startInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.startInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkSetInstanceMachineTypeProgress with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes startInstance without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.StartInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.StartInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.startInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.startInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.startInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkSetInstanceMachineTypeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes startInstance with call error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.StartInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.StartInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.startInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.startInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.startInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('setInstanceLabels', () => { - it('invokes setInstanceLabels without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.setInstanceLabels = stubLongRunningCall(expectedResponse); - const [operation] = await client.setInstanceLabels(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setInstanceLabels as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceLabels as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes startInstance with LRO error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.StartInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.StartInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.startInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.startInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.startInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes setInstanceLabels without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.setInstanceLabels = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setInstanceLabels( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setInstanceLabels as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceLabels as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkStartInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkStartInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes setInstanceLabels with call error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.setInstanceLabels = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.setInstanceLabels(request), expectedError); - const actualRequest = (client.innerApiCalls.setInstanceLabels as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceLabels as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkStartInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkStartInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('stopInstance', () => { + it('invokes stopInstance without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.StopInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.StopInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.stopInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.stopInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.stopInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes setInstanceLabels with LRO error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.setInstanceLabels = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.setInstanceLabels(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.setInstanceLabels as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInstanceLabels as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes stopInstance without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.StopInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.StopInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.stopInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.stopInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.stopInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkSetInstanceLabelsProgress without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkSetInstanceLabelsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes stopInstance with call error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.StopInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.StopInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.stopInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.stopInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.stopInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkSetInstanceLabelsProgress with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes stopInstance with LRO error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.StopInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.StopInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.stopInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.stopInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.stopInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkSetInstanceLabelsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkStopInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkStopInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('deleteInstance', () => { - it('invokes deleteInstance without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkStopInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkStopInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('resetInstance', () => { + it('invokes resetInstance without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ResetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.ResetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.resetInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.resetInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resetInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resetInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteInstance without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes resetInstance without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ResetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.ResetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.resetInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resetInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resetInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resetInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteInstance with call error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes resetInstance with call error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ResetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.ResetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resetInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.resetInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.resetInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resetInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteInstance with LRO error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes resetInstance with LRO error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ResetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.ResetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resetInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.resetInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.resetInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resetInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkResetInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkResetInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes checkResetInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkResetInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('reportInstanceInfo', () => { + it('invokes reportInstanceInfo without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.reportInstanceInfo = + stubLongRunningCall(expectedResponse); + const [operation] = await client.reportInstanceInfo(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.reportInstanceInfo as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reportInstanceInfo as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes reportInstanceInfo without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.reportInstanceInfo = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.reportInstanceInfo( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.reportInstanceInfo as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reportInstanceInfo as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('startInstance', () => { - it('invokes startInstance without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.StartInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.StartInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.startInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.startInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes reportInstanceInfo with call error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.reportInstanceInfo = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.reportInstanceInfo(request), expectedError); + const actualRequest = ( + client.innerApiCalls.reportInstanceInfo as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reportInstanceInfo as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes startInstance without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.StartInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.StartInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.startInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.startInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes reportInstanceInfo with LRO error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.reportInstanceInfo = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.reportInstanceInfo(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.reportInstanceInfo as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reportInstanceInfo as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes startInstance with call error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.StartInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.StartInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.startInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.startInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkReportInstanceInfoProgress without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkReportInstanceInfoProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes startInstance with LRO error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.StartInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.StartInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.startInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.startInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkReportInstanceInfoProgress with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkReportInstanceInfoProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('upgradeInstance', () => { + it('invokes upgradeInstance without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.upgradeInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.upgradeInstance(request); + const [response] = await operation.promise(); + assert(stub.calledOnce); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.upgradeInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.upgradeInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkStartInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkStartInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes upgradeInstance without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.upgradeInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.upgradeInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert(stub.calledOnce); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.upgradeInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.upgradeInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkStartInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes upgradeInstance with call error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.upgradeInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.upgradeInstance(request), expectedError); + assert(stub.calledOnce); + const actualRequest = ( + client.innerApiCalls.upgradeInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.upgradeInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkStartInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes upgradeInstance with LRO error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.upgradeInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.upgradeInstance(request); + await assert.rejects(operation.promise(), expectedError); + assert(stub.calledOnce); + const actualRequest = ( + client.innerApiCalls.upgradeInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.upgradeInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('stopInstance', () => { - it('invokes stopInstance without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.StopInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.StopInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.stopInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.stopInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpgradeInstanceProgress without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + await 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.checkUpgradeInstanceProgress( + expectedResponse.name, + ); + assert(stub.calledOnce); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes stopInstance without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.StopInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.StopInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.stopInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.stopInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpgradeInstanceProgress with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpgradeInstanceProgress(''), + expectedError, + ); + assert(stub.calledOnce); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('upgradeInstanceInternal', () => { + it('invokes upgradeInstanceInternal without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.upgradeInstanceInternal = + stubLongRunningCall(expectedResponse); + const [operation] = await client.upgradeInstanceInternal(request); + const [response] = await operation.promise(); + assert(stub.calledOnce); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.upgradeInstanceInternal as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.upgradeInstanceInternal as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes stopInstance with call error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.StopInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.StopInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.stopInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.stopInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes upgradeInstanceInternal without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.upgradeInstanceInternal = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.upgradeInstanceInternal( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1beta1.IInstance, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert(stub.calledOnce); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.upgradeInstanceInternal as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.upgradeInstanceInternal as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes stopInstance with LRO error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.StopInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.StopInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.stopInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.stopInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes upgradeInstanceInternal with call error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.upgradeInstanceInternal = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.upgradeInstanceInternal(request), + expectedError, + ); + assert(stub.calledOnce); + const actualRequest = ( + client.innerApiCalls.upgradeInstanceInternal as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.upgradeInstanceInternal as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkStopInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkStopInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkStopInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkStopInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes upgradeInstanceInternal with LRO error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.upgradeInstanceInternal = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.upgradeInstanceInternal(request); + await assert.rejects(operation.promise(), expectedError); + assert(stub.calledOnce); + const actualRequest = ( + client.innerApiCalls.upgradeInstanceInternal as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.upgradeInstanceInternal as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('resetInstance', () => { - it('invokes resetInstance without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ResetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ResetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.resetInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.resetInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resetInstance without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ResetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ResetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.resetInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.resetInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resetInstance with call error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ResetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ResetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.resetInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.resetInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resetInstance with LRO error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ResetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ResetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.resetInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.resetInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkResetInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkResetInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkResetInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkResetInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpgradeInstanceInternalProgress without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + await 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.checkUpgradeInstanceInternalProgress( + expectedResponse.name, + ); + assert(stub.calledOnce); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('reportInstanceInfo', () => { - it('invokes reportInstanceInfo without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.reportInstanceInfo = stubLongRunningCall(expectedResponse); - const [operation] = await client.reportInstanceInfo(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.reportInstanceInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reportInstanceInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes reportInstanceInfo without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.reportInstanceInfo = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.reportInstanceInfo( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.reportInstanceInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reportInstanceInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes reportInstanceInfo with call error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.reportInstanceInfo = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.reportInstanceInfo(request), expectedError); - const actualRequest = (client.innerApiCalls.reportInstanceInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reportInstanceInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes reportInstanceInfo with LRO error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ReportInstanceInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.reportInstanceInfo = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.reportInstanceInfo(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.reportInstanceInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reportInstanceInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkReportInstanceInfoProgress without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkReportInstanceInfoProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkReportInstanceInfoProgress with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkReportInstanceInfoProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpgradeInstanceInternalProgress with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpgradeInstanceInternalProgress(''), + expectedError, + ); + assert(stub.calledOnce); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - - describe('upgradeInstance', () => { - it('invokes upgradeInstance without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.upgradeInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.upgradeInstance(request); - const [response] = await operation.promise(); - assert(stub.calledOnce); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeInstance without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.upgradeInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.upgradeInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert(stub.calledOnce); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeInstance with call error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.upgradeInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.upgradeInstance(request), expectedError); - assert(stub.calledOnce); - const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeInstance with LRO error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.upgradeInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.upgradeInstance(request); - await assert.rejects(operation.promise(), expectedError); - assert(stub.calledOnce); - const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpgradeInstanceProgress without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - await 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.checkUpgradeInstanceProgress(expectedResponse.name); - assert(stub.calledOnce); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpgradeInstanceProgress with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpgradeInstanceProgress(''), expectedError); - assert(stub.calledOnce); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + }); + + describe('createEnvironment', () => { + it('invokes createEnvironment without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createEnvironment = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createEnvironment(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createEnvironment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEnvironment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('upgradeInstanceInternal', () => { - it('invokes upgradeInstanceInternal without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.upgradeInstanceInternal = stubLongRunningCall(expectedResponse); - const [operation] = await client.upgradeInstanceInternal(request); - const [response] = await operation.promise(); - assert(stub.calledOnce); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeInstanceInternal without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.upgradeInstanceInternal = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.upgradeInstanceInternal( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert(stub.calledOnce); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeInstanceInternal with call error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.upgradeInstanceInternal = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.upgradeInstanceInternal(request), expectedError); - assert(stub.calledOnce); - const actualRequest = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes upgradeInstanceInternal with LRO error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.UpgradeInstanceInternalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.upgradeInstanceInternal = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.upgradeInstanceInternal(request); - await assert.rejects(operation.promise(), expectedError); - assert(stub.calledOnce); - const actualRequest = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstanceInternal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpgradeInstanceInternalProgress without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - await 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.checkUpgradeInstanceInternalProgress(expectedResponse.name); - assert(stub.calledOnce); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpgradeInstanceInternalProgress with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpgradeInstanceInternalProgress(''), expectedError); - assert(stub.calledOnce); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createEnvironment without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createEnvironment = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createEnvironment( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v1beta1.IEnvironment, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v1beta1.IEnvironment, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createEnvironment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEnvironment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createEnvironment', () => { - it('invokes createEnvironment without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createEnvironment = stubLongRunningCall(expectedResponse); - const [operation] = await client.createEnvironment(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createEnvironment without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createEnvironment = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createEnvironment( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createEnvironment with call error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createEnvironment = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createEnvironment(request), expectedError); - const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createEnvironment with LRO error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createEnvironment = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createEnvironment(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateEnvironmentProgress without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateEnvironmentProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createEnvironment with call error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createEnvironment = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createEnvironment(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createEnvironment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEnvironment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateEnvironmentProgress with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes createEnvironment with LRO error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createEnvironment = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createEnvironment(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createEnvironment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEnvironment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateEnvironmentProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateEnvironmentProgress without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateEnvironmentProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('deleteEnvironment', () => { - it('invokes deleteEnvironment without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteEnvironment = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteEnvironment(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateEnvironmentProgress with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateEnvironmentProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteEnvironment', () => { + it('invokes deleteEnvironment without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteEnvironment = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteEnvironment(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteEnvironment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEnvironment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteEnvironment without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteEnvironment = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteEnvironment( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteEnvironment without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteEnvironment = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteEnvironment( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteEnvironment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEnvironment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteEnvironment with call error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteEnvironment = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteEnvironment(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteEnvironment with call error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteEnvironment = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteEnvironment(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteEnvironment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEnvironment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteEnvironment with LRO error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteEnvironment = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteEnvironment(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteEnvironment with LRO error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteEnvironment = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteEnvironment(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteEnvironment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEnvironment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteEnvironmentProgress without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteEnvironmentProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkDeleteEnvironmentProgress without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteEnvironmentProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteEnvironmentProgress with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes checkDeleteEnvironmentProgress with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteEnvironmentProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listInstances', () => { + it('invokes listInstances without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Instance(), + ), + ]; + client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); + const [response] = await client.listInstances(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteEnvironmentProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes listInstances without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Instance(), + ), + ]; + client.innerApiCalls.listInstances = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listInstances( + request, + ( + err?: Error | null, + result?: protos.google.cloud.notebooks.v1beta1.IInstance[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listInstances', () => { - it('invokes listInstances without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), - ]; - client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); - const [response] = await client.listInstances(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listInstances with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listInstances = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listInstances(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listInstances without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), - ]; - client.innerApiCalls.listInstances = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listInstances( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1beta1.IInstance[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listInstancesStream without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Instance(), + ), + ]; + client.descriptors.page.listInstances.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v1beta1.Instance[] = []; + stream.on( + 'data', + (response: protos.google.cloud.notebooks.v1beta1.Instance) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listInstances, request), + ); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listInstances with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listInstances = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listInstances(request), expectedError); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listInstancesStream with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstances.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v1beta1.Instance[] = []; + stream.on( + 'data', + (response: protos.google.cloud.notebooks.v1beta1.Instance) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listInstances, request), + ); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listInstancesStream without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), - ]; - client.descriptors.page.listInstances.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listInstancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v1beta1.Instance[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v1beta1.Instance) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); - assert( - (client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listInstances without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Instance(), + ), + ]; + client.descriptors.page.listInstances.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.notebooks.v1beta1.IInstance[] = []; + const iterable = client.listInstancesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listInstances.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listInstancesStream with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstances.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listInstancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v1beta1.Instance[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v1beta1.Instance) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); - assert( - (client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listInstances with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstances.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listInstancesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.notebooks.v1beta1.IInstance[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listInstances.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listEnvironments', () => { + it('invokes listEnvironments without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Environment(), + ), + generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Environment(), + ), + generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Environment(), + ), + ]; + client.innerApiCalls.listEnvironments = stubSimpleCall(expectedResponse); + const [response] = await client.listEnvironments(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listEnvironments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEnvironments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listInstances without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Instance()), - ]; - client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.notebooks.v1beta1.IInstance[] = []; - const iterable = client.listInstancesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listEnvironments without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Environment(), + ), + generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Environment(), + ), + generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Environment(), + ), + ]; + client.innerApiCalls.listEnvironments = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listEnvironments( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.notebooks.v1beta1.IEnvironment[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listInstances with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listInstancesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.notebooks.v1beta1.IInstance[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listEnvironments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEnvironments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listEnvironments', () => { - it('invokes listEnvironments without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), - ]; - client.innerApiCalls.listEnvironments = stubSimpleCall(expectedResponse); - const [response] = await client.listEnvironments(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEnvironments without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), - ]; - client.innerApiCalls.listEnvironments = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listEnvironments( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v1beta1.IEnvironment[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEnvironments with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listEnvironments = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listEnvironments(request), expectedError); - const actualRequest = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEnvironments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listEnvironments with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listEnvironments = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listEnvironments(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listEnvironments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEnvironments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listEnvironmentsStream without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), - ]; - client.descriptors.page.listEnvironments.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listEnvironmentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v1beta1.Environment[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v1beta1.Environment) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listEnvironments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listEnvironments, request)); - assert( - (client.descriptors.page.listEnvironments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listEnvironmentsStream without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Environment(), + ), + generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Environment(), + ), + generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Environment(), + ), + ]; + client.descriptors.page.listEnvironments.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listEnvironmentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v1beta1.Environment[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.notebooks.v1beta1.Environment) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listEnvironments.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listEnvironments, request), + ); + assert( + (client.descriptors.page.listEnvironments.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listEnvironmentsStream with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listEnvironments.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listEnvironmentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v1beta1.Environment[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v1beta1.Environment) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listEnvironments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listEnvironments, request)); - assert( - (client.descriptors.page.listEnvironments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listEnvironmentsStream with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listEnvironments.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listEnvironmentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v1beta1.Environment[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.notebooks.v1beta1.Environment) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listEnvironments.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listEnvironments, request), + ); + assert( + (client.descriptors.page.listEnvironments.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listEnvironments without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), - generateSampleMessage(new protos.google.cloud.notebooks.v1beta1.Environment()), - ]; - client.descriptors.page.listEnvironments.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.notebooks.v1beta1.IEnvironment[] = []; - const iterable = client.listEnvironmentsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listEnvironments without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Environment(), + ), + generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Environment(), + ), + generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.Environment(), + ), + ]; + client.descriptors.page.listEnvironments.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.notebooks.v1beta1.IEnvironment[] = + []; + const iterable = client.listEnvironmentsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listEnvironments.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listEnvironments with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listEnvironments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listEnvironmentsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.notebooks.v1beta1.IEnvironment[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listEnvironments with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v1beta1.ListEnvironmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listEnvironments.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listEnvironmentsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.notebooks.v1beta1.IEnvironment[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listEnvironments.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listEnvironments.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes setIamPolicy with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes testIamPermissions with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('environment', async () => { + const fakePath = '/rendered/path/environment'; + const expectedParameters = { + project: 'projectValue', + environment: 'environmentValue', + }; + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.environmentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.environmentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('environmentPath', () => { + const result = client.environmentPath( + 'projectValue', + 'environmentValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.environmentPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromEnvironmentName', () => { + const result = client.matchProjectFromEnvironmentName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.environmentPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEnvironmentFromEnvironmentName', () => { + const result = client.matchEnvironmentFromEnvironmentName(fakePath); + assert.strictEqual(result, 'environmentValue'); + assert( + (client.pathTemplates.environmentPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('environment', async () => { - const fakePath = "/rendered/path/environment"; - const expectedParameters = { - project: "projectValue", - environment: "environmentValue", - }; - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.environmentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.environmentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('environmentPath', () => { - const result = client.environmentPath("projectValue", "environmentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.environmentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromEnvironmentName', () => { - const result = client.matchProjectFromEnvironmentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEnvironmentFromEnvironmentName', () => { - const result = client.matchEnvironmentFromEnvironmentName(fakePath); - assert.strictEqual(result, "environmentValue"); - assert((client.pathTemplates.environmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('instance', async () => { - const fakePath = "/rendered/path/instance"; - const expectedParameters = { - project: "projectValue", - instance: "instanceValue", - }; - const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.instancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.instancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('instancePath', () => { - const result = client.instancePath("projectValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.instancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInstanceName', () => { - const result = client.matchProjectFromInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromInstanceName', () => { - const result = client.matchInstanceFromInstanceName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('instance', async () => { + const fakePath = '/rendered/path/instance'; + const expectedParameters = { + project: 'projectValue', + instance: 'instanceValue', + }; + const client = new notebookserviceModule.v1beta1.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.instancePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.instancePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('instancePath', () => { + const result = client.instancePath('projectValue', 'instanceValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.instancePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromInstanceName', () => { + const result = client.matchProjectFromInstanceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchInstanceFromInstanceName', () => { + const result = client.matchInstanceFromInstanceName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-notebooks/test/gapic_notebook_service_v2.ts b/packages/google-cloud-notebooks/test/gapic_notebook_service_v2.ts index fb55f91df597..634ede90bd11 100644 --- a/packages/google-cloud-notebooks/test/gapic_notebook_service_v2.ts +++ b/packages/google-cloud-notebooks/test/gapic_notebook_service_v2.ts @@ -19,2924 +19,3659 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as notebookserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + IamProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v2.NotebookServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new notebookserviceModule.v2.NotebookServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'notebooks.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new notebookserviceModule.v2.NotebookServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = notebookserviceModule.v2.NotebookServiceClient.servicePath; - assert.strictEqual(servicePath, 'notebooks.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = notebookserviceModule.v2.NotebookServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'notebooks.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'notebooks.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'notebooks.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new notebookserviceModule.v2.NotebookServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'notebooks.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new notebookserviceModule.v2.NotebookServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'notebooks.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new notebookserviceModule.v2.NotebookServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = notebookserviceModule.v2.NotebookServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new notebookserviceModule.v2.NotebookServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.notebookServiceStub, undefined); - await client.initialize(); - assert(client.notebookServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.notebookServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has close method for the non-initialized client', done => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.notebookServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new notebookserviceModule.v2.NotebookServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'notebooks.googleapis.com'); }); - describe('getInstance', () => { - it('invokes getInstance without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v2.Instance() - ); - client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); - const [response] = await client.getInstance(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has universeDomain', () => { + const client = new notebookserviceModule.v2.NotebookServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('invokes getInstance without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v2.Instance() - ); - client.innerApiCalls.getInstance = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getInstance( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v2.IInstance|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + notebookserviceModule.v2.NotebookServiceClient.servicePath; + assert.strictEqual(servicePath, 'notebooks.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + notebookserviceModule.v2.NotebookServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'notebooks.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'notebooks.example.com'); + }); - it('invokes getInstance with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getInstance = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'notebooks.example.com'); + }); - it('invokes getInstance with closed client', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getInstance(request), expectedError); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new notebookserviceModule.v2.NotebookServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'notebooks.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new notebookserviceModule.v2.NotebookServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'notebooks.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new notebookserviceModule.v2.NotebookServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); }); - describe('checkInstanceUpgradability', () => { - it('invokes checkInstanceUpgradability without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest', ['notebookInstance']); - request.notebookInstance = defaultValue1; - const expectedHeaderRequestParams = `notebook_instance=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v2.CheckInstanceUpgradabilityResponse() - ); - client.innerApiCalls.checkInstanceUpgradability = stubSimpleCall(expectedResponse); - const [response] = await client.checkInstanceUpgradability(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.checkInstanceUpgradability as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.checkInstanceUpgradability as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has port', () => { + const port = notebookserviceModule.v2.NotebookServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('invokes checkInstanceUpgradability without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest', ['notebookInstance']); - request.notebookInstance = defaultValue1; - const expectedHeaderRequestParams = `notebook_instance=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.notebooks.v2.CheckInstanceUpgradabilityResponse() - ); - client.innerApiCalls.checkInstanceUpgradability = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.checkInstanceUpgradability( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.checkInstanceUpgradability as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.checkInstanceUpgradability as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('should create a client with no option', () => { + const client = new notebookserviceModule.v2.NotebookServiceClient(); + assert(client); + }); - it('invokes checkInstanceUpgradability with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest', ['notebookInstance']); - request.notebookInstance = defaultValue1; - const expectedHeaderRequestParams = `notebook_instance=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.checkInstanceUpgradability = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkInstanceUpgradability(request), expectedError); - const actualRequest = (client.innerApiCalls.checkInstanceUpgradability as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.checkInstanceUpgradability as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('should create a client with gRPC fallback', () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + fallback: true, + }); + assert(client); + }); - it('invokes checkInstanceUpgradability with closed client', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest', ['notebookInstance']); - request.notebookInstance = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.checkInstanceUpgradability(request), expectedError); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.notebookServiceStub, undefined); + await client.initialize(); + assert(client.notebookServiceStub); }); - describe('createInstance', () => { - it('invokes createInstance without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.createInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the initialized client', (done) => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.notebookServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes createInstance without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the non-initialized client', (done) => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.notebookServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes createInstance with call error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('invokes createInstance with LRO error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getInstance', () => { + it('invokes getInstance without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v2.Instance(), + ); + client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); + const [response] = await client.getInstance(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateInstanceProgress without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes getInstance without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v2.Instance(), + ); + client.innerApiCalls.getInstance = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getInstance( + request, + ( + err?: Error | null, + result?: protos.google.cloud.notebooks.v2.IInstance | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateInstanceProgress with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes getInstance with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getInstance = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateInstance', () => { - it('invokes updateInstance without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getInstance with closed client', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getInstance(request), expectedError); + }); + }); + + describe('checkInstanceUpgradability', () => { + it('invokes checkInstanceUpgradability without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest', + ['notebookInstance'], + ); + request.notebookInstance = defaultValue1; + const expectedHeaderRequestParams = `notebook_instance=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v2.CheckInstanceUpgradabilityResponse(), + ); + client.innerApiCalls.checkInstanceUpgradability = + stubSimpleCall(expectedResponse); + const [response] = await client.checkInstanceUpgradability(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.checkInstanceUpgradability as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.checkInstanceUpgradability as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateInstance without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkInstanceUpgradability without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest', + ['notebookInstance'], + ); + request.notebookInstance = defaultValue1; + const expectedHeaderRequestParams = `notebook_instance=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.notebooks.v2.CheckInstanceUpgradabilityResponse(), + ); + client.innerApiCalls.checkInstanceUpgradability = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.checkInstanceUpgradability( + request, + ( + err?: Error | null, + result?: protos.google.cloud.notebooks.v2.ICheckInstanceUpgradabilityResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.checkInstanceUpgradability as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.checkInstanceUpgradability as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateInstance with call error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkInstanceUpgradability with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest', + ['notebookInstance'], + ); + request.notebookInstance = defaultValue1; + const expectedHeaderRequestParams = `notebook_instance=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.checkInstanceUpgradability = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkInstanceUpgradability(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.checkInstanceUpgradability as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.checkInstanceUpgradability as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateInstance with LRO error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkInstanceUpgradability with closed client', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.CheckInstanceUpgradabilityRequest', + ['notebookInstance'], + ); + request.notebookInstance = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.checkInstanceUpgradability(request), + expectedError, + ); + }); + }); + + describe('createInstance', () => { + it('invokes createInstance without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.CreateInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.CreateInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateInstanceProgress without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createInstance without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.CreateInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.CreateInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateInstanceProgress with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createInstance with call error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.CreateInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.CreateInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteInstance', () => { - it('invokes deleteInstance without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createInstance with LRO error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.CreateInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.CreateInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteInstance without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateInstanceProgress without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteInstance with call error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateInstanceProgress with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateInstance', () => { + it('invokes updateInstance without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.UpdateInstanceRequest(), + ); + request.instance ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.UpdateInstanceRequest', + ['instance', 'name'], + ); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteInstance with LRO error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateInstance without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.UpdateInstanceRequest(), + ); + request.instance ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.UpdateInstanceRequest', + ['instance', 'name'], + ); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteInstanceProgress without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateInstance with call error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.UpdateInstanceRequest(), + ); + request.instance ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.UpdateInstanceRequest', + ['instance', 'name'], + ); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteInstanceProgress with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateInstance with LRO error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.UpdateInstanceRequest(), + ); + request.instance ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.UpdateInstanceRequest', + ['instance', 'name'], + ); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('startInstance', () => { - it('invokes startInstance without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.StartInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.StartInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.startInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.startInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateInstanceProgress without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes startInstance without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.StartInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.StartInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.startInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.startInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateInstanceProgress with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteInstance', () => { + it('invokes deleteInstance without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.DeleteInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.DeleteInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes startInstance with call error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.StartInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.StartInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.startInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.startInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteInstance without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.DeleteInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.DeleteInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v2.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.notebooks.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes startInstance with LRO error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.StartInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.StartInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.startInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.startInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteInstance with call error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.DeleteInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.DeleteInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkStartInstanceProgress without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkStartInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteInstance with LRO error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.DeleteInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.DeleteInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkStartInstanceProgress with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkStartInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteInstanceProgress without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('stopInstance', () => { - it('invokes stopInstance without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.StopInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.StopInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.stopInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.stopInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteInstanceProgress with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('startInstance', () => { + it('invokes startInstance without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.StartInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.StartInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.startInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.startInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.startInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes stopInstance without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.StopInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.StopInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.stopInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.stopInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes startInstance without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.StartInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.StartInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.startInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.startInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.startInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes stopInstance with call error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.StopInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.StopInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.stopInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.stopInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes startInstance with call error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.StartInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.StartInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.startInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.startInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.startInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes stopInstance with LRO error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.StopInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.StopInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.stopInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.stopInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes startInstance with LRO error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.StartInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.StartInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.startInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.startInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.startInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkStopInstanceProgress without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkStopInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkStartInstanceProgress without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkStartInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkStopInstanceProgress with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkStopInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkStartInstanceProgress with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkStartInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('stopInstance', () => { + it('invokes stopInstance without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.StopInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.StopInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.stopInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.stopInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.stopInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('resetInstance', () => { - it('invokes resetInstance without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.ResetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.ResetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.resetInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.resetInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes stopInstance without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.StopInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.StopInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.stopInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.stopInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.stopInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes resetInstance without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.ResetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.ResetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.resetInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.resetInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes stopInstance with call error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.StopInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.StopInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.stopInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.stopInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.stopInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes resetInstance with call error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.ResetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.ResetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.resetInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.resetInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes stopInstance with LRO error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.StopInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.StopInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.stopInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.stopInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.stopInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes resetInstance with LRO error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.ResetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.ResetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.resetInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.resetInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkStopInstanceProgress without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkStopInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkResetInstanceProgress without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkResetInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkStopInstanceProgress with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkStopInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('resetInstance', () => { + it('invokes resetInstance without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.ResetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.ResetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.resetInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.resetInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resetInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resetInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkResetInstanceProgress with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkResetInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes resetInstance without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.ResetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.ResetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.resetInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resetInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resetInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resetInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('upgradeInstance', () => { - it('invokes upgradeInstance without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.upgradeInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.upgradeInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes resetInstance with call error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.ResetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.ResetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resetInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.resetInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.resetInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resetInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes upgradeInstance without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.upgradeInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.upgradeInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes resetInstance with LRO error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.ResetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.ResetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resetInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.resetInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.resetInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resetInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes upgradeInstance with call error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.upgradeInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.upgradeInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkResetInstanceProgress without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkResetInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes upgradeInstance with LRO error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.UpgradeInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.UpgradeInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.upgradeInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.upgradeInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.upgradeInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkResetInstanceProgress with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkResetInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('upgradeInstance', () => { + it('invokes upgradeInstance without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.UpgradeInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.UpgradeInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.upgradeInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.upgradeInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.upgradeInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.upgradeInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpgradeInstanceProgress without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpgradeInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes upgradeInstance without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.UpgradeInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.UpgradeInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.upgradeInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.upgradeInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.upgradeInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.upgradeInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpgradeInstanceProgress with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpgradeInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes upgradeInstance with call error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.UpgradeInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.UpgradeInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.upgradeInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.upgradeInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.upgradeInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.upgradeInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('rollbackInstance', () => { - it('invokes rollbackInstance without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.RollbackInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.RollbackInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.rollbackInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.rollbackInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rollbackInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rollbackInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes upgradeInstance with LRO error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.UpgradeInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.UpgradeInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.upgradeInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.upgradeInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.upgradeInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.upgradeInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes rollbackInstance without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.RollbackInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.RollbackInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.rollbackInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rollbackInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rollbackInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rollbackInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpgradeInstanceProgress without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpgradeInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes rollbackInstance with call error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.RollbackInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.RollbackInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rollbackInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.rollbackInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.rollbackInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rollbackInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpgradeInstanceProgress with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpgradeInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('rollbackInstance', () => { + it('invokes rollbackInstance without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.RollbackInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.RollbackInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.rollbackInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.rollbackInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rollbackInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rollbackInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes rollbackInstance with LRO error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.RollbackInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.RollbackInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rollbackInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.rollbackInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.rollbackInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rollbackInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes rollbackInstance without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.RollbackInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.RollbackInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.rollbackInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rollbackInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rollbackInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rollbackInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRollbackInstanceProgress without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkRollbackInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes rollbackInstance with call error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.RollbackInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.RollbackInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rollbackInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.rollbackInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.rollbackInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rollbackInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRollbackInstanceProgress with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRollbackInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes rollbackInstance with LRO error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.RollbackInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.RollbackInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rollbackInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.rollbackInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.rollbackInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rollbackInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('diagnoseInstance', () => { - it('invokes diagnoseInstance without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.DiagnoseInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.DiagnoseInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.diagnoseInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.diagnoseInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.diagnoseInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.diagnoseInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRollbackInstanceProgress without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkRollbackInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes diagnoseInstance without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.DiagnoseInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.DiagnoseInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.diagnoseInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.diagnoseInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.diagnoseInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.diagnoseInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRollbackInstanceProgress with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkRollbackInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('diagnoseInstance', () => { + it('invokes diagnoseInstance without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.DiagnoseInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.DiagnoseInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.diagnoseInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.diagnoseInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.diagnoseInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.diagnoseInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes diagnoseInstance with call error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.DiagnoseInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.DiagnoseInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.diagnoseInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.diagnoseInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.diagnoseInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.diagnoseInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes diagnoseInstance without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.DiagnoseInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.DiagnoseInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.diagnoseInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.diagnoseInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.notebooks.v2.IInstance, + protos.google.cloud.notebooks.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.diagnoseInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.diagnoseInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes diagnoseInstance with LRO error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.DiagnoseInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.DiagnoseInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.diagnoseInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.diagnoseInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.diagnoseInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.diagnoseInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes diagnoseInstance with call error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.DiagnoseInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.DiagnoseInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.diagnoseInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.diagnoseInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.diagnoseInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.diagnoseInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDiagnoseInstanceProgress without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDiagnoseInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes diagnoseInstance with LRO error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.DiagnoseInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.DiagnoseInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.diagnoseInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.diagnoseInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.diagnoseInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.diagnoseInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDiagnoseInstanceProgress with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDiagnoseInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDiagnoseInstanceProgress without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDiagnoseInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('listInstances', () => { - it('invokes listInstances without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), - ]; - client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); - const [response] = await client.listInstances(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDiagnoseInstanceProgress with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDiagnoseInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listInstances', () => { + it('invokes listInstances without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), + ]; + client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); + const [response] = await client.listInstances(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listInstances without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), - ]; - client.innerApiCalls.listInstances = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listInstances( - request, - (err?: Error|null, result?: protos.google.cloud.notebooks.v2.IInstance[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listInstances without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), + ]; + client.innerApiCalls.listInstances = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listInstances( + request, + ( + err?: Error | null, + result?: protos.google.cloud.notebooks.v2.IInstance[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listInstances with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listInstances = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listInstances(request), expectedError); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listInstances with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listInstances = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listInstances(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listInstancesStream without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), - ]; - client.descriptors.page.listInstances.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listInstancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v2.Instance[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v2.Instance) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); - assert( - (client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listInstancesStream without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), + ]; + client.descriptors.page.listInstances.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v2.Instance[] = []; + stream.on( + 'data', + (response: protos.google.cloud.notebooks.v2.Instance) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listInstances, request), + ); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listInstancesStream with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstances.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listInstancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.notebooks.v2.Instance[] = []; - stream.on('data', (response: protos.google.cloud.notebooks.v2.Instance) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); - assert( - (client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listInstancesStream with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstances.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.notebooks.v2.Instance[] = []; + stream.on( + 'data', + (response: protos.google.cloud.notebooks.v2.Instance) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listInstances, request), + ); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listInstances without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), - generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), - ]; - client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.notebooks.v2.IInstance[] = []; - const iterable = client.listInstancesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listInstances without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), + generateSampleMessage(new protos.google.cloud.notebooks.v2.Instance()), + ]; + client.descriptors.page.listInstances.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.notebooks.v2.IInstance[] = []; + const iterable = client.listInstancesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listInstances.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listInstances with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.notebooks.v2.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.notebooks.v2.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listInstancesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.notebooks.v2.IInstance[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listInstances with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.notebooks.v2.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.notebooks.v2.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstances.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listInstancesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.notebooks.v2.IInstance[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listInstances.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes setIamPolicy with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); + }); + it('invokes testIamPermissions with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('instance', async () => { + const fakePath = '/rendered/path/instance'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + instance: 'instanceValue', + }; + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.instancePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.instancePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('instancePath', () => { + const result = client.instancePath( + 'projectValue', + 'locationValue', + 'instanceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.instancePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromInstanceName', () => { + const result = client.matchProjectFromInstanceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromInstanceName', () => { + const result = client.matchLocationFromInstanceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchInstanceFromInstanceName', () => { + const result = client.matchInstanceFromInstanceName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('instance', async () => { - const fakePath = "/rendered/path/instance"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - instance: "instanceValue", - }; - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.instancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.instancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('instancePath', () => { - const result = client.instancePath("projectValue", "locationValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.instancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInstanceName', () => { - const result = client.matchProjectFromInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromInstanceName', () => { - const result = client.matchLocationFromInstanceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromInstanceName', () => { - const result = client.matchInstanceFromInstanceName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new notebookserviceModule.v2.NotebookServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new notebookserviceModule.v2.NotebookServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-notebooks/webpack.config.js b/packages/google-cloud-notebooks/webpack.config.js index 8e40267d06c6..8b93a8e29df5 100644 --- a/packages/google-cloud-notebooks/webpack.config.js +++ b/packages/google-cloud-notebooks/webpack.config.js @@ -1,4 +1,4 @@ -// Copyright 2026 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-oracledatabase/.eslintignore b/packages/google-cloud-oracledatabase/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-oracledatabase/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-oracledatabase/.eslintrc.json b/packages/google-cloud-oracledatabase/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-oracledatabase/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-oracledatabase/README.md b/packages/google-cloud-oracledatabase/README.md index 4933c10807a6..68098f1c810d 100644 --- a/packages/google-cloud-oracledatabase/README.md +++ b/packages/google-cloud-oracledatabase/README.md @@ -149,7 +149,7 @@ More Information: [Google Cloud Platform Launch Stages][launch_stages] ## Contributing -Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-oracledatabase/CONTRIBUTING.md). +Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/CONTRIBUTING.md). Please note that this `README.md` and a variety of configuration files in this repository (including `.nycrc` and `tsconfig.json`) @@ -159,7 +159,7 @@ are generated from a central template. Apache Version 2.0 -See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-oracledatabase/LICENSE) +See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/LICENSE) [shell_img]: https://gstatic.com/cloudssh/images/open-btn.png [projects]: https://console.cloud.google.com/project diff --git a/packages/google-cloud-oracledatabase/protos/protos.d.ts b/packages/google-cloud-oracledatabase/protos/protos.d.ts index a2e2951599da..e88ae8f4dbc3 100644 --- a/packages/google-cloud-oracledatabase/protos/protos.d.ts +++ b/packages/google-cloud-oracledatabase/protos/protos.d.ts @@ -19692,6 +19692,9 @@ export namespace google { /** FieldInfo format */ format?: (google.api.FieldInfo.Format|keyof typeof google.api.FieldInfo.Format|null); + + /** FieldInfo referencedTypes */ + referencedTypes?: (google.api.ITypeReference[]|null); } /** Represents a FieldInfo. */ @@ -19706,6 +19709,9 @@ export namespace google { /** FieldInfo format. */ public format: (google.api.FieldInfo.Format|keyof typeof google.api.FieldInfo.Format); + /** FieldInfo referencedTypes. */ + public referencedTypes: google.api.ITypeReference[]; + /** * Creates a new FieldInfo instance using the specified properties. * @param [properties] Properties to set @@ -19796,6 +19802,103 @@ export namespace google { } } + /** Properties of a TypeReference. */ + interface ITypeReference { + + /** TypeReference typeName */ + typeName?: (string|null); + } + + /** Represents a TypeReference. */ + class TypeReference implements ITypeReference { + + /** + * Constructs a new TypeReference. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.ITypeReference); + + /** TypeReference typeName. */ + public typeName: string; + + /** + * Creates a new TypeReference instance using the specified properties. + * @param [properties] Properties to set + * @returns TypeReference instance + */ + public static create(properties?: google.api.ITypeReference): google.api.TypeReference; + + /** + * Encodes the specified TypeReference message. Does not implicitly {@link google.api.TypeReference.verify|verify} messages. + * @param message TypeReference message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.ITypeReference, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified TypeReference message, length delimited. Does not implicitly {@link google.api.TypeReference.verify|verify} messages. + * @param message TypeReference message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.ITypeReference, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TypeReference message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns TypeReference + * @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.api.TypeReference; + + /** + * Decodes a TypeReference message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns TypeReference + * @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.api.TypeReference; + + /** + * Verifies a TypeReference 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 TypeReference message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TypeReference + */ + public static fromObject(object: { [k: string]: any }): google.api.TypeReference; + + /** + * Creates a plain object from a TypeReference message. Also converts values to other types if specified. + * @param message TypeReference + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.TypeReference, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TypeReference to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for TypeReference + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** Properties of a Http. */ interface IHttp { @@ -20164,6 +20267,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -20181,6 +20287,9 @@ export namespace google { /** CommonLanguageSettings destinations. */ public destinations: google.api.ClientLibraryDestination[]; + /** CommonLanguageSettings selectiveGapicGeneration. */ + public selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); + /** * Creates a new CommonLanguageSettings instance using the specified properties. * @param [properties] Properties to set @@ -20881,6 +20990,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -20895,6 +21007,9 @@ export namespace google { /** PythonSettings common. */ public common?: (google.api.ICommonLanguageSettings|null); + /** PythonSettings experimentalFeatures. */ + public experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); + /** * Creates a new PythonSettings instance using the specified properties. * @param [properties] Properties to set @@ -20973,6 +21088,118 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + namespace PythonSettings { + + /** Properties of an ExperimentalFeatures. */ + interface IExperimentalFeatures { + + /** ExperimentalFeatures restAsyncIoEnabled */ + restAsyncIoEnabled?: (boolean|null); + + /** ExperimentalFeatures protobufPythonicTypesEnabled */ + protobufPythonicTypesEnabled?: (boolean|null); + + /** ExperimentalFeatures unversionedPackageDisabled */ + unversionedPackageDisabled?: (boolean|null); + } + + /** Represents an ExperimentalFeatures. */ + class ExperimentalFeatures implements IExperimentalFeatures { + + /** + * Constructs a new ExperimentalFeatures. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.PythonSettings.IExperimentalFeatures); + + /** ExperimentalFeatures restAsyncIoEnabled. */ + public restAsyncIoEnabled: boolean; + + /** ExperimentalFeatures protobufPythonicTypesEnabled. */ + public protobufPythonicTypesEnabled: boolean; + + /** ExperimentalFeatures unversionedPackageDisabled. */ + public unversionedPackageDisabled: boolean; + + /** + * Creates a new ExperimentalFeatures instance using the specified properties. + * @param [properties] Properties to set + * @returns ExperimentalFeatures instance + */ + public static create(properties?: google.api.PythonSettings.IExperimentalFeatures): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Encodes the specified ExperimentalFeatures message. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @param message ExperimentalFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.PythonSettings.IExperimentalFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExperimentalFeatures message, length delimited. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @param message ExperimentalFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.PythonSettings.IExperimentalFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExperimentalFeatures + * @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.api.PythonSettings.ExperimentalFeatures; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExperimentalFeatures + * @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.api.PythonSettings.ExperimentalFeatures; + + /** + * Verifies an ExperimentalFeatures 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 an ExperimentalFeatures message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExperimentalFeatures + */ + public static fromObject(object: { [k: string]: any }): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Creates a plain object from an ExperimentalFeatures message. Also converts values to other types if specified. + * @param message ExperimentalFeatures + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.PythonSettings.ExperimentalFeatures, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExperimentalFeatures to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExperimentalFeatures + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + /** Properties of a NodeSettings. */ interface INodeSettings { @@ -21299,6 +21526,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -21313,6 +21543,9 @@ export namespace google { /** GoSettings common. */ public common?: (google.api.ICommonLanguageSettings|null); + /** GoSettings renamedServices. */ + public renamedServices: { [k: string]: string }; + /** * Creates a new GoSettings instance using the specified properties. * @param [properties] Properties to set @@ -21637,6 +21870,109 @@ export namespace google { PACKAGE_MANAGER = 20 } + /** Properties of a SelectiveGapicGeneration. */ + interface ISelectiveGapicGeneration { + + /** SelectiveGapicGeneration methods */ + methods?: (string[]|null); + + /** SelectiveGapicGeneration generateOmittedAsInternal */ + generateOmittedAsInternal?: (boolean|null); + } + + /** Represents a SelectiveGapicGeneration. */ + class SelectiveGapicGeneration implements ISelectiveGapicGeneration { + + /** + * Constructs a new SelectiveGapicGeneration. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.ISelectiveGapicGeneration); + + /** SelectiveGapicGeneration methods. */ + public methods: string[]; + + /** SelectiveGapicGeneration generateOmittedAsInternal. */ + public generateOmittedAsInternal: boolean; + + /** + * Creates a new SelectiveGapicGeneration instance using the specified properties. + * @param [properties] Properties to set + * @returns SelectiveGapicGeneration instance + */ + public static create(properties?: google.api.ISelectiveGapicGeneration): google.api.SelectiveGapicGeneration; + + /** + * Encodes the specified SelectiveGapicGeneration message. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @param message SelectiveGapicGeneration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.ISelectiveGapicGeneration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SelectiveGapicGeneration message, length delimited. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @param message SelectiveGapicGeneration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.ISelectiveGapicGeneration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SelectiveGapicGeneration + * @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.api.SelectiveGapicGeneration; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SelectiveGapicGeneration + * @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.api.SelectiveGapicGeneration; + + /** + * Verifies a SelectiveGapicGeneration 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 SelectiveGapicGeneration message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SelectiveGapicGeneration + */ + public static fromObject(object: { [k: string]: any }): google.api.SelectiveGapicGeneration; + + /** + * Creates a plain object from a SelectiveGapicGeneration message. Also converts values to other types if specified. + * @param message SelectiveGapicGeneration + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.SelectiveGapicGeneration, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SelectiveGapicGeneration to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SelectiveGapicGeneration + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** LaunchStage enum. */ enum LaunchStage { LAUNCH_STAGE_UNSPECIFIED = 0, @@ -21753,6 +22089,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -21783,6 +22120,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -21832,6 +22172,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -21966,6 +22309,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -22007,6 +22353,9 @@ export namespace google { /** DescriptorProto reservedName. */ public reservedName: string[]; + /** DescriptorProto visibility. */ + public visibility: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility); + /** * Creates a new DescriptorProto instance using the specified properties. * @param [properties] Properties to set @@ -22854,6 +23203,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -22880,6 +23232,9 @@ export namespace google { /** EnumDescriptorProto reservedName. */ public reservedName: string[]; + /** EnumDescriptorProto visibility. */ + public visibility: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility); + /** * Creates a new EnumDescriptorProto instance using the specified properties. * @param [properties] Properties to set @@ -23814,6 +24169,9 @@ export namespace google { /** FieldOptions features */ features?: (google.protobuf.IFeatureSet|null); + /** FieldOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** FieldOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); @@ -23872,6 +24230,9 @@ export namespace google { /** FieldOptions features. */ public features?: (google.protobuf.IFeatureSet|null); + /** FieldOptions featureSupport. */ + public featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** FieldOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; @@ -24092,6 +24453,121 @@ export namespace google { */ public static getTypeUrl(typeUrlPrefix?: string): string; } + + /** Properties of a FeatureSupport. */ + interface IFeatureSupport { + + /** FeatureSupport editionIntroduced */ + editionIntroduced?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSupport editionDeprecated */ + editionDeprecated?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSupport deprecationWarning */ + deprecationWarning?: (string|null); + + /** FeatureSupport editionRemoved */ + editionRemoved?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + } + + /** Represents a FeatureSupport. */ + class FeatureSupport implements IFeatureSupport { + + /** + * Constructs a new FeatureSupport. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.FieldOptions.IFeatureSupport); + + /** FeatureSupport editionIntroduced. */ + public editionIntroduced: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSupport editionDeprecated. */ + public editionDeprecated: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSupport deprecationWarning. */ + public deprecationWarning: string; + + /** FeatureSupport editionRemoved. */ + public editionRemoved: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** + * Creates a new FeatureSupport instance using the specified properties. + * @param [properties] Properties to set + * @returns FeatureSupport instance + */ + public static create(properties?: google.protobuf.FieldOptions.IFeatureSupport): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Encodes the specified FeatureSupport message. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @param message FeatureSupport message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.FieldOptions.IFeatureSupport, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FeatureSupport message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @param message FeatureSupport message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.FieldOptions.IFeatureSupport, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FeatureSupport + * @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.protobuf.FieldOptions.FeatureSupport; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FeatureSupport + * @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.protobuf.FieldOptions.FeatureSupport; + + /** + * Verifies a FeatureSupport 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 FeatureSupport message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FeatureSupport + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Creates a plain object from a FeatureSupport message. Also converts values to other types if specified. + * @param message FeatureSupport + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldOptions.FeatureSupport, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FeatureSupport to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FeatureSupport + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } } /** Properties of an OneofOptions. */ @@ -24330,6 +24806,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -24352,6 +24831,9 @@ export namespace google { /** EnumValueOptions debugRedact. */ public debugRedact: boolean; + /** EnumValueOptions featureSupport. */ + public featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; @@ -24944,6 +25426,12 @@ export namespace google { /** FeatureSet jsonFormat */ jsonFormat?: (google.protobuf.FeatureSet.JsonFormat|keyof typeof google.protobuf.FeatureSet.JsonFormat|null); + + /** FeatureSet enforceNamingStyle */ + enforceNamingStyle?: (google.protobuf.FeatureSet.EnforceNamingStyle|keyof typeof google.protobuf.FeatureSet.EnforceNamingStyle|null); + + /** FeatureSet defaultSymbolVisibility */ + defaultSymbolVisibility?: (google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|keyof typeof google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|null); } /** Represents a FeatureSet. */ @@ -24973,6 +25461,12 @@ export namespace google { /** FeatureSet jsonFormat. */ public jsonFormat: (google.protobuf.FeatureSet.JsonFormat|keyof typeof google.protobuf.FeatureSet.JsonFormat); + /** FeatureSet enforceNamingStyle. */ + public enforceNamingStyle: (google.protobuf.FeatureSet.EnforceNamingStyle|keyof typeof google.protobuf.FeatureSet.EnforceNamingStyle); + + /** FeatureSet defaultSymbolVisibility. */ + public defaultSymbolVisibility: (google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|keyof typeof google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility); + /** * Creates a new FeatureSet instance using the specified properties. * @param [properties] Properties to set @@ -25095,6 +25589,116 @@ export namespace google { ALLOW = 1, LEGACY_BEST_EFFORT = 2 } + + /** EnforceNamingStyle enum. */ + enum EnforceNamingStyle { + ENFORCE_NAMING_STYLE_UNKNOWN = 0, + STYLE2024 = 1, + STYLE_LEGACY = 2 + } + + /** Properties of a VisibilityFeature. */ + interface IVisibilityFeature { + } + + /** Represents a VisibilityFeature. */ + class VisibilityFeature implements IVisibilityFeature { + + /** + * Constructs a new VisibilityFeature. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.FeatureSet.IVisibilityFeature); + + /** + * Creates a new VisibilityFeature instance using the specified properties. + * @param [properties] Properties to set + * @returns VisibilityFeature instance + */ + public static create(properties?: google.protobuf.FeatureSet.IVisibilityFeature): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Encodes the specified VisibilityFeature message. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @param message VisibilityFeature message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.FeatureSet.IVisibilityFeature, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified VisibilityFeature message, length delimited. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @param message VisibilityFeature message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.FeatureSet.IVisibilityFeature, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns VisibilityFeature + * @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.protobuf.FeatureSet.VisibilityFeature; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns VisibilityFeature + * @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.protobuf.FeatureSet.VisibilityFeature; + + /** + * Verifies a VisibilityFeature 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 VisibilityFeature message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns VisibilityFeature + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Creates a plain object from a VisibilityFeature message. Also converts values to other types if specified. + * @param message VisibilityFeature + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FeatureSet.VisibilityFeature, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this VisibilityFeature to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for VisibilityFeature + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace VisibilityFeature { + + /** DefaultSymbolVisibility enum. */ + enum DefaultSymbolVisibility { + DEFAULT_SYMBOL_VISIBILITY_UNKNOWN = 0, + EXPORT_ALL = 1, + EXPORT_TOP_LEVEL = 2, + LOCAL_ALL = 3, + STRICT = 4 + } + } } /** Properties of a FeatureSetDefaults. */ @@ -25214,8 +25818,11 @@ export namespace google { /** FeatureSetEditionDefault edition */ edition?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); - /** FeatureSetEditionDefault features */ - features?: (google.protobuf.IFeatureSet|null); + /** FeatureSetEditionDefault overridableFeatures */ + overridableFeatures?: (google.protobuf.IFeatureSet|null); + + /** FeatureSetEditionDefault fixedFeatures */ + fixedFeatures?: (google.protobuf.IFeatureSet|null); } /** Represents a FeatureSetEditionDefault. */ @@ -25230,8 +25837,11 @@ export namespace google { /** FeatureSetEditionDefault edition. */ public edition: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); - /** FeatureSetEditionDefault features. */ - public features?: (google.protobuf.IFeatureSet|null); + /** FeatureSetEditionDefault overridableFeatures. */ + public overridableFeatures?: (google.protobuf.IFeatureSet|null); + + /** FeatureSetEditionDefault fixedFeatures. */ + public fixedFeatures?: (google.protobuf.IFeatureSet|null); /** * Creates a new FeatureSetEditionDefault instance using the specified properties. @@ -25764,6 +26374,13 @@ export namespace google { } } + /** SymbolVisibility enum. */ + enum SymbolVisibility { + VISIBILITY_UNSET = 0, + VISIBILITY_LOCAL = 1, + VISIBILITY_EXPORT = 2 + } + /** Properties of a Duration. */ interface IDuration { diff --git a/packages/google-cloud-oracledatabase/protos/protos.js b/packages/google-cloud-oracledatabase/protos/protos.js index 0ce3a9314df5..8caed3a2aa97 100644 --- a/packages/google-cloud-oracledatabase/protos/protos.js +++ b/packages/google-cloud-oracledatabase/protos/protos.js @@ -51566,6 +51566,7 @@ * @memberof google.api * @interface IFieldInfo * @property {google.api.FieldInfo.Format|null} [format] FieldInfo format + * @property {Array.|null} [referencedTypes] FieldInfo referencedTypes */ /** @@ -51577,6 +51578,7 @@ * @param {google.api.IFieldInfo=} [properties] Properties to set */ function FieldInfo(properties) { + this.referencedTypes = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -51591,6 +51593,14 @@ */ FieldInfo.prototype.format = 0; + /** + * FieldInfo referencedTypes. + * @member {Array.} referencedTypes + * @memberof google.api.FieldInfo + * @instance + */ + FieldInfo.prototype.referencedTypes = $util.emptyArray; + /** * Creates a new FieldInfo instance using the specified properties. * @function create @@ -51617,6 +51627,9 @@ writer = $Writer.create(); if (message.format != null && Object.hasOwnProperty.call(message, "format")) writer.uint32(/* id 1, wireType 0 =*/8).int32(message.format); + if (message.referencedTypes != null && message.referencedTypes.length) + for (var i = 0; i < message.referencedTypes.length; ++i) + $root.google.api.TypeReference.encode(message.referencedTypes[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; @@ -51657,6 +51670,12 @@ message.format = reader.int32(); break; } + case 2: { + if (!(message.referencedTypes && message.referencedTypes.length)) + message.referencedTypes = []; + message.referencedTypes.push($root.google.api.TypeReference.decode(reader, reader.uint32())); + break; + } default: reader.skipType(tag & 7); break; @@ -51703,6 +51722,15 @@ case 4: break; } + if (message.referencedTypes != null && message.hasOwnProperty("referencedTypes")) { + if (!Array.isArray(message.referencedTypes)) + return "referencedTypes: array expected"; + for (var i = 0; i < message.referencedTypes.length; ++i) { + var error = $root.google.api.TypeReference.verify(message.referencedTypes[i]); + if (error) + return "referencedTypes." + error; + } + } return null; }; @@ -51746,6 +51774,16 @@ message.format = 4; break; } + if (object.referencedTypes) { + if (!Array.isArray(object.referencedTypes)) + throw TypeError(".google.api.FieldInfo.referencedTypes: array expected"); + message.referencedTypes = []; + for (var i = 0; i < object.referencedTypes.length; ++i) { + if (typeof object.referencedTypes[i] !== "object") + throw TypeError(".google.api.FieldInfo.referencedTypes: object expected"); + message.referencedTypes[i] = $root.google.api.TypeReference.fromObject(object.referencedTypes[i]); + } + } return message; }; @@ -51762,10 +51800,17 @@ if (!options) options = {}; var object = {}; + if (options.arrays || options.defaults) + object.referencedTypes = []; if (options.defaults) object.format = options.enums === String ? "FORMAT_UNSPECIFIED" : 0; if (message.format != null && message.hasOwnProperty("format")) object.format = options.enums === String ? $root.google.api.FieldInfo.Format[message.format] === undefined ? message.format : $root.google.api.FieldInfo.Format[message.format] : message.format; + if (message.referencedTypes && message.referencedTypes.length) { + object.referencedTypes = []; + for (var j = 0; j < message.referencedTypes.length; ++j) + object.referencedTypes[j] = $root.google.api.TypeReference.toObject(message.referencedTypes[j], options); + } return object; }; @@ -51818,6 +51863,211 @@ return FieldInfo; })(); + api.TypeReference = (function() { + + /** + * Properties of a TypeReference. + * @memberof google.api + * @interface ITypeReference + * @property {string|null} [typeName] TypeReference typeName + */ + + /** + * Constructs a new TypeReference. + * @memberof google.api + * @classdesc Represents a TypeReference. + * @implements ITypeReference + * @constructor + * @param {google.api.ITypeReference=} [properties] Properties to set + */ + function TypeReference(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]]; + } + + /** + * TypeReference typeName. + * @member {string} typeName + * @memberof google.api.TypeReference + * @instance + */ + TypeReference.prototype.typeName = ""; + + /** + * Creates a new TypeReference instance using the specified properties. + * @function create + * @memberof google.api.TypeReference + * @static + * @param {google.api.ITypeReference=} [properties] Properties to set + * @returns {google.api.TypeReference} TypeReference instance + */ + TypeReference.create = function create(properties) { + return new TypeReference(properties); + }; + + /** + * Encodes the specified TypeReference message. Does not implicitly {@link google.api.TypeReference.verify|verify} messages. + * @function encode + * @memberof google.api.TypeReference + * @static + * @param {google.api.ITypeReference} message TypeReference message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TypeReference.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.typeName != null && Object.hasOwnProperty.call(message, "typeName")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.typeName); + return writer; + }; + + /** + * Encodes the specified TypeReference message, length delimited. Does not implicitly {@link google.api.TypeReference.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.TypeReference + * @static + * @param {google.api.ITypeReference} message TypeReference message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TypeReference.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a TypeReference message from the specified reader or buffer. + * @function decode + * @memberof google.api.TypeReference + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.TypeReference} TypeReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TypeReference.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.TypeReference(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.typeName = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a TypeReference message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.TypeReference + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.TypeReference} TypeReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TypeReference.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TypeReference message. + * @function verify + * @memberof google.api.TypeReference + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TypeReference.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.typeName != null && message.hasOwnProperty("typeName")) + if (!$util.isString(message.typeName)) + return "typeName: string expected"; + return null; + }; + + /** + * Creates a TypeReference message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.TypeReference + * @static + * @param {Object.} object Plain object + * @returns {google.api.TypeReference} TypeReference + */ + TypeReference.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.TypeReference) + return object; + var message = new $root.google.api.TypeReference(); + if (object.typeName != null) + message.typeName = String(object.typeName); + return message; + }; + + /** + * Creates a plain object from a TypeReference message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.TypeReference + * @static + * @param {google.api.TypeReference} message TypeReference + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TypeReference.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.typeName = ""; + if (message.typeName != null && message.hasOwnProperty("typeName")) + object.typeName = message.typeName; + return object; + }; + + /** + * Converts this TypeReference to JSON. + * @function toJSON + * @memberof google.api.TypeReference + * @instance + * @returns {Object.} JSON object + */ + TypeReference.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for TypeReference + * @function getTypeUrl + * @memberof google.api.TypeReference + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + TypeReference.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.TypeReference"; + }; + + return TypeReference; + })(); + api.Http = (function() { /** @@ -52795,6 +53045,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -52829,6 +53080,14 @@ */ CommonLanguageSettings.prototype.destinations = $util.emptyArray; + /** + * CommonLanguageSettings selectiveGapicGeneration. + * @member {google.api.ISelectiveGapicGeneration|null|undefined} selectiveGapicGeneration + * @memberof google.api.CommonLanguageSettings + * @instance + */ + CommonLanguageSettings.prototype.selectiveGapicGeneration = null; + /** * Creates a new CommonLanguageSettings instance using the specified properties. * @function create @@ -52861,6 +53120,8 @@ writer.int32(message.destinations[i]); writer.ldelim(); } + if (message.selectiveGapicGeneration != null && Object.hasOwnProperty.call(message, "selectiveGapicGeneration")) + $root.google.api.SelectiveGapicGeneration.encode(message.selectiveGapicGeneration, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); return writer; }; @@ -52912,6 +53173,10 @@ message.destinations.push(reader.int32()); break; } + case 3: { + message.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -52963,6 +53228,11 @@ break; } } + if (message.selectiveGapicGeneration != null && message.hasOwnProperty("selectiveGapicGeneration")) { + var error = $root.google.api.SelectiveGapicGeneration.verify(message.selectiveGapicGeneration); + if (error) + return "selectiveGapicGeneration." + error; + } return null; }; @@ -53005,6 +53275,11 @@ break; } } + if (object.selectiveGapicGeneration != null) { + if (typeof object.selectiveGapicGeneration !== "object") + throw TypeError(".google.api.CommonLanguageSettings.selectiveGapicGeneration: object expected"); + message.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.fromObject(object.selectiveGapicGeneration); + } return message; }; @@ -53023,8 +53298,10 @@ var object = {}; if (options.arrays || options.defaults) object.destinations = []; - if (options.defaults) + if (options.defaults) { object.referenceDocsUri = ""; + object.selectiveGapicGeneration = null; + } if (message.referenceDocsUri != null && message.hasOwnProperty("referenceDocsUri")) object.referenceDocsUri = message.referenceDocsUri; if (message.destinations && message.destinations.length) { @@ -53032,6 +53309,8 @@ for (var j = 0; j < message.destinations.length; ++j) object.destinations[j] = options.enums === String ? $root.google.api.ClientLibraryDestination[message.destinations[j]] === undefined ? message.destinations[j] : $root.google.api.ClientLibraryDestination[message.destinations[j]] : message.destinations[j]; } + if (message.selectiveGapicGeneration != null && message.hasOwnProperty("selectiveGapicGeneration")) + object.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.toObject(message.selectiveGapicGeneration, options); return object; }; @@ -54854,6 +55133,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -54879,6 +55159,14 @@ */ PythonSettings.prototype.common = null; + /** + * PythonSettings experimentalFeatures. + * @member {google.api.PythonSettings.IExperimentalFeatures|null|undefined} experimentalFeatures + * @memberof google.api.PythonSettings + * @instance + */ + PythonSettings.prototype.experimentalFeatures = null; + /** * Creates a new PythonSettings instance using the specified properties. * @function create @@ -54905,6 +55193,8 @@ writer = $Writer.create(); if (message.common != null && Object.hasOwnProperty.call(message, "common")) $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.experimentalFeatures != null && Object.hasOwnProperty.call(message, "experimentalFeatures")) + $root.google.api.PythonSettings.ExperimentalFeatures.encode(message.experimentalFeatures, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; @@ -54945,6 +55235,10 @@ message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); break; } + case 2: { + message.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -54985,6 +55279,11 @@ if (error) return "common." + error; } + if (message.experimentalFeatures != null && message.hasOwnProperty("experimentalFeatures")) { + var error = $root.google.api.PythonSettings.ExperimentalFeatures.verify(message.experimentalFeatures); + if (error) + return "experimentalFeatures." + error; + } return null; }; @@ -55005,6 +55304,11 @@ throw TypeError(".google.api.PythonSettings.common: object expected"); message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); } + if (object.experimentalFeatures != null) { + if (typeof object.experimentalFeatures !== "object") + throw TypeError(".google.api.PythonSettings.experimentalFeatures: object expected"); + message.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.fromObject(object.experimentalFeatures); + } return message; }; @@ -55021,10 +55325,14 @@ if (!options) options = {}; var object = {}; - if (options.defaults) + if (options.defaults) { object.common = null; + object.experimentalFeatures = null; + } if (message.common != null && message.hasOwnProperty("common")) object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + if (message.experimentalFeatures != null && message.hasOwnProperty("experimentalFeatures")) + object.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.toObject(message.experimentalFeatures, options); return object; }; @@ -55054,58 +55362,310 @@ return typeUrlPrefix + "/google.api.PythonSettings"; }; - return PythonSettings; - })(); + PythonSettings.ExperimentalFeatures = (function() { - api.NodeSettings = (function() { + /** + * Properties of an ExperimentalFeatures. + * @memberof google.api.PythonSettings + * @interface IExperimentalFeatures + * @property {boolean|null} [restAsyncIoEnabled] ExperimentalFeatures restAsyncIoEnabled + * @property {boolean|null} [protobufPythonicTypesEnabled] ExperimentalFeatures protobufPythonicTypesEnabled + * @property {boolean|null} [unversionedPackageDisabled] ExperimentalFeatures unversionedPackageDisabled + */ - /** - * Properties of a NodeSettings. - * @memberof google.api - * @interface INodeSettings - * @property {google.api.ICommonLanguageSettings|null} [common] NodeSettings common - */ + /** + * Constructs a new ExperimentalFeatures. + * @memberof google.api.PythonSettings + * @classdesc Represents an ExperimentalFeatures. + * @implements IExperimentalFeatures + * @constructor + * @param {google.api.PythonSettings.IExperimentalFeatures=} [properties] Properties to set + */ + function ExperimentalFeatures(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]]; + } - /** - * Constructs a new NodeSettings. - * @memberof google.api - * @classdesc Represents a NodeSettings. - * @implements INodeSettings - * @constructor - * @param {google.api.INodeSettings=} [properties] Properties to set - */ - function NodeSettings(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]]; - } + /** + * ExperimentalFeatures restAsyncIoEnabled. + * @member {boolean} restAsyncIoEnabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.restAsyncIoEnabled = false; - /** - * NodeSettings common. - * @member {google.api.ICommonLanguageSettings|null|undefined} common - * @memberof google.api.NodeSettings - * @instance - */ - NodeSettings.prototype.common = null; + /** + * ExperimentalFeatures protobufPythonicTypesEnabled. + * @member {boolean} protobufPythonicTypesEnabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.protobufPythonicTypesEnabled = false; - /** - * Creates a new NodeSettings instance using the specified properties. - * @function create - * @memberof google.api.NodeSettings - * @static - * @param {google.api.INodeSettings=} [properties] Properties to set - * @returns {google.api.NodeSettings} NodeSettings instance - */ - NodeSettings.create = function create(properties) { - return new NodeSettings(properties); - }; + /** + * ExperimentalFeatures unversionedPackageDisabled. + * @member {boolean} unversionedPackageDisabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.unversionedPackageDisabled = false; - /** - * Encodes the specified NodeSettings message. Does not implicitly {@link google.api.NodeSettings.verify|verify} messages. - * @function encode - * @memberof google.api.NodeSettings - * @static + /** + * Creates a new ExperimentalFeatures instance using the specified properties. + * @function create + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures=} [properties] Properties to set + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures instance + */ + ExperimentalFeatures.create = function create(properties) { + return new ExperimentalFeatures(properties); + }; + + /** + * Encodes the specified ExperimentalFeatures message. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @function encode + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures} message ExperimentalFeatures message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExperimentalFeatures.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.restAsyncIoEnabled != null && Object.hasOwnProperty.call(message, "restAsyncIoEnabled")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.restAsyncIoEnabled); + if (message.protobufPythonicTypesEnabled != null && Object.hasOwnProperty.call(message, "protobufPythonicTypesEnabled")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.protobufPythonicTypesEnabled); + if (message.unversionedPackageDisabled != null && Object.hasOwnProperty.call(message, "unversionedPackageDisabled")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.unversionedPackageDisabled); + return writer; + }; + + /** + * Encodes the specified ExperimentalFeatures message, length delimited. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures} message ExperimentalFeatures message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExperimentalFeatures.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer. + * @function decode + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExperimentalFeatures.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.PythonSettings.ExperimentalFeatures(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.restAsyncIoEnabled = reader.bool(); + break; + } + case 2: { + message.protobufPythonicTypesEnabled = reader.bool(); + break; + } + case 3: { + message.unversionedPackageDisabled = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExperimentalFeatures.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExperimentalFeatures message. + * @function verify + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExperimentalFeatures.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.restAsyncIoEnabled != null && message.hasOwnProperty("restAsyncIoEnabled")) + if (typeof message.restAsyncIoEnabled !== "boolean") + return "restAsyncIoEnabled: boolean expected"; + if (message.protobufPythonicTypesEnabled != null && message.hasOwnProperty("protobufPythonicTypesEnabled")) + if (typeof message.protobufPythonicTypesEnabled !== "boolean") + return "protobufPythonicTypesEnabled: boolean expected"; + if (message.unversionedPackageDisabled != null && message.hasOwnProperty("unversionedPackageDisabled")) + if (typeof message.unversionedPackageDisabled !== "boolean") + return "unversionedPackageDisabled: boolean expected"; + return null; + }; + + /** + * Creates an ExperimentalFeatures message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {Object.} object Plain object + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + */ + ExperimentalFeatures.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.PythonSettings.ExperimentalFeatures) + return object; + var message = new $root.google.api.PythonSettings.ExperimentalFeatures(); + if (object.restAsyncIoEnabled != null) + message.restAsyncIoEnabled = Boolean(object.restAsyncIoEnabled); + if (object.protobufPythonicTypesEnabled != null) + message.protobufPythonicTypesEnabled = Boolean(object.protobufPythonicTypesEnabled); + if (object.unversionedPackageDisabled != null) + message.unversionedPackageDisabled = Boolean(object.unversionedPackageDisabled); + return message; + }; + + /** + * Creates a plain object from an ExperimentalFeatures message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.ExperimentalFeatures} message ExperimentalFeatures + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExperimentalFeatures.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.restAsyncIoEnabled = false; + object.protobufPythonicTypesEnabled = false; + object.unversionedPackageDisabled = false; + } + if (message.restAsyncIoEnabled != null && message.hasOwnProperty("restAsyncIoEnabled")) + object.restAsyncIoEnabled = message.restAsyncIoEnabled; + if (message.protobufPythonicTypesEnabled != null && message.hasOwnProperty("protobufPythonicTypesEnabled")) + object.protobufPythonicTypesEnabled = message.protobufPythonicTypesEnabled; + if (message.unversionedPackageDisabled != null && message.hasOwnProperty("unversionedPackageDisabled")) + object.unversionedPackageDisabled = message.unversionedPackageDisabled; + return object; + }; + + /** + * Converts this ExperimentalFeatures to JSON. + * @function toJSON + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + * @returns {Object.} JSON object + */ + ExperimentalFeatures.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExperimentalFeatures + * @function getTypeUrl + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExperimentalFeatures.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.PythonSettings.ExperimentalFeatures"; + }; + + return ExperimentalFeatures; + })(); + + return PythonSettings; + })(); + + api.NodeSettings = (function() { + + /** + * Properties of a NodeSettings. + * @memberof google.api + * @interface INodeSettings + * @property {google.api.ICommonLanguageSettings|null} [common] NodeSettings common + */ + + /** + * Constructs a new NodeSettings. + * @memberof google.api + * @classdesc Represents a NodeSettings. + * @implements INodeSettings + * @constructor + * @param {google.api.INodeSettings=} [properties] Properties to set + */ + function NodeSettings(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]]; + } + + /** + * NodeSettings common. + * @member {google.api.ICommonLanguageSettings|null|undefined} common + * @memberof google.api.NodeSettings + * @instance + */ + NodeSettings.prototype.common = null; + + /** + * Creates a new NodeSettings instance using the specified properties. + * @function create + * @memberof google.api.NodeSettings + * @static + * @param {google.api.INodeSettings=} [properties] Properties to set + * @returns {google.api.NodeSettings} NodeSettings instance + */ + NodeSettings.create = function create(properties) { + return new NodeSettings(properties); + }; + + /** + * Encodes the specified NodeSettings message. Does not implicitly {@link google.api.NodeSettings.verify|verify} messages. + * @function encode + * @memberof google.api.NodeSettings + * @static * @param {google.api.INodeSettings} message NodeSettings message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer @@ -55930,6 +56490,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -55941,6 +56502,7 @@ * @param {google.api.IGoSettings=} [properties] Properties to set */ function GoSettings(properties) { + this.renamedServices = {}; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -55955,6 +56517,14 @@ */ GoSettings.prototype.common = null; + /** + * GoSettings renamedServices. + * @member {Object.} renamedServices + * @memberof google.api.GoSettings + * @instance + */ + GoSettings.prototype.renamedServices = $util.emptyObject; + /** * Creates a new GoSettings instance using the specified properties. * @function create @@ -55981,6 +56551,9 @@ writer = $Writer.create(); if (message.common != null && Object.hasOwnProperty.call(message, "common")) $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.renamedServices != null && Object.hasOwnProperty.call(message, "renamedServices")) + for (var keys = Object.keys(message.renamedServices), i = 0; i < keys.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.renamedServices[keys[i]]).ldelim(); return writer; }; @@ -56011,7 +56584,7 @@ GoSettings.decode = function decode(reader, length, error) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.GoSettings(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.GoSettings(), key, value; while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) @@ -56021,6 +56594,29 @@ message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); break; } + case 2: { + if (message.renamedServices === $util.emptyObject) + message.renamedServices = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = ""; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = reader.string(); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.renamedServices[key] = value; + break; + } default: reader.skipType(tag & 7); break; @@ -56061,6 +56657,14 @@ if (error) return "common." + error; } + if (message.renamedServices != null && message.hasOwnProperty("renamedServices")) { + if (!$util.isObject(message.renamedServices)) + return "renamedServices: object expected"; + var key = Object.keys(message.renamedServices); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.renamedServices[key[i]])) + return "renamedServices: string{k:string} expected"; + } return null; }; @@ -56081,6 +56685,13 @@ throw TypeError(".google.api.GoSettings.common: object expected"); message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); } + if (object.renamedServices) { + if (typeof object.renamedServices !== "object") + throw TypeError(".google.api.GoSettings.renamedServices: object expected"); + message.renamedServices = {}; + for (var keys = Object.keys(object.renamedServices), i = 0; i < keys.length; ++i) + message.renamedServices[keys[i]] = String(object.renamedServices[keys[i]]); + } return message; }; @@ -56097,10 +56708,18 @@ if (!options) options = {}; var object = {}; + if (options.objects || options.defaults) + object.renamedServices = {}; if (options.defaults) object.common = null; if (message.common != null && message.hasOwnProperty("common")) object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + var keys2; + if (message.renamedServices && (keys2 = Object.keys(message.renamedServices)).length) { + object.renamedServices = {}; + for (var j = 0; j < keys2.length; ++j) + object.renamedServices[keys2[j]] = message.renamedServices[keys2[j]]; + } return object; }; @@ -56739,30 +57358,275 @@ return values; })(); - /** - * LaunchStage enum. - * @name google.api.LaunchStage - * @enum {number} - * @property {number} LAUNCH_STAGE_UNSPECIFIED=0 LAUNCH_STAGE_UNSPECIFIED value - * @property {number} UNIMPLEMENTED=6 UNIMPLEMENTED value - * @property {number} PRELAUNCH=7 PRELAUNCH value - * @property {number} EARLY_ACCESS=1 EARLY_ACCESS value - * @property {number} ALPHA=2 ALPHA value - * @property {number} BETA=3 BETA value - * @property {number} GA=4 GA value - * @property {number} DEPRECATED=5 DEPRECATED value - */ - api.LaunchStage = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "LAUNCH_STAGE_UNSPECIFIED"] = 0; - values[valuesById[6] = "UNIMPLEMENTED"] = 6; - values[valuesById[7] = "PRELAUNCH"] = 7; - values[valuesById[1] = "EARLY_ACCESS"] = 1; - values[valuesById[2] = "ALPHA"] = 2; - values[valuesById[3] = "BETA"] = 3; - values[valuesById[4] = "GA"] = 4; - values[valuesById[5] = "DEPRECATED"] = 5; - return values; + api.SelectiveGapicGeneration = (function() { + + /** + * Properties of a SelectiveGapicGeneration. + * @memberof google.api + * @interface ISelectiveGapicGeneration + * @property {Array.|null} [methods] SelectiveGapicGeneration methods + * @property {boolean|null} [generateOmittedAsInternal] SelectiveGapicGeneration generateOmittedAsInternal + */ + + /** + * Constructs a new SelectiveGapicGeneration. + * @memberof google.api + * @classdesc Represents a SelectiveGapicGeneration. + * @implements ISelectiveGapicGeneration + * @constructor + * @param {google.api.ISelectiveGapicGeneration=} [properties] Properties to set + */ + function SelectiveGapicGeneration(properties) { + this.methods = []; + 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]]; + } + + /** + * SelectiveGapicGeneration methods. + * @member {Array.} methods + * @memberof google.api.SelectiveGapicGeneration + * @instance + */ + SelectiveGapicGeneration.prototype.methods = $util.emptyArray; + + /** + * SelectiveGapicGeneration generateOmittedAsInternal. + * @member {boolean} generateOmittedAsInternal + * @memberof google.api.SelectiveGapicGeneration + * @instance + */ + SelectiveGapicGeneration.prototype.generateOmittedAsInternal = false; + + /** + * Creates a new SelectiveGapicGeneration instance using the specified properties. + * @function create + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration=} [properties] Properties to set + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration instance + */ + SelectiveGapicGeneration.create = function create(properties) { + return new SelectiveGapicGeneration(properties); + }; + + /** + * Encodes the specified SelectiveGapicGeneration message. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @function encode + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration} message SelectiveGapicGeneration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SelectiveGapicGeneration.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.methods != null && message.methods.length) + for (var i = 0; i < message.methods.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.methods[i]); + if (message.generateOmittedAsInternal != null && Object.hasOwnProperty.call(message, "generateOmittedAsInternal")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.generateOmittedAsInternal); + return writer; + }; + + /** + * Encodes the specified SelectiveGapicGeneration message, length delimited. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration} message SelectiveGapicGeneration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SelectiveGapicGeneration.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer. + * @function decode + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SelectiveGapicGeneration.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.SelectiveGapicGeneration(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + if (!(message.methods && message.methods.length)) + message.methods = []; + message.methods.push(reader.string()); + break; + } + case 2: { + message.generateOmittedAsInternal = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SelectiveGapicGeneration.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SelectiveGapicGeneration message. + * @function verify + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SelectiveGapicGeneration.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.methods != null && message.hasOwnProperty("methods")) { + if (!Array.isArray(message.methods)) + return "methods: array expected"; + for (var i = 0; i < message.methods.length; ++i) + if (!$util.isString(message.methods[i])) + return "methods: string[] expected"; + } + if (message.generateOmittedAsInternal != null && message.hasOwnProperty("generateOmittedAsInternal")) + if (typeof message.generateOmittedAsInternal !== "boolean") + return "generateOmittedAsInternal: boolean expected"; + return null; + }; + + /** + * Creates a SelectiveGapicGeneration message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {Object.} object Plain object + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + */ + SelectiveGapicGeneration.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.SelectiveGapicGeneration) + return object; + var message = new $root.google.api.SelectiveGapicGeneration(); + if (object.methods) { + if (!Array.isArray(object.methods)) + throw TypeError(".google.api.SelectiveGapicGeneration.methods: array expected"); + message.methods = []; + for (var i = 0; i < object.methods.length; ++i) + message.methods[i] = String(object.methods[i]); + } + if (object.generateOmittedAsInternal != null) + message.generateOmittedAsInternal = Boolean(object.generateOmittedAsInternal); + return message; + }; + + /** + * Creates a plain object from a SelectiveGapicGeneration message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.SelectiveGapicGeneration} message SelectiveGapicGeneration + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SelectiveGapicGeneration.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.methods = []; + if (options.defaults) + object.generateOmittedAsInternal = false; + if (message.methods && message.methods.length) { + object.methods = []; + for (var j = 0; j < message.methods.length; ++j) + object.methods[j] = message.methods[j]; + } + if (message.generateOmittedAsInternal != null && message.hasOwnProperty("generateOmittedAsInternal")) + object.generateOmittedAsInternal = message.generateOmittedAsInternal; + return object; + }; + + /** + * Converts this SelectiveGapicGeneration to JSON. + * @function toJSON + * @memberof google.api.SelectiveGapicGeneration + * @instance + * @returns {Object.} JSON object + */ + SelectiveGapicGeneration.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SelectiveGapicGeneration + * @function getTypeUrl + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SelectiveGapicGeneration.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.SelectiveGapicGeneration"; + }; + + return SelectiveGapicGeneration; + })(); + + /** + * LaunchStage enum. + * @name google.api.LaunchStage + * @enum {number} + * @property {number} LAUNCH_STAGE_UNSPECIFIED=0 LAUNCH_STAGE_UNSPECIFIED value + * @property {number} UNIMPLEMENTED=6 UNIMPLEMENTED value + * @property {number} PRELAUNCH=7 PRELAUNCH value + * @property {number} EARLY_ACCESS=1 EARLY_ACCESS value + * @property {number} ALPHA=2 ALPHA value + * @property {number} BETA=3 BETA value + * @property {number} GA=4 GA value + * @property {number} DEPRECATED=5 DEPRECATED value + */ + api.LaunchStage = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "LAUNCH_STAGE_UNSPECIFIED"] = 0; + values[valuesById[6] = "UNIMPLEMENTED"] = 6; + values[valuesById[7] = "PRELAUNCH"] = 7; + values[valuesById[1] = "EARLY_ACCESS"] = 1; + values[valuesById[2] = "ALPHA"] = 2; + values[valuesById[3] = "BETA"] = 3; + values[valuesById[4] = "GA"] = 4; + values[valuesById[5] = "DEPRECATED"] = 5; + return values; })(); return api; @@ -57008,6 +57872,7 @@ * @name google.protobuf.Edition * @enum {number} * @property {number} EDITION_UNKNOWN=0 EDITION_UNKNOWN value + * @property {number} EDITION_LEGACY=900 EDITION_LEGACY value * @property {number} EDITION_PROTO2=998 EDITION_PROTO2 value * @property {number} EDITION_PROTO3=999 EDITION_PROTO3 value * @property {number} EDITION_2023=1000 EDITION_2023 value @@ -57022,6 +57887,7 @@ protobuf.Edition = (function() { var valuesById = {}, values = Object.create(valuesById); values[valuesById[0] = "EDITION_UNKNOWN"] = 0; + values[valuesById[900] = "EDITION_LEGACY"] = 900; values[valuesById[998] = "EDITION_PROTO2"] = 998; values[valuesById[999] = "EDITION_PROTO3"] = 999; values[valuesById[1000] = "EDITION_2023"] = 1000; @@ -57046,6 +57912,7 @@ * @property {Array.|null} [dependency] FileDescriptorProto dependency * @property {Array.|null} [publicDependency] FileDescriptorProto publicDependency * @property {Array.|null} [weakDependency] FileDescriptorProto weakDependency + * @property {Array.|null} [optionDependency] FileDescriptorProto optionDependency * @property {Array.|null} [messageType] FileDescriptorProto messageType * @property {Array.|null} [enumType] FileDescriptorProto enumType * @property {Array.|null} [service] FileDescriptorProto service @@ -57068,6 +57935,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -57118,6 +57986,14 @@ */ FileDescriptorProto.prototype.weakDependency = $util.emptyArray; + /** + * FileDescriptorProto optionDependency. + * @member {Array.} optionDependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.optionDependency = $util.emptyArray; + /** * FileDescriptorProto messageType. * @member {Array.} messageType @@ -57239,6 +58115,9 @@ writer.uint32(/* id 12, wireType 2 =*/98).string(message.syntax); if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) writer.uint32(/* id 14, wireType 0 =*/112).int32(message.edition); + if (message.optionDependency != null && message.optionDependency.length) + for (var i = 0; i < message.optionDependency.length; ++i) + writer.uint32(/* id 15, wireType 2 =*/122).string(message.optionDependency[i]); return writer; }; @@ -57311,6 +58190,12 @@ message.weakDependency.push(reader.int32()); break; } + case 15: { + if (!(message.optionDependency && message.optionDependency.length)) + message.optionDependency = []; + message.optionDependency.push(reader.string()); + break; + } case 4: { if (!(message.messageType && message.messageType.length)) message.messageType = []; @@ -57413,6 +58298,13 @@ if (!$util.isInteger(message.weakDependency[i])) return "weakDependency: integer[] expected"; } + if (message.optionDependency != null && message.hasOwnProperty("optionDependency")) { + if (!Array.isArray(message.optionDependency)) + return "optionDependency: array expected"; + for (var i = 0; i < message.optionDependency.length; ++i) + if (!$util.isString(message.optionDependency[i])) + return "optionDependency: string[] expected"; + } if (message.messageType != null && message.hasOwnProperty("messageType")) { if (!Array.isArray(message.messageType)) return "messageType: array expected"; @@ -57467,6 +58359,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -57519,6 +58412,13 @@ for (var i = 0; i < object.weakDependency.length; ++i) message.weakDependency[i] = object.weakDependency[i] | 0; } + if (object.optionDependency) { + if (!Array.isArray(object.optionDependency)) + throw TypeError(".google.protobuf.FileDescriptorProto.optionDependency: array expected"); + message.optionDependency = []; + for (var i = 0; i < object.optionDependency.length; ++i) + message.optionDependency[i] = String(object.optionDependency[i]); + } if (object.messageType) { if (!Array.isArray(object.messageType)) throw TypeError(".google.protobuf.FileDescriptorProto.messageType: array expected"); @@ -57582,6 +58482,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -57647,6 +58551,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -57703,6 +58608,11 @@ object.syntax = message.syntax; if (message.edition != null && message.hasOwnProperty("edition")) object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.optionDependency && message.optionDependency.length) { + object.optionDependency = []; + for (var j = 0; j < message.optionDependency.length; ++j) + object.optionDependency[j] = message.optionDependency[j]; + } return object; }; @@ -57751,6 +58661,7 @@ * @property {google.protobuf.IMessageOptions|null} [options] DescriptorProto options * @property {Array.|null} [reservedRange] DescriptorProto reservedRange * @property {Array.|null} [reservedName] DescriptorProto reservedName + * @property {google.protobuf.SymbolVisibility|null} [visibility] DescriptorProto visibility */ /** @@ -57856,6 +58767,14 @@ */ DescriptorProto.prototype.reservedName = $util.emptyArray; + /** + * DescriptorProto visibility. + * @member {google.protobuf.SymbolVisibility} visibility + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.visibility = 0; + /** * Creates a new DescriptorProto instance using the specified properties. * @function create @@ -57908,6 +58827,8 @@ if (message.reservedName != null && message.reservedName.length) for (var i = 0; i < message.reservedName.length; ++i) writer.uint32(/* id 10, wireType 2 =*/82).string(message.reservedName[i]); + if (message.visibility != null && Object.hasOwnProperty.call(message, "visibility")) + writer.uint32(/* id 11, wireType 0 =*/88).int32(message.visibility); return writer; }; @@ -58000,6 +58921,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -58113,6 +59038,15 @@ if (!$util.isString(message.reservedName[i])) return "reservedName: string[] expected"; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + switch (message.visibility) { + default: + return "visibility: enum value expected"; + case 0: + case 1: + case 2: + break; + } return null; }; @@ -58212,6 +59146,26 @@ for (var i = 0; i < object.reservedName.length; ++i) message.reservedName[i] = String(object.reservedName[i]); } + switch (object.visibility) { + default: + if (typeof object.visibility === "number") { + message.visibility = object.visibility; + break; + } + break; + case "VISIBILITY_UNSET": + case 0: + message.visibility = 0; + break; + case "VISIBILITY_LOCAL": + case 1: + message.visibility = 1; + break; + case "VISIBILITY_EXPORT": + case 2: + message.visibility = 2; + break; + } return message; }; @@ -58241,6 +59195,7 @@ if (options.defaults) { object.name = ""; object.options = null; + object.visibility = options.enums === String ? "VISIBILITY_UNSET" : 0; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -58286,6 +59241,8 @@ for (var j = 0; j < message.reservedName.length; ++j) object.reservedName[j] = message.reservedName[j]; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + object.visibility = options.enums === String ? $root.google.protobuf.SymbolVisibility[message.visibility] === undefined ? message.visibility : $root.google.protobuf.SymbolVisibility[message.visibility] : message.visibility; return object; }; @@ -60330,6 +61287,7 @@ * @property {google.protobuf.IEnumOptions|null} [options] EnumDescriptorProto options * @property {Array.|null} [reservedRange] EnumDescriptorProto reservedRange * @property {Array.|null} [reservedName] EnumDescriptorProto reservedName + * @property {google.protobuf.SymbolVisibility|null} [visibility] EnumDescriptorProto visibility */ /** @@ -60390,6 +61348,14 @@ */ EnumDescriptorProto.prototype.reservedName = $util.emptyArray; + /** + * EnumDescriptorProto visibility. + * @member {google.protobuf.SymbolVisibility} visibility + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.visibility = 0; + /** * Creates a new EnumDescriptorProto instance using the specified properties. * @function create @@ -60427,6 +61393,8 @@ if (message.reservedName != null && message.reservedName.length) for (var i = 0; i < message.reservedName.length; ++i) writer.uint32(/* id 5, wireType 2 =*/42).string(message.reservedName[i]); + if (message.visibility != null && Object.hasOwnProperty.call(message, "visibility")) + writer.uint32(/* id 6, wireType 0 =*/48).int32(message.visibility); return writer; }; @@ -60489,6 +61457,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -60557,6 +61529,15 @@ if (!$util.isString(message.reservedName[i])) return "reservedName: string[] expected"; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + switch (message.visibility) { + default: + return "visibility: enum value expected"; + case 0: + case 1: + case 2: + break; + } return null; }; @@ -60606,6 +61587,26 @@ for (var i = 0; i < object.reservedName.length; ++i) message.reservedName[i] = String(object.reservedName[i]); } + switch (object.visibility) { + default: + if (typeof object.visibility === "number") { + message.visibility = object.visibility; + break; + } + break; + case "VISIBILITY_UNSET": + case 0: + message.visibility = 0; + break; + case "VISIBILITY_LOCAL": + case 1: + message.visibility = 1; + break; + case "VISIBILITY_EXPORT": + case 2: + message.visibility = 2; + break; + } return message; }; @@ -60630,6 +61631,7 @@ if (options.defaults) { object.name = ""; object.options = null; + object.visibility = options.enums === String ? "VISIBILITY_UNSET" : 0; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -60650,6 +61652,8 @@ for (var j = 0; j < message.reservedName.length; ++j) object.reservedName[j] = message.reservedName[j]; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + object.visibility = options.enums === String ? $root.google.protobuf.SymbolVisibility[message.visibility] === undefined ? message.visibility : $root.google.protobuf.SymbolVisibility[message.visibility] : message.visibility; return object; }; @@ -62968,6 +63972,7 @@ * @property {Array.|null} [targets] FieldOptions targets * @property {Array.|null} [editionDefaults] FieldOptions editionDefaults * @property {google.protobuf.IFeatureSet|null} [features] FieldOptions features + * @property {google.protobuf.FieldOptions.IFeatureSupport|null} [featureSupport] FieldOptions featureSupport * @property {Array.|null} [uninterpretedOption] FieldOptions uninterpretedOption * @property {Array.|null} [".google.api.fieldBehavior"] FieldOptions .google.api.fieldBehavior * @property {google.api.IResourceReference|null} [".google.api.resourceReference"] FieldOptions .google.api.resourceReference @@ -63089,6 +64094,14 @@ */ FieldOptions.prototype.features = null; + /** + * FieldOptions featureSupport. + * @member {google.protobuf.FieldOptions.IFeatureSupport|null|undefined} featureSupport + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.featureSupport = null; + /** * FieldOptions uninterpretedOption. * @member {Array.} uninterpretedOption @@ -63171,6 +64184,8 @@ $root.google.protobuf.FieldOptions.EditionDefault.encode(message.editionDefaults[i], writer.uint32(/* id 20, wireType 2 =*/162).fork()).ldelim(); if (message.features != null && Object.hasOwnProperty.call(message, "features")) $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 21, wireType 2 =*/170).fork()).ldelim(); + if (message.featureSupport != null && Object.hasOwnProperty.call(message, "featureSupport")) + $root.google.protobuf.FieldOptions.FeatureSupport.encode(message.featureSupport, writer.uint32(/* id 22, wireType 2 =*/178).fork()).ldelim(); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); @@ -63274,6 +64289,10 @@ message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); break; } + case 22: { + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.decode(reader, reader.uint32()); + break; + } case 999: { if (!(message.uninterpretedOption && message.uninterpretedOption.length)) message.uninterpretedOption = []; @@ -63413,6 +64432,11 @@ if (error) return "features." + error; } + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) { + var error = $root.google.protobuf.FieldOptions.FeatureSupport.verify(message.featureSupport); + if (error) + return "featureSupport." + error; + } if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { if (!Array.isArray(message.uninterpretedOption)) return "uninterpretedOption: array expected"; @@ -63606,6 +64630,11 @@ throw TypeError(".google.protobuf.FieldOptions.features: object expected"); message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); } + if (object.featureSupport != null) { + if (typeof object.featureSupport !== "object") + throw TypeError(".google.protobuf.FieldOptions.featureSupport: object expected"); + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.fromObject(object.featureSupport); + } if (object.uninterpretedOption) { if (!Array.isArray(object.uninterpretedOption)) throw TypeError(".google.protobuf.FieldOptions.uninterpretedOption: array expected"); @@ -63708,6 +64737,7 @@ object.debugRedact = false; object.retention = options.enums === String ? "RETENTION_UNKNOWN" : 0; object.features = null; + object.featureSupport = null; object[".google.api.resourceReference"] = null; object[".google.api.fieldInfo"] = null; } @@ -63741,6 +64771,8 @@ } if (message.features != null && message.hasOwnProperty("features")) object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) + object.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.toObject(message.featureSupport, options); if (message.uninterpretedOption && message.uninterpretedOption.length) { object.uninterpretedOption = []; for (var j = 0; j < message.uninterpretedOption.length; ++j) @@ -64015,6 +65047,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -64056,103 +65089,589 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; + case "EDITION_PROTO2": + case 998: + message.edition = 998; + break; + case "EDITION_PROTO3": + case 999: + message.edition = 999; + break; + case "EDITION_2023": + case 1000: + message.edition = 1000; + break; + case "EDITION_2024": + case 1001: + message.edition = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.edition = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.edition = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.edition = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.edition = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.edition = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.edition = 2147483647; + break; + } + if (object.value != null) + message.value = String(object.value); + return message; + }; + + /** + * Creates a plain object from an EditionDefault message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {google.protobuf.FieldOptions.EditionDefault} message EditionDefault + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EditionDefault.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.value = ""; + object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + } + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + if (message.edition != null && message.hasOwnProperty("edition")) + object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + return object; + }; + + /** + * Converts this EditionDefault to JSON. + * @function toJSON + * @memberof google.protobuf.FieldOptions.EditionDefault + * @instance + * @returns {Object.} JSON object + */ + EditionDefault.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for EditionDefault + * @function getTypeUrl + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + EditionDefault.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FieldOptions.EditionDefault"; + }; + + return EditionDefault; + })(); + + FieldOptions.FeatureSupport = (function() { + + /** + * Properties of a FeatureSupport. + * @memberof google.protobuf.FieldOptions + * @interface IFeatureSupport + * @property {google.protobuf.Edition|null} [editionIntroduced] FeatureSupport editionIntroduced + * @property {google.protobuf.Edition|null} [editionDeprecated] FeatureSupport editionDeprecated + * @property {string|null} [deprecationWarning] FeatureSupport deprecationWarning + * @property {google.protobuf.Edition|null} [editionRemoved] FeatureSupport editionRemoved + */ + + /** + * Constructs a new FeatureSupport. + * @memberof google.protobuf.FieldOptions + * @classdesc Represents a FeatureSupport. + * @implements IFeatureSupport + * @constructor + * @param {google.protobuf.FieldOptions.IFeatureSupport=} [properties] Properties to set + */ + function FeatureSupport(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]]; + } + + /** + * FeatureSupport editionIntroduced. + * @member {google.protobuf.Edition} editionIntroduced + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionIntroduced = 0; + + /** + * FeatureSupport editionDeprecated. + * @member {google.protobuf.Edition} editionDeprecated + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionDeprecated = 0; + + /** + * FeatureSupport deprecationWarning. + * @member {string} deprecationWarning + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.deprecationWarning = ""; + + /** + * FeatureSupport editionRemoved. + * @member {google.protobuf.Edition} editionRemoved + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionRemoved = 0; + + /** + * Creates a new FeatureSupport instance using the specified properties. + * @function create + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport=} [properties] Properties to set + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport instance + */ + FeatureSupport.create = function create(properties) { + return new FeatureSupport(properties); + }; + + /** + * Encodes the specified FeatureSupport message. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport} message FeatureSupport message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSupport.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.editionIntroduced != null && Object.hasOwnProperty.call(message, "editionIntroduced")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.editionIntroduced); + if (message.editionDeprecated != null && Object.hasOwnProperty.call(message, "editionDeprecated")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.editionDeprecated); + if (message.deprecationWarning != null && Object.hasOwnProperty.call(message, "deprecationWarning")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.deprecationWarning); + if (message.editionRemoved != null && Object.hasOwnProperty.call(message, "editionRemoved")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.editionRemoved); + return writer; + }; + + /** + * Encodes the specified FeatureSupport message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport} message FeatureSupport message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSupport.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSupport.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FieldOptions.FeatureSupport(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.editionIntroduced = reader.int32(); + break; + } + case 2: { + message.editionDeprecated = reader.int32(); + break; + } + case 3: { + message.deprecationWarning = reader.string(); + break; + } + case 4: { + message.editionRemoved = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSupport.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FeatureSupport message. + * @function verify + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FeatureSupport.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.editionIntroduced != null && message.hasOwnProperty("editionIntroduced")) + switch (message.editionIntroduced) { + default: + return "editionIntroduced: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + if (message.editionDeprecated != null && message.hasOwnProperty("editionDeprecated")) + switch (message.editionDeprecated) { + default: + return "editionDeprecated: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + if (message.deprecationWarning != null && message.hasOwnProperty("deprecationWarning")) + if (!$util.isString(message.deprecationWarning)) + return "deprecationWarning: string expected"; + if (message.editionRemoved != null && message.hasOwnProperty("editionRemoved")) + switch (message.editionRemoved) { + default: + return "editionRemoved: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + return null; + }; + + /** + * Creates a FeatureSupport message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + */ + FeatureSupport.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FieldOptions.FeatureSupport) + return object; + var message = new $root.google.protobuf.FieldOptions.FeatureSupport(); + switch (object.editionIntroduced) { + default: + if (typeof object.editionIntroduced === "number") { + message.editionIntroduced = object.editionIntroduced; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionIntroduced = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionIntroduced = 900; + break; + case "EDITION_PROTO2": + case 998: + message.editionIntroduced = 998; + break; + case "EDITION_PROTO3": + case 999: + message.editionIntroduced = 999; + break; + case "EDITION_2023": + case 1000: + message.editionIntroduced = 1000; + break; + case "EDITION_2024": + case 1001: + message.editionIntroduced = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.editionIntroduced = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.editionIntroduced = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.editionIntroduced = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.editionIntroduced = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.editionIntroduced = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.editionIntroduced = 2147483647; + break; + } + switch (object.editionDeprecated) { + default: + if (typeof object.editionDeprecated === "number") { + message.editionDeprecated = object.editionDeprecated; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionDeprecated = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionDeprecated = 900; + break; + case "EDITION_PROTO2": + case 998: + message.editionDeprecated = 998; + break; + case "EDITION_PROTO3": + case 999: + message.editionDeprecated = 999; + break; + case "EDITION_2023": + case 1000: + message.editionDeprecated = 1000; + break; + case "EDITION_2024": + case 1001: + message.editionDeprecated = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.editionDeprecated = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.editionDeprecated = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.editionDeprecated = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.editionDeprecated = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.editionDeprecated = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.editionDeprecated = 2147483647; + break; + } + if (object.deprecationWarning != null) + message.deprecationWarning = String(object.deprecationWarning); + switch (object.editionRemoved) { + default: + if (typeof object.editionRemoved === "number") { + message.editionRemoved = object.editionRemoved; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionRemoved = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionRemoved = 900; + break; case "EDITION_PROTO2": case 998: - message.edition = 998; + message.editionRemoved = 998; break; case "EDITION_PROTO3": case 999: - message.edition = 999; + message.editionRemoved = 999; break; case "EDITION_2023": case 1000: - message.edition = 1000; + message.editionRemoved = 1000; break; case "EDITION_2024": case 1001: - message.edition = 1001; + message.editionRemoved = 1001; break; case "EDITION_1_TEST_ONLY": case 1: - message.edition = 1; + message.editionRemoved = 1; break; case "EDITION_2_TEST_ONLY": case 2: - message.edition = 2; + message.editionRemoved = 2; break; case "EDITION_99997_TEST_ONLY": case 99997: - message.edition = 99997; + message.editionRemoved = 99997; break; case "EDITION_99998_TEST_ONLY": case 99998: - message.edition = 99998; + message.editionRemoved = 99998; break; case "EDITION_99999_TEST_ONLY": case 99999: - message.edition = 99999; + message.editionRemoved = 99999; break; case "EDITION_MAX": case 2147483647: - message.edition = 2147483647; + message.editionRemoved = 2147483647; break; } - if (object.value != null) - message.value = String(object.value); return message; }; /** - * Creates a plain object from an EditionDefault message. Also converts values to other types if specified. + * Creates a plain object from a FeatureSupport message. Also converts values to other types if specified. * @function toObject - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @static - * @param {google.protobuf.FieldOptions.EditionDefault} message EditionDefault + * @param {google.protobuf.FieldOptions.FeatureSupport} message FeatureSupport * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - EditionDefault.toObject = function toObject(message, options) { + FeatureSupport.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { - object.value = ""; - object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.editionIntroduced = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.editionDeprecated = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.deprecationWarning = ""; + object.editionRemoved = options.enums === String ? "EDITION_UNKNOWN" : 0; } - if (message.value != null && message.hasOwnProperty("value")) - object.value = message.value; - if (message.edition != null && message.hasOwnProperty("edition")) - object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.editionIntroduced != null && message.hasOwnProperty("editionIntroduced")) + object.editionIntroduced = options.enums === String ? $root.google.protobuf.Edition[message.editionIntroduced] === undefined ? message.editionIntroduced : $root.google.protobuf.Edition[message.editionIntroduced] : message.editionIntroduced; + if (message.editionDeprecated != null && message.hasOwnProperty("editionDeprecated")) + object.editionDeprecated = options.enums === String ? $root.google.protobuf.Edition[message.editionDeprecated] === undefined ? message.editionDeprecated : $root.google.protobuf.Edition[message.editionDeprecated] : message.editionDeprecated; + if (message.deprecationWarning != null && message.hasOwnProperty("deprecationWarning")) + object.deprecationWarning = message.deprecationWarning; + if (message.editionRemoved != null && message.hasOwnProperty("editionRemoved")) + object.editionRemoved = options.enums === String ? $root.google.protobuf.Edition[message.editionRemoved] === undefined ? message.editionRemoved : $root.google.protobuf.Edition[message.editionRemoved] : message.editionRemoved; return object; }; /** - * Converts this EditionDefault to JSON. + * Converts this FeatureSupport to JSON. * @function toJSON - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @instance * @returns {Object.} JSON object */ - EditionDefault.prototype.toJSON = function toJSON() { + FeatureSupport.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for EditionDefault + * Gets the default type url for FeatureSupport * @function getTypeUrl - * @memberof google.protobuf.FieldOptions.EditionDefault + * @memberof google.protobuf.FieldOptions.FeatureSupport * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - EditionDefault.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + FeatureSupport.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.protobuf.FieldOptions.EditionDefault"; + return typeUrlPrefix + "/google.protobuf.FieldOptions.FeatureSupport"; }; - return EditionDefault; + return FeatureSupport; })(); return FieldOptions; @@ -64747,6 +66266,7 @@ * @property {boolean|null} [deprecated] EnumValueOptions deprecated * @property {google.protobuf.IFeatureSet|null} [features] EnumValueOptions features * @property {boolean|null} [debugRedact] EnumValueOptions debugRedact + * @property {google.protobuf.FieldOptions.IFeatureSupport|null} [featureSupport] EnumValueOptions featureSupport * @property {Array.|null} [uninterpretedOption] EnumValueOptions uninterpretedOption */ @@ -64790,6 +66310,14 @@ */ EnumValueOptions.prototype.debugRedact = false; + /** + * EnumValueOptions featureSupport. + * @member {google.protobuf.FieldOptions.IFeatureSupport|null|undefined} featureSupport + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.featureSupport = null; + /** * EnumValueOptions uninterpretedOption. * @member {Array.} uninterpretedOption @@ -64828,6 +66356,8 @@ $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.debugRedact != null && Object.hasOwnProperty.call(message, "debugRedact")) writer.uint32(/* id 3, wireType 0 =*/24).bool(message.debugRedact); + if (message.featureSupport != null && Object.hasOwnProperty.call(message, "featureSupport")) + $root.google.protobuf.FieldOptions.FeatureSupport.encode(message.featureSupport, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); @@ -64879,6 +66409,10 @@ message.debugRedact = reader.bool(); break; } + case 4: { + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.decode(reader, reader.uint32()); + break; + } case 999: { if (!(message.uninterpretedOption && message.uninterpretedOption.length)) message.uninterpretedOption = []; @@ -64931,6 +66465,11 @@ if (message.debugRedact != null && message.hasOwnProperty("debugRedact")) if (typeof message.debugRedact !== "boolean") return "debugRedact: boolean expected"; + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) { + var error = $root.google.protobuf.FieldOptions.FeatureSupport.verify(message.featureSupport); + if (error) + return "featureSupport." + error; + } if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { if (!Array.isArray(message.uninterpretedOption)) return "uninterpretedOption: array expected"; @@ -64964,6 +66503,11 @@ } if (object.debugRedact != null) message.debugRedact = Boolean(object.debugRedact); + if (object.featureSupport != null) { + if (typeof object.featureSupport !== "object") + throw TypeError(".google.protobuf.EnumValueOptions.featureSupport: object expected"); + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.fromObject(object.featureSupport); + } if (object.uninterpretedOption) { if (!Array.isArray(object.uninterpretedOption)) throw TypeError(".google.protobuf.EnumValueOptions.uninterpretedOption: array expected"); @@ -64996,6 +66540,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -65003,6 +66548,8 @@ object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); if (message.debugRedact != null && message.hasOwnProperty("debugRedact")) object.debugRedact = message.debugRedact; + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) + object.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.toObject(message.featureSupport, options); if (message.uninterpretedOption && message.uninterpretedOption.length) { object.uninterpretedOption = []; for (var j = 0; j < message.uninterpretedOption.length; ++j) @@ -66470,6 +68017,8 @@ * @property {google.protobuf.FeatureSet.Utf8Validation|null} [utf8Validation] FeatureSet utf8Validation * @property {google.protobuf.FeatureSet.MessageEncoding|null} [messageEncoding] FeatureSet messageEncoding * @property {google.protobuf.FeatureSet.JsonFormat|null} [jsonFormat] FeatureSet jsonFormat + * @property {google.protobuf.FeatureSet.EnforceNamingStyle|null} [enforceNamingStyle] FeatureSet enforceNamingStyle + * @property {google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|null} [defaultSymbolVisibility] FeatureSet defaultSymbolVisibility */ /** @@ -66535,6 +68084,22 @@ */ FeatureSet.prototype.jsonFormat = 0; + /** + * FeatureSet enforceNamingStyle. + * @member {google.protobuf.FeatureSet.EnforceNamingStyle} enforceNamingStyle + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.enforceNamingStyle = 0; + + /** + * FeatureSet defaultSymbolVisibility. + * @member {google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility} defaultSymbolVisibility + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.defaultSymbolVisibility = 0; + /** * Creates a new FeatureSet instance using the specified properties. * @function create @@ -66571,6 +68136,10 @@ writer.uint32(/* id 5, wireType 0 =*/40).int32(message.messageEncoding); if (message.jsonFormat != null && Object.hasOwnProperty.call(message, "jsonFormat")) writer.uint32(/* id 6, wireType 0 =*/48).int32(message.jsonFormat); + if (message.enforceNamingStyle != null && Object.hasOwnProperty.call(message, "enforceNamingStyle")) + writer.uint32(/* id 7, wireType 0 =*/56).int32(message.enforceNamingStyle); + if (message.defaultSymbolVisibility != null && Object.hasOwnProperty.call(message, "defaultSymbolVisibility")) + writer.uint32(/* id 8, wireType 0 =*/64).int32(message.defaultSymbolVisibility); return writer; }; @@ -66631,6 +68200,14 @@ message.jsonFormat = reader.int32(); break; } + case 7: { + message.enforceNamingStyle = reader.int32(); + break; + } + case 8: { + message.defaultSymbolVisibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -66721,6 +68298,26 @@ case 2: break; } + if (message.enforceNamingStyle != null && message.hasOwnProperty("enforceNamingStyle")) + switch (message.enforceNamingStyle) { + default: + return "enforceNamingStyle: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.defaultSymbolVisibility != null && message.hasOwnProperty("defaultSymbolVisibility")) + switch (message.defaultSymbolVisibility) { + default: + return "defaultSymbolVisibility: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } return null; }; @@ -66860,6 +68457,54 @@ message.jsonFormat = 2; break; } + switch (object.enforceNamingStyle) { + default: + if (typeof object.enforceNamingStyle === "number") { + message.enforceNamingStyle = object.enforceNamingStyle; + break; + } + break; + case "ENFORCE_NAMING_STYLE_UNKNOWN": + case 0: + message.enforceNamingStyle = 0; + break; + case "STYLE2024": + case 1: + message.enforceNamingStyle = 1; + break; + case "STYLE_LEGACY": + case 2: + message.enforceNamingStyle = 2; + break; + } + switch (object.defaultSymbolVisibility) { + default: + if (typeof object.defaultSymbolVisibility === "number") { + message.defaultSymbolVisibility = object.defaultSymbolVisibility; + break; + } + break; + case "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN": + case 0: + message.defaultSymbolVisibility = 0; + break; + case "EXPORT_ALL": + case 1: + message.defaultSymbolVisibility = 1; + break; + case "EXPORT_TOP_LEVEL": + case 2: + message.defaultSymbolVisibility = 2; + break; + case "LOCAL_ALL": + case 3: + message.defaultSymbolVisibility = 3; + break; + case "STRICT": + case 4: + message.defaultSymbolVisibility = 4; + break; + } return message; }; @@ -66883,6 +68528,8 @@ object.utf8Validation = options.enums === String ? "UTF8_VALIDATION_UNKNOWN" : 0; object.messageEncoding = options.enums === String ? "MESSAGE_ENCODING_UNKNOWN" : 0; object.jsonFormat = options.enums === String ? "JSON_FORMAT_UNKNOWN" : 0; + object.enforceNamingStyle = options.enums === String ? "ENFORCE_NAMING_STYLE_UNKNOWN" : 0; + object.defaultSymbolVisibility = options.enums === String ? "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN" : 0; } if (message.fieldPresence != null && message.hasOwnProperty("fieldPresence")) object.fieldPresence = options.enums === String ? $root.google.protobuf.FeatureSet.FieldPresence[message.fieldPresence] === undefined ? message.fieldPresence : $root.google.protobuf.FeatureSet.FieldPresence[message.fieldPresence] : message.fieldPresence; @@ -66896,6 +68543,10 @@ object.messageEncoding = options.enums === String ? $root.google.protobuf.FeatureSet.MessageEncoding[message.messageEncoding] === undefined ? message.messageEncoding : $root.google.protobuf.FeatureSet.MessageEncoding[message.messageEncoding] : message.messageEncoding; if (message.jsonFormat != null && message.hasOwnProperty("jsonFormat")) object.jsonFormat = options.enums === String ? $root.google.protobuf.FeatureSet.JsonFormat[message.jsonFormat] === undefined ? message.jsonFormat : $root.google.protobuf.FeatureSet.JsonFormat[message.jsonFormat] : message.jsonFormat; + if (message.enforceNamingStyle != null && message.hasOwnProperty("enforceNamingStyle")) + object.enforceNamingStyle = options.enums === String ? $root.google.protobuf.FeatureSet.EnforceNamingStyle[message.enforceNamingStyle] === undefined ? message.enforceNamingStyle : $root.google.protobuf.FeatureSet.EnforceNamingStyle[message.enforceNamingStyle] : message.enforceNamingStyle; + if (message.defaultSymbolVisibility != null && message.hasOwnProperty("defaultSymbolVisibility")) + object.defaultSymbolVisibility = options.enums === String ? $root.google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility[message.defaultSymbolVisibility] === undefined ? message.defaultSymbolVisibility : $root.google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility[message.defaultSymbolVisibility] : message.defaultSymbolVisibility; return object; }; @@ -67023,6 +68674,219 @@ return values; })(); + /** + * EnforceNamingStyle enum. + * @name google.protobuf.FeatureSet.EnforceNamingStyle + * @enum {number} + * @property {number} ENFORCE_NAMING_STYLE_UNKNOWN=0 ENFORCE_NAMING_STYLE_UNKNOWN value + * @property {number} STYLE2024=1 STYLE2024 value + * @property {number} STYLE_LEGACY=2 STYLE_LEGACY value + */ + FeatureSet.EnforceNamingStyle = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "ENFORCE_NAMING_STYLE_UNKNOWN"] = 0; + values[valuesById[1] = "STYLE2024"] = 1; + values[valuesById[2] = "STYLE_LEGACY"] = 2; + return values; + })(); + + FeatureSet.VisibilityFeature = (function() { + + /** + * Properties of a VisibilityFeature. + * @memberof google.protobuf.FeatureSet + * @interface IVisibilityFeature + */ + + /** + * Constructs a new VisibilityFeature. + * @memberof google.protobuf.FeatureSet + * @classdesc Represents a VisibilityFeature. + * @implements IVisibilityFeature + * @constructor + * @param {google.protobuf.FeatureSet.IVisibilityFeature=} [properties] Properties to set + */ + function VisibilityFeature(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]]; + } + + /** + * Creates a new VisibilityFeature instance using the specified properties. + * @function create + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature=} [properties] Properties to set + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature instance + */ + VisibilityFeature.create = function create(properties) { + return new VisibilityFeature(properties); + }; + + /** + * Encodes the specified VisibilityFeature message. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature} message VisibilityFeature message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VisibilityFeature.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified VisibilityFeature message, length delimited. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature} message VisibilityFeature message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VisibilityFeature.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VisibilityFeature.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FeatureSet.VisibilityFeature(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VisibilityFeature.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a VisibilityFeature message. + * @function verify + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + VisibilityFeature.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a VisibilityFeature message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + */ + VisibilityFeature.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FeatureSet.VisibilityFeature) + return object; + return new $root.google.protobuf.FeatureSet.VisibilityFeature(); + }; + + /** + * Creates a plain object from a VisibilityFeature message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.VisibilityFeature} message VisibilityFeature + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + VisibilityFeature.toObject = function toObject() { + return {}; + }; + + /** + * Converts this VisibilityFeature to JSON. + * @function toJSON + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @instance + * @returns {Object.} JSON object + */ + VisibilityFeature.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for VisibilityFeature + * @function getTypeUrl + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + VisibilityFeature.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FeatureSet.VisibilityFeature"; + }; + + /** + * DefaultSymbolVisibility enum. + * @name google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility + * @enum {number} + * @property {number} DEFAULT_SYMBOL_VISIBILITY_UNKNOWN=0 DEFAULT_SYMBOL_VISIBILITY_UNKNOWN value + * @property {number} EXPORT_ALL=1 EXPORT_ALL value + * @property {number} EXPORT_TOP_LEVEL=2 EXPORT_TOP_LEVEL value + * @property {number} LOCAL_ALL=3 LOCAL_ALL value + * @property {number} STRICT=4 STRICT value + */ + VisibilityFeature.DefaultSymbolVisibility = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN"] = 0; + values[valuesById[1] = "EXPORT_ALL"] = 1; + values[valuesById[2] = "EXPORT_TOP_LEVEL"] = 2; + values[valuesById[3] = "LOCAL_ALL"] = 3; + values[valuesById[4] = "STRICT"] = 4; + return values; + })(); + + return VisibilityFeature; + })(); + return FeatureSet; })(); @@ -67207,6 +69071,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -67224,6 +69089,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -67272,6 +69138,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -67324,6 +69194,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -67432,7 +69306,8 @@ * @memberof google.protobuf.FeatureSetDefaults * @interface IFeatureSetEditionDefault * @property {google.protobuf.Edition|null} [edition] FeatureSetEditionDefault edition - * @property {google.protobuf.IFeatureSet|null} [features] FeatureSetEditionDefault features + * @property {google.protobuf.IFeatureSet|null} [overridableFeatures] FeatureSetEditionDefault overridableFeatures + * @property {google.protobuf.IFeatureSet|null} [fixedFeatures] FeatureSetEditionDefault fixedFeatures */ /** @@ -67459,12 +69334,20 @@ FeatureSetEditionDefault.prototype.edition = 0; /** - * FeatureSetEditionDefault features. - * @member {google.protobuf.IFeatureSet|null|undefined} features + * FeatureSetEditionDefault overridableFeatures. + * @member {google.protobuf.IFeatureSet|null|undefined} overridableFeatures + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @instance + */ + FeatureSetEditionDefault.prototype.overridableFeatures = null; + + /** + * FeatureSetEditionDefault fixedFeatures. + * @member {google.protobuf.IFeatureSet|null|undefined} fixedFeatures * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault * @instance */ - FeatureSetEditionDefault.prototype.features = null; + FeatureSetEditionDefault.prototype.fixedFeatures = null; /** * Creates a new FeatureSetEditionDefault instance using the specified properties. @@ -67490,10 +69373,12 @@ FeatureSetEditionDefault.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.features != null && Object.hasOwnProperty.call(message, "features")) - $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) writer.uint32(/* id 3, wireType 0 =*/24).int32(message.edition); + if (message.overridableFeatures != null && Object.hasOwnProperty.call(message, "overridableFeatures")) + $root.google.protobuf.FeatureSet.encode(message.overridableFeatures, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.fixedFeatures != null && Object.hasOwnProperty.call(message, "fixedFeatures")) + $root.google.protobuf.FeatureSet.encode(message.fixedFeatures, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); return writer; }; @@ -67534,8 +69419,12 @@ message.edition = reader.int32(); break; } - case 2: { - message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + case 4: { + message.overridableFeatures = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + break; + } + case 5: { + message.fixedFeatures = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); break; } default: @@ -67578,6 +69467,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -67590,10 +69480,15 @@ case 2147483647: break; } - if (message.features != null && message.hasOwnProperty("features")) { - var error = $root.google.protobuf.FeatureSet.verify(message.features); + if (message.overridableFeatures != null && message.hasOwnProperty("overridableFeatures")) { + var error = $root.google.protobuf.FeatureSet.verify(message.overridableFeatures); + if (error) + return "overridableFeatures." + error; + } + if (message.fixedFeatures != null && message.hasOwnProperty("fixedFeatures")) { + var error = $root.google.protobuf.FeatureSet.verify(message.fixedFeatures); if (error) - return "features." + error; + return "fixedFeatures." + error; } return null; }; @@ -67621,6 +69516,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -67662,10 +69561,15 @@ message.edition = 2147483647; break; } - if (object.features != null) { - if (typeof object.features !== "object") - throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.features: object expected"); - message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); + if (object.overridableFeatures != null) { + if (typeof object.overridableFeatures !== "object") + throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.overridableFeatures: object expected"); + message.overridableFeatures = $root.google.protobuf.FeatureSet.fromObject(object.overridableFeatures); + } + if (object.fixedFeatures != null) { + if (typeof object.fixedFeatures !== "object") + throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.fixedFeatures: object expected"); + message.fixedFeatures = $root.google.protobuf.FeatureSet.fromObject(object.fixedFeatures); } return message; }; @@ -67684,13 +69588,16 @@ options = {}; var object = {}; if (options.defaults) { - object.features = null; object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.overridableFeatures = null; + object.fixedFeatures = null; } - if (message.features != null && message.hasOwnProperty("features")) - object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); if (message.edition != null && message.hasOwnProperty("edition")) object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.overridableFeatures != null && message.hasOwnProperty("overridableFeatures")) + object.overridableFeatures = $root.google.protobuf.FeatureSet.toObject(message.overridableFeatures, options); + if (message.fixedFeatures != null && message.hasOwnProperty("fixedFeatures")) + object.fixedFeatures = $root.google.protobuf.FeatureSet.toObject(message.fixedFeatures, options); return object; }; @@ -68905,6 +70812,22 @@ return GeneratedCodeInfo; })(); + /** + * SymbolVisibility enum. + * @name google.protobuf.SymbolVisibility + * @enum {number} + * @property {number} VISIBILITY_UNSET=0 VISIBILITY_UNSET value + * @property {number} VISIBILITY_LOCAL=1 VISIBILITY_LOCAL value + * @property {number} VISIBILITY_EXPORT=2 VISIBILITY_EXPORT value + */ + protobuf.SymbolVisibility = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "VISIBILITY_UNSET"] = 0; + values[valuesById[1] = "VISIBILITY_LOCAL"] = 1; + values[valuesById[2] = "VISIBILITY_EXPORT"] = 2; + return values; + })(); + protobuf.Duration = (function() { /** diff --git a/packages/google-cloud-oracledatabase/protos/protos.json b/packages/google-cloud-oracledatabase/protos/protos.json index 875c7eab8832..e84448b60400 100644 --- a/packages/google-cloud-oracledatabase/protos/protos.json +++ b/packages/google-cloud-oracledatabase/protos/protos.json @@ -7613,8 +7613,7 @@ "java_multiple_files": true, "java_outer_classname": "LaunchStageProto", "java_package": "com.google.api", - "objc_class_prefix": "GAPI", - "cc_enable_arenas": true + "objc_class_prefix": "GAPI" }, "nested": { "fieldBehavior": { @@ -7726,6 +7725,11 @@ "format": { "type": "Format", "id": 1 + }, + "referencedTypes": { + "rule": "repeated", + "type": "TypeReference", + "id": 2 } }, "nested": { @@ -7740,6 +7744,14 @@ } } }, + "TypeReference": { + "fields": { + "typeName": { + "type": "string", + "id": 1 + } + } + }, "http": { "type": "HttpRule", "id": 72295728, @@ -7861,6 +7873,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -8001,6 +8017,28 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "experimentalFeatures": { + "type": "ExperimentalFeatures", + "id": 2 + } + }, + "nested": { + "ExperimentalFeatures": { + "fields": { + "restAsyncIoEnabled": { + "type": "bool", + "id": 1 + }, + "protobufPythonicTypesEnabled": { + "type": "bool", + "id": 2 + }, + "unversionedPackageDisabled": { + "type": "bool", + "id": 3 + } + } } } }, @@ -8058,6 +8096,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -8119,6 +8162,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -8152,12 +8208,19 @@ "type": "FileDescriptorProto", "id": 1 } - } + }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ] }, "Edition": { "edition": "proto2", "values": { "EDITION_UNKNOWN": 0, + "EDITION_LEGACY": 900, "EDITION_PROTO2": 998, "EDITION_PROTO3": 999, "EDITION_2023": 1000, @@ -8196,6 +8259,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -8284,6 +8352,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -8509,6 +8581,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -8559,7 +8635,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -8723,6 +8806,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -8858,7 +8942,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -8886,6 +8971,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -8955,6 +9044,26 @@ "id": 2 } } + }, + "FeatureSupport": { + "fields": { + "editionIntroduced": { + "type": "Edition", + "id": 1 + }, + "editionDeprecated": { + "type": "Edition", + "id": 2 + }, + "deprecationWarning": { + "type": "string", + "id": 3 + }, + "editionRemoved": { + "type": "Edition", + "id": 4 + } + } } } }, @@ -9043,6 +9152,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -9185,6 +9298,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -9195,6 +9309,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -9205,6 +9320,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -9215,6 +9331,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -9225,7 +9342,8 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", - "edition_defaults.edition": "EDITION_PROTO2", + "feature_support.edition_introduced": "EDITION_2023", + "edition_defaults.edition": "EDITION_LEGACY", "edition_defaults.value": "LENGTH_PREFIXED" } }, @@ -9235,27 +9353,38 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "ALLOW" } + }, + "enforceNamingStyle": { + "type": "EnforceNamingStyle", + "id": 7, + "options": { + "retention": "RETENTION_SOURCE", + "targets": "TARGET_TYPE_METHOD", + "feature_support.edition_introduced": "EDITION_2024", + "edition_defaults.edition": "EDITION_2024", + "edition_defaults.value": "STYLE2024" + } + }, + "defaultSymbolVisibility": { + "type": "VisibilityFeature.DefaultSymbolVisibility", + "id": 8, + "options": { + "retention": "RETENTION_SOURCE", + "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2024", + "edition_defaults.edition": "EDITION_2024", + "edition_defaults.value": "EXPORT_TOP_LEVEL" + } } }, "extensions": [ [ 1000, - 1000 - ], - [ - 1001, - 1001 - ], - [ - 1002, - 1002 - ], - [ - 9990, - 9990 + 9994 ], [ 9995, @@ -9300,7 +9429,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -9315,6 +9450,33 @@ "ALLOW": 1, "LEGACY_BEST_EFFORT": 2 } + }, + "EnforceNamingStyle": { + "values": { + "ENFORCE_NAMING_STYLE_UNKNOWN": 0, + "STYLE2024": 1, + "STYLE_LEGACY": 2 + } + }, + "VisibilityFeature": { + "fields": {}, + "reserved": [ + [ + 1, + 536870911 + ] + ], + "nested": { + "DefaultSymbolVisibility": { + "values": { + "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN": 0, + "EXPORT_ALL": 1, + "EXPORT_TOP_LEVEL": 2, + "LOCAL_ALL": 3, + "STRICT": 4 + } + } + } } } }, @@ -9342,11 +9504,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -9359,6 +9536,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -9444,6 +9627,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Duration": { "fields": { "seconds": { @@ -9623,6 +9814,7 @@ "java_multiple_files": true, "java_outer_classname": "OperationsProto", "java_package": "com.google.longrunning", + "objc_class_prefix": "GLRUN", "php_namespace": "Google\\LongRunning" }, "nested": { diff --git a/packages/google-cloud-oracledatabase/samples/generated/v1/snippet_metadata_google.cloud.oracledatabase.v1.json b/packages/google-cloud-oracledatabase/samples/generated/v1/snippet_metadata_google.cloud.oracledatabase.v1.json index 3ec0600e299b..6c8b8d9e6e51 100644 --- a/packages/google-cloud-oracledatabase/samples/generated/v1/snippet_metadata_google.cloud.oracledatabase.v1.json +++ b/packages/google-cloud-oracledatabase/samples/generated/v1/snippet_metadata_google.cloud.oracledatabase.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-oracledatabase", - "version": "0.7.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-oracledatabase/src/v1/index.ts b/packages/google-cloud-oracledatabase/src/v1/index.ts index de91ffe2986d..9d5553daa854 100644 --- a/packages/google-cloud-oracledatabase/src/v1/index.ts +++ b/packages/google-cloud-oracledatabase/src/v1/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {OracleDatabaseClient} from './oracle_database_client'; +export { OracleDatabaseClient } from './oracle_database_client'; diff --git a/packages/google-cloud-oracledatabase/src/v1/oracle_database_client.ts b/packages/google-cloud-oracledatabase/src/v1/oracle_database_client.ts index 77f9b3a09bcf..cb0a4618ffa2 100644 --- a/packages/google-cloud-oracledatabase/src/v1/oracle_database_client.ts +++ b/packages/google-cloud-oracledatabase/src/v1/oracle_database_client.ts @@ -18,11 +18,22 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -44,7 +55,7 @@ export class OracleDatabaseClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('oracledatabase'); @@ -57,11 +68,11 @@ export class OracleDatabaseClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - oracleDatabaseStub?: Promise<{[name: string]: Function}>; + oracleDatabaseStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of OracleDatabaseClient. @@ -102,21 +113,42 @@ export class OracleDatabaseClient { * const client = new OracleDatabaseClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof OracleDatabaseClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'oracledatabase.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -141,7 +173,7 @@ export class OracleDatabaseClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -155,15 +187,11 @@ export class OracleDatabaseClient { } this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -185,130 +213,199 @@ export class OracleDatabaseClient { // Create useful helper objects for these. this.pathTemplates = { autonomousDatabasePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/autonomousDatabases/{autonomous_database}' + 'projects/{project}/locations/{location}/autonomousDatabases/{autonomous_database}', ), autonomousDatabaseBackupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/autonomousDatabaseBackups/{autonomous_database_backup}' - ), - autonomousDatabaseCharacterSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/autonomousDatabaseCharacterSets/{autonomous_database_character_set}' + 'projects/{project}/locations/{location}/autonomousDatabaseBackups/{autonomous_database_backup}', ), + autonomousDatabaseCharacterSetPathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/autonomousDatabaseCharacterSets/{autonomous_database_character_set}', + ), autonomousDbVersionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/autonomousDbVersions/{autonomous_db_version}' + 'projects/{project}/locations/{location}/autonomousDbVersions/{autonomous_db_version}', ), cloudExadataInfrastructurePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/cloudExadataInfrastructures/{cloud_exadata_infrastructure}' + 'projects/{project}/locations/{location}/cloudExadataInfrastructures/{cloud_exadata_infrastructure}', ), cloudVmClusterPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/cloudVmClusters/{cloud_vm_cluster}' + 'projects/{project}/locations/{location}/cloudVmClusters/{cloud_vm_cluster}', ), databasePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/databases/{database}' + 'projects/{project}/locations/{location}/databases/{database}', ), databaseCharacterSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/databaseCharacterSets/{database_character_set}' + 'projects/{project}/locations/{location}/databaseCharacterSets/{database_character_set}', ), dbServerPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/cloudExadataInfrastructures/{cloud_exadata_infrastructure}/dbServers/{db_server}' + 'projects/{project}/locations/{location}/cloudExadataInfrastructures/{cloud_exadata_infrastructure}/dbServers/{db_server}', ), dbSystemPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dbSystems/{db_system}' + 'projects/{project}/locations/{location}/dbSystems/{db_system}', ), dbSystemInitialStorageSizePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dbSystemInitialStorageSizes/{db_system_initial_storage_size}' + 'projects/{project}/locations/{location}/dbSystemInitialStorageSizes/{db_system_initial_storage_size}', ), dbSystemShapePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dbSystemShapes/{db_system_shape}' + 'projects/{project}/locations/{location}/dbSystemShapes/{db_system_shape}', ), dbVersionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dbVersions/{db_version}' + 'projects/{project}/locations/{location}/dbVersions/{db_version}', ), entitlementPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/entitlements/{entitlement}' + 'projects/{project}/locations/{location}/entitlements/{entitlement}', ), exadbVmClusterPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/exadbVmClusters/{exadb_vm_cluster}' + 'projects/{project}/locations/{location}/exadbVmClusters/{exadb_vm_cluster}', ), exascaleDbStorageVaultPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/exascaleDbStorageVaults/{exascale_db_storage_vault}' + 'projects/{project}/locations/{location}/exascaleDbStorageVaults/{exascale_db_storage_vault}', ), giVersionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/giVersions/{gi_version}' + 'projects/{project}/locations/{location}/giVersions/{gi_version}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), minorVersionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/giVersions/{gi_version}/minorVersions/{minor_version}' + 'projects/{project}/locations/{location}/giVersions/{gi_version}/minorVersions/{minor_version}', ), odbNetworkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/odbNetworks/{odb_network}' + 'projects/{project}/locations/{location}/odbNetworks/{odb_network}', ), odbSubnetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/odbNetworks/{odb_network}/odbSubnets/{odb_subnet}' + 'projects/{project}/locations/{location}/odbNetworks/{odb_network}/odbSubnets/{odb_subnet}', ), pluggableDatabasePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/pluggableDatabases/{pluggable_database}' + 'projects/{project}/locations/{location}/pluggableDatabases/{pluggable_database}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - projectLocationCloudVmClusterDbNodesPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/cloudVmClusters/{cloud_vm_cluster}/dbNodes/{db_node}' - ), - projectLocationExadbVmClusterDbNodesPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/exadbVmClusters/{exadb_vm_cluster}/dbNodes/{db_node}' + 'projects/{project}', ), + projectLocationCloudVmClusterDbNodesPathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/cloudVmClusters/{cloud_vm_cluster}/dbNodes/{db_node}', + ), + projectLocationExadbVmClusterDbNodesPathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/exadbVmClusters/{exadb_vm_cluster}/dbNodes/{db_node}', + ), }; // Some of the methods on this service return "paged" results, // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listCloudExadataInfrastructures: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'cloudExadataInfrastructures'), - listCloudVmClusters: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'cloudVmClusters'), - listEntitlements: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'entitlements'), - listDbServers: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'dbServers'), - listDbNodes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'dbNodes'), - listGiVersions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'giVersions'), - listMinorVersions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'minorVersions'), - listDbSystemShapes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'dbSystemShapes'), - listAutonomousDatabases: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'autonomousDatabases'), - listAutonomousDbVersions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'autonomousDbVersions'), - listAutonomousDatabaseCharacterSets: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'autonomousDatabaseCharacterSets'), - listAutonomousDatabaseBackups: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'autonomousDatabaseBackups'), - listOdbNetworks: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'odbNetworks'), - listOdbSubnets: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'odbSubnets'), - listExadbVmClusters: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'exadbVmClusters'), - listExascaleDbStorageVaults: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'exascaleDbStorageVaults'), - listDbSystemInitialStorageSizes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'dbSystemInitialStorageSizes'), - listDatabases: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'databases'), - listPluggableDatabases: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'pluggableDatabases'), - listDbSystems: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'dbSystems'), - listDbVersions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'dbVersions'), - listDatabaseCharacterSets: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'databaseCharacterSets') + listCloudExadataInfrastructures: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'cloudExadataInfrastructures', + ), + listCloudVmClusters: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'cloudVmClusters', + ), + listEntitlements: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'entitlements', + ), + listDbServers: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'dbServers', + ), + listDbNodes: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'dbNodes', + ), + listGiVersions: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'giVersions', + ), + listMinorVersions: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'minorVersions', + ), + listDbSystemShapes: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'dbSystemShapes', + ), + listAutonomousDatabases: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'autonomousDatabases', + ), + listAutonomousDbVersions: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'autonomousDbVersions', + ), + listAutonomousDatabaseCharacterSets: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'autonomousDatabaseCharacterSets', + ), + listAutonomousDatabaseBackups: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'autonomousDatabaseBackups', + ), + listOdbNetworks: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'odbNetworks', + ), + listOdbSubnets: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'odbSubnets', + ), + listExadbVmClusters: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'exadbVmClusters', + ), + listExascaleDbStorageVaults: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'exascaleDbStorageVaults', + ), + listDbSystemInitialStorageSizes: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'dbSystemInitialStorageSizes', + ), + listDatabases: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'databases', + ), + listPluggableDatabases: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'pluggableDatabases', + ), + listDbSystems: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'dbSystems', + ), + listDbVersions: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'dbVersions', + ), + listDatabaseCharacterSets: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'databaseCharacterSets', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -317,221 +414,386 @@ export class OracleDatabaseClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1/{name=projects/*}/locations', + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createCloudExadataInfrastructureResponse = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.CloudExadataInfrastructure') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.CloudExadataInfrastructure', + ) as gax.protobuf.Type; const createCloudExadataInfrastructureMetadata = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteCloudExadataInfrastructureResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteCloudExadataInfrastructureMetadata = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.OperationMetadata', + ) as gax.protobuf.Type; const createCloudVmClusterResponse = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.CloudVmCluster') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.CloudVmCluster', + ) as gax.protobuf.Type; const createCloudVmClusterMetadata = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteCloudVmClusterResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteCloudVmClusterMetadata = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.OperationMetadata', + ) as gax.protobuf.Type; const createAutonomousDatabaseResponse = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.AutonomousDatabase') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.AutonomousDatabase', + ) as gax.protobuf.Type; const createAutonomousDatabaseMetadata = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateAutonomousDatabaseResponse = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.AutonomousDatabase') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.AutonomousDatabase', + ) as gax.protobuf.Type; const updateAutonomousDatabaseMetadata = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteAutonomousDatabaseResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteAutonomousDatabaseMetadata = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.OperationMetadata', + ) as gax.protobuf.Type; const restoreAutonomousDatabaseResponse = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.AutonomousDatabase') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.AutonomousDatabase', + ) as gax.protobuf.Type; const restoreAutonomousDatabaseMetadata = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.OperationMetadata', + ) as gax.protobuf.Type; const stopAutonomousDatabaseResponse = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.AutonomousDatabase') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.AutonomousDatabase', + ) as gax.protobuf.Type; const stopAutonomousDatabaseMetadata = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.OperationMetadata', + ) as gax.protobuf.Type; const startAutonomousDatabaseResponse = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.AutonomousDatabase') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.AutonomousDatabase', + ) as gax.protobuf.Type; const startAutonomousDatabaseMetadata = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.OperationMetadata', + ) as gax.protobuf.Type; const restartAutonomousDatabaseResponse = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.AutonomousDatabase') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.AutonomousDatabase', + ) as gax.protobuf.Type; const restartAutonomousDatabaseMetadata = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.OperationMetadata', + ) as gax.protobuf.Type; const switchoverAutonomousDatabaseResponse = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.AutonomousDatabase') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.AutonomousDatabase', + ) as gax.protobuf.Type; const switchoverAutonomousDatabaseMetadata = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.OperationMetadata', + ) as gax.protobuf.Type; const failoverAutonomousDatabaseResponse = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.AutonomousDatabase') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.AutonomousDatabase', + ) as gax.protobuf.Type; const failoverAutonomousDatabaseMetadata = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.OperationMetadata', + ) as gax.protobuf.Type; const createOdbNetworkResponse = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.OdbNetwork') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.OdbNetwork', + ) as gax.protobuf.Type; const createOdbNetworkMetadata = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteOdbNetworkResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteOdbNetworkMetadata = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.OperationMetadata', + ) as gax.protobuf.Type; const createOdbSubnetResponse = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.OdbSubnet') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.OdbSubnet', + ) as gax.protobuf.Type; const createOdbSubnetMetadata = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteOdbSubnetResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteOdbSubnetMetadata = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.OperationMetadata', + ) as gax.protobuf.Type; const createExadbVmClusterResponse = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.ExadbVmCluster') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.ExadbVmCluster', + ) as gax.protobuf.Type; const createExadbVmClusterMetadata = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteExadbVmClusterResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteExadbVmClusterMetadata = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateExadbVmClusterResponse = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.ExadbVmCluster') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.ExadbVmCluster', + ) as gax.protobuf.Type; const updateExadbVmClusterMetadata = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.OperationMetadata', + ) as gax.protobuf.Type; const removeVirtualMachineExadbVmClusterResponse = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.ExadbVmCluster') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.ExadbVmCluster', + ) as gax.protobuf.Type; const removeVirtualMachineExadbVmClusterMetadata = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.OperationMetadata', + ) as gax.protobuf.Type; const createExascaleDbStorageVaultResponse = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.ExascaleDbStorageVault') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.ExascaleDbStorageVault', + ) as gax.protobuf.Type; const createExascaleDbStorageVaultMetadata = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteExascaleDbStorageVaultResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteExascaleDbStorageVaultMetadata = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.OperationMetadata', + ) as gax.protobuf.Type; const createDbSystemResponse = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.DbSystem') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.DbSystem', + ) as gax.protobuf.Type; const createDbSystemMetadata = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteDbSystemResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteDbSystemMetadata = protoFilesRoot.lookup( - '.google.cloud.oracledatabase.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.oracledatabase.v1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { - createCloudExadataInfrastructure: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createCloudExadataInfrastructureResponse.decode.bind(createCloudExadataInfrastructureResponse), - createCloudExadataInfrastructureMetadata.decode.bind(createCloudExadataInfrastructureMetadata)), - deleteCloudExadataInfrastructure: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteCloudExadataInfrastructureResponse.decode.bind(deleteCloudExadataInfrastructureResponse), - deleteCloudExadataInfrastructureMetadata.decode.bind(deleteCloudExadataInfrastructureMetadata)), + createCloudExadataInfrastructure: + new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createCloudExadataInfrastructureResponse.decode.bind( + createCloudExadataInfrastructureResponse, + ), + createCloudExadataInfrastructureMetadata.decode.bind( + createCloudExadataInfrastructureMetadata, + ), + ), + deleteCloudExadataInfrastructure: + new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteCloudExadataInfrastructureResponse.decode.bind( + deleteCloudExadataInfrastructureResponse, + ), + deleteCloudExadataInfrastructureMetadata.decode.bind( + deleteCloudExadataInfrastructureMetadata, + ), + ), createCloudVmCluster: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createCloudVmClusterResponse.decode.bind(createCloudVmClusterResponse), - createCloudVmClusterMetadata.decode.bind(createCloudVmClusterMetadata)), + createCloudVmClusterMetadata.decode.bind(createCloudVmClusterMetadata), + ), deleteCloudVmCluster: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteCloudVmClusterResponse.decode.bind(deleteCloudVmClusterResponse), - deleteCloudVmClusterMetadata.decode.bind(deleteCloudVmClusterMetadata)), + deleteCloudVmClusterMetadata.decode.bind(deleteCloudVmClusterMetadata), + ), createAutonomousDatabase: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - createAutonomousDatabaseResponse.decode.bind(createAutonomousDatabaseResponse), - createAutonomousDatabaseMetadata.decode.bind(createAutonomousDatabaseMetadata)), + createAutonomousDatabaseResponse.decode.bind( + createAutonomousDatabaseResponse, + ), + createAutonomousDatabaseMetadata.decode.bind( + createAutonomousDatabaseMetadata, + ), + ), updateAutonomousDatabase: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - updateAutonomousDatabaseResponse.decode.bind(updateAutonomousDatabaseResponse), - updateAutonomousDatabaseMetadata.decode.bind(updateAutonomousDatabaseMetadata)), + updateAutonomousDatabaseResponse.decode.bind( + updateAutonomousDatabaseResponse, + ), + updateAutonomousDatabaseMetadata.decode.bind( + updateAutonomousDatabaseMetadata, + ), + ), deleteAutonomousDatabase: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - deleteAutonomousDatabaseResponse.decode.bind(deleteAutonomousDatabaseResponse), - deleteAutonomousDatabaseMetadata.decode.bind(deleteAutonomousDatabaseMetadata)), + deleteAutonomousDatabaseResponse.decode.bind( + deleteAutonomousDatabaseResponse, + ), + deleteAutonomousDatabaseMetadata.decode.bind( + deleteAutonomousDatabaseMetadata, + ), + ), restoreAutonomousDatabase: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - restoreAutonomousDatabaseResponse.decode.bind(restoreAutonomousDatabaseResponse), - restoreAutonomousDatabaseMetadata.decode.bind(restoreAutonomousDatabaseMetadata)), + restoreAutonomousDatabaseResponse.decode.bind( + restoreAutonomousDatabaseResponse, + ), + restoreAutonomousDatabaseMetadata.decode.bind( + restoreAutonomousDatabaseMetadata, + ), + ), stopAutonomousDatabase: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - stopAutonomousDatabaseResponse.decode.bind(stopAutonomousDatabaseResponse), - stopAutonomousDatabaseMetadata.decode.bind(stopAutonomousDatabaseMetadata)), + stopAutonomousDatabaseResponse.decode.bind( + stopAutonomousDatabaseResponse, + ), + stopAutonomousDatabaseMetadata.decode.bind( + stopAutonomousDatabaseMetadata, + ), + ), startAutonomousDatabase: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - startAutonomousDatabaseResponse.decode.bind(startAutonomousDatabaseResponse), - startAutonomousDatabaseMetadata.decode.bind(startAutonomousDatabaseMetadata)), + startAutonomousDatabaseResponse.decode.bind( + startAutonomousDatabaseResponse, + ), + startAutonomousDatabaseMetadata.decode.bind( + startAutonomousDatabaseMetadata, + ), + ), restartAutonomousDatabase: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - restartAutonomousDatabaseResponse.decode.bind(restartAutonomousDatabaseResponse), - restartAutonomousDatabaseMetadata.decode.bind(restartAutonomousDatabaseMetadata)), + restartAutonomousDatabaseResponse.decode.bind( + restartAutonomousDatabaseResponse, + ), + restartAutonomousDatabaseMetadata.decode.bind( + restartAutonomousDatabaseMetadata, + ), + ), switchoverAutonomousDatabase: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - switchoverAutonomousDatabaseResponse.decode.bind(switchoverAutonomousDatabaseResponse), - switchoverAutonomousDatabaseMetadata.decode.bind(switchoverAutonomousDatabaseMetadata)), + switchoverAutonomousDatabaseResponse.decode.bind( + switchoverAutonomousDatabaseResponse, + ), + switchoverAutonomousDatabaseMetadata.decode.bind( + switchoverAutonomousDatabaseMetadata, + ), + ), failoverAutonomousDatabase: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - failoverAutonomousDatabaseResponse.decode.bind(failoverAutonomousDatabaseResponse), - failoverAutonomousDatabaseMetadata.decode.bind(failoverAutonomousDatabaseMetadata)), + failoverAutonomousDatabaseResponse.decode.bind( + failoverAutonomousDatabaseResponse, + ), + failoverAutonomousDatabaseMetadata.decode.bind( + failoverAutonomousDatabaseMetadata, + ), + ), createOdbNetwork: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createOdbNetworkResponse.decode.bind(createOdbNetworkResponse), - createOdbNetworkMetadata.decode.bind(createOdbNetworkMetadata)), + createOdbNetworkMetadata.decode.bind(createOdbNetworkMetadata), + ), deleteOdbNetwork: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteOdbNetworkResponse.decode.bind(deleteOdbNetworkResponse), - deleteOdbNetworkMetadata.decode.bind(deleteOdbNetworkMetadata)), + deleteOdbNetworkMetadata.decode.bind(deleteOdbNetworkMetadata), + ), createOdbSubnet: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createOdbSubnetResponse.decode.bind(createOdbSubnetResponse), - createOdbSubnetMetadata.decode.bind(createOdbSubnetMetadata)), + createOdbSubnetMetadata.decode.bind(createOdbSubnetMetadata), + ), deleteOdbSubnet: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteOdbSubnetResponse.decode.bind(deleteOdbSubnetResponse), - deleteOdbSubnetMetadata.decode.bind(deleteOdbSubnetMetadata)), + deleteOdbSubnetMetadata.decode.bind(deleteOdbSubnetMetadata), + ), createExadbVmCluster: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createExadbVmClusterResponse.decode.bind(createExadbVmClusterResponse), - createExadbVmClusterMetadata.decode.bind(createExadbVmClusterMetadata)), + createExadbVmClusterMetadata.decode.bind(createExadbVmClusterMetadata), + ), deleteExadbVmCluster: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteExadbVmClusterResponse.decode.bind(deleteExadbVmClusterResponse), - deleteExadbVmClusterMetadata.decode.bind(deleteExadbVmClusterMetadata)), + deleteExadbVmClusterMetadata.decode.bind(deleteExadbVmClusterMetadata), + ), updateExadbVmCluster: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateExadbVmClusterResponse.decode.bind(updateExadbVmClusterResponse), - updateExadbVmClusterMetadata.decode.bind(updateExadbVmClusterMetadata)), - removeVirtualMachineExadbVmCluster: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - removeVirtualMachineExadbVmClusterResponse.decode.bind(removeVirtualMachineExadbVmClusterResponse), - removeVirtualMachineExadbVmClusterMetadata.decode.bind(removeVirtualMachineExadbVmClusterMetadata)), + updateExadbVmClusterMetadata.decode.bind(updateExadbVmClusterMetadata), + ), + removeVirtualMachineExadbVmCluster: + new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + removeVirtualMachineExadbVmClusterResponse.decode.bind( + removeVirtualMachineExadbVmClusterResponse, + ), + removeVirtualMachineExadbVmClusterMetadata.decode.bind( + removeVirtualMachineExadbVmClusterMetadata, + ), + ), createExascaleDbStorageVault: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - createExascaleDbStorageVaultResponse.decode.bind(createExascaleDbStorageVaultResponse), - createExascaleDbStorageVaultMetadata.decode.bind(createExascaleDbStorageVaultMetadata)), + createExascaleDbStorageVaultResponse.decode.bind( + createExascaleDbStorageVaultResponse, + ), + createExascaleDbStorageVaultMetadata.decode.bind( + createExascaleDbStorageVaultMetadata, + ), + ), deleteExascaleDbStorageVault: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - deleteExascaleDbStorageVaultResponse.decode.bind(deleteExascaleDbStorageVaultResponse), - deleteExascaleDbStorageVaultMetadata.decode.bind(deleteExascaleDbStorageVaultMetadata)), + deleteExascaleDbStorageVaultResponse.decode.bind( + deleteExascaleDbStorageVaultResponse, + ), + deleteExascaleDbStorageVaultMetadata.decode.bind( + deleteExascaleDbStorageVaultMetadata, + ), + ), createDbSystem: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createDbSystemResponse.decode.bind(createDbSystemResponse), - createDbSystemMetadata.decode.bind(createDbSystemMetadata)), + createDbSystemMetadata.decode.bind(createDbSystemMetadata), + ), deleteDbSystem: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteDbSystemResponse.decode.bind(deleteDbSystemResponse), - deleteDbSystemMetadata.decode.bind(deleteDbSystemMetadata)) + deleteDbSystemMetadata.decode.bind(deleteDbSystemMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.oracledatabase.v1.OracleDatabase', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.oracledatabase.v1.OracleDatabase', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -562,28 +824,92 @@ export class OracleDatabaseClient { // Put together the "service stub" for // google.cloud.oracledatabase.v1.OracleDatabase. this.oracleDatabaseStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.oracledatabase.v1.OracleDatabase') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.oracledatabase.v1.OracleDatabase', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.oracledatabase.v1.OracleDatabase, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const oracleDatabaseStubMethods = - ['listCloudExadataInfrastructures', 'getCloudExadataInfrastructure', 'createCloudExadataInfrastructure', 'deleteCloudExadataInfrastructure', 'listCloudVmClusters', 'getCloudVmCluster', 'createCloudVmCluster', 'deleteCloudVmCluster', 'listEntitlements', 'listDbServers', 'listDbNodes', 'listGiVersions', 'listMinorVersions', 'listDbSystemShapes', 'listAutonomousDatabases', 'getAutonomousDatabase', 'createAutonomousDatabase', 'updateAutonomousDatabase', 'deleteAutonomousDatabase', 'restoreAutonomousDatabase', 'generateAutonomousDatabaseWallet', 'listAutonomousDbVersions', 'listAutonomousDatabaseCharacterSets', 'listAutonomousDatabaseBackups', 'stopAutonomousDatabase', 'startAutonomousDatabase', 'restartAutonomousDatabase', 'switchoverAutonomousDatabase', 'failoverAutonomousDatabase', 'listOdbNetworks', 'getOdbNetwork', 'createOdbNetwork', 'deleteOdbNetwork', 'listOdbSubnets', 'getOdbSubnet', 'createOdbSubnet', 'deleteOdbSubnet', 'listExadbVmClusters', 'getExadbVmCluster', 'createExadbVmCluster', 'deleteExadbVmCluster', 'updateExadbVmCluster', 'removeVirtualMachineExadbVmCluster', 'listExascaleDbStorageVaults', 'getExascaleDbStorageVault', 'createExascaleDbStorageVault', 'deleteExascaleDbStorageVault', 'listDbSystemInitialStorageSizes', 'listDatabases', 'getDatabase', 'listPluggableDatabases', 'getPluggableDatabase', 'listDbSystems', 'getDbSystem', 'createDbSystem', 'deleteDbSystem', 'listDbVersions', 'listDatabaseCharacterSets']; + const oracleDatabaseStubMethods = [ + 'listCloudExadataInfrastructures', + 'getCloudExadataInfrastructure', + 'createCloudExadataInfrastructure', + 'deleteCloudExadataInfrastructure', + 'listCloudVmClusters', + 'getCloudVmCluster', + 'createCloudVmCluster', + 'deleteCloudVmCluster', + 'listEntitlements', + 'listDbServers', + 'listDbNodes', + 'listGiVersions', + 'listMinorVersions', + 'listDbSystemShapes', + 'listAutonomousDatabases', + 'getAutonomousDatabase', + 'createAutonomousDatabase', + 'updateAutonomousDatabase', + 'deleteAutonomousDatabase', + 'restoreAutonomousDatabase', + 'generateAutonomousDatabaseWallet', + 'listAutonomousDbVersions', + 'listAutonomousDatabaseCharacterSets', + 'listAutonomousDatabaseBackups', + 'stopAutonomousDatabase', + 'startAutonomousDatabase', + 'restartAutonomousDatabase', + 'switchoverAutonomousDatabase', + 'failoverAutonomousDatabase', + 'listOdbNetworks', + 'getOdbNetwork', + 'createOdbNetwork', + 'deleteOdbNetwork', + 'listOdbSubnets', + 'getOdbSubnet', + 'createOdbSubnet', + 'deleteOdbSubnet', + 'listExadbVmClusters', + 'getExadbVmCluster', + 'createExadbVmCluster', + 'deleteExadbVmCluster', + 'updateExadbVmCluster', + 'removeVirtualMachineExadbVmCluster', + 'listExascaleDbStorageVaults', + 'getExascaleDbStorageVault', + 'createExascaleDbStorageVault', + 'deleteExascaleDbStorageVault', + 'listDbSystemInitialStorageSizes', + 'listDatabases', + 'getDatabase', + 'listPluggableDatabases', + 'getPluggableDatabase', + 'listDbSystems', + 'getDbSystem', + 'createDbSystem', + 'deleteDbSystem', + 'listDbVersions', + 'listDatabaseCharacterSets', + ]; for (const methodName of oracleDatabaseStubMethods) { const callPromise = this.oracleDatabaseStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -593,7 +919,7 @@ export class OracleDatabaseClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -608,8 +934,14 @@ export class OracleDatabaseClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'oracledatabase.googleapis.com'; } @@ -620,8 +952,14 @@ export class OracleDatabaseClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'oracledatabase.googleapis.com'; } @@ -652,9 +990,7 @@ export class OracleDatabaseClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -663,8 +999,9 @@ export class OracleDatabaseClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -675,4122 +1012,6248 @@ export class OracleDatabaseClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets details of a single Exadata Infrastructure. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the Cloud Exadata Infrastructure in the following - * format: - * projects/{project}/locations/{location}/cloudExadataInfrastructures/{cloud_exadata_infrastructure}. - * @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 {@link protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure|CloudExadataInfrastructure}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.get_cloud_exadata_infrastructure.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_GetCloudExadataInfrastructure_async - */ + /** + * Gets details of a single Exadata Infrastructure. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the Cloud Exadata Infrastructure in the following + * format: + * projects/{project}/locations/{location}/cloudExadataInfrastructures/{cloud_exadata_infrastructure}. + * @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 {@link protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure|CloudExadataInfrastructure}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.get_cloud_exadata_infrastructure.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_GetCloudExadataInfrastructure_async + */ getCloudExadataInfrastructure( - request?: protos.google.cloud.oracledatabase.v1.IGetCloudExadataInfrastructureRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure, - protos.google.cloud.oracledatabase.v1.IGetCloudExadataInfrastructureRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.IGetCloudExadataInfrastructureRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure, + ( + | protos.google.cloud.oracledatabase.v1.IGetCloudExadataInfrastructureRequest + | undefined + ), + {} | undefined, + ] + >; getCloudExadataInfrastructure( - request: protos.google.cloud.oracledatabase.v1.IGetCloudExadataInfrastructureRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure, - protos.google.cloud.oracledatabase.v1.IGetCloudExadataInfrastructureRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IGetCloudExadataInfrastructureRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure, + | protos.google.cloud.oracledatabase.v1.IGetCloudExadataInfrastructureRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getCloudExadataInfrastructure( - request: protos.google.cloud.oracledatabase.v1.IGetCloudExadataInfrastructureRequest, - callback: Callback< - protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure, - protos.google.cloud.oracledatabase.v1.IGetCloudExadataInfrastructureRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IGetCloudExadataInfrastructureRequest, + callback: Callback< + protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure, + | protos.google.cloud.oracledatabase.v1.IGetCloudExadataInfrastructureRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getCloudExadataInfrastructure( - request?: protos.google.cloud.oracledatabase.v1.IGetCloudExadataInfrastructureRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure, - protos.google.cloud.oracledatabase.v1.IGetCloudExadataInfrastructureRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.oracledatabase.v1.IGetCloudExadataInfrastructureRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure, - protos.google.cloud.oracledatabase.v1.IGetCloudExadataInfrastructureRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure, - protos.google.cloud.oracledatabase.v1.IGetCloudExadataInfrastructureRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.oracledatabase.v1.IGetCloudExadataInfrastructureRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure, + | protos.google.cloud.oracledatabase.v1.IGetCloudExadataInfrastructureRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure, + ( + | protos.google.cloud.oracledatabase.v1.IGetCloudExadataInfrastructureRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getCloudExadataInfrastructure request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure, - protos.google.cloud.oracledatabase.v1.IGetCloudExadataInfrastructureRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure, + | protos.google.cloud.oracledatabase.v1.IGetCloudExadataInfrastructureRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getCloudExadataInfrastructure response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getCloudExadataInfrastructure(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure, - protos.google.cloud.oracledatabase.v1.IGetCloudExadataInfrastructureRequest|undefined, - {}|undefined - ]) => { - this._log.info('getCloudExadataInfrastructure response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getCloudExadataInfrastructure(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure, + ( + | protos.google.cloud.oracledatabase.v1.IGetCloudExadataInfrastructureRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getCloudExadataInfrastructure response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single VM Cluster. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the Cloud VM Cluster in the following format: - * projects/{project}/locations/{location}/cloudVmClusters/{cloud_vm_cluster}. - * @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 {@link protos.google.cloud.oracledatabase.v1.CloudVmCluster|CloudVmCluster}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.get_cloud_vm_cluster.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_GetCloudVmCluster_async - */ + /** + * Gets details of a single VM Cluster. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the Cloud VM Cluster in the following format: + * projects/{project}/locations/{location}/cloudVmClusters/{cloud_vm_cluster}. + * @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 {@link protos.google.cloud.oracledatabase.v1.CloudVmCluster|CloudVmCluster}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.get_cloud_vm_cluster.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_GetCloudVmCluster_async + */ getCloudVmCluster( - request?: protos.google.cloud.oracledatabase.v1.IGetCloudVmClusterRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.ICloudVmCluster, - protos.google.cloud.oracledatabase.v1.IGetCloudVmClusterRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.IGetCloudVmClusterRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.ICloudVmCluster, + ( + | protos.google.cloud.oracledatabase.v1.IGetCloudVmClusterRequest + | undefined + ), + {} | undefined, + ] + >; getCloudVmCluster( - request: protos.google.cloud.oracledatabase.v1.IGetCloudVmClusterRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.oracledatabase.v1.ICloudVmCluster, - protos.google.cloud.oracledatabase.v1.IGetCloudVmClusterRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IGetCloudVmClusterRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.oracledatabase.v1.ICloudVmCluster, + | protos.google.cloud.oracledatabase.v1.IGetCloudVmClusterRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getCloudVmCluster( - request: protos.google.cloud.oracledatabase.v1.IGetCloudVmClusterRequest, - callback: Callback< - protos.google.cloud.oracledatabase.v1.ICloudVmCluster, - protos.google.cloud.oracledatabase.v1.IGetCloudVmClusterRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IGetCloudVmClusterRequest, + callback: Callback< + protos.google.cloud.oracledatabase.v1.ICloudVmCluster, + | protos.google.cloud.oracledatabase.v1.IGetCloudVmClusterRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getCloudVmCluster( - request?: protos.google.cloud.oracledatabase.v1.IGetCloudVmClusterRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.oracledatabase.v1.ICloudVmCluster, - protos.google.cloud.oracledatabase.v1.IGetCloudVmClusterRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.oracledatabase.v1.IGetCloudVmClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.oracledatabase.v1.ICloudVmCluster, - protos.google.cloud.oracledatabase.v1.IGetCloudVmClusterRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.oracledatabase.v1.ICloudVmCluster, - protos.google.cloud.oracledatabase.v1.IGetCloudVmClusterRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.oracledatabase.v1.IGetCloudVmClusterRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.oracledatabase.v1.ICloudVmCluster, + | protos.google.cloud.oracledatabase.v1.IGetCloudVmClusterRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.ICloudVmCluster, + ( + | protos.google.cloud.oracledatabase.v1.IGetCloudVmClusterRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getCloudVmCluster request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.oracledatabase.v1.ICloudVmCluster, - protos.google.cloud.oracledatabase.v1.IGetCloudVmClusterRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.oracledatabase.v1.ICloudVmCluster, + | protos.google.cloud.oracledatabase.v1.IGetCloudVmClusterRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getCloudVmCluster response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getCloudVmCluster(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.oracledatabase.v1.ICloudVmCluster, - protos.google.cloud.oracledatabase.v1.IGetCloudVmClusterRequest|undefined, - {}|undefined - ]) => { - this._log.info('getCloudVmCluster response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getCloudVmCluster(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.oracledatabase.v1.ICloudVmCluster, + ( + | protos.google.cloud.oracledatabase.v1.IGetCloudVmClusterRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getCloudVmCluster response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets the details of a single Autonomous Database. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the Autonomous Database in the following format: - * projects/{project}/locations/{location}/autonomousDatabases/{autonomous_database}. - * @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 {@link protos.google.cloud.oracledatabase.v1.AutonomousDatabase|AutonomousDatabase}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.get_autonomous_database.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_GetAutonomousDatabase_async - */ + /** + * Gets the details of a single Autonomous Database. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the Autonomous Database in the following format: + * projects/{project}/locations/{location}/autonomousDatabases/{autonomous_database}. + * @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 {@link protos.google.cloud.oracledatabase.v1.AutonomousDatabase|AutonomousDatabase}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.get_autonomous_database.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_GetAutonomousDatabase_async + */ getAutonomousDatabase( - request?: protos.google.cloud.oracledatabase.v1.IGetAutonomousDatabaseRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, - protos.google.cloud.oracledatabase.v1.IGetAutonomousDatabaseRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.IGetAutonomousDatabaseRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + ( + | protos.google.cloud.oracledatabase.v1.IGetAutonomousDatabaseRequest + | undefined + ), + {} | undefined, + ] + >; getAutonomousDatabase( - request: protos.google.cloud.oracledatabase.v1.IGetAutonomousDatabaseRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, - protos.google.cloud.oracledatabase.v1.IGetAutonomousDatabaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IGetAutonomousDatabaseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + | protos.google.cloud.oracledatabase.v1.IGetAutonomousDatabaseRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAutonomousDatabase( - request: protos.google.cloud.oracledatabase.v1.IGetAutonomousDatabaseRequest, - callback: Callback< - protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, - protos.google.cloud.oracledatabase.v1.IGetAutonomousDatabaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IGetAutonomousDatabaseRequest, + callback: Callback< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + | protos.google.cloud.oracledatabase.v1.IGetAutonomousDatabaseRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAutonomousDatabase( - request?: protos.google.cloud.oracledatabase.v1.IGetAutonomousDatabaseRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, - protos.google.cloud.oracledatabase.v1.IGetAutonomousDatabaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.oracledatabase.v1.IGetAutonomousDatabaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, - protos.google.cloud.oracledatabase.v1.IGetAutonomousDatabaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, - protos.google.cloud.oracledatabase.v1.IGetAutonomousDatabaseRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.oracledatabase.v1.IGetAutonomousDatabaseRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + | protos.google.cloud.oracledatabase.v1.IGetAutonomousDatabaseRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + ( + | protos.google.cloud.oracledatabase.v1.IGetAutonomousDatabaseRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getAutonomousDatabase request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, - protos.google.cloud.oracledatabase.v1.IGetAutonomousDatabaseRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + | protos.google.cloud.oracledatabase.v1.IGetAutonomousDatabaseRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getAutonomousDatabase response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getAutonomousDatabase(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, - protos.google.cloud.oracledatabase.v1.IGetAutonomousDatabaseRequest|undefined, - {}|undefined - ]) => { - this._log.info('getAutonomousDatabase response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getAutonomousDatabase(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + ( + | protos.google.cloud.oracledatabase.v1.IGetAutonomousDatabaseRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getAutonomousDatabase response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Generates a wallet for an Autonomous Database. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the Autonomous Database in the following format: - * projects/{project}/locations/{location}/autonomousDatabases/{autonomous_database}. - * @param {google.cloud.oracledatabase.v1.GenerateType} [request.type] - * Optional. The type of wallet generation for the Autonomous Database. The - * default value is SINGLE. - * @param {boolean} [request.isRegional] - * Optional. True when requesting regional connection strings in PDB connect - * info, applicable to cross-region Data Guard only. - * @param {string} request.password - * Required. The password used to encrypt the keys inside the wallet. The - * password must be a minimum of 8 characters. - * @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 {@link protos.google.cloud.oracledatabase.v1.GenerateAutonomousDatabaseWalletResponse|GenerateAutonomousDatabaseWalletResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.generate_autonomous_database_wallet.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_GenerateAutonomousDatabaseWallet_async - */ + /** + * Generates a wallet for an Autonomous Database. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the Autonomous Database in the following format: + * projects/{project}/locations/{location}/autonomousDatabases/{autonomous_database}. + * @param {google.cloud.oracledatabase.v1.GenerateType} [request.type] + * Optional. The type of wallet generation for the Autonomous Database. The + * default value is SINGLE. + * @param {boolean} [request.isRegional] + * Optional. True when requesting regional connection strings in PDB connect + * info, applicable to cross-region Data Guard only. + * @param {string} request.password + * Required. The password used to encrypt the keys inside the wallet. The + * password must be a minimum of 8 characters. + * @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 {@link protos.google.cloud.oracledatabase.v1.GenerateAutonomousDatabaseWalletResponse|GenerateAutonomousDatabaseWalletResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.generate_autonomous_database_wallet.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_GenerateAutonomousDatabaseWallet_async + */ generateAutonomousDatabaseWallet( - request?: protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletResponse, - protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletResponse, + ( + | protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletRequest + | undefined + ), + {} | undefined, + ] + >; generateAutonomousDatabaseWallet( - request: protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletResponse, - protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletResponse, + | protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletRequest + | null + | undefined, + {} | null | undefined + >, + ): void; generateAutonomousDatabaseWallet( - request: protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletRequest, - callback: Callback< - protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletResponse, - protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletRequest, + callback: Callback< + protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletResponse, + | protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletRequest + | null + | undefined, + {} | null | undefined + >, + ): void; generateAutonomousDatabaseWallet( - request?: protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletResponse, - protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletResponse, - protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletResponse, - protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletResponse, + | protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletResponse, + ( + | protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('generateAutonomousDatabaseWallet request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletResponse, - protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletRequest|null|undefined, - {}|null|undefined>|undefined = callback - ? (error, response, options, rawResponse) => { - this._log.info('generateAutonomousDatabaseWallet response %j', response); + const wrappedCallback: + | Callback< + protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletResponse, + | protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info( + 'generateAutonomousDatabaseWallet response %j', + response, + ); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.generateAutonomousDatabaseWallet(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletResponse, - protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletRequest|undefined, - {}|undefined - ]) => { - this._log.info('generateAutonomousDatabaseWallet response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .generateAutonomousDatabaseWallet(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletResponse, + ( + | protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info( + 'generateAutonomousDatabaseWallet response %j', + response, + ); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single ODB Network. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the OdbNetwork in the following format: - * projects/{project}/locations/{location}/odbNetworks/{odb_network}. - * @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 {@link protos.google.cloud.oracledatabase.v1.OdbNetwork|OdbNetwork}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.get_odb_network.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_GetOdbNetwork_async - */ + /** + * Gets details of a single ODB Network. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the OdbNetwork in the following format: + * projects/{project}/locations/{location}/odbNetworks/{odb_network}. + * @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 {@link protos.google.cloud.oracledatabase.v1.OdbNetwork|OdbNetwork}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.get_odb_network.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_GetOdbNetwork_async + */ getOdbNetwork( - request?: protos.google.cloud.oracledatabase.v1.IGetOdbNetworkRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.IOdbNetwork, - protos.google.cloud.oracledatabase.v1.IGetOdbNetworkRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.IGetOdbNetworkRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IOdbNetwork, + protos.google.cloud.oracledatabase.v1.IGetOdbNetworkRequest | undefined, + {} | undefined, + ] + >; getOdbNetwork( - request: protos.google.cloud.oracledatabase.v1.IGetOdbNetworkRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.oracledatabase.v1.IOdbNetwork, - protos.google.cloud.oracledatabase.v1.IGetOdbNetworkRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IGetOdbNetworkRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.oracledatabase.v1.IOdbNetwork, + | protos.google.cloud.oracledatabase.v1.IGetOdbNetworkRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getOdbNetwork( - request: protos.google.cloud.oracledatabase.v1.IGetOdbNetworkRequest, - callback: Callback< - protos.google.cloud.oracledatabase.v1.IOdbNetwork, - protos.google.cloud.oracledatabase.v1.IGetOdbNetworkRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IGetOdbNetworkRequest, + callback: Callback< + protos.google.cloud.oracledatabase.v1.IOdbNetwork, + | protos.google.cloud.oracledatabase.v1.IGetOdbNetworkRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getOdbNetwork( - request?: protos.google.cloud.oracledatabase.v1.IGetOdbNetworkRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.oracledatabase.v1.IOdbNetwork, - protos.google.cloud.oracledatabase.v1.IGetOdbNetworkRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.oracledatabase.v1.IGetOdbNetworkRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.oracledatabase.v1.IOdbNetwork, - protos.google.cloud.oracledatabase.v1.IGetOdbNetworkRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.oracledatabase.v1.IOdbNetwork, - protos.google.cloud.oracledatabase.v1.IGetOdbNetworkRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.oracledatabase.v1.IGetOdbNetworkRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.oracledatabase.v1.IOdbNetwork, + | protos.google.cloud.oracledatabase.v1.IGetOdbNetworkRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IOdbNetwork, + protos.google.cloud.oracledatabase.v1.IGetOdbNetworkRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getOdbNetwork request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.oracledatabase.v1.IOdbNetwork, - protos.google.cloud.oracledatabase.v1.IGetOdbNetworkRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.oracledatabase.v1.IOdbNetwork, + | protos.google.cloud.oracledatabase.v1.IGetOdbNetworkRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getOdbNetwork response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getOdbNetwork(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.oracledatabase.v1.IOdbNetwork, - protos.google.cloud.oracledatabase.v1.IGetOdbNetworkRequest|undefined, - {}|undefined - ]) => { - this._log.info('getOdbNetwork response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getOdbNetwork(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.oracledatabase.v1.IOdbNetwork, + ( + | protos.google.cloud.oracledatabase.v1.IGetOdbNetworkRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getOdbNetwork response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single ODB Subnet. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the OdbSubnet in the following format: - * projects/{project}/locations/{location}/odbNetworks/{odb_network}/odbSubnets/{odb_subnet}. - * @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 {@link protos.google.cloud.oracledatabase.v1.OdbSubnet|OdbSubnet}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.get_odb_subnet.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_GetOdbSubnet_async - */ + /** + * Gets details of a single ODB Subnet. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the OdbSubnet in the following format: + * projects/{project}/locations/{location}/odbNetworks/{odb_network}/odbSubnets/{odb_subnet}. + * @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 {@link protos.google.cloud.oracledatabase.v1.OdbSubnet|OdbSubnet}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.get_odb_subnet.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_GetOdbSubnet_async + */ getOdbSubnet( - request?: protos.google.cloud.oracledatabase.v1.IGetOdbSubnetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.IOdbSubnet, - protos.google.cloud.oracledatabase.v1.IGetOdbSubnetRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.IGetOdbSubnetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IOdbSubnet, + protos.google.cloud.oracledatabase.v1.IGetOdbSubnetRequest | undefined, + {} | undefined, + ] + >; getOdbSubnet( - request: protos.google.cloud.oracledatabase.v1.IGetOdbSubnetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.oracledatabase.v1.IOdbSubnet, - protos.google.cloud.oracledatabase.v1.IGetOdbSubnetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IGetOdbSubnetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.oracledatabase.v1.IOdbSubnet, + | protos.google.cloud.oracledatabase.v1.IGetOdbSubnetRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getOdbSubnet( - request: protos.google.cloud.oracledatabase.v1.IGetOdbSubnetRequest, - callback: Callback< - protos.google.cloud.oracledatabase.v1.IOdbSubnet, - protos.google.cloud.oracledatabase.v1.IGetOdbSubnetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IGetOdbSubnetRequest, + callback: Callback< + protos.google.cloud.oracledatabase.v1.IOdbSubnet, + | protos.google.cloud.oracledatabase.v1.IGetOdbSubnetRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getOdbSubnet( - request?: protos.google.cloud.oracledatabase.v1.IGetOdbSubnetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.oracledatabase.v1.IOdbSubnet, - protos.google.cloud.oracledatabase.v1.IGetOdbSubnetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.oracledatabase.v1.IGetOdbSubnetRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.oracledatabase.v1.IOdbSubnet, - protos.google.cloud.oracledatabase.v1.IGetOdbSubnetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.oracledatabase.v1.IOdbSubnet, - protos.google.cloud.oracledatabase.v1.IGetOdbSubnetRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.oracledatabase.v1.IGetOdbSubnetRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.oracledatabase.v1.IOdbSubnet, + | protos.google.cloud.oracledatabase.v1.IGetOdbSubnetRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IOdbSubnet, + protos.google.cloud.oracledatabase.v1.IGetOdbSubnetRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getOdbSubnet request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.oracledatabase.v1.IOdbSubnet, - protos.google.cloud.oracledatabase.v1.IGetOdbSubnetRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.oracledatabase.v1.IOdbSubnet, + | protos.google.cloud.oracledatabase.v1.IGetOdbSubnetRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getOdbSubnet response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getOdbSubnet(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.oracledatabase.v1.IOdbSubnet, - protos.google.cloud.oracledatabase.v1.IGetOdbSubnetRequest|undefined, - {}|undefined - ]) => { - this._log.info('getOdbSubnet response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getOdbSubnet(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.oracledatabase.v1.IOdbSubnet, + ( + | protos.google.cloud.oracledatabase.v1.IGetOdbSubnetRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getOdbSubnet response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single Exadb (Exascale) VM Cluster. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the ExadbVmCluster in the following format: - * projects/{project}/locations/{location}/exadbVmClusters/{exadb_vm_cluster}. - * @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 {@link protos.google.cloud.oracledatabase.v1.ExadbVmCluster|ExadbVmCluster}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.get_exadb_vm_cluster.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_GetExadbVmCluster_async - */ + /** + * Gets details of a single Exadb (Exascale) VM Cluster. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the ExadbVmCluster in the following format: + * projects/{project}/locations/{location}/exadbVmClusters/{exadb_vm_cluster}. + * @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 {@link protos.google.cloud.oracledatabase.v1.ExadbVmCluster|ExadbVmCluster}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.get_exadb_vm_cluster.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_GetExadbVmCluster_async + */ getExadbVmCluster( - request?: protos.google.cloud.oracledatabase.v1.IGetExadbVmClusterRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.IExadbVmCluster, - protos.google.cloud.oracledatabase.v1.IGetExadbVmClusterRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.IGetExadbVmClusterRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + ( + | protos.google.cloud.oracledatabase.v1.IGetExadbVmClusterRequest + | undefined + ), + {} | undefined, + ] + >; getExadbVmCluster( - request: protos.google.cloud.oracledatabase.v1.IGetExadbVmClusterRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.oracledatabase.v1.IExadbVmCluster, - protos.google.cloud.oracledatabase.v1.IGetExadbVmClusterRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IGetExadbVmClusterRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + | protos.google.cloud.oracledatabase.v1.IGetExadbVmClusterRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getExadbVmCluster( - request: protos.google.cloud.oracledatabase.v1.IGetExadbVmClusterRequest, - callback: Callback< - protos.google.cloud.oracledatabase.v1.IExadbVmCluster, - protos.google.cloud.oracledatabase.v1.IGetExadbVmClusterRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IGetExadbVmClusterRequest, + callback: Callback< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + | protos.google.cloud.oracledatabase.v1.IGetExadbVmClusterRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getExadbVmCluster( - request?: protos.google.cloud.oracledatabase.v1.IGetExadbVmClusterRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.oracledatabase.v1.IExadbVmCluster, - protos.google.cloud.oracledatabase.v1.IGetExadbVmClusterRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.oracledatabase.v1.IGetExadbVmClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.oracledatabase.v1.IExadbVmCluster, - protos.google.cloud.oracledatabase.v1.IGetExadbVmClusterRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.oracledatabase.v1.IExadbVmCluster, - protos.google.cloud.oracledatabase.v1.IGetExadbVmClusterRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.oracledatabase.v1.IGetExadbVmClusterRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + | protos.google.cloud.oracledatabase.v1.IGetExadbVmClusterRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + ( + | protos.google.cloud.oracledatabase.v1.IGetExadbVmClusterRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getExadbVmCluster request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.oracledatabase.v1.IExadbVmCluster, - protos.google.cloud.oracledatabase.v1.IGetExadbVmClusterRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + | protos.google.cloud.oracledatabase.v1.IGetExadbVmClusterRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getExadbVmCluster response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getExadbVmCluster(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.oracledatabase.v1.IExadbVmCluster, - protos.google.cloud.oracledatabase.v1.IGetExadbVmClusterRequest|undefined, - {}|undefined - ]) => { - this._log.info('getExadbVmCluster response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getExadbVmCluster(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + ( + | protos.google.cloud.oracledatabase.v1.IGetExadbVmClusterRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getExadbVmCluster response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single ExascaleDB Storage Vault. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the ExascaleDbStorageVault in the following format: - * projects/{project}/locations/{location}/exascaleDbStorageVaults/{exascale_db_storage_vault}. - * @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 {@link protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault|ExascaleDbStorageVault}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.get_exascale_db_storage_vault.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_GetExascaleDbStorageVault_async - */ + /** + * Gets details of a single ExascaleDB Storage Vault. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the ExascaleDbStorageVault in the following format: + * projects/{project}/locations/{location}/exascaleDbStorageVaults/{exascale_db_storage_vault}. + * @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 {@link protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault|ExascaleDbStorageVault}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.get_exascale_db_storage_vault.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_GetExascaleDbStorageVault_async + */ getExascaleDbStorageVault( - request?: protos.google.cloud.oracledatabase.v1.IGetExascaleDbStorageVaultRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault, - protos.google.cloud.oracledatabase.v1.IGetExascaleDbStorageVaultRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.IGetExascaleDbStorageVaultRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault, + ( + | protos.google.cloud.oracledatabase.v1.IGetExascaleDbStorageVaultRequest + | undefined + ), + {} | undefined, + ] + >; getExascaleDbStorageVault( - request: protos.google.cloud.oracledatabase.v1.IGetExascaleDbStorageVaultRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault, - protos.google.cloud.oracledatabase.v1.IGetExascaleDbStorageVaultRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IGetExascaleDbStorageVaultRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault, + | protos.google.cloud.oracledatabase.v1.IGetExascaleDbStorageVaultRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getExascaleDbStorageVault( - request: protos.google.cloud.oracledatabase.v1.IGetExascaleDbStorageVaultRequest, - callback: Callback< - protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault, - protos.google.cloud.oracledatabase.v1.IGetExascaleDbStorageVaultRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IGetExascaleDbStorageVaultRequest, + callback: Callback< + protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault, + | protos.google.cloud.oracledatabase.v1.IGetExascaleDbStorageVaultRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getExascaleDbStorageVault( - request?: protos.google.cloud.oracledatabase.v1.IGetExascaleDbStorageVaultRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault, - protos.google.cloud.oracledatabase.v1.IGetExascaleDbStorageVaultRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.oracledatabase.v1.IGetExascaleDbStorageVaultRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault, - protos.google.cloud.oracledatabase.v1.IGetExascaleDbStorageVaultRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault, - protos.google.cloud.oracledatabase.v1.IGetExascaleDbStorageVaultRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.oracledatabase.v1.IGetExascaleDbStorageVaultRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault, + | protos.google.cloud.oracledatabase.v1.IGetExascaleDbStorageVaultRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault, + ( + | protos.google.cloud.oracledatabase.v1.IGetExascaleDbStorageVaultRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getExascaleDbStorageVault request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault, - protos.google.cloud.oracledatabase.v1.IGetExascaleDbStorageVaultRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault, + | protos.google.cloud.oracledatabase.v1.IGetExascaleDbStorageVaultRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getExascaleDbStorageVault response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getExascaleDbStorageVault(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault, - protos.google.cloud.oracledatabase.v1.IGetExascaleDbStorageVaultRequest|undefined, - {}|undefined - ]) => { - this._log.info('getExascaleDbStorageVault response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getExascaleDbStorageVault(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault, + ( + | protos.google.cloud.oracledatabase.v1.IGetExascaleDbStorageVaultRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getExascaleDbStorageVault response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single Database. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the Database resource in the following format: - * projects/{project}/locations/{region}/databases/{database} - * @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 {@link protos.google.cloud.oracledatabase.v1.Database|Database}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.get_database.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_GetDatabase_async - */ + /** + * Gets details of a single Database. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the Database resource in the following format: + * projects/{project}/locations/{region}/databases/{database} + * @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 {@link protos.google.cloud.oracledatabase.v1.Database|Database}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.get_database.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_GetDatabase_async + */ getDatabase( - request?: protos.google.cloud.oracledatabase.v1.IGetDatabaseRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.IDatabase, - protos.google.cloud.oracledatabase.v1.IGetDatabaseRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.IGetDatabaseRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IDatabase, + protos.google.cloud.oracledatabase.v1.IGetDatabaseRequest | undefined, + {} | undefined, + ] + >; getDatabase( - request: protos.google.cloud.oracledatabase.v1.IGetDatabaseRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.oracledatabase.v1.IDatabase, - protos.google.cloud.oracledatabase.v1.IGetDatabaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IGetDatabaseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.oracledatabase.v1.IDatabase, + | protos.google.cloud.oracledatabase.v1.IGetDatabaseRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getDatabase( - request: protos.google.cloud.oracledatabase.v1.IGetDatabaseRequest, - callback: Callback< - protos.google.cloud.oracledatabase.v1.IDatabase, - protos.google.cloud.oracledatabase.v1.IGetDatabaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IGetDatabaseRequest, + callback: Callback< + protos.google.cloud.oracledatabase.v1.IDatabase, + | protos.google.cloud.oracledatabase.v1.IGetDatabaseRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getDatabase( - request?: protos.google.cloud.oracledatabase.v1.IGetDatabaseRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.oracledatabase.v1.IDatabase, - protos.google.cloud.oracledatabase.v1.IGetDatabaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.oracledatabase.v1.IGetDatabaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.oracledatabase.v1.IDatabase, - protos.google.cloud.oracledatabase.v1.IGetDatabaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.oracledatabase.v1.IDatabase, - protos.google.cloud.oracledatabase.v1.IGetDatabaseRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.oracledatabase.v1.IGetDatabaseRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.oracledatabase.v1.IDatabase, + | protos.google.cloud.oracledatabase.v1.IGetDatabaseRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IDatabase, + protos.google.cloud.oracledatabase.v1.IGetDatabaseRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getDatabase request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.oracledatabase.v1.IDatabase, - protos.google.cloud.oracledatabase.v1.IGetDatabaseRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.oracledatabase.v1.IDatabase, + | protos.google.cloud.oracledatabase.v1.IGetDatabaseRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getDatabase response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getDatabase(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.oracledatabase.v1.IDatabase, - protos.google.cloud.oracledatabase.v1.IGetDatabaseRequest|undefined, - {}|undefined - ]) => { - this._log.info('getDatabase response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getDatabase(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.oracledatabase.v1.IDatabase, + protos.google.cloud.oracledatabase.v1.IGetDatabaseRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getDatabase response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single PluggableDatabase. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the PluggableDatabase resource in the following - * format: - * projects/{project}/locations/{region}/pluggableDatabases/{pluggable_database} - * @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 {@link protos.google.cloud.oracledatabase.v1.PluggableDatabase|PluggableDatabase}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.get_pluggable_database.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_GetPluggableDatabase_async - */ + /** + * Gets details of a single PluggableDatabase. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the PluggableDatabase resource in the following + * format: + * projects/{project}/locations/{region}/pluggableDatabases/{pluggable_database} + * @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 {@link protos.google.cloud.oracledatabase.v1.PluggableDatabase|PluggableDatabase}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.get_pluggable_database.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_GetPluggableDatabase_async + */ getPluggableDatabase( - request?: protos.google.cloud.oracledatabase.v1.IGetPluggableDatabaseRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.IPluggableDatabase, - protos.google.cloud.oracledatabase.v1.IGetPluggableDatabaseRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.IGetPluggableDatabaseRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IPluggableDatabase, + ( + | protos.google.cloud.oracledatabase.v1.IGetPluggableDatabaseRequest + | undefined + ), + {} | undefined, + ] + >; getPluggableDatabase( - request: protos.google.cloud.oracledatabase.v1.IGetPluggableDatabaseRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.oracledatabase.v1.IPluggableDatabase, - protos.google.cloud.oracledatabase.v1.IGetPluggableDatabaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IGetPluggableDatabaseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.oracledatabase.v1.IPluggableDatabase, + | protos.google.cloud.oracledatabase.v1.IGetPluggableDatabaseRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getPluggableDatabase( - request: protos.google.cloud.oracledatabase.v1.IGetPluggableDatabaseRequest, - callback: Callback< - protos.google.cloud.oracledatabase.v1.IPluggableDatabase, - protos.google.cloud.oracledatabase.v1.IGetPluggableDatabaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IGetPluggableDatabaseRequest, + callback: Callback< + protos.google.cloud.oracledatabase.v1.IPluggableDatabase, + | protos.google.cloud.oracledatabase.v1.IGetPluggableDatabaseRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getPluggableDatabase( - request?: protos.google.cloud.oracledatabase.v1.IGetPluggableDatabaseRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.oracledatabase.v1.IPluggableDatabase, - protos.google.cloud.oracledatabase.v1.IGetPluggableDatabaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.oracledatabase.v1.IGetPluggableDatabaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.oracledatabase.v1.IPluggableDatabase, - protos.google.cloud.oracledatabase.v1.IGetPluggableDatabaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.oracledatabase.v1.IPluggableDatabase, - protos.google.cloud.oracledatabase.v1.IGetPluggableDatabaseRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.oracledatabase.v1.IGetPluggableDatabaseRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.oracledatabase.v1.IPluggableDatabase, + | protos.google.cloud.oracledatabase.v1.IGetPluggableDatabaseRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IPluggableDatabase, + ( + | protos.google.cloud.oracledatabase.v1.IGetPluggableDatabaseRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getPluggableDatabase request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.oracledatabase.v1.IPluggableDatabase, - protos.google.cloud.oracledatabase.v1.IGetPluggableDatabaseRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.oracledatabase.v1.IPluggableDatabase, + | protos.google.cloud.oracledatabase.v1.IGetPluggableDatabaseRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getPluggableDatabase response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getPluggableDatabase(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.oracledatabase.v1.IPluggableDatabase, - protos.google.cloud.oracledatabase.v1.IGetPluggableDatabaseRequest|undefined, - {}|undefined - ]) => { - this._log.info('getPluggableDatabase response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getPluggableDatabase(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.oracledatabase.v1.IPluggableDatabase, + ( + | protos.google.cloud.oracledatabase.v1.IGetPluggableDatabaseRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getPluggableDatabase response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details of a single DbSystem. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the DbSystem in the following format: - * projects/{project}/locations/{location}/dbSystems/{db_system}. - * @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 {@link protos.google.cloud.oracledatabase.v1.DbSystem|DbSystem}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.get_db_system.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_GetDbSystem_async - */ + /** + * Gets details of a single DbSystem. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the DbSystem in the following format: + * projects/{project}/locations/{location}/dbSystems/{db_system}. + * @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 {@link protos.google.cloud.oracledatabase.v1.DbSystem|DbSystem}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.get_db_system.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_GetDbSystem_async + */ getDbSystem( - request?: protos.google.cloud.oracledatabase.v1.IGetDbSystemRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.IDbSystem, - protos.google.cloud.oracledatabase.v1.IGetDbSystemRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.IGetDbSystemRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IDbSystem, + protos.google.cloud.oracledatabase.v1.IGetDbSystemRequest | undefined, + {} | undefined, + ] + >; getDbSystem( - request: protos.google.cloud.oracledatabase.v1.IGetDbSystemRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.oracledatabase.v1.IDbSystem, - protos.google.cloud.oracledatabase.v1.IGetDbSystemRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IGetDbSystemRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.oracledatabase.v1.IDbSystem, + | protos.google.cloud.oracledatabase.v1.IGetDbSystemRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getDbSystem( - request: protos.google.cloud.oracledatabase.v1.IGetDbSystemRequest, - callback: Callback< - protos.google.cloud.oracledatabase.v1.IDbSystem, - protos.google.cloud.oracledatabase.v1.IGetDbSystemRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IGetDbSystemRequest, + callback: Callback< + protos.google.cloud.oracledatabase.v1.IDbSystem, + | protos.google.cloud.oracledatabase.v1.IGetDbSystemRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getDbSystem( - request?: protos.google.cloud.oracledatabase.v1.IGetDbSystemRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.oracledatabase.v1.IDbSystem, - protos.google.cloud.oracledatabase.v1.IGetDbSystemRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.oracledatabase.v1.IGetDbSystemRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.oracledatabase.v1.IDbSystem, - protos.google.cloud.oracledatabase.v1.IGetDbSystemRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.oracledatabase.v1.IDbSystem, - protos.google.cloud.oracledatabase.v1.IGetDbSystemRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.oracledatabase.v1.IGetDbSystemRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.oracledatabase.v1.IDbSystem, + | protos.google.cloud.oracledatabase.v1.IGetDbSystemRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IDbSystem, + protos.google.cloud.oracledatabase.v1.IGetDbSystemRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getDbSystem request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.oracledatabase.v1.IDbSystem, - protos.google.cloud.oracledatabase.v1.IGetDbSystemRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.oracledatabase.v1.IDbSystem, + | protos.google.cloud.oracledatabase.v1.IGetDbSystemRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getDbSystem response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getDbSystem(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.oracledatabase.v1.IDbSystem, - protos.google.cloud.oracledatabase.v1.IGetDbSystemRequest|undefined, - {}|undefined - ]) => { - this._log.info('getDbSystem response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getDbSystem(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.oracledatabase.v1.IDbSystem, + protos.google.cloud.oracledatabase.v1.IGetDbSystemRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getDbSystem response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a new Exadata Infrastructure in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for CloudExadataInfrastructure in the following - * format: projects/{project}/locations/{location}. - * @param {string} request.cloudExadataInfrastructureId - * Required. The ID of the Exadata Infrastructure to create. This value is - * restricted to (^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$) and must be a maximum of - * 63 characters in length. The value must start with a letter and end with a - * letter or a number. - * @param {google.cloud.oracledatabase.v1.CloudExadataInfrastructure} request.cloudExadataInfrastructure - * Required. Details of the Exadata Infrastructure instance to create. - * @param {string} [request.requestId] - * Optional. An optional ID to identify the request. This value is used to - * identify duplicate requests. If you make a request with the same request ID - * and the original request is still in progress or completed, the server - * ignores the second request. This prevents clients from - * accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/oracle_database.create_cloud_exadata_infrastructure.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateCloudExadataInfrastructure_async - */ + /** + * Creates a new Exadata Infrastructure in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for CloudExadataInfrastructure in the following + * format: projects/{project}/locations/{location}. + * @param {string} request.cloudExadataInfrastructureId + * Required. The ID of the Exadata Infrastructure to create. This value is + * restricted to (^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$) and must be a maximum of + * 63 characters in length. The value must start with a letter and end with a + * letter or a number. + * @param {google.cloud.oracledatabase.v1.CloudExadataInfrastructure} request.cloudExadataInfrastructure + * Required. Details of the Exadata Infrastructure instance to create. + * @param {string} [request.requestId] + * Optional. An optional ID to identify the request. This value is used to + * identify duplicate requests. If you make a request with the same request ID + * and the original request is still in progress or completed, the server + * ignores the second request. This prevents clients from + * accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/oracle_database.create_cloud_exadata_infrastructure.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateCloudExadataInfrastructure_async + */ createCloudExadataInfrastructure( - request?: protos.google.cloud.oracledatabase.v1.ICreateCloudExadataInfrastructureRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.ICreateCloudExadataInfrastructureRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createCloudExadataInfrastructure( - request: protos.google.cloud.oracledatabase.v1.ICreateCloudExadataInfrastructureRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.ICreateCloudExadataInfrastructureRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createCloudExadataInfrastructure( - request: protos.google.cloud.oracledatabase.v1.ICreateCloudExadataInfrastructureRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.ICreateCloudExadataInfrastructureRequest, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createCloudExadataInfrastructure( - request?: protos.google.cloud.oracledatabase.v1.ICreateCloudExadataInfrastructureRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.oracledatabase.v1.ICreateCloudExadataInfrastructureRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { - this._log.info('createCloudExadataInfrastructure response %j', rawResponse); + this._log.info( + 'createCloudExadataInfrastructure response %j', + rawResponse, + ); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createCloudExadataInfrastructure request %j', request); - return this.innerApiCalls.createCloudExadataInfrastructure(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createCloudExadataInfrastructure response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createCloudExadataInfrastructure(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info( + 'createCloudExadataInfrastructure response %j', + rawResponse, + ); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createCloudExadataInfrastructure()`. - * @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/oracle_database.create_cloud_exadata_infrastructure.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateCloudExadataInfrastructure_async - */ - async checkCreateCloudExadataInfrastructureProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createCloudExadataInfrastructure()`. + * @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/oracle_database.create_cloud_exadata_infrastructure.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateCloudExadataInfrastructure_async + */ + async checkCreateCloudExadataInfrastructureProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure, + protos.google.cloud.oracledatabase.v1.OperationMetadata + > + > { this._log.info('createCloudExadataInfrastructure long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createCloudExadataInfrastructure, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createCloudExadataInfrastructure, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure, + protos.google.cloud.oracledatabase.v1.OperationMetadata + >; } -/** - * Deletes a single Exadata Infrastructure. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the Cloud Exadata Infrastructure in the following - * format: - * projects/{project}/locations/{location}/cloudExadataInfrastructures/{cloud_exadata_infrastructure}. - * @param {string} [request.requestId] - * Optional. An optional ID to identify the request. This value is used to - * identify duplicate requests. If you make a request with the same request ID - * and the original request is still in progress or completed, the server - * ignores the second request. This prevents clients from - * accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {boolean} [request.force] - * Optional. If set to true, all VM clusters for this Exadata Infrastructure - * will be deleted. An Exadata Infrastructure can only be deleted once all its - * VM clusters have been deleted. - * @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/oracle_database.delete_cloud_exadata_infrastructure.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteCloudExadataInfrastructure_async - */ + /** + * Deletes a single Exadata Infrastructure. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the Cloud Exadata Infrastructure in the following + * format: + * projects/{project}/locations/{location}/cloudExadataInfrastructures/{cloud_exadata_infrastructure}. + * @param {string} [request.requestId] + * Optional. An optional ID to identify the request. This value is used to + * identify duplicate requests. If you make a request with the same request ID + * and the original request is still in progress or completed, the server + * ignores the second request. This prevents clients from + * accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {boolean} [request.force] + * Optional. If set to true, all VM clusters for this Exadata Infrastructure + * will be deleted. An Exadata Infrastructure can only be deleted once all its + * VM clusters have been deleted. + * @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/oracle_database.delete_cloud_exadata_infrastructure.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteCloudExadataInfrastructure_async + */ deleteCloudExadataInfrastructure( - request?: protos.google.cloud.oracledatabase.v1.IDeleteCloudExadataInfrastructureRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.IDeleteCloudExadataInfrastructureRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteCloudExadataInfrastructure( - request: protos.google.cloud.oracledatabase.v1.IDeleteCloudExadataInfrastructureRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IDeleteCloudExadataInfrastructureRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteCloudExadataInfrastructure( - request: protos.google.cloud.oracledatabase.v1.IDeleteCloudExadataInfrastructureRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IDeleteCloudExadataInfrastructureRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteCloudExadataInfrastructure( - request?: protos.google.cloud.oracledatabase.v1.IDeleteCloudExadataInfrastructureRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.oracledatabase.v1.IDeleteCloudExadataInfrastructureRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { - this._log.info('deleteCloudExadataInfrastructure response %j', rawResponse); + this._log.info( + 'deleteCloudExadataInfrastructure response %j', + rawResponse, + ); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteCloudExadataInfrastructure request %j', request); - return this.innerApiCalls.deleteCloudExadataInfrastructure(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteCloudExadataInfrastructure response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteCloudExadataInfrastructure(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info( + 'deleteCloudExadataInfrastructure response %j', + rawResponse, + ); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteCloudExadataInfrastructure()`. - * @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/oracle_database.delete_cloud_exadata_infrastructure.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteCloudExadataInfrastructure_async - */ - async checkDeleteCloudExadataInfrastructureProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteCloudExadataInfrastructure()`. + * @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/oracle_database.delete_cloud_exadata_infrastructure.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteCloudExadataInfrastructure_async + */ + async checkDeleteCloudExadataInfrastructureProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.oracledatabase.v1.OperationMetadata + > + > { this._log.info('deleteCloudExadataInfrastructure long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteCloudExadataInfrastructure, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteCloudExadataInfrastructure, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.oracledatabase.v1.OperationMetadata + >; } -/** - * Creates a new VM Cluster in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent in the following format: - * projects/{project}/locations/{location}. - * @param {string} request.cloudVmClusterId - * Required. The ID of the VM Cluster to create. This value is restricted - * to (^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$) and must be a maximum of 63 - * characters in length. The value must start with a letter and end with - * a letter or a number. - * @param {google.cloud.oracledatabase.v1.CloudVmCluster} request.cloudVmCluster - * Required. The resource being created - * @param {string} [request.requestId] - * Optional. An optional ID to identify the request. This value is used to - * identify duplicate requests. If you make a request with the same request ID - * and the original request is still in progress or completed, the server - * ignores the second request. This prevents clients from - * accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/oracle_database.create_cloud_vm_cluster.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateCloudVmCluster_async - */ + /** + * Creates a new VM Cluster in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent in the following format: + * projects/{project}/locations/{location}. + * @param {string} request.cloudVmClusterId + * Required. The ID of the VM Cluster to create. This value is restricted + * to (^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$) and must be a maximum of 63 + * characters in length. The value must start with a letter and end with + * a letter or a number. + * @param {google.cloud.oracledatabase.v1.CloudVmCluster} request.cloudVmCluster + * Required. The resource being created + * @param {string} [request.requestId] + * Optional. An optional ID to identify the request. This value is used to + * identify duplicate requests. If you make a request with the same request ID + * and the original request is still in progress or completed, the server + * ignores the second request. This prevents clients from + * accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/oracle_database.create_cloud_vm_cluster.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateCloudVmCluster_async + */ createCloudVmCluster( - request?: protos.google.cloud.oracledatabase.v1.ICreateCloudVmClusterRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.ICreateCloudVmClusterRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.ICloudVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createCloudVmCluster( - request: protos.google.cloud.oracledatabase.v1.ICreateCloudVmClusterRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.ICreateCloudVmClusterRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.ICloudVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createCloudVmCluster( - request: protos.google.cloud.oracledatabase.v1.ICreateCloudVmClusterRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.ICreateCloudVmClusterRequest, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.ICloudVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createCloudVmCluster( - request?: protos.google.cloud.oracledatabase.v1.ICreateCloudVmClusterRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.oracledatabase.v1.ICreateCloudVmClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.ICloudVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.ICloudVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.ICloudVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.ICloudVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createCloudVmCluster response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createCloudVmCluster request %j', request); - return this.innerApiCalls.createCloudVmCluster(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createCloudVmCluster response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createCloudVmCluster(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.oracledatabase.v1.ICloudVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createCloudVmCluster response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createCloudVmCluster()`. - * @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/oracle_database.create_cloud_vm_cluster.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateCloudVmCluster_async - */ - async checkCreateCloudVmClusterProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createCloudVmCluster()`. + * @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/oracle_database.create_cloud_vm_cluster.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateCloudVmCluster_async + */ + async checkCreateCloudVmClusterProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.oracledatabase.v1.CloudVmCluster, + protos.google.cloud.oracledatabase.v1.OperationMetadata + > + > { this._log.info('createCloudVmCluster long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createCloudVmCluster, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createCloudVmCluster, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.oracledatabase.v1.CloudVmCluster, + protos.google.cloud.oracledatabase.v1.OperationMetadata + >; } -/** - * Deletes a single VM Cluster. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the Cloud VM Cluster in the following format: - * projects/{project}/locations/{location}/cloudVmClusters/{cloud_vm_cluster}. - * @param {string} [request.requestId] - * Optional. An optional ID to identify the request. This value is used to - * identify duplicate requests. If you make a request with the same request ID - * and the original request is still in progress or completed, the server - * ignores the second request. This prevents clients from - * accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {boolean} [request.force] - * Optional. If set to true, all child resources for the VM Cluster will be - * deleted. A VM Cluster can only be deleted once all its child resources have - * been deleted. - * @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/oracle_database.delete_cloud_vm_cluster.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteCloudVmCluster_async - */ + /** + * Deletes a single VM Cluster. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the Cloud VM Cluster in the following format: + * projects/{project}/locations/{location}/cloudVmClusters/{cloud_vm_cluster}. + * @param {string} [request.requestId] + * Optional. An optional ID to identify the request. This value is used to + * identify duplicate requests. If you make a request with the same request ID + * and the original request is still in progress or completed, the server + * ignores the second request. This prevents clients from + * accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {boolean} [request.force] + * Optional. If set to true, all child resources for the VM Cluster will be + * deleted. A VM Cluster can only be deleted once all its child resources have + * been deleted. + * @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/oracle_database.delete_cloud_vm_cluster.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteCloudVmCluster_async + */ deleteCloudVmCluster( - request?: protos.google.cloud.oracledatabase.v1.IDeleteCloudVmClusterRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.IDeleteCloudVmClusterRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteCloudVmCluster( - request: protos.google.cloud.oracledatabase.v1.IDeleteCloudVmClusterRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IDeleteCloudVmClusterRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteCloudVmCluster( - request: protos.google.cloud.oracledatabase.v1.IDeleteCloudVmClusterRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IDeleteCloudVmClusterRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteCloudVmCluster( - request?: protos.google.cloud.oracledatabase.v1.IDeleteCloudVmClusterRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.oracledatabase.v1.IDeleteCloudVmClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteCloudVmCluster response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteCloudVmCluster request %j', request); - return this.innerApiCalls.deleteCloudVmCluster(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteCloudVmCluster response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteCloudVmCluster(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteCloudVmCluster response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteCloudVmCluster()`. - * @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/oracle_database.delete_cloud_vm_cluster.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteCloudVmCluster_async - */ - async checkDeleteCloudVmClusterProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteCloudVmCluster()`. + * @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/oracle_database.delete_cloud_vm_cluster.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteCloudVmCluster_async + */ + async checkDeleteCloudVmClusterProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.oracledatabase.v1.OperationMetadata + > + > { this._log.info('deleteCloudVmCluster long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteCloudVmCluster, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteCloudVmCluster, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.oracledatabase.v1.OperationMetadata + >; } -/** - * Creates a new Autonomous Database in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent in the following format: - * projects/{project}/locations/{location}. - * @param {string} request.autonomousDatabaseId - * Required. The ID of the Autonomous Database to create. This value is - * restricted to (^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$) and must be a maximum of - * 63 characters in length. The value must start with a letter and end with a - * letter or a number. - * @param {google.cloud.oracledatabase.v1.AutonomousDatabase} request.autonomousDatabase - * Required. The Autonomous Database being created. - * @param {string} [request.requestId] - * Optional. An optional ID to identify the request. This value is used to - * identify duplicate requests. If you make a request with the same request ID - * and the original request is still in progress or completed, the server - * ignores the second request. This prevents clients from - * accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/oracle_database.create_autonomous_database.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateAutonomousDatabase_async - */ + /** + * Creates a new Autonomous Database in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent in the following format: + * projects/{project}/locations/{location}. + * @param {string} request.autonomousDatabaseId + * Required. The ID of the Autonomous Database to create. This value is + * restricted to (^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$) and must be a maximum of + * 63 characters in length. The value must start with a letter and end with a + * letter or a number. + * @param {google.cloud.oracledatabase.v1.AutonomousDatabase} request.autonomousDatabase + * Required. The Autonomous Database being created. + * @param {string} [request.requestId] + * Optional. An optional ID to identify the request. This value is used to + * identify duplicate requests. If you make a request with the same request ID + * and the original request is still in progress or completed, the server + * ignores the second request. This prevents clients from + * accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/oracle_database.create_autonomous_database.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateAutonomousDatabase_async + */ createAutonomousDatabase( - request?: protos.google.cloud.oracledatabase.v1.ICreateAutonomousDatabaseRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.ICreateAutonomousDatabaseRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createAutonomousDatabase( - request: protos.google.cloud.oracledatabase.v1.ICreateAutonomousDatabaseRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.ICreateAutonomousDatabaseRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createAutonomousDatabase( - request: protos.google.cloud.oracledatabase.v1.ICreateAutonomousDatabaseRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.ICreateAutonomousDatabaseRequest, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createAutonomousDatabase( - request?: protos.google.cloud.oracledatabase.v1.ICreateAutonomousDatabaseRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.oracledatabase.v1.ICreateAutonomousDatabaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createAutonomousDatabase response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createAutonomousDatabase request %j', request); - return this.innerApiCalls.createAutonomousDatabase(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createAutonomousDatabase response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createAutonomousDatabase(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createAutonomousDatabase response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createAutonomousDatabase()`. - * @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/oracle_database.create_autonomous_database.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateAutonomousDatabase_async - */ - async checkCreateAutonomousDatabaseProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createAutonomousDatabase()`. + * @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/oracle_database.create_autonomous_database.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateAutonomousDatabase_async + */ + async checkCreateAutonomousDatabaseProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.oracledatabase.v1.AutonomousDatabase, + protos.google.cloud.oracledatabase.v1.OperationMetadata + > + > { this._log.info('createAutonomousDatabase long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createAutonomousDatabase, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createAutonomousDatabase, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.oracledatabase.v1.AutonomousDatabase, + protos.google.cloud.oracledatabase.v1.OperationMetadata + >; } -/** - * Updates the parameters of a single Autonomous Database. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask is used to specify the fields to be overwritten in the - * Exadata resource by the update. The fields specified in the update_mask are - * relative to the resource, not the full request. A field will be overwritten - * if it is in the mask. If the user does not provide a mask then all fields - * will be overwritten. - * @param {google.cloud.oracledatabase.v1.AutonomousDatabase} request.autonomousDatabase - * Required. The resource being updated - * @param {string} [request.requestId] - * Optional. An optional ID to identify the request. This value is used to - * identify duplicate requests. If you make a request with the same request ID - * and the original request is still in progress or completed, the server - * ignores the second request. This prevents clients from - * accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/oracle_database.update_autonomous_database.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_UpdateAutonomousDatabase_async - */ + /** + * Updates the parameters of a single Autonomous Database. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask is used to specify the fields to be overwritten in the + * Exadata resource by the update. The fields specified in the update_mask are + * relative to the resource, not the full request. A field will be overwritten + * if it is in the mask. If the user does not provide a mask then all fields + * will be overwritten. + * @param {google.cloud.oracledatabase.v1.AutonomousDatabase} request.autonomousDatabase + * Required. The resource being updated + * @param {string} [request.requestId] + * Optional. An optional ID to identify the request. This value is used to + * identify duplicate requests. If you make a request with the same request ID + * and the original request is still in progress or completed, the server + * ignores the second request. This prevents clients from + * accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/oracle_database.update_autonomous_database.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_UpdateAutonomousDatabase_async + */ updateAutonomousDatabase( - request?: protos.google.cloud.oracledatabase.v1.IUpdateAutonomousDatabaseRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.IUpdateAutonomousDatabaseRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateAutonomousDatabase( - request: protos.google.cloud.oracledatabase.v1.IUpdateAutonomousDatabaseRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IUpdateAutonomousDatabaseRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateAutonomousDatabase( - request: protos.google.cloud.oracledatabase.v1.IUpdateAutonomousDatabaseRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IUpdateAutonomousDatabaseRequest, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateAutonomousDatabase( - request?: protos.google.cloud.oracledatabase.v1.IUpdateAutonomousDatabaseRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.oracledatabase.v1.IUpdateAutonomousDatabaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'autonomous_database.name': request.autonomousDatabase!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'autonomous_database.name': request.autonomousDatabase!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateAutonomousDatabase response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateAutonomousDatabase request %j', request); - return this.innerApiCalls.updateAutonomousDatabase(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateAutonomousDatabase response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateAutonomousDatabase(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateAutonomousDatabase response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateAutonomousDatabase()`. - * @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/oracle_database.update_autonomous_database.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_UpdateAutonomousDatabase_async - */ - async checkUpdateAutonomousDatabaseProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateAutonomousDatabase()`. + * @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/oracle_database.update_autonomous_database.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_UpdateAutonomousDatabase_async + */ + async checkUpdateAutonomousDatabaseProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.oracledatabase.v1.AutonomousDatabase, + protos.google.cloud.oracledatabase.v1.OperationMetadata + > + > { this._log.info('updateAutonomousDatabase long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateAutonomousDatabase, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateAutonomousDatabase, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.oracledatabase.v1.AutonomousDatabase, + protos.google.cloud.oracledatabase.v1.OperationMetadata + >; } -/** - * Deletes a single Autonomous Database. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the resource in the following format: - * projects/{project}/locations/{location}/autonomousDatabases/{autonomous_database}. - * @param {string} [request.requestId] - * Optional. An optional ID to identify the request. This value is used to - * identify duplicate requests. If you make a request with the same request ID - * and the original request is still in progress or completed, the server - * ignores the second request. This prevents clients from - * accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/oracle_database.delete_autonomous_database.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteAutonomousDatabase_async - */ + /** + * Deletes a single Autonomous Database. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the resource in the following format: + * projects/{project}/locations/{location}/autonomousDatabases/{autonomous_database}. + * @param {string} [request.requestId] + * Optional. An optional ID to identify the request. This value is used to + * identify duplicate requests. If you make a request with the same request ID + * and the original request is still in progress or completed, the server + * ignores the second request. This prevents clients from + * accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/oracle_database.delete_autonomous_database.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteAutonomousDatabase_async + */ deleteAutonomousDatabase( - request?: protos.google.cloud.oracledatabase.v1.IDeleteAutonomousDatabaseRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.IDeleteAutonomousDatabaseRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteAutonomousDatabase( - request: protos.google.cloud.oracledatabase.v1.IDeleteAutonomousDatabaseRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IDeleteAutonomousDatabaseRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteAutonomousDatabase( - request: protos.google.cloud.oracledatabase.v1.IDeleteAutonomousDatabaseRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IDeleteAutonomousDatabaseRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteAutonomousDatabase( - request?: protos.google.cloud.oracledatabase.v1.IDeleteAutonomousDatabaseRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.oracledatabase.v1.IDeleteAutonomousDatabaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteAutonomousDatabase response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteAutonomousDatabase request %j', request); - return this.innerApiCalls.deleteAutonomousDatabase(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteAutonomousDatabase response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteAutonomousDatabase(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteAutonomousDatabase response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteAutonomousDatabase()`. - * @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/oracle_database.delete_autonomous_database.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteAutonomousDatabase_async - */ - async checkDeleteAutonomousDatabaseProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteAutonomousDatabase()`. + * @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/oracle_database.delete_autonomous_database.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteAutonomousDatabase_async + */ + async checkDeleteAutonomousDatabaseProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.oracledatabase.v1.OperationMetadata + > + > { this._log.info('deleteAutonomousDatabase long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteAutonomousDatabase, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteAutonomousDatabase, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.oracledatabase.v1.OperationMetadata + >; } -/** - * Restores a single Autonomous Database. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the Autonomous Database in the following format: - * projects/{project}/locations/{location}/autonomousDatabases/{autonomous_database}. - * @param {google.protobuf.Timestamp} request.restoreTime - * Required. The time and date to restore the database to. - * @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/oracle_database.restore_autonomous_database.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_RestoreAutonomousDatabase_async - */ + /** + * Restores a single Autonomous Database. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the Autonomous Database in the following format: + * projects/{project}/locations/{location}/autonomousDatabases/{autonomous_database}. + * @param {google.protobuf.Timestamp} request.restoreTime + * Required. The time and date to restore the database to. + * @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/oracle_database.restore_autonomous_database.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_RestoreAutonomousDatabase_async + */ restoreAutonomousDatabase( - request?: protos.google.cloud.oracledatabase.v1.IRestoreAutonomousDatabaseRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.IRestoreAutonomousDatabaseRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; restoreAutonomousDatabase( - request: protos.google.cloud.oracledatabase.v1.IRestoreAutonomousDatabaseRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IRestoreAutonomousDatabaseRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; restoreAutonomousDatabase( - request: protos.google.cloud.oracledatabase.v1.IRestoreAutonomousDatabaseRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IRestoreAutonomousDatabaseRequest, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; restoreAutonomousDatabase( - request?: protos.google.cloud.oracledatabase.v1.IRestoreAutonomousDatabaseRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.oracledatabase.v1.IRestoreAutonomousDatabaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('restoreAutonomousDatabase response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('restoreAutonomousDatabase request %j', request); - return this.innerApiCalls.restoreAutonomousDatabase(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('restoreAutonomousDatabase response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .restoreAutonomousDatabase(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('restoreAutonomousDatabase response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `restoreAutonomousDatabase()`. - * @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/oracle_database.restore_autonomous_database.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_RestoreAutonomousDatabase_async - */ - async checkRestoreAutonomousDatabaseProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `restoreAutonomousDatabase()`. + * @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/oracle_database.restore_autonomous_database.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_RestoreAutonomousDatabase_async + */ + async checkRestoreAutonomousDatabaseProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.oracledatabase.v1.AutonomousDatabase, + protos.google.cloud.oracledatabase.v1.OperationMetadata + > + > { this._log.info('restoreAutonomousDatabase long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.restoreAutonomousDatabase, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.restoreAutonomousDatabase, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.oracledatabase.v1.AutonomousDatabase, + protos.google.cloud.oracledatabase.v1.OperationMetadata + >; } -/** - * Stops an Autonomous Database. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the Autonomous Database in the following format: - * projects/{project}/locations/{location}/autonomousDatabases/{autonomous_database}. - * @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/oracle_database.stop_autonomous_database.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_StopAutonomousDatabase_async - */ + /** + * Stops an Autonomous Database. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the Autonomous Database in the following format: + * projects/{project}/locations/{location}/autonomousDatabases/{autonomous_database}. + * @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/oracle_database.stop_autonomous_database.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_StopAutonomousDatabase_async + */ stopAutonomousDatabase( - request?: protos.google.cloud.oracledatabase.v1.IStopAutonomousDatabaseRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.IStopAutonomousDatabaseRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; stopAutonomousDatabase( - request: protos.google.cloud.oracledatabase.v1.IStopAutonomousDatabaseRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IStopAutonomousDatabaseRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; stopAutonomousDatabase( - request: protos.google.cloud.oracledatabase.v1.IStopAutonomousDatabaseRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IStopAutonomousDatabaseRequest, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; stopAutonomousDatabase( - request?: protos.google.cloud.oracledatabase.v1.IStopAutonomousDatabaseRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.oracledatabase.v1.IStopAutonomousDatabaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('stopAutonomousDatabase response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('stopAutonomousDatabase request %j', request); - return this.innerApiCalls.stopAutonomousDatabase(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('stopAutonomousDatabase response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .stopAutonomousDatabase(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('stopAutonomousDatabase response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `stopAutonomousDatabase()`. - * @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/oracle_database.stop_autonomous_database.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_StopAutonomousDatabase_async - */ - async checkStopAutonomousDatabaseProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `stopAutonomousDatabase()`. + * @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/oracle_database.stop_autonomous_database.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_StopAutonomousDatabase_async + */ + async checkStopAutonomousDatabaseProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.oracledatabase.v1.AutonomousDatabase, + protos.google.cloud.oracledatabase.v1.OperationMetadata + > + > { this._log.info('stopAutonomousDatabase long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.stopAutonomousDatabase, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.stopAutonomousDatabase, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.oracledatabase.v1.AutonomousDatabase, + protos.google.cloud.oracledatabase.v1.OperationMetadata + >; } -/** - * Starts an Autonomous Database. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the Autonomous Database in the following format: - * projects/{project}/locations/{location}/autonomousDatabases/{autonomous_database}. - * @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/oracle_database.start_autonomous_database.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_StartAutonomousDatabase_async - */ + /** + * Starts an Autonomous Database. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the Autonomous Database in the following format: + * projects/{project}/locations/{location}/autonomousDatabases/{autonomous_database}. + * @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/oracle_database.start_autonomous_database.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_StartAutonomousDatabase_async + */ startAutonomousDatabase( - request?: protos.google.cloud.oracledatabase.v1.IStartAutonomousDatabaseRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.IStartAutonomousDatabaseRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; startAutonomousDatabase( - request: protos.google.cloud.oracledatabase.v1.IStartAutonomousDatabaseRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IStartAutonomousDatabaseRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; startAutonomousDatabase( - request: protos.google.cloud.oracledatabase.v1.IStartAutonomousDatabaseRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IStartAutonomousDatabaseRequest, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; startAutonomousDatabase( - request?: protos.google.cloud.oracledatabase.v1.IStartAutonomousDatabaseRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.oracledatabase.v1.IStartAutonomousDatabaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('startAutonomousDatabase response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('startAutonomousDatabase request %j', request); - return this.innerApiCalls.startAutonomousDatabase(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('startAutonomousDatabase response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .startAutonomousDatabase(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('startAutonomousDatabase response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `startAutonomousDatabase()`. - * @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/oracle_database.start_autonomous_database.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_StartAutonomousDatabase_async - */ - async checkStartAutonomousDatabaseProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `startAutonomousDatabase()`. + * @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/oracle_database.start_autonomous_database.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_StartAutonomousDatabase_async + */ + async checkStartAutonomousDatabaseProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.oracledatabase.v1.AutonomousDatabase, + protos.google.cloud.oracledatabase.v1.OperationMetadata + > + > { this._log.info('startAutonomousDatabase long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.startAutonomousDatabase, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.startAutonomousDatabase, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.oracledatabase.v1.AutonomousDatabase, + protos.google.cloud.oracledatabase.v1.OperationMetadata + >; } -/** - * Restarts an Autonomous Database. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the Autonomous Database in the following format: - * projects/{project}/locations/{location}/autonomousDatabases/{autonomous_database}. - * @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/oracle_database.restart_autonomous_database.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_RestartAutonomousDatabase_async - */ + /** + * Restarts an Autonomous Database. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the Autonomous Database in the following format: + * projects/{project}/locations/{location}/autonomousDatabases/{autonomous_database}. + * @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/oracle_database.restart_autonomous_database.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_RestartAutonomousDatabase_async + */ restartAutonomousDatabase( - request?: protos.google.cloud.oracledatabase.v1.IRestartAutonomousDatabaseRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.IRestartAutonomousDatabaseRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; restartAutonomousDatabase( - request: protos.google.cloud.oracledatabase.v1.IRestartAutonomousDatabaseRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IRestartAutonomousDatabaseRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; restartAutonomousDatabase( - request: protos.google.cloud.oracledatabase.v1.IRestartAutonomousDatabaseRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IRestartAutonomousDatabaseRequest, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; restartAutonomousDatabase( - request?: protos.google.cloud.oracledatabase.v1.IRestartAutonomousDatabaseRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.oracledatabase.v1.IRestartAutonomousDatabaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('restartAutonomousDatabase response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('restartAutonomousDatabase request %j', request); - return this.innerApiCalls.restartAutonomousDatabase(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('restartAutonomousDatabase response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .restartAutonomousDatabase(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('restartAutonomousDatabase response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `restartAutonomousDatabase()`. - * @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/oracle_database.restart_autonomous_database.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_RestartAutonomousDatabase_async - */ - async checkRestartAutonomousDatabaseProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `restartAutonomousDatabase()`. + * @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/oracle_database.restart_autonomous_database.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_RestartAutonomousDatabase_async + */ + async checkRestartAutonomousDatabaseProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.oracledatabase.v1.AutonomousDatabase, + protos.google.cloud.oracledatabase.v1.OperationMetadata + > + > { this._log.info('restartAutonomousDatabase long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.restartAutonomousDatabase, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.restartAutonomousDatabase, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.oracledatabase.v1.AutonomousDatabase, + protos.google.cloud.oracledatabase.v1.OperationMetadata + >; } -/** - * Initiates a switchover of specified autonomous database to the associated - * peer database. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the Autonomous Database in the following format: - * projects/{project}/locations/{location}/autonomousDatabases/{autonomous_database}. - * @param {string} request.peerAutonomousDatabase - * Required. The peer database name to switch over to. - * @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/oracle_database.switchover_autonomous_database.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_SwitchoverAutonomousDatabase_async - */ + /** + * Initiates a switchover of specified autonomous database to the associated + * peer database. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the Autonomous Database in the following format: + * projects/{project}/locations/{location}/autonomousDatabases/{autonomous_database}. + * @param {string} request.peerAutonomousDatabase + * Required. The peer database name to switch over to. + * @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/oracle_database.switchover_autonomous_database.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_SwitchoverAutonomousDatabase_async + */ switchoverAutonomousDatabase( - request?: protos.google.cloud.oracledatabase.v1.ISwitchoverAutonomousDatabaseRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.ISwitchoverAutonomousDatabaseRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; switchoverAutonomousDatabase( - request: protos.google.cloud.oracledatabase.v1.ISwitchoverAutonomousDatabaseRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.ISwitchoverAutonomousDatabaseRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; switchoverAutonomousDatabase( - request: protos.google.cloud.oracledatabase.v1.ISwitchoverAutonomousDatabaseRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.ISwitchoverAutonomousDatabaseRequest, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; switchoverAutonomousDatabase( - request?: protos.google.cloud.oracledatabase.v1.ISwitchoverAutonomousDatabaseRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.oracledatabase.v1.ISwitchoverAutonomousDatabaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { - this._log.info('switchoverAutonomousDatabase response %j', rawResponse); + this._log.info( + 'switchoverAutonomousDatabase response %j', + rawResponse, + ); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('switchoverAutonomousDatabase request %j', request); - return this.innerApiCalls.switchoverAutonomousDatabase(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('switchoverAutonomousDatabase response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .switchoverAutonomousDatabase(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info( + 'switchoverAutonomousDatabase response %j', + rawResponse, + ); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `switchoverAutonomousDatabase()`. - * @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/oracle_database.switchover_autonomous_database.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_SwitchoverAutonomousDatabase_async - */ - async checkSwitchoverAutonomousDatabaseProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `switchoverAutonomousDatabase()`. + * @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/oracle_database.switchover_autonomous_database.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_SwitchoverAutonomousDatabase_async + */ + async checkSwitchoverAutonomousDatabaseProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.oracledatabase.v1.AutonomousDatabase, + protos.google.cloud.oracledatabase.v1.OperationMetadata + > + > { this._log.info('switchoverAutonomousDatabase long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.switchoverAutonomousDatabase, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.switchoverAutonomousDatabase, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.oracledatabase.v1.AutonomousDatabase, + protos.google.cloud.oracledatabase.v1.OperationMetadata + >; } -/** - * Initiates a failover to target autonomous database from the associated - * primary database. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the Autonomous Database in the following format: - * projects/{project}/locations/{location}/autonomousDatabases/{autonomous_database}. - * @param {string} request.peerAutonomousDatabase - * Required. The peer database name to fail over to. - * @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/oracle_database.failover_autonomous_database.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_FailoverAutonomousDatabase_async - */ + /** + * Initiates a failover to target autonomous database from the associated + * primary database. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the Autonomous Database in the following format: + * projects/{project}/locations/{location}/autonomousDatabases/{autonomous_database}. + * @param {string} request.peerAutonomousDatabase + * Required. The peer database name to fail over to. + * @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/oracle_database.failover_autonomous_database.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_FailoverAutonomousDatabase_async + */ failoverAutonomousDatabase( - request?: protos.google.cloud.oracledatabase.v1.IFailoverAutonomousDatabaseRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.IFailoverAutonomousDatabaseRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; failoverAutonomousDatabase( - request: protos.google.cloud.oracledatabase.v1.IFailoverAutonomousDatabaseRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IFailoverAutonomousDatabaseRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; failoverAutonomousDatabase( - request: protos.google.cloud.oracledatabase.v1.IFailoverAutonomousDatabaseRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IFailoverAutonomousDatabaseRequest, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; failoverAutonomousDatabase( - request?: protos.google.cloud.oracledatabase.v1.IFailoverAutonomousDatabaseRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.oracledatabase.v1.IFailoverAutonomousDatabaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('failoverAutonomousDatabase response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('failoverAutonomousDatabase request %j', request); - return this.innerApiCalls.failoverAutonomousDatabase(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('failoverAutonomousDatabase response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .failoverAutonomousDatabase(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('failoverAutonomousDatabase response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `failoverAutonomousDatabase()`. - * @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/oracle_database.failover_autonomous_database.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_FailoverAutonomousDatabase_async - */ - async checkFailoverAutonomousDatabaseProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `failoverAutonomousDatabase()`. + * @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/oracle_database.failover_autonomous_database.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_FailoverAutonomousDatabase_async + */ + async checkFailoverAutonomousDatabaseProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.oracledatabase.v1.AutonomousDatabase, + protos.google.cloud.oracledatabase.v1.OperationMetadata + > + > { this._log.info('failoverAutonomousDatabase long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.failoverAutonomousDatabase, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.failoverAutonomousDatabase, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.oracledatabase.v1.AutonomousDatabase, + protos.google.cloud.oracledatabase.v1.OperationMetadata + >; } -/** - * Creates a new ODB Network in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for the OdbNetwork in the following format: - * projects/{project}/locations/{location}. - * @param {string} request.odbNetworkId - * Required. The ID of the OdbNetwork to create. This value is restricted - * to (^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$) and must be a maximum of 63 - * characters in length. The value must start with a letter and end with - * a letter or a number. - * @param {google.cloud.oracledatabase.v1.OdbNetwork} request.odbNetwork - * Required. Details of the OdbNetwork instance to create. - * @param {string} [request.requestId] - * Optional. An optional ID to identify the request. This value is used to - * identify duplicate requests. If you make a request with the same request ID - * and the original request is still in progress or completed, the server - * ignores the second request. This prevents clients from - * accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/oracle_database.create_odb_network.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateOdbNetwork_async - */ + /** + * Creates a new ODB Network in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for the OdbNetwork in the following format: + * projects/{project}/locations/{location}. + * @param {string} request.odbNetworkId + * Required. The ID of the OdbNetwork to create. This value is restricted + * to (^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$) and must be a maximum of 63 + * characters in length. The value must start with a letter and end with + * a letter or a number. + * @param {google.cloud.oracledatabase.v1.OdbNetwork} request.odbNetwork + * Required. Details of the OdbNetwork instance to create. + * @param {string} [request.requestId] + * Optional. An optional ID to identify the request. This value is used to + * identify duplicate requests. If you make a request with the same request ID + * and the original request is still in progress or completed, the server + * ignores the second request. This prevents clients from + * accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/oracle_database.create_odb_network.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateOdbNetwork_async + */ createOdbNetwork( - request?: protos.google.cloud.oracledatabase.v1.ICreateOdbNetworkRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.ICreateOdbNetworkRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.IOdbNetwork, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createOdbNetwork( - request: protos.google.cloud.oracledatabase.v1.ICreateOdbNetworkRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.ICreateOdbNetworkRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IOdbNetwork, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createOdbNetwork( - request: protos.google.cloud.oracledatabase.v1.ICreateOdbNetworkRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.ICreateOdbNetworkRequest, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IOdbNetwork, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createOdbNetwork( - request?: protos.google.cloud.oracledatabase.v1.ICreateOdbNetworkRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.oracledatabase.v1.ICreateOdbNetworkRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IOdbNetwork, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IOdbNetwork, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.IOdbNetwork, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IOdbNetwork, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createOdbNetwork response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createOdbNetwork request %j', request); - return this.innerApiCalls.createOdbNetwork(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createOdbNetwork response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createOdbNetwork(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.oracledatabase.v1.IOdbNetwork, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createOdbNetwork response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createOdbNetwork()`. - * @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/oracle_database.create_odb_network.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateOdbNetwork_async - */ - async checkCreateOdbNetworkProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createOdbNetwork()`. + * @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/oracle_database.create_odb_network.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateOdbNetwork_async + */ + async checkCreateOdbNetworkProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.oracledatabase.v1.OdbNetwork, + protos.google.cloud.oracledatabase.v1.OperationMetadata + > + > { this._log.info('createOdbNetwork long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createOdbNetwork, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createOdbNetwork, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.oracledatabase.v1.OdbNetwork, + protos.google.cloud.oracledatabase.v1.OperationMetadata + >; } -/** - * Deletes a single ODB Network. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the resource in the following format: - * projects/{project}/locations/{location}/odbNetworks/{odb_network}. - * @param {string} [request.requestId] - * Optional. An optional ID to identify the request. This value is used to - * identify duplicate requests. If you make a request with the same request ID - * and the original request is still in progress or completed, the server - * ignores the second request. This prevents clients from - * accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/oracle_database.delete_odb_network.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteOdbNetwork_async - */ + /** + * Deletes a single ODB Network. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the resource in the following format: + * projects/{project}/locations/{location}/odbNetworks/{odb_network}. + * @param {string} [request.requestId] + * Optional. An optional ID to identify the request. This value is used to + * identify duplicate requests. If you make a request with the same request ID + * and the original request is still in progress or completed, the server + * ignores the second request. This prevents clients from + * accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/oracle_database.delete_odb_network.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteOdbNetwork_async + */ deleteOdbNetwork( - request?: protos.google.cloud.oracledatabase.v1.IDeleteOdbNetworkRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.IDeleteOdbNetworkRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteOdbNetwork( - request: protos.google.cloud.oracledatabase.v1.IDeleteOdbNetworkRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IDeleteOdbNetworkRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteOdbNetwork( - request: protos.google.cloud.oracledatabase.v1.IDeleteOdbNetworkRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IDeleteOdbNetworkRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteOdbNetwork( - request?: protos.google.cloud.oracledatabase.v1.IDeleteOdbNetworkRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.oracledatabase.v1.IDeleteOdbNetworkRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteOdbNetwork response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteOdbNetwork request %j', request); - return this.innerApiCalls.deleteOdbNetwork(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteOdbNetwork response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteOdbNetwork(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteOdbNetwork response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteOdbNetwork()`. - * @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/oracle_database.delete_odb_network.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteOdbNetwork_async - */ - async checkDeleteOdbNetworkProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteOdbNetwork()`. + * @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/oracle_database.delete_odb_network.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteOdbNetwork_async + */ + async checkDeleteOdbNetworkProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.oracledatabase.v1.OperationMetadata + > + > { this._log.info('deleteOdbNetwork long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteOdbNetwork, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteOdbNetwork, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.oracledatabase.v1.OperationMetadata + >; } -/** - * Creates a new ODB Subnet in a given ODB Network. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for the OdbSubnet in the following format: - * projects/{project}/locations/{location}/odbNetworks/{odb_network}. - * @param {string} request.odbSubnetId - * Required. The ID of the OdbSubnet to create. This value is restricted - * to (^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$) and must be a maximum of 63 - * characters in length. The value must start with a letter and end with - * a letter or a number. - * @param {google.cloud.oracledatabase.v1.OdbSubnet} request.odbSubnet - * Required. Details of the OdbSubnet instance to create. - * @param {string} [request.requestId] - * Optional. An optional ID to identify the request. This value is used to - * identify duplicate requests. If you make a request with the same request ID - * and the original request is still in progress or completed, the server - * ignores the second request. This prevents clients from - * accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/oracle_database.create_odb_subnet.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateOdbSubnet_async - */ + /** + * Creates a new ODB Subnet in a given ODB Network. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for the OdbSubnet in the following format: + * projects/{project}/locations/{location}/odbNetworks/{odb_network}. + * @param {string} request.odbSubnetId + * Required. The ID of the OdbSubnet to create. This value is restricted + * to (^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$) and must be a maximum of 63 + * characters in length. The value must start with a letter and end with + * a letter or a number. + * @param {google.cloud.oracledatabase.v1.OdbSubnet} request.odbSubnet + * Required. Details of the OdbSubnet instance to create. + * @param {string} [request.requestId] + * Optional. An optional ID to identify the request. This value is used to + * identify duplicate requests. If you make a request with the same request ID + * and the original request is still in progress or completed, the server + * ignores the second request. This prevents clients from + * accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/oracle_database.create_odb_subnet.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateOdbSubnet_async + */ createOdbSubnet( - request?: protos.google.cloud.oracledatabase.v1.ICreateOdbSubnetRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.ICreateOdbSubnetRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.IOdbSubnet, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createOdbSubnet( - request: protos.google.cloud.oracledatabase.v1.ICreateOdbSubnetRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.ICreateOdbSubnetRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IOdbSubnet, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createOdbSubnet( - request: protos.google.cloud.oracledatabase.v1.ICreateOdbSubnetRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.ICreateOdbSubnetRequest, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IOdbSubnet, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createOdbSubnet( - request?: protos.google.cloud.oracledatabase.v1.ICreateOdbSubnetRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.oracledatabase.v1.ICreateOdbSubnetRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IOdbSubnet, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IOdbSubnet, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.IOdbSubnet, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IOdbSubnet, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createOdbSubnet response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createOdbSubnet request %j', request); - return this.innerApiCalls.createOdbSubnet(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createOdbSubnet response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createOdbSubnet(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.oracledatabase.v1.IOdbSubnet, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createOdbSubnet response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createOdbSubnet()`. - * @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/oracle_database.create_odb_subnet.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateOdbSubnet_async - */ - async checkCreateOdbSubnetProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createOdbSubnet()`. + * @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/oracle_database.create_odb_subnet.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateOdbSubnet_async + */ + async checkCreateOdbSubnetProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.oracledatabase.v1.OdbSubnet, + protos.google.cloud.oracledatabase.v1.OperationMetadata + > + > { this._log.info('createOdbSubnet long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createOdbSubnet, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createOdbSubnet, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.oracledatabase.v1.OdbSubnet, + protos.google.cloud.oracledatabase.v1.OperationMetadata + >; } -/** - * Deletes a single ODB Subnet. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the resource in the following format: - * projects/{project}/locations/{region}/odbNetworks/{odb_network}/odbSubnets/{odb_subnet}. - * @param {string} [request.requestId] - * Optional. An optional ID to identify the request. This value is used to - * identify duplicate requests. If you make a request with the same request ID - * and the original request is still in progress or completed, the server - * ignores the second request. This prevents clients from - * accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/oracle_database.delete_odb_subnet.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteOdbSubnet_async - */ + /** + * Deletes a single ODB Subnet. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the resource in the following format: + * projects/{project}/locations/{region}/odbNetworks/{odb_network}/odbSubnets/{odb_subnet}. + * @param {string} [request.requestId] + * Optional. An optional ID to identify the request. This value is used to + * identify duplicate requests. If you make a request with the same request ID + * and the original request is still in progress or completed, the server + * ignores the second request. This prevents clients from + * accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/oracle_database.delete_odb_subnet.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteOdbSubnet_async + */ deleteOdbSubnet( - request?: protos.google.cloud.oracledatabase.v1.IDeleteOdbSubnetRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.IDeleteOdbSubnetRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteOdbSubnet( - request: protos.google.cloud.oracledatabase.v1.IDeleteOdbSubnetRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IDeleteOdbSubnetRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteOdbSubnet( - request: protos.google.cloud.oracledatabase.v1.IDeleteOdbSubnetRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IDeleteOdbSubnetRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteOdbSubnet( - request?: protos.google.cloud.oracledatabase.v1.IDeleteOdbSubnetRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.oracledatabase.v1.IDeleteOdbSubnetRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteOdbSubnet response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteOdbSubnet request %j', request); - return this.innerApiCalls.deleteOdbSubnet(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteOdbSubnet response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteOdbSubnet(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteOdbSubnet response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteOdbSubnet()`. - * @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/oracle_database.delete_odb_subnet.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteOdbSubnet_async - */ - async checkDeleteOdbSubnetProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteOdbSubnet()`. + * @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/oracle_database.delete_odb_subnet.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteOdbSubnet_async + */ + async checkDeleteOdbSubnetProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.oracledatabase.v1.OperationMetadata + > + > { this._log.info('deleteOdbSubnet long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteOdbSubnet, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteOdbSubnet, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.oracledatabase.v1.OperationMetadata + >; } -/** - * Creates a new Exadb (Exascale) VM Cluster resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The value for parent of the ExadbVmCluster in the following - * format: projects/{project}/locations/{location}. - * @param {string} request.exadbVmClusterId - * Required. The ID of the ExadbVmCluster to create. This value is - * restricted to (^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$) and must be a maximum of - * 63 characters in length. The value must start with a letter and end with a - * letter or a number. - * @param {google.cloud.oracledatabase.v1.ExadbVmCluster} request.exadbVmCluster - * Required. The resource being created. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/oracle_database.create_exadb_vm_cluster.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateExadbVmCluster_async - */ + /** + * Creates a new Exadb (Exascale) VM Cluster resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The value for parent of the ExadbVmCluster in the following + * format: projects/{project}/locations/{location}. + * @param {string} request.exadbVmClusterId + * Required. The ID of the ExadbVmCluster to create. This value is + * restricted to (^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$) and must be a maximum of + * 63 characters in length. The value must start with a letter and end with a + * letter or a number. + * @param {google.cloud.oracledatabase.v1.ExadbVmCluster} request.exadbVmCluster + * Required. The resource being created. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/oracle_database.create_exadb_vm_cluster.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateExadbVmCluster_async + */ createExadbVmCluster( - request?: protos.google.cloud.oracledatabase.v1.ICreateExadbVmClusterRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.ICreateExadbVmClusterRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createExadbVmCluster( - request: protos.google.cloud.oracledatabase.v1.ICreateExadbVmClusterRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.ICreateExadbVmClusterRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createExadbVmCluster( - request: protos.google.cloud.oracledatabase.v1.ICreateExadbVmClusterRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.ICreateExadbVmClusterRequest, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createExadbVmCluster( - request?: protos.google.cloud.oracledatabase.v1.ICreateExadbVmClusterRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.oracledatabase.v1.ICreateExadbVmClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createExadbVmCluster response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createExadbVmCluster request %j', request); - return this.innerApiCalls.createExadbVmCluster(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createExadbVmCluster response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createExadbVmCluster(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createExadbVmCluster response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createExadbVmCluster()`. - * @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/oracle_database.create_exadb_vm_cluster.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateExadbVmCluster_async - */ - async checkCreateExadbVmClusterProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createExadbVmCluster()`. + * @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/oracle_database.create_exadb_vm_cluster.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateExadbVmCluster_async + */ + async checkCreateExadbVmClusterProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.oracledatabase.v1.ExadbVmCluster, + protos.google.cloud.oracledatabase.v1.OperationMetadata + > + > { this._log.info('createExadbVmCluster long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createExadbVmCluster, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createExadbVmCluster, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.oracledatabase.v1.ExadbVmCluster, + protos.google.cloud.oracledatabase.v1.OperationMetadata + >; } -/** - * Deletes a single Exadb (Exascale) VM Cluster. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the ExadbVmCluster in the following format: - * projects/{project}/locations/{location}/exadbVmClusters/{exadb_vm_cluster}. - * @param {string} [request.requestId] - * Optional. An optional ID to identify the request. This value is used to - * identify duplicate requests. If you make a request with the same request ID - * and the original request is still in progress or completed, the server - * ignores the second request. This prevents clients from - * accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/oracle_database.delete_exadb_vm_cluster.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteExadbVmCluster_async - */ + /** + * Deletes a single Exadb (Exascale) VM Cluster. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the ExadbVmCluster in the following format: + * projects/{project}/locations/{location}/exadbVmClusters/{exadb_vm_cluster}. + * @param {string} [request.requestId] + * Optional. An optional ID to identify the request. This value is used to + * identify duplicate requests. If you make a request with the same request ID + * and the original request is still in progress or completed, the server + * ignores the second request. This prevents clients from + * accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/oracle_database.delete_exadb_vm_cluster.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteExadbVmCluster_async + */ deleteExadbVmCluster( - request?: protos.google.cloud.oracledatabase.v1.IDeleteExadbVmClusterRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.IDeleteExadbVmClusterRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteExadbVmCluster( - request: protos.google.cloud.oracledatabase.v1.IDeleteExadbVmClusterRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IDeleteExadbVmClusterRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteExadbVmCluster( - request: protos.google.cloud.oracledatabase.v1.IDeleteExadbVmClusterRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IDeleteExadbVmClusterRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteExadbVmCluster( - request?: protos.google.cloud.oracledatabase.v1.IDeleteExadbVmClusterRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.oracledatabase.v1.IDeleteExadbVmClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteExadbVmCluster response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteExadbVmCluster request %j', request); - return this.innerApiCalls.deleteExadbVmCluster(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteExadbVmCluster response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteExadbVmCluster(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteExadbVmCluster response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteExadbVmCluster()`. - * @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/oracle_database.delete_exadb_vm_cluster.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteExadbVmCluster_async - */ - async checkDeleteExadbVmClusterProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteExadbVmCluster()`. + * @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/oracle_database.delete_exadb_vm_cluster.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteExadbVmCluster_async + */ + async checkDeleteExadbVmClusterProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.oracledatabase.v1.OperationMetadata + > + > { this._log.info('deleteExadbVmCluster long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteExadbVmCluster, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteExadbVmCluster, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.oracledatabase.v1.OperationMetadata + >; } -/** - * Updates a single Exadb (Exascale) VM Cluster. To add virtual machines to - * existing exadb vm cluster, only pass the node count. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. A mask specifying which fields in th VM Cluster should be - * updated. A field specified in the mask is overwritten. If a mask isn't - * provided then all the fields in the VM Cluster are overwritten. - * @param {google.cloud.oracledatabase.v1.ExadbVmCluster} request.exadbVmCluster - * Required. The resource being updated. - * @param {string} [request.requestId] - * Optional. An optional ID to identify the request. This value is used to - * identify duplicate requests. If you make a request with the same request ID - * and the original request is still in progress or completed, the server - * ignores the second request. This prevents clients from - * accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/oracle_database.update_exadb_vm_cluster.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_UpdateExadbVmCluster_async - */ + /** + * Updates a single Exadb (Exascale) VM Cluster. To add virtual machines to + * existing exadb vm cluster, only pass the node count. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. A mask specifying which fields in th VM Cluster should be + * updated. A field specified in the mask is overwritten. If a mask isn't + * provided then all the fields in the VM Cluster are overwritten. + * @param {google.cloud.oracledatabase.v1.ExadbVmCluster} request.exadbVmCluster + * Required. The resource being updated. + * @param {string} [request.requestId] + * Optional. An optional ID to identify the request. This value is used to + * identify duplicate requests. If you make a request with the same request ID + * and the original request is still in progress or completed, the server + * ignores the second request. This prevents clients from + * accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/oracle_database.update_exadb_vm_cluster.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_UpdateExadbVmCluster_async + */ updateExadbVmCluster( - request?: protos.google.cloud.oracledatabase.v1.IUpdateExadbVmClusterRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.IUpdateExadbVmClusterRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateExadbVmCluster( - request: protos.google.cloud.oracledatabase.v1.IUpdateExadbVmClusterRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IUpdateExadbVmClusterRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateExadbVmCluster( - request: protos.google.cloud.oracledatabase.v1.IUpdateExadbVmClusterRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IUpdateExadbVmClusterRequest, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateExadbVmCluster( - request?: protos.google.cloud.oracledatabase.v1.IUpdateExadbVmClusterRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.oracledatabase.v1.IUpdateExadbVmClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'exadb_vm_cluster.name': request.exadbVmCluster!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'exadb_vm_cluster.name': request.exadbVmCluster!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateExadbVmCluster response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateExadbVmCluster request %j', request); - return this.innerApiCalls.updateExadbVmCluster(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateExadbVmCluster response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateExadbVmCluster(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateExadbVmCluster response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateExadbVmCluster()`. - * @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/oracle_database.update_exadb_vm_cluster.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_UpdateExadbVmCluster_async - */ - async checkUpdateExadbVmClusterProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateExadbVmCluster()`. + * @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/oracle_database.update_exadb_vm_cluster.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_UpdateExadbVmCluster_async + */ + async checkUpdateExadbVmClusterProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.oracledatabase.v1.ExadbVmCluster, + protos.google.cloud.oracledatabase.v1.OperationMetadata + > + > { this._log.info('updateExadbVmCluster long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.updateExadbVmCluster, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateExadbVmCluster, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.oracledatabase.v1.ExadbVmCluster, + protos.google.cloud.oracledatabase.v1.OperationMetadata + >; } -/** - * Removes virtual machines from an existing exadb vm cluster. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the ExadbVmCluster in the following format: - * projects/{project}/locations/{location}/exadbVmClusters/{exadb_vm_cluster}. - * @param {string} [request.requestId] - * Optional. An optional ID to identify the request. This value is used to - * identify duplicate requests. If you make a request with the same request ID - * and the original request is still in progress or completed, the server - * ignores the second request. This prevents clients from - * accidentally creating duplicate commitments. - * - * 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.hostnames - * Required. The list of host names of db nodes to be removed from the - * ExadbVmCluster. - * @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/oracle_database.remove_virtual_machine_exadb_vm_cluster.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_RemoveVirtualMachineExadbVmCluster_async - */ + /** + * Removes virtual machines from an existing exadb vm cluster. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the ExadbVmCluster in the following format: + * projects/{project}/locations/{location}/exadbVmClusters/{exadb_vm_cluster}. + * @param {string} [request.requestId] + * Optional. An optional ID to identify the request. This value is used to + * identify duplicate requests. If you make a request with the same request ID + * and the original request is still in progress or completed, the server + * ignores the second request. This prevents clients from + * accidentally creating duplicate commitments. + * + * 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.hostnames + * Required. The list of host names of db nodes to be removed from the + * ExadbVmCluster. + * @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/oracle_database.remove_virtual_machine_exadb_vm_cluster.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_RemoveVirtualMachineExadbVmCluster_async + */ removeVirtualMachineExadbVmCluster( - request?: protos.google.cloud.oracledatabase.v1.IRemoveVirtualMachineExadbVmClusterRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.IRemoveVirtualMachineExadbVmClusterRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; removeVirtualMachineExadbVmCluster( - request: protos.google.cloud.oracledatabase.v1.IRemoveVirtualMachineExadbVmClusterRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IRemoveVirtualMachineExadbVmClusterRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; removeVirtualMachineExadbVmCluster( - request: protos.google.cloud.oracledatabase.v1.IRemoveVirtualMachineExadbVmClusterRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IRemoveVirtualMachineExadbVmClusterRequest, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; removeVirtualMachineExadbVmCluster( - request?: protos.google.cloud.oracledatabase.v1.IRemoveVirtualMachineExadbVmClusterRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.oracledatabase.v1.IRemoveVirtualMachineExadbVmClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { - this._log.info('removeVirtualMachineExadbVmCluster response %j', rawResponse); + this._log.info( + 'removeVirtualMachineExadbVmCluster response %j', + rawResponse, + ); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('removeVirtualMachineExadbVmCluster request %j', request); - return this.innerApiCalls.removeVirtualMachineExadbVmCluster(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('removeVirtualMachineExadbVmCluster response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .removeVirtualMachineExadbVmCluster(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info( + 'removeVirtualMachineExadbVmCluster response %j', + rawResponse, + ); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `removeVirtualMachineExadbVmCluster()`. - * @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/oracle_database.remove_virtual_machine_exadb_vm_cluster.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_RemoveVirtualMachineExadbVmCluster_async - */ - async checkRemoveVirtualMachineExadbVmClusterProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `removeVirtualMachineExadbVmCluster()`. + * @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/oracle_database.remove_virtual_machine_exadb_vm_cluster.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_RemoveVirtualMachineExadbVmCluster_async + */ + async checkRemoveVirtualMachineExadbVmClusterProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.oracledatabase.v1.ExadbVmCluster, + protos.google.cloud.oracledatabase.v1.OperationMetadata + > + > { this._log.info('removeVirtualMachineExadbVmCluster long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.removeVirtualMachineExadbVmCluster, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.removeVirtualMachineExadbVmCluster, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.oracledatabase.v1.ExadbVmCluster, + protos.google.cloud.oracledatabase.v1.OperationMetadata + >; } -/** - * Creates a new ExascaleDB Storage Vault resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The value for parent of the ExascaleDbStorageVault in the - * following format: projects/{project}/locations/{location}. - * @param {string} request.exascaleDbStorageVaultId - * Required. The ID of the ExascaleDbStorageVault to create. This value is - * restricted to (^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$) and must be a maximum of - * 63 characters in length. The value must start with a letter and end with a - * letter or a number. - * @param {google.cloud.oracledatabase.v1.ExascaleDbStorageVault} request.exascaleDbStorageVault - * Required. The resource being created. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/oracle_database.create_exascale_db_storage_vault.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateExascaleDbStorageVault_async - */ + /** + * Creates a new ExascaleDB Storage Vault resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The value for parent of the ExascaleDbStorageVault in the + * following format: projects/{project}/locations/{location}. + * @param {string} request.exascaleDbStorageVaultId + * Required. The ID of the ExascaleDbStorageVault to create. This value is + * restricted to (^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$) and must be a maximum of + * 63 characters in length. The value must start with a letter and end with a + * letter or a number. + * @param {google.cloud.oracledatabase.v1.ExascaleDbStorageVault} request.exascaleDbStorageVault + * Required. The resource being created. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/oracle_database.create_exascale_db_storage_vault.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateExascaleDbStorageVault_async + */ createExascaleDbStorageVault( - request?: protos.google.cloud.oracledatabase.v1.ICreateExascaleDbStorageVaultRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.ICreateExascaleDbStorageVaultRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createExascaleDbStorageVault( - request: protos.google.cloud.oracledatabase.v1.ICreateExascaleDbStorageVaultRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.ICreateExascaleDbStorageVaultRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createExascaleDbStorageVault( - request: protos.google.cloud.oracledatabase.v1.ICreateExascaleDbStorageVaultRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.ICreateExascaleDbStorageVaultRequest, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createExascaleDbStorageVault( - request?: protos.google.cloud.oracledatabase.v1.ICreateExascaleDbStorageVaultRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.oracledatabase.v1.ICreateExascaleDbStorageVaultRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { - this._log.info('createExascaleDbStorageVault response %j', rawResponse); + this._log.info( + 'createExascaleDbStorageVault response %j', + rawResponse, + ); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createExascaleDbStorageVault request %j', request); - return this.innerApiCalls.createExascaleDbStorageVault(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createExascaleDbStorageVault response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createExascaleDbStorageVault(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info( + 'createExascaleDbStorageVault response %j', + rawResponse, + ); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createExascaleDbStorageVault()`. - * @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/oracle_database.create_exascale_db_storage_vault.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateExascaleDbStorageVault_async - */ - async checkCreateExascaleDbStorageVaultProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createExascaleDbStorageVault()`. + * @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/oracle_database.create_exascale_db_storage_vault.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateExascaleDbStorageVault_async + */ + async checkCreateExascaleDbStorageVaultProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault, + protos.google.cloud.oracledatabase.v1.OperationMetadata + > + > { this._log.info('createExascaleDbStorageVault long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createExascaleDbStorageVault, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createExascaleDbStorageVault, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault, + protos.google.cloud.oracledatabase.v1.OperationMetadata + >; } -/** - * Deletes a single ExascaleDB Storage Vault. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the ExascaleDbStorageVault in the following format: - * projects/{project}/locations/{location}/exascaleDbStorageVaults/{exascale_db_storage_vault}. - * @param {string} [request.requestId] - * Optional. An optional ID to identify the request. This value is used to - * identify duplicate requests. If you make a request with the same request ID - * and the original request is still in progress or completed, the server - * ignores the second request. This prevents clients from - * accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/oracle_database.delete_exascale_db_storage_vault.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteExascaleDbStorageVault_async - */ + /** + * Deletes a single ExascaleDB Storage Vault. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the ExascaleDbStorageVault in the following format: + * projects/{project}/locations/{location}/exascaleDbStorageVaults/{exascale_db_storage_vault}. + * @param {string} [request.requestId] + * Optional. An optional ID to identify the request. This value is used to + * identify duplicate requests. If you make a request with the same request ID + * and the original request is still in progress or completed, the server + * ignores the second request. This prevents clients from + * accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/oracle_database.delete_exascale_db_storage_vault.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteExascaleDbStorageVault_async + */ deleteExascaleDbStorageVault( - request?: protos.google.cloud.oracledatabase.v1.IDeleteExascaleDbStorageVaultRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.IDeleteExascaleDbStorageVaultRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteExascaleDbStorageVault( - request: protos.google.cloud.oracledatabase.v1.IDeleteExascaleDbStorageVaultRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IDeleteExascaleDbStorageVaultRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteExascaleDbStorageVault( - request: protos.google.cloud.oracledatabase.v1.IDeleteExascaleDbStorageVaultRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IDeleteExascaleDbStorageVaultRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteExascaleDbStorageVault( - request?: protos.google.cloud.oracledatabase.v1.IDeleteExascaleDbStorageVaultRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.oracledatabase.v1.IDeleteExascaleDbStorageVaultRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { - this._log.info('deleteExascaleDbStorageVault response %j', rawResponse); + this._log.info( + 'deleteExascaleDbStorageVault response %j', + rawResponse, + ); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteExascaleDbStorageVault request %j', request); - return this.innerApiCalls.deleteExascaleDbStorageVault(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteExascaleDbStorageVault response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteExascaleDbStorageVault(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info( + 'deleteExascaleDbStorageVault response %j', + rawResponse, + ); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteExascaleDbStorageVault()`. - * @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/oracle_database.delete_exascale_db_storage_vault.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteExascaleDbStorageVault_async - */ - async checkDeleteExascaleDbStorageVaultProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteExascaleDbStorageVault()`. + * @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/oracle_database.delete_exascale_db_storage_vault.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteExascaleDbStorageVault_async + */ + async checkDeleteExascaleDbStorageVaultProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.oracledatabase.v1.OperationMetadata + > + > { this._log.info('deleteExascaleDbStorageVault long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteExascaleDbStorageVault, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteExascaleDbStorageVault, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.oracledatabase.v1.OperationMetadata + >; } -/** - * Creates a new DbSystem in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The value for parent of the DbSystem in the following format: - * projects/{project}/locations/{location}. - * @param {string} request.dbSystemId - * Required. The ID of the DbSystem to create. This value is - * restricted to (^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$) and must be a maximum of - * 63 characters in length. The value must start with a letter and end with a - * letter or a number. - * @param {google.cloud.oracledatabase.v1.DbSystem} request.dbSystem - * Required. The resource being created. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/oracle_database.create_db_system.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateDbSystem_async - */ + /** + * Creates a new DbSystem in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The value for parent of the DbSystem in the following format: + * projects/{project}/locations/{location}. + * @param {string} request.dbSystemId + * Required. The ID of the DbSystem to create. This value is + * restricted to (^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$) and must be a maximum of + * 63 characters in length. The value must start with a letter and end with a + * letter or a number. + * @param {google.cloud.oracledatabase.v1.DbSystem} request.dbSystem + * Required. The resource being created. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/oracle_database.create_db_system.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateDbSystem_async + */ createDbSystem( - request?: protos.google.cloud.oracledatabase.v1.ICreateDbSystemRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.ICreateDbSystemRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.IDbSystem, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createDbSystem( - request: protos.google.cloud.oracledatabase.v1.ICreateDbSystemRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.ICreateDbSystemRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IDbSystem, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createDbSystem( - request: protos.google.cloud.oracledatabase.v1.ICreateDbSystemRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.ICreateDbSystemRequest, + callback: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IDbSystem, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createDbSystem( - request?: protos.google.cloud.oracledatabase.v1.ICreateDbSystemRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.oracledatabase.v1.ICreateDbSystemRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IDbSystem, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IDbSystem, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.oracledatabase.v1.IDbSystem, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.oracledatabase.v1.IDbSystem, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createDbSystem response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createDbSystem request %j', request); - return this.innerApiCalls.createDbSystem(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createDbSystem response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createDbSystem(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.oracledatabase.v1.IDbSystem, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createDbSystem response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createDbSystem()`. - * @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/oracle_database.create_db_system.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateDbSystem_async - */ - async checkCreateDbSystemProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createDbSystem()`. + * @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/oracle_database.create_db_system.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_CreateDbSystem_async + */ + async checkCreateDbSystemProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.oracledatabase.v1.DbSystem, + protos.google.cloud.oracledatabase.v1.OperationMetadata + > + > { this._log.info('createDbSystem long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.createDbSystem, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createDbSystem, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.oracledatabase.v1.DbSystem, + protos.google.cloud.oracledatabase.v1.OperationMetadata + >; } -/** - * Deletes a single DbSystem. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the DbSystem in the following format: - * projects/{project}/locations/{location}/dbSystems/{db_system}. - * @param {string} [request.requestId] - * Optional. An optional ID to identify the request. This value is used to - * identify duplicate requests. If you make a request with the same request ID - * and the original request is still in progress or completed, the server - * ignores the second request. This prevents clients from - * accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/oracle_database.delete_db_system.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteDbSystem_async - */ + /** + * Deletes a single DbSystem. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the DbSystem in the following format: + * projects/{project}/locations/{location}/dbSystems/{db_system}. + * @param {string} [request.requestId] + * Optional. An optional ID to identify the request. This value is used to + * identify duplicate requests. If you make a request with the same request ID + * and the original request is still in progress or completed, the server + * ignores the second request. This prevents clients from + * accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/oracle_database.delete_db_system.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteDbSystem_async + */ deleteDbSystem( - request?: protos.google.cloud.oracledatabase.v1.IDeleteDbSystemRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.oracledatabase.v1.IDeleteDbSystemRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteDbSystem( - request: protos.google.cloud.oracledatabase.v1.IDeleteDbSystemRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IDeleteDbSystemRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteDbSystem( - request: protos.google.cloud.oracledatabase.v1.IDeleteDbSystemRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.oracledatabase.v1.IDeleteDbSystemRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteDbSystem( - request?: protos.google.cloud.oracledatabase.v1.IDeleteDbSystemRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.oracledatabase.v1.IDeleteDbSystemRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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 ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteDbSystem response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteDbSystem request %j', request); - return this.innerApiCalls.deleteDbSystem(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteDbSystem response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteDbSystem(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteDbSystem response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteDbSystem()`. - * @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/oracle_database.delete_db_system.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteDbSystem_async - */ - async checkDeleteDbSystemProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteDbSystem()`. + * @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/oracle_database.delete_db_system.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_DeleteDbSystem_async + */ + async checkDeleteDbSystemProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.oracledatabase.v1.OperationMetadata + > + > { this._log.info('deleteDbSystem long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + 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.deleteDbSystem, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists Exadata Infrastructures in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for CloudExadataInfrastructure in the following - * format: projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 Exadata infrastructures will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. - * @param {string} [request.orderBy] - * Optional. An expression for ordering the results of the request. - * @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 Array of {@link protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure|CloudExadataInfrastructure}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listCloudExadataInfrastructuresAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteDbSystem, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.oracledatabase.v1.OperationMetadata + >; + } + /** + * Lists Exadata Infrastructures in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for CloudExadataInfrastructure in the following + * format: projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 Exadata infrastructures will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. + * @param {string} [request.orderBy] + * Optional. An expression for ordering the results of the request. + * @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 Array of {@link protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure|CloudExadataInfrastructure}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listCloudExadataInfrastructuresAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCloudExadataInfrastructures( - request?: protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure[], - protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresRequest|null, - protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresResponse - ]>; + request?: protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure[], + protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresRequest | null, + protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresResponse, + ] + >; listCloudExadataInfrastructures( - request: protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresRequest, - protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure>): void; + request: protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresRequest, + | protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure + >, + ): void; listCloudExadataInfrastructures( - request: protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresRequest, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresRequest, - protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure>): void; + request: protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresRequest, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresRequest, + | protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure + >, + ): void; listCloudExadataInfrastructures( - request?: protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresRequest, - protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure>, - callback?: PaginationCallback< + request?: protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresRequest, - protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure>): - Promise<[ - protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure[], - protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresRequest|null, - protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresResponse - ]>|void { + | protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure + >, + callback?: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresRequest, + | protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure[], + protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresRequest | null, + protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresRequest, - protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresRequest, + | protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listCloudExadataInfrastructures values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -4799,208 +7262,239 @@ export class OracleDatabaseClient { this._log.info('listCloudExadataInfrastructures request %j', request); return this.innerApiCalls .listCloudExadataInfrastructures(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure[], - protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresRequest|null, - protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresResponse - ]) => { - this._log.info('listCloudExadataInfrastructures values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure[], + protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresRequest | null, + protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresResponse, + ]) => { + this._log.info('listCloudExadataInfrastructures values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listCloudExadataInfrastructures`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for CloudExadataInfrastructure in the following - * format: projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 Exadata infrastructures will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. - * @param {string} [request.orderBy] - * Optional. An expression for ordering the results of the request. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure|CloudExadataInfrastructure} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listCloudExadataInfrastructuresAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listCloudExadataInfrastructures`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for CloudExadataInfrastructure in the following + * format: projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 Exadata infrastructures will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. + * @param {string} [request.orderBy] + * Optional. An expression for ordering the results of the request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure|CloudExadataInfrastructure} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listCloudExadataInfrastructuresAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCloudExadataInfrastructuresStream( - request?: protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listCloudExadataInfrastructures']; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = + this._defaults['listCloudExadataInfrastructures']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listCloudExadataInfrastructures stream %j', request); return this.descriptors.page.listCloudExadataInfrastructures.createStream( this.innerApiCalls.listCloudExadataInfrastructures as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listCloudExadataInfrastructures`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for CloudExadataInfrastructure in the following - * format: projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 Exadata infrastructures will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. - * @param {string} [request.orderBy] - * Optional. An expression for ordering the results of the request. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure|CloudExadataInfrastructure}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.list_cloud_exadata_infrastructures.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_ListCloudExadataInfrastructures_async - */ + /** + * Equivalent to `listCloudExadataInfrastructures`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for CloudExadataInfrastructure in the following + * format: projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 Exadata infrastructures will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. + * @param {string} [request.orderBy] + * Optional. An expression for ordering the results of the request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure|CloudExadataInfrastructure}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.list_cloud_exadata_infrastructures.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_ListCloudExadataInfrastructures_async + */ listCloudExadataInfrastructuresAsync( - request?: protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.oracledatabase.v1.IListCloudExadataInfrastructuresRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listCloudExadataInfrastructures']; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = + this._defaults['listCloudExadataInfrastructures']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listCloudExadataInfrastructures iterate %j', request); return this.descriptors.page.listCloudExadataInfrastructures.asyncIterate( this.innerApiCalls['listCloudExadataInfrastructures'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists the VM Clusters in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent in the following format: - * projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The number of VM clusters to return. - * If unspecified, at most 50 VM clusters will be returned. - * The maximum value is 1,000. - * @param {string} [request.pageToken] - * Optional. A token identifying the page of results the server returns. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. - * @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 Array of {@link protos.google.cloud.oracledatabase.v1.CloudVmCluster|CloudVmCluster}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listCloudVmClustersAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists the VM Clusters in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent in the following format: + * projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The number of VM clusters to return. + * If unspecified, at most 50 VM clusters will be returned. + * The maximum value is 1,000. + * @param {string} [request.pageToken] + * Optional. A token identifying the page of results the server returns. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. + * @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 Array of {@link protos.google.cloud.oracledatabase.v1.CloudVmCluster|CloudVmCluster}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listCloudVmClustersAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCloudVmClusters( - request?: protos.google.cloud.oracledatabase.v1.IListCloudVmClustersRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.ICloudVmCluster[], - protos.google.cloud.oracledatabase.v1.IListCloudVmClustersRequest|null, - protos.google.cloud.oracledatabase.v1.IListCloudVmClustersResponse - ]>; + request?: protos.google.cloud.oracledatabase.v1.IListCloudVmClustersRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.ICloudVmCluster[], + protos.google.cloud.oracledatabase.v1.IListCloudVmClustersRequest | null, + protos.google.cloud.oracledatabase.v1.IListCloudVmClustersResponse, + ] + >; listCloudVmClusters( - request: protos.google.cloud.oracledatabase.v1.IListCloudVmClustersRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListCloudVmClustersRequest, - protos.google.cloud.oracledatabase.v1.IListCloudVmClustersResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.ICloudVmCluster>): void; + request: protos.google.cloud.oracledatabase.v1.IListCloudVmClustersRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListCloudVmClustersRequest, + | protos.google.cloud.oracledatabase.v1.IListCloudVmClustersResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.ICloudVmCluster + >, + ): void; listCloudVmClusters( - request: protos.google.cloud.oracledatabase.v1.IListCloudVmClustersRequest, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListCloudVmClustersRequest, - protos.google.cloud.oracledatabase.v1.IListCloudVmClustersResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.ICloudVmCluster>): void; + request: protos.google.cloud.oracledatabase.v1.IListCloudVmClustersRequest, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListCloudVmClustersRequest, + | protos.google.cloud.oracledatabase.v1.IListCloudVmClustersResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.ICloudVmCluster + >, + ): void; listCloudVmClusters( - request?: protos.google.cloud.oracledatabase.v1.IListCloudVmClustersRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListCloudVmClustersRequest, - protos.google.cloud.oracledatabase.v1.IListCloudVmClustersResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.ICloudVmCluster>, - callback?: PaginationCallback< + request?: protos.google.cloud.oracledatabase.v1.IListCloudVmClustersRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.oracledatabase.v1.IListCloudVmClustersRequest, - protos.google.cloud.oracledatabase.v1.IListCloudVmClustersResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.ICloudVmCluster>): - Promise<[ - protos.google.cloud.oracledatabase.v1.ICloudVmCluster[], - protos.google.cloud.oracledatabase.v1.IListCloudVmClustersRequest|null, - protos.google.cloud.oracledatabase.v1.IListCloudVmClustersResponse - ]>|void { + | protos.google.cloud.oracledatabase.v1.IListCloudVmClustersResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.ICloudVmCluster + >, + callback?: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListCloudVmClustersRequest, + | protos.google.cloud.oracledatabase.v1.IListCloudVmClustersResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.ICloudVmCluster + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.ICloudVmCluster[], + protos.google.cloud.oracledatabase.v1.IListCloudVmClustersRequest | null, + protos.google.cloud.oracledatabase.v1.IListCloudVmClustersResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListCloudVmClustersRequest, - protos.google.cloud.oracledatabase.v1.IListCloudVmClustersResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.ICloudVmCluster>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListCloudVmClustersRequest, + | protos.google.cloud.oracledatabase.v1.IListCloudVmClustersResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.ICloudVmCluster + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listCloudVmClusters values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -5009,202 +7503,231 @@ export class OracleDatabaseClient { this._log.info('listCloudVmClusters request %j', request); return this.innerApiCalls .listCloudVmClusters(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.oracledatabase.v1.ICloudVmCluster[], - protos.google.cloud.oracledatabase.v1.IListCloudVmClustersRequest|null, - protos.google.cloud.oracledatabase.v1.IListCloudVmClustersResponse - ]) => { - this._log.info('listCloudVmClusters values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.oracledatabase.v1.ICloudVmCluster[], + protos.google.cloud.oracledatabase.v1.IListCloudVmClustersRequest | null, + protos.google.cloud.oracledatabase.v1.IListCloudVmClustersResponse, + ]) => { + this._log.info('listCloudVmClusters values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listCloudVmClusters`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent in the following format: - * projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The number of VM clusters to return. - * If unspecified, at most 50 VM clusters will be returned. - * The maximum value is 1,000. - * @param {string} [request.pageToken] - * Optional. A token identifying the page of results the server returns. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.CloudVmCluster|CloudVmCluster} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listCloudVmClustersAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listCloudVmClusters`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent in the following format: + * projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The number of VM clusters to return. + * If unspecified, at most 50 VM clusters will be returned. + * The maximum value is 1,000. + * @param {string} [request.pageToken] + * Optional. A token identifying the page of results the server returns. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.CloudVmCluster|CloudVmCluster} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listCloudVmClustersAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCloudVmClustersStream( - request?: protos.google.cloud.oracledatabase.v1.IListCloudVmClustersRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.oracledatabase.v1.IListCloudVmClustersRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listCloudVmClusters']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listCloudVmClusters stream %j', request); return this.descriptors.page.listCloudVmClusters.createStream( this.innerApiCalls.listCloudVmClusters as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listCloudVmClusters`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent in the following format: - * projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The number of VM clusters to return. - * If unspecified, at most 50 VM clusters will be returned. - * The maximum value is 1,000. - * @param {string} [request.pageToken] - * Optional. A token identifying the page of results the server returns. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.oracledatabase.v1.CloudVmCluster|CloudVmCluster}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.list_cloud_vm_clusters.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_ListCloudVmClusters_async - */ + /** + * Equivalent to `listCloudVmClusters`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent in the following format: + * projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The number of VM clusters to return. + * If unspecified, at most 50 VM clusters will be returned. + * The maximum value is 1,000. + * @param {string} [request.pageToken] + * Optional. A token identifying the page of results the server returns. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.oracledatabase.v1.CloudVmCluster|CloudVmCluster}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.list_cloud_vm_clusters.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_ListCloudVmClusters_async + */ listCloudVmClustersAsync( - request?: protos.google.cloud.oracledatabase.v1.IListCloudVmClustersRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.oracledatabase.v1.IListCloudVmClustersRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listCloudVmClusters']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listCloudVmClusters iterate %j', request); return this.descriptors.page.listCloudVmClusters.asyncIterate( this.innerApiCalls['listCloudVmClusters'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists the entitlements in a given project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for the entitlement in the following format: - * projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, a maximum of 50 entitlements will be returned. - * The maximum value is 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @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 Array of {@link protos.google.cloud.oracledatabase.v1.Entitlement|Entitlement}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listEntitlementsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists the entitlements in a given project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for the entitlement in the following format: + * projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, a maximum of 50 entitlements will be returned. + * The maximum value is 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @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 Array of {@link protos.google.cloud.oracledatabase.v1.Entitlement|Entitlement}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listEntitlementsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listEntitlements( - request?: protos.google.cloud.oracledatabase.v1.IListEntitlementsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.IEntitlement[], - protos.google.cloud.oracledatabase.v1.IListEntitlementsRequest|null, - protos.google.cloud.oracledatabase.v1.IListEntitlementsResponse - ]>; + request?: protos.google.cloud.oracledatabase.v1.IListEntitlementsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IEntitlement[], + protos.google.cloud.oracledatabase.v1.IListEntitlementsRequest | null, + protos.google.cloud.oracledatabase.v1.IListEntitlementsResponse, + ] + >; listEntitlements( - request: protos.google.cloud.oracledatabase.v1.IListEntitlementsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListEntitlementsRequest, - protos.google.cloud.oracledatabase.v1.IListEntitlementsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IEntitlement>): void; + request: protos.google.cloud.oracledatabase.v1.IListEntitlementsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListEntitlementsRequest, + | protos.google.cloud.oracledatabase.v1.IListEntitlementsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IEntitlement + >, + ): void; listEntitlements( - request: protos.google.cloud.oracledatabase.v1.IListEntitlementsRequest, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListEntitlementsRequest, - protos.google.cloud.oracledatabase.v1.IListEntitlementsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IEntitlement>): void; + request: protos.google.cloud.oracledatabase.v1.IListEntitlementsRequest, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListEntitlementsRequest, + | protos.google.cloud.oracledatabase.v1.IListEntitlementsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IEntitlement + >, + ): void; listEntitlements( - request?: protos.google.cloud.oracledatabase.v1.IListEntitlementsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListEntitlementsRequest, - protos.google.cloud.oracledatabase.v1.IListEntitlementsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IEntitlement>, - callback?: PaginationCallback< + request?: protos.google.cloud.oracledatabase.v1.IListEntitlementsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.oracledatabase.v1.IListEntitlementsRequest, - protos.google.cloud.oracledatabase.v1.IListEntitlementsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IEntitlement>): - Promise<[ - protos.google.cloud.oracledatabase.v1.IEntitlement[], - protos.google.cloud.oracledatabase.v1.IListEntitlementsRequest|null, - protos.google.cloud.oracledatabase.v1.IListEntitlementsResponse - ]>|void { + | protos.google.cloud.oracledatabase.v1.IListEntitlementsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IEntitlement + >, + callback?: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListEntitlementsRequest, + | protos.google.cloud.oracledatabase.v1.IListEntitlementsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IEntitlement + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IEntitlement[], + protos.google.cloud.oracledatabase.v1.IListEntitlementsRequest | null, + protos.google.cloud.oracledatabase.v1.IListEntitlementsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListEntitlementsRequest, - protos.google.cloud.oracledatabase.v1.IListEntitlementsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IEntitlement>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListEntitlementsRequest, + | protos.google.cloud.oracledatabase.v1.IListEntitlementsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IEntitlement + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listEntitlements values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -5213,198 +7736,227 @@ export class OracleDatabaseClient { this._log.info('listEntitlements request %j', request); return this.innerApiCalls .listEntitlements(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.oracledatabase.v1.IEntitlement[], - protos.google.cloud.oracledatabase.v1.IListEntitlementsRequest|null, - protos.google.cloud.oracledatabase.v1.IListEntitlementsResponse - ]) => { - this._log.info('listEntitlements values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.oracledatabase.v1.IEntitlement[], + protos.google.cloud.oracledatabase.v1.IListEntitlementsRequest | null, + protos.google.cloud.oracledatabase.v1.IListEntitlementsResponse, + ]) => { + this._log.info('listEntitlements values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listEntitlements`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for the entitlement in the following format: - * projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, a maximum of 50 entitlements will be returned. - * The maximum value is 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.Entitlement|Entitlement} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listEntitlementsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listEntitlements`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for the entitlement in the following format: + * projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, a maximum of 50 entitlements will be returned. + * The maximum value is 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.Entitlement|Entitlement} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listEntitlementsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listEntitlementsStream( - request?: protos.google.cloud.oracledatabase.v1.IListEntitlementsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.oracledatabase.v1.IListEntitlementsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listEntitlements']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listEntitlements stream %j', request); return this.descriptors.page.listEntitlements.createStream( this.innerApiCalls.listEntitlements as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listEntitlements`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for the entitlement in the following format: - * projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, a maximum of 50 entitlements will be returned. - * The maximum value is 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.oracledatabase.v1.Entitlement|Entitlement}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.list_entitlements.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_ListEntitlements_async - */ + /** + * Equivalent to `listEntitlements`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for the entitlement in the following format: + * projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, a maximum of 50 entitlements will be returned. + * The maximum value is 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.oracledatabase.v1.Entitlement|Entitlement}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.list_entitlements.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_ListEntitlements_async + */ listEntitlementsAsync( - request?: protos.google.cloud.oracledatabase.v1.IListEntitlementsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.oracledatabase.v1.IListEntitlementsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listEntitlements']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listEntitlements iterate %j', request); return this.descriptors.page.listEntitlements.asyncIterate( this.innerApiCalls['listEntitlements'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists the database servers of an Exadata Infrastructure instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for database server in the following format: - * projects/{project}/locations/{location}/cloudExadataInfrastructures/{cloudExadataInfrastructure}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, a maximum of 50 db servers will be returned. - * The maximum value is 1000; values above 1000 will be reset to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @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 Array of {@link protos.google.cloud.oracledatabase.v1.DbServer|DbServer}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listDbServersAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists the database servers of an Exadata Infrastructure instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for database server in the following format: + * projects/{project}/locations/{location}/cloudExadataInfrastructures/{cloudExadataInfrastructure}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, a maximum of 50 db servers will be returned. + * The maximum value is 1000; values above 1000 will be reset to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @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 Array of {@link protos.google.cloud.oracledatabase.v1.DbServer|DbServer}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listDbServersAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listDbServers( - request?: protos.google.cloud.oracledatabase.v1.IListDbServersRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.IDbServer[], - protos.google.cloud.oracledatabase.v1.IListDbServersRequest|null, - protos.google.cloud.oracledatabase.v1.IListDbServersResponse - ]>; + request?: protos.google.cloud.oracledatabase.v1.IListDbServersRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IDbServer[], + protos.google.cloud.oracledatabase.v1.IListDbServersRequest | null, + protos.google.cloud.oracledatabase.v1.IListDbServersResponse, + ] + >; listDbServers( - request: protos.google.cloud.oracledatabase.v1.IListDbServersRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDbServersRequest, - protos.google.cloud.oracledatabase.v1.IListDbServersResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDbServer>): void; + request: protos.google.cloud.oracledatabase.v1.IListDbServersRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDbServersRequest, + | protos.google.cloud.oracledatabase.v1.IListDbServersResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDbServer + >, + ): void; listDbServers( - request: protos.google.cloud.oracledatabase.v1.IListDbServersRequest, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDbServersRequest, - protos.google.cloud.oracledatabase.v1.IListDbServersResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDbServer>): void; + request: protos.google.cloud.oracledatabase.v1.IListDbServersRequest, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDbServersRequest, + | protos.google.cloud.oracledatabase.v1.IListDbServersResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDbServer + >, + ): void; listDbServers( - request?: protos.google.cloud.oracledatabase.v1.IListDbServersRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDbServersRequest, - protos.google.cloud.oracledatabase.v1.IListDbServersResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDbServer>, - callback?: PaginationCallback< + request?: protos.google.cloud.oracledatabase.v1.IListDbServersRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.oracledatabase.v1.IListDbServersRequest, - protos.google.cloud.oracledatabase.v1.IListDbServersResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDbServer>): - Promise<[ - protos.google.cloud.oracledatabase.v1.IDbServer[], - protos.google.cloud.oracledatabase.v1.IListDbServersRequest|null, - protos.google.cloud.oracledatabase.v1.IListDbServersResponse - ]>|void { + | protos.google.cloud.oracledatabase.v1.IListDbServersResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDbServer + >, + callback?: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDbServersRequest, + | protos.google.cloud.oracledatabase.v1.IListDbServersResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDbServer + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IDbServer[], + protos.google.cloud.oracledatabase.v1.IListDbServersRequest | null, + protos.google.cloud.oracledatabase.v1.IListDbServersResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDbServersRequest, - protos.google.cloud.oracledatabase.v1.IListDbServersResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDbServer>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDbServersRequest, + | protos.google.cloud.oracledatabase.v1.IListDbServersResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDbServer + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listDbServers values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -5413,199 +7965,228 @@ export class OracleDatabaseClient { this._log.info('listDbServers request %j', request); return this.innerApiCalls .listDbServers(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.oracledatabase.v1.IDbServer[], - protos.google.cloud.oracledatabase.v1.IListDbServersRequest|null, - protos.google.cloud.oracledatabase.v1.IListDbServersResponse - ]) => { - this._log.info('listDbServers values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.oracledatabase.v1.IDbServer[], + protos.google.cloud.oracledatabase.v1.IListDbServersRequest | null, + protos.google.cloud.oracledatabase.v1.IListDbServersResponse, + ]) => { + this._log.info('listDbServers values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listDbServers`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for database server in the following format: - * projects/{project}/locations/{location}/cloudExadataInfrastructures/{cloudExadataInfrastructure}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, a maximum of 50 db servers will be returned. - * The maximum value is 1000; values above 1000 will be reset to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.DbServer|DbServer} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listDbServersAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listDbServers`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for database server in the following format: + * projects/{project}/locations/{location}/cloudExadataInfrastructures/{cloudExadataInfrastructure}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, a maximum of 50 db servers will be returned. + * The maximum value is 1000; values above 1000 will be reset to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.DbServer|DbServer} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listDbServersAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listDbServersStream( - request?: protos.google.cloud.oracledatabase.v1.IListDbServersRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.oracledatabase.v1.IListDbServersRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listDbServers']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listDbServers stream %j', request); return this.descriptors.page.listDbServers.createStream( this.innerApiCalls.listDbServers as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listDbServers`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for database server in the following format: - * projects/{project}/locations/{location}/cloudExadataInfrastructures/{cloudExadataInfrastructure}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, a maximum of 50 db servers will be returned. - * The maximum value is 1000; values above 1000 will be reset to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.oracledatabase.v1.DbServer|DbServer}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.list_db_servers.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_ListDbServers_async - */ + /** + * Equivalent to `listDbServers`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for database server in the following format: + * projects/{project}/locations/{location}/cloudExadataInfrastructures/{cloudExadataInfrastructure}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, a maximum of 50 db servers will be returned. + * The maximum value is 1000; values above 1000 will be reset to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.oracledatabase.v1.DbServer|DbServer}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.list_db_servers.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_ListDbServers_async + */ listDbServersAsync( - request?: protos.google.cloud.oracledatabase.v1.IListDbServersRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.oracledatabase.v1.IListDbServersRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listDbServers']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listDbServers iterate %j', request); return this.descriptors.page.listDbServers.asyncIterate( this.innerApiCalls['listDbServers'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists the database nodes of a VM Cluster. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for database node in the following format: - * projects/{project}/locations/{location}/cloudVmClusters/{cloudVmCluster}. - * . - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 db nodes will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the node should return. - * @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 Array of {@link protos.google.cloud.oracledatabase.v1.DbNode|DbNode}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listDbNodesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists the database nodes of a VM Cluster. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for database node in the following format: + * projects/{project}/locations/{location}/cloudVmClusters/{cloudVmCluster}. + * . + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 db nodes will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the node should return. + * @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 Array of {@link protos.google.cloud.oracledatabase.v1.DbNode|DbNode}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listDbNodesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listDbNodes( - request?: protos.google.cloud.oracledatabase.v1.IListDbNodesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.IDbNode[], - protos.google.cloud.oracledatabase.v1.IListDbNodesRequest|null, - protos.google.cloud.oracledatabase.v1.IListDbNodesResponse - ]>; + request?: protos.google.cloud.oracledatabase.v1.IListDbNodesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IDbNode[], + protos.google.cloud.oracledatabase.v1.IListDbNodesRequest | null, + protos.google.cloud.oracledatabase.v1.IListDbNodesResponse, + ] + >; listDbNodes( - request: protos.google.cloud.oracledatabase.v1.IListDbNodesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDbNodesRequest, - protos.google.cloud.oracledatabase.v1.IListDbNodesResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDbNode>): void; + request: protos.google.cloud.oracledatabase.v1.IListDbNodesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDbNodesRequest, + | protos.google.cloud.oracledatabase.v1.IListDbNodesResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDbNode + >, + ): void; listDbNodes( - request: protos.google.cloud.oracledatabase.v1.IListDbNodesRequest, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDbNodesRequest, - protos.google.cloud.oracledatabase.v1.IListDbNodesResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDbNode>): void; + request: protos.google.cloud.oracledatabase.v1.IListDbNodesRequest, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDbNodesRequest, + | protos.google.cloud.oracledatabase.v1.IListDbNodesResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDbNode + >, + ): void; listDbNodes( - request?: protos.google.cloud.oracledatabase.v1.IListDbNodesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDbNodesRequest, - protos.google.cloud.oracledatabase.v1.IListDbNodesResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDbNode>, - callback?: PaginationCallback< + request?: protos.google.cloud.oracledatabase.v1.IListDbNodesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.oracledatabase.v1.IListDbNodesRequest, - protos.google.cloud.oracledatabase.v1.IListDbNodesResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDbNode>): - Promise<[ - protos.google.cloud.oracledatabase.v1.IDbNode[], - protos.google.cloud.oracledatabase.v1.IListDbNodesRequest|null, - protos.google.cloud.oracledatabase.v1.IListDbNodesResponse - ]>|void { + | protos.google.cloud.oracledatabase.v1.IListDbNodesResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDbNode + >, + callback?: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDbNodesRequest, + | protos.google.cloud.oracledatabase.v1.IListDbNodesResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDbNode + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IDbNode[], + protos.google.cloud.oracledatabase.v1.IListDbNodesRequest | null, + protos.google.cloud.oracledatabase.v1.IListDbNodesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDbNodesRequest, - protos.google.cloud.oracledatabase.v1.IListDbNodesResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDbNode>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDbNodesRequest, + | protos.google.cloud.oracledatabase.v1.IListDbNodesResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDbNode + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listDbNodes values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -5614,206 +8195,235 @@ export class OracleDatabaseClient { this._log.info('listDbNodes request %j', request); return this.innerApiCalls .listDbNodes(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.oracledatabase.v1.IDbNode[], - protos.google.cloud.oracledatabase.v1.IListDbNodesRequest|null, - protos.google.cloud.oracledatabase.v1.IListDbNodesResponse - ]) => { - this._log.info('listDbNodes values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.oracledatabase.v1.IDbNode[], + protos.google.cloud.oracledatabase.v1.IListDbNodesRequest | null, + protos.google.cloud.oracledatabase.v1.IListDbNodesResponse, + ]) => { + this._log.info('listDbNodes values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listDbNodes`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for database node in the following format: - * projects/{project}/locations/{location}/cloudVmClusters/{cloudVmCluster}. - * . - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 db nodes will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the node should return. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.DbNode|DbNode} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listDbNodesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listDbNodes`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for database node in the following format: + * projects/{project}/locations/{location}/cloudVmClusters/{cloudVmCluster}. + * . + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 db nodes will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the node should return. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.DbNode|DbNode} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listDbNodesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listDbNodesStream( - request?: protos.google.cloud.oracledatabase.v1.IListDbNodesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.oracledatabase.v1.IListDbNodesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listDbNodes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listDbNodes stream %j', request); return this.descriptors.page.listDbNodes.createStream( this.innerApiCalls.listDbNodes as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listDbNodes`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for database node in the following format: - * projects/{project}/locations/{location}/cloudVmClusters/{cloudVmCluster}. - * . - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 db nodes will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the node should return. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.oracledatabase.v1.DbNode|DbNode}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.list_db_nodes.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_ListDbNodes_async - */ + /** + * Equivalent to `listDbNodes`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for database node in the following format: + * projects/{project}/locations/{location}/cloudVmClusters/{cloudVmCluster}. + * . + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 db nodes will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the node should return. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.oracledatabase.v1.DbNode|DbNode}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.list_db_nodes.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_ListDbNodes_async + */ listDbNodesAsync( - request?: protos.google.cloud.oracledatabase.v1.IListDbNodesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.oracledatabase.v1.IListDbNodesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listDbNodes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listDbNodes iterate %j', request); return this.descriptors.page.listDbNodes.asyncIterate( this.innerApiCalls['listDbNodes'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists all the valid Oracle Grid Infrastructure (GI) versions for the given - * project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for Grid Infrastructure Version in the following - * format: Format: projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, a maximum of 50 Oracle Grid Infrastructure (GI) versions - * will be returned. The maximum value is 1000; values above 1000 will be - * reset to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. Only the - * shape, gcp_oracle_zone and gi_version fields are supported in this format: - * `shape="{shape}"`. - * @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 Array of {@link protos.google.cloud.oracledatabase.v1.GiVersion|GiVersion}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listGiVersionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists all the valid Oracle Grid Infrastructure (GI) versions for the given + * project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for Grid Infrastructure Version in the following + * format: Format: projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, a maximum of 50 Oracle Grid Infrastructure (GI) versions + * will be returned. The maximum value is 1000; values above 1000 will be + * reset to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. Only the + * shape, gcp_oracle_zone and gi_version fields are supported in this format: + * `shape="{shape}"`. + * @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 Array of {@link protos.google.cloud.oracledatabase.v1.GiVersion|GiVersion}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listGiVersionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listGiVersions( - request?: protos.google.cloud.oracledatabase.v1.IListGiVersionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.IGiVersion[], - protos.google.cloud.oracledatabase.v1.IListGiVersionsRequest|null, - protos.google.cloud.oracledatabase.v1.IListGiVersionsResponse - ]>; + request?: protos.google.cloud.oracledatabase.v1.IListGiVersionsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IGiVersion[], + protos.google.cloud.oracledatabase.v1.IListGiVersionsRequest | null, + protos.google.cloud.oracledatabase.v1.IListGiVersionsResponse, + ] + >; listGiVersions( - request: protos.google.cloud.oracledatabase.v1.IListGiVersionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListGiVersionsRequest, - protos.google.cloud.oracledatabase.v1.IListGiVersionsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IGiVersion>): void; + request: protos.google.cloud.oracledatabase.v1.IListGiVersionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListGiVersionsRequest, + | protos.google.cloud.oracledatabase.v1.IListGiVersionsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IGiVersion + >, + ): void; listGiVersions( - request: protos.google.cloud.oracledatabase.v1.IListGiVersionsRequest, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListGiVersionsRequest, - protos.google.cloud.oracledatabase.v1.IListGiVersionsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IGiVersion>): void; + request: protos.google.cloud.oracledatabase.v1.IListGiVersionsRequest, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListGiVersionsRequest, + | protos.google.cloud.oracledatabase.v1.IListGiVersionsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IGiVersion + >, + ): void; listGiVersions( - request?: protos.google.cloud.oracledatabase.v1.IListGiVersionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListGiVersionsRequest, - protos.google.cloud.oracledatabase.v1.IListGiVersionsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IGiVersion>, - callback?: PaginationCallback< + request?: protos.google.cloud.oracledatabase.v1.IListGiVersionsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.oracledatabase.v1.IListGiVersionsRequest, - protos.google.cloud.oracledatabase.v1.IListGiVersionsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IGiVersion>): - Promise<[ - protos.google.cloud.oracledatabase.v1.IGiVersion[], - protos.google.cloud.oracledatabase.v1.IListGiVersionsRequest|null, - protos.google.cloud.oracledatabase.v1.IListGiVersionsResponse - ]>|void { + | protos.google.cloud.oracledatabase.v1.IListGiVersionsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IGiVersion + >, + callback?: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListGiVersionsRequest, + | protos.google.cloud.oracledatabase.v1.IListGiVersionsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IGiVersion + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IGiVersion[], + protos.google.cloud.oracledatabase.v1.IListGiVersionsRequest | null, + protos.google.cloud.oracledatabase.v1.IListGiVersionsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListGiVersionsRequest, - protos.google.cloud.oracledatabase.v1.IListGiVersionsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IGiVersion>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListGiVersionsRequest, + | protos.google.cloud.oracledatabase.v1.IListGiVersionsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IGiVersion + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listGiVersions values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -5822,216 +8432,245 @@ export class OracleDatabaseClient { this._log.info('listGiVersions request %j', request); return this.innerApiCalls .listGiVersions(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.oracledatabase.v1.IGiVersion[], - protos.google.cloud.oracledatabase.v1.IListGiVersionsRequest|null, - protos.google.cloud.oracledatabase.v1.IListGiVersionsResponse - ]) => { - this._log.info('listGiVersions values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.oracledatabase.v1.IGiVersion[], + protos.google.cloud.oracledatabase.v1.IListGiVersionsRequest | null, + protos.google.cloud.oracledatabase.v1.IListGiVersionsResponse, + ]) => { + this._log.info('listGiVersions values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listGiVersions`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for Grid Infrastructure Version in the following - * format: Format: projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, a maximum of 50 Oracle Grid Infrastructure (GI) versions - * will be returned. The maximum value is 1000; values above 1000 will be - * reset to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. Only the - * shape, gcp_oracle_zone and gi_version fields are supported in this format: - * `shape="{shape}"`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.GiVersion|GiVersion} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listGiVersionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listGiVersions`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for Grid Infrastructure Version in the following + * format: Format: projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, a maximum of 50 Oracle Grid Infrastructure (GI) versions + * will be returned. The maximum value is 1000; values above 1000 will be + * reset to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. Only the + * shape, gcp_oracle_zone and gi_version fields are supported in this format: + * `shape="{shape}"`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.GiVersion|GiVersion} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listGiVersionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listGiVersionsStream( - request?: protos.google.cloud.oracledatabase.v1.IListGiVersionsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.oracledatabase.v1.IListGiVersionsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listGiVersions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listGiVersions stream %j', request); return this.descriptors.page.listGiVersions.createStream( this.innerApiCalls.listGiVersions as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listGiVersions`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for Grid Infrastructure Version in the following - * format: Format: projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, a maximum of 50 Oracle Grid Infrastructure (GI) versions - * will be returned. The maximum value is 1000; values above 1000 will be - * reset to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. Only the - * shape, gcp_oracle_zone and gi_version fields are supported in this format: - * `shape="{shape}"`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.oracledatabase.v1.GiVersion|GiVersion}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.list_gi_versions.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_ListGiVersions_async - */ + /** + * Equivalent to `listGiVersions`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for Grid Infrastructure Version in the following + * format: Format: projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, a maximum of 50 Oracle Grid Infrastructure (GI) versions + * will be returned. The maximum value is 1000; values above 1000 will be + * reset to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. Only the + * shape, gcp_oracle_zone and gi_version fields are supported in this format: + * `shape="{shape}"`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.oracledatabase.v1.GiVersion|GiVersion}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.list_gi_versions.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_ListGiVersions_async + */ listGiVersionsAsync( - request?: protos.google.cloud.oracledatabase.v1.IListGiVersionsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.oracledatabase.v1.IListGiVersionsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listGiVersions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listGiVersions iterate %j', request); return this.descriptors.page.listGiVersions.asyncIterate( this.innerApiCalls['listGiVersions'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists all the valid minor versions for the given - * project, location, gi version and shape family. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for the MinorVersion resource with the format: - * projects/{project}/locations/{location}/giVersions/{gi_version} - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, a maximum of 50 System Versions will be returned. - * The maximum value is 1000; values above 1000 will be reset to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying the requested page of results to return. All - * fields except the filter should remain the same as in the request that - * provided this page token. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. - * Only shapeFamily and gcp_oracle_zone_id are supported in this format: - * `shape_family="{shapeFamily}" AND - * gcp_oracle_zone_id="{gcp_oracle_zone_id}"`. - * @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 Array of {@link protos.google.cloud.oracledatabase.v1.MinorVersion|MinorVersion}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listMinorVersionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists all the valid minor versions for the given + * project, location, gi version and shape family. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for the MinorVersion resource with the format: + * projects/{project}/locations/{location}/giVersions/{gi_version} + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, a maximum of 50 System Versions will be returned. + * The maximum value is 1000; values above 1000 will be reset to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying the requested page of results to return. All + * fields except the filter should remain the same as in the request that + * provided this page token. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. + * Only shapeFamily and gcp_oracle_zone_id are supported in this format: + * `shape_family="{shapeFamily}" AND + * gcp_oracle_zone_id="{gcp_oracle_zone_id}"`. + * @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 Array of {@link protos.google.cloud.oracledatabase.v1.MinorVersion|MinorVersion}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listMinorVersionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMinorVersions( - request?: protos.google.cloud.oracledatabase.v1.IListMinorVersionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.IMinorVersion[], - protos.google.cloud.oracledatabase.v1.IListMinorVersionsRequest|null, - protos.google.cloud.oracledatabase.v1.IListMinorVersionsResponse - ]>; + request?: protos.google.cloud.oracledatabase.v1.IListMinorVersionsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IMinorVersion[], + protos.google.cloud.oracledatabase.v1.IListMinorVersionsRequest | null, + protos.google.cloud.oracledatabase.v1.IListMinorVersionsResponse, + ] + >; listMinorVersions( - request: protos.google.cloud.oracledatabase.v1.IListMinorVersionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListMinorVersionsRequest, - protos.google.cloud.oracledatabase.v1.IListMinorVersionsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IMinorVersion>): void; + request: protos.google.cloud.oracledatabase.v1.IListMinorVersionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListMinorVersionsRequest, + | protos.google.cloud.oracledatabase.v1.IListMinorVersionsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IMinorVersion + >, + ): void; listMinorVersions( - request: protos.google.cloud.oracledatabase.v1.IListMinorVersionsRequest, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListMinorVersionsRequest, - protos.google.cloud.oracledatabase.v1.IListMinorVersionsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IMinorVersion>): void; + request: protos.google.cloud.oracledatabase.v1.IListMinorVersionsRequest, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListMinorVersionsRequest, + | protos.google.cloud.oracledatabase.v1.IListMinorVersionsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IMinorVersion + >, + ): void; listMinorVersions( - request?: protos.google.cloud.oracledatabase.v1.IListMinorVersionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListMinorVersionsRequest, - protos.google.cloud.oracledatabase.v1.IListMinorVersionsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IMinorVersion>, - callback?: PaginationCallback< + request?: protos.google.cloud.oracledatabase.v1.IListMinorVersionsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.oracledatabase.v1.IListMinorVersionsRequest, - protos.google.cloud.oracledatabase.v1.IListMinorVersionsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IMinorVersion>): - Promise<[ - protos.google.cloud.oracledatabase.v1.IMinorVersion[], - protos.google.cloud.oracledatabase.v1.IListMinorVersionsRequest|null, - protos.google.cloud.oracledatabase.v1.IListMinorVersionsResponse - ]>|void { + | protos.google.cloud.oracledatabase.v1.IListMinorVersionsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IMinorVersion + >, + callback?: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListMinorVersionsRequest, + | protos.google.cloud.oracledatabase.v1.IListMinorVersionsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IMinorVersion + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IMinorVersion[], + protos.google.cloud.oracledatabase.v1.IListMinorVersionsRequest | null, + protos.google.cloud.oracledatabase.v1.IListMinorVersionsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListMinorVersionsRequest, - protos.google.cloud.oracledatabase.v1.IListMinorVersionsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IMinorVersion>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListMinorVersionsRequest, + | protos.google.cloud.oracledatabase.v1.IListMinorVersionsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IMinorVersion + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listMinorVersions values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -6040,216 +8679,245 @@ export class OracleDatabaseClient { this._log.info('listMinorVersions request %j', request); return this.innerApiCalls .listMinorVersions(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.oracledatabase.v1.IMinorVersion[], - protos.google.cloud.oracledatabase.v1.IListMinorVersionsRequest|null, - protos.google.cloud.oracledatabase.v1.IListMinorVersionsResponse - ]) => { - this._log.info('listMinorVersions values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.oracledatabase.v1.IMinorVersion[], + protos.google.cloud.oracledatabase.v1.IListMinorVersionsRequest | null, + protos.google.cloud.oracledatabase.v1.IListMinorVersionsResponse, + ]) => { + this._log.info('listMinorVersions values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listMinorVersions`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for the MinorVersion resource with the format: - * projects/{project}/locations/{location}/giVersions/{gi_version} - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, a maximum of 50 System Versions will be returned. - * The maximum value is 1000; values above 1000 will be reset to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying the requested page of results to return. All - * fields except the filter should remain the same as in the request that - * provided this page token. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. - * Only shapeFamily and gcp_oracle_zone_id are supported in this format: - * `shape_family="{shapeFamily}" AND - * gcp_oracle_zone_id="{gcp_oracle_zone_id}"`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.MinorVersion|MinorVersion} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listMinorVersionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listMinorVersions`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for the MinorVersion resource with the format: + * projects/{project}/locations/{location}/giVersions/{gi_version} + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, a maximum of 50 System Versions will be returned. + * The maximum value is 1000; values above 1000 will be reset to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying the requested page of results to return. All + * fields except the filter should remain the same as in the request that + * provided this page token. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. + * Only shapeFamily and gcp_oracle_zone_id are supported in this format: + * `shape_family="{shapeFamily}" AND + * gcp_oracle_zone_id="{gcp_oracle_zone_id}"`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.MinorVersion|MinorVersion} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listMinorVersionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMinorVersionsStream( - request?: protos.google.cloud.oracledatabase.v1.IListMinorVersionsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.oracledatabase.v1.IListMinorVersionsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listMinorVersions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listMinorVersions stream %j', request); return this.descriptors.page.listMinorVersions.createStream( this.innerApiCalls.listMinorVersions as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listMinorVersions`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for the MinorVersion resource with the format: - * projects/{project}/locations/{location}/giVersions/{gi_version} - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, a maximum of 50 System Versions will be returned. - * The maximum value is 1000; values above 1000 will be reset to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying the requested page of results to return. All - * fields except the filter should remain the same as in the request that - * provided this page token. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. - * Only shapeFamily and gcp_oracle_zone_id are supported in this format: - * `shape_family="{shapeFamily}" AND - * gcp_oracle_zone_id="{gcp_oracle_zone_id}"`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.oracledatabase.v1.MinorVersion|MinorVersion}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.list_minor_versions.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_ListMinorVersions_async - */ + /** + * Equivalent to `listMinorVersions`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for the MinorVersion resource with the format: + * projects/{project}/locations/{location}/giVersions/{gi_version} + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, a maximum of 50 System Versions will be returned. + * The maximum value is 1000; values above 1000 will be reset to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying the requested page of results to return. All + * fields except the filter should remain the same as in the request that + * provided this page token. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. + * Only shapeFamily and gcp_oracle_zone_id are supported in this format: + * `shape_family="{shapeFamily}" AND + * gcp_oracle_zone_id="{gcp_oracle_zone_id}"`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.oracledatabase.v1.MinorVersion|MinorVersion}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.list_minor_versions.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_ListMinorVersions_async + */ listMinorVersionsAsync( - request?: protos.google.cloud.oracledatabase.v1.IListMinorVersionsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.oracledatabase.v1.IListMinorVersionsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listMinorVersions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listMinorVersions iterate %j', request); return this.descriptors.page.listMinorVersions.asyncIterate( this.innerApiCalls['listMinorVersions'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists the database system shapes available for the project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for Database System Shapes in the following - * format: projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 database system shapes will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. Only the - * gcp_oracle_zone_id field is supported in this format: - * `gcp_oracle_zone_id="{gcp_oracle_zone_id}"`. - * @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 Array of {@link protos.google.cloud.oracledatabase.v1.DbSystemShape|DbSystemShape}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listDbSystemShapesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists the database system shapes available for the project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for Database System Shapes in the following + * format: projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 database system shapes will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. Only the + * gcp_oracle_zone_id field is supported in this format: + * `gcp_oracle_zone_id="{gcp_oracle_zone_id}"`. + * @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 Array of {@link protos.google.cloud.oracledatabase.v1.DbSystemShape|DbSystemShape}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listDbSystemShapesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listDbSystemShapes( - request?: protos.google.cloud.oracledatabase.v1.IListDbSystemShapesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.IDbSystemShape[], - protos.google.cloud.oracledatabase.v1.IListDbSystemShapesRequest|null, - protos.google.cloud.oracledatabase.v1.IListDbSystemShapesResponse - ]>; + request?: protos.google.cloud.oracledatabase.v1.IListDbSystemShapesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IDbSystemShape[], + protos.google.cloud.oracledatabase.v1.IListDbSystemShapesRequest | null, + protos.google.cloud.oracledatabase.v1.IListDbSystemShapesResponse, + ] + >; listDbSystemShapes( - request: protos.google.cloud.oracledatabase.v1.IListDbSystemShapesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDbSystemShapesRequest, - protos.google.cloud.oracledatabase.v1.IListDbSystemShapesResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDbSystemShape>): void; + request: protos.google.cloud.oracledatabase.v1.IListDbSystemShapesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDbSystemShapesRequest, + | protos.google.cloud.oracledatabase.v1.IListDbSystemShapesResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDbSystemShape + >, + ): void; listDbSystemShapes( - request: protos.google.cloud.oracledatabase.v1.IListDbSystemShapesRequest, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDbSystemShapesRequest, - protos.google.cloud.oracledatabase.v1.IListDbSystemShapesResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDbSystemShape>): void; + request: protos.google.cloud.oracledatabase.v1.IListDbSystemShapesRequest, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDbSystemShapesRequest, + | protos.google.cloud.oracledatabase.v1.IListDbSystemShapesResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDbSystemShape + >, + ): void; listDbSystemShapes( - request?: protos.google.cloud.oracledatabase.v1.IListDbSystemShapesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDbSystemShapesRequest, - protos.google.cloud.oracledatabase.v1.IListDbSystemShapesResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDbSystemShape>, - callback?: PaginationCallback< + request?: protos.google.cloud.oracledatabase.v1.IListDbSystemShapesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.oracledatabase.v1.IListDbSystemShapesRequest, - protos.google.cloud.oracledatabase.v1.IListDbSystemShapesResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDbSystemShape>): - Promise<[ - protos.google.cloud.oracledatabase.v1.IDbSystemShape[], - protos.google.cloud.oracledatabase.v1.IListDbSystemShapesRequest|null, - protos.google.cloud.oracledatabase.v1.IListDbSystemShapesResponse - ]>|void { + | protos.google.cloud.oracledatabase.v1.IListDbSystemShapesResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDbSystemShape + >, + callback?: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDbSystemShapesRequest, + | protos.google.cloud.oracledatabase.v1.IListDbSystemShapesResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDbSystemShape + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IDbSystemShape[], + protos.google.cloud.oracledatabase.v1.IListDbSystemShapesRequest | null, + protos.google.cloud.oracledatabase.v1.IListDbSystemShapesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDbSystemShapesRequest, - protos.google.cloud.oracledatabase.v1.IListDbSystemShapesResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDbSystemShape>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDbSystemShapesRequest, + | protos.google.cloud.oracledatabase.v1.IListDbSystemShapesResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDbSystemShape + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listDbSystemShapes values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -6258,210 +8926,239 @@ export class OracleDatabaseClient { this._log.info('listDbSystemShapes request %j', request); return this.innerApiCalls .listDbSystemShapes(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.oracledatabase.v1.IDbSystemShape[], - protos.google.cloud.oracledatabase.v1.IListDbSystemShapesRequest|null, - protos.google.cloud.oracledatabase.v1.IListDbSystemShapesResponse - ]) => { - this._log.info('listDbSystemShapes values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.oracledatabase.v1.IDbSystemShape[], + protos.google.cloud.oracledatabase.v1.IListDbSystemShapesRequest | null, + protos.google.cloud.oracledatabase.v1.IListDbSystemShapesResponse, + ]) => { + this._log.info('listDbSystemShapes values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listDbSystemShapes`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for Database System Shapes in the following - * format: projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 database system shapes will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. Only the - * gcp_oracle_zone_id field is supported in this format: - * `gcp_oracle_zone_id="{gcp_oracle_zone_id}"`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.DbSystemShape|DbSystemShape} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listDbSystemShapesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listDbSystemShapes`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for Database System Shapes in the following + * format: projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 database system shapes will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. Only the + * gcp_oracle_zone_id field is supported in this format: + * `gcp_oracle_zone_id="{gcp_oracle_zone_id}"`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.DbSystemShape|DbSystemShape} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listDbSystemShapesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listDbSystemShapesStream( - request?: protos.google.cloud.oracledatabase.v1.IListDbSystemShapesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.oracledatabase.v1.IListDbSystemShapesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listDbSystemShapes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listDbSystemShapes stream %j', request); return this.descriptors.page.listDbSystemShapes.createStream( this.innerApiCalls.listDbSystemShapes as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listDbSystemShapes`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for Database System Shapes in the following - * format: projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 database system shapes will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. Only the - * gcp_oracle_zone_id field is supported in this format: - * `gcp_oracle_zone_id="{gcp_oracle_zone_id}"`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.oracledatabase.v1.DbSystemShape|DbSystemShape}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.list_db_system_shapes.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_ListDbSystemShapes_async - */ + /** + * Equivalent to `listDbSystemShapes`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for Database System Shapes in the following + * format: projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 database system shapes will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. Only the + * gcp_oracle_zone_id field is supported in this format: + * `gcp_oracle_zone_id="{gcp_oracle_zone_id}"`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.oracledatabase.v1.DbSystemShape|DbSystemShape}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.list_db_system_shapes.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_ListDbSystemShapes_async + */ listDbSystemShapesAsync( - request?: protos.google.cloud.oracledatabase.v1.IListDbSystemShapesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.oracledatabase.v1.IListDbSystemShapesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listDbSystemShapes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listDbSystemShapes iterate %j', request); return this.descriptors.page.listDbSystemShapes.asyncIterate( this.innerApiCalls['listDbSystemShapes'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists the Autonomous Databases in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for the Autonomous Database in the following - * format: projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 Autonomous Database will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. - * @param {string} [request.orderBy] - * Optional. An expression for ordering the results of the request. - * @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 Array of {@link protos.google.cloud.oracledatabase.v1.AutonomousDatabase|AutonomousDatabase}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listAutonomousDatabasesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists the Autonomous Databases in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for the Autonomous Database in the following + * format: projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 Autonomous Database will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. + * @param {string} [request.orderBy] + * Optional. An expression for ordering the results of the request. + * @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 Array of {@link protos.google.cloud.oracledatabase.v1.AutonomousDatabase|AutonomousDatabase}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listAutonomousDatabasesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listAutonomousDatabases( - request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.IAutonomousDatabase[], - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesRequest|null, - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesResponse - ]>; + request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase[], + protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesRequest | null, + protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesResponse, + ] + >; listAutonomousDatabases( - request: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesRequest, - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IAutonomousDatabase>): void; + request: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesRequest, + | protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase + >, + ): void; listAutonomousDatabases( - request: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesRequest, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesRequest, - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IAutonomousDatabase>): void; + request: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesRequest, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesRequest, + | protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase + >, + ): void; listAutonomousDatabases( - request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesRequest, - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IAutonomousDatabase>, - callback?: PaginationCallback< + request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesRequest, - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IAutonomousDatabase>): - Promise<[ - protos.google.cloud.oracledatabase.v1.IAutonomousDatabase[], - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesRequest|null, - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesResponse - ]>|void { + | protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase + >, + callback?: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesRequest, + | protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase[], + protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesRequest | null, + protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesRequest, - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IAutonomousDatabase>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesRequest, + | protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listAutonomousDatabases values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -6470,207 +9167,236 @@ export class OracleDatabaseClient { this._log.info('listAutonomousDatabases request %j', request); return this.innerApiCalls .listAutonomousDatabases(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.oracledatabase.v1.IAutonomousDatabase[], - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesRequest|null, - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesResponse - ]) => { - this._log.info('listAutonomousDatabases values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase[], + protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesRequest | null, + protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesResponse, + ]) => { + this._log.info('listAutonomousDatabases values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listAutonomousDatabases`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for the Autonomous Database in the following - * format: projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 Autonomous Database will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. - * @param {string} [request.orderBy] - * Optional. An expression for ordering the results of the request. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.AutonomousDatabase|AutonomousDatabase} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listAutonomousDatabasesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listAutonomousDatabases`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for the Autonomous Database in the following + * format: projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 Autonomous Database will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. + * @param {string} [request.orderBy] + * Optional. An expression for ordering the results of the request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.AutonomousDatabase|AutonomousDatabase} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listAutonomousDatabasesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listAutonomousDatabasesStream( - request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listAutonomousDatabases']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listAutonomousDatabases stream %j', request); return this.descriptors.page.listAutonomousDatabases.createStream( this.innerApiCalls.listAutonomousDatabases as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listAutonomousDatabases`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for the Autonomous Database in the following - * format: projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 Autonomous Database will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. - * @param {string} [request.orderBy] - * Optional. An expression for ordering the results of the request. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.oracledatabase.v1.AutonomousDatabase|AutonomousDatabase}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.list_autonomous_databases.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_ListAutonomousDatabases_async - */ + /** + * Equivalent to `listAutonomousDatabases`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for the Autonomous Database in the following + * format: projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 Autonomous Database will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. + * @param {string} [request.orderBy] + * Optional. An expression for ordering the results of the request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.oracledatabase.v1.AutonomousDatabase|AutonomousDatabase}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.list_autonomous_databases.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_ListAutonomousDatabases_async + */ listAutonomousDatabasesAsync( - request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabasesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listAutonomousDatabases']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listAutonomousDatabases iterate %j', request); return this.descriptors.page.listAutonomousDatabases.asyncIterate( this.innerApiCalls['listAutonomousDatabases'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists all the available Autonomous Database versions for a project and - * location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for the Autonomous Database in the following - * format: projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 Autonomous DB Versions will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @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 Array of {@link protos.google.cloud.oracledatabase.v1.AutonomousDbVersion|AutonomousDbVersion}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listAutonomousDbVersionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists all the available Autonomous Database versions for a project and + * location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for the Autonomous Database in the following + * format: projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 Autonomous DB Versions will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @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 Array of {@link protos.google.cloud.oracledatabase.v1.AutonomousDbVersion|AutonomousDbVersion}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listAutonomousDbVersionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listAutonomousDbVersions( - request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.IAutonomousDbVersion[], - protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsRequest|null, - protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsResponse - ]>; + request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IAutonomousDbVersion[], + protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsRequest | null, + protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsResponse, + ] + >; listAutonomousDbVersions( - request: protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsRequest, - protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IAutonomousDbVersion>): void; + request: protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsRequest, + | protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IAutonomousDbVersion + >, + ): void; listAutonomousDbVersions( - request: protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsRequest, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsRequest, - protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IAutonomousDbVersion>): void; + request: protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsRequest, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsRequest, + | protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IAutonomousDbVersion + >, + ): void; listAutonomousDbVersions( - request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsRequest, - protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IAutonomousDbVersion>, - callback?: PaginationCallback< + request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsRequest, - protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IAutonomousDbVersion>): - Promise<[ - protos.google.cloud.oracledatabase.v1.IAutonomousDbVersion[], - protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsRequest|null, - protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsResponse - ]>|void { + | protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IAutonomousDbVersion + >, + callback?: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsRequest, + | protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IAutonomousDbVersion + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IAutonomousDbVersion[], + protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsRequest | null, + protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsRequest, - protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IAutonomousDbVersion>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsRequest, + | protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IAutonomousDbVersion + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listAutonomousDbVersions values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -6679,421 +9405,487 @@ export class OracleDatabaseClient { this._log.info('listAutonomousDbVersions request %j', request); return this.innerApiCalls .listAutonomousDbVersions(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.oracledatabase.v1.IAutonomousDbVersion[], - protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsRequest|null, - protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsResponse - ]) => { - this._log.info('listAutonomousDbVersions values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.oracledatabase.v1.IAutonomousDbVersion[], + protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsRequest | null, + protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsResponse, + ]) => { + this._log.info('listAutonomousDbVersions values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listAutonomousDbVersions`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for the Autonomous Database in the following - * format: projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 Autonomous DB Versions will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.AutonomousDbVersion|AutonomousDbVersion} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listAutonomousDbVersionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listAutonomousDbVersions`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for the Autonomous Database in the following + * format: projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 Autonomous DB Versions will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.AutonomousDbVersion|AutonomousDbVersion} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listAutonomousDbVersionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listAutonomousDbVersionsStream( - request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listAutonomousDbVersions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listAutonomousDbVersions stream %j', request); return this.descriptors.page.listAutonomousDbVersions.createStream( this.innerApiCalls.listAutonomousDbVersions as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listAutonomousDbVersions`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for the Autonomous Database in the following - * format: projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 Autonomous DB Versions will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.oracledatabase.v1.AutonomousDbVersion|AutonomousDbVersion}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.list_autonomous_db_versions.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_ListAutonomousDbVersions_async - */ + /** + * Equivalent to `listAutonomousDbVersions`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for the Autonomous Database in the following + * format: projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 Autonomous DB Versions will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.oracledatabase.v1.AutonomousDbVersion|AutonomousDbVersion}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.list_autonomous_db_versions.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_ListAutonomousDbVersions_async + */ listAutonomousDbVersionsAsync( - request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDbVersionsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listAutonomousDbVersions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listAutonomousDbVersions iterate %j', request); return this.descriptors.page.listAutonomousDbVersions.asyncIterate( this.innerApiCalls['listAutonomousDbVersions'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists Autonomous Database Character Sets in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for the Autonomous Database in the following - * format: projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 Autonomous DB Character Sets will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. Only the - * **character_set_type** field is supported in the following format: - * `character_set_type="{characterSetType}"`. Accepted values include - * `DATABASE` and `NATIONAL`. - * @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 Array of {@link protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet|AutonomousDatabaseCharacterSet}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listAutonomousDatabaseCharacterSetsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists Autonomous Database Character Sets in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for the Autonomous Database in the following + * format: projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 Autonomous DB Character Sets will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. Only the + * **character_set_type** field is supported in the following format: + * `character_set_type="{characterSetType}"`. Accepted values include + * `DATABASE` and `NATIONAL`. + * @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 Array of {@link protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet|AutonomousDatabaseCharacterSet}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listAutonomousDatabaseCharacterSetsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listAutonomousDatabaseCharacterSets( - request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseCharacterSet[], - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsRequest|null, - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsResponse - ]>; + request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseCharacterSet[], + protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsRequest | null, + protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsResponse, + ] + >; listAutonomousDatabaseCharacterSets( - request: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsRequest, - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseCharacterSet>): void; + request: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsRequest, + | protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseCharacterSet + >, + ): void; listAutonomousDatabaseCharacterSets( - request: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsRequest, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsRequest, - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseCharacterSet>): void; + request: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsRequest, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsRequest, + | protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseCharacterSet + >, + ): void; listAutonomousDatabaseCharacterSets( - request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsRequest, - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseCharacterSet>, - callback?: PaginationCallback< + request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsRequest, - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseCharacterSet>): - Promise<[ - protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseCharacterSet[], - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsRequest|null, - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsResponse - ]>|void { + | protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseCharacterSet + >, + callback?: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsRequest, + | protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseCharacterSet + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseCharacterSet[], + protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsRequest | null, + protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsRequest, - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseCharacterSet>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsRequest, + | protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseCharacterSet + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { - this._log.info('listAutonomousDatabaseCharacterSets values %j', values); + this._log.info( + 'listAutonomousDatabaseCharacterSets values %j', + values, + ); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. } : undefined; this._log.info('listAutonomousDatabaseCharacterSets request %j', request); return this.innerApiCalls .listAutonomousDatabaseCharacterSets(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseCharacterSet[], - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsRequest|null, - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsResponse - ]) => { - this._log.info('listAutonomousDatabaseCharacterSets values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseCharacterSet[], + protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsRequest | null, + protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsResponse, + ]) => { + this._log.info( + 'listAutonomousDatabaseCharacterSets values %j', + response, + ); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listAutonomousDatabaseCharacterSets`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for the Autonomous Database in the following - * format: projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 Autonomous DB Character Sets will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. Only the - * **character_set_type** field is supported in the following format: - * `character_set_type="{characterSetType}"`. Accepted values include - * `DATABASE` and `NATIONAL`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet|AutonomousDatabaseCharacterSet} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listAutonomousDatabaseCharacterSetsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listAutonomousDatabaseCharacterSets`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for the Autonomous Database in the following + * format: projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 Autonomous DB Character Sets will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. Only the + * **character_set_type** field is supported in the following format: + * `character_set_type="{characterSetType}"`. Accepted values include + * `DATABASE` and `NATIONAL`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet|AutonomousDatabaseCharacterSet} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listAutonomousDatabaseCharacterSetsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listAutonomousDatabaseCharacterSetsStream( - request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listAutonomousDatabaseCharacterSets']; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = + this._defaults['listAutonomousDatabaseCharacterSets']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listAutonomousDatabaseCharacterSets stream %j', request); return this.descriptors.page.listAutonomousDatabaseCharacterSets.createStream( this.innerApiCalls.listAutonomousDatabaseCharacterSets as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listAutonomousDatabaseCharacterSets`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for the Autonomous Database in the following - * format: projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 Autonomous DB Character Sets will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. Only the - * **character_set_type** field is supported in the following format: - * `character_set_type="{characterSetType}"`. Accepted values include - * `DATABASE` and `NATIONAL`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet|AutonomousDatabaseCharacterSet}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.list_autonomous_database_character_sets.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_ListAutonomousDatabaseCharacterSets_async - */ + /** + * Equivalent to `listAutonomousDatabaseCharacterSets`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for the Autonomous Database in the following + * format: projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 Autonomous DB Character Sets will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. Only the + * **character_set_type** field is supported in the following format: + * `character_set_type="{characterSetType}"`. Accepted values include + * `DATABASE` and `NATIONAL`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet|AutonomousDatabaseCharacterSet}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.list_autonomous_database_character_sets.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_ListAutonomousDatabaseCharacterSets_async + */ listAutonomousDatabaseCharacterSetsAsync( - request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseCharacterSetsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listAutonomousDatabaseCharacterSets']; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = + this._defaults['listAutonomousDatabaseCharacterSets']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listAutonomousDatabaseCharacterSets iterate %j', request); return this.descriptors.page.listAutonomousDatabaseCharacterSets.asyncIterate( this.innerApiCalls['listAutonomousDatabaseCharacterSets'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists the long-term and automatic backups of an Autonomous Database. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for ListAutonomousDatabaseBackups in the - * following format: projects/{project}/locations/{location}. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. Only the - * **autonomous_database_id** field is supported in the following format: - * `autonomous_database_id="{autonomous_database_id}"`. The accepted values - * must be a valid Autonomous Database ID, limited to the naming - * restrictions of the ID: ^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$). - * The ID must start with a letter, end with a letter or a number, and be - * a maximum of 63 characters. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 Autonomous DB Backups will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @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 Array of {@link protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup|AutonomousDatabaseBackup}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listAutonomousDatabaseBackupsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists the long-term and automatic backups of an Autonomous Database. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for ListAutonomousDatabaseBackups in the + * following format: projects/{project}/locations/{location}. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. Only the + * **autonomous_database_id** field is supported in the following format: + * `autonomous_database_id="{autonomous_database_id}"`. The accepted values + * must be a valid Autonomous Database ID, limited to the naming + * restrictions of the ID: ^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$). + * The ID must start with a letter, end with a letter or a number, and be + * a maximum of 63 characters. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 Autonomous DB Backups will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @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 Array of {@link protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup|AutonomousDatabaseBackup}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listAutonomousDatabaseBackupsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listAutonomousDatabaseBackups( - request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseBackup[], - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsRequest|null, - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsResponse - ]>; + request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseBackup[], + protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsRequest | null, + protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsResponse, + ] + >; listAutonomousDatabaseBackups( - request: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsRequest, - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseBackup>): void; + request: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsRequest, + | protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseBackup + >, + ): void; listAutonomousDatabaseBackups( - request: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsRequest, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsRequest, - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseBackup>): void; + request: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsRequest, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsRequest, + | protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseBackup + >, + ): void; listAutonomousDatabaseBackups( - request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsRequest, - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseBackup>, - callback?: PaginationCallback< + request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsRequest, - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseBackup>): - Promise<[ - protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseBackup[], - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsRequest|null, - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsResponse - ]>|void { + | protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseBackup + >, + callback?: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsRequest, + | protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseBackup + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseBackup[], + protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsRequest | null, + protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsRequest, - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseBackup>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsRequest, + | protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseBackup + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listAutonomousDatabaseBackups values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -7102,218 +9894,247 @@ export class OracleDatabaseClient { this._log.info('listAutonomousDatabaseBackups request %j', request); return this.innerApiCalls .listAutonomousDatabaseBackups(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseBackup[], - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsRequest|null, - protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsResponse - ]) => { - this._log.info('listAutonomousDatabaseBackups values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseBackup[], + protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsRequest | null, + protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsResponse, + ]) => { + this._log.info('listAutonomousDatabaseBackups values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listAutonomousDatabaseBackups`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for ListAutonomousDatabaseBackups in the - * following format: projects/{project}/locations/{location}. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. Only the - * **autonomous_database_id** field is supported in the following format: - * `autonomous_database_id="{autonomous_database_id}"`. The accepted values - * must be a valid Autonomous Database ID, limited to the naming - * restrictions of the ID: ^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$). - * The ID must start with a letter, end with a letter or a number, and be - * a maximum of 63 characters. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 Autonomous DB Backups will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup|AutonomousDatabaseBackup} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listAutonomousDatabaseBackupsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listAutonomousDatabaseBackups`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for ListAutonomousDatabaseBackups in the + * following format: projects/{project}/locations/{location}. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. Only the + * **autonomous_database_id** field is supported in the following format: + * `autonomous_database_id="{autonomous_database_id}"`. The accepted values + * must be a valid Autonomous Database ID, limited to the naming + * restrictions of the ID: ^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$). + * The ID must start with a letter, end with a letter or a number, and be + * a maximum of 63 characters. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 Autonomous DB Backups will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup|AutonomousDatabaseBackup} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listAutonomousDatabaseBackupsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listAutonomousDatabaseBackupsStream( - request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listAutonomousDatabaseBackups']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listAutonomousDatabaseBackups stream %j', request); return this.descriptors.page.listAutonomousDatabaseBackups.createStream( this.innerApiCalls.listAutonomousDatabaseBackups as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listAutonomousDatabaseBackups`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for ListAutonomousDatabaseBackups in the - * following format: projects/{project}/locations/{location}. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. Only the - * **autonomous_database_id** field is supported in the following format: - * `autonomous_database_id="{autonomous_database_id}"`. The accepted values - * must be a valid Autonomous Database ID, limited to the naming - * restrictions of the ID: ^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$). - * The ID must start with a letter, end with a letter or a number, and be - * a maximum of 63 characters. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 Autonomous DB Backups will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup|AutonomousDatabaseBackup}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.list_autonomous_database_backups.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_ListAutonomousDatabaseBackups_async - */ + /** + * Equivalent to `listAutonomousDatabaseBackups`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for ListAutonomousDatabaseBackups in the + * following format: projects/{project}/locations/{location}. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. Only the + * **autonomous_database_id** field is supported in the following format: + * `autonomous_database_id="{autonomous_database_id}"`. The accepted values + * must be a valid Autonomous Database ID, limited to the naming + * restrictions of the ID: ^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$). + * The ID must start with a letter, end with a letter or a number, and be + * a maximum of 63 characters. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 Autonomous DB Backups will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup|AutonomousDatabaseBackup}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.list_autonomous_database_backups.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_ListAutonomousDatabaseBackups_async + */ listAutonomousDatabaseBackupsAsync( - request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.oracledatabase.v1.IListAutonomousDatabaseBackupsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listAutonomousDatabaseBackups']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listAutonomousDatabaseBackups iterate %j', request); return this.descriptors.page.listAutonomousDatabaseBackups.asyncIterate( this.innerApiCalls['listAutonomousDatabaseBackups'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists the ODB Networks in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for the ODB Network in the following format: - * projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 ODB Networks will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. - * @param {string} [request.orderBy] - * Optional. An expression for ordering the results of the request. - * @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 Array of {@link protos.google.cloud.oracledatabase.v1.OdbNetwork|OdbNetwork}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listOdbNetworksAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists the ODB Networks in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for the ODB Network in the following format: + * projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 ODB Networks will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. + * @param {string} [request.orderBy] + * Optional. An expression for ordering the results of the request. + * @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 Array of {@link protos.google.cloud.oracledatabase.v1.OdbNetwork|OdbNetwork}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listOdbNetworksAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listOdbNetworks( - request?: protos.google.cloud.oracledatabase.v1.IListOdbNetworksRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.IOdbNetwork[], - protos.google.cloud.oracledatabase.v1.IListOdbNetworksRequest|null, - protos.google.cloud.oracledatabase.v1.IListOdbNetworksResponse - ]>; + request?: protos.google.cloud.oracledatabase.v1.IListOdbNetworksRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IOdbNetwork[], + protos.google.cloud.oracledatabase.v1.IListOdbNetworksRequest | null, + protos.google.cloud.oracledatabase.v1.IListOdbNetworksResponse, + ] + >; listOdbNetworks( - request: protos.google.cloud.oracledatabase.v1.IListOdbNetworksRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListOdbNetworksRequest, - protos.google.cloud.oracledatabase.v1.IListOdbNetworksResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IOdbNetwork>): void; + request: protos.google.cloud.oracledatabase.v1.IListOdbNetworksRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListOdbNetworksRequest, + | protos.google.cloud.oracledatabase.v1.IListOdbNetworksResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IOdbNetwork + >, + ): void; listOdbNetworks( - request: protos.google.cloud.oracledatabase.v1.IListOdbNetworksRequest, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListOdbNetworksRequest, - protos.google.cloud.oracledatabase.v1.IListOdbNetworksResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IOdbNetwork>): void; + request: protos.google.cloud.oracledatabase.v1.IListOdbNetworksRequest, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListOdbNetworksRequest, + | protos.google.cloud.oracledatabase.v1.IListOdbNetworksResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IOdbNetwork + >, + ): void; listOdbNetworks( - request?: protos.google.cloud.oracledatabase.v1.IListOdbNetworksRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListOdbNetworksRequest, - protos.google.cloud.oracledatabase.v1.IListOdbNetworksResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IOdbNetwork>, - callback?: PaginationCallback< + request?: protos.google.cloud.oracledatabase.v1.IListOdbNetworksRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.oracledatabase.v1.IListOdbNetworksRequest, - protos.google.cloud.oracledatabase.v1.IListOdbNetworksResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IOdbNetwork>): - Promise<[ - protos.google.cloud.oracledatabase.v1.IOdbNetwork[], - protos.google.cloud.oracledatabase.v1.IListOdbNetworksRequest|null, - protos.google.cloud.oracledatabase.v1.IListOdbNetworksResponse - ]>|void { + | protos.google.cloud.oracledatabase.v1.IListOdbNetworksResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IOdbNetwork + >, + callback?: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListOdbNetworksRequest, + | protos.google.cloud.oracledatabase.v1.IListOdbNetworksResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IOdbNetwork + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IOdbNetwork[], + protos.google.cloud.oracledatabase.v1.IListOdbNetworksRequest | null, + protos.google.cloud.oracledatabase.v1.IListOdbNetworksResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListOdbNetworksRequest, - protos.google.cloud.oracledatabase.v1.IListOdbNetworksResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IOdbNetwork>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListOdbNetworksRequest, + | protos.google.cloud.oracledatabase.v1.IListOdbNetworksResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IOdbNetwork + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listOdbNetworks values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -7322,210 +10143,239 @@ export class OracleDatabaseClient { this._log.info('listOdbNetworks request %j', request); return this.innerApiCalls .listOdbNetworks(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.oracledatabase.v1.IOdbNetwork[], - protos.google.cloud.oracledatabase.v1.IListOdbNetworksRequest|null, - protos.google.cloud.oracledatabase.v1.IListOdbNetworksResponse - ]) => { - this._log.info('listOdbNetworks values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.oracledatabase.v1.IOdbNetwork[], + protos.google.cloud.oracledatabase.v1.IListOdbNetworksRequest | null, + protos.google.cloud.oracledatabase.v1.IListOdbNetworksResponse, + ]) => { + this._log.info('listOdbNetworks values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listOdbNetworks`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for the ODB Network in the following format: - * projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 ODB Networks will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. - * @param {string} [request.orderBy] - * Optional. An expression for ordering the results of the request. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.OdbNetwork|OdbNetwork} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listOdbNetworksAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listOdbNetworks`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for the ODB Network in the following format: + * projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 ODB Networks will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. + * @param {string} [request.orderBy] + * Optional. An expression for ordering the results of the request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.OdbNetwork|OdbNetwork} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listOdbNetworksAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listOdbNetworksStream( - request?: protos.google.cloud.oracledatabase.v1.IListOdbNetworksRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.oracledatabase.v1.IListOdbNetworksRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listOdbNetworks']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listOdbNetworks stream %j', request); return this.descriptors.page.listOdbNetworks.createStream( this.innerApiCalls.listOdbNetworks as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listOdbNetworks`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for the ODB Network in the following format: - * projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 ODB Networks will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. - * @param {string} [request.orderBy] - * Optional. An expression for ordering the results of the request. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.oracledatabase.v1.OdbNetwork|OdbNetwork}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.list_odb_networks.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_ListOdbNetworks_async - */ + /** + * Equivalent to `listOdbNetworks`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for the ODB Network in the following format: + * projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 ODB Networks will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. + * @param {string} [request.orderBy] + * Optional. An expression for ordering the results of the request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.oracledatabase.v1.OdbNetwork|OdbNetwork}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.list_odb_networks.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_ListOdbNetworks_async + */ listOdbNetworksAsync( - request?: protos.google.cloud.oracledatabase.v1.IListOdbNetworksRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.oracledatabase.v1.IListOdbNetworksRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listOdbNetworks']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listOdbNetworks iterate %j', request); return this.descriptors.page.listOdbNetworks.asyncIterate( this.innerApiCalls['listOdbNetworks'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists all the ODB Subnets in a given ODB Network. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for the OdbSubnet in the following format: - * projects/{project}/locations/{location}/odbNetworks/{odb_network}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 ODB Networks will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. - * @param {string} [request.orderBy] - * Optional. An expression for ordering the results of the request. - * @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 Array of {@link protos.google.cloud.oracledatabase.v1.OdbSubnet|OdbSubnet}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listOdbSubnetsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists all the ODB Subnets in a given ODB Network. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for the OdbSubnet in the following format: + * projects/{project}/locations/{location}/odbNetworks/{odb_network}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 ODB Networks will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. + * @param {string} [request.orderBy] + * Optional. An expression for ordering the results of the request. + * @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 Array of {@link protos.google.cloud.oracledatabase.v1.OdbSubnet|OdbSubnet}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listOdbSubnetsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listOdbSubnets( - request?: protos.google.cloud.oracledatabase.v1.IListOdbSubnetsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.IOdbSubnet[], - protos.google.cloud.oracledatabase.v1.IListOdbSubnetsRequest|null, - protos.google.cloud.oracledatabase.v1.IListOdbSubnetsResponse - ]>; + request?: protos.google.cloud.oracledatabase.v1.IListOdbSubnetsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IOdbSubnet[], + protos.google.cloud.oracledatabase.v1.IListOdbSubnetsRequest | null, + protos.google.cloud.oracledatabase.v1.IListOdbSubnetsResponse, + ] + >; listOdbSubnets( - request: protos.google.cloud.oracledatabase.v1.IListOdbSubnetsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListOdbSubnetsRequest, - protos.google.cloud.oracledatabase.v1.IListOdbSubnetsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IOdbSubnet>): void; + request: protos.google.cloud.oracledatabase.v1.IListOdbSubnetsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListOdbSubnetsRequest, + | protos.google.cloud.oracledatabase.v1.IListOdbSubnetsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IOdbSubnet + >, + ): void; listOdbSubnets( - request: protos.google.cloud.oracledatabase.v1.IListOdbSubnetsRequest, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListOdbSubnetsRequest, - protos.google.cloud.oracledatabase.v1.IListOdbSubnetsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IOdbSubnet>): void; + request: protos.google.cloud.oracledatabase.v1.IListOdbSubnetsRequest, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListOdbSubnetsRequest, + | protos.google.cloud.oracledatabase.v1.IListOdbSubnetsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IOdbSubnet + >, + ): void; listOdbSubnets( - request?: protos.google.cloud.oracledatabase.v1.IListOdbSubnetsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListOdbSubnetsRequest, - protos.google.cloud.oracledatabase.v1.IListOdbSubnetsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IOdbSubnet>, - callback?: PaginationCallback< + request?: protos.google.cloud.oracledatabase.v1.IListOdbSubnetsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.oracledatabase.v1.IListOdbSubnetsRequest, - protos.google.cloud.oracledatabase.v1.IListOdbSubnetsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IOdbSubnet>): - Promise<[ - protos.google.cloud.oracledatabase.v1.IOdbSubnet[], - protos.google.cloud.oracledatabase.v1.IListOdbSubnetsRequest|null, - protos.google.cloud.oracledatabase.v1.IListOdbSubnetsResponse - ]>|void { + | protos.google.cloud.oracledatabase.v1.IListOdbSubnetsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IOdbSubnet + >, + callback?: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListOdbSubnetsRequest, + | protos.google.cloud.oracledatabase.v1.IListOdbSubnetsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IOdbSubnet + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IOdbSubnet[], + protos.google.cloud.oracledatabase.v1.IListOdbSubnetsRequest | null, + protos.google.cloud.oracledatabase.v1.IListOdbSubnetsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListOdbSubnetsRequest, - protos.google.cloud.oracledatabase.v1.IListOdbSubnetsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IOdbSubnet>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListOdbSubnetsRequest, + | protos.google.cloud.oracledatabase.v1.IListOdbSubnetsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IOdbSubnet + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listOdbSubnets values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -7534,211 +10384,240 @@ export class OracleDatabaseClient { this._log.info('listOdbSubnets request %j', request); return this.innerApiCalls .listOdbSubnets(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.oracledatabase.v1.IOdbSubnet[], - protos.google.cloud.oracledatabase.v1.IListOdbSubnetsRequest|null, - protos.google.cloud.oracledatabase.v1.IListOdbSubnetsResponse - ]) => { - this._log.info('listOdbSubnets values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.oracledatabase.v1.IOdbSubnet[], + protos.google.cloud.oracledatabase.v1.IListOdbSubnetsRequest | null, + protos.google.cloud.oracledatabase.v1.IListOdbSubnetsResponse, + ]) => { + this._log.info('listOdbSubnets values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listOdbSubnets`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for the OdbSubnet in the following format: - * projects/{project}/locations/{location}/odbNetworks/{odb_network}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 ODB Networks will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. - * @param {string} [request.orderBy] - * Optional. An expression for ordering the results of the request. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.OdbSubnet|OdbSubnet} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listOdbSubnetsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listOdbSubnets`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for the OdbSubnet in the following format: + * projects/{project}/locations/{location}/odbNetworks/{odb_network}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 ODB Networks will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. + * @param {string} [request.orderBy] + * Optional. An expression for ordering the results of the request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.OdbSubnet|OdbSubnet} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listOdbSubnetsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listOdbSubnetsStream( - request?: protos.google.cloud.oracledatabase.v1.IListOdbSubnetsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.oracledatabase.v1.IListOdbSubnetsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listOdbSubnets']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listOdbSubnets stream %j', request); return this.descriptors.page.listOdbSubnets.createStream( this.innerApiCalls.listOdbSubnets as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listOdbSubnets`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for the OdbSubnet in the following format: - * projects/{project}/locations/{location}/odbNetworks/{odb_network}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 ODB Networks will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. - * @param {string} [request.orderBy] - * Optional. An expression for ordering the results of the request. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.oracledatabase.v1.OdbSubnet|OdbSubnet}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.list_odb_subnets.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_ListOdbSubnets_async - */ + /** + * Equivalent to `listOdbSubnets`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for the OdbSubnet in the following format: + * projects/{project}/locations/{location}/odbNetworks/{odb_network}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 ODB Networks will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. + * @param {string} [request.orderBy] + * Optional. An expression for ordering the results of the request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.oracledatabase.v1.OdbSubnet|OdbSubnet}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.list_odb_subnets.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_ListOdbSubnets_async + */ listOdbSubnetsAsync( - request?: protos.google.cloud.oracledatabase.v1.IListOdbSubnetsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.oracledatabase.v1.IListOdbSubnetsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listOdbSubnets']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listOdbSubnets iterate %j', request); return this.descriptors.page.listOdbSubnets.asyncIterate( this.innerApiCalls['listOdbSubnets'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists all the Exadb (Exascale) VM Clusters for the given project and - * location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for ExadbVmClusters in the following format: - * projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 ExadbVmClusters will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. - * @param {string} [request.orderBy] - * Optional. An expression for ordering the results of the request. - * @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 Array of {@link protos.google.cloud.oracledatabase.v1.ExadbVmCluster|ExadbVmCluster}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listExadbVmClustersAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists all the Exadb (Exascale) VM Clusters for the given project and + * location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for ExadbVmClusters in the following format: + * projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 ExadbVmClusters will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. + * @param {string} [request.orderBy] + * Optional. An expression for ordering the results of the request. + * @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 Array of {@link protos.google.cloud.oracledatabase.v1.ExadbVmCluster|ExadbVmCluster}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listExadbVmClustersAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listExadbVmClusters( - request?: protos.google.cloud.oracledatabase.v1.IListExadbVmClustersRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.IExadbVmCluster[], - protos.google.cloud.oracledatabase.v1.IListExadbVmClustersRequest|null, - protos.google.cloud.oracledatabase.v1.IListExadbVmClustersResponse - ]>; + request?: protos.google.cloud.oracledatabase.v1.IListExadbVmClustersRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IExadbVmCluster[], + protos.google.cloud.oracledatabase.v1.IListExadbVmClustersRequest | null, + protos.google.cloud.oracledatabase.v1.IListExadbVmClustersResponse, + ] + >; listExadbVmClusters( - request: protos.google.cloud.oracledatabase.v1.IListExadbVmClustersRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListExadbVmClustersRequest, - protos.google.cloud.oracledatabase.v1.IListExadbVmClustersResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IExadbVmCluster>): void; + request: protos.google.cloud.oracledatabase.v1.IListExadbVmClustersRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListExadbVmClustersRequest, + | protos.google.cloud.oracledatabase.v1.IListExadbVmClustersResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IExadbVmCluster + >, + ): void; listExadbVmClusters( - request: protos.google.cloud.oracledatabase.v1.IListExadbVmClustersRequest, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListExadbVmClustersRequest, - protos.google.cloud.oracledatabase.v1.IListExadbVmClustersResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IExadbVmCluster>): void; + request: protos.google.cloud.oracledatabase.v1.IListExadbVmClustersRequest, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListExadbVmClustersRequest, + | protos.google.cloud.oracledatabase.v1.IListExadbVmClustersResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IExadbVmCluster + >, + ): void; listExadbVmClusters( - request?: protos.google.cloud.oracledatabase.v1.IListExadbVmClustersRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListExadbVmClustersRequest, - protos.google.cloud.oracledatabase.v1.IListExadbVmClustersResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IExadbVmCluster>, - callback?: PaginationCallback< + request?: protos.google.cloud.oracledatabase.v1.IListExadbVmClustersRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.oracledatabase.v1.IListExadbVmClustersRequest, - protos.google.cloud.oracledatabase.v1.IListExadbVmClustersResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IExadbVmCluster>): - Promise<[ - protos.google.cloud.oracledatabase.v1.IExadbVmCluster[], - protos.google.cloud.oracledatabase.v1.IListExadbVmClustersRequest|null, - protos.google.cloud.oracledatabase.v1.IListExadbVmClustersResponse - ]>|void { + | protos.google.cloud.oracledatabase.v1.IListExadbVmClustersResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IExadbVmCluster + >, + callback?: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListExadbVmClustersRequest, + | protos.google.cloud.oracledatabase.v1.IListExadbVmClustersResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IExadbVmCluster + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IExadbVmCluster[], + protos.google.cloud.oracledatabase.v1.IListExadbVmClustersRequest | null, + protos.google.cloud.oracledatabase.v1.IListExadbVmClustersResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListExadbVmClustersRequest, - protos.google.cloud.oracledatabase.v1.IListExadbVmClustersResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IExadbVmCluster>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListExadbVmClustersRequest, + | protos.google.cloud.oracledatabase.v1.IListExadbVmClustersResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IExadbVmCluster + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listExadbVmClusters values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -7747,213 +10626,242 @@ export class OracleDatabaseClient { this._log.info('listExadbVmClusters request %j', request); return this.innerApiCalls .listExadbVmClusters(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.oracledatabase.v1.IExadbVmCluster[], - protos.google.cloud.oracledatabase.v1.IListExadbVmClustersRequest|null, - protos.google.cloud.oracledatabase.v1.IListExadbVmClustersResponse - ]) => { - this._log.info('listExadbVmClusters values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.oracledatabase.v1.IExadbVmCluster[], + protos.google.cloud.oracledatabase.v1.IListExadbVmClustersRequest | null, + protos.google.cloud.oracledatabase.v1.IListExadbVmClustersResponse, + ]) => { + this._log.info('listExadbVmClusters values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listExadbVmClusters`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for ExadbVmClusters in the following format: - * projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 ExadbVmClusters will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. - * @param {string} [request.orderBy] - * Optional. An expression for ordering the results of the request. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.ExadbVmCluster|ExadbVmCluster} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listExadbVmClustersAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listExadbVmClusters`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for ExadbVmClusters in the following format: + * projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 ExadbVmClusters will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. + * @param {string} [request.orderBy] + * Optional. An expression for ordering the results of the request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.ExadbVmCluster|ExadbVmCluster} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listExadbVmClustersAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listExadbVmClustersStream( - request?: protos.google.cloud.oracledatabase.v1.IListExadbVmClustersRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.oracledatabase.v1.IListExadbVmClustersRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listExadbVmClusters']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listExadbVmClusters stream %j', request); return this.descriptors.page.listExadbVmClusters.createStream( this.innerApiCalls.listExadbVmClusters as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listExadbVmClusters`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for ExadbVmClusters in the following format: - * projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 ExadbVmClusters will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. - * @param {string} [request.orderBy] - * Optional. An expression for ordering the results of the request. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.oracledatabase.v1.ExadbVmCluster|ExadbVmCluster}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.list_exadb_vm_clusters.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_ListExadbVmClusters_async - */ + /** + * Equivalent to `listExadbVmClusters`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for ExadbVmClusters in the following format: + * projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 ExadbVmClusters will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. + * @param {string} [request.orderBy] + * Optional. An expression for ordering the results of the request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.oracledatabase.v1.ExadbVmCluster|ExadbVmCluster}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.list_exadb_vm_clusters.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_ListExadbVmClusters_async + */ listExadbVmClustersAsync( - request?: protos.google.cloud.oracledatabase.v1.IListExadbVmClustersRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.oracledatabase.v1.IListExadbVmClustersRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listExadbVmClusters']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listExadbVmClusters iterate %j', request); return this.descriptors.page.listExadbVmClusters.asyncIterate( this.innerApiCalls['listExadbVmClusters'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists all the ExascaleDB Storage Vaults for the given project and - * location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for ExascaleDbStorageVault in the following - * format: projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 ExascaleDbStorageVaults will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. Filter - * the list as specified in https://google.aip.dev/160. - * @param {string} [request.orderBy] - * Optional. An expression for ordering the results of the request. Order - * results as specified in https://google.aip.dev/132. - * @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 Array of {@link protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault|ExascaleDbStorageVault}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listExascaleDbStorageVaultsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists all the ExascaleDB Storage Vaults for the given project and + * location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for ExascaleDbStorageVault in the following + * format: projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 ExascaleDbStorageVaults will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. Filter + * the list as specified in https://google.aip.dev/160. + * @param {string} [request.orderBy] + * Optional. An expression for ordering the results of the request. Order + * results as specified in https://google.aip.dev/132. + * @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 Array of {@link protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault|ExascaleDbStorageVault}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listExascaleDbStorageVaultsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listExascaleDbStorageVaults( - request?: protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault[], - protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsRequest|null, - protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsResponse - ]>; + request?: protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault[], + protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsRequest | null, + protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsResponse, + ] + >; listExascaleDbStorageVaults( - request: protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsRequest, - protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault>): void; + request: protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsRequest, + | protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault + >, + ): void; listExascaleDbStorageVaults( - request: protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsRequest, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsRequest, - protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault>): void; + request: protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsRequest, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsRequest, + | protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault + >, + ): void; listExascaleDbStorageVaults( - request?: protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsRequest, - protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault>, - callback?: PaginationCallback< + request?: protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsRequest, - protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault>): - Promise<[ - protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault[], - protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsRequest|null, - protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsResponse - ]>|void { + | protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault + >, + callback?: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsRequest, + | protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault[], + protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsRequest | null, + protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsRequest, - protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsRequest, + | protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listExascaleDbStorageVaults values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -7962,214 +10870,243 @@ export class OracleDatabaseClient { this._log.info('listExascaleDbStorageVaults request %j', request); return this.innerApiCalls .listExascaleDbStorageVaults(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault[], - protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsRequest|null, - protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsResponse - ]) => { - this._log.info('listExascaleDbStorageVaults values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault[], + protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsRequest | null, + protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsResponse, + ]) => { + this._log.info('listExascaleDbStorageVaults values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listExascaleDbStorageVaults`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for ExascaleDbStorageVault in the following - * format: projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 ExascaleDbStorageVaults will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. Filter - * the list as specified in https://google.aip.dev/160. - * @param {string} [request.orderBy] - * Optional. An expression for ordering the results of the request. Order - * results as specified in https://google.aip.dev/132. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault|ExascaleDbStorageVault} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listExascaleDbStorageVaultsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listExascaleDbStorageVaults`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for ExascaleDbStorageVault in the following + * format: projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 ExascaleDbStorageVaults will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. Filter + * the list as specified in https://google.aip.dev/160. + * @param {string} [request.orderBy] + * Optional. An expression for ordering the results of the request. Order + * results as specified in https://google.aip.dev/132. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault|ExascaleDbStorageVault} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listExascaleDbStorageVaultsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listExascaleDbStorageVaultsStream( - request?: protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listExascaleDbStorageVaults']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listExascaleDbStorageVaults stream %j', request); return this.descriptors.page.listExascaleDbStorageVaults.createStream( this.innerApiCalls.listExascaleDbStorageVaults as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listExascaleDbStorageVaults`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for ExascaleDbStorageVault in the following - * format: projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 ExascaleDbStorageVaults will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. Filter - * the list as specified in https://google.aip.dev/160. - * @param {string} [request.orderBy] - * Optional. An expression for ordering the results of the request. Order - * results as specified in https://google.aip.dev/132. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault|ExascaleDbStorageVault}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.list_exascale_db_storage_vaults.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_ListExascaleDbStorageVaults_async - */ + /** + * Equivalent to `listExascaleDbStorageVaults`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for ExascaleDbStorageVault in the following + * format: projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 ExascaleDbStorageVaults will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. Filter + * the list as specified in https://google.aip.dev/160. + * @param {string} [request.orderBy] + * Optional. An expression for ordering the results of the request. Order + * results as specified in https://google.aip.dev/132. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault|ExascaleDbStorageVault}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.list_exascale_db_storage_vaults.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_ListExascaleDbStorageVaults_async + */ listExascaleDbStorageVaultsAsync( - request?: protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.oracledatabase.v1.IListExascaleDbStorageVaultsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listExascaleDbStorageVaults']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listExascaleDbStorageVaults iterate %j', request); return this.descriptors.page.listExascaleDbStorageVaults.asyncIterate( this.innerApiCalls['listExascaleDbStorageVaults'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists all the DbSystemInitialStorageSizes for the given project and - * location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for the DbSystemInitialStorageSize resource with - * the format: projects/{project}/locations/{location} - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, a maximum of 50 DbSystemInitialStorageSizes will be - * returned. The maximum value is 1000; values above 1000 will be reset to - * 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying the requested page of results to return. All - * fields except the filter should remain the same as in the request that - * provided this page token. - * @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 Array of {@link protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize|DbSystemInitialStorageSize}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listDbSystemInitialStorageSizesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists all the DbSystemInitialStorageSizes for the given project and + * location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for the DbSystemInitialStorageSize resource with + * the format: projects/{project}/locations/{location} + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, a maximum of 50 DbSystemInitialStorageSizes will be + * returned. The maximum value is 1000; values above 1000 will be reset to + * 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying the requested page of results to return. All + * fields except the filter should remain the same as in the request that + * provided this page token. + * @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 Array of {@link protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize|DbSystemInitialStorageSize}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listDbSystemInitialStorageSizesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listDbSystemInitialStorageSizes( - request?: protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.IDbSystemInitialStorageSize[], - protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesRequest|null, - protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesResponse - ]>; + request?: protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IDbSystemInitialStorageSize[], + protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesRequest | null, + protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesResponse, + ] + >; listDbSystemInitialStorageSizes( - request: protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesRequest, - protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDbSystemInitialStorageSize>): void; + request: protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesRequest, + | protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDbSystemInitialStorageSize + >, + ): void; listDbSystemInitialStorageSizes( - request: protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesRequest, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesRequest, - protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDbSystemInitialStorageSize>): void; + request: protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesRequest, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesRequest, + | protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDbSystemInitialStorageSize + >, + ): void; listDbSystemInitialStorageSizes( - request?: protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesRequest, - protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDbSystemInitialStorageSize>, - callback?: PaginationCallback< + request?: protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesRequest, - protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDbSystemInitialStorageSize>): - Promise<[ - protos.google.cloud.oracledatabase.v1.IDbSystemInitialStorageSize[], - protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesRequest|null, - protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesResponse - ]>|void { + | protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDbSystemInitialStorageSize + >, + callback?: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesRequest, + | protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDbSystemInitialStorageSize + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IDbSystemInitialStorageSize[], + protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesRequest | null, + protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesRequest, - protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDbSystemInitialStorageSize>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesRequest, + | protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDbSystemInitialStorageSize + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listDbSystemInitialStorageSizes values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -8178,211 +11115,242 @@ export class OracleDatabaseClient { this._log.info('listDbSystemInitialStorageSizes request %j', request); return this.innerApiCalls .listDbSystemInitialStorageSizes(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.oracledatabase.v1.IDbSystemInitialStorageSize[], - protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesRequest|null, - protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesResponse - ]) => { - this._log.info('listDbSystemInitialStorageSizes values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.oracledatabase.v1.IDbSystemInitialStorageSize[], + protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesRequest | null, + protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesResponse, + ]) => { + this._log.info('listDbSystemInitialStorageSizes values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listDbSystemInitialStorageSizes`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for the DbSystemInitialStorageSize resource with - * the format: projects/{project}/locations/{location} - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, a maximum of 50 DbSystemInitialStorageSizes will be - * returned. The maximum value is 1000; values above 1000 will be reset to - * 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying the requested page of results to return. All - * fields except the filter should remain the same as in the request that - * provided this page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize|DbSystemInitialStorageSize} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listDbSystemInitialStorageSizesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listDbSystemInitialStorageSizes`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for the DbSystemInitialStorageSize resource with + * the format: projects/{project}/locations/{location} + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, a maximum of 50 DbSystemInitialStorageSizes will be + * returned. The maximum value is 1000; values above 1000 will be reset to + * 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying the requested page of results to return. All + * fields except the filter should remain the same as in the request that + * provided this page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize|DbSystemInitialStorageSize} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listDbSystemInitialStorageSizesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listDbSystemInitialStorageSizesStream( - request?: protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listDbSystemInitialStorageSizes']; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = + this._defaults['listDbSystemInitialStorageSizes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listDbSystemInitialStorageSizes stream %j', request); return this.descriptors.page.listDbSystemInitialStorageSizes.createStream( this.innerApiCalls.listDbSystemInitialStorageSizes as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listDbSystemInitialStorageSizes`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for the DbSystemInitialStorageSize resource with - * the format: projects/{project}/locations/{location} - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, a maximum of 50 DbSystemInitialStorageSizes will be - * returned. The maximum value is 1000; values above 1000 will be reset to - * 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying the requested page of results to return. All - * fields except the filter should remain the same as in the request that - * provided this page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize|DbSystemInitialStorageSize}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.list_db_system_initial_storage_sizes.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_ListDbSystemInitialStorageSizes_async - */ + /** + * Equivalent to `listDbSystemInitialStorageSizes`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for the DbSystemInitialStorageSize resource with + * the format: projects/{project}/locations/{location} + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, a maximum of 50 DbSystemInitialStorageSizes will be + * returned. The maximum value is 1000; values above 1000 will be reset to + * 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying the requested page of results to return. All + * fields except the filter should remain the same as in the request that + * provided this page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize|DbSystemInitialStorageSize}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.list_db_system_initial_storage_sizes.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_ListDbSystemInitialStorageSizes_async + */ listDbSystemInitialStorageSizesAsync( - request?: protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.oracledatabase.v1.IListDbSystemInitialStorageSizesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listDbSystemInitialStorageSizes']; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = + this._defaults['listDbSystemInitialStorageSizes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listDbSystemInitialStorageSizes iterate %j', request); return this.descriptors.page.listDbSystemInitialStorageSizes.asyncIterate( this.innerApiCalls['listDbSystemInitialStorageSizes'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists all the Databases for the given project, location and DbSystem. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name in the following format: - * projects/{project}/locations/{region} - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, a maximum of 50 Databases will be returned. - * The maximum value is 1000; values above 1000 will be reset to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying the requested page of results to return. All - * fields except the filter should remain the same as in the request that - * provided this page token. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. list for - * container databases is supported only with a valid dbSystem (full resource - * name) filter in this format: - * `dbSystem="projects/{project}/locations/{location}/dbSystems/{dbSystemId}"` - * @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 Array of {@link protos.google.cloud.oracledatabase.v1.Database|Database}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listDatabasesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists all the Databases for the given project, location and DbSystem. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name in the following format: + * projects/{project}/locations/{region} + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, a maximum of 50 Databases will be returned. + * The maximum value is 1000; values above 1000 will be reset to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying the requested page of results to return. All + * fields except the filter should remain the same as in the request that + * provided this page token. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. list for + * container databases is supported only with a valid dbSystem (full resource + * name) filter in this format: + * `dbSystem="projects/{project}/locations/{location}/dbSystems/{dbSystemId}"` + * @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 Array of {@link protos.google.cloud.oracledatabase.v1.Database|Database}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listDatabasesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listDatabases( - request?: protos.google.cloud.oracledatabase.v1.IListDatabasesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.IDatabase[], - protos.google.cloud.oracledatabase.v1.IListDatabasesRequest|null, - protos.google.cloud.oracledatabase.v1.IListDatabasesResponse - ]>; + request?: protos.google.cloud.oracledatabase.v1.IListDatabasesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IDatabase[], + protos.google.cloud.oracledatabase.v1.IListDatabasesRequest | null, + protos.google.cloud.oracledatabase.v1.IListDatabasesResponse, + ] + >; listDatabases( - request: protos.google.cloud.oracledatabase.v1.IListDatabasesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDatabasesRequest, - protos.google.cloud.oracledatabase.v1.IListDatabasesResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDatabase>): void; + request: protos.google.cloud.oracledatabase.v1.IListDatabasesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDatabasesRequest, + | protos.google.cloud.oracledatabase.v1.IListDatabasesResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDatabase + >, + ): void; listDatabases( - request: protos.google.cloud.oracledatabase.v1.IListDatabasesRequest, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDatabasesRequest, - protos.google.cloud.oracledatabase.v1.IListDatabasesResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDatabase>): void; + request: protos.google.cloud.oracledatabase.v1.IListDatabasesRequest, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDatabasesRequest, + | protos.google.cloud.oracledatabase.v1.IListDatabasesResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDatabase + >, + ): void; listDatabases( - request?: protos.google.cloud.oracledatabase.v1.IListDatabasesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDatabasesRequest, - protos.google.cloud.oracledatabase.v1.IListDatabasesResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDatabase>, - callback?: PaginationCallback< + request?: protos.google.cloud.oracledatabase.v1.IListDatabasesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.oracledatabase.v1.IListDatabasesRequest, - protos.google.cloud.oracledatabase.v1.IListDatabasesResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDatabase>): - Promise<[ - protos.google.cloud.oracledatabase.v1.IDatabase[], - protos.google.cloud.oracledatabase.v1.IListDatabasesRequest|null, - protos.google.cloud.oracledatabase.v1.IListDatabasesResponse - ]>|void { + | protos.google.cloud.oracledatabase.v1.IListDatabasesResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDatabase + >, + callback?: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDatabasesRequest, + | protos.google.cloud.oracledatabase.v1.IListDatabasesResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDatabase + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IDatabase[], + protos.google.cloud.oracledatabase.v1.IListDatabasesRequest | null, + protos.google.cloud.oracledatabase.v1.IListDatabasesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDatabasesRequest, - protos.google.cloud.oracledatabase.v1.IListDatabasesResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDatabase>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDatabasesRequest, + | protos.google.cloud.oracledatabase.v1.IListDatabasesResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDatabase + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listDatabases values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -8391,221 +11359,250 @@ export class OracleDatabaseClient { this._log.info('listDatabases request %j', request); return this.innerApiCalls .listDatabases(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.oracledatabase.v1.IDatabase[], - protos.google.cloud.oracledatabase.v1.IListDatabasesRequest|null, - protos.google.cloud.oracledatabase.v1.IListDatabasesResponse - ]) => { - this._log.info('listDatabases values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.oracledatabase.v1.IDatabase[], + protos.google.cloud.oracledatabase.v1.IListDatabasesRequest | null, + protos.google.cloud.oracledatabase.v1.IListDatabasesResponse, + ]) => { + this._log.info('listDatabases values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listDatabases`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name in the following format: - * projects/{project}/locations/{region} - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, a maximum of 50 Databases will be returned. - * The maximum value is 1000; values above 1000 will be reset to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying the requested page of results to return. All - * fields except the filter should remain the same as in the request that - * provided this page token. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. list for - * container databases is supported only with a valid dbSystem (full resource - * name) filter in this format: - * `dbSystem="projects/{project}/locations/{location}/dbSystems/{dbSystemId}"` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.Database|Database} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listDatabasesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listDatabases`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name in the following format: + * projects/{project}/locations/{region} + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, a maximum of 50 Databases will be returned. + * The maximum value is 1000; values above 1000 will be reset to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying the requested page of results to return. All + * fields except the filter should remain the same as in the request that + * provided this page token. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. list for + * container databases is supported only with a valid dbSystem (full resource + * name) filter in this format: + * `dbSystem="projects/{project}/locations/{location}/dbSystems/{dbSystemId}"` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.Database|Database} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listDatabasesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listDatabasesStream( - request?: protos.google.cloud.oracledatabase.v1.IListDatabasesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.oracledatabase.v1.IListDatabasesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listDatabases']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listDatabases stream %j', request); return this.descriptors.page.listDatabases.createStream( this.innerApiCalls.listDatabases as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listDatabases`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name in the following format: - * projects/{project}/locations/{region} - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, a maximum of 50 Databases will be returned. - * The maximum value is 1000; values above 1000 will be reset to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying the requested page of results to return. All - * fields except the filter should remain the same as in the request that - * provided this page token. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. list for - * container databases is supported only with a valid dbSystem (full resource - * name) filter in this format: - * `dbSystem="projects/{project}/locations/{location}/dbSystems/{dbSystemId}"` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.oracledatabase.v1.Database|Database}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.list_databases.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_ListDatabases_async - */ + /** + * Equivalent to `listDatabases`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name in the following format: + * projects/{project}/locations/{region} + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, a maximum of 50 Databases will be returned. + * The maximum value is 1000; values above 1000 will be reset to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying the requested page of results to return. All + * fields except the filter should remain the same as in the request that + * provided this page token. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. list for + * container databases is supported only with a valid dbSystem (full resource + * name) filter in this format: + * `dbSystem="projects/{project}/locations/{location}/dbSystems/{dbSystemId}"` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.oracledatabase.v1.Database|Database}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.list_databases.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_ListDatabases_async + */ listDatabasesAsync( - request?: protos.google.cloud.oracledatabase.v1.IListDatabasesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.oracledatabase.v1.IListDatabasesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listDatabases']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listDatabases iterate %j', request); return this.descriptors.page.listDatabases.asyncIterate( this.innerApiCalls['listDatabases'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists all the PluggableDatabases for the given project, location and - * Container Database. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent, which owns this collection of PluggableDatabases. - * Format: projects/{project}/locations/{location} - * @param {number} [request.pageSize] - * Optional. The maximum number of PluggableDatabases to return. The service - * may return fewer than this value. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListPluggableDatabases` - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListPluggableDatabases` - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. List for - * pluggable databases is supported only with a valid container database (full - * resource name) filter in this format: - * `database="projects/{project}/locations/{location}/databases/{database}"` - * @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 Array of {@link protos.google.cloud.oracledatabase.v1.PluggableDatabase|PluggableDatabase}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listPluggableDatabasesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists all the PluggableDatabases for the given project, location and + * Container Database. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent, which owns this collection of PluggableDatabases. + * Format: projects/{project}/locations/{location} + * @param {number} [request.pageSize] + * Optional. The maximum number of PluggableDatabases to return. The service + * may return fewer than this value. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListPluggableDatabases` + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListPluggableDatabases` + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. List for + * pluggable databases is supported only with a valid container database (full + * resource name) filter in this format: + * `database="projects/{project}/locations/{location}/databases/{database}"` + * @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 Array of {@link protos.google.cloud.oracledatabase.v1.PluggableDatabase|PluggableDatabase}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listPluggableDatabasesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listPluggableDatabases( - request?: protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.IPluggableDatabase[], - protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesRequest|null, - protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesResponse - ]>; + request?: protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IPluggableDatabase[], + protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesRequest | null, + protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesResponse, + ] + >; listPluggableDatabases( - request: protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesRequest, - protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IPluggableDatabase>): void; + request: protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesRequest, + | protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IPluggableDatabase + >, + ): void; listPluggableDatabases( - request: protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesRequest, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesRequest, - protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IPluggableDatabase>): void; + request: protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesRequest, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesRequest, + | protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IPluggableDatabase + >, + ): void; listPluggableDatabases( - request?: protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesRequest, - protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IPluggableDatabase>, - callback?: PaginationCallback< + request?: protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesRequest, - protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IPluggableDatabase>): - Promise<[ - protos.google.cloud.oracledatabase.v1.IPluggableDatabase[], - protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesRequest|null, - protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesResponse - ]>|void { + | protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IPluggableDatabase + >, + callback?: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesRequest, + | protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IPluggableDatabase + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IPluggableDatabase[], + protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesRequest | null, + protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesRequest, - protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IPluggableDatabase>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesRequest, + | protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IPluggableDatabase + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listPluggableDatabases values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -8614,218 +11611,247 @@ export class OracleDatabaseClient { this._log.info('listPluggableDatabases request %j', request); return this.innerApiCalls .listPluggableDatabases(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.oracledatabase.v1.IPluggableDatabase[], - protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesRequest|null, - protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesResponse - ]) => { - this._log.info('listPluggableDatabases values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.oracledatabase.v1.IPluggableDatabase[], + protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesRequest | null, + protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesResponse, + ]) => { + this._log.info('listPluggableDatabases values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listPluggableDatabases`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent, which owns this collection of PluggableDatabases. - * Format: projects/{project}/locations/{location} - * @param {number} [request.pageSize] - * Optional. The maximum number of PluggableDatabases to return. The service - * may return fewer than this value. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListPluggableDatabases` - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListPluggableDatabases` - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. List for - * pluggable databases is supported only with a valid container database (full - * resource name) filter in this format: - * `database="projects/{project}/locations/{location}/databases/{database}"` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.PluggableDatabase|PluggableDatabase} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listPluggableDatabasesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listPluggableDatabases`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent, which owns this collection of PluggableDatabases. + * Format: projects/{project}/locations/{location} + * @param {number} [request.pageSize] + * Optional. The maximum number of PluggableDatabases to return. The service + * may return fewer than this value. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListPluggableDatabases` + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListPluggableDatabases` + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. List for + * pluggable databases is supported only with a valid container database (full + * resource name) filter in this format: + * `database="projects/{project}/locations/{location}/databases/{database}"` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.PluggableDatabase|PluggableDatabase} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listPluggableDatabasesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listPluggableDatabasesStream( - request?: protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listPluggableDatabases']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listPluggableDatabases stream %j', request); return this.descriptors.page.listPluggableDatabases.createStream( this.innerApiCalls.listPluggableDatabases as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listPluggableDatabases`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent, which owns this collection of PluggableDatabases. - * Format: projects/{project}/locations/{location} - * @param {number} [request.pageSize] - * Optional. The maximum number of PluggableDatabases to return. The service - * may return fewer than this value. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListPluggableDatabases` - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListPluggableDatabases` - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. List for - * pluggable databases is supported only with a valid container database (full - * resource name) filter in this format: - * `database="projects/{project}/locations/{location}/databases/{database}"` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.oracledatabase.v1.PluggableDatabase|PluggableDatabase}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.list_pluggable_databases.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_ListPluggableDatabases_async - */ + /** + * Equivalent to `listPluggableDatabases`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent, which owns this collection of PluggableDatabases. + * Format: projects/{project}/locations/{location} + * @param {number} [request.pageSize] + * Optional. The maximum number of PluggableDatabases to return. The service + * may return fewer than this value. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListPluggableDatabases` + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListPluggableDatabases` + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. List for + * pluggable databases is supported only with a valid container database (full + * resource name) filter in this format: + * `database="projects/{project}/locations/{location}/databases/{database}"` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.oracledatabase.v1.PluggableDatabase|PluggableDatabase}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.list_pluggable_databases.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_ListPluggableDatabases_async + */ listPluggableDatabasesAsync( - request?: protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.oracledatabase.v1.IListPluggableDatabasesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listPluggableDatabases']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listPluggableDatabases iterate %j', request); return this.descriptors.page.listPluggableDatabases.asyncIterate( this.innerApiCalls['listPluggableDatabases'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists all the DbSystems for the given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for DbSystems in the following format: - * projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 DbSystems will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. - * @param {string} [request.orderBy] - * Optional. An expression for ordering the results of the request. - * @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 Array of {@link protos.google.cloud.oracledatabase.v1.DbSystem|DbSystem}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listDbSystemsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists all the DbSystems for the given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for DbSystems in the following format: + * projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 DbSystems will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. + * @param {string} [request.orderBy] + * Optional. An expression for ordering the results of the request. + * @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 Array of {@link protos.google.cloud.oracledatabase.v1.DbSystem|DbSystem}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listDbSystemsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listDbSystems( - request?: protos.google.cloud.oracledatabase.v1.IListDbSystemsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.IDbSystem[], - protos.google.cloud.oracledatabase.v1.IListDbSystemsRequest|null, - protos.google.cloud.oracledatabase.v1.IListDbSystemsResponse - ]>; + request?: protos.google.cloud.oracledatabase.v1.IListDbSystemsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IDbSystem[], + protos.google.cloud.oracledatabase.v1.IListDbSystemsRequest | null, + protos.google.cloud.oracledatabase.v1.IListDbSystemsResponse, + ] + >; listDbSystems( - request: protos.google.cloud.oracledatabase.v1.IListDbSystemsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDbSystemsRequest, - protos.google.cloud.oracledatabase.v1.IListDbSystemsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDbSystem>): void; + request: protos.google.cloud.oracledatabase.v1.IListDbSystemsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDbSystemsRequest, + | protos.google.cloud.oracledatabase.v1.IListDbSystemsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDbSystem + >, + ): void; listDbSystems( - request: protos.google.cloud.oracledatabase.v1.IListDbSystemsRequest, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDbSystemsRequest, - protos.google.cloud.oracledatabase.v1.IListDbSystemsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDbSystem>): void; + request: protos.google.cloud.oracledatabase.v1.IListDbSystemsRequest, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDbSystemsRequest, + | protos.google.cloud.oracledatabase.v1.IListDbSystemsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDbSystem + >, + ): void; listDbSystems( - request?: protos.google.cloud.oracledatabase.v1.IListDbSystemsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDbSystemsRequest, - protos.google.cloud.oracledatabase.v1.IListDbSystemsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDbSystem>, - callback?: PaginationCallback< + request?: protos.google.cloud.oracledatabase.v1.IListDbSystemsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.oracledatabase.v1.IListDbSystemsRequest, - protos.google.cloud.oracledatabase.v1.IListDbSystemsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDbSystem>): - Promise<[ - protos.google.cloud.oracledatabase.v1.IDbSystem[], - protos.google.cloud.oracledatabase.v1.IListDbSystemsRequest|null, - protos.google.cloud.oracledatabase.v1.IListDbSystemsResponse - ]>|void { + | protos.google.cloud.oracledatabase.v1.IListDbSystemsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDbSystem + >, + callback?: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDbSystemsRequest, + | protos.google.cloud.oracledatabase.v1.IListDbSystemsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDbSystem + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IDbSystem[], + protos.google.cloud.oracledatabase.v1.IListDbSystemsRequest | null, + protos.google.cloud.oracledatabase.v1.IListDbSystemsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDbSystemsRequest, - protos.google.cloud.oracledatabase.v1.IListDbSystemsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDbSystem>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDbSystemsRequest, + | protos.google.cloud.oracledatabase.v1.IListDbSystemsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDbSystem + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listDbSystems values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -8834,213 +11860,242 @@ export class OracleDatabaseClient { this._log.info('listDbSystems request %j', request); return this.innerApiCalls .listDbSystems(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.oracledatabase.v1.IDbSystem[], - protos.google.cloud.oracledatabase.v1.IListDbSystemsRequest|null, - protos.google.cloud.oracledatabase.v1.IListDbSystemsResponse - ]) => { - this._log.info('listDbSystems values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.oracledatabase.v1.IDbSystem[], + protos.google.cloud.oracledatabase.v1.IListDbSystemsRequest | null, + protos.google.cloud.oracledatabase.v1.IListDbSystemsResponse, + ]) => { + this._log.info('listDbSystems values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listDbSystems`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for DbSystems in the following format: - * projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 DbSystems will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. - * @param {string} [request.orderBy] - * Optional. An expression for ordering the results of the request. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.DbSystem|DbSystem} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listDbSystemsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listDbSystems`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for DbSystems in the following format: + * projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 DbSystems will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. + * @param {string} [request.orderBy] + * Optional. An expression for ordering the results of the request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.DbSystem|DbSystem} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listDbSystemsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listDbSystemsStream( - request?: protos.google.cloud.oracledatabase.v1.IListDbSystemsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.oracledatabase.v1.IListDbSystemsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listDbSystems']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listDbSystems stream %j', request); return this.descriptors.page.listDbSystems.createStream( this.innerApiCalls.listDbSystems as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listDbSystems`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for DbSystems in the following format: - * projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, at most 50 DbSystems will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. - * @param {string} [request.orderBy] - * Optional. An expression for ordering the results of the request. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.oracledatabase.v1.DbSystem|DbSystem}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.list_db_systems.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_ListDbSystems_async - */ + /** + * Equivalent to `listDbSystems`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for DbSystems in the following format: + * projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, at most 50 DbSystems will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. + * @param {string} [request.orderBy] + * Optional. An expression for ordering the results of the request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.oracledatabase.v1.DbSystem|DbSystem}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.list_db_systems.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_ListDbSystems_async + */ listDbSystemsAsync( - request?: protos.google.cloud.oracledatabase.v1.IListDbSystemsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.oracledatabase.v1.IListDbSystemsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listDbSystems']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listDbSystems iterate %j', request); return this.descriptors.page.listDbSystems.asyncIterate( this.innerApiCalls['listDbSystems'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * List DbVersions for the given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for the DbVersion resource with the - * format: projects/{project}/locations/{location} - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, a maximum of 50 DbVersions will be returned. - * The maximum value is 1000; values above 1000 will be reset to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying the requested page of results to return. All - * fields except the filter should remain the same as in the request that - * provided this page token. - * @param {string} [request.filter] - * Optional. Filter expression that matches a subset of the DbVersions to - * show. The supported filter for dbSystem creation is `db_system_shape = - * {db_system_shape} AND storage_management = {storage_management}`. If no - * filter is provided, all DbVersions will be returned. - * @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 Array of {@link protos.google.cloud.oracledatabase.v1.DbVersion|DbVersion}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listDbVersionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * List DbVersions for the given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for the DbVersion resource with the + * format: projects/{project}/locations/{location} + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, a maximum of 50 DbVersions will be returned. + * The maximum value is 1000; values above 1000 will be reset to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying the requested page of results to return. All + * fields except the filter should remain the same as in the request that + * provided this page token. + * @param {string} [request.filter] + * Optional. Filter expression that matches a subset of the DbVersions to + * show. The supported filter for dbSystem creation is `db_system_shape = + * {db_system_shape} AND storage_management = {storage_management}`. If no + * filter is provided, all DbVersions will be returned. + * @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 Array of {@link protos.google.cloud.oracledatabase.v1.DbVersion|DbVersion}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listDbVersionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listDbVersions( - request?: protos.google.cloud.oracledatabase.v1.IListDbVersionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.IDbVersion[], - protos.google.cloud.oracledatabase.v1.IListDbVersionsRequest|null, - protos.google.cloud.oracledatabase.v1.IListDbVersionsResponse - ]>; + request?: protos.google.cloud.oracledatabase.v1.IListDbVersionsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IDbVersion[], + protos.google.cloud.oracledatabase.v1.IListDbVersionsRequest | null, + protos.google.cloud.oracledatabase.v1.IListDbVersionsResponse, + ] + >; listDbVersions( - request: protos.google.cloud.oracledatabase.v1.IListDbVersionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDbVersionsRequest, - protos.google.cloud.oracledatabase.v1.IListDbVersionsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDbVersion>): void; + request: protos.google.cloud.oracledatabase.v1.IListDbVersionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDbVersionsRequest, + | protos.google.cloud.oracledatabase.v1.IListDbVersionsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDbVersion + >, + ): void; listDbVersions( - request: protos.google.cloud.oracledatabase.v1.IListDbVersionsRequest, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDbVersionsRequest, - protos.google.cloud.oracledatabase.v1.IListDbVersionsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDbVersion>): void; + request: protos.google.cloud.oracledatabase.v1.IListDbVersionsRequest, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDbVersionsRequest, + | protos.google.cloud.oracledatabase.v1.IListDbVersionsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDbVersion + >, + ): void; listDbVersions( - request?: protos.google.cloud.oracledatabase.v1.IListDbVersionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDbVersionsRequest, - protos.google.cloud.oracledatabase.v1.IListDbVersionsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDbVersion>, - callback?: PaginationCallback< + request?: protos.google.cloud.oracledatabase.v1.IListDbVersionsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.oracledatabase.v1.IListDbVersionsRequest, - protos.google.cloud.oracledatabase.v1.IListDbVersionsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDbVersion>): - Promise<[ - protos.google.cloud.oracledatabase.v1.IDbVersion[], - protos.google.cloud.oracledatabase.v1.IListDbVersionsRequest|null, - protos.google.cloud.oracledatabase.v1.IListDbVersionsResponse - ]>|void { + | protos.google.cloud.oracledatabase.v1.IListDbVersionsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDbVersion + >, + callback?: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDbVersionsRequest, + | protos.google.cloud.oracledatabase.v1.IListDbVersionsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDbVersion + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IDbVersion[], + protos.google.cloud.oracledatabase.v1.IListDbVersionsRequest | null, + protos.google.cloud.oracledatabase.v1.IListDbVersionsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDbVersionsRequest, - protos.google.cloud.oracledatabase.v1.IListDbVersionsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDbVersion>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDbVersionsRequest, + | protos.google.cloud.oracledatabase.v1.IListDbVersionsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDbVersion + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listDbVersions values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -9049,224 +12104,253 @@ export class OracleDatabaseClient { this._log.info('listDbVersions request %j', request); return this.innerApiCalls .listDbVersions(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.oracledatabase.v1.IDbVersion[], - protos.google.cloud.oracledatabase.v1.IListDbVersionsRequest|null, - protos.google.cloud.oracledatabase.v1.IListDbVersionsResponse - ]) => { - this._log.info('listDbVersions values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.oracledatabase.v1.IDbVersion[], + protos.google.cloud.oracledatabase.v1.IListDbVersionsRequest | null, + protos.google.cloud.oracledatabase.v1.IListDbVersionsResponse, + ]) => { + this._log.info('listDbVersions values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listDbVersions`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for the DbVersion resource with the - * format: projects/{project}/locations/{location} - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, a maximum of 50 DbVersions will be returned. - * The maximum value is 1000; values above 1000 will be reset to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying the requested page of results to return. All - * fields except the filter should remain the same as in the request that - * provided this page token. - * @param {string} [request.filter] - * Optional. Filter expression that matches a subset of the DbVersions to - * show. The supported filter for dbSystem creation is `db_system_shape = - * {db_system_shape} AND storage_management = {storage_management}`. If no - * filter is provided, all DbVersions will be returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.DbVersion|DbVersion} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listDbVersionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listDbVersions`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for the DbVersion resource with the + * format: projects/{project}/locations/{location} + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, a maximum of 50 DbVersions will be returned. + * The maximum value is 1000; values above 1000 will be reset to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying the requested page of results to return. All + * fields except the filter should remain the same as in the request that + * provided this page token. + * @param {string} [request.filter] + * Optional. Filter expression that matches a subset of the DbVersions to + * show. The supported filter for dbSystem creation is `db_system_shape = + * {db_system_shape} AND storage_management = {storage_management}`. If no + * filter is provided, all DbVersions will be returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.DbVersion|DbVersion} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listDbVersionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listDbVersionsStream( - request?: protos.google.cloud.oracledatabase.v1.IListDbVersionsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.oracledatabase.v1.IListDbVersionsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listDbVersions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listDbVersions stream %j', request); return this.descriptors.page.listDbVersions.createStream( this.innerApiCalls.listDbVersions as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listDbVersions`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for the DbVersion resource with the - * format: projects/{project}/locations/{location} - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * If unspecified, a maximum of 50 DbVersions will be returned. - * The maximum value is 1000; values above 1000 will be reset to 1000. - * @param {string} [request.pageToken] - * Optional. A token identifying the requested page of results to return. All - * fields except the filter should remain the same as in the request that - * provided this page token. - * @param {string} [request.filter] - * Optional. Filter expression that matches a subset of the DbVersions to - * show. The supported filter for dbSystem creation is `db_system_shape = - * {db_system_shape} AND storage_management = {storage_management}`. If no - * filter is provided, all DbVersions will be returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.oracledatabase.v1.DbVersion|DbVersion}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.list_db_versions.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_ListDbVersions_async - */ + /** + * Equivalent to `listDbVersions`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for the DbVersion resource with the + * format: projects/{project}/locations/{location} + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * If unspecified, a maximum of 50 DbVersions will be returned. + * The maximum value is 1000; values above 1000 will be reset to 1000. + * @param {string} [request.pageToken] + * Optional. A token identifying the requested page of results to return. All + * fields except the filter should remain the same as in the request that + * provided this page token. + * @param {string} [request.filter] + * Optional. Filter expression that matches a subset of the DbVersions to + * show. The supported filter for dbSystem creation is `db_system_shape = + * {db_system_shape} AND storage_management = {storage_management}`. If no + * filter is provided, all DbVersions will be returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.oracledatabase.v1.DbVersion|DbVersion}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.list_db_versions.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_ListDbVersions_async + */ listDbVersionsAsync( - request?: protos.google.cloud.oracledatabase.v1.IListDbVersionsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.oracledatabase.v1.IListDbVersionsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listDbVersions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listDbVersions iterate %j', request); return this.descriptors.page.listDbVersions.asyncIterate( this.innerApiCalls['listDbVersions'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * List DatabaseCharacterSets for the given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for DatabaseCharacterSets in the following - * format: projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of DatabaseCharacterSets to return. The - * service may return fewer than this value. If unspecified, at most 50 - * DatabaseCharacterSets will be returned. The maximum value is 1000; values - * above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * `ListDatabaseCharacterSets` call. Provide this to retrieve the subsequent - * page. - * - * When paginating, all other parameters provided to - * `ListDatabaseCharacterSets` must match the call that provided the page - * token. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. Only the - * **character_set_type** field is supported in the following format: - * `character_set_type="{characterSetType}"`. Accepted values include - * `DATABASE` and `NATIONAL`. - * @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 Array of {@link protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet|DatabaseCharacterSet}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listDatabaseCharacterSetsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * List DatabaseCharacterSets for the given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for DatabaseCharacterSets in the following + * format: projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of DatabaseCharacterSets to return. The + * service may return fewer than this value. If unspecified, at most 50 + * DatabaseCharacterSets will be returned. The maximum value is 1000; values + * above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * `ListDatabaseCharacterSets` call. Provide this to retrieve the subsequent + * page. + * + * When paginating, all other parameters provided to + * `ListDatabaseCharacterSets` must match the call that provided the page + * token. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. Only the + * **character_set_type** field is supported in the following format: + * `character_set_type="{characterSetType}"`. Accepted values include + * `DATABASE` and `NATIONAL`. + * @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 Array of {@link protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet|DatabaseCharacterSet}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listDatabaseCharacterSetsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listDatabaseCharacterSets( - request?: protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.oracledatabase.v1.IDatabaseCharacterSet[], - protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsRequest|null, - protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsResponse - ]>; + request?: protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IDatabaseCharacterSet[], + protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsRequest | null, + protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsResponse, + ] + >; listDatabaseCharacterSets( - request: protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsRequest, - protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDatabaseCharacterSet>): void; + request: protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsRequest, + | protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDatabaseCharacterSet + >, + ): void; listDatabaseCharacterSets( - request: protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsRequest, - callback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsRequest, - protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDatabaseCharacterSet>): void; + request: protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsRequest, + callback: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsRequest, + | protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDatabaseCharacterSet + >, + ): void; listDatabaseCharacterSets( - request?: protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsRequest, - protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDatabaseCharacterSet>, - callback?: PaginationCallback< + request?: protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsRequest, - protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDatabaseCharacterSet>): - Promise<[ - protos.google.cloud.oracledatabase.v1.IDatabaseCharacterSet[], - protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsRequest|null, - protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsResponse - ]>|void { + | protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDatabaseCharacterSet + >, + callback?: PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsRequest, + | protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDatabaseCharacterSet + >, + ): Promise< + [ + protos.google.cloud.oracledatabase.v1.IDatabaseCharacterSet[], + protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsRequest | null, + protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } 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({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsRequest, - protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsResponse|null|undefined, - protos.google.cloud.oracledatabase.v1.IDatabaseCharacterSet>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsRequest, + | protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsResponse + | null + | undefined, + protos.google.cloud.oracledatabase.v1.IDatabaseCharacterSet + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listDatabaseCharacterSets values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -9275,139 +12359,144 @@ export class OracleDatabaseClient { this._log.info('listDatabaseCharacterSets request %j', request); return this.innerApiCalls .listDatabaseCharacterSets(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.oracledatabase.v1.IDatabaseCharacterSet[], - protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsRequest|null, - protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsResponse - ]) => { - this._log.info('listDatabaseCharacterSets values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.oracledatabase.v1.IDatabaseCharacterSet[], + protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsRequest | null, + protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsResponse, + ]) => { + this._log.info('listDatabaseCharacterSets values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listDatabaseCharacterSets`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for DatabaseCharacterSets in the following - * format: projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of DatabaseCharacterSets to return. The - * service may return fewer than this value. If unspecified, at most 50 - * DatabaseCharacterSets will be returned. The maximum value is 1000; values - * above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * `ListDatabaseCharacterSets` call. Provide this to retrieve the subsequent - * page. - * - * When paginating, all other parameters provided to - * `ListDatabaseCharacterSets` must match the call that provided the page - * token. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. Only the - * **character_set_type** field is supported in the following format: - * `character_set_type="{characterSetType}"`. Accepted values include - * `DATABASE` and `NATIONAL`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet|DatabaseCharacterSet} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listDatabaseCharacterSetsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listDatabaseCharacterSets`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for DatabaseCharacterSets in the following + * format: projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of DatabaseCharacterSets to return. The + * service may return fewer than this value. If unspecified, at most 50 + * DatabaseCharacterSets will be returned. The maximum value is 1000; values + * above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * `ListDatabaseCharacterSets` call. Provide this to retrieve the subsequent + * page. + * + * When paginating, all other parameters provided to + * `ListDatabaseCharacterSets` must match the call that provided the page + * token. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. Only the + * **character_set_type** field is supported in the following format: + * `character_set_type="{characterSetType}"`. Accepted values include + * `DATABASE` and `NATIONAL`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet|DatabaseCharacterSet} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listDatabaseCharacterSetsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listDatabaseCharacterSetsStream( - request?: protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listDatabaseCharacterSets']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listDatabaseCharacterSets stream %j', request); return this.descriptors.page.listDatabaseCharacterSets.createStream( this.innerApiCalls.listDatabaseCharacterSets as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listDatabaseCharacterSets`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent value for DatabaseCharacterSets in the following - * format: projects/{project}/locations/{location}. - * @param {number} [request.pageSize] - * Optional. The maximum number of DatabaseCharacterSets to return. The - * service may return fewer than this value. If unspecified, at most 50 - * DatabaseCharacterSets will be returned. The maximum value is 1000; values - * above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * `ListDatabaseCharacterSets` call. Provide this to retrieve the subsequent - * page. - * - * When paginating, all other parameters provided to - * `ListDatabaseCharacterSets` must match the call that provided the page - * token. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. Only the - * **character_set_type** field is supported in the following format: - * `character_set_type="{characterSetType}"`. Accepted values include - * `DATABASE` and `NATIONAL`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet|DatabaseCharacterSet}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/oracle_database.list_database_character_sets.js - * region_tag:oracledatabase_v1_generated_OracleDatabase_ListDatabaseCharacterSets_async - */ + /** + * Equivalent to `listDatabaseCharacterSets`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent value for DatabaseCharacterSets in the following + * format: projects/{project}/locations/{location}. + * @param {number} [request.pageSize] + * Optional. The maximum number of DatabaseCharacterSets to return. The + * service may return fewer than this value. If unspecified, at most 50 + * DatabaseCharacterSets will be returned. The maximum value is 1000; values + * above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * `ListDatabaseCharacterSets` call. Provide this to retrieve the subsequent + * page. + * + * When paginating, all other parameters provided to + * `ListDatabaseCharacterSets` must match the call that provided the page + * token. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. Only the + * **character_set_type** field is supported in the following format: + * `character_set_type="{characterSetType}"`. Accepted values include + * `DATABASE` and `NATIONAL`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet|DatabaseCharacterSet}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/oracle_database.list_database_character_sets.js + * region_tag:oracledatabase_v1_generated_OracleDatabase_ListDatabaseCharacterSets_async + */ listDatabaseCharacterSetsAsync( - request?: protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.oracledatabase.v1.IListDatabaseCharacterSetsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listDatabaseCharacterSets']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listDatabaseCharacterSets iterate %j', request); return this.descriptors.page.listDatabaseCharacterSets.asyncIterate( this.innerApiCalls['listDatabaseCharacterSets'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** + + /** * Gets information about a location. * * @param {Object} request @@ -9442,12 +12531,11 @@ export class OracleDatabaseClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -9480,12 +12568,12 @@ export class OracleDatabaseClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -9528,22 +12616,22 @@ export class OracleDatabaseClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -9578,15 +12666,15 @@ export class OracleDatabaseClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - 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 ?? '', - }); + 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 ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -9620,7 +12708,7 @@ export class OracleDatabaseClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -9633,25 +12721,24 @@ export class OracleDatabaseClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -9690,22 +12777,22 @@ export class OracleDatabaseClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.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 ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -9721,7 +12808,11 @@ export class OracleDatabaseClient { * @param {string} autonomous_database * @returns {string} Resource name string. */ - autonomousDatabasePath(project:string,location:string,autonomousDatabase:string) { + autonomousDatabasePath( + project: string, + location: string, + autonomousDatabase: string, + ) { return this.pathTemplates.autonomousDatabasePathTemplate.render({ project: project, location: location, @@ -9737,7 +12828,9 @@ export class OracleDatabaseClient { * @returns {string} A string representing the project. */ matchProjectFromAutonomousDatabaseName(autonomousDatabaseName: string) { - return this.pathTemplates.autonomousDatabasePathTemplate.match(autonomousDatabaseName).project; + return this.pathTemplates.autonomousDatabasePathTemplate.match( + autonomousDatabaseName, + ).project; } /** @@ -9748,7 +12841,9 @@ export class OracleDatabaseClient { * @returns {string} A string representing the location. */ matchLocationFromAutonomousDatabaseName(autonomousDatabaseName: string) { - return this.pathTemplates.autonomousDatabasePathTemplate.match(autonomousDatabaseName).location; + return this.pathTemplates.autonomousDatabasePathTemplate.match( + autonomousDatabaseName, + ).location; } /** @@ -9758,8 +12853,12 @@ export class OracleDatabaseClient { * A fully-qualified path representing AutonomousDatabase resource. * @returns {string} A string representing the autonomous_database. */ - matchAutonomousDatabaseFromAutonomousDatabaseName(autonomousDatabaseName: string) { - return this.pathTemplates.autonomousDatabasePathTemplate.match(autonomousDatabaseName).autonomous_database; + matchAutonomousDatabaseFromAutonomousDatabaseName( + autonomousDatabaseName: string, + ) { + return this.pathTemplates.autonomousDatabasePathTemplate.match( + autonomousDatabaseName, + ).autonomous_database; } /** @@ -9770,7 +12869,11 @@ export class OracleDatabaseClient { * @param {string} autonomous_database_backup * @returns {string} Resource name string. */ - autonomousDatabaseBackupPath(project:string,location:string,autonomousDatabaseBackup:string) { + autonomousDatabaseBackupPath( + project: string, + location: string, + autonomousDatabaseBackup: string, + ) { return this.pathTemplates.autonomousDatabaseBackupPathTemplate.render({ project: project, location: location, @@ -9785,8 +12888,12 @@ export class OracleDatabaseClient { * A fully-qualified path representing AutonomousDatabaseBackup resource. * @returns {string} A string representing the project. */ - matchProjectFromAutonomousDatabaseBackupName(autonomousDatabaseBackupName: string) { - return this.pathTemplates.autonomousDatabaseBackupPathTemplate.match(autonomousDatabaseBackupName).project; + matchProjectFromAutonomousDatabaseBackupName( + autonomousDatabaseBackupName: string, + ) { + return this.pathTemplates.autonomousDatabaseBackupPathTemplate.match( + autonomousDatabaseBackupName, + ).project; } /** @@ -9796,8 +12903,12 @@ export class OracleDatabaseClient { * A fully-qualified path representing AutonomousDatabaseBackup resource. * @returns {string} A string representing the location. */ - matchLocationFromAutonomousDatabaseBackupName(autonomousDatabaseBackupName: string) { - return this.pathTemplates.autonomousDatabaseBackupPathTemplate.match(autonomousDatabaseBackupName).location; + matchLocationFromAutonomousDatabaseBackupName( + autonomousDatabaseBackupName: string, + ) { + return this.pathTemplates.autonomousDatabaseBackupPathTemplate.match( + autonomousDatabaseBackupName, + ).location; } /** @@ -9807,8 +12918,12 @@ export class OracleDatabaseClient { * A fully-qualified path representing AutonomousDatabaseBackup resource. * @returns {string} A string representing the autonomous_database_backup. */ - matchAutonomousDatabaseBackupFromAutonomousDatabaseBackupName(autonomousDatabaseBackupName: string) { - return this.pathTemplates.autonomousDatabaseBackupPathTemplate.match(autonomousDatabaseBackupName).autonomous_database_backup; + matchAutonomousDatabaseBackupFromAutonomousDatabaseBackupName( + autonomousDatabaseBackupName: string, + ) { + return this.pathTemplates.autonomousDatabaseBackupPathTemplate.match( + autonomousDatabaseBackupName, + ).autonomous_database_backup; } /** @@ -9819,12 +12934,18 @@ export class OracleDatabaseClient { * @param {string} autonomous_database_character_set * @returns {string} Resource name string. */ - autonomousDatabaseCharacterSetPath(project:string,location:string,autonomousDatabaseCharacterSet:string) { - return this.pathTemplates.autonomousDatabaseCharacterSetPathTemplate.render({ - project: project, - location: location, - autonomous_database_character_set: autonomousDatabaseCharacterSet, - }); + autonomousDatabaseCharacterSetPath( + project: string, + location: string, + autonomousDatabaseCharacterSet: string, + ) { + return this.pathTemplates.autonomousDatabaseCharacterSetPathTemplate.render( + { + project: project, + location: location, + autonomous_database_character_set: autonomousDatabaseCharacterSet, + }, + ); } /** @@ -9834,8 +12955,12 @@ export class OracleDatabaseClient { * A fully-qualified path representing AutonomousDatabaseCharacterSet resource. * @returns {string} A string representing the project. */ - matchProjectFromAutonomousDatabaseCharacterSetName(autonomousDatabaseCharacterSetName: string) { - return this.pathTemplates.autonomousDatabaseCharacterSetPathTemplate.match(autonomousDatabaseCharacterSetName).project; + matchProjectFromAutonomousDatabaseCharacterSetName( + autonomousDatabaseCharacterSetName: string, + ) { + return this.pathTemplates.autonomousDatabaseCharacterSetPathTemplate.match( + autonomousDatabaseCharacterSetName, + ).project; } /** @@ -9845,8 +12970,12 @@ export class OracleDatabaseClient { * A fully-qualified path representing AutonomousDatabaseCharacterSet resource. * @returns {string} A string representing the location. */ - matchLocationFromAutonomousDatabaseCharacterSetName(autonomousDatabaseCharacterSetName: string) { - return this.pathTemplates.autonomousDatabaseCharacterSetPathTemplate.match(autonomousDatabaseCharacterSetName).location; + matchLocationFromAutonomousDatabaseCharacterSetName( + autonomousDatabaseCharacterSetName: string, + ) { + return this.pathTemplates.autonomousDatabaseCharacterSetPathTemplate.match( + autonomousDatabaseCharacterSetName, + ).location; } /** @@ -9856,8 +12985,12 @@ export class OracleDatabaseClient { * A fully-qualified path representing AutonomousDatabaseCharacterSet resource. * @returns {string} A string representing the autonomous_database_character_set. */ - matchAutonomousDatabaseCharacterSetFromAutonomousDatabaseCharacterSetName(autonomousDatabaseCharacterSetName: string) { - return this.pathTemplates.autonomousDatabaseCharacterSetPathTemplate.match(autonomousDatabaseCharacterSetName).autonomous_database_character_set; + matchAutonomousDatabaseCharacterSetFromAutonomousDatabaseCharacterSetName( + autonomousDatabaseCharacterSetName: string, + ) { + return this.pathTemplates.autonomousDatabaseCharacterSetPathTemplate.match( + autonomousDatabaseCharacterSetName, + ).autonomous_database_character_set; } /** @@ -9868,7 +13001,11 @@ export class OracleDatabaseClient { * @param {string} autonomous_db_version * @returns {string} Resource name string. */ - autonomousDbVersionPath(project:string,location:string,autonomousDbVersion:string) { + autonomousDbVersionPath( + project: string, + location: string, + autonomousDbVersion: string, + ) { return this.pathTemplates.autonomousDbVersionPathTemplate.render({ project: project, location: location, @@ -9884,7 +13021,9 @@ export class OracleDatabaseClient { * @returns {string} A string representing the project. */ matchProjectFromAutonomousDbVersionName(autonomousDbVersionName: string) { - return this.pathTemplates.autonomousDbVersionPathTemplate.match(autonomousDbVersionName).project; + return this.pathTemplates.autonomousDbVersionPathTemplate.match( + autonomousDbVersionName, + ).project; } /** @@ -9895,7 +13034,9 @@ export class OracleDatabaseClient { * @returns {string} A string representing the location. */ matchLocationFromAutonomousDbVersionName(autonomousDbVersionName: string) { - return this.pathTemplates.autonomousDbVersionPathTemplate.match(autonomousDbVersionName).location; + return this.pathTemplates.autonomousDbVersionPathTemplate.match( + autonomousDbVersionName, + ).location; } /** @@ -9905,8 +13046,12 @@ export class OracleDatabaseClient { * A fully-qualified path representing AutonomousDbVersion resource. * @returns {string} A string representing the autonomous_db_version. */ - matchAutonomousDbVersionFromAutonomousDbVersionName(autonomousDbVersionName: string) { - return this.pathTemplates.autonomousDbVersionPathTemplate.match(autonomousDbVersionName).autonomous_db_version; + matchAutonomousDbVersionFromAutonomousDbVersionName( + autonomousDbVersionName: string, + ) { + return this.pathTemplates.autonomousDbVersionPathTemplate.match( + autonomousDbVersionName, + ).autonomous_db_version; } /** @@ -9917,7 +13062,11 @@ export class OracleDatabaseClient { * @param {string} cloud_exadata_infrastructure * @returns {string} Resource name string. */ - cloudExadataInfrastructurePath(project:string,location:string,cloudExadataInfrastructure:string) { + cloudExadataInfrastructurePath( + project: string, + location: string, + cloudExadataInfrastructure: string, + ) { return this.pathTemplates.cloudExadataInfrastructurePathTemplate.render({ project: project, location: location, @@ -9932,8 +13081,12 @@ export class OracleDatabaseClient { * A fully-qualified path representing CloudExadataInfrastructure resource. * @returns {string} A string representing the project. */ - matchProjectFromCloudExadataInfrastructureName(cloudExadataInfrastructureName: string) { - return this.pathTemplates.cloudExadataInfrastructurePathTemplate.match(cloudExadataInfrastructureName).project; + matchProjectFromCloudExadataInfrastructureName( + cloudExadataInfrastructureName: string, + ) { + return this.pathTemplates.cloudExadataInfrastructurePathTemplate.match( + cloudExadataInfrastructureName, + ).project; } /** @@ -9943,8 +13096,12 @@ export class OracleDatabaseClient { * A fully-qualified path representing CloudExadataInfrastructure resource. * @returns {string} A string representing the location. */ - matchLocationFromCloudExadataInfrastructureName(cloudExadataInfrastructureName: string) { - return this.pathTemplates.cloudExadataInfrastructurePathTemplate.match(cloudExadataInfrastructureName).location; + matchLocationFromCloudExadataInfrastructureName( + cloudExadataInfrastructureName: string, + ) { + return this.pathTemplates.cloudExadataInfrastructurePathTemplate.match( + cloudExadataInfrastructureName, + ).location; } /** @@ -9954,8 +13111,12 @@ export class OracleDatabaseClient { * A fully-qualified path representing CloudExadataInfrastructure resource. * @returns {string} A string representing the cloud_exadata_infrastructure. */ - matchCloudExadataInfrastructureFromCloudExadataInfrastructureName(cloudExadataInfrastructureName: string) { - return this.pathTemplates.cloudExadataInfrastructurePathTemplate.match(cloudExadataInfrastructureName).cloud_exadata_infrastructure; + matchCloudExadataInfrastructureFromCloudExadataInfrastructureName( + cloudExadataInfrastructureName: string, + ) { + return this.pathTemplates.cloudExadataInfrastructurePathTemplate.match( + cloudExadataInfrastructureName, + ).cloud_exadata_infrastructure; } /** @@ -9966,7 +13127,11 @@ export class OracleDatabaseClient { * @param {string} cloud_vm_cluster * @returns {string} Resource name string. */ - cloudVmClusterPath(project:string,location:string,cloudVmCluster:string) { + cloudVmClusterPath( + project: string, + location: string, + cloudVmCluster: string, + ) { return this.pathTemplates.cloudVmClusterPathTemplate.render({ project: project, location: location, @@ -9982,7 +13147,9 @@ export class OracleDatabaseClient { * @returns {string} A string representing the project. */ matchProjectFromCloudVmClusterName(cloudVmClusterName: string) { - return this.pathTemplates.cloudVmClusterPathTemplate.match(cloudVmClusterName).project; + return this.pathTemplates.cloudVmClusterPathTemplate.match( + cloudVmClusterName, + ).project; } /** @@ -9993,7 +13160,9 @@ export class OracleDatabaseClient { * @returns {string} A string representing the location. */ matchLocationFromCloudVmClusterName(cloudVmClusterName: string) { - return this.pathTemplates.cloudVmClusterPathTemplate.match(cloudVmClusterName).location; + return this.pathTemplates.cloudVmClusterPathTemplate.match( + cloudVmClusterName, + ).location; } /** @@ -10004,7 +13173,9 @@ export class OracleDatabaseClient { * @returns {string} A string representing the cloud_vm_cluster. */ matchCloudVmClusterFromCloudVmClusterName(cloudVmClusterName: string) { - return this.pathTemplates.cloudVmClusterPathTemplate.match(cloudVmClusterName).cloud_vm_cluster; + return this.pathTemplates.cloudVmClusterPathTemplate.match( + cloudVmClusterName, + ).cloud_vm_cluster; } /** @@ -10015,7 +13186,7 @@ export class OracleDatabaseClient { * @param {string} database * @returns {string} Resource name string. */ - databasePath(project:string,location:string,database:string) { + databasePath(project: string, location: string, database: string) { return this.pathTemplates.databasePathTemplate.render({ project: project, location: location, @@ -10064,7 +13235,11 @@ export class OracleDatabaseClient { * @param {string} database_character_set * @returns {string} Resource name string. */ - databaseCharacterSetPath(project:string,location:string,databaseCharacterSet:string) { + databaseCharacterSetPath( + project: string, + location: string, + databaseCharacterSet: string, + ) { return this.pathTemplates.databaseCharacterSetPathTemplate.render({ project: project, location: location, @@ -10080,7 +13255,9 @@ export class OracleDatabaseClient { * @returns {string} A string representing the project. */ matchProjectFromDatabaseCharacterSetName(databaseCharacterSetName: string) { - return this.pathTemplates.databaseCharacterSetPathTemplate.match(databaseCharacterSetName).project; + return this.pathTemplates.databaseCharacterSetPathTemplate.match( + databaseCharacterSetName, + ).project; } /** @@ -10091,7 +13268,9 @@ export class OracleDatabaseClient { * @returns {string} A string representing the location. */ matchLocationFromDatabaseCharacterSetName(databaseCharacterSetName: string) { - return this.pathTemplates.databaseCharacterSetPathTemplate.match(databaseCharacterSetName).location; + return this.pathTemplates.databaseCharacterSetPathTemplate.match( + databaseCharacterSetName, + ).location; } /** @@ -10101,8 +13280,12 @@ export class OracleDatabaseClient { * A fully-qualified path representing DatabaseCharacterSet resource. * @returns {string} A string representing the database_character_set. */ - matchDatabaseCharacterSetFromDatabaseCharacterSetName(databaseCharacterSetName: string) { - return this.pathTemplates.databaseCharacterSetPathTemplate.match(databaseCharacterSetName).database_character_set; + matchDatabaseCharacterSetFromDatabaseCharacterSetName( + databaseCharacterSetName: string, + ) { + return this.pathTemplates.databaseCharacterSetPathTemplate.match( + databaseCharacterSetName, + ).database_character_set; } /** @@ -10114,7 +13297,12 @@ export class OracleDatabaseClient { * @param {string} db_server * @returns {string} Resource name string. */ - dbServerPath(project:string,location:string,cloudExadataInfrastructure:string,dbServer:string) { + dbServerPath( + project: string, + location: string, + cloudExadataInfrastructure: string, + dbServer: string, + ) { return this.pathTemplates.dbServerPathTemplate.render({ project: project, location: location, @@ -10153,7 +13341,8 @@ export class OracleDatabaseClient { * @returns {string} A string representing the cloud_exadata_infrastructure. */ matchCloudExadataInfrastructureFromDbServerName(dbServerName: string) { - return this.pathTemplates.dbServerPathTemplate.match(dbServerName).cloud_exadata_infrastructure; + return this.pathTemplates.dbServerPathTemplate.match(dbServerName) + .cloud_exadata_infrastructure; } /** @@ -10164,7 +13353,8 @@ export class OracleDatabaseClient { * @returns {string} A string representing the db_server. */ matchDbServerFromDbServerName(dbServerName: string) { - return this.pathTemplates.dbServerPathTemplate.match(dbServerName).db_server; + return this.pathTemplates.dbServerPathTemplate.match(dbServerName) + .db_server; } /** @@ -10175,7 +13365,7 @@ export class OracleDatabaseClient { * @param {string} db_system * @returns {string} Resource name string. */ - dbSystemPath(project:string,location:string,dbSystem:string) { + dbSystemPath(project: string, location: string, dbSystem: string) { return this.pathTemplates.dbSystemPathTemplate.render({ project: project, location: location, @@ -10213,7 +13403,8 @@ export class OracleDatabaseClient { * @returns {string} A string representing the db_system. */ matchDbSystemFromDbSystemName(dbSystemName: string) { - return this.pathTemplates.dbSystemPathTemplate.match(dbSystemName).db_system; + return this.pathTemplates.dbSystemPathTemplate.match(dbSystemName) + .db_system; } /** @@ -10224,7 +13415,11 @@ export class OracleDatabaseClient { * @param {string} db_system_initial_storage_size * @returns {string} Resource name string. */ - dbSystemInitialStorageSizePath(project:string,location:string,dbSystemInitialStorageSize:string) { + dbSystemInitialStorageSizePath( + project: string, + location: string, + dbSystemInitialStorageSize: string, + ) { return this.pathTemplates.dbSystemInitialStorageSizePathTemplate.render({ project: project, location: location, @@ -10239,8 +13434,12 @@ export class OracleDatabaseClient { * A fully-qualified path representing DbSystemInitialStorageSize resource. * @returns {string} A string representing the project. */ - matchProjectFromDbSystemInitialStorageSizeName(dbSystemInitialStorageSizeName: string) { - return this.pathTemplates.dbSystemInitialStorageSizePathTemplate.match(dbSystemInitialStorageSizeName).project; + matchProjectFromDbSystemInitialStorageSizeName( + dbSystemInitialStorageSizeName: string, + ) { + return this.pathTemplates.dbSystemInitialStorageSizePathTemplate.match( + dbSystemInitialStorageSizeName, + ).project; } /** @@ -10250,8 +13449,12 @@ export class OracleDatabaseClient { * A fully-qualified path representing DbSystemInitialStorageSize resource. * @returns {string} A string representing the location. */ - matchLocationFromDbSystemInitialStorageSizeName(dbSystemInitialStorageSizeName: string) { - return this.pathTemplates.dbSystemInitialStorageSizePathTemplate.match(dbSystemInitialStorageSizeName).location; + matchLocationFromDbSystemInitialStorageSizeName( + dbSystemInitialStorageSizeName: string, + ) { + return this.pathTemplates.dbSystemInitialStorageSizePathTemplate.match( + dbSystemInitialStorageSizeName, + ).location; } /** @@ -10261,8 +13464,12 @@ export class OracleDatabaseClient { * A fully-qualified path representing DbSystemInitialStorageSize resource. * @returns {string} A string representing the db_system_initial_storage_size. */ - matchDbSystemInitialStorageSizeFromDbSystemInitialStorageSizeName(dbSystemInitialStorageSizeName: string) { - return this.pathTemplates.dbSystemInitialStorageSizePathTemplate.match(dbSystemInitialStorageSizeName).db_system_initial_storage_size; + matchDbSystemInitialStorageSizeFromDbSystemInitialStorageSizeName( + dbSystemInitialStorageSizeName: string, + ) { + return this.pathTemplates.dbSystemInitialStorageSizePathTemplate.match( + dbSystemInitialStorageSizeName, + ).db_system_initial_storage_size; } /** @@ -10273,7 +13480,7 @@ export class OracleDatabaseClient { * @param {string} db_system_shape * @returns {string} Resource name string. */ - dbSystemShapePath(project:string,location:string,dbSystemShape:string) { + dbSystemShapePath(project: string, location: string, dbSystemShape: string) { return this.pathTemplates.dbSystemShapePathTemplate.render({ project: project, location: location, @@ -10289,7 +13496,8 @@ export class OracleDatabaseClient { * @returns {string} A string representing the project. */ matchProjectFromDbSystemShapeName(dbSystemShapeName: string) { - return this.pathTemplates.dbSystemShapePathTemplate.match(dbSystemShapeName).project; + return this.pathTemplates.dbSystemShapePathTemplate.match(dbSystemShapeName) + .project; } /** @@ -10300,7 +13508,8 @@ export class OracleDatabaseClient { * @returns {string} A string representing the location. */ matchLocationFromDbSystemShapeName(dbSystemShapeName: string) { - return this.pathTemplates.dbSystemShapePathTemplate.match(dbSystemShapeName).location; + return this.pathTemplates.dbSystemShapePathTemplate.match(dbSystemShapeName) + .location; } /** @@ -10311,7 +13520,8 @@ export class OracleDatabaseClient { * @returns {string} A string representing the db_system_shape. */ matchDbSystemShapeFromDbSystemShapeName(dbSystemShapeName: string) { - return this.pathTemplates.dbSystemShapePathTemplate.match(dbSystemShapeName).db_system_shape; + return this.pathTemplates.dbSystemShapePathTemplate.match(dbSystemShapeName) + .db_system_shape; } /** @@ -10322,7 +13532,7 @@ export class OracleDatabaseClient { * @param {string} db_version * @returns {string} Resource name string. */ - dbVersionPath(project:string,location:string,dbVersion:string) { + dbVersionPath(project: string, location: string, dbVersion: string) { return this.pathTemplates.dbVersionPathTemplate.render({ project: project, location: location, @@ -10338,7 +13548,8 @@ export class OracleDatabaseClient { * @returns {string} A string representing the project. */ matchProjectFromDbVersionName(dbVersionName: string) { - return this.pathTemplates.dbVersionPathTemplate.match(dbVersionName).project; + return this.pathTemplates.dbVersionPathTemplate.match(dbVersionName) + .project; } /** @@ -10349,7 +13560,8 @@ export class OracleDatabaseClient { * @returns {string} A string representing the location. */ matchLocationFromDbVersionName(dbVersionName: string) { - return this.pathTemplates.dbVersionPathTemplate.match(dbVersionName).location; + return this.pathTemplates.dbVersionPathTemplate.match(dbVersionName) + .location; } /** @@ -10360,7 +13572,8 @@ export class OracleDatabaseClient { * @returns {string} A string representing the db_version. */ matchDbVersionFromDbVersionName(dbVersionName: string) { - return this.pathTemplates.dbVersionPathTemplate.match(dbVersionName).db_version; + return this.pathTemplates.dbVersionPathTemplate.match(dbVersionName) + .db_version; } /** @@ -10371,7 +13584,7 @@ export class OracleDatabaseClient { * @param {string} entitlement * @returns {string} Resource name string. */ - entitlementPath(project:string,location:string,entitlement:string) { + entitlementPath(project: string, location: string, entitlement: string) { return this.pathTemplates.entitlementPathTemplate.render({ project: project, location: location, @@ -10387,7 +13600,8 @@ export class OracleDatabaseClient { * @returns {string} A string representing the project. */ matchProjectFromEntitlementName(entitlementName: string) { - return this.pathTemplates.entitlementPathTemplate.match(entitlementName).project; + return this.pathTemplates.entitlementPathTemplate.match(entitlementName) + .project; } /** @@ -10398,7 +13612,8 @@ export class OracleDatabaseClient { * @returns {string} A string representing the location. */ matchLocationFromEntitlementName(entitlementName: string) { - return this.pathTemplates.entitlementPathTemplate.match(entitlementName).location; + return this.pathTemplates.entitlementPathTemplate.match(entitlementName) + .location; } /** @@ -10409,7 +13624,8 @@ export class OracleDatabaseClient { * @returns {string} A string representing the entitlement. */ matchEntitlementFromEntitlementName(entitlementName: string) { - return this.pathTemplates.entitlementPathTemplate.match(entitlementName).entitlement; + return this.pathTemplates.entitlementPathTemplate.match(entitlementName) + .entitlement; } /** @@ -10420,7 +13636,11 @@ export class OracleDatabaseClient { * @param {string} exadb_vm_cluster * @returns {string} Resource name string. */ - exadbVmClusterPath(project:string,location:string,exadbVmCluster:string) { + exadbVmClusterPath( + project: string, + location: string, + exadbVmCluster: string, + ) { return this.pathTemplates.exadbVmClusterPathTemplate.render({ project: project, location: location, @@ -10436,7 +13656,9 @@ export class OracleDatabaseClient { * @returns {string} A string representing the project. */ matchProjectFromExadbVmClusterName(exadbVmClusterName: string) { - return this.pathTemplates.exadbVmClusterPathTemplate.match(exadbVmClusterName).project; + return this.pathTemplates.exadbVmClusterPathTemplate.match( + exadbVmClusterName, + ).project; } /** @@ -10447,7 +13669,9 @@ export class OracleDatabaseClient { * @returns {string} A string representing the location. */ matchLocationFromExadbVmClusterName(exadbVmClusterName: string) { - return this.pathTemplates.exadbVmClusterPathTemplate.match(exadbVmClusterName).location; + return this.pathTemplates.exadbVmClusterPathTemplate.match( + exadbVmClusterName, + ).location; } /** @@ -10458,7 +13682,9 @@ export class OracleDatabaseClient { * @returns {string} A string representing the exadb_vm_cluster. */ matchExadbVmClusterFromExadbVmClusterName(exadbVmClusterName: string) { - return this.pathTemplates.exadbVmClusterPathTemplate.match(exadbVmClusterName).exadb_vm_cluster; + return this.pathTemplates.exadbVmClusterPathTemplate.match( + exadbVmClusterName, + ).exadb_vm_cluster; } /** @@ -10469,7 +13695,11 @@ export class OracleDatabaseClient { * @param {string} exascale_db_storage_vault * @returns {string} Resource name string. */ - exascaleDbStorageVaultPath(project:string,location:string,exascaleDbStorageVault:string) { + exascaleDbStorageVaultPath( + project: string, + location: string, + exascaleDbStorageVault: string, + ) { return this.pathTemplates.exascaleDbStorageVaultPathTemplate.render({ project: project, location: location, @@ -10484,8 +13714,12 @@ export class OracleDatabaseClient { * A fully-qualified path representing ExascaleDbStorageVault resource. * @returns {string} A string representing the project. */ - matchProjectFromExascaleDbStorageVaultName(exascaleDbStorageVaultName: string) { - return this.pathTemplates.exascaleDbStorageVaultPathTemplate.match(exascaleDbStorageVaultName).project; + matchProjectFromExascaleDbStorageVaultName( + exascaleDbStorageVaultName: string, + ) { + return this.pathTemplates.exascaleDbStorageVaultPathTemplate.match( + exascaleDbStorageVaultName, + ).project; } /** @@ -10495,8 +13729,12 @@ export class OracleDatabaseClient { * A fully-qualified path representing ExascaleDbStorageVault resource. * @returns {string} A string representing the location. */ - matchLocationFromExascaleDbStorageVaultName(exascaleDbStorageVaultName: string) { - return this.pathTemplates.exascaleDbStorageVaultPathTemplate.match(exascaleDbStorageVaultName).location; + matchLocationFromExascaleDbStorageVaultName( + exascaleDbStorageVaultName: string, + ) { + return this.pathTemplates.exascaleDbStorageVaultPathTemplate.match( + exascaleDbStorageVaultName, + ).location; } /** @@ -10506,8 +13744,12 @@ export class OracleDatabaseClient { * A fully-qualified path representing ExascaleDbStorageVault resource. * @returns {string} A string representing the exascale_db_storage_vault. */ - matchExascaleDbStorageVaultFromExascaleDbStorageVaultName(exascaleDbStorageVaultName: string) { - return this.pathTemplates.exascaleDbStorageVaultPathTemplate.match(exascaleDbStorageVaultName).exascale_db_storage_vault; + matchExascaleDbStorageVaultFromExascaleDbStorageVaultName( + exascaleDbStorageVaultName: string, + ) { + return this.pathTemplates.exascaleDbStorageVaultPathTemplate.match( + exascaleDbStorageVaultName, + ).exascale_db_storage_vault; } /** @@ -10518,7 +13760,7 @@ export class OracleDatabaseClient { * @param {string} gi_version * @returns {string} Resource name string. */ - giVersionPath(project:string,location:string,giVersion:string) { + giVersionPath(project: string, location: string, giVersion: string) { return this.pathTemplates.giVersionPathTemplate.render({ project: project, location: location, @@ -10534,7 +13776,8 @@ export class OracleDatabaseClient { * @returns {string} A string representing the project. */ matchProjectFromGiVersionName(giVersionName: string) { - return this.pathTemplates.giVersionPathTemplate.match(giVersionName).project; + return this.pathTemplates.giVersionPathTemplate.match(giVersionName) + .project; } /** @@ -10545,7 +13788,8 @@ export class OracleDatabaseClient { * @returns {string} A string representing the location. */ matchLocationFromGiVersionName(giVersionName: string) { - return this.pathTemplates.giVersionPathTemplate.match(giVersionName).location; + return this.pathTemplates.giVersionPathTemplate.match(giVersionName) + .location; } /** @@ -10556,7 +13800,8 @@ export class OracleDatabaseClient { * @returns {string} A string representing the gi_version. */ matchGiVersionFromGiVersionName(giVersionName: string) { - return this.pathTemplates.giVersionPathTemplate.match(giVersionName).gi_version; + return this.pathTemplates.giVersionPathTemplate.match(giVersionName) + .gi_version; } /** @@ -10566,7 +13811,7 @@ export class OracleDatabaseClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -10604,7 +13849,12 @@ export class OracleDatabaseClient { * @param {string} minor_version * @returns {string} Resource name string. */ - minorVersionPath(project:string,location:string,giVersion:string,minorVersion:string) { + minorVersionPath( + project: string, + location: string, + giVersion: string, + minorVersion: string, + ) { return this.pathTemplates.minorVersionPathTemplate.render({ project: project, location: location, @@ -10621,7 +13871,8 @@ export class OracleDatabaseClient { * @returns {string} A string representing the project. */ matchProjectFromMinorVersionName(minorVersionName: string) { - return this.pathTemplates.minorVersionPathTemplate.match(minorVersionName).project; + return this.pathTemplates.minorVersionPathTemplate.match(minorVersionName) + .project; } /** @@ -10632,7 +13883,8 @@ export class OracleDatabaseClient { * @returns {string} A string representing the location. */ matchLocationFromMinorVersionName(minorVersionName: string) { - return this.pathTemplates.minorVersionPathTemplate.match(minorVersionName).location; + return this.pathTemplates.minorVersionPathTemplate.match(minorVersionName) + .location; } /** @@ -10643,7 +13895,8 @@ export class OracleDatabaseClient { * @returns {string} A string representing the gi_version. */ matchGiVersionFromMinorVersionName(minorVersionName: string) { - return this.pathTemplates.minorVersionPathTemplate.match(minorVersionName).gi_version; + return this.pathTemplates.minorVersionPathTemplate.match(minorVersionName) + .gi_version; } /** @@ -10654,7 +13907,8 @@ export class OracleDatabaseClient { * @returns {string} A string representing the minor_version. */ matchMinorVersionFromMinorVersionName(minorVersionName: string) { - return this.pathTemplates.minorVersionPathTemplate.match(minorVersionName).minor_version; + return this.pathTemplates.minorVersionPathTemplate.match(minorVersionName) + .minor_version; } /** @@ -10665,7 +13919,7 @@ export class OracleDatabaseClient { * @param {string} odb_network * @returns {string} Resource name string. */ - odbNetworkPath(project:string,location:string,odbNetwork:string) { + odbNetworkPath(project: string, location: string, odbNetwork: string) { return this.pathTemplates.odbNetworkPathTemplate.render({ project: project, location: location, @@ -10681,7 +13935,8 @@ export class OracleDatabaseClient { * @returns {string} A string representing the project. */ matchProjectFromOdbNetworkName(odbNetworkName: string) { - return this.pathTemplates.odbNetworkPathTemplate.match(odbNetworkName).project; + return this.pathTemplates.odbNetworkPathTemplate.match(odbNetworkName) + .project; } /** @@ -10692,7 +13947,8 @@ export class OracleDatabaseClient { * @returns {string} A string representing the location. */ matchLocationFromOdbNetworkName(odbNetworkName: string) { - return this.pathTemplates.odbNetworkPathTemplate.match(odbNetworkName).location; + return this.pathTemplates.odbNetworkPathTemplate.match(odbNetworkName) + .location; } /** @@ -10703,7 +13959,8 @@ export class OracleDatabaseClient { * @returns {string} A string representing the odb_network. */ matchOdbNetworkFromOdbNetworkName(odbNetworkName: string) { - return this.pathTemplates.odbNetworkPathTemplate.match(odbNetworkName).odb_network; + return this.pathTemplates.odbNetworkPathTemplate.match(odbNetworkName) + .odb_network; } /** @@ -10715,7 +13972,12 @@ export class OracleDatabaseClient { * @param {string} odb_subnet * @returns {string} Resource name string. */ - odbSubnetPath(project:string,location:string,odbNetwork:string,odbSubnet:string) { + odbSubnetPath( + project: string, + location: string, + odbNetwork: string, + odbSubnet: string, + ) { return this.pathTemplates.odbSubnetPathTemplate.render({ project: project, location: location, @@ -10732,7 +13994,8 @@ export class OracleDatabaseClient { * @returns {string} A string representing the project. */ matchProjectFromOdbSubnetName(odbSubnetName: string) { - return this.pathTemplates.odbSubnetPathTemplate.match(odbSubnetName).project; + return this.pathTemplates.odbSubnetPathTemplate.match(odbSubnetName) + .project; } /** @@ -10743,7 +14006,8 @@ export class OracleDatabaseClient { * @returns {string} A string representing the location. */ matchLocationFromOdbSubnetName(odbSubnetName: string) { - return this.pathTemplates.odbSubnetPathTemplate.match(odbSubnetName).location; + return this.pathTemplates.odbSubnetPathTemplate.match(odbSubnetName) + .location; } /** @@ -10754,7 +14018,8 @@ export class OracleDatabaseClient { * @returns {string} A string representing the odb_network. */ matchOdbNetworkFromOdbSubnetName(odbSubnetName: string) { - return this.pathTemplates.odbSubnetPathTemplate.match(odbSubnetName).odb_network; + return this.pathTemplates.odbSubnetPathTemplate.match(odbSubnetName) + .odb_network; } /** @@ -10765,7 +14030,8 @@ export class OracleDatabaseClient { * @returns {string} A string representing the odb_subnet. */ matchOdbSubnetFromOdbSubnetName(odbSubnetName: string) { - return this.pathTemplates.odbSubnetPathTemplate.match(odbSubnetName).odb_subnet; + return this.pathTemplates.odbSubnetPathTemplate.match(odbSubnetName) + .odb_subnet; } /** @@ -10776,7 +14042,11 @@ export class OracleDatabaseClient { * @param {string} pluggable_database * @returns {string} Resource name string. */ - pluggableDatabasePath(project:string,location:string,pluggableDatabase:string) { + pluggableDatabasePath( + project: string, + location: string, + pluggableDatabase: string, + ) { return this.pathTemplates.pluggableDatabasePathTemplate.render({ project: project, location: location, @@ -10792,7 +14062,9 @@ export class OracleDatabaseClient { * @returns {string} A string representing the project. */ matchProjectFromPluggableDatabaseName(pluggableDatabaseName: string) { - return this.pathTemplates.pluggableDatabasePathTemplate.match(pluggableDatabaseName).project; + return this.pathTemplates.pluggableDatabasePathTemplate.match( + pluggableDatabaseName, + ).project; } /** @@ -10803,7 +14075,9 @@ export class OracleDatabaseClient { * @returns {string} A string representing the location. */ matchLocationFromPluggableDatabaseName(pluggableDatabaseName: string) { - return this.pathTemplates.pluggableDatabasePathTemplate.match(pluggableDatabaseName).location; + return this.pathTemplates.pluggableDatabasePathTemplate.match( + pluggableDatabaseName, + ).location; } /** @@ -10813,8 +14087,12 @@ export class OracleDatabaseClient { * A fully-qualified path representing PluggableDatabase resource. * @returns {string} A string representing the pluggable_database. */ - matchPluggableDatabaseFromPluggableDatabaseName(pluggableDatabaseName: string) { - return this.pathTemplates.pluggableDatabasePathTemplate.match(pluggableDatabaseName).pluggable_database; + matchPluggableDatabaseFromPluggableDatabaseName( + pluggableDatabaseName: string, + ) { + return this.pathTemplates.pluggableDatabasePathTemplate.match( + pluggableDatabaseName, + ).pluggable_database; } /** @@ -10823,7 +14101,7 @@ export class OracleDatabaseClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -10849,13 +14127,20 @@ export class OracleDatabaseClient { * @param {string} db_node * @returns {string} Resource name string. */ - projectLocationCloudVmClusterDbNodesPath(project:string,location:string,cloudVmCluster:string,dbNode:string) { - return this.pathTemplates.projectLocationCloudVmClusterDbNodesPathTemplate.render({ - project: project, - location: location, - cloud_vm_cluster: cloudVmCluster, - db_node: dbNode, - }); + projectLocationCloudVmClusterDbNodesPath( + project: string, + location: string, + cloudVmCluster: string, + dbNode: string, + ) { + return this.pathTemplates.projectLocationCloudVmClusterDbNodesPathTemplate.render( + { + project: project, + location: location, + cloud_vm_cluster: cloudVmCluster, + db_node: dbNode, + }, + ); } /** @@ -10865,8 +14150,12 @@ export class OracleDatabaseClient { * A fully-qualified path representing project_location_cloud_vm_cluster_dbNodes resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectLocationCloudVmClusterDbNodesName(projectLocationCloudVmClusterDbNodesName: string) { - return this.pathTemplates.projectLocationCloudVmClusterDbNodesPathTemplate.match(projectLocationCloudVmClusterDbNodesName).project; + matchProjectFromProjectLocationCloudVmClusterDbNodesName( + projectLocationCloudVmClusterDbNodesName: string, + ) { + return this.pathTemplates.projectLocationCloudVmClusterDbNodesPathTemplate.match( + projectLocationCloudVmClusterDbNodesName, + ).project; } /** @@ -10876,8 +14165,12 @@ export class OracleDatabaseClient { * A fully-qualified path representing project_location_cloud_vm_cluster_dbNodes resource. * @returns {string} A string representing the location. */ - matchLocationFromProjectLocationCloudVmClusterDbNodesName(projectLocationCloudVmClusterDbNodesName: string) { - return this.pathTemplates.projectLocationCloudVmClusterDbNodesPathTemplate.match(projectLocationCloudVmClusterDbNodesName).location; + matchLocationFromProjectLocationCloudVmClusterDbNodesName( + projectLocationCloudVmClusterDbNodesName: string, + ) { + return this.pathTemplates.projectLocationCloudVmClusterDbNodesPathTemplate.match( + projectLocationCloudVmClusterDbNodesName, + ).location; } /** @@ -10887,8 +14180,12 @@ export class OracleDatabaseClient { * A fully-qualified path representing project_location_cloud_vm_cluster_dbNodes resource. * @returns {string} A string representing the cloud_vm_cluster. */ - matchCloudVmClusterFromProjectLocationCloudVmClusterDbNodesName(projectLocationCloudVmClusterDbNodesName: string) { - return this.pathTemplates.projectLocationCloudVmClusterDbNodesPathTemplate.match(projectLocationCloudVmClusterDbNodesName).cloud_vm_cluster; + matchCloudVmClusterFromProjectLocationCloudVmClusterDbNodesName( + projectLocationCloudVmClusterDbNodesName: string, + ) { + return this.pathTemplates.projectLocationCloudVmClusterDbNodesPathTemplate.match( + projectLocationCloudVmClusterDbNodesName, + ).cloud_vm_cluster; } /** @@ -10898,8 +14195,12 @@ export class OracleDatabaseClient { * A fully-qualified path representing project_location_cloud_vm_cluster_dbNodes resource. * @returns {string} A string representing the db_node. */ - matchDbNodeFromProjectLocationCloudVmClusterDbNodesName(projectLocationCloudVmClusterDbNodesName: string) { - return this.pathTemplates.projectLocationCloudVmClusterDbNodesPathTemplate.match(projectLocationCloudVmClusterDbNodesName).db_node; + matchDbNodeFromProjectLocationCloudVmClusterDbNodesName( + projectLocationCloudVmClusterDbNodesName: string, + ) { + return this.pathTemplates.projectLocationCloudVmClusterDbNodesPathTemplate.match( + projectLocationCloudVmClusterDbNodesName, + ).db_node; } /** @@ -10911,13 +14212,20 @@ export class OracleDatabaseClient { * @param {string} db_node * @returns {string} Resource name string. */ - projectLocationExadbVmClusterDbNodesPath(project:string,location:string,exadbVmCluster:string,dbNode:string) { - return this.pathTemplates.projectLocationExadbVmClusterDbNodesPathTemplate.render({ - project: project, - location: location, - exadb_vm_cluster: exadbVmCluster, - db_node: dbNode, - }); + projectLocationExadbVmClusterDbNodesPath( + project: string, + location: string, + exadbVmCluster: string, + dbNode: string, + ) { + return this.pathTemplates.projectLocationExadbVmClusterDbNodesPathTemplate.render( + { + project: project, + location: location, + exadb_vm_cluster: exadbVmCluster, + db_node: dbNode, + }, + ); } /** @@ -10927,8 +14235,12 @@ export class OracleDatabaseClient { * A fully-qualified path representing project_location_exadb_vm_cluster_dbNodes resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectLocationExadbVmClusterDbNodesName(projectLocationExadbVmClusterDbNodesName: string) { - return this.pathTemplates.projectLocationExadbVmClusterDbNodesPathTemplate.match(projectLocationExadbVmClusterDbNodesName).project; + matchProjectFromProjectLocationExadbVmClusterDbNodesName( + projectLocationExadbVmClusterDbNodesName: string, + ) { + return this.pathTemplates.projectLocationExadbVmClusterDbNodesPathTemplate.match( + projectLocationExadbVmClusterDbNodesName, + ).project; } /** @@ -10938,8 +14250,12 @@ export class OracleDatabaseClient { * A fully-qualified path representing project_location_exadb_vm_cluster_dbNodes resource. * @returns {string} A string representing the location. */ - matchLocationFromProjectLocationExadbVmClusterDbNodesName(projectLocationExadbVmClusterDbNodesName: string) { - return this.pathTemplates.projectLocationExadbVmClusterDbNodesPathTemplate.match(projectLocationExadbVmClusterDbNodesName).location; + matchLocationFromProjectLocationExadbVmClusterDbNodesName( + projectLocationExadbVmClusterDbNodesName: string, + ) { + return this.pathTemplates.projectLocationExadbVmClusterDbNodesPathTemplate.match( + projectLocationExadbVmClusterDbNodesName, + ).location; } /** @@ -10949,8 +14265,12 @@ export class OracleDatabaseClient { * A fully-qualified path representing project_location_exadb_vm_cluster_dbNodes resource. * @returns {string} A string representing the exadb_vm_cluster. */ - matchExadbVmClusterFromProjectLocationExadbVmClusterDbNodesName(projectLocationExadbVmClusterDbNodesName: string) { - return this.pathTemplates.projectLocationExadbVmClusterDbNodesPathTemplate.match(projectLocationExadbVmClusterDbNodesName).exadb_vm_cluster; + matchExadbVmClusterFromProjectLocationExadbVmClusterDbNodesName( + projectLocationExadbVmClusterDbNodesName: string, + ) { + return this.pathTemplates.projectLocationExadbVmClusterDbNodesPathTemplate.match( + projectLocationExadbVmClusterDbNodesName, + ).exadb_vm_cluster; } /** @@ -10960,8 +14280,12 @@ export class OracleDatabaseClient { * A fully-qualified path representing project_location_exadb_vm_cluster_dbNodes resource. * @returns {string} A string representing the db_node. */ - matchDbNodeFromProjectLocationExadbVmClusterDbNodesName(projectLocationExadbVmClusterDbNodesName: string) { - return this.pathTemplates.projectLocationExadbVmClusterDbNodesPathTemplate.match(projectLocationExadbVmClusterDbNodesName).db_node; + matchDbNodeFromProjectLocationExadbVmClusterDbNodesName( + projectLocationExadbVmClusterDbNodesName: string, + ) { + return this.pathTemplates.projectLocationExadbVmClusterDbNodesPathTemplate.match( + projectLocationExadbVmClusterDbNodesName, + ).db_node; } /** @@ -10972,14 +14296,16 @@ export class OracleDatabaseClient { */ close(): Promise { if (this.oracleDatabaseStub && !this._terminated) { - return this.oracleDatabaseStub.then(stub => { + return this.oracleDatabaseStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.locationsClient.close().catch(err => {throw err}); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-oracledatabase/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-oracledatabase/system-test/fixtures/sample/src/index.ts index 5c2ae78b5441..973e0bb8afce 100644 --- a/packages/google-cloud-oracledatabase/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-oracledatabase/system-test/fixtures/sample/src/index.ts @@ -16,7 +16,7 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {OracleDatabaseClient} from '@google-cloud/oracledatabase'; +import { OracleDatabaseClient } from '@google-cloud/oracledatabase'; // check that the client class type name can be used function doStuffWithOracleDatabaseClient(client: OracleDatabaseClient) { diff --git a/packages/google-cloud-oracledatabase/system-test/install.ts b/packages/google-cloud-oracledatabase/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-oracledatabase/system-test/install.ts +++ b/packages/google-cloud-oracledatabase/system-test/install.ts @@ -16,34 +16,36 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {packNTest} from 'pack-n-play'; -import {readFileSync} from 'fs'; -import {describe, it} from 'mocha'; +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; +import { describe, it } from 'mocha'; describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { + it('TypeScript code', async function () { this.timeout(300000); const options = { packageDir: process.cwd(), sample: { description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } + ts: readFileSync( + './system-test/fixtures/sample/src/index.ts', + ).toString(), + }, }; await packNTest(options); }); - it('JavaScript code', async function() { + it('JavaScript code', async function () { this.timeout(300000); const options = { packageDir: process.cwd(), sample: { description: 'JavaScript user can use the library', - cjs: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } + cjs: readFileSync( + './system-test/fixtures/sample/src/index.js', + ).toString(), + }, }; await packNTest(options); }); - }); diff --git a/packages/google-cloud-oracledatabase/test/gapic_oracle_database_v1.ts b/packages/google-cloud-oracledatabase/test/gapic_oracle_database_v1.ts index 8b2250641d46..2b72dbf9b498 100644 --- a/packages/google-cloud-oracledatabase/test/gapic_oracle_database_v1.ts +++ b/packages/google-cloud-oracledatabase/test/gapic_oracle_database_v1.ts @@ -19,12285 +19,16594 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as oracledatabaseModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1.OracleDatabaseClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'oracledatabase.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'oracledatabase.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = oracledatabaseModule.v1.OracleDatabaseClient.servicePath; - assert.strictEqual(servicePath, 'oracledatabase.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = oracledatabaseModule.v1.OracleDatabaseClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'oracledatabase.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'oracledatabase.example.com'); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + oracledatabaseModule.v1.OracleDatabaseClient.servicePath; + assert.strictEqual(servicePath, 'oracledatabase.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + oracledatabaseModule.v1.OracleDatabaseClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'oracledatabase.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'oracledatabase.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'oracledatabase.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'oracledatabase.example.com'); + }); - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new oracledatabaseModule.v1.OracleDatabaseClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'oracledatabase.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new oracledatabaseModule.v1.OracleDatabaseClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'oracledatabase.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new oracledatabaseModule.v1.OracleDatabaseClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new oracledatabaseModule.v1.OracleDatabaseClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'oracledatabase.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'oracledatabase.configured.example.com', + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new oracledatabaseModule.v1.OracleDatabaseClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has port', () => { - const port = oracledatabaseModule.v1.OracleDatabaseClient.port; - assert(port); - assert(typeof port === 'number'); - }); + it('has port', () => { + const port = oracledatabaseModule.v1.OracleDatabaseClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('should create a client with no option', () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient(); - assert(client); - }); + it('should create a client with no option', () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient(); + assert(client); + }); - it('should create a client with gRPC fallback', () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - fallback: true, - }); - assert(client); - }); + it('should create a client with gRPC fallback', () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + fallback: true, + }); + assert(client); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.oracleDatabaseStub, undefined); - await client.initialize(); - assert(client.oracleDatabaseStub); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.oracleDatabaseStub, undefined); + await client.initialize(); + assert(client.oracleDatabaseStub); + }); - it('has close method for the initialized client', done => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.oracleDatabaseStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the initialized client', (done) => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.oracleDatabaseStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has close method for the non-initialized client', done => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.oracleDatabaseStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the non-initialized client', (done) => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.oracleDatabaseStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getCloudExadataInfrastructure', () => { + it('invokes getCloudExadataInfrastructure without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetCloudExadataInfrastructureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetCloudExadataInfrastructureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure(), + ); + client.innerApiCalls.getCloudExadataInfrastructure = + stubSimpleCall(expectedResponse); + const [response] = await client.getCloudExadataInfrastructure(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCloudExadataInfrastructure as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCloudExadataInfrastructure as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getCloudExadataInfrastructure', () => { - it('invokes getCloudExadataInfrastructure without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetCloudExadataInfrastructureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetCloudExadataInfrastructureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure() - ); - client.innerApiCalls.getCloudExadataInfrastructure = stubSimpleCall(expectedResponse); - const [response] = await client.getCloudExadataInfrastructure(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCloudExadataInfrastructure as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCloudExadataInfrastructure as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getCloudExadataInfrastructure without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetCloudExadataInfrastructureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetCloudExadataInfrastructureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure(), + ); + client.innerApiCalls.getCloudExadataInfrastructure = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCloudExadataInfrastructure( + request, + ( + err?: Error | null, + result?: protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCloudExadataInfrastructure as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCloudExadataInfrastructure as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getCloudExadataInfrastructure without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetCloudExadataInfrastructureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetCloudExadataInfrastructureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure() - ); - client.innerApiCalls.getCloudExadataInfrastructure = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getCloudExadataInfrastructure( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCloudExadataInfrastructure as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCloudExadataInfrastructure as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getCloudExadataInfrastructure with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetCloudExadataInfrastructureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetCloudExadataInfrastructureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getCloudExadataInfrastructure = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getCloudExadataInfrastructure(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.getCloudExadataInfrastructure as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCloudExadataInfrastructure as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getCloudExadataInfrastructure with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetCloudExadataInfrastructureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetCloudExadataInfrastructureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getCloudExadataInfrastructure = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getCloudExadataInfrastructure(request), expectedError); - const actualRequest = (client.innerApiCalls.getCloudExadataInfrastructure as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCloudExadataInfrastructure as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getCloudExadataInfrastructure with closed client', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetCloudExadataInfrastructureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetCloudExadataInfrastructureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.getCloudExadataInfrastructure(request), + expectedError, + ); + }); + }); + + describe('getCloudVmCluster', () => { + it('invokes getCloudVmCluster without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetCloudVmClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetCloudVmClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CloudVmCluster(), + ); + client.innerApiCalls.getCloudVmCluster = stubSimpleCall(expectedResponse); + const [response] = await client.getCloudVmCluster(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCloudVmCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCloudVmCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getCloudExadataInfrastructure with closed client', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetCloudExadataInfrastructureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetCloudExadataInfrastructureRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getCloudExadataInfrastructure(request), expectedError); - }); + it('invokes getCloudVmCluster without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetCloudVmClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetCloudVmClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CloudVmCluster(), + ); + client.innerApiCalls.getCloudVmCluster = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCloudVmCluster( + request, + ( + err?: Error | null, + result?: protos.google.cloud.oracledatabase.v1.ICloudVmCluster | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCloudVmCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCloudVmCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getCloudVmCluster', () => { - it('invokes getCloudVmCluster without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetCloudVmClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetCloudVmClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CloudVmCluster() - ); - client.innerApiCalls.getCloudVmCluster = stubSimpleCall(expectedResponse); - const [response] = await client.getCloudVmCluster(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCloudVmCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCloudVmCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getCloudVmCluster with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetCloudVmClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetCloudVmClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getCloudVmCluster = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getCloudVmCluster(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getCloudVmCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCloudVmCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getCloudVmCluster without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetCloudVmClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetCloudVmClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CloudVmCluster() - ); - client.innerApiCalls.getCloudVmCluster = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getCloudVmCluster( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.ICloudVmCluster|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCloudVmCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCloudVmCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getCloudVmCluster with closed client', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetCloudVmClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetCloudVmClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getCloudVmCluster(request), expectedError); + }); + }); + + describe('getAutonomousDatabase', () => { + it('invokes getAutonomousDatabase without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabase(), + ); + client.innerApiCalls.getAutonomousDatabase = + stubSimpleCall(expectedResponse); + const [response] = await client.getAutonomousDatabase(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getCloudVmCluster with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetCloudVmClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetCloudVmClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getCloudVmCluster = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getCloudVmCluster(request), expectedError); - const actualRequest = (client.innerApiCalls.getCloudVmCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCloudVmCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getAutonomousDatabase without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabase(), + ); + client.innerApiCalls.getAutonomousDatabase = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getAutonomousDatabase( + request, + ( + err?: Error | null, + result?: protos.google.cloud.oracledatabase.v1.IAutonomousDatabase | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getCloudVmCluster with closed client', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetCloudVmClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetCloudVmClusterRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getCloudVmCluster(request), expectedError); - }); + it('invokes getAutonomousDatabase with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getAutonomousDatabase = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getAutonomousDatabase(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.getAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getAutonomousDatabase', () => { - it('invokes getAutonomousDatabase without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.AutonomousDatabase() - ); - client.innerApiCalls.getAutonomousDatabase = stubSimpleCall(expectedResponse); - const [response] = await client.getAutonomousDatabase(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getAutonomousDatabase with closed client', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.getAutonomousDatabase(request), + expectedError, + ); + }); + }); + + describe('generateAutonomousDatabaseWallet', () => { + it('invokes generateAutonomousDatabaseWallet without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GenerateAutonomousDatabaseWalletRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GenerateAutonomousDatabaseWalletRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GenerateAutonomousDatabaseWalletResponse(), + ); + client.innerApiCalls.generateAutonomousDatabaseWallet = + stubSimpleCall(expectedResponse); + const [response] = await client.generateAutonomousDatabaseWallet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.generateAutonomousDatabaseWallet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateAutonomousDatabaseWallet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getAutonomousDatabase without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.AutonomousDatabase() - ); - client.innerApiCalls.getAutonomousDatabase = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getAutonomousDatabase( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.IAutonomousDatabase|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes generateAutonomousDatabaseWallet without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GenerateAutonomousDatabaseWalletRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GenerateAutonomousDatabaseWalletRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GenerateAutonomousDatabaseWalletResponse(), + ); + client.innerApiCalls.generateAutonomousDatabaseWallet = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.generateAutonomousDatabaseWallet( + request, + ( + err?: Error | null, + result?: protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.generateAutonomousDatabaseWallet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateAutonomousDatabaseWallet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getAutonomousDatabase with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getAutonomousDatabase = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getAutonomousDatabase(request), expectedError); - const actualRequest = (client.innerApiCalls.getAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes generateAutonomousDatabaseWallet with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GenerateAutonomousDatabaseWalletRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GenerateAutonomousDatabaseWalletRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.generateAutonomousDatabaseWallet = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.generateAutonomousDatabaseWallet(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.generateAutonomousDatabaseWallet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateAutonomousDatabaseWallet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getAutonomousDatabase with closed client', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getAutonomousDatabase(request), expectedError); - }); + it('invokes generateAutonomousDatabaseWallet with closed client', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GenerateAutonomousDatabaseWalletRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GenerateAutonomousDatabaseWalletRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.generateAutonomousDatabaseWallet(request), + expectedError, + ); + }); + }); + + describe('getOdbNetwork', () => { + it('invokes getOdbNetwork without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetOdbNetworkRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetOdbNetworkRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.OdbNetwork(), + ); + client.innerApiCalls.getOdbNetwork = stubSimpleCall(expectedResponse); + const [response] = await client.getOdbNetwork(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getOdbNetwork as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getOdbNetwork as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('generateAutonomousDatabaseWallet', () => { - it('invokes generateAutonomousDatabaseWallet without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GenerateAutonomousDatabaseWalletRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GenerateAutonomousDatabaseWalletRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GenerateAutonomousDatabaseWalletResponse() - ); - client.innerApiCalls.generateAutonomousDatabaseWallet = stubSimpleCall(expectedResponse); - const [response] = await client.generateAutonomousDatabaseWallet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.generateAutonomousDatabaseWallet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateAutonomousDatabaseWallet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getOdbNetwork without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetOdbNetworkRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetOdbNetworkRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.OdbNetwork(), + ); + client.innerApiCalls.getOdbNetwork = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getOdbNetwork( + request, + ( + err?: Error | null, + result?: protos.google.cloud.oracledatabase.v1.IOdbNetwork | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getOdbNetwork as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getOdbNetwork as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes generateAutonomousDatabaseWallet without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GenerateAutonomousDatabaseWalletRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GenerateAutonomousDatabaseWalletRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GenerateAutonomousDatabaseWalletResponse() - ); - client.innerApiCalls.generateAutonomousDatabaseWallet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.generateAutonomousDatabaseWallet( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.IGenerateAutonomousDatabaseWalletResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.generateAutonomousDatabaseWallet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateAutonomousDatabaseWallet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getOdbNetwork with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetOdbNetworkRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetOdbNetworkRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getOdbNetwork = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getOdbNetwork(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getOdbNetwork as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getOdbNetwork as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes generateAutonomousDatabaseWallet with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GenerateAutonomousDatabaseWalletRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GenerateAutonomousDatabaseWalletRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.generateAutonomousDatabaseWallet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.generateAutonomousDatabaseWallet(request), expectedError); - const actualRequest = (client.innerApiCalls.generateAutonomousDatabaseWallet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateAutonomousDatabaseWallet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getOdbNetwork with closed client', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetOdbNetworkRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetOdbNetworkRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getOdbNetwork(request), expectedError); + }); + }); + + describe('getOdbSubnet', () => { + it('invokes getOdbSubnet without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetOdbSubnetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetOdbSubnetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.OdbSubnet(), + ); + client.innerApiCalls.getOdbSubnet = stubSimpleCall(expectedResponse); + const [response] = await client.getOdbSubnet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getOdbSubnet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getOdbSubnet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes generateAutonomousDatabaseWallet with closed client', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GenerateAutonomousDatabaseWalletRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GenerateAutonomousDatabaseWalletRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.generateAutonomousDatabaseWallet(request), expectedError); - }); + it('invokes getOdbSubnet without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetOdbSubnetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetOdbSubnetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.OdbSubnet(), + ); + client.innerApiCalls.getOdbSubnet = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getOdbSubnet( + request, + ( + err?: Error | null, + result?: protos.google.cloud.oracledatabase.v1.IOdbSubnet | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getOdbSubnet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getOdbSubnet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getOdbNetwork', () => { - it('invokes getOdbNetwork without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetOdbNetworkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetOdbNetworkRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.OdbNetwork() - ); - client.innerApiCalls.getOdbNetwork = stubSimpleCall(expectedResponse); - const [response] = await client.getOdbNetwork(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getOdbNetwork as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getOdbNetwork as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getOdbSubnet with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetOdbSubnetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetOdbSubnetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getOdbSubnet = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getOdbSubnet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getOdbSubnet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getOdbSubnet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getOdbNetwork without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetOdbNetworkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetOdbNetworkRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.OdbNetwork() - ); - client.innerApiCalls.getOdbNetwork = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getOdbNetwork( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.IOdbNetwork|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getOdbNetwork as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getOdbNetwork as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getOdbSubnet with closed client', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetOdbSubnetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetOdbSubnetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getOdbSubnet(request), expectedError); + }); + }); + + describe('getExadbVmCluster', () => { + it('invokes getExadbVmCluster without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetExadbVmClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetExadbVmClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ExadbVmCluster(), + ); + client.innerApiCalls.getExadbVmCluster = stubSimpleCall(expectedResponse); + const [response] = await client.getExadbVmCluster(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getExadbVmCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getExadbVmCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getOdbNetwork with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetOdbNetworkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetOdbNetworkRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getOdbNetwork = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getOdbNetwork(request), expectedError); - const actualRequest = (client.innerApiCalls.getOdbNetwork as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getOdbNetwork as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getExadbVmCluster without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetExadbVmClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetExadbVmClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ExadbVmCluster(), + ); + client.innerApiCalls.getExadbVmCluster = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getExadbVmCluster( + request, + ( + err?: Error | null, + result?: protos.google.cloud.oracledatabase.v1.IExadbVmCluster | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getExadbVmCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getExadbVmCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getOdbNetwork with closed client', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetOdbNetworkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetOdbNetworkRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getOdbNetwork(request), expectedError); - }); + it('invokes getExadbVmCluster with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetExadbVmClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetExadbVmClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getExadbVmCluster = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getExadbVmCluster(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getExadbVmCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getExadbVmCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getOdbSubnet', () => { - it('invokes getOdbSubnet without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetOdbSubnetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetOdbSubnetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.OdbSubnet() - ); - client.innerApiCalls.getOdbSubnet = stubSimpleCall(expectedResponse); - const [response] = await client.getOdbSubnet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getOdbSubnet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getOdbSubnet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getExadbVmCluster with closed client', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetExadbVmClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetExadbVmClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getExadbVmCluster(request), expectedError); + }); + }); + + describe('getExascaleDbStorageVault', () => { + it('invokes getExascaleDbStorageVault without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetExascaleDbStorageVaultRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetExascaleDbStorageVaultRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault(), + ); + client.innerApiCalls.getExascaleDbStorageVault = + stubSimpleCall(expectedResponse); + const [response] = await client.getExascaleDbStorageVault(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getExascaleDbStorageVault as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getExascaleDbStorageVault as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getOdbSubnet without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetOdbSubnetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetOdbSubnetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.OdbSubnet() - ); - client.innerApiCalls.getOdbSubnet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getOdbSubnet( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.IOdbSubnet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getOdbSubnet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getOdbSubnet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getExascaleDbStorageVault without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetExascaleDbStorageVaultRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetExascaleDbStorageVaultRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault(), + ); + client.innerApiCalls.getExascaleDbStorageVault = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getExascaleDbStorageVault( + request, + ( + err?: Error | null, + result?: protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getExascaleDbStorageVault as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getExascaleDbStorageVault as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getOdbSubnet with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetOdbSubnetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetOdbSubnetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getOdbSubnet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getOdbSubnet(request), expectedError); - const actualRequest = (client.innerApiCalls.getOdbSubnet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getOdbSubnet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getExascaleDbStorageVault with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetExascaleDbStorageVaultRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetExascaleDbStorageVaultRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getExascaleDbStorageVault = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getExascaleDbStorageVault(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.getExascaleDbStorageVault as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getExascaleDbStorageVault as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getOdbSubnet with closed client', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetOdbSubnetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetOdbSubnetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getOdbSubnet(request), expectedError); - }); + it('invokes getExascaleDbStorageVault with closed client', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetExascaleDbStorageVaultRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetExascaleDbStorageVaultRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.getExascaleDbStorageVault(request), + expectedError, + ); + }); + }); + + describe('getDatabase', () => { + it('invokes getDatabase without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.Database(), + ); + client.innerApiCalls.getDatabase = stubSimpleCall(expectedResponse); + const [response] = await client.getDatabase(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getExadbVmCluster', () => { - it('invokes getExadbVmCluster without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetExadbVmClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetExadbVmClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ExadbVmCluster() - ); - client.innerApiCalls.getExadbVmCluster = stubSimpleCall(expectedResponse); - const [response] = await client.getExadbVmCluster(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getExadbVmCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getExadbVmCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getDatabase without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.Database(), + ); + client.innerApiCalls.getDatabase = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDatabase( + request, + ( + err?: Error | null, + result?: protos.google.cloud.oracledatabase.v1.IDatabase | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getExadbVmCluster without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetExadbVmClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetExadbVmClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ExadbVmCluster() - ); - client.innerApiCalls.getExadbVmCluster = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getExadbVmCluster( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.IExadbVmCluster|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getExadbVmCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getExadbVmCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getDatabase with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getDatabase = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getDatabase(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getExadbVmCluster with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetExadbVmClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetExadbVmClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getExadbVmCluster = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getExadbVmCluster(request), expectedError); - const actualRequest = (client.innerApiCalls.getExadbVmCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getExadbVmCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getDatabase with closed client', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getDatabase(request), expectedError); + }); + }); + + describe('getPluggableDatabase', () => { + it('invokes getPluggableDatabase without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetPluggableDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetPluggableDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.PluggableDatabase(), + ); + client.innerApiCalls.getPluggableDatabase = + stubSimpleCall(expectedResponse); + const [response] = await client.getPluggableDatabase(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getPluggableDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPluggableDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getExadbVmCluster with closed client', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetExadbVmClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetExadbVmClusterRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getExadbVmCluster(request), expectedError); - }); + it('invokes getPluggableDatabase without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetPluggableDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetPluggableDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.PluggableDatabase(), + ); + client.innerApiCalls.getPluggableDatabase = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getPluggableDatabase( + request, + ( + err?: Error | null, + result?: protos.google.cloud.oracledatabase.v1.IPluggableDatabase | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getPluggableDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPluggableDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getExascaleDbStorageVault', () => { - it('invokes getExascaleDbStorageVault without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetExascaleDbStorageVaultRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetExascaleDbStorageVaultRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault() - ); - client.innerApiCalls.getExascaleDbStorageVault = stubSimpleCall(expectedResponse); - const [response] = await client.getExascaleDbStorageVault(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getExascaleDbStorageVault as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getExascaleDbStorageVault as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getPluggableDatabase with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetPluggableDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetPluggableDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getPluggableDatabase = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getPluggableDatabase(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getPluggableDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPluggableDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getExascaleDbStorageVault without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetExascaleDbStorageVaultRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetExascaleDbStorageVaultRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault() - ); - client.innerApiCalls.getExascaleDbStorageVault = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getExascaleDbStorageVault( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getExascaleDbStorageVault as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getExascaleDbStorageVault as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getPluggableDatabase with closed client', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetPluggableDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetPluggableDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getPluggableDatabase(request), expectedError); + }); + }); + + describe('getDbSystem', () => { + it('invokes getDbSystem without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetDbSystemRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetDbSystemRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystem(), + ); + client.innerApiCalls.getDbSystem = stubSimpleCall(expectedResponse); + const [response] = await client.getDbSystem(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getDbSystem as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDbSystem as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getExascaleDbStorageVault with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetExascaleDbStorageVaultRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetExascaleDbStorageVaultRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getExascaleDbStorageVault = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getExascaleDbStorageVault(request), expectedError); - const actualRequest = (client.innerApiCalls.getExascaleDbStorageVault as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getExascaleDbStorageVault as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getDbSystem without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetDbSystemRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetDbSystemRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystem(), + ); + client.innerApiCalls.getDbSystem = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDbSystem( + request, + ( + err?: Error | null, + result?: protos.google.cloud.oracledatabase.v1.IDbSystem | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getDbSystem as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDbSystem as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getExascaleDbStorageVault with closed client', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetExascaleDbStorageVaultRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetExascaleDbStorageVaultRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getExascaleDbStorageVault(request), expectedError); - }); + it('invokes getDbSystem with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetDbSystemRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetDbSystemRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getDbSystem = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getDbSystem(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getDbSystem as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDbSystem as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getDatabase', () => { - it('invokes getDatabase without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.Database() - ); - client.innerApiCalls.getDatabase = stubSimpleCall(expectedResponse); - const [response] = await client.getDatabase(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getDbSystem with closed client', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GetDbSystemRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.GetDbSystemRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getDbSystem(request), expectedError); + }); + }); + + describe('createCloudExadataInfrastructure', () => { + it('invokes createCloudExadataInfrastructure without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateCloudExadataInfrastructureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateCloudExadataInfrastructureRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createCloudExadataInfrastructure = + stubLongRunningCall(expectedResponse); + const [operation] = + await client.createCloudExadataInfrastructure(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCloudExadataInfrastructure as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCloudExadataInfrastructure as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getDatabase without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.Database() - ); - client.innerApiCalls.getDatabase = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getDatabase( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.IDatabase|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createCloudExadataInfrastructure without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateCloudExadataInfrastructureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateCloudExadataInfrastructureRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createCloudExadataInfrastructure = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createCloudExadataInfrastructure( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCloudExadataInfrastructure as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCloudExadataInfrastructure as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getDatabase with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getDatabase = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDatabase(request), expectedError); - const actualRequest = (client.innerApiCalls.getDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createCloudExadataInfrastructure with call error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateCloudExadataInfrastructureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateCloudExadataInfrastructureRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createCloudExadataInfrastructure = + stubLongRunningCall(undefined, expectedError); + await assert.rejects( + client.createCloudExadataInfrastructure(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createCloudExadataInfrastructure as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCloudExadataInfrastructure as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getDatabase with closed client', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getDatabase(request), expectedError); - }); + it('invokes createCloudExadataInfrastructure with LRO error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateCloudExadataInfrastructureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateCloudExadataInfrastructureRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createCloudExadataInfrastructure = + stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = + await client.createCloudExadataInfrastructure(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createCloudExadataInfrastructure as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCloudExadataInfrastructure as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getPluggableDatabase', () => { - it('invokes getPluggableDatabase without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetPluggableDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetPluggableDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.PluggableDatabase() - ); - client.innerApiCalls.getPluggableDatabase = stubSimpleCall(expectedResponse); - const [response] = await client.getPluggableDatabase(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getPluggableDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPluggableDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateCloudExadataInfrastructureProgress without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateCloudExadataInfrastructureProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes getPluggableDatabase without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetPluggableDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetPluggableDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.PluggableDatabase() - ); - client.innerApiCalls.getPluggableDatabase = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getPluggableDatabase( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.IPluggableDatabase|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getPluggableDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPluggableDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateCloudExadataInfrastructureProgress with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateCloudExadataInfrastructureProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteCloudExadataInfrastructure', () => { + it('invokes deleteCloudExadataInfrastructure without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteCloudExadataInfrastructureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteCloudExadataInfrastructureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteCloudExadataInfrastructure = + stubLongRunningCall(expectedResponse); + const [operation] = + await client.deleteCloudExadataInfrastructure(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteCloudExadataInfrastructure as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCloudExadataInfrastructure as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getPluggableDatabase with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetPluggableDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetPluggableDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getPluggableDatabase = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getPluggableDatabase(request), expectedError); - const actualRequest = (client.innerApiCalls.getPluggableDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPluggableDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteCloudExadataInfrastructure without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteCloudExadataInfrastructureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteCloudExadataInfrastructureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteCloudExadataInfrastructure = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteCloudExadataInfrastructure( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteCloudExadataInfrastructure as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCloudExadataInfrastructure as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getPluggableDatabase with closed client', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetPluggableDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetPluggableDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getPluggableDatabase(request), expectedError); - }); + it('invokes deleteCloudExadataInfrastructure with call error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteCloudExadataInfrastructureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteCloudExadataInfrastructureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteCloudExadataInfrastructure = + stubLongRunningCall(undefined, expectedError); + await assert.rejects( + client.deleteCloudExadataInfrastructure(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteCloudExadataInfrastructure as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCloudExadataInfrastructure as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getDbSystem', () => { - it('invokes getDbSystem without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetDbSystemRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetDbSystemRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DbSystem() - ); - client.innerApiCalls.getDbSystem = stubSimpleCall(expectedResponse); - const [response] = await client.getDbSystem(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDbSystem as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDbSystem as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteCloudExadataInfrastructure with LRO error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteCloudExadataInfrastructureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteCloudExadataInfrastructureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteCloudExadataInfrastructure = + stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = + await client.deleteCloudExadataInfrastructure(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteCloudExadataInfrastructure as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCloudExadataInfrastructure as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getDbSystem without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetDbSystemRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetDbSystemRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DbSystem() - ); - client.innerApiCalls.getDbSystem = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getDbSystem( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.IDbSystem|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDbSystem as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDbSystem as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteCloudExadataInfrastructureProgress without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteCloudExadataInfrastructureProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes getDbSystem with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetDbSystemRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetDbSystemRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getDbSystem = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDbSystem(request), expectedError); - const actualRequest = (client.innerApiCalls.getDbSystem as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDbSystem as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteCloudExadataInfrastructureProgress with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteCloudExadataInfrastructureProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createCloudVmCluster', () => { + it('invokes createCloudVmCluster without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateCloudVmClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateCloudVmClusterRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createCloudVmCluster = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createCloudVmCluster(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCloudVmCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCloudVmCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getDbSystem with closed client', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.GetDbSystemRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.GetDbSystemRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getDbSystem(request), expectedError); - }); + it('invokes createCloudVmCluster without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateCloudVmClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateCloudVmClusterRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createCloudVmCluster = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createCloudVmCluster( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.oracledatabase.v1.ICloudVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.oracledatabase.v1.ICloudVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCloudVmCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCloudVmCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createCloudExadataInfrastructure', () => { - it('invokes createCloudExadataInfrastructure without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateCloudExadataInfrastructureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateCloudExadataInfrastructureRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createCloudExadataInfrastructure = stubLongRunningCall(expectedResponse); - const [operation] = await client.createCloudExadataInfrastructure(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCloudExadataInfrastructure as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCloudExadataInfrastructure as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createCloudVmCluster with call error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateCloudVmClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateCloudVmClusterRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createCloudVmCluster = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createCloudVmCluster(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createCloudVmCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCloudVmCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createCloudExadataInfrastructure without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateCloudExadataInfrastructureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateCloudExadataInfrastructureRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createCloudExadataInfrastructure = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createCloudExadataInfrastructure( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCloudExadataInfrastructure as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCloudExadataInfrastructure as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createCloudVmCluster with LRO error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateCloudVmClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateCloudVmClusterRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createCloudVmCluster = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createCloudVmCluster(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createCloudVmCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCloudVmCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createCloudExadataInfrastructure with call error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateCloudExadataInfrastructureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateCloudExadataInfrastructureRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createCloudExadataInfrastructure = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createCloudExadataInfrastructure(request), expectedError); - const actualRequest = (client.innerApiCalls.createCloudExadataInfrastructure as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCloudExadataInfrastructure as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateCloudVmClusterProgress without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateCloudVmClusterProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createCloudExadataInfrastructure with LRO error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateCloudExadataInfrastructureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateCloudExadataInfrastructureRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createCloudExadataInfrastructure = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createCloudExadataInfrastructure(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createCloudExadataInfrastructure as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCloudExadataInfrastructure as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateCloudVmClusterProgress with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateCloudVmClusterProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteCloudVmCluster', () => { + it('invokes deleteCloudVmCluster without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteCloudVmClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteCloudVmClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteCloudVmCluster = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteCloudVmCluster(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteCloudVmCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCloudVmCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateCloudExadataInfrastructureProgress without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateCloudExadataInfrastructureProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteCloudVmCluster without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteCloudVmClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteCloudVmClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteCloudVmCluster = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteCloudVmCluster( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteCloudVmCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCloudVmCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateCloudExadataInfrastructureProgress with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateCloudExadataInfrastructureProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteCloudVmCluster with call error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteCloudVmClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteCloudVmClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteCloudVmCluster = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteCloudVmCluster(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteCloudVmCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCloudVmCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteCloudExadataInfrastructure', () => { - it('invokes deleteCloudExadataInfrastructure without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteCloudExadataInfrastructureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteCloudExadataInfrastructureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteCloudExadataInfrastructure = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteCloudExadataInfrastructure(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteCloudExadataInfrastructure as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCloudExadataInfrastructure as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteCloudVmCluster with LRO error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteCloudVmClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteCloudVmClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteCloudVmCluster = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteCloudVmCluster(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteCloudVmCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCloudVmCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteCloudExadataInfrastructure without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteCloudExadataInfrastructureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteCloudExadataInfrastructureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteCloudExadataInfrastructure = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteCloudExadataInfrastructure( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteCloudExadataInfrastructure as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCloudExadataInfrastructure as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteCloudVmClusterProgress without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteCloudVmClusterProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteCloudExadataInfrastructure with call error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteCloudExadataInfrastructureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteCloudExadataInfrastructureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteCloudExadataInfrastructure = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteCloudExadataInfrastructure(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteCloudExadataInfrastructure as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCloudExadataInfrastructure as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteCloudVmClusterProgress with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteCloudVmClusterProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createAutonomousDatabase', () => { + it('invokes createAutonomousDatabase without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateAutonomousDatabaseRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createAutonomousDatabase = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createAutonomousDatabase(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteCloudExadataInfrastructure with LRO error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteCloudExadataInfrastructureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteCloudExadataInfrastructureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteCloudExadataInfrastructure = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteCloudExadataInfrastructure(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteCloudExadataInfrastructure as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCloudExadataInfrastructure as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createAutonomousDatabase without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateAutonomousDatabaseRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createAutonomousDatabase = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createAutonomousDatabase( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteCloudExadataInfrastructureProgress without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteCloudExadataInfrastructureProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createAutonomousDatabase with call error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateAutonomousDatabaseRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createAutonomousDatabase = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.createAutonomousDatabase(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteCloudExadataInfrastructureProgress with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteCloudExadataInfrastructureProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createAutonomousDatabase with LRO error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateAutonomousDatabaseRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createAutonomousDatabase = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createAutonomousDatabase(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createCloudVmCluster', () => { - it('invokes createCloudVmCluster without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateCloudVmClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateCloudVmClusterRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createCloudVmCluster = stubLongRunningCall(expectedResponse); - const [operation] = await client.createCloudVmCluster(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCloudVmCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCloudVmCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateAutonomousDatabaseProgress without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateAutonomousDatabaseProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createCloudVmCluster without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateCloudVmClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateCloudVmClusterRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createCloudVmCluster = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createCloudVmCluster( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCloudVmCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCloudVmCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateAutonomousDatabaseProgress with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateAutonomousDatabaseProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateAutonomousDatabase', () => { + it('invokes updateAutonomousDatabase without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.UpdateAutonomousDatabaseRequest(), + ); + request.autonomousDatabase ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.UpdateAutonomousDatabaseRequest', + ['autonomousDatabase', 'name'], + ); + request.autonomousDatabase.name = defaultValue1; + const expectedHeaderRequestParams = `autonomous_database.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateAutonomousDatabase = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateAutonomousDatabase(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createCloudVmCluster with call error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateCloudVmClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateCloudVmClusterRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createCloudVmCluster = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createCloudVmCluster(request), expectedError); - const actualRequest = (client.innerApiCalls.createCloudVmCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCloudVmCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateAutonomousDatabase without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.UpdateAutonomousDatabaseRequest(), + ); + request.autonomousDatabase ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.UpdateAutonomousDatabaseRequest', + ['autonomousDatabase', 'name'], + ); + request.autonomousDatabase.name = defaultValue1; + const expectedHeaderRequestParams = `autonomous_database.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateAutonomousDatabase = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateAutonomousDatabase( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createCloudVmCluster with LRO error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateCloudVmClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateCloudVmClusterRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createCloudVmCluster = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createCloudVmCluster(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createCloudVmCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCloudVmCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateAutonomousDatabase with call error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.UpdateAutonomousDatabaseRequest(), + ); + request.autonomousDatabase ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.UpdateAutonomousDatabaseRequest', + ['autonomousDatabase', 'name'], + ); + request.autonomousDatabase.name = defaultValue1; + const expectedHeaderRequestParams = `autonomous_database.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateAutonomousDatabase = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.updateAutonomousDatabase(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.updateAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateCloudVmClusterProgress without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateCloudVmClusterProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateAutonomousDatabase with LRO error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.UpdateAutonomousDatabaseRequest(), + ); + request.autonomousDatabase ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.UpdateAutonomousDatabaseRequest', + ['autonomousDatabase', 'name'], + ); + request.autonomousDatabase.name = defaultValue1; + const expectedHeaderRequestParams = `autonomous_database.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateAutonomousDatabase = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateAutonomousDatabase(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateCloudVmClusterProgress with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateCloudVmClusterProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpdateAutonomousDatabaseProgress without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateAutonomousDatabaseProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('deleteCloudVmCluster', () => { - it('invokes deleteCloudVmCluster without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteCloudVmClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteCloudVmClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteCloudVmCluster = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteCloudVmCluster(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteCloudVmCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCloudVmCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateAutonomousDatabaseProgress with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateAutonomousDatabaseProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteAutonomousDatabase', () => { + it('invokes deleteAutonomousDatabase without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteAutonomousDatabase = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteAutonomousDatabase(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteCloudVmCluster without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteCloudVmClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteCloudVmClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteCloudVmCluster = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteCloudVmCluster( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteCloudVmCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCloudVmCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteAutonomousDatabase without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteAutonomousDatabase = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteAutonomousDatabase( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteCloudVmCluster with call error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteCloudVmClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteCloudVmClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteCloudVmCluster = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteCloudVmCluster(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteCloudVmCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCloudVmCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteAutonomousDatabase with call error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteAutonomousDatabase = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.deleteAutonomousDatabase(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteCloudVmCluster with LRO error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteCloudVmClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteCloudVmClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteCloudVmCluster = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteCloudVmCluster(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteCloudVmCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCloudVmCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteAutonomousDatabase with LRO error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteAutonomousDatabase = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteAutonomousDatabase(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteCloudVmClusterProgress without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteCloudVmClusterProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkDeleteAutonomousDatabaseProgress without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteAutonomousDatabaseProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteCloudVmClusterProgress with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteCloudVmClusterProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteAutonomousDatabaseProgress with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteAutonomousDatabaseProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('restoreAutonomousDatabase', () => { + it('invokes restoreAutonomousDatabase without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.RestoreAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.RestoreAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.restoreAutonomousDatabase = + stubLongRunningCall(expectedResponse); + const [operation] = await client.restoreAutonomousDatabase(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.restoreAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createAutonomousDatabase', () => { - it('invokes createAutonomousDatabase without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateAutonomousDatabaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createAutonomousDatabase = stubLongRunningCall(expectedResponse); - const [operation] = await client.createAutonomousDatabase(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes restoreAutonomousDatabase without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.RestoreAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.RestoreAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.restoreAutonomousDatabase = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.restoreAutonomousDatabase( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.restoreAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createAutonomousDatabase without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateAutonomousDatabaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createAutonomousDatabase = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createAutonomousDatabase( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes restoreAutonomousDatabase with call error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.RestoreAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.RestoreAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.restoreAutonomousDatabase = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.restoreAutonomousDatabase(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.restoreAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createAutonomousDatabase with call error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateAutonomousDatabaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createAutonomousDatabase = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createAutonomousDatabase(request), expectedError); - const actualRequest = (client.innerApiCalls.createAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes restoreAutonomousDatabase with LRO error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.RestoreAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.RestoreAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.restoreAutonomousDatabase = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.restoreAutonomousDatabase(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.restoreAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createAutonomousDatabase with LRO error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateAutonomousDatabaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createAutonomousDatabase = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createAutonomousDatabase(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRestoreAutonomousDatabaseProgress without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkRestoreAutonomousDatabaseProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkCreateAutonomousDatabaseProgress without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateAutonomousDatabaseProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkRestoreAutonomousDatabaseProgress with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkRestoreAutonomousDatabaseProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('stopAutonomousDatabase', () => { + it('invokes stopAutonomousDatabase without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.StopAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.StopAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.stopAutonomousDatabase = + stubLongRunningCall(expectedResponse); + const [operation] = await client.stopAutonomousDatabase(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.stopAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateAutonomousDatabaseProgress with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateAutonomousDatabaseProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes stopAutonomousDatabase without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.StopAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.StopAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.stopAutonomousDatabase = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.stopAutonomousDatabase( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.stopAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateAutonomousDatabase', () => { - it('invokes updateAutonomousDatabase without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.UpdateAutonomousDatabaseRequest() - ); - request.autonomousDatabase ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.UpdateAutonomousDatabaseRequest', ['autonomousDatabase', 'name']); - request.autonomousDatabase.name = defaultValue1; - const expectedHeaderRequestParams = `autonomous_database.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateAutonomousDatabase = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateAutonomousDatabase(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes stopAutonomousDatabase with call error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.StopAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.StopAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.stopAutonomousDatabase = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.stopAutonomousDatabase(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.stopAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateAutonomousDatabase without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.UpdateAutonomousDatabaseRequest() - ); - request.autonomousDatabase ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.UpdateAutonomousDatabaseRequest', ['autonomousDatabase', 'name']); - request.autonomousDatabase.name = defaultValue1; - const expectedHeaderRequestParams = `autonomous_database.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateAutonomousDatabase = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateAutonomousDatabase( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes stopAutonomousDatabase with LRO error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.StopAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.StopAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.stopAutonomousDatabase = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.stopAutonomousDatabase(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.stopAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateAutonomousDatabase with call error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.UpdateAutonomousDatabaseRequest() - ); - request.autonomousDatabase ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.UpdateAutonomousDatabaseRequest', ['autonomousDatabase', 'name']); - request.autonomousDatabase.name = defaultValue1; - const expectedHeaderRequestParams = `autonomous_database.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateAutonomousDatabase = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateAutonomousDatabase(request), expectedError); - const actualRequest = (client.innerApiCalls.updateAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkStopAutonomousDatabaseProgress without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkStopAutonomousDatabaseProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateAutonomousDatabase with LRO error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.UpdateAutonomousDatabaseRequest() - ); - request.autonomousDatabase ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.UpdateAutonomousDatabaseRequest', ['autonomousDatabase', 'name']); - request.autonomousDatabase.name = defaultValue1; - const expectedHeaderRequestParams = `autonomous_database.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateAutonomousDatabase = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateAutonomousDatabase(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkStopAutonomousDatabaseProgress with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkStopAutonomousDatabaseProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('startAutonomousDatabase', () => { + it('invokes startAutonomousDatabase without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.StartAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.StartAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.startAutonomousDatabase = + stubLongRunningCall(expectedResponse); + const [operation] = await client.startAutonomousDatabase(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.startAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateAutonomousDatabaseProgress without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateAutonomousDatabaseProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes startAutonomousDatabase without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.StartAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.StartAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.startAutonomousDatabase = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.startAutonomousDatabase( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.startAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateAutonomousDatabaseProgress with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateAutonomousDatabaseProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes startAutonomousDatabase with call error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.StartAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.StartAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.startAutonomousDatabase = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.startAutonomousDatabase(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.startAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteAutonomousDatabase', () => { - it('invokes deleteAutonomousDatabase without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteAutonomousDatabase = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteAutonomousDatabase(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes startAutonomousDatabase with LRO error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.StartAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.StartAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.startAutonomousDatabase = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.startAutonomousDatabase(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.startAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteAutonomousDatabase without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteAutonomousDatabase = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteAutonomousDatabase( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkStartAutonomousDatabaseProgress without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkStartAutonomousDatabaseProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteAutonomousDatabase with call error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteAutonomousDatabase = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteAutonomousDatabase(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkStartAutonomousDatabaseProgress with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkStartAutonomousDatabaseProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('restartAutonomousDatabase', () => { + it('invokes restartAutonomousDatabase without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.RestartAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.RestartAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.restartAutonomousDatabase = + stubLongRunningCall(expectedResponse); + const [operation] = await client.restartAutonomousDatabase(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.restartAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restartAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteAutonomousDatabase with LRO error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteAutonomousDatabase = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteAutonomousDatabase(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes restartAutonomousDatabase without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.RestartAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.RestartAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.restartAutonomousDatabase = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.restartAutonomousDatabase( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.restartAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restartAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteAutonomousDatabaseProgress without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteAutonomousDatabaseProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes restartAutonomousDatabase with call error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.RestartAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.RestartAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.restartAutonomousDatabase = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.restartAutonomousDatabase(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.restartAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restartAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteAutonomousDatabaseProgress with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteAutonomousDatabaseProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes restartAutonomousDatabase with LRO error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.RestartAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.RestartAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.restartAutonomousDatabase = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.restartAutonomousDatabase(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.restartAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restartAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('restoreAutonomousDatabase', () => { - it('invokes restoreAutonomousDatabase without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.RestoreAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.RestoreAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.restoreAutonomousDatabase = stubLongRunningCall(expectedResponse); - const [operation] = await client.restoreAutonomousDatabase(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.restoreAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRestartAutonomousDatabaseProgress without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkRestartAutonomousDatabaseProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes restoreAutonomousDatabase without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.RestoreAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.RestoreAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.restoreAutonomousDatabase = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.restoreAutonomousDatabase( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.restoreAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRestartAutonomousDatabaseProgress with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkRestartAutonomousDatabaseProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('switchoverAutonomousDatabase', () => { + it('invokes switchoverAutonomousDatabase without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.SwitchoverAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.SwitchoverAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.switchoverAutonomousDatabase = + stubLongRunningCall(expectedResponse); + const [operation] = await client.switchoverAutonomousDatabase(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.switchoverAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.switchoverAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes restoreAutonomousDatabase with call error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.RestoreAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.RestoreAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.restoreAutonomousDatabase = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.restoreAutonomousDatabase(request), expectedError); - const actualRequest = (client.innerApiCalls.restoreAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes switchoverAutonomousDatabase without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.SwitchoverAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.SwitchoverAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.switchoverAutonomousDatabase = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.switchoverAutonomousDatabase( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.switchoverAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.switchoverAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes restoreAutonomousDatabase with LRO error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.RestoreAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.RestoreAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.restoreAutonomousDatabase = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.restoreAutonomousDatabase(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.restoreAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes switchoverAutonomousDatabase with call error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.SwitchoverAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.SwitchoverAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.switchoverAutonomousDatabase = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.switchoverAutonomousDatabase(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.switchoverAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.switchoverAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRestoreAutonomousDatabaseProgress without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkRestoreAutonomousDatabaseProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes switchoverAutonomousDatabase with LRO error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.SwitchoverAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.SwitchoverAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.switchoverAutonomousDatabase = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.switchoverAutonomousDatabase(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.switchoverAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.switchoverAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRestoreAutonomousDatabaseProgress with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRestoreAutonomousDatabaseProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkSwitchoverAutonomousDatabaseProgress without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkSwitchoverAutonomousDatabaseProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('stopAutonomousDatabase', () => { - it('invokes stopAutonomousDatabase without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.StopAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.StopAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.stopAutonomousDatabase = stubLongRunningCall(expectedResponse); - const [operation] = await client.stopAutonomousDatabase(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.stopAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkSwitchoverAutonomousDatabaseProgress with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkSwitchoverAutonomousDatabaseProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('failoverAutonomousDatabase', () => { + it('invokes failoverAutonomousDatabase without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.FailoverAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.FailoverAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.failoverAutonomousDatabase = + stubLongRunningCall(expectedResponse); + const [operation] = await client.failoverAutonomousDatabase(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.failoverAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.failoverAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes stopAutonomousDatabase without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.StopAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.StopAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.stopAutonomousDatabase = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.stopAutonomousDatabase( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.stopAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes failoverAutonomousDatabase without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.FailoverAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.FailoverAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.failoverAutonomousDatabase = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.failoverAutonomousDatabase( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.oracledatabase.v1.IAutonomousDatabase, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.failoverAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.failoverAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes stopAutonomousDatabase with call error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.StopAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.StopAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.stopAutonomousDatabase = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.stopAutonomousDatabase(request), expectedError); - const actualRequest = (client.innerApiCalls.stopAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes failoverAutonomousDatabase with call error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.FailoverAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.FailoverAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.failoverAutonomousDatabase = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.failoverAutonomousDatabase(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.failoverAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.failoverAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes stopAutonomousDatabase with LRO error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.StopAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.StopAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.stopAutonomousDatabase = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.stopAutonomousDatabase(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.stopAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes failoverAutonomousDatabase with LRO error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.FailoverAutonomousDatabaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.FailoverAutonomousDatabaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.failoverAutonomousDatabase = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.failoverAutonomousDatabase(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.failoverAutonomousDatabase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.failoverAutonomousDatabase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkStopAutonomousDatabaseProgress without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkStopAutonomousDatabaseProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkFailoverAutonomousDatabaseProgress without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkFailoverAutonomousDatabaseProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkStopAutonomousDatabaseProgress with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkStopAutonomousDatabaseProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkFailoverAutonomousDatabaseProgress with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkFailoverAutonomousDatabaseProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createOdbNetwork', () => { + it('invokes createOdbNetwork without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateOdbNetworkRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateOdbNetworkRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createOdbNetwork = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createOdbNetwork(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createOdbNetwork as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createOdbNetwork as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('startAutonomousDatabase', () => { - it('invokes startAutonomousDatabase without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.StartAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.StartAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.startAutonomousDatabase = stubLongRunningCall(expectedResponse); - const [operation] = await client.startAutonomousDatabase(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.startAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createOdbNetwork without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateOdbNetworkRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateOdbNetworkRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createOdbNetwork = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createOdbNetwork( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.oracledatabase.v1.IOdbNetwork, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.oracledatabase.v1.IOdbNetwork, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createOdbNetwork as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createOdbNetwork as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes startAutonomousDatabase without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.StartAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.StartAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.startAutonomousDatabase = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.startAutonomousDatabase( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.startAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createOdbNetwork with call error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateOdbNetworkRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateOdbNetworkRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createOdbNetwork = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createOdbNetwork(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createOdbNetwork as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createOdbNetwork as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes startAutonomousDatabase with call error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.StartAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.StartAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.startAutonomousDatabase = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.startAutonomousDatabase(request), expectedError); - const actualRequest = (client.innerApiCalls.startAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createOdbNetwork with LRO error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateOdbNetworkRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateOdbNetworkRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createOdbNetwork = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createOdbNetwork(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createOdbNetwork as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createOdbNetwork as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes startAutonomousDatabase with LRO error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.StartAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.StartAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.startAutonomousDatabase = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.startAutonomousDatabase(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.startAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateOdbNetworkProgress without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateOdbNetworkProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkStartAutonomousDatabaseProgress without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkStartAutonomousDatabaseProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkCreateOdbNetworkProgress with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateOdbNetworkProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteOdbNetwork', () => { + it('invokes deleteOdbNetwork without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteOdbNetworkRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteOdbNetworkRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteOdbNetwork = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteOdbNetwork(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteOdbNetwork as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteOdbNetwork as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkStartAutonomousDatabaseProgress with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkStartAutonomousDatabaseProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteOdbNetwork without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteOdbNetworkRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteOdbNetworkRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteOdbNetwork = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteOdbNetwork( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteOdbNetwork as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteOdbNetwork as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('restartAutonomousDatabase', () => { - it('invokes restartAutonomousDatabase without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.RestartAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.RestartAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.restartAutonomousDatabase = stubLongRunningCall(expectedResponse); - const [operation] = await client.restartAutonomousDatabase(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.restartAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restartAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteOdbNetwork with call error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteOdbNetworkRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteOdbNetworkRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteOdbNetwork = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteOdbNetwork(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteOdbNetwork as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteOdbNetwork as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes restartAutonomousDatabase without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.RestartAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.RestartAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.restartAutonomousDatabase = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.restartAutonomousDatabase( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.restartAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restartAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteOdbNetwork with LRO error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteOdbNetworkRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteOdbNetworkRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteOdbNetwork = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteOdbNetwork(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteOdbNetwork as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteOdbNetwork as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes restartAutonomousDatabase with call error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.RestartAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.RestartAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.restartAutonomousDatabase = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.restartAutonomousDatabase(request), expectedError); - const actualRequest = (client.innerApiCalls.restartAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restartAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteOdbNetworkProgress without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteOdbNetworkProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes restartAutonomousDatabase with LRO error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.RestartAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.RestartAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.restartAutonomousDatabase = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.restartAutonomousDatabase(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.restartAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restartAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteOdbNetworkProgress with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteOdbNetworkProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createOdbSubnet', () => { + it('invokes createOdbSubnet without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateOdbSubnetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateOdbSubnetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createOdbSubnet = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createOdbSubnet(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createOdbSubnet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createOdbSubnet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRestartAutonomousDatabaseProgress without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkRestartAutonomousDatabaseProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createOdbSubnet without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateOdbSubnetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateOdbSubnetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createOdbSubnet = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createOdbSubnet( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.oracledatabase.v1.IOdbSubnet, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.oracledatabase.v1.IOdbSubnet, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createOdbSubnet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createOdbSubnet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRestartAutonomousDatabaseProgress with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRestartAutonomousDatabaseProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createOdbSubnet with call error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateOdbSubnetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateOdbSubnetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createOdbSubnet = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createOdbSubnet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createOdbSubnet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createOdbSubnet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('switchoverAutonomousDatabase', () => { - it('invokes switchoverAutonomousDatabase without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.SwitchoverAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.SwitchoverAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.switchoverAutonomousDatabase = stubLongRunningCall(expectedResponse); - const [operation] = await client.switchoverAutonomousDatabase(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.switchoverAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.switchoverAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createOdbSubnet with LRO error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateOdbSubnetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateOdbSubnetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createOdbSubnet = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createOdbSubnet(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createOdbSubnet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createOdbSubnet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes switchoverAutonomousDatabase without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.SwitchoverAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.SwitchoverAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.switchoverAutonomousDatabase = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.switchoverAutonomousDatabase( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.switchoverAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.switchoverAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateOdbSubnetProgress without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateOdbSubnetProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes switchoverAutonomousDatabase with call error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.SwitchoverAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.SwitchoverAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.switchoverAutonomousDatabase = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.switchoverAutonomousDatabase(request), expectedError); - const actualRequest = (client.innerApiCalls.switchoverAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.switchoverAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateOdbSubnetProgress with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateOdbSubnetProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteOdbSubnet', () => { + it('invokes deleteOdbSubnet without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteOdbSubnetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteOdbSubnetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteOdbSubnet = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteOdbSubnet(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteOdbSubnet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteOdbSubnet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes switchoverAutonomousDatabase with LRO error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.SwitchoverAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.SwitchoverAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.switchoverAutonomousDatabase = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.switchoverAutonomousDatabase(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.switchoverAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.switchoverAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteOdbSubnet without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteOdbSubnetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteOdbSubnetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteOdbSubnet = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteOdbSubnet( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteOdbSubnet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteOdbSubnet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkSwitchoverAutonomousDatabaseProgress without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkSwitchoverAutonomousDatabaseProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteOdbSubnet with call error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteOdbSubnetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteOdbSubnetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteOdbSubnet = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteOdbSubnet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteOdbSubnet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteOdbSubnet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkSwitchoverAutonomousDatabaseProgress with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkSwitchoverAutonomousDatabaseProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteOdbSubnet with LRO error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteOdbSubnetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteOdbSubnetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteOdbSubnet = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteOdbSubnet(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteOdbSubnet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteOdbSubnet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('failoverAutonomousDatabase', () => { - it('invokes failoverAutonomousDatabase without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.FailoverAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.FailoverAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.failoverAutonomousDatabase = stubLongRunningCall(expectedResponse); - const [operation] = await client.failoverAutonomousDatabase(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.failoverAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.failoverAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteOdbSubnetProgress without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteOdbSubnetProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes failoverAutonomousDatabase without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.FailoverAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.FailoverAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.failoverAutonomousDatabase = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.failoverAutonomousDatabase( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.failoverAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.failoverAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteOdbSubnetProgress with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteOdbSubnetProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createExadbVmCluster', () => { + it('invokes createExadbVmCluster without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateExadbVmClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateExadbVmClusterRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createExadbVmCluster = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createExadbVmCluster(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createExadbVmCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createExadbVmCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes failoverAutonomousDatabase with call error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.FailoverAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.FailoverAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.failoverAutonomousDatabase = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.failoverAutonomousDatabase(request), expectedError); - const actualRequest = (client.innerApiCalls.failoverAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.failoverAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createExadbVmCluster without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateExadbVmClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateExadbVmClusterRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createExadbVmCluster = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createExadbVmCluster( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createExadbVmCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createExadbVmCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes failoverAutonomousDatabase with LRO error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.FailoverAutonomousDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.FailoverAutonomousDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.failoverAutonomousDatabase = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.failoverAutonomousDatabase(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.failoverAutonomousDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.failoverAutonomousDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createExadbVmCluster with call error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateExadbVmClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateExadbVmClusterRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createExadbVmCluster = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createExadbVmCluster(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createExadbVmCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createExadbVmCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkFailoverAutonomousDatabaseProgress without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkFailoverAutonomousDatabaseProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createExadbVmCluster with LRO error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateExadbVmClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateExadbVmClusterRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createExadbVmCluster = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createExadbVmCluster(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createExadbVmCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createExadbVmCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkFailoverAutonomousDatabaseProgress with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkFailoverAutonomousDatabaseProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateExadbVmClusterProgress without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateExadbVmClusterProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('createOdbNetwork', () => { - it('invokes createOdbNetwork without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateOdbNetworkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateOdbNetworkRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createOdbNetwork = stubLongRunningCall(expectedResponse); - const [operation] = await client.createOdbNetwork(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createOdbNetwork as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createOdbNetwork as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateExadbVmClusterProgress with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateExadbVmClusterProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteExadbVmCluster', () => { + it('invokes deleteExadbVmCluster without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteExadbVmClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteExadbVmClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteExadbVmCluster = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteExadbVmCluster(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteExadbVmCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteExadbVmCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createOdbNetwork without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateOdbNetworkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateOdbNetworkRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createOdbNetwork = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createOdbNetwork( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createOdbNetwork as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createOdbNetwork as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteExadbVmCluster without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteExadbVmClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteExadbVmClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteExadbVmCluster = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteExadbVmCluster( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteExadbVmCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteExadbVmCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createOdbNetwork with call error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateOdbNetworkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateOdbNetworkRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createOdbNetwork = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createOdbNetwork(request), expectedError); - const actualRequest = (client.innerApiCalls.createOdbNetwork as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createOdbNetwork as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteExadbVmCluster with call error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteExadbVmClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteExadbVmClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteExadbVmCluster = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteExadbVmCluster(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteExadbVmCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteExadbVmCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createOdbNetwork with LRO error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateOdbNetworkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateOdbNetworkRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createOdbNetwork = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createOdbNetwork(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createOdbNetwork as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createOdbNetwork as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteExadbVmCluster with LRO error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteExadbVmClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteExadbVmClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteExadbVmCluster = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteExadbVmCluster(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteExadbVmCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteExadbVmCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateOdbNetworkProgress without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateOdbNetworkProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkDeleteExadbVmClusterProgress without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteExadbVmClusterProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkCreateOdbNetworkProgress with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateOdbNetworkProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteExadbVmClusterProgress with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteExadbVmClusterProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateExadbVmCluster', () => { + it('invokes updateExadbVmCluster without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.UpdateExadbVmClusterRequest(), + ); + request.exadbVmCluster ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.UpdateExadbVmClusterRequest', + ['exadbVmCluster', 'name'], + ); + request.exadbVmCluster.name = defaultValue1; + const expectedHeaderRequestParams = `exadb_vm_cluster.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateExadbVmCluster = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateExadbVmCluster(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateExadbVmCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateExadbVmCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteOdbNetwork', () => { - it('invokes deleteOdbNetwork without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteOdbNetworkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteOdbNetworkRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteOdbNetwork = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteOdbNetwork(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteOdbNetwork as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteOdbNetwork as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateExadbVmCluster without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.UpdateExadbVmClusterRequest(), + ); + request.exadbVmCluster ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.UpdateExadbVmClusterRequest', + ['exadbVmCluster', 'name'], + ); + request.exadbVmCluster.name = defaultValue1; + const expectedHeaderRequestParams = `exadb_vm_cluster.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateExadbVmCluster = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateExadbVmCluster( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateExadbVmCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateExadbVmCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteOdbNetwork without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteOdbNetworkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteOdbNetworkRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteOdbNetwork = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteOdbNetwork( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteOdbNetwork as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteOdbNetwork as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateExadbVmCluster with call error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.UpdateExadbVmClusterRequest(), + ); + request.exadbVmCluster ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.UpdateExadbVmClusterRequest', + ['exadbVmCluster', 'name'], + ); + request.exadbVmCluster.name = defaultValue1; + const expectedHeaderRequestParams = `exadb_vm_cluster.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateExadbVmCluster = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateExadbVmCluster(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateExadbVmCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateExadbVmCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteOdbNetwork with call error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteOdbNetworkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteOdbNetworkRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteOdbNetwork = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteOdbNetwork(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteOdbNetwork as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteOdbNetwork as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateExadbVmCluster with LRO error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.UpdateExadbVmClusterRequest(), + ); + request.exadbVmCluster ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.UpdateExadbVmClusterRequest', + ['exadbVmCluster', 'name'], + ); + request.exadbVmCluster.name = defaultValue1; + const expectedHeaderRequestParams = `exadb_vm_cluster.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateExadbVmCluster = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateExadbVmCluster(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateExadbVmCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateExadbVmCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteOdbNetwork with LRO error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteOdbNetworkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteOdbNetworkRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteOdbNetwork = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteOdbNetwork(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteOdbNetwork as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteOdbNetwork as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateExadbVmClusterProgress without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkUpdateExadbVmClusterProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteOdbNetworkProgress without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteOdbNetworkProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateExadbVmClusterProgress with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateExadbVmClusterProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('removeVirtualMachineExadbVmCluster', () => { + it('invokes removeVirtualMachineExadbVmCluster without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.RemoveVirtualMachineExadbVmClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.RemoveVirtualMachineExadbVmClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.removeVirtualMachineExadbVmCluster = + stubLongRunningCall(expectedResponse); + const [operation] = + await client.removeVirtualMachineExadbVmCluster(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeVirtualMachineExadbVmCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeVirtualMachineExadbVmCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteOdbNetworkProgress with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteOdbNetworkProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes removeVirtualMachineExadbVmCluster without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.RemoveVirtualMachineExadbVmClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.RemoveVirtualMachineExadbVmClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.removeVirtualMachineExadbVmCluster = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeVirtualMachineExadbVmCluster( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.oracledatabase.v1.IExadbVmCluster, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeVirtualMachineExadbVmCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeVirtualMachineExadbVmCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createOdbSubnet', () => { - it('invokes createOdbSubnet without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateOdbSubnetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateOdbSubnetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createOdbSubnet = stubLongRunningCall(expectedResponse); - const [operation] = await client.createOdbSubnet(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createOdbSubnet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createOdbSubnet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes removeVirtualMachineExadbVmCluster with call error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.RemoveVirtualMachineExadbVmClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.RemoveVirtualMachineExadbVmClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeVirtualMachineExadbVmCluster = + stubLongRunningCall(undefined, expectedError); + await assert.rejects( + client.removeVirtualMachineExadbVmCluster(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.removeVirtualMachineExadbVmCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeVirtualMachineExadbVmCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createOdbSubnet without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateOdbSubnetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateOdbSubnetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createOdbSubnet = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createOdbSubnet( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createOdbSubnet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createOdbSubnet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes removeVirtualMachineExadbVmCluster with LRO error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.RemoveVirtualMachineExadbVmClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.RemoveVirtualMachineExadbVmClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeVirtualMachineExadbVmCluster = + stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = + await client.removeVirtualMachineExadbVmCluster(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.removeVirtualMachineExadbVmCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeVirtualMachineExadbVmCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createOdbSubnet with call error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateOdbSubnetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateOdbSubnetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createOdbSubnet = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createOdbSubnet(request), expectedError); - const actualRequest = (client.innerApiCalls.createOdbSubnet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createOdbSubnet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRemoveVirtualMachineExadbVmClusterProgress without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkRemoveVirtualMachineExadbVmClusterProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createOdbSubnet with LRO error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateOdbSubnetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateOdbSubnetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createOdbSubnet = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createOdbSubnet(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createOdbSubnet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createOdbSubnet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRemoveVirtualMachineExadbVmClusterProgress with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkRemoveVirtualMachineExadbVmClusterProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createExascaleDbStorageVault', () => { + it('invokes createExascaleDbStorageVault without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateExascaleDbStorageVaultRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateExascaleDbStorageVaultRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createExascaleDbStorageVault = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createExascaleDbStorageVault(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createExascaleDbStorageVault as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createExascaleDbStorageVault as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateOdbSubnetProgress without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateOdbSubnetProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createExascaleDbStorageVault without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateExascaleDbStorageVaultRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateExascaleDbStorageVaultRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createExascaleDbStorageVault = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createExascaleDbStorageVault( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createExascaleDbStorageVault as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createExascaleDbStorageVault as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateOdbSubnetProgress with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateOdbSubnetProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createExascaleDbStorageVault with call error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateExascaleDbStorageVaultRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateExascaleDbStorageVaultRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createExascaleDbStorageVault = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.createExascaleDbStorageVault(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createExascaleDbStorageVault as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createExascaleDbStorageVault as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteOdbSubnet', () => { - it('invokes deleteOdbSubnet without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteOdbSubnetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteOdbSubnetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteOdbSubnet = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteOdbSubnet(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteOdbSubnet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteOdbSubnet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createExascaleDbStorageVault with LRO error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateExascaleDbStorageVaultRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateExascaleDbStorageVaultRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createExascaleDbStorageVault = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createExascaleDbStorageVault(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createExascaleDbStorageVault as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createExascaleDbStorageVault as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteOdbSubnet without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteOdbSubnetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteOdbSubnetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteOdbSubnet = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteOdbSubnet( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteOdbSubnet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteOdbSubnet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateExascaleDbStorageVaultProgress without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateExascaleDbStorageVaultProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteOdbSubnet with call error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteOdbSubnetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteOdbSubnetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteOdbSubnet = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteOdbSubnet(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteOdbSubnet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteOdbSubnet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateExascaleDbStorageVaultProgress with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateExascaleDbStorageVaultProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteExascaleDbStorageVault', () => { + it('invokes deleteExascaleDbStorageVault without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteExascaleDbStorageVaultRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteExascaleDbStorageVaultRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteExascaleDbStorageVault = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteExascaleDbStorageVault(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteExascaleDbStorageVault as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteExascaleDbStorageVault as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteOdbSubnet with LRO error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteOdbSubnetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteOdbSubnetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteOdbSubnet = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteOdbSubnet(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteOdbSubnet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteOdbSubnet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteExascaleDbStorageVault without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteExascaleDbStorageVaultRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteExascaleDbStorageVaultRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteExascaleDbStorageVault = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteExascaleDbStorageVault( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteExascaleDbStorageVault as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteExascaleDbStorageVault as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteOdbSubnetProgress without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteOdbSubnetProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteExascaleDbStorageVault with call error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteExascaleDbStorageVaultRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteExascaleDbStorageVaultRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteExascaleDbStorageVault = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.deleteExascaleDbStorageVault(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteExascaleDbStorageVault as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteExascaleDbStorageVault as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteOdbSubnetProgress with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteOdbSubnetProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteExascaleDbStorageVault with LRO error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteExascaleDbStorageVaultRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteExascaleDbStorageVaultRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteExascaleDbStorageVault = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteExascaleDbStorageVault(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteExascaleDbStorageVault as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteExascaleDbStorageVault as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createExadbVmCluster', () => { - it('invokes createExadbVmCluster without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateExadbVmClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateExadbVmClusterRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createExadbVmCluster = stubLongRunningCall(expectedResponse); - const [operation] = await client.createExadbVmCluster(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createExadbVmCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createExadbVmCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteExascaleDbStorageVaultProgress without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteExascaleDbStorageVaultProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createExadbVmCluster without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateExadbVmClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateExadbVmClusterRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createExadbVmCluster = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createExadbVmCluster( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createExadbVmCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createExadbVmCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteExascaleDbStorageVaultProgress with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteExascaleDbStorageVaultProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createDbSystem', () => { + it('invokes createDbSystem without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateDbSystemRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateDbSystemRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createDbSystem = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createDbSystem(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createDbSystem as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDbSystem as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createExadbVmCluster with call error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateExadbVmClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateExadbVmClusterRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createExadbVmCluster = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createExadbVmCluster(request), expectedError); - const actualRequest = (client.innerApiCalls.createExadbVmCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createExadbVmCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createDbSystem without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateDbSystemRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateDbSystemRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createDbSystem = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createDbSystem( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.oracledatabase.v1.IDbSystem, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.oracledatabase.v1.IDbSystem, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createDbSystem as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDbSystem as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createExadbVmCluster with LRO error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateExadbVmClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateExadbVmClusterRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createExadbVmCluster = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createExadbVmCluster(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createExadbVmCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createExadbVmCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createDbSystem with call error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateDbSystemRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateDbSystemRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createDbSystem = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createDbSystem(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createDbSystem as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDbSystem as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateExadbVmClusterProgress without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateExadbVmClusterProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createDbSystem with LRO error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CreateDbSystemRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.CreateDbSystemRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createDbSystem = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createDbSystem(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createDbSystem as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDbSystem as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateExadbVmClusterProgress with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateExadbVmClusterProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateDbSystemProgress without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkCreateDbSystemProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('deleteExadbVmCluster', () => { - it('invokes deleteExadbVmCluster without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteExadbVmClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteExadbVmClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteExadbVmCluster = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteExadbVmCluster(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteExadbVmCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteExadbVmCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateDbSystemProgress with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateDbSystemProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteDbSystem', () => { + it('invokes deleteDbSystem without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteDbSystemRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteDbSystemRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteDbSystem = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteDbSystem(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteDbSystem as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDbSystem as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteExadbVmCluster without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteExadbVmClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteExadbVmClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteExadbVmCluster = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteExadbVmCluster( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteExadbVmCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteExadbVmCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteDbSystem without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteDbSystemRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteDbSystemRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteDbSystem = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteDbSystem( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.oracledatabase.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteDbSystem as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDbSystem as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteExadbVmCluster with call error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteExadbVmClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteExadbVmClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteExadbVmCluster = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteExadbVmCluster(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteExadbVmCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteExadbVmCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteDbSystem with call error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteDbSystemRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteDbSystemRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteDbSystem = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteDbSystem(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteDbSystem as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDbSystem as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteExadbVmCluster with LRO error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteExadbVmClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteExadbVmClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteExadbVmCluster = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteExadbVmCluster(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteExadbVmCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteExadbVmCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteDbSystem with LRO error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DeleteDbSystemRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.DeleteDbSystemRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteDbSystem = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteDbSystem(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteDbSystem as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDbSystem as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteExadbVmClusterProgress without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteExadbVmClusterProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkDeleteDbSystemProgress without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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.checkDeleteDbSystemProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteExadbVmClusterProgress with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteExadbVmClusterProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteDbSystemProgress with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteDbSystemProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listCloudExadataInfrastructures', () => { + it('invokes listCloudExadataInfrastructures without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListCloudExadataInfrastructuresRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListCloudExadataInfrastructuresRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure(), + ), + ]; + client.innerApiCalls.listCloudExadataInfrastructures = + stubSimpleCall(expectedResponse); + const [response] = await client.listCloudExadataInfrastructures(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCloudExadataInfrastructures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCloudExadataInfrastructures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateExadbVmCluster', () => { - it('invokes updateExadbVmCluster without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.UpdateExadbVmClusterRequest() - ); - request.exadbVmCluster ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.UpdateExadbVmClusterRequest', ['exadbVmCluster', 'name']); - request.exadbVmCluster.name = defaultValue1; - const expectedHeaderRequestParams = `exadb_vm_cluster.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateExadbVmCluster = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateExadbVmCluster(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateExadbVmCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateExadbVmCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listCloudExadataInfrastructures without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListCloudExadataInfrastructuresRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListCloudExadataInfrastructuresRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure(), + ), + ]; + client.innerApiCalls.listCloudExadataInfrastructures = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCloudExadataInfrastructures( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCloudExadataInfrastructures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCloudExadataInfrastructures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateExadbVmCluster without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.UpdateExadbVmClusterRequest() - ); - request.exadbVmCluster ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.UpdateExadbVmClusterRequest', ['exadbVmCluster', 'name']); - request.exadbVmCluster.name = defaultValue1; - const expectedHeaderRequestParams = `exadb_vm_cluster.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateExadbVmCluster = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateExadbVmCluster( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateExadbVmCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateExadbVmCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listCloudExadataInfrastructures with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListCloudExadataInfrastructuresRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListCloudExadataInfrastructuresRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listCloudExadataInfrastructures = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listCloudExadataInfrastructures(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listCloudExadataInfrastructures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCloudExadataInfrastructures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateExadbVmCluster with call error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.UpdateExadbVmClusterRequest() - ); - request.exadbVmCluster ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.UpdateExadbVmClusterRequest', ['exadbVmCluster', 'name']); - request.exadbVmCluster.name = defaultValue1; - const expectedHeaderRequestParams = `exadb_vm_cluster.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateExadbVmCluster = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateExadbVmCluster(request), expectedError); - const actualRequest = (client.innerApiCalls.updateExadbVmCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateExadbVmCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listCloudExadataInfrastructuresStream without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListCloudExadataInfrastructuresRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListCloudExadataInfrastructuresRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure(), + ), + ]; + client.descriptors.page.listCloudExadataInfrastructures.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listCloudExadataInfrastructuresStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listCloudExadataInfrastructures + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listCloudExadataInfrastructures, + request, + ), + ); + assert( + ( + client.descriptors.page.listCloudExadataInfrastructures + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes updateExadbVmCluster with LRO error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.UpdateExadbVmClusterRequest() - ); - request.exadbVmCluster ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.UpdateExadbVmClusterRequest', ['exadbVmCluster', 'name']); - request.exadbVmCluster.name = defaultValue1; - const expectedHeaderRequestParams = `exadb_vm_cluster.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateExadbVmCluster = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateExadbVmCluster(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateExadbVmCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateExadbVmCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listCloudExadataInfrastructuresStream with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListCloudExadataInfrastructuresRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListCloudExadataInfrastructuresRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCloudExadataInfrastructures.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listCloudExadataInfrastructuresStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listCloudExadataInfrastructures + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listCloudExadataInfrastructures, + request, + ), + ); + assert( + ( + client.descriptors.page.listCloudExadataInfrastructures + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes checkUpdateExadbVmClusterProgress without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkUpdateExadbVmClusterProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('uses async iteration with listCloudExadataInfrastructures without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListCloudExadataInfrastructuresRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListCloudExadataInfrastructuresRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure(), + ), + ]; + client.descriptors.page.listCloudExadataInfrastructures.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure[] = + []; + const iterable = client.listCloudExadataInfrastructuresAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listCloudExadataInfrastructures + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listCloudExadataInfrastructures + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes checkUpdateExadbVmClusterProgress with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateExadbVmClusterProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('uses async iteration with listCloudExadataInfrastructures with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListCloudExadataInfrastructuresRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListCloudExadataInfrastructuresRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCloudExadataInfrastructures.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCloudExadataInfrastructuresAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listCloudExadataInfrastructures + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listCloudExadataInfrastructures + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('listCloudVmClusters', () => { + it('invokes listCloudVmClusters without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListCloudVmClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListCloudVmClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CloudVmCluster(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CloudVmCluster(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CloudVmCluster(), + ), + ]; + client.innerApiCalls.listCloudVmClusters = + stubSimpleCall(expectedResponse); + const [response] = await client.listCloudVmClusters(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCloudVmClusters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCloudVmClusters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('removeVirtualMachineExadbVmCluster', () => { - it('invokes removeVirtualMachineExadbVmCluster without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.RemoveVirtualMachineExadbVmClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.RemoveVirtualMachineExadbVmClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.removeVirtualMachineExadbVmCluster = stubLongRunningCall(expectedResponse); - const [operation] = await client.removeVirtualMachineExadbVmCluster(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.removeVirtualMachineExadbVmCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeVirtualMachineExadbVmCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listCloudVmClusters without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListCloudVmClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListCloudVmClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CloudVmCluster(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CloudVmCluster(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CloudVmCluster(), + ), + ]; + client.innerApiCalls.listCloudVmClusters = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCloudVmClusters( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.oracledatabase.v1.ICloudVmCluster[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCloudVmClusters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCloudVmClusters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes removeVirtualMachineExadbVmCluster without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.RemoveVirtualMachineExadbVmClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.RemoveVirtualMachineExadbVmClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.removeVirtualMachineExadbVmCluster = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeVirtualMachineExadbVmCluster( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.removeVirtualMachineExadbVmCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeVirtualMachineExadbVmCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listCloudVmClusters with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListCloudVmClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListCloudVmClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listCloudVmClusters = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listCloudVmClusters(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listCloudVmClusters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCloudVmClusters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes removeVirtualMachineExadbVmCluster with call error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.RemoveVirtualMachineExadbVmClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.RemoveVirtualMachineExadbVmClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.removeVirtualMachineExadbVmCluster = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.removeVirtualMachineExadbVmCluster(request), expectedError); - const actualRequest = (client.innerApiCalls.removeVirtualMachineExadbVmCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeVirtualMachineExadbVmCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listCloudVmClustersStream without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListCloudVmClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListCloudVmClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CloudVmCluster(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CloudVmCluster(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CloudVmCluster(), + ), + ]; + client.descriptors.page.listCloudVmClusters.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listCloudVmClustersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.CloudVmCluster[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.oracledatabase.v1.CloudVmCluster) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listCloudVmClusters.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCloudVmClusters, request), + ); + assert( + (client.descriptors.page.listCloudVmClusters.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes removeVirtualMachineExadbVmCluster with LRO error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.RemoveVirtualMachineExadbVmClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.RemoveVirtualMachineExadbVmClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.removeVirtualMachineExadbVmCluster = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.removeVirtualMachineExadbVmCluster(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.removeVirtualMachineExadbVmCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeVirtualMachineExadbVmCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listCloudVmClustersStream with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListCloudVmClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListCloudVmClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCloudVmClusters.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listCloudVmClustersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.CloudVmCluster[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.oracledatabase.v1.CloudVmCluster) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listCloudVmClusters.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCloudVmClusters, request), + ); + assert( + (client.descriptors.page.listCloudVmClusters.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes checkRemoveVirtualMachineExadbVmClusterProgress without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkRemoveVirtualMachineExadbVmClusterProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('uses async iteration with listCloudVmClusters without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListCloudVmClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListCloudVmClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CloudVmCluster(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CloudVmCluster(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.CloudVmCluster(), + ), + ]; + client.descriptors.page.listCloudVmClusters.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.oracledatabase.v1.ICloudVmCluster[] = + []; + const iterable = client.listCloudVmClustersAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listCloudVmClusters.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listCloudVmClusters.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes checkRemoveVirtualMachineExadbVmClusterProgress with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRemoveVirtualMachineExadbVmClusterProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('uses async iteration with listCloudVmClusters with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListCloudVmClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListCloudVmClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCloudVmClusters.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCloudVmClustersAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.oracledatabase.v1.ICloudVmCluster[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listCloudVmClusters.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listCloudVmClusters.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listEntitlements', () => { + it('invokes listEntitlements without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListEntitlementsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListEntitlementsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.Entitlement(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.Entitlement(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.Entitlement(), + ), + ]; + client.innerApiCalls.listEntitlements = stubSimpleCall(expectedResponse); + const [response] = await client.listEntitlements(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listEntitlements as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEntitlements as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createExascaleDbStorageVault', () => { - it('invokes createExascaleDbStorageVault without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateExascaleDbStorageVaultRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateExascaleDbStorageVaultRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createExascaleDbStorageVault = stubLongRunningCall(expectedResponse); - const [operation] = await client.createExascaleDbStorageVault(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createExascaleDbStorageVault as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createExascaleDbStorageVault as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listEntitlements without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListEntitlementsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListEntitlementsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.Entitlement(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.Entitlement(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.Entitlement(), + ), + ]; + client.innerApiCalls.listEntitlements = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listEntitlements( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.oracledatabase.v1.IEntitlement[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listEntitlements as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEntitlements as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createExascaleDbStorageVault without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateExascaleDbStorageVaultRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateExascaleDbStorageVaultRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createExascaleDbStorageVault = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createExascaleDbStorageVault( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createExascaleDbStorageVault as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createExascaleDbStorageVault as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listEntitlements with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListEntitlementsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListEntitlementsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listEntitlements = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listEntitlements(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listEntitlements as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEntitlements as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createExascaleDbStorageVault with call error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateExascaleDbStorageVaultRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateExascaleDbStorageVaultRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createExascaleDbStorageVault = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createExascaleDbStorageVault(request), expectedError); - const actualRequest = (client.innerApiCalls.createExascaleDbStorageVault as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createExascaleDbStorageVault as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listEntitlementsStream without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListEntitlementsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListEntitlementsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.Entitlement(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.Entitlement(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.Entitlement(), + ), + ]; + client.descriptors.page.listEntitlements.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listEntitlementsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.Entitlement[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.oracledatabase.v1.Entitlement) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listEntitlements.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listEntitlements, request), + ); + assert( + (client.descriptors.page.listEntitlements.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes createExascaleDbStorageVault with LRO error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateExascaleDbStorageVaultRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateExascaleDbStorageVaultRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createExascaleDbStorageVault = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createExascaleDbStorageVault(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createExascaleDbStorageVault as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createExascaleDbStorageVault as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listEntitlementsStream with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListEntitlementsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListEntitlementsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listEntitlements.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listEntitlementsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.Entitlement[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.oracledatabase.v1.Entitlement) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listEntitlements.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listEntitlements, request), + ); + assert( + (client.descriptors.page.listEntitlements.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes checkCreateExascaleDbStorageVaultProgress without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateExascaleDbStorageVaultProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('uses async iteration with listEntitlements without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListEntitlementsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListEntitlementsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.Entitlement(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.Entitlement(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.Entitlement(), + ), + ]; + client.descriptors.page.listEntitlements.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.oracledatabase.v1.IEntitlement[] = + []; + const iterable = client.listEntitlementsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listEntitlements.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listEntitlements.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes checkCreateExascaleDbStorageVaultProgress with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateExascaleDbStorageVaultProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('uses async iteration with listEntitlements with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListEntitlementsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListEntitlementsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listEntitlements.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listEntitlementsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.oracledatabase.v1.IEntitlement[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listEntitlements.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listEntitlements.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listDbServers', () => { + it('invokes listDbServers without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbServersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbServersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbServer(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbServer(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbServer(), + ), + ]; + client.innerApiCalls.listDbServers = stubSimpleCall(expectedResponse); + const [response] = await client.listDbServers(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDbServers as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDbServers as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteExascaleDbStorageVault', () => { - it('invokes deleteExascaleDbStorageVault without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteExascaleDbStorageVaultRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteExascaleDbStorageVaultRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteExascaleDbStorageVault = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteExascaleDbStorageVault(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteExascaleDbStorageVault as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteExascaleDbStorageVault as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listDbServers without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbServersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbServersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbServer(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbServer(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbServer(), + ), + ]; + client.innerApiCalls.listDbServers = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listDbServers( + request, + ( + err?: Error | null, + result?: protos.google.cloud.oracledatabase.v1.IDbServer[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDbServers as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDbServers as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteExascaleDbStorageVault without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteExascaleDbStorageVaultRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteExascaleDbStorageVaultRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteExascaleDbStorageVault = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteExascaleDbStorageVault( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteExascaleDbStorageVault as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteExascaleDbStorageVault as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listDbServers with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbServersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbServersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listDbServers = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listDbServers(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listDbServers as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDbServers as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteExascaleDbStorageVault with call error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteExascaleDbStorageVaultRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteExascaleDbStorageVaultRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteExascaleDbStorageVault = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteExascaleDbStorageVault(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteExascaleDbStorageVault as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteExascaleDbStorageVault as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listDbServersStream without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbServersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbServersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbServer(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbServer(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbServer(), + ), + ]; + client.descriptors.page.listDbServers.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listDbServersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.DbServer[] = []; + stream.on( + 'data', + (response: protos.google.cloud.oracledatabase.v1.DbServer) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listDbServers.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listDbServers, request), + ); + assert( + (client.descriptors.page.listDbServers.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes deleteExascaleDbStorageVault with LRO error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteExascaleDbStorageVaultRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteExascaleDbStorageVaultRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteExascaleDbStorageVault = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteExascaleDbStorageVault(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteExascaleDbStorageVault as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteExascaleDbStorageVault as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listDbServersStream with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbServersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbServersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDbServers.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listDbServersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.DbServer[] = []; + stream.on( + 'data', + (response: protos.google.cloud.oracledatabase.v1.DbServer) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listDbServers.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listDbServers, request), + ); + assert( + (client.descriptors.page.listDbServers.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes checkDeleteExascaleDbStorageVaultProgress without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteExascaleDbStorageVaultProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('uses async iteration with listDbServers without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbServersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbServersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbServer(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbServer(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbServer(), + ), + ]; + client.descriptors.page.listDbServers.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.oracledatabase.v1.IDbServer[] = []; + const iterable = client.listDbServersAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listDbServers.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listDbServers.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes checkDeleteExascaleDbStorageVaultProgress with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteExascaleDbStorageVaultProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('uses async iteration with listDbServers with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbServersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbServersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDbServers.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listDbServersAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.oracledatabase.v1.IDbServer[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listDbServers.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listDbServers.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listDbNodes', () => { + it('invokes listDbNodes without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbNodesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbNodesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbNode(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbNode(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbNode(), + ), + ]; + client.innerApiCalls.listDbNodes = stubSimpleCall(expectedResponse); + const [response] = await client.listDbNodes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDbNodes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDbNodes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createDbSystem', () => { - it('invokes createDbSystem without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateDbSystemRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateDbSystemRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createDbSystem = stubLongRunningCall(expectedResponse); - const [operation] = await client.createDbSystem(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createDbSystem as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDbSystem as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listDbNodes without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbNodesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbNodesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbNode(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbNode(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbNode(), + ), + ]; + client.innerApiCalls.listDbNodes = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listDbNodes( + request, + ( + err?: Error | null, + result?: protos.google.cloud.oracledatabase.v1.IDbNode[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDbNodes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDbNodes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createDbSystem without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateDbSystemRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateDbSystemRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createDbSystem = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createDbSystem( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createDbSystem as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDbSystem as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listDbNodes with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbNodesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbNodesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listDbNodes = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listDbNodes(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listDbNodes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDbNodes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createDbSystem with call error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateDbSystemRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateDbSystemRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createDbSystem = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createDbSystem(request), expectedError); - const actualRequest = (client.innerApiCalls.createDbSystem as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDbSystem as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listDbNodesStream without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbNodesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbNodesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbNode(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbNode(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbNode(), + ), + ]; + client.descriptors.page.listDbNodes.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listDbNodesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.DbNode[] = []; + stream.on( + 'data', + (response: protos.google.cloud.oracledatabase.v1.DbNode) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listDbNodes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listDbNodes, request), + ); + assert( + (client.descriptors.page.listDbNodes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes createDbSystem with LRO error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.CreateDbSystemRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.CreateDbSystemRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createDbSystem = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createDbSystem(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createDbSystem as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDbSystem as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listDbNodesStream with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbNodesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbNodesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDbNodes.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listDbNodesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.DbNode[] = []; + stream.on( + 'data', + (response: protos.google.cloud.oracledatabase.v1.DbNode) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listDbNodes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listDbNodes, request), + ); + assert( + (client.descriptors.page.listDbNodes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes checkCreateDbSystemProgress without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkCreateDbSystemProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('uses async iteration with listDbNodes without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbNodesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbNodesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbNode(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbNode(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbNode(), + ), + ]; + client.descriptors.page.listDbNodes.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.oracledatabase.v1.IDbNode[] = []; + const iterable = client.listDbNodesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listDbNodes.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listDbNodes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes checkCreateDbSystemProgress with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateDbSystemProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('uses async iteration with listDbNodes with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbNodesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbNodesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDbNodes.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listDbNodesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.oracledatabase.v1.IDbNode[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listDbNodes.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listDbNodes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listGiVersions', () => { + it('invokes listGiVersions without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListGiVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListGiVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GiVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GiVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GiVersion(), + ), + ]; + client.innerApiCalls.listGiVersions = stubSimpleCall(expectedResponse); + const [response] = await client.listGiVersions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listGiVersions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listGiVersions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteDbSystem', () => { - it('invokes deleteDbSystem without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteDbSystemRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteDbSystemRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteDbSystem = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteDbSystem(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteDbSystem as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDbSystem as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listGiVersions without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListGiVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListGiVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GiVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GiVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GiVersion(), + ), + ]; + client.innerApiCalls.listGiVersions = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listGiVersions( + request, + ( + err?: Error | null, + result?: protos.google.cloud.oracledatabase.v1.IGiVersion[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listGiVersions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listGiVersions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteDbSystem without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteDbSystemRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteDbSystemRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteDbSystem = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteDbSystem( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteDbSystem as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDbSystem as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listGiVersions with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListGiVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListGiVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listGiVersions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listGiVersions(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listGiVersions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listGiVersions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteDbSystem with call error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteDbSystemRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteDbSystemRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteDbSystem = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteDbSystem(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteDbSystem as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDbSystem as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listGiVersionsStream without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListGiVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListGiVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GiVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GiVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GiVersion(), + ), + ]; + client.descriptors.page.listGiVersions.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listGiVersionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.GiVersion[] = []; + stream.on( + 'data', + (response: protos.google.cloud.oracledatabase.v1.GiVersion) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listGiVersions.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listGiVersions, request), + ); + assert( + (client.descriptors.page.listGiVersions.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes deleteDbSystem with LRO error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.DeleteDbSystemRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.DeleteDbSystemRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteDbSystem = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteDbSystem(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteDbSystem as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDbSystem as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listGiVersionsStream with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListGiVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListGiVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listGiVersions.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listGiVersionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.GiVersion[] = []; + stream.on( + 'data', + (response: protos.google.cloud.oracledatabase.v1.GiVersion) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listGiVersions.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listGiVersions, request), + ); + assert( + (client.descriptors.page.listGiVersions.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes checkDeleteDbSystemProgress without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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.checkDeleteDbSystemProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('uses async iteration with listGiVersions without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListGiVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListGiVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GiVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GiVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.GiVersion(), + ), + ]; + client.descriptors.page.listGiVersions.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.oracledatabase.v1.IGiVersion[] = []; + const iterable = client.listGiVersionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listGiVersions.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listGiVersions.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes checkDeleteDbSystemProgress with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteDbSystemProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('uses async iteration with listGiVersions with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListGiVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListGiVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listGiVersions.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listGiVersionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.oracledatabase.v1.IGiVersion[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listGiVersions.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listGiVersions.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listMinorVersions', () => { + it('invokes listMinorVersions without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListMinorVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListMinorVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.MinorVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.MinorVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.MinorVersion(), + ), + ]; + client.innerApiCalls.listMinorVersions = stubSimpleCall(expectedResponse); + const [response] = await client.listMinorVersions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listMinorVersions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMinorVersions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listCloudExadataInfrastructures', () => { - it('invokes listCloudExadataInfrastructures without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListCloudExadataInfrastructuresRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListCloudExadataInfrastructuresRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure()), - ]; - client.innerApiCalls.listCloudExadataInfrastructures = stubSimpleCall(expectedResponse); - const [response] = await client.listCloudExadataInfrastructures(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCloudExadataInfrastructures as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCloudExadataInfrastructures as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listMinorVersions without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListMinorVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListMinorVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.MinorVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.MinorVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.MinorVersion(), + ), + ]; + client.innerApiCalls.listMinorVersions = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listMinorVersions( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.oracledatabase.v1.IMinorVersion[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listMinorVersions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMinorVersions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listCloudExadataInfrastructures without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListCloudExadataInfrastructuresRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListCloudExadataInfrastructuresRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure()), - ]; - client.innerApiCalls.listCloudExadataInfrastructures = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listCloudExadataInfrastructures( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCloudExadataInfrastructures as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCloudExadataInfrastructures as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listMinorVersions with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListMinorVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListMinorVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listMinorVersions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listMinorVersions(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listMinorVersions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMinorVersions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listCloudExadataInfrastructures with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListCloudExadataInfrastructuresRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListCloudExadataInfrastructuresRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listCloudExadataInfrastructures = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCloudExadataInfrastructures(request), expectedError); - const actualRequest = (client.innerApiCalls.listCloudExadataInfrastructures as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCloudExadataInfrastructures as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listMinorVersionsStream without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListMinorVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListMinorVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.MinorVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.MinorVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.MinorVersion(), + ), + ]; + client.descriptors.page.listMinorVersions.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listMinorVersionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.MinorVersion[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.oracledatabase.v1.MinorVersion) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listMinorVersions.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listMinorVersions, request), + ); + assert( + (client.descriptors.page.listMinorVersions.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listCloudExadataInfrastructuresStream without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListCloudExadataInfrastructuresRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListCloudExadataInfrastructuresRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure()), - ]; - client.descriptors.page.listCloudExadataInfrastructures.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listCloudExadataInfrastructuresStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listCloudExadataInfrastructures.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCloudExadataInfrastructures, request)); - assert( - (client.descriptors.page.listCloudExadataInfrastructures.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listMinorVersionsStream with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListMinorVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListMinorVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMinorVersions.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listMinorVersionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.MinorVersion[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.oracledatabase.v1.MinorVersion) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listMinorVersions.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listMinorVersions, request), + ); + assert( + (client.descriptors.page.listMinorVersions.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listCloudExadataInfrastructuresStream with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListCloudExadataInfrastructuresRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListCloudExadataInfrastructuresRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listCloudExadataInfrastructures.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listCloudExadataInfrastructuresStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listCloudExadataInfrastructures.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCloudExadataInfrastructures, request)); - assert( - (client.descriptors.page.listCloudExadataInfrastructures.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listMinorVersions without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListMinorVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListMinorVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.MinorVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.MinorVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.MinorVersion(), + ), + ]; + client.descriptors.page.listMinorVersions.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.oracledatabase.v1.IMinorVersion[] = + []; + const iterable = client.listMinorVersionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listMinorVersions.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listMinorVersions.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listCloudExadataInfrastructures without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListCloudExadataInfrastructuresRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListCloudExadataInfrastructuresRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.CloudExadataInfrastructure()), - ]; - client.descriptors.page.listCloudExadataInfrastructures.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure[] = []; - const iterable = client.listCloudExadataInfrastructuresAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listCloudExadataInfrastructures.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCloudExadataInfrastructures.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listMinorVersions with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListMinorVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListMinorVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMinorVersions.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listMinorVersionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.oracledatabase.v1.IMinorVersion[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listMinorVersions.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listMinorVersions.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listDbSystemShapes', () => { + it('invokes listDbSystemShapes without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbSystemShapesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbSystemShapesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystemShape(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystemShape(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystemShape(), + ), + ]; + client.innerApiCalls.listDbSystemShapes = + stubSimpleCall(expectedResponse); + const [response] = await client.listDbSystemShapes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDbSystemShapes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDbSystemShapes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listCloudExadataInfrastructures with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListCloudExadataInfrastructuresRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListCloudExadataInfrastructuresRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listCloudExadataInfrastructures.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listCloudExadataInfrastructuresAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.oracledatabase.v1.ICloudExadataInfrastructure[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listCloudExadataInfrastructures.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCloudExadataInfrastructures.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listDbSystemShapes without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbSystemShapesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbSystemShapesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystemShape(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystemShape(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystemShape(), + ), + ]; + client.innerApiCalls.listDbSystemShapes = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listDbSystemShapes( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.oracledatabase.v1.IDbSystemShape[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDbSystemShapes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDbSystemShapes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listCloudVmClusters', () => { - it('invokes listCloudVmClusters without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListCloudVmClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListCloudVmClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.CloudVmCluster()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.CloudVmCluster()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.CloudVmCluster()), - ]; - client.innerApiCalls.listCloudVmClusters = stubSimpleCall(expectedResponse); - const [response] = await client.listCloudVmClusters(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCloudVmClusters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCloudVmClusters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listDbSystemShapes with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbSystemShapesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbSystemShapesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listDbSystemShapes = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listDbSystemShapes(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listDbSystemShapes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDbSystemShapes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listCloudVmClusters without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListCloudVmClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListCloudVmClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.CloudVmCluster()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.CloudVmCluster()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.CloudVmCluster()), - ]; - client.innerApiCalls.listCloudVmClusters = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listCloudVmClusters( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.ICloudVmCluster[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCloudVmClusters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCloudVmClusters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listDbSystemShapesStream without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbSystemShapesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbSystemShapesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystemShape(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystemShape(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystemShape(), + ), + ]; + client.descriptors.page.listDbSystemShapes.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listDbSystemShapesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.DbSystemShape[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.oracledatabase.v1.DbSystemShape) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listDbSystemShapes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listDbSystemShapes, request), + ); + assert( + (client.descriptors.page.listDbSystemShapes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listCloudVmClusters with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListCloudVmClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListCloudVmClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listCloudVmClusters = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCloudVmClusters(request), expectedError); - const actualRequest = (client.innerApiCalls.listCloudVmClusters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCloudVmClusters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listDbSystemShapesStream with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbSystemShapesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbSystemShapesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDbSystemShapes.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listDbSystemShapesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.DbSystemShape[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.oracledatabase.v1.DbSystemShape) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listDbSystemShapes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listDbSystemShapes, request), + ); + assert( + (client.descriptors.page.listDbSystemShapes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listCloudVmClustersStream without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListCloudVmClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListCloudVmClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.CloudVmCluster()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.CloudVmCluster()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.CloudVmCluster()), - ]; - client.descriptors.page.listCloudVmClusters.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listCloudVmClustersStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.CloudVmCluster[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.CloudVmCluster) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listCloudVmClusters.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCloudVmClusters, request)); - assert( - (client.descriptors.page.listCloudVmClusters.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listDbSystemShapes without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbSystemShapesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbSystemShapesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystemShape(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystemShape(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystemShape(), + ), + ]; + client.descriptors.page.listDbSystemShapes.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.oracledatabase.v1.IDbSystemShape[] = + []; + const iterable = client.listDbSystemShapesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listDbSystemShapes.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listDbSystemShapes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listCloudVmClustersStream with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListCloudVmClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListCloudVmClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listCloudVmClusters.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listCloudVmClustersStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.CloudVmCluster[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.CloudVmCluster) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listCloudVmClusters.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCloudVmClusters, request)); - assert( - (client.descriptors.page.listCloudVmClusters.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listDbSystemShapes with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbSystemShapesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbSystemShapesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDbSystemShapes.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listDbSystemShapesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.oracledatabase.v1.IDbSystemShape[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listDbSystemShapes.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listDbSystemShapes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listAutonomousDatabases', () => { + it('invokes listAutonomousDatabases without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListAutonomousDatabasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabase(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabase(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabase(), + ), + ]; + client.innerApiCalls.listAutonomousDatabases = + stubSimpleCall(expectedResponse); + const [response] = await client.listAutonomousDatabases(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listAutonomousDatabases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAutonomousDatabases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listCloudVmClusters without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListCloudVmClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListCloudVmClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.CloudVmCluster()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.CloudVmCluster()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.CloudVmCluster()), - ]; - client.descriptors.page.listCloudVmClusters.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.oracledatabase.v1.ICloudVmCluster[] = []; - const iterable = client.listCloudVmClustersAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listAutonomousDatabases without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListAutonomousDatabasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabase(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabase(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabase(), + ), + ]; + client.innerApiCalls.listAutonomousDatabases = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listAutonomousDatabases( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.oracledatabase.v1.IAutonomousDatabase[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listCloudVmClusters.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCloudVmClusters.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listAutonomousDatabases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAutonomousDatabases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listCloudVmClusters with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListCloudVmClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListCloudVmClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listCloudVmClusters.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listCloudVmClustersAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.oracledatabase.v1.ICloudVmCluster[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listCloudVmClusters.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCloudVmClusters.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listAutonomousDatabases with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListAutonomousDatabasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listAutonomousDatabases = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listAutonomousDatabases(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listAutonomousDatabases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAutonomousDatabases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listEntitlements', () => { - it('invokes listEntitlements without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListEntitlementsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListEntitlementsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.Entitlement()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.Entitlement()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.Entitlement()), - ]; - client.innerApiCalls.listEntitlements = stubSimpleCall(expectedResponse); - const [response] = await client.listEntitlements(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEntitlements as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEntitlements as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listAutonomousDatabasesStream without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListAutonomousDatabasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabase(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabase(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabase(), + ), + ]; + client.descriptors.page.listAutonomousDatabases.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listAutonomousDatabasesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.AutonomousDatabase[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.oracledatabase.v1.AutonomousDatabase, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listAutonomousDatabases + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listAutonomousDatabases, request), + ); + assert( + ( + client.descriptors.page.listAutonomousDatabases + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listEntitlements without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListEntitlementsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListEntitlementsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.Entitlement()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.Entitlement()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.Entitlement()), - ]; - client.innerApiCalls.listEntitlements = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listEntitlements( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.IEntitlement[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEntitlements as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEntitlements as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEntitlements with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListEntitlementsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListEntitlementsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listEntitlements = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listEntitlements(request), expectedError); - const actualRequest = (client.innerApiCalls.listEntitlements as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEntitlements as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEntitlementsStream without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListEntitlementsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListEntitlementsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.Entitlement()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.Entitlement()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.Entitlement()), - ]; - client.descriptors.page.listEntitlements.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listEntitlementsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.Entitlement[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.Entitlement) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listEntitlements.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listEntitlements, request)); - assert( - (client.descriptors.page.listEntitlements.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listEntitlementsStream with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListEntitlementsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListEntitlementsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listEntitlements.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listEntitlementsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.Entitlement[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.Entitlement) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listEntitlements.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listEntitlements, request)); - assert( - (client.descriptors.page.listEntitlements.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listEntitlements without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListEntitlementsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListEntitlementsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.Entitlement()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.Entitlement()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.Entitlement()), - ]; - client.descriptors.page.listEntitlements.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.oracledatabase.v1.IEntitlement[] = []; - const iterable = client.listEntitlementsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listEntitlements.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listEntitlements.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listEntitlements with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListEntitlementsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListEntitlementsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listEntitlements.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listEntitlementsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.oracledatabase.v1.IEntitlement[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listEntitlements.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listEntitlements.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listAutonomousDatabasesStream with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListAutonomousDatabasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listAutonomousDatabases.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listAutonomousDatabasesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.AutonomousDatabase[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.oracledatabase.v1.AutonomousDatabase, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listAutonomousDatabases + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listAutonomousDatabases, request), + ); + assert( + ( + client.descriptors.page.listAutonomousDatabases + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - describe('listDbServers', () => { - it('invokes listDbServers without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbServersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbServersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbServer()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbServer()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbServer()), - ]; - client.innerApiCalls.listDbServers = stubSimpleCall(expectedResponse); - const [response] = await client.listDbServers(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDbServers as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDbServers as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDbServers without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbServersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbServersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbServer()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbServer()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbServer()), - ]; - client.innerApiCalls.listDbServers = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listDbServers( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.IDbServer[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDbServers as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDbServers as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDbServers with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbServersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbServersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listDbServers = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDbServers(request), expectedError); - const actualRequest = (client.innerApiCalls.listDbServers as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDbServers as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDbServersStream without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbServersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbServersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbServer()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbServer()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbServer()), - ]; - client.descriptors.page.listDbServers.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listDbServersStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.DbServer[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.DbServer) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listDbServers.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDbServers, request)); - assert( - (client.descriptors.page.listDbServers.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listDbServersStream with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbServersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbServersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listDbServers.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listDbServersStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.DbServer[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.DbServer) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listDbServers.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDbServers, request)); - assert( - (client.descriptors.page.listDbServers.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listDbServers without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbServersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbServersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbServer()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbServer()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbServer()), - ]; - client.descriptors.page.listDbServers.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.oracledatabase.v1.IDbServer[] = []; - const iterable = client.listDbServersAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listDbServers.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDbServers.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listDbServers with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbServersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbServersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listDbServers.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listDbServersAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.oracledatabase.v1.IDbServer[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listDbServers.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDbServers.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listAutonomousDatabases without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListAutonomousDatabasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabase(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabase(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabase(), + ), + ]; + client.descriptors.page.listAutonomousDatabases.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.oracledatabase.v1.IAutonomousDatabase[] = + []; + const iterable = client.listAutonomousDatabasesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listAutonomousDatabases + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listAutonomousDatabases + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - describe('listDbNodes', () => { - it('invokes listDbNodes without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbNodesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbNodesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbNode()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbNode()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbNode()), - ]; - client.innerApiCalls.listDbNodes = stubSimpleCall(expectedResponse); - const [response] = await client.listDbNodes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDbNodes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDbNodes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDbNodes without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbNodesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbNodesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbNode()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbNode()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbNode()), - ]; - client.innerApiCalls.listDbNodes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listDbNodes( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.IDbNode[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDbNodes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDbNodes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDbNodes with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbNodesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbNodesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listDbNodes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDbNodes(request), expectedError); - const actualRequest = (client.innerApiCalls.listDbNodes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDbNodes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDbNodesStream without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbNodesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbNodesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbNode()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbNode()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbNode()), - ]; - client.descriptors.page.listDbNodes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listDbNodesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.DbNode[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.DbNode) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listDbNodes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDbNodes, request)); - assert( - (client.descriptors.page.listDbNodes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listDbNodesStream with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbNodesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbNodesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listDbNodes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listDbNodesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.DbNode[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.DbNode) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listDbNodes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDbNodes, request)); - assert( - (client.descriptors.page.listDbNodes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listDbNodes without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbNodesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbNodesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbNode()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbNode()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbNode()), - ]; - client.descriptors.page.listDbNodes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.oracledatabase.v1.IDbNode[] = []; - const iterable = client.listDbNodesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listDbNodes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDbNodes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listDbNodes with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbNodesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbNodesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listDbNodes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listDbNodesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.oracledatabase.v1.IDbNode[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listDbNodes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDbNodes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listAutonomousDatabases with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListAutonomousDatabasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listAutonomousDatabases.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAutonomousDatabasesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.oracledatabase.v1.IAutonomousDatabase[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listAutonomousDatabases + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listAutonomousDatabases + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - - describe('listGiVersions', () => { - it('invokes listGiVersions without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListGiVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListGiVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.GiVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.GiVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.GiVersion()), - ]; - client.innerApiCalls.listGiVersions = stubSimpleCall(expectedResponse); - const [response] = await client.listGiVersions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listGiVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listGiVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listGiVersions without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListGiVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListGiVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.GiVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.GiVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.GiVersion()), - ]; - client.innerApiCalls.listGiVersions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listGiVersions( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.IGiVersion[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listGiVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listGiVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listGiVersions with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListGiVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListGiVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listGiVersions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listGiVersions(request), expectedError); - const actualRequest = (client.innerApiCalls.listGiVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listGiVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listGiVersionsStream without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListGiVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListGiVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.GiVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.GiVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.GiVersion()), - ]; - client.descriptors.page.listGiVersions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listGiVersionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.GiVersion[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.GiVersion) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listGiVersions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listGiVersions, request)); - assert( - (client.descriptors.page.listGiVersions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listGiVersionsStream with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListGiVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListGiVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listGiVersions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listGiVersionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.GiVersion[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.GiVersion) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listGiVersions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listGiVersions, request)); - assert( - (client.descriptors.page.listGiVersions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listGiVersions without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListGiVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListGiVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.GiVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.GiVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.GiVersion()), - ]; - client.descriptors.page.listGiVersions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.oracledatabase.v1.IGiVersion[] = []; - const iterable = client.listGiVersionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listGiVersions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listGiVersions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listGiVersions with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListGiVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListGiVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listGiVersions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listGiVersionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.oracledatabase.v1.IGiVersion[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listGiVersions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listGiVersions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }); + + describe('listAutonomousDbVersions', () => { + it('invokes listAutonomousDbVersions without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListAutonomousDbVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListAutonomousDbVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDbVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDbVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDbVersion(), + ), + ]; + client.innerApiCalls.listAutonomousDbVersions = + stubSimpleCall(expectedResponse); + const [response] = await client.listAutonomousDbVersions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listAutonomousDbVersions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAutonomousDbVersions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listMinorVersions', () => { - it('invokes listMinorVersions without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListMinorVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListMinorVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.MinorVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.MinorVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.MinorVersion()), - ]; - client.innerApiCalls.listMinorVersions = stubSimpleCall(expectedResponse); - const [response] = await client.listMinorVersions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMinorVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMinorVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listMinorVersions without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListMinorVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListMinorVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.MinorVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.MinorVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.MinorVersion()), - ]; - client.innerApiCalls.listMinorVersions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listMinorVersions( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.IMinorVersion[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMinorVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMinorVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listMinorVersions with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListMinorVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListMinorVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listMinorVersions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listMinorVersions(request), expectedError); - const actualRequest = (client.innerApiCalls.listMinorVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMinorVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listMinorVersionsStream without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListMinorVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListMinorVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.MinorVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.MinorVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.MinorVersion()), - ]; - client.descriptors.page.listMinorVersions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listMinorVersionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.MinorVersion[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.MinorVersion) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listMinorVersions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMinorVersions, request)); - assert( - (client.descriptors.page.listMinorVersions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listMinorVersionsStream with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListMinorVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListMinorVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMinorVersions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listMinorVersionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.MinorVersion[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.MinorVersion) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listMinorVersions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMinorVersions, request)); - assert( - (client.descriptors.page.listMinorVersions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listMinorVersions without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListMinorVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListMinorVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.MinorVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.MinorVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.MinorVersion()), - ]; - client.descriptors.page.listMinorVersions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.oracledatabase.v1.IMinorVersion[] = []; - const iterable = client.listMinorVersionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listAutonomousDbVersions without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListAutonomousDbVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListAutonomousDbVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDbVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDbVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDbVersion(), + ), + ]; + client.innerApiCalls.listAutonomousDbVersions = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listAutonomousDbVersions( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.oracledatabase.v1.IAutonomousDbVersion[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listMinorVersions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMinorVersions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listMinorVersions with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListMinorVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListMinorVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMinorVersions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listMinorVersionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.oracledatabase.v1.IMinorVersion[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listMinorVersions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMinorVersions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listAutonomousDbVersions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAutonomousDbVersions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listDbSystemShapes', () => { - it('invokes listDbSystemShapes without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbSystemShapesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbSystemShapesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystemShape()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystemShape()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystemShape()), - ]; - client.innerApiCalls.listDbSystemShapes = stubSimpleCall(expectedResponse); - const [response] = await client.listDbSystemShapes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDbSystemShapes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDbSystemShapes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDbSystemShapes without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbSystemShapesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbSystemShapesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystemShape()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystemShape()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystemShape()), - ]; - client.innerApiCalls.listDbSystemShapes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listDbSystemShapes( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.IDbSystemShape[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDbSystemShapes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDbSystemShapes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDbSystemShapes with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbSystemShapesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbSystemShapesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listDbSystemShapes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDbSystemShapes(request), expectedError); - const actualRequest = (client.innerApiCalls.listDbSystemShapes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDbSystemShapes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDbSystemShapesStream without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbSystemShapesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbSystemShapesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystemShape()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystemShape()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystemShape()), - ]; - client.descriptors.page.listDbSystemShapes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listDbSystemShapesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.DbSystemShape[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.DbSystemShape) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listDbSystemShapes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDbSystemShapes, request)); - assert( - (client.descriptors.page.listDbSystemShapes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listDbSystemShapesStream with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbSystemShapesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbSystemShapesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listDbSystemShapes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listDbSystemShapesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.DbSystemShape[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.DbSystemShape) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listDbSystemShapes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDbSystemShapes, request)); - assert( - (client.descriptors.page.listDbSystemShapes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listDbSystemShapes without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbSystemShapesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbSystemShapesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystemShape()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystemShape()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystemShape()), - ]; - client.descriptors.page.listDbSystemShapes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.oracledatabase.v1.IDbSystemShape[] = []; - const iterable = client.listDbSystemShapesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listDbSystemShapes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDbSystemShapes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listDbSystemShapes with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbSystemShapesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbSystemShapesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listDbSystemShapes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listDbSystemShapesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.oracledatabase.v1.IDbSystemShape[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listDbSystemShapes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDbSystemShapes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listAutonomousDbVersions with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListAutonomousDbVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListAutonomousDbVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listAutonomousDbVersions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listAutonomousDbVersions(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listAutonomousDbVersions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAutonomousDbVersions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listAutonomousDatabases', () => { - it('invokes listAutonomousDatabases without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListAutonomousDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabase()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabase()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabase()), - ]; - client.innerApiCalls.listAutonomousDatabases = stubSimpleCall(expectedResponse); - const [response] = await client.listAutonomousDatabases(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listAutonomousDatabases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAutonomousDatabases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listAutonomousDatabases without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListAutonomousDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabase()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabase()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabase()), - ]; - client.innerApiCalls.listAutonomousDatabases = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listAutonomousDatabases( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.IAutonomousDatabase[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listAutonomousDatabases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAutonomousDatabases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listAutonomousDatabases with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListAutonomousDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listAutonomousDatabases = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listAutonomousDatabases(request), expectedError); - const actualRequest = (client.innerApiCalls.listAutonomousDatabases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAutonomousDatabases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listAutonomousDatabasesStream without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListAutonomousDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabase()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabase()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabase()), - ]; - client.descriptors.page.listAutonomousDatabases.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listAutonomousDatabasesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.AutonomousDatabase[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.AutonomousDatabase) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listAutonomousDatabases.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAutonomousDatabases, request)); - assert( - (client.descriptors.page.listAutonomousDatabases.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listAutonomousDatabasesStream with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListAutonomousDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listAutonomousDatabases.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listAutonomousDatabasesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.AutonomousDatabase[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.AutonomousDatabase) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listAutonomousDatabases.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAutonomousDatabases, request)); - assert( - (client.descriptors.page.listAutonomousDatabases.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listAutonomousDatabases without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListAutonomousDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabase()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabase()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabase()), - ]; - client.descriptors.page.listAutonomousDatabases.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.oracledatabase.v1.IAutonomousDatabase[] = []; - const iterable = client.listAutonomousDatabasesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listAutonomousDatabases.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listAutonomousDatabases.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listAutonomousDatabases with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListAutonomousDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listAutonomousDatabases.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listAutonomousDatabasesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.oracledatabase.v1.IAutonomousDatabase[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listAutonomousDatabases.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listAutonomousDatabases.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listAutonomousDbVersionsStream without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListAutonomousDbVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListAutonomousDbVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDbVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDbVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDbVersion(), + ), + ]; + client.descriptors.page.listAutonomousDbVersions.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listAutonomousDbVersionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.AutonomousDbVersion[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.oracledatabase.v1.AutonomousDbVersion, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listAutonomousDbVersions + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listAutonomousDbVersions, request), + ); + assert( + ( + client.descriptors.page.listAutonomousDbVersions + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - describe('listAutonomousDbVersions', () => { - it('invokes listAutonomousDbVersions without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListAutonomousDbVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListAutonomousDbVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDbVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDbVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDbVersion()), - ]; - client.innerApiCalls.listAutonomousDbVersions = stubSimpleCall(expectedResponse); - const [response] = await client.listAutonomousDbVersions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listAutonomousDbVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAutonomousDbVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listAutonomousDbVersions without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListAutonomousDbVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListAutonomousDbVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDbVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDbVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDbVersion()), - ]; - client.innerApiCalls.listAutonomousDbVersions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listAutonomousDbVersions( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.IAutonomousDbVersion[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listAutonomousDbVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAutonomousDbVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listAutonomousDbVersions with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListAutonomousDbVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListAutonomousDbVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listAutonomousDbVersions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listAutonomousDbVersions(request), expectedError); - const actualRequest = (client.innerApiCalls.listAutonomousDbVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAutonomousDbVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listAutonomousDbVersionsStream with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListAutonomousDbVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListAutonomousDbVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listAutonomousDbVersions.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listAutonomousDbVersionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.AutonomousDbVersion[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.oracledatabase.v1.AutonomousDbVersion, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listAutonomousDbVersions + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listAutonomousDbVersions, request), + ); + assert( + ( + client.descriptors.page.listAutonomousDbVersions + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listAutonomousDbVersionsStream without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListAutonomousDbVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListAutonomousDbVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDbVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDbVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDbVersion()), - ]; - client.descriptors.page.listAutonomousDbVersions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listAutonomousDbVersionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.AutonomousDbVersion[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.AutonomousDbVersion) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listAutonomousDbVersions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAutonomousDbVersions, request)); - assert( - (client.descriptors.page.listAutonomousDbVersions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listAutonomousDbVersions without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListAutonomousDbVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListAutonomousDbVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDbVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDbVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDbVersion(), + ), + ]; + client.descriptors.page.listAutonomousDbVersions.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.oracledatabase.v1.IAutonomousDbVersion[] = + []; + const iterable = client.listAutonomousDbVersionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listAutonomousDbVersions + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listAutonomousDbVersions + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listAutonomousDbVersionsStream with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListAutonomousDbVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListAutonomousDbVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listAutonomousDbVersions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listAutonomousDbVersionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.AutonomousDbVersion[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.AutonomousDbVersion) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listAutonomousDbVersions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAutonomousDbVersions, request)); - assert( - (client.descriptors.page.listAutonomousDbVersions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listAutonomousDbVersions with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListAutonomousDbVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListAutonomousDbVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listAutonomousDbVersions.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAutonomousDbVersionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.oracledatabase.v1.IAutonomousDbVersion[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listAutonomousDbVersions + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listAutonomousDbVersions + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('listAutonomousDatabaseCharacterSets', () => { + it('invokes listAutonomousDatabaseCharacterSets without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabaseCharacterSetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListAutonomousDatabaseCharacterSetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet(), + ), + ]; + client.innerApiCalls.listAutonomousDatabaseCharacterSets = + stubSimpleCall(expectedResponse); + const [response] = + await client.listAutonomousDatabaseCharacterSets(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listAutonomousDatabaseCharacterSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAutonomousDatabaseCharacterSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listAutonomousDbVersions without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListAutonomousDbVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListAutonomousDbVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDbVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDbVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDbVersion()), - ]; - client.descriptors.page.listAutonomousDbVersions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.oracledatabase.v1.IAutonomousDbVersion[] = []; - const iterable = client.listAutonomousDbVersionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listAutonomousDatabaseCharacterSets without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabaseCharacterSetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListAutonomousDatabaseCharacterSetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet(), + ), + ]; + client.innerApiCalls.listAutonomousDatabaseCharacterSets = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listAutonomousDatabaseCharacterSets( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseCharacterSet[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listAutonomousDbVersions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listAutonomousDbVersions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listAutonomousDbVersions with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListAutonomousDbVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListAutonomousDbVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listAutonomousDbVersions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listAutonomousDbVersionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.oracledatabase.v1.IAutonomousDbVersion[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listAutonomousDbVersions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listAutonomousDbVersions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listAutonomousDatabaseCharacterSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAutonomousDatabaseCharacterSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listAutonomousDatabaseCharacterSets', () => { - it('invokes listAutonomousDatabaseCharacterSets without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabaseCharacterSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListAutonomousDatabaseCharacterSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet()), - ]; - client.innerApiCalls.listAutonomousDatabaseCharacterSets = stubSimpleCall(expectedResponse); - const [response] = await client.listAutonomousDatabaseCharacterSets(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listAutonomousDatabaseCharacterSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAutonomousDatabaseCharacterSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listAutonomousDatabaseCharacterSets with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabaseCharacterSetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListAutonomousDatabaseCharacterSetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listAutonomousDatabaseCharacterSets = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listAutonomousDatabaseCharacterSets(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listAutonomousDatabaseCharacterSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAutonomousDatabaseCharacterSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listAutonomousDatabaseCharacterSets without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabaseCharacterSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListAutonomousDatabaseCharacterSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet()), - ]; - client.innerApiCalls.listAutonomousDatabaseCharacterSets = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listAutonomousDatabaseCharacterSets( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseCharacterSet[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listAutonomousDatabaseCharacterSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAutonomousDatabaseCharacterSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listAutonomousDatabaseCharacterSetsStream without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabaseCharacterSetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListAutonomousDatabaseCharacterSetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet(), + ), + ]; + client.descriptors.page.listAutonomousDatabaseCharacterSets.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listAutonomousDatabaseCharacterSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listAutonomousDatabaseCharacterSets + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listAutonomousDatabaseCharacterSets, + request, + ), + ); + assert( + ( + client.descriptors.page.listAutonomousDatabaseCharacterSets + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listAutonomousDatabaseCharacterSets with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabaseCharacterSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListAutonomousDatabaseCharacterSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listAutonomousDatabaseCharacterSets = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listAutonomousDatabaseCharacterSets(request), expectedError); - const actualRequest = (client.innerApiCalls.listAutonomousDatabaseCharacterSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAutonomousDatabaseCharacterSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listAutonomousDatabaseCharacterSetsStream with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabaseCharacterSetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListAutonomousDatabaseCharacterSetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listAutonomousDatabaseCharacterSets.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listAutonomousDatabaseCharacterSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listAutonomousDatabaseCharacterSets + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listAutonomousDatabaseCharacterSets, + request, + ), + ); + assert( + ( + client.descriptors.page.listAutonomousDatabaseCharacterSets + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listAutonomousDatabaseCharacterSetsStream without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabaseCharacterSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListAutonomousDatabaseCharacterSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet()), - ]; - client.descriptors.page.listAutonomousDatabaseCharacterSets.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listAutonomousDatabaseCharacterSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listAutonomousDatabaseCharacterSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAutonomousDatabaseCharacterSets, request)); - assert( - (client.descriptors.page.listAutonomousDatabaseCharacterSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listAutonomousDatabaseCharacterSets without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabaseCharacterSetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListAutonomousDatabaseCharacterSetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet(), + ), + ]; + client.descriptors.page.listAutonomousDatabaseCharacterSets.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseCharacterSet[] = + []; + const iterable = client.listAutonomousDatabaseCharacterSetsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listAutonomousDatabaseCharacterSets + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listAutonomousDatabaseCharacterSets + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listAutonomousDatabaseCharacterSetsStream with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabaseCharacterSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListAutonomousDatabaseCharacterSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listAutonomousDatabaseCharacterSets.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listAutonomousDatabaseCharacterSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listAutonomousDatabaseCharacterSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAutonomousDatabaseCharacterSets, request)); - assert( - (client.descriptors.page.listAutonomousDatabaseCharacterSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listAutonomousDatabaseCharacterSets with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabaseCharacterSetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListAutonomousDatabaseCharacterSetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listAutonomousDatabaseCharacterSets.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAutonomousDatabaseCharacterSetsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseCharacterSet[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listAutonomousDatabaseCharacterSets + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listAutonomousDatabaseCharacterSets + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('listAutonomousDatabaseBackups', () => { + it('invokes listAutonomousDatabaseBackups without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabaseBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListAutonomousDatabaseBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup(), + ), + ]; + client.innerApiCalls.listAutonomousDatabaseBackups = + stubSimpleCall(expectedResponse); + const [response] = await client.listAutonomousDatabaseBackups(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listAutonomousDatabaseBackups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAutonomousDatabaseBackups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listAutonomousDatabaseCharacterSets without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabaseCharacterSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListAutonomousDatabaseCharacterSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseCharacterSet()), - ]; - client.descriptors.page.listAutonomousDatabaseCharacterSets.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseCharacterSet[] = []; - const iterable = client.listAutonomousDatabaseCharacterSetsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listAutonomousDatabaseBackups without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabaseBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListAutonomousDatabaseBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup(), + ), + ]; + client.innerApiCalls.listAutonomousDatabaseBackups = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listAutonomousDatabaseBackups( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseBackup[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listAutonomousDatabaseCharacterSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listAutonomousDatabaseCharacterSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listAutonomousDatabaseCharacterSets with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabaseCharacterSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListAutonomousDatabaseCharacterSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listAutonomousDatabaseCharacterSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listAutonomousDatabaseCharacterSetsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseCharacterSet[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listAutonomousDatabaseCharacterSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listAutonomousDatabaseCharacterSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listAutonomousDatabaseBackups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAutonomousDatabaseBackups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listAutonomousDatabaseBackups', () => { - it('invokes listAutonomousDatabaseBackups without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabaseBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListAutonomousDatabaseBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup()), - ]; - client.innerApiCalls.listAutonomousDatabaseBackups = stubSimpleCall(expectedResponse); - const [response] = await client.listAutonomousDatabaseBackups(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listAutonomousDatabaseBackups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAutonomousDatabaseBackups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listAutonomousDatabaseBackups with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabaseBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListAutonomousDatabaseBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listAutonomousDatabaseBackups = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listAutonomousDatabaseBackups(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listAutonomousDatabaseBackups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAutonomousDatabaseBackups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listAutonomousDatabaseBackups without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabaseBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListAutonomousDatabaseBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup()), - ]; - client.innerApiCalls.listAutonomousDatabaseBackups = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listAutonomousDatabaseBackups( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseBackup[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listAutonomousDatabaseBackups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAutonomousDatabaseBackups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listAutonomousDatabaseBackupsStream without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabaseBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListAutonomousDatabaseBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup(), + ), + ]; + client.descriptors.page.listAutonomousDatabaseBackups.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listAutonomousDatabaseBackupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listAutonomousDatabaseBackups + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listAutonomousDatabaseBackups, + request, + ), + ); + assert( + ( + client.descriptors.page.listAutonomousDatabaseBackups + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listAutonomousDatabaseBackups with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabaseBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListAutonomousDatabaseBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listAutonomousDatabaseBackups = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listAutonomousDatabaseBackups(request), expectedError); - const actualRequest = (client.innerApiCalls.listAutonomousDatabaseBackups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAutonomousDatabaseBackups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listAutonomousDatabaseBackupsStream with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabaseBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListAutonomousDatabaseBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listAutonomousDatabaseBackups.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listAutonomousDatabaseBackupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listAutonomousDatabaseBackups + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listAutonomousDatabaseBackups, + request, + ), + ); + assert( + ( + client.descriptors.page.listAutonomousDatabaseBackups + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listAutonomousDatabaseBackupsStream without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabaseBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListAutonomousDatabaseBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup()), - ]; - client.descriptors.page.listAutonomousDatabaseBackups.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listAutonomousDatabaseBackupsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listAutonomousDatabaseBackups.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAutonomousDatabaseBackups, request)); - assert( - (client.descriptors.page.listAutonomousDatabaseBackups.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listAutonomousDatabaseBackups without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabaseBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListAutonomousDatabaseBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup(), + ), + ]; + client.descriptors.page.listAutonomousDatabaseBackups.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseBackup[] = + []; + const iterable = client.listAutonomousDatabaseBackupsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listAutonomousDatabaseBackups + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listAutonomousDatabaseBackups + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listAutonomousDatabaseBackupsStream with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabaseBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListAutonomousDatabaseBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listAutonomousDatabaseBackups.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listAutonomousDatabaseBackupsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listAutonomousDatabaseBackups.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAutonomousDatabaseBackups, request)); - assert( - (client.descriptors.page.listAutonomousDatabaseBackups.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listAutonomousDatabaseBackups with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabaseBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListAutonomousDatabaseBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listAutonomousDatabaseBackups.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAutonomousDatabaseBackupsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseBackup[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listAutonomousDatabaseBackups + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listAutonomousDatabaseBackups + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('listOdbNetworks', () => { + it('invokes listOdbNetworks without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListOdbNetworksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListOdbNetworksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.OdbNetwork(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.OdbNetwork(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.OdbNetwork(), + ), + ]; + client.innerApiCalls.listOdbNetworks = stubSimpleCall(expectedResponse); + const [response] = await client.listOdbNetworks(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listOdbNetworks as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listOdbNetworks as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listAutonomousDatabaseBackups without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabaseBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListAutonomousDatabaseBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.AutonomousDatabaseBackup()), - ]; - client.descriptors.page.listAutonomousDatabaseBackups.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseBackup[] = []; - const iterable = client.listAutonomousDatabaseBackupsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listOdbNetworks without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListOdbNetworksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListOdbNetworksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.OdbNetwork(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.OdbNetwork(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.OdbNetwork(), + ), + ]; + client.innerApiCalls.listOdbNetworks = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listOdbNetworks( + request, + ( + err?: Error | null, + result?: protos.google.cloud.oracledatabase.v1.IOdbNetwork[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listAutonomousDatabaseBackups.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listAutonomousDatabaseBackups.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listAutonomousDatabaseBackups with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListAutonomousDatabaseBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListAutonomousDatabaseBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listAutonomousDatabaseBackups.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listAutonomousDatabaseBackupsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.oracledatabase.v1.IAutonomousDatabaseBackup[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listAutonomousDatabaseBackups.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listAutonomousDatabaseBackups.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listOdbNetworks as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listOdbNetworks as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listOdbNetworks', () => { - it('invokes listOdbNetworks without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListOdbNetworksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListOdbNetworksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.OdbNetwork()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.OdbNetwork()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.OdbNetwork()), - ]; - client.innerApiCalls.listOdbNetworks = stubSimpleCall(expectedResponse); - const [response] = await client.listOdbNetworks(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listOdbNetworks as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listOdbNetworks as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listOdbNetworks with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListOdbNetworksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListOdbNetworksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listOdbNetworks = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listOdbNetworks(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listOdbNetworks as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listOdbNetworks as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listOdbNetworks without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListOdbNetworksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListOdbNetworksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.OdbNetwork()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.OdbNetwork()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.OdbNetwork()), - ]; - client.innerApiCalls.listOdbNetworks = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listOdbNetworks( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.IOdbNetwork[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listOdbNetworks as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listOdbNetworks as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listOdbNetworksStream without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListOdbNetworksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListOdbNetworksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.OdbNetwork(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.OdbNetwork(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.OdbNetwork(), + ), + ]; + client.descriptors.page.listOdbNetworks.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listOdbNetworksStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.OdbNetwork[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.oracledatabase.v1.OdbNetwork) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listOdbNetworks.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listOdbNetworks, request), + ); + assert( + (client.descriptors.page.listOdbNetworks.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listOdbNetworks with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListOdbNetworksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListOdbNetworksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listOdbNetworks = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listOdbNetworks(request), expectedError); - const actualRequest = (client.innerApiCalls.listOdbNetworks as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listOdbNetworks as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listOdbNetworksStream with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListOdbNetworksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListOdbNetworksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listOdbNetworks.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listOdbNetworksStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.OdbNetwork[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.oracledatabase.v1.OdbNetwork) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listOdbNetworks.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listOdbNetworks, request), + ); + assert( + (client.descriptors.page.listOdbNetworks.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listOdbNetworksStream without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListOdbNetworksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListOdbNetworksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.OdbNetwork()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.OdbNetwork()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.OdbNetwork()), - ]; - client.descriptors.page.listOdbNetworks.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listOdbNetworksStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.OdbNetwork[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.OdbNetwork) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listOdbNetworks.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listOdbNetworks, request)); - assert( - (client.descriptors.page.listOdbNetworks.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listOdbNetworks without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListOdbNetworksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListOdbNetworksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.OdbNetwork(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.OdbNetwork(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.OdbNetwork(), + ), + ]; + client.descriptors.page.listOdbNetworks.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.oracledatabase.v1.IOdbNetwork[] = []; + const iterable = client.listOdbNetworksAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listOdbNetworks.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listOdbNetworks.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listOdbNetworksStream with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListOdbNetworksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListOdbNetworksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listOdbNetworks.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listOdbNetworksStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.OdbNetwork[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.OdbNetwork) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listOdbNetworks.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listOdbNetworks, request)); - assert( - (client.descriptors.page.listOdbNetworks.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listOdbNetworks with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListOdbNetworksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListOdbNetworksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listOdbNetworks.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listOdbNetworksAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.oracledatabase.v1.IOdbNetwork[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listOdbNetworks.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listOdbNetworks.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listOdbSubnets', () => { + it('invokes listOdbSubnets without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListOdbSubnetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListOdbSubnetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.OdbSubnet(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.OdbSubnet(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.OdbSubnet(), + ), + ]; + client.innerApiCalls.listOdbSubnets = stubSimpleCall(expectedResponse); + const [response] = await client.listOdbSubnets(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listOdbSubnets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listOdbSubnets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listOdbNetworks without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListOdbNetworksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListOdbNetworksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.OdbNetwork()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.OdbNetwork()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.OdbNetwork()), - ]; - client.descriptors.page.listOdbNetworks.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.oracledatabase.v1.IOdbNetwork[] = []; - const iterable = client.listOdbNetworksAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listOdbSubnets without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListOdbSubnetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListOdbSubnetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.OdbSubnet(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.OdbSubnet(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.OdbSubnet(), + ), + ]; + client.innerApiCalls.listOdbSubnets = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listOdbSubnets( + request, + ( + err?: Error | null, + result?: protos.google.cloud.oracledatabase.v1.IOdbSubnet[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listOdbNetworks.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listOdbNetworks.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listOdbNetworks with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListOdbNetworksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListOdbNetworksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listOdbNetworks.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listOdbNetworksAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.oracledatabase.v1.IOdbNetwork[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listOdbNetworks.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listOdbNetworks.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listOdbSubnets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listOdbSubnets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listOdbSubnets', () => { - it('invokes listOdbSubnets without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListOdbSubnetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListOdbSubnetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.OdbSubnet()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.OdbSubnet()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.OdbSubnet()), - ]; - client.innerApiCalls.listOdbSubnets = stubSimpleCall(expectedResponse); - const [response] = await client.listOdbSubnets(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listOdbSubnets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listOdbSubnets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listOdbSubnets with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListOdbSubnetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListOdbSubnetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listOdbSubnets = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listOdbSubnets(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listOdbSubnets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listOdbSubnets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listOdbSubnets without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListOdbSubnetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListOdbSubnetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.OdbSubnet()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.OdbSubnet()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.OdbSubnet()), - ]; - client.innerApiCalls.listOdbSubnets = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listOdbSubnets( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.IOdbSubnet[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listOdbSubnets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listOdbSubnets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listOdbSubnetsStream without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListOdbSubnetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListOdbSubnetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.OdbSubnet(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.OdbSubnet(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.OdbSubnet(), + ), + ]; + client.descriptors.page.listOdbSubnets.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listOdbSubnetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.OdbSubnet[] = []; + stream.on( + 'data', + (response: protos.google.cloud.oracledatabase.v1.OdbSubnet) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listOdbSubnets.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listOdbSubnets, request), + ); + assert( + (client.descriptors.page.listOdbSubnets.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listOdbSubnets with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListOdbSubnetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListOdbSubnetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listOdbSubnets = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listOdbSubnets(request), expectedError); - const actualRequest = (client.innerApiCalls.listOdbSubnets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listOdbSubnets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listOdbSubnetsStream with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListOdbSubnetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListOdbSubnetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listOdbSubnets.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listOdbSubnetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.OdbSubnet[] = []; + stream.on( + 'data', + (response: protos.google.cloud.oracledatabase.v1.OdbSubnet) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listOdbSubnets.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listOdbSubnets, request), + ); + assert( + (client.descriptors.page.listOdbSubnets.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listOdbSubnetsStream without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListOdbSubnetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListOdbSubnetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.OdbSubnet()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.OdbSubnet()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.OdbSubnet()), - ]; - client.descriptors.page.listOdbSubnets.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listOdbSubnetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.OdbSubnet[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.OdbSubnet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listOdbSubnets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listOdbSubnets, request)); - assert( - (client.descriptors.page.listOdbSubnets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listOdbSubnets without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListOdbSubnetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListOdbSubnetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.OdbSubnet(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.OdbSubnet(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.OdbSubnet(), + ), + ]; + client.descriptors.page.listOdbSubnets.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.oracledatabase.v1.IOdbSubnet[] = []; + const iterable = client.listOdbSubnetsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listOdbSubnets.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listOdbSubnets.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listOdbSubnetsStream with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListOdbSubnetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListOdbSubnetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listOdbSubnets.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listOdbSubnetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.OdbSubnet[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.OdbSubnet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listOdbSubnets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listOdbSubnets, request)); - assert( - (client.descriptors.page.listOdbSubnets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listOdbSubnets with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListOdbSubnetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListOdbSubnetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listOdbSubnets.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listOdbSubnetsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.oracledatabase.v1.IOdbSubnet[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listOdbSubnets.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listOdbSubnets.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listExadbVmClusters', () => { + it('invokes listExadbVmClusters without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListExadbVmClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListExadbVmClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ExadbVmCluster(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ExadbVmCluster(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ExadbVmCluster(), + ), + ]; + client.innerApiCalls.listExadbVmClusters = + stubSimpleCall(expectedResponse); + const [response] = await client.listExadbVmClusters(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listExadbVmClusters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listExadbVmClusters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listOdbSubnets without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListOdbSubnetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListOdbSubnetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.OdbSubnet()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.OdbSubnet()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.OdbSubnet()), - ]; - client.descriptors.page.listOdbSubnets.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.oracledatabase.v1.IOdbSubnet[] = []; - const iterable = client.listOdbSubnetsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listExadbVmClusters without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListExadbVmClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListExadbVmClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ExadbVmCluster(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ExadbVmCluster(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ExadbVmCluster(), + ), + ]; + client.innerApiCalls.listExadbVmClusters = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listExadbVmClusters( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.oracledatabase.v1.IExadbVmCluster[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listOdbSubnets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listOdbSubnets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listOdbSubnets with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListOdbSubnetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListOdbSubnetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listOdbSubnets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listOdbSubnetsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.oracledatabase.v1.IOdbSubnet[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listOdbSubnets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listOdbSubnets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listExadbVmClusters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listExadbVmClusters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listExadbVmClusters', () => { - it('invokes listExadbVmClusters without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListExadbVmClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListExadbVmClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.ExadbVmCluster()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.ExadbVmCluster()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.ExadbVmCluster()), - ]; - client.innerApiCalls.listExadbVmClusters = stubSimpleCall(expectedResponse); - const [response] = await client.listExadbVmClusters(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listExadbVmClusters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listExadbVmClusters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listExadbVmClusters with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListExadbVmClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListExadbVmClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listExadbVmClusters = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listExadbVmClusters(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listExadbVmClusters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listExadbVmClusters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listExadbVmClusters without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListExadbVmClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListExadbVmClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.ExadbVmCluster()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.ExadbVmCluster()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.ExadbVmCluster()), - ]; - client.innerApiCalls.listExadbVmClusters = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listExadbVmClusters( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.IExadbVmCluster[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listExadbVmClusters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listExadbVmClusters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listExadbVmClustersStream without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListExadbVmClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListExadbVmClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ExadbVmCluster(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ExadbVmCluster(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ExadbVmCluster(), + ), + ]; + client.descriptors.page.listExadbVmClusters.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listExadbVmClustersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.ExadbVmCluster[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.oracledatabase.v1.ExadbVmCluster) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listExadbVmClusters.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listExadbVmClusters, request), + ); + assert( + (client.descriptors.page.listExadbVmClusters.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listExadbVmClusters with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListExadbVmClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListExadbVmClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listExadbVmClusters = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listExadbVmClusters(request), expectedError); - const actualRequest = (client.innerApiCalls.listExadbVmClusters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listExadbVmClusters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listExadbVmClustersStream with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListExadbVmClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListExadbVmClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listExadbVmClusters.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listExadbVmClustersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.ExadbVmCluster[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.oracledatabase.v1.ExadbVmCluster) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listExadbVmClusters.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listExadbVmClusters, request), + ); + assert( + (client.descriptors.page.listExadbVmClusters.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listExadbVmClustersStream without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListExadbVmClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListExadbVmClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.ExadbVmCluster()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.ExadbVmCluster()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.ExadbVmCluster()), - ]; - client.descriptors.page.listExadbVmClusters.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listExadbVmClustersStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.ExadbVmCluster[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.ExadbVmCluster) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listExadbVmClusters.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listExadbVmClusters, request)); - assert( - (client.descriptors.page.listExadbVmClusters.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listExadbVmClusters without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListExadbVmClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListExadbVmClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ExadbVmCluster(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ExadbVmCluster(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ExadbVmCluster(), + ), + ]; + client.descriptors.page.listExadbVmClusters.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.oracledatabase.v1.IExadbVmCluster[] = + []; + const iterable = client.listExadbVmClustersAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listExadbVmClusters.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listExadbVmClusters.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listExadbVmClustersStream with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListExadbVmClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListExadbVmClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listExadbVmClusters.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listExadbVmClustersStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.ExadbVmCluster[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.ExadbVmCluster) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listExadbVmClusters.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listExadbVmClusters, request)); - assert( - (client.descriptors.page.listExadbVmClusters.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listExadbVmClusters with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListExadbVmClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListExadbVmClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listExadbVmClusters.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listExadbVmClustersAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.oracledatabase.v1.IExadbVmCluster[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listExadbVmClusters.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listExadbVmClusters.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listExascaleDbStorageVaults', () => { + it('invokes listExascaleDbStorageVaults without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListExascaleDbStorageVaultsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListExascaleDbStorageVaultsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault(), + ), + ]; + client.innerApiCalls.listExascaleDbStorageVaults = + stubSimpleCall(expectedResponse); + const [response] = await client.listExascaleDbStorageVaults(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listExascaleDbStorageVaults as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listExascaleDbStorageVaults as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listExadbVmClusters without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListExadbVmClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListExadbVmClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.ExadbVmCluster()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.ExadbVmCluster()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.ExadbVmCluster()), - ]; - client.descriptors.page.listExadbVmClusters.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.oracledatabase.v1.IExadbVmCluster[] = []; - const iterable = client.listExadbVmClustersAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listExascaleDbStorageVaults without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListExascaleDbStorageVaultsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListExascaleDbStorageVaultsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault(), + ), + ]; + client.innerApiCalls.listExascaleDbStorageVaults = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listExascaleDbStorageVaults( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listExadbVmClusters.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listExadbVmClusters.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listExadbVmClusters with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListExadbVmClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListExadbVmClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listExadbVmClusters.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listExadbVmClustersAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.oracledatabase.v1.IExadbVmCluster[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listExadbVmClusters.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listExadbVmClusters.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listExascaleDbStorageVaults as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listExascaleDbStorageVaults as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listExascaleDbStorageVaults', () => { - it('invokes listExascaleDbStorageVaults without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListExascaleDbStorageVaultsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListExascaleDbStorageVaultsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault()), - ]; - client.innerApiCalls.listExascaleDbStorageVaults = stubSimpleCall(expectedResponse); - const [response] = await client.listExascaleDbStorageVaults(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listExascaleDbStorageVaults as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listExascaleDbStorageVaults as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listExascaleDbStorageVaults with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListExascaleDbStorageVaultsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListExascaleDbStorageVaultsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listExascaleDbStorageVaults = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listExascaleDbStorageVaults(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listExascaleDbStorageVaults as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listExascaleDbStorageVaults as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listExascaleDbStorageVaults without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListExascaleDbStorageVaultsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListExascaleDbStorageVaultsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault()), - ]; - client.innerApiCalls.listExascaleDbStorageVaults = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listExascaleDbStorageVaults( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listExascaleDbStorageVaults as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listExascaleDbStorageVaults as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listExascaleDbStorageVaultsStream without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListExascaleDbStorageVaultsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListExascaleDbStorageVaultsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault(), + ), + ]; + client.descriptors.page.listExascaleDbStorageVaults.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listExascaleDbStorageVaultsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listExascaleDbStorageVaults + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listExascaleDbStorageVaults, + request, + ), + ); + assert( + ( + client.descriptors.page.listExascaleDbStorageVaults + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listExascaleDbStorageVaults with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListExascaleDbStorageVaultsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListExascaleDbStorageVaultsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listExascaleDbStorageVaults = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listExascaleDbStorageVaults(request), expectedError); - const actualRequest = (client.innerApiCalls.listExascaleDbStorageVaults as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listExascaleDbStorageVaults as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listExascaleDbStorageVaultsStream with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListExascaleDbStorageVaultsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListExascaleDbStorageVaultsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listExascaleDbStorageVaults.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listExascaleDbStorageVaultsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listExascaleDbStorageVaults + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listExascaleDbStorageVaults, + request, + ), + ); + assert( + ( + client.descriptors.page.listExascaleDbStorageVaults + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listExascaleDbStorageVaultsStream without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListExascaleDbStorageVaultsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListExascaleDbStorageVaultsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault()), - ]; - client.descriptors.page.listExascaleDbStorageVaults.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listExascaleDbStorageVaultsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listExascaleDbStorageVaults.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listExascaleDbStorageVaults, request)); - assert( - (client.descriptors.page.listExascaleDbStorageVaults.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listExascaleDbStorageVaults without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListExascaleDbStorageVaultsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListExascaleDbStorageVaultsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault(), + ), + ]; + client.descriptors.page.listExascaleDbStorageVaults.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault[] = + []; + const iterable = client.listExascaleDbStorageVaultsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listExascaleDbStorageVaults + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listExascaleDbStorageVaults + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listExascaleDbStorageVaultsStream with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListExascaleDbStorageVaultsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListExascaleDbStorageVaultsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listExascaleDbStorageVaults.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listExascaleDbStorageVaultsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listExascaleDbStorageVaults.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listExascaleDbStorageVaults, request)); - assert( - (client.descriptors.page.listExascaleDbStorageVaults.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listExascaleDbStorageVaults with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListExascaleDbStorageVaultsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListExascaleDbStorageVaultsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listExascaleDbStorageVaults.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listExascaleDbStorageVaultsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listExascaleDbStorageVaults + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listExascaleDbStorageVaults + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('listDbSystemInitialStorageSizes', () => { + it('invokes listDbSystemInitialStorageSizes without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbSystemInitialStorageSizesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbSystemInitialStorageSizesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize(), + ), + ]; + client.innerApiCalls.listDbSystemInitialStorageSizes = + stubSimpleCall(expectedResponse); + const [response] = await client.listDbSystemInitialStorageSizes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDbSystemInitialStorageSizes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDbSystemInitialStorageSizes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listExascaleDbStorageVaults without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListExascaleDbStorageVaultsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListExascaleDbStorageVaultsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.ExascaleDbStorageVault()), - ]; - client.descriptors.page.listExascaleDbStorageVaults.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault[] = []; - const iterable = client.listExascaleDbStorageVaultsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listDbSystemInitialStorageSizes without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbSystemInitialStorageSizesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbSystemInitialStorageSizesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize(), + ), + ]; + client.innerApiCalls.listDbSystemInitialStorageSizes = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listDbSystemInitialStorageSizes( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.oracledatabase.v1.IDbSystemInitialStorageSize[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listExascaleDbStorageVaults.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listExascaleDbStorageVaults.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listExascaleDbStorageVaults with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListExascaleDbStorageVaultsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListExascaleDbStorageVaultsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listExascaleDbStorageVaults.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listExascaleDbStorageVaultsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.oracledatabase.v1.IExascaleDbStorageVault[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listExascaleDbStorageVaults.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listExascaleDbStorageVaults.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDbSystemInitialStorageSizes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDbSystemInitialStorageSizes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listDbSystemInitialStorageSizes', () => { - it('invokes listDbSystemInitialStorageSizes without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbSystemInitialStorageSizesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbSystemInitialStorageSizesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize()), - ]; - client.innerApiCalls.listDbSystemInitialStorageSizes = stubSimpleCall(expectedResponse); - const [response] = await client.listDbSystemInitialStorageSizes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDbSystemInitialStorageSizes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDbSystemInitialStorageSizes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listDbSystemInitialStorageSizes with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbSystemInitialStorageSizesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbSystemInitialStorageSizesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listDbSystemInitialStorageSizes = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listDbSystemInitialStorageSizes(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listDbSystemInitialStorageSizes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDbSystemInitialStorageSizes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listDbSystemInitialStorageSizes without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbSystemInitialStorageSizesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbSystemInitialStorageSizesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize()), - ]; - client.innerApiCalls.listDbSystemInitialStorageSizes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listDbSystemInitialStorageSizes( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.IDbSystemInitialStorageSize[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDbSystemInitialStorageSizes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDbSystemInitialStorageSizes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listDbSystemInitialStorageSizesStream without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbSystemInitialStorageSizesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbSystemInitialStorageSizesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize(), + ), + ]; + client.descriptors.page.listDbSystemInitialStorageSizes.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listDbSystemInitialStorageSizesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listDbSystemInitialStorageSizes + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listDbSystemInitialStorageSizes, + request, + ), + ); + assert( + ( + client.descriptors.page.listDbSystemInitialStorageSizes + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listDbSystemInitialStorageSizes with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbSystemInitialStorageSizesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbSystemInitialStorageSizesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listDbSystemInitialStorageSizes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDbSystemInitialStorageSizes(request), expectedError); - const actualRequest = (client.innerApiCalls.listDbSystemInitialStorageSizes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDbSystemInitialStorageSizes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listDbSystemInitialStorageSizesStream with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbSystemInitialStorageSizesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbSystemInitialStorageSizesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDbSystemInitialStorageSizes.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listDbSystemInitialStorageSizesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listDbSystemInitialStorageSizes + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listDbSystemInitialStorageSizes, + request, + ), + ); + assert( + ( + client.descriptors.page.listDbSystemInitialStorageSizes + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listDbSystemInitialStorageSizesStream without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbSystemInitialStorageSizesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbSystemInitialStorageSizesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize()), - ]; - client.descriptors.page.listDbSystemInitialStorageSizes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listDbSystemInitialStorageSizesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listDbSystemInitialStorageSizes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDbSystemInitialStorageSizes, request)); - assert( - (client.descriptors.page.listDbSystemInitialStorageSizes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listDbSystemInitialStorageSizes without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbSystemInitialStorageSizesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbSystemInitialStorageSizesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize(), + ), + ]; + client.descriptors.page.listDbSystemInitialStorageSizes.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.oracledatabase.v1.IDbSystemInitialStorageSize[] = + []; + const iterable = client.listDbSystemInitialStorageSizesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listDbSystemInitialStorageSizes + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listDbSystemInitialStorageSizes + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listDbSystemInitialStorageSizesStream with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbSystemInitialStorageSizesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbSystemInitialStorageSizesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listDbSystemInitialStorageSizes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listDbSystemInitialStorageSizesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listDbSystemInitialStorageSizes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDbSystemInitialStorageSizes, request)); - assert( - (client.descriptors.page.listDbSystemInitialStorageSizes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listDbSystemInitialStorageSizes with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbSystemInitialStorageSizesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbSystemInitialStorageSizesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDbSystemInitialStorageSizes.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listDbSystemInitialStorageSizesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.oracledatabase.v1.IDbSystemInitialStorageSize[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listDbSystemInitialStorageSizes + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listDbSystemInitialStorageSizes + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('listDatabases', () => { + it('invokes listDatabases without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDatabasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDatabasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.Database(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.Database(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.Database(), + ), + ]; + client.innerApiCalls.listDatabases = stubSimpleCall(expectedResponse); + const [response] = await client.listDatabases(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDatabases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDatabases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listDbSystemInitialStorageSizes without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbSystemInitialStorageSizesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbSystemInitialStorageSizesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystemInitialStorageSize()), - ]; - client.descriptors.page.listDbSystemInitialStorageSizes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.oracledatabase.v1.IDbSystemInitialStorageSize[] = []; - const iterable = client.listDbSystemInitialStorageSizesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listDatabases without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDatabasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDatabasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.Database(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.Database(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.Database(), + ), + ]; + client.innerApiCalls.listDatabases = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listDatabases( + request, + ( + err?: Error | null, + result?: protos.google.cloud.oracledatabase.v1.IDatabase[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listDbSystemInitialStorageSizes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDbSystemInitialStorageSizes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listDbSystemInitialStorageSizes with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbSystemInitialStorageSizesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbSystemInitialStorageSizesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listDbSystemInitialStorageSizes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listDbSystemInitialStorageSizesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.oracledatabase.v1.IDbSystemInitialStorageSize[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listDbSystemInitialStorageSizes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDbSystemInitialStorageSizes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDatabases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDatabases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listDatabases', () => { - it('invokes listDatabases without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDatabasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.Database()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.Database()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.Database()), - ]; - client.innerApiCalls.listDatabases = stubSimpleCall(expectedResponse); - const [response] = await client.listDatabases(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDatabases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDatabases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listDatabases with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDatabasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDatabasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listDatabases = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listDatabases(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listDatabases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDatabases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listDatabases without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDatabasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.Database()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.Database()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.Database()), - ]; - client.innerApiCalls.listDatabases = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listDatabases( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.IDatabase[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDatabases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDatabases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listDatabasesStream without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDatabasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDatabasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.Database(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.Database(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.Database(), + ), + ]; + client.descriptors.page.listDatabases.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listDatabasesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.Database[] = []; + stream.on( + 'data', + (response: protos.google.cloud.oracledatabase.v1.Database) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listDatabases.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listDatabases, request), + ); + assert( + (client.descriptors.page.listDatabases.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listDatabases with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDatabasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listDatabases = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDatabases(request), expectedError); - const actualRequest = (client.innerApiCalls.listDatabases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDatabases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listDatabasesStream with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDatabasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDatabasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDatabases.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listDatabasesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.Database[] = []; + stream.on( + 'data', + (response: protos.google.cloud.oracledatabase.v1.Database) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listDatabases.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listDatabases, request), + ); + assert( + (client.descriptors.page.listDatabases.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listDatabasesStream without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDatabasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.Database()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.Database()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.Database()), - ]; - client.descriptors.page.listDatabases.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listDatabasesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.Database[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.Database) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listDatabases.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDatabases, request)); - assert( - (client.descriptors.page.listDatabases.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listDatabases without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDatabasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDatabasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.Database(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.Database(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.Database(), + ), + ]; + client.descriptors.page.listDatabases.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.oracledatabase.v1.IDatabase[] = []; + const iterable = client.listDatabasesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listDatabases.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listDatabases.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listDatabasesStream with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDatabasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listDatabases.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listDatabasesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.Database[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.Database) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listDatabases.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDatabases, request)); - assert( - (client.descriptors.page.listDatabases.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listDatabases with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDatabasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDatabasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDatabases.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listDatabasesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.oracledatabase.v1.IDatabase[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listDatabases.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listDatabases.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listPluggableDatabases', () => { + it('invokes listPluggableDatabases without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListPluggableDatabasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListPluggableDatabasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.PluggableDatabase(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.PluggableDatabase(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.PluggableDatabase(), + ), + ]; + client.innerApiCalls.listPluggableDatabases = + stubSimpleCall(expectedResponse); + const [response] = await client.listPluggableDatabases(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listPluggableDatabases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPluggableDatabases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listDatabases without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDatabasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.Database()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.Database()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.Database()), - ]; - client.descriptors.page.listDatabases.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.oracledatabase.v1.IDatabase[] = []; - const iterable = client.listDatabasesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listPluggableDatabases without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListPluggableDatabasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListPluggableDatabasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.PluggableDatabase(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.PluggableDatabase(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.PluggableDatabase(), + ), + ]; + client.innerApiCalls.listPluggableDatabases = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listPluggableDatabases( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.oracledatabase.v1.IPluggableDatabase[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listDatabases.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDatabases.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listDatabases with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDatabasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listDatabases.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listDatabasesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.oracledatabase.v1.IDatabase[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listDatabases.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDatabases.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listPluggableDatabases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPluggableDatabases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listPluggableDatabases', () => { - it('invokes listPluggableDatabases without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListPluggableDatabasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListPluggableDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.PluggableDatabase()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.PluggableDatabase()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.PluggableDatabase()), - ]; - client.innerApiCalls.listPluggableDatabases = stubSimpleCall(expectedResponse); - const [response] = await client.listPluggableDatabases(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPluggableDatabases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPluggableDatabases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listPluggableDatabases with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListPluggableDatabasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListPluggableDatabasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listPluggableDatabases = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listPluggableDatabases(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listPluggableDatabases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPluggableDatabases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listPluggableDatabases without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListPluggableDatabasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListPluggableDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.PluggableDatabase()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.PluggableDatabase()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.PluggableDatabase()), - ]; - client.innerApiCalls.listPluggableDatabases = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listPluggableDatabases( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.IPluggableDatabase[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPluggableDatabases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPluggableDatabases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listPluggableDatabasesStream without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListPluggableDatabasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListPluggableDatabasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.PluggableDatabase(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.PluggableDatabase(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.PluggableDatabase(), + ), + ]; + client.descriptors.page.listPluggableDatabases.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listPluggableDatabasesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.PluggableDatabase[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.oracledatabase.v1.PluggableDatabase, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listPluggableDatabases + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listPluggableDatabases, request), + ); + assert( + ( + client.descriptors.page.listPluggableDatabases + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listPluggableDatabases with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListPluggableDatabasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListPluggableDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listPluggableDatabases = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listPluggableDatabases(request), expectedError); - const actualRequest = (client.innerApiCalls.listPluggableDatabases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPluggableDatabases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listPluggableDatabasesStream with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListPluggableDatabasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListPluggableDatabasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPluggableDatabases.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listPluggableDatabasesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.PluggableDatabase[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.oracledatabase.v1.PluggableDatabase, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listPluggableDatabases + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listPluggableDatabases, request), + ); + assert( + ( + client.descriptors.page.listPluggableDatabases + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listPluggableDatabasesStream without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListPluggableDatabasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListPluggableDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.PluggableDatabase()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.PluggableDatabase()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.PluggableDatabase()), - ]; - client.descriptors.page.listPluggableDatabases.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listPluggableDatabasesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.PluggableDatabase[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.PluggableDatabase) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listPluggableDatabases.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPluggableDatabases, request)); - assert( - (client.descriptors.page.listPluggableDatabases.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listPluggableDatabases without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListPluggableDatabasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListPluggableDatabasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.PluggableDatabase(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.PluggableDatabase(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.PluggableDatabase(), + ), + ]; + client.descriptors.page.listPluggableDatabases.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.oracledatabase.v1.IPluggableDatabase[] = + []; + const iterable = client.listPluggableDatabasesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listPluggableDatabases + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listPluggableDatabases + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listPluggableDatabasesStream with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListPluggableDatabasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListPluggableDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listPluggableDatabases.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listPluggableDatabasesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.PluggableDatabase[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.PluggableDatabase) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listPluggableDatabases.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPluggableDatabases, request)); - assert( - (client.descriptors.page.listPluggableDatabases.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listPluggableDatabases with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListPluggableDatabasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListPluggableDatabasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPluggableDatabases.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listPluggableDatabasesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.oracledatabase.v1.IPluggableDatabase[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listPluggableDatabases + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listPluggableDatabases + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('listDbSystems', () => { + it('invokes listDbSystems without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbSystemsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbSystemsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystem(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystem(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystem(), + ), + ]; + client.innerApiCalls.listDbSystems = stubSimpleCall(expectedResponse); + const [response] = await client.listDbSystems(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDbSystems as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDbSystems as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listPluggableDatabases without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListPluggableDatabasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListPluggableDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.PluggableDatabase()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.PluggableDatabase()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.PluggableDatabase()), - ]; - client.descriptors.page.listPluggableDatabases.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.oracledatabase.v1.IPluggableDatabase[] = []; - const iterable = client.listPluggableDatabasesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listDbSystems without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbSystemsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbSystemsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystem(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystem(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystem(), + ), + ]; + client.innerApiCalls.listDbSystems = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listDbSystems( + request, + ( + err?: Error | null, + result?: protos.google.cloud.oracledatabase.v1.IDbSystem[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listPluggableDatabases.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPluggableDatabases.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listPluggableDatabases with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListPluggableDatabasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListPluggableDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listPluggableDatabases.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listPluggableDatabasesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.oracledatabase.v1.IPluggableDatabase[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listPluggableDatabases.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPluggableDatabases.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDbSystems as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDbSystems as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listDbSystems', () => { - it('invokes listDbSystems without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbSystemsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbSystemsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystem()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystem()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystem()), - ]; - client.innerApiCalls.listDbSystems = stubSimpleCall(expectedResponse); - const [response] = await client.listDbSystems(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDbSystems as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDbSystems as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listDbSystems with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbSystemsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbSystemsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listDbSystems = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listDbSystems(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listDbSystems as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDbSystems as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listDbSystems without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbSystemsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbSystemsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystem()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystem()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystem()), - ]; - client.innerApiCalls.listDbSystems = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listDbSystems( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.IDbSystem[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDbSystems as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDbSystems as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listDbSystemsStream without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbSystemsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbSystemsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystem(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystem(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystem(), + ), + ]; + client.descriptors.page.listDbSystems.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listDbSystemsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.DbSystem[] = []; + stream.on( + 'data', + (response: protos.google.cloud.oracledatabase.v1.DbSystem) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listDbSystems.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listDbSystems, request), + ); + assert( + (client.descriptors.page.listDbSystems.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listDbSystems with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbSystemsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbSystemsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listDbSystems = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDbSystems(request), expectedError); - const actualRequest = (client.innerApiCalls.listDbSystems as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDbSystems as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listDbSystemsStream with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbSystemsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbSystemsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDbSystems.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listDbSystemsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.DbSystem[] = []; + stream.on( + 'data', + (response: protos.google.cloud.oracledatabase.v1.DbSystem) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listDbSystems.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listDbSystems, request), + ); + assert( + (client.descriptors.page.listDbSystems.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listDbSystemsStream without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbSystemsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbSystemsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystem()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystem()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystem()), - ]; - client.descriptors.page.listDbSystems.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listDbSystemsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.DbSystem[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.DbSystem) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listDbSystems.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDbSystems, request)); - assert( - (client.descriptors.page.listDbSystems.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listDbSystems without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbSystemsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbSystemsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystem(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystem(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbSystem(), + ), + ]; + client.descriptors.page.listDbSystems.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.oracledatabase.v1.IDbSystem[] = []; + const iterable = client.listDbSystemsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listDbSystems.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listDbSystems.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listDbSystemsStream with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbSystemsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbSystemsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listDbSystems.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listDbSystemsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.DbSystem[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.DbSystem) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listDbSystems.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDbSystems, request)); - assert( - (client.descriptors.page.listDbSystems.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listDbSystems with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbSystemsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbSystemsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDbSystems.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listDbSystemsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.oracledatabase.v1.IDbSystem[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listDbSystems.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listDbSystems.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listDbVersions', () => { + it('invokes listDbVersions without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbVersion(), + ), + ]; + client.innerApiCalls.listDbVersions = stubSimpleCall(expectedResponse); + const [response] = await client.listDbVersions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDbVersions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDbVersions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listDbSystems without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbSystemsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbSystemsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystem()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystem()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbSystem()), - ]; - client.descriptors.page.listDbSystems.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.oracledatabase.v1.IDbSystem[] = []; - const iterable = client.listDbSystemsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listDbVersions without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbVersion(), + ), + ]; + client.innerApiCalls.listDbVersions = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listDbVersions( + request, + ( + err?: Error | null, + result?: protos.google.cloud.oracledatabase.v1.IDbVersion[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listDbSystems.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDbSystems.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listDbSystems with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbSystemsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbSystemsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listDbSystems.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listDbSystemsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.oracledatabase.v1.IDbSystem[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listDbSystems.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDbSystems.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDbVersions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDbVersions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listDbVersions', () => { - it('invokes listDbVersions without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbVersion()), - ]; - client.innerApiCalls.listDbVersions = stubSimpleCall(expectedResponse); - const [response] = await client.listDbVersions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDbVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDbVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listDbVersions with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listDbVersions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listDbVersions(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listDbVersions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDbVersions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listDbVersions without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbVersion()), - ]; - client.innerApiCalls.listDbVersions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listDbVersions( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.IDbVersion[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDbVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDbVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listDbVersionsStream without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbVersion(), + ), + ]; + client.descriptors.page.listDbVersions.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listDbVersionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.DbVersion[] = []; + stream.on( + 'data', + (response: protos.google.cloud.oracledatabase.v1.DbVersion) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listDbVersions.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listDbVersions, request), + ); + assert( + (client.descriptors.page.listDbVersions.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listDbVersions with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listDbVersions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDbVersions(request), expectedError); - const actualRequest = (client.innerApiCalls.listDbVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDbVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listDbVersionsStream with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDbVersions.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listDbVersionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.DbVersion[] = []; + stream.on( + 'data', + (response: protos.google.cloud.oracledatabase.v1.DbVersion) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listDbVersions.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listDbVersions, request), + ); + assert( + (client.descriptors.page.listDbVersions.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listDbVersionsStream without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbVersion()), - ]; - client.descriptors.page.listDbVersions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listDbVersionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.DbVersion[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.DbVersion) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listDbVersions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDbVersions, request)); - assert( - (client.descriptors.page.listDbVersions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listDbVersions without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbVersion(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DbVersion(), + ), + ]; + client.descriptors.page.listDbVersions.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.oracledatabase.v1.IDbVersion[] = []; + const iterable = client.listDbVersionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listDbVersions.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listDbVersions.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listDbVersionsStream with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listDbVersions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listDbVersionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.DbVersion[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.DbVersion) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listDbVersions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDbVersions, request)); - assert( - (client.descriptors.page.listDbVersions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listDbVersions with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDbVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDbVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDbVersions.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listDbVersionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.oracledatabase.v1.IDbVersion[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listDbVersions.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listDbVersions.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listDatabaseCharacterSets', () => { + it('invokes listDatabaseCharacterSets without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDatabaseCharacterSetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDatabaseCharacterSetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet(), + ), + ]; + client.innerApiCalls.listDatabaseCharacterSets = + stubSimpleCall(expectedResponse); + const [response] = await client.listDatabaseCharacterSets(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDatabaseCharacterSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDatabaseCharacterSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listDbVersions without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbVersion()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DbVersion()), - ]; - client.descriptors.page.listDbVersions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.oracledatabase.v1.IDbVersion[] = []; - const iterable = client.listDbVersionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listDatabaseCharacterSets without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDatabaseCharacterSetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDatabaseCharacterSetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet(), + ), + ]; + client.innerApiCalls.listDatabaseCharacterSets = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listDatabaseCharacterSets( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.oracledatabase.v1.IDatabaseCharacterSet[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listDbVersions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDbVersions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listDbVersions with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDbVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDbVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listDbVersions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listDbVersionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.oracledatabase.v1.IDbVersion[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listDbVersions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDbVersions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDatabaseCharacterSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDatabaseCharacterSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listDatabaseCharacterSets', () => { - it('invokes listDatabaseCharacterSets without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDatabaseCharacterSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDatabaseCharacterSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet()), - ]; - client.innerApiCalls.listDatabaseCharacterSets = stubSimpleCall(expectedResponse); - const [response] = await client.listDatabaseCharacterSets(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDatabaseCharacterSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDatabaseCharacterSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDatabaseCharacterSets without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDatabaseCharacterSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDatabaseCharacterSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet()), - ]; - client.innerApiCalls.listDatabaseCharacterSets = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listDatabaseCharacterSets( - request, - (err?: Error|null, result?: protos.google.cloud.oracledatabase.v1.IDatabaseCharacterSet[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDatabaseCharacterSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDatabaseCharacterSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDatabaseCharacterSets with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDatabaseCharacterSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDatabaseCharacterSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listDatabaseCharacterSets = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDatabaseCharacterSets(request), expectedError); - const actualRequest = (client.innerApiCalls.listDatabaseCharacterSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDatabaseCharacterSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listDatabaseCharacterSets with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDatabaseCharacterSetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDatabaseCharacterSetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listDatabaseCharacterSets = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listDatabaseCharacterSets(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listDatabaseCharacterSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDatabaseCharacterSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listDatabaseCharacterSetsStream without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDatabaseCharacterSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDatabaseCharacterSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet()), - ]; - client.descriptors.page.listDatabaseCharacterSets.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listDatabaseCharacterSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listDatabaseCharacterSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDatabaseCharacterSets, request)); - assert( - (client.descriptors.page.listDatabaseCharacterSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listDatabaseCharacterSetsStream without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDatabaseCharacterSetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDatabaseCharacterSetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet(), + ), + ]; + client.descriptors.page.listDatabaseCharacterSets.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listDatabaseCharacterSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listDatabaseCharacterSets + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listDatabaseCharacterSets, request), + ); + assert( + ( + client.descriptors.page.listDatabaseCharacterSets + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listDatabaseCharacterSetsStream with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDatabaseCharacterSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDatabaseCharacterSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listDatabaseCharacterSets.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listDatabaseCharacterSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet[] = []; - stream.on('data', (response: protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listDatabaseCharacterSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDatabaseCharacterSets, request)); - assert( - (client.descriptors.page.listDatabaseCharacterSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listDatabaseCharacterSetsStream with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDatabaseCharacterSetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDatabaseCharacterSetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDatabaseCharacterSets.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listDatabaseCharacterSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listDatabaseCharacterSets + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listDatabaseCharacterSets, request), + ); + assert( + ( + client.descriptors.page.listDatabaseCharacterSets + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('uses async iteration with listDatabaseCharacterSets without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDatabaseCharacterSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDatabaseCharacterSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet()), - generateSampleMessage(new protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet()), - ]; - client.descriptors.page.listDatabaseCharacterSets.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.oracledatabase.v1.IDatabaseCharacterSet[] = []; - const iterable = client.listDatabaseCharacterSetsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listDatabaseCharacterSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDatabaseCharacterSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listDatabaseCharacterSets without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDatabaseCharacterSetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDatabaseCharacterSetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet(), + ), + generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.DatabaseCharacterSet(), + ), + ]; + client.descriptors.page.listDatabaseCharacterSets.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.oracledatabase.v1.IDatabaseCharacterSet[] = + []; + const iterable = client.listDatabaseCharacterSetsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listDatabaseCharacterSets + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listDatabaseCharacterSets + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('uses async iteration with listDatabaseCharacterSets with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oracledatabase.v1.ListDatabaseCharacterSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.oracledatabase.v1.ListDatabaseCharacterSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listDatabaseCharacterSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listDatabaseCharacterSetsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.oracledatabase.v1.IDatabaseCharacterSet[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listDatabaseCharacterSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDatabaseCharacterSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listDatabaseCharacterSets with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oracledatabase.v1.ListDatabaseCharacterSetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oracledatabase.v1.ListDatabaseCharacterSetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDatabaseCharacterSets.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listDatabaseCharacterSetsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.oracledatabase.v1.IDatabaseCharacterSet[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listDatabaseCharacterSets + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listDatabaseCharacterSets + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes getLocation without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes getLocation with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('uses async iteration with listLocations with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('autonomousDatabase', async () => { + const fakePath = '/rendered/path/autonomousDatabase'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + autonomous_database: 'autonomousDatabaseValue', + }; + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.autonomousDatabasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.autonomousDatabasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('autonomousDatabasePath', () => { + const result = client.autonomousDatabasePath( + 'projectValue', + 'locationValue', + 'autonomousDatabaseValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.autonomousDatabasePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromAutonomousDatabaseName', () => { + const result = client.matchProjectFromAutonomousDatabaseName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.autonomousDatabasePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromAutonomousDatabaseName', () => { + const result = client.matchLocationFromAutonomousDatabaseName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.autonomousDatabasePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAutonomousDatabaseFromAutonomousDatabaseName', () => { + const result = + client.matchAutonomousDatabaseFromAutonomousDatabaseName(fakePath); + assert.strictEqual(result, 'autonomousDatabaseValue'); + assert( + ( + client.pathTemplates.autonomousDatabasePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('autonomousDatabase', async () => { - const fakePath = "/rendered/path/autonomousDatabase"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - autonomous_database: "autonomousDatabaseValue", - }; - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.autonomousDatabasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.autonomousDatabasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('autonomousDatabasePath', () => { - const result = client.autonomousDatabasePath("projectValue", "locationValue", "autonomousDatabaseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.autonomousDatabasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAutonomousDatabaseName', () => { - const result = client.matchProjectFromAutonomousDatabaseName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.autonomousDatabasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAutonomousDatabaseName', () => { - const result = client.matchLocationFromAutonomousDatabaseName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.autonomousDatabasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAutonomousDatabaseFromAutonomousDatabaseName', () => { - const result = client.matchAutonomousDatabaseFromAutonomousDatabaseName(fakePath); - assert.strictEqual(result, "autonomousDatabaseValue"); - assert((client.pathTemplates.autonomousDatabasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('autonomousDatabaseBackup', async () => { - const fakePath = "/rendered/path/autonomousDatabaseBackup"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - autonomous_database_backup: "autonomousDatabaseBackupValue", - }; - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.autonomousDatabaseBackupPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.autonomousDatabaseBackupPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('autonomousDatabaseBackupPath', () => { - const result = client.autonomousDatabaseBackupPath("projectValue", "locationValue", "autonomousDatabaseBackupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.autonomousDatabaseBackupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAutonomousDatabaseBackupName', () => { - const result = client.matchProjectFromAutonomousDatabaseBackupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.autonomousDatabaseBackupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAutonomousDatabaseBackupName', () => { - const result = client.matchLocationFromAutonomousDatabaseBackupName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.autonomousDatabaseBackupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAutonomousDatabaseBackupFromAutonomousDatabaseBackupName', () => { - const result = client.matchAutonomousDatabaseBackupFromAutonomousDatabaseBackupName(fakePath); - assert.strictEqual(result, "autonomousDatabaseBackupValue"); - assert((client.pathTemplates.autonomousDatabaseBackupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('autonomousDatabaseBackup', async () => { + const fakePath = '/rendered/path/autonomousDatabaseBackup'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + autonomous_database_backup: 'autonomousDatabaseBackupValue', + }; + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.autonomousDatabaseBackupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.autonomousDatabaseBackupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('autonomousDatabaseBackupPath', () => { + const result = client.autonomousDatabaseBackupPath( + 'projectValue', + 'locationValue', + 'autonomousDatabaseBackupValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.autonomousDatabaseBackupPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromAutonomousDatabaseBackupName', () => { + const result = + client.matchProjectFromAutonomousDatabaseBackupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.autonomousDatabaseBackupPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromAutonomousDatabaseBackupName', () => { + const result = + client.matchLocationFromAutonomousDatabaseBackupName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.autonomousDatabaseBackupPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAutonomousDatabaseBackupFromAutonomousDatabaseBackupName', () => { + const result = + client.matchAutonomousDatabaseBackupFromAutonomousDatabaseBackupName( + fakePath, + ); + assert.strictEqual(result, 'autonomousDatabaseBackupValue'); + assert( + ( + client.pathTemplates.autonomousDatabaseBackupPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('autonomousDatabaseCharacterSet', async () => { - const fakePath = "/rendered/path/autonomousDatabaseCharacterSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - autonomous_database_character_set: "autonomousDatabaseCharacterSetValue", - }; - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.autonomousDatabaseCharacterSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.autonomousDatabaseCharacterSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('autonomousDatabaseCharacterSetPath', () => { - const result = client.autonomousDatabaseCharacterSetPath("projectValue", "locationValue", "autonomousDatabaseCharacterSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.autonomousDatabaseCharacterSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAutonomousDatabaseCharacterSetName', () => { - const result = client.matchProjectFromAutonomousDatabaseCharacterSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.autonomousDatabaseCharacterSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAutonomousDatabaseCharacterSetName', () => { - const result = client.matchLocationFromAutonomousDatabaseCharacterSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.autonomousDatabaseCharacterSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAutonomousDatabaseCharacterSetFromAutonomousDatabaseCharacterSetName', () => { - const result = client.matchAutonomousDatabaseCharacterSetFromAutonomousDatabaseCharacterSetName(fakePath); - assert.strictEqual(result, "autonomousDatabaseCharacterSetValue"); - assert((client.pathTemplates.autonomousDatabaseCharacterSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('autonomousDatabaseCharacterSet', async () => { + const fakePath = '/rendered/path/autonomousDatabaseCharacterSet'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + autonomous_database_character_set: + 'autonomousDatabaseCharacterSetValue', + }; + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.autonomousDatabaseCharacterSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.autonomousDatabaseCharacterSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('autonomousDatabaseCharacterSetPath', () => { + const result = client.autonomousDatabaseCharacterSetPath( + 'projectValue', + 'locationValue', + 'autonomousDatabaseCharacterSetValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.autonomousDatabaseCharacterSetPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromAutonomousDatabaseCharacterSetName', () => { + const result = + client.matchProjectFromAutonomousDatabaseCharacterSetName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.autonomousDatabaseCharacterSetPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromAutonomousDatabaseCharacterSetName', () => { + const result = + client.matchLocationFromAutonomousDatabaseCharacterSetName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.autonomousDatabaseCharacterSetPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAutonomousDatabaseCharacterSetFromAutonomousDatabaseCharacterSetName', () => { + const result = + client.matchAutonomousDatabaseCharacterSetFromAutonomousDatabaseCharacterSetName( + fakePath, + ); + assert.strictEqual(result, 'autonomousDatabaseCharacterSetValue'); + assert( + ( + client.pathTemplates.autonomousDatabaseCharacterSetPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('autonomousDbVersion', async () => { - const fakePath = "/rendered/path/autonomousDbVersion"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - autonomous_db_version: "autonomousDbVersionValue", - }; - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.autonomousDbVersionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.autonomousDbVersionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('autonomousDbVersionPath', () => { - const result = client.autonomousDbVersionPath("projectValue", "locationValue", "autonomousDbVersionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.autonomousDbVersionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAutonomousDbVersionName', () => { - const result = client.matchProjectFromAutonomousDbVersionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.autonomousDbVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAutonomousDbVersionName', () => { - const result = client.matchLocationFromAutonomousDbVersionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.autonomousDbVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAutonomousDbVersionFromAutonomousDbVersionName', () => { - const result = client.matchAutonomousDbVersionFromAutonomousDbVersionName(fakePath); - assert.strictEqual(result, "autonomousDbVersionValue"); - assert((client.pathTemplates.autonomousDbVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('autonomousDbVersion', async () => { + const fakePath = '/rendered/path/autonomousDbVersion'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + autonomous_db_version: 'autonomousDbVersionValue', + }; + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.autonomousDbVersionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.autonomousDbVersionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('autonomousDbVersionPath', () => { + const result = client.autonomousDbVersionPath( + 'projectValue', + 'locationValue', + 'autonomousDbVersionValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.autonomousDbVersionPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromAutonomousDbVersionName', () => { + const result = client.matchProjectFromAutonomousDbVersionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.autonomousDbVersionPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromAutonomousDbVersionName', () => { + const result = + client.matchLocationFromAutonomousDbVersionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.autonomousDbVersionPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAutonomousDbVersionFromAutonomousDbVersionName', () => { + const result = + client.matchAutonomousDbVersionFromAutonomousDbVersionName(fakePath); + assert.strictEqual(result, 'autonomousDbVersionValue'); + assert( + ( + client.pathTemplates.autonomousDbVersionPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('cloudExadataInfrastructure', async () => { - const fakePath = "/rendered/path/cloudExadataInfrastructure"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - cloud_exadata_infrastructure: "cloudExadataInfrastructureValue", - }; - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.cloudExadataInfrastructurePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.cloudExadataInfrastructurePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('cloudExadataInfrastructurePath', () => { - const result = client.cloudExadataInfrastructurePath("projectValue", "locationValue", "cloudExadataInfrastructureValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.cloudExadataInfrastructurePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCloudExadataInfrastructureName', () => { - const result = client.matchProjectFromCloudExadataInfrastructureName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.cloudExadataInfrastructurePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCloudExadataInfrastructureName', () => { - const result = client.matchLocationFromCloudExadataInfrastructureName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.cloudExadataInfrastructurePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCloudExadataInfrastructureFromCloudExadataInfrastructureName', () => { - const result = client.matchCloudExadataInfrastructureFromCloudExadataInfrastructureName(fakePath); - assert.strictEqual(result, "cloudExadataInfrastructureValue"); - assert((client.pathTemplates.cloudExadataInfrastructurePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('cloudExadataInfrastructure', async () => { + const fakePath = '/rendered/path/cloudExadataInfrastructure'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + cloud_exadata_infrastructure: 'cloudExadataInfrastructureValue', + }; + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.cloudExadataInfrastructurePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.cloudExadataInfrastructurePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('cloudExadataInfrastructurePath', () => { + const result = client.cloudExadataInfrastructurePath( + 'projectValue', + 'locationValue', + 'cloudExadataInfrastructureValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.cloudExadataInfrastructurePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromCloudExadataInfrastructureName', () => { + const result = + client.matchProjectFromCloudExadataInfrastructureName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.cloudExadataInfrastructurePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromCloudExadataInfrastructureName', () => { + const result = + client.matchLocationFromCloudExadataInfrastructureName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.cloudExadataInfrastructurePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCloudExadataInfrastructureFromCloudExadataInfrastructureName', () => { + const result = + client.matchCloudExadataInfrastructureFromCloudExadataInfrastructureName( + fakePath, + ); + assert.strictEqual(result, 'cloudExadataInfrastructureValue'); + assert( + ( + client.pathTemplates.cloudExadataInfrastructurePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('cloudVmCluster', async () => { - const fakePath = "/rendered/path/cloudVmCluster"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - cloud_vm_cluster: "cloudVmClusterValue", - }; - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.cloudVmClusterPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.cloudVmClusterPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('cloudVmClusterPath', () => { - const result = client.cloudVmClusterPath("projectValue", "locationValue", "cloudVmClusterValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.cloudVmClusterPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCloudVmClusterName', () => { - const result = client.matchProjectFromCloudVmClusterName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.cloudVmClusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCloudVmClusterName', () => { - const result = client.matchLocationFromCloudVmClusterName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.cloudVmClusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCloudVmClusterFromCloudVmClusterName', () => { - const result = client.matchCloudVmClusterFromCloudVmClusterName(fakePath); - assert.strictEqual(result, "cloudVmClusterValue"); - assert((client.pathTemplates.cloudVmClusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('cloudVmCluster', async () => { + const fakePath = '/rendered/path/cloudVmCluster'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + cloud_vm_cluster: 'cloudVmClusterValue', + }; + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.cloudVmClusterPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.cloudVmClusterPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('cloudVmClusterPath', () => { + const result = client.cloudVmClusterPath( + 'projectValue', + 'locationValue', + 'cloudVmClusterValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.cloudVmClusterPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromCloudVmClusterName', () => { + const result = client.matchProjectFromCloudVmClusterName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.cloudVmClusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromCloudVmClusterName', () => { + const result = client.matchLocationFromCloudVmClusterName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.cloudVmClusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCloudVmClusterFromCloudVmClusterName', () => { + const result = + client.matchCloudVmClusterFromCloudVmClusterName(fakePath); + assert.strictEqual(result, 'cloudVmClusterValue'); + assert( + (client.pathTemplates.cloudVmClusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('database', async () => { - const fakePath = "/rendered/path/database"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - database: "databaseValue", - }; - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.databasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.databasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('databasePath', () => { - const result = client.databasePath("projectValue", "locationValue", "databaseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.databasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDatabaseName', () => { - const result = client.matchProjectFromDatabaseName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.databasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromDatabaseName', () => { - const result = client.matchLocationFromDatabaseName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.databasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDatabaseFromDatabaseName', () => { - const result = client.matchDatabaseFromDatabaseName(fakePath); - assert.strictEqual(result, "databaseValue"); - assert((client.pathTemplates.databasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('database', async () => { + const fakePath = '/rendered/path/database'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + database: 'databaseValue', + }; + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.databasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.databasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('databasePath', () => { + const result = client.databasePath( + 'projectValue', + 'locationValue', + 'databaseValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.databasePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromDatabaseName', () => { + const result = client.matchProjectFromDatabaseName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.databasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromDatabaseName', () => { + const result = client.matchLocationFromDatabaseName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.databasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchDatabaseFromDatabaseName', () => { + const result = client.matchDatabaseFromDatabaseName(fakePath); + assert.strictEqual(result, 'databaseValue'); + assert( + (client.pathTemplates.databasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('databaseCharacterSet', async () => { - const fakePath = "/rendered/path/databaseCharacterSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - database_character_set: "databaseCharacterSetValue", - }; - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.databaseCharacterSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.databaseCharacterSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('databaseCharacterSetPath', () => { - const result = client.databaseCharacterSetPath("projectValue", "locationValue", "databaseCharacterSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.databaseCharacterSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDatabaseCharacterSetName', () => { - const result = client.matchProjectFromDatabaseCharacterSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.databaseCharacterSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromDatabaseCharacterSetName', () => { - const result = client.matchLocationFromDatabaseCharacterSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.databaseCharacterSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDatabaseCharacterSetFromDatabaseCharacterSetName', () => { - const result = client.matchDatabaseCharacterSetFromDatabaseCharacterSetName(fakePath); - assert.strictEqual(result, "databaseCharacterSetValue"); - assert((client.pathTemplates.databaseCharacterSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('databaseCharacterSet', async () => { + const fakePath = '/rendered/path/databaseCharacterSet'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + database_character_set: 'databaseCharacterSetValue', + }; + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.databaseCharacterSetPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.databaseCharacterSetPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('databaseCharacterSetPath', () => { + const result = client.databaseCharacterSetPath( + 'projectValue', + 'locationValue', + 'databaseCharacterSetValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.databaseCharacterSetPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromDatabaseCharacterSetName', () => { + const result = + client.matchProjectFromDatabaseCharacterSetName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.databaseCharacterSetPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromDatabaseCharacterSetName', () => { + const result = + client.matchLocationFromDatabaseCharacterSetName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.databaseCharacterSetPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchDatabaseCharacterSetFromDatabaseCharacterSetName', () => { + const result = + client.matchDatabaseCharacterSetFromDatabaseCharacterSetName( + fakePath, + ); + assert.strictEqual(result, 'databaseCharacterSetValue'); + assert( + ( + client.pathTemplates.databaseCharacterSetPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('dbServer', async () => { - const fakePath = "/rendered/path/dbServer"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - cloud_exadata_infrastructure: "cloudExadataInfrastructureValue", - db_server: "dbServerValue", - }; - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.dbServerPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.dbServerPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('dbServerPath', () => { - const result = client.dbServerPath("projectValue", "locationValue", "cloudExadataInfrastructureValue", "dbServerValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.dbServerPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDbServerName', () => { - const result = client.matchProjectFromDbServerName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.dbServerPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromDbServerName', () => { - const result = client.matchLocationFromDbServerName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.dbServerPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCloudExadataInfrastructureFromDbServerName', () => { - const result = client.matchCloudExadataInfrastructureFromDbServerName(fakePath); - assert.strictEqual(result, "cloudExadataInfrastructureValue"); - assert((client.pathTemplates.dbServerPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDbServerFromDbServerName', () => { - const result = client.matchDbServerFromDbServerName(fakePath); - assert.strictEqual(result, "dbServerValue"); - assert((client.pathTemplates.dbServerPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('dbServer', async () => { + const fakePath = '/rendered/path/dbServer'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + cloud_exadata_infrastructure: 'cloudExadataInfrastructureValue', + db_server: 'dbServerValue', + }; + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.dbServerPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.dbServerPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('dbServerPath', () => { + const result = client.dbServerPath( + 'projectValue', + 'locationValue', + 'cloudExadataInfrastructureValue', + 'dbServerValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.dbServerPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromDbServerName', () => { + const result = client.matchProjectFromDbServerName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.dbServerPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromDbServerName', () => { + const result = client.matchLocationFromDbServerName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.dbServerPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCloudExadataInfrastructureFromDbServerName', () => { + const result = + client.matchCloudExadataInfrastructureFromDbServerName(fakePath); + assert.strictEqual(result, 'cloudExadataInfrastructureValue'); + assert( + (client.pathTemplates.dbServerPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchDbServerFromDbServerName', () => { + const result = client.matchDbServerFromDbServerName(fakePath); + assert.strictEqual(result, 'dbServerValue'); + assert( + (client.pathTemplates.dbServerPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('dbSystem', async () => { - const fakePath = "/rendered/path/dbSystem"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - db_system: "dbSystemValue", - }; - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.dbSystemPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.dbSystemPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('dbSystemPath', () => { - const result = client.dbSystemPath("projectValue", "locationValue", "dbSystemValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.dbSystemPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDbSystemName', () => { - const result = client.matchProjectFromDbSystemName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.dbSystemPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromDbSystemName', () => { - const result = client.matchLocationFromDbSystemName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.dbSystemPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDbSystemFromDbSystemName', () => { - const result = client.matchDbSystemFromDbSystemName(fakePath); - assert.strictEqual(result, "dbSystemValue"); - assert((client.pathTemplates.dbSystemPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('dbSystem', async () => { + const fakePath = '/rendered/path/dbSystem'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + db_system: 'dbSystemValue', + }; + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.dbSystemPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.dbSystemPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('dbSystemPath', () => { + const result = client.dbSystemPath( + 'projectValue', + 'locationValue', + 'dbSystemValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.dbSystemPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromDbSystemName', () => { + const result = client.matchProjectFromDbSystemName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.dbSystemPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromDbSystemName', () => { + const result = client.matchLocationFromDbSystemName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.dbSystemPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchDbSystemFromDbSystemName', () => { + const result = client.matchDbSystemFromDbSystemName(fakePath); + assert.strictEqual(result, 'dbSystemValue'); + assert( + (client.pathTemplates.dbSystemPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('dbSystemInitialStorageSize', async () => { - const fakePath = "/rendered/path/dbSystemInitialStorageSize"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - db_system_initial_storage_size: "dbSystemInitialStorageSizeValue", - }; - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.dbSystemInitialStorageSizePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.dbSystemInitialStorageSizePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('dbSystemInitialStorageSizePath', () => { - const result = client.dbSystemInitialStorageSizePath("projectValue", "locationValue", "dbSystemInitialStorageSizeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.dbSystemInitialStorageSizePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDbSystemInitialStorageSizeName', () => { - const result = client.matchProjectFromDbSystemInitialStorageSizeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.dbSystemInitialStorageSizePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromDbSystemInitialStorageSizeName', () => { - const result = client.matchLocationFromDbSystemInitialStorageSizeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.dbSystemInitialStorageSizePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDbSystemInitialStorageSizeFromDbSystemInitialStorageSizeName', () => { - const result = client.matchDbSystemInitialStorageSizeFromDbSystemInitialStorageSizeName(fakePath); - assert.strictEqual(result, "dbSystemInitialStorageSizeValue"); - assert((client.pathTemplates.dbSystemInitialStorageSizePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('dbSystemInitialStorageSize', async () => { + const fakePath = '/rendered/path/dbSystemInitialStorageSize'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + db_system_initial_storage_size: 'dbSystemInitialStorageSizeValue', + }; + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.dbSystemInitialStorageSizePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.dbSystemInitialStorageSizePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('dbSystemInitialStorageSizePath', () => { + const result = client.dbSystemInitialStorageSizePath( + 'projectValue', + 'locationValue', + 'dbSystemInitialStorageSizeValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.dbSystemInitialStorageSizePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromDbSystemInitialStorageSizeName', () => { + const result = + client.matchProjectFromDbSystemInitialStorageSizeName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.dbSystemInitialStorageSizePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromDbSystemInitialStorageSizeName', () => { + const result = + client.matchLocationFromDbSystemInitialStorageSizeName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.dbSystemInitialStorageSizePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchDbSystemInitialStorageSizeFromDbSystemInitialStorageSizeName', () => { + const result = + client.matchDbSystemInitialStorageSizeFromDbSystemInitialStorageSizeName( + fakePath, + ); + assert.strictEqual(result, 'dbSystemInitialStorageSizeValue'); + assert( + ( + client.pathTemplates.dbSystemInitialStorageSizePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('dbSystemShape', async () => { - const fakePath = "/rendered/path/dbSystemShape"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - db_system_shape: "dbSystemShapeValue", - }; - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.dbSystemShapePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.dbSystemShapePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('dbSystemShapePath', () => { - const result = client.dbSystemShapePath("projectValue", "locationValue", "dbSystemShapeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.dbSystemShapePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDbSystemShapeName', () => { - const result = client.matchProjectFromDbSystemShapeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.dbSystemShapePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromDbSystemShapeName', () => { - const result = client.matchLocationFromDbSystemShapeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.dbSystemShapePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDbSystemShapeFromDbSystemShapeName', () => { - const result = client.matchDbSystemShapeFromDbSystemShapeName(fakePath); - assert.strictEqual(result, "dbSystemShapeValue"); - assert((client.pathTemplates.dbSystemShapePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('dbSystemShape', async () => { + const fakePath = '/rendered/path/dbSystemShape'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + db_system_shape: 'dbSystemShapeValue', + }; + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.dbSystemShapePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.dbSystemShapePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('dbSystemShapePath', () => { + const result = client.dbSystemShapePath( + 'projectValue', + 'locationValue', + 'dbSystemShapeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.dbSystemShapePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromDbSystemShapeName', () => { + const result = client.matchProjectFromDbSystemShapeName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.dbSystemShapePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromDbSystemShapeName', () => { + const result = client.matchLocationFromDbSystemShapeName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.dbSystemShapePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchDbSystemShapeFromDbSystemShapeName', () => { + const result = client.matchDbSystemShapeFromDbSystemShapeName(fakePath); + assert.strictEqual(result, 'dbSystemShapeValue'); + assert( + (client.pathTemplates.dbSystemShapePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('dbVersion', async () => { - const fakePath = "/rendered/path/dbVersion"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - db_version: "dbVersionValue", - }; - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.dbVersionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.dbVersionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('dbVersionPath', () => { - const result = client.dbVersionPath("projectValue", "locationValue", "dbVersionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.dbVersionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDbVersionName', () => { - const result = client.matchProjectFromDbVersionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.dbVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromDbVersionName', () => { - const result = client.matchLocationFromDbVersionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.dbVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDbVersionFromDbVersionName', () => { - const result = client.matchDbVersionFromDbVersionName(fakePath); - assert.strictEqual(result, "dbVersionValue"); - assert((client.pathTemplates.dbVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('dbVersion', async () => { + const fakePath = '/rendered/path/dbVersion'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + db_version: 'dbVersionValue', + }; + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.dbVersionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.dbVersionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('dbVersionPath', () => { + const result = client.dbVersionPath( + 'projectValue', + 'locationValue', + 'dbVersionValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.dbVersionPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromDbVersionName', () => { + const result = client.matchProjectFromDbVersionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.dbVersionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromDbVersionName', () => { + const result = client.matchLocationFromDbVersionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.dbVersionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchDbVersionFromDbVersionName', () => { + const result = client.matchDbVersionFromDbVersionName(fakePath); + assert.strictEqual(result, 'dbVersionValue'); + assert( + (client.pathTemplates.dbVersionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('entitlement', async () => { - const fakePath = "/rendered/path/entitlement"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - entitlement: "entitlementValue", - }; - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.entitlementPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.entitlementPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('entitlementPath', () => { - const result = client.entitlementPath("projectValue", "locationValue", "entitlementValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.entitlementPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromEntitlementName', () => { - const result = client.matchProjectFromEntitlementName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.entitlementPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromEntitlementName', () => { - const result = client.matchLocationFromEntitlementName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.entitlementPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEntitlementFromEntitlementName', () => { - const result = client.matchEntitlementFromEntitlementName(fakePath); - assert.strictEqual(result, "entitlementValue"); - assert((client.pathTemplates.entitlementPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('entitlement', async () => { + const fakePath = '/rendered/path/entitlement'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + entitlement: 'entitlementValue', + }; + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.entitlementPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.entitlementPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('entitlementPath', () => { + const result = client.entitlementPath( + 'projectValue', + 'locationValue', + 'entitlementValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.entitlementPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromEntitlementName', () => { + const result = client.matchProjectFromEntitlementName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.entitlementPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromEntitlementName', () => { + const result = client.matchLocationFromEntitlementName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.entitlementPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEntitlementFromEntitlementName', () => { + const result = client.matchEntitlementFromEntitlementName(fakePath); + assert.strictEqual(result, 'entitlementValue'); + assert( + (client.pathTemplates.entitlementPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('exadbVmCluster', async () => { - const fakePath = "/rendered/path/exadbVmCluster"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - exadb_vm_cluster: "exadbVmClusterValue", - }; - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.exadbVmClusterPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.exadbVmClusterPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('exadbVmClusterPath', () => { - const result = client.exadbVmClusterPath("projectValue", "locationValue", "exadbVmClusterValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.exadbVmClusterPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromExadbVmClusterName', () => { - const result = client.matchProjectFromExadbVmClusterName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.exadbVmClusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromExadbVmClusterName', () => { - const result = client.matchLocationFromExadbVmClusterName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.exadbVmClusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchExadbVmClusterFromExadbVmClusterName', () => { - const result = client.matchExadbVmClusterFromExadbVmClusterName(fakePath); - assert.strictEqual(result, "exadbVmClusterValue"); - assert((client.pathTemplates.exadbVmClusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('exadbVmCluster', async () => { + const fakePath = '/rendered/path/exadbVmCluster'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + exadb_vm_cluster: 'exadbVmClusterValue', + }; + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.exadbVmClusterPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.exadbVmClusterPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('exadbVmClusterPath', () => { + const result = client.exadbVmClusterPath( + 'projectValue', + 'locationValue', + 'exadbVmClusterValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.exadbVmClusterPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromExadbVmClusterName', () => { + const result = client.matchProjectFromExadbVmClusterName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.exadbVmClusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromExadbVmClusterName', () => { + const result = client.matchLocationFromExadbVmClusterName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.exadbVmClusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchExadbVmClusterFromExadbVmClusterName', () => { + const result = + client.matchExadbVmClusterFromExadbVmClusterName(fakePath); + assert.strictEqual(result, 'exadbVmClusterValue'); + assert( + (client.pathTemplates.exadbVmClusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('exascaleDbStorageVault', async () => { - const fakePath = "/rendered/path/exascaleDbStorageVault"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - exascale_db_storage_vault: "exascaleDbStorageVaultValue", - }; - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.exascaleDbStorageVaultPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.exascaleDbStorageVaultPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('exascaleDbStorageVaultPath', () => { - const result = client.exascaleDbStorageVaultPath("projectValue", "locationValue", "exascaleDbStorageVaultValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.exascaleDbStorageVaultPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromExascaleDbStorageVaultName', () => { - const result = client.matchProjectFromExascaleDbStorageVaultName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.exascaleDbStorageVaultPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromExascaleDbStorageVaultName', () => { - const result = client.matchLocationFromExascaleDbStorageVaultName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.exascaleDbStorageVaultPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchExascaleDbStorageVaultFromExascaleDbStorageVaultName', () => { - const result = client.matchExascaleDbStorageVaultFromExascaleDbStorageVaultName(fakePath); - assert.strictEqual(result, "exascaleDbStorageVaultValue"); - assert((client.pathTemplates.exascaleDbStorageVaultPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('exascaleDbStorageVault', async () => { + const fakePath = '/rendered/path/exascaleDbStorageVault'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + exascale_db_storage_vault: 'exascaleDbStorageVaultValue', + }; + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.exascaleDbStorageVaultPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.exascaleDbStorageVaultPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('exascaleDbStorageVaultPath', () => { + const result = client.exascaleDbStorageVaultPath( + 'projectValue', + 'locationValue', + 'exascaleDbStorageVaultValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.exascaleDbStorageVaultPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromExascaleDbStorageVaultName', () => { + const result = + client.matchProjectFromExascaleDbStorageVaultName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.exascaleDbStorageVaultPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromExascaleDbStorageVaultName', () => { + const result = + client.matchLocationFromExascaleDbStorageVaultName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.exascaleDbStorageVaultPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchExascaleDbStorageVaultFromExascaleDbStorageVaultName', () => { + const result = + client.matchExascaleDbStorageVaultFromExascaleDbStorageVaultName( + fakePath, + ); + assert.strictEqual(result, 'exascaleDbStorageVaultValue'); + assert( + ( + client.pathTemplates.exascaleDbStorageVaultPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('giVersion', async () => { - const fakePath = "/rendered/path/giVersion"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - gi_version: "giVersionValue", - }; - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.giVersionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.giVersionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('giVersionPath', () => { - const result = client.giVersionPath("projectValue", "locationValue", "giVersionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.giVersionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromGiVersionName', () => { - const result = client.matchProjectFromGiVersionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.giVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromGiVersionName', () => { - const result = client.matchLocationFromGiVersionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.giVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchGiVersionFromGiVersionName', () => { - const result = client.matchGiVersionFromGiVersionName(fakePath); - assert.strictEqual(result, "giVersionValue"); - assert((client.pathTemplates.giVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('giVersion', async () => { + const fakePath = '/rendered/path/giVersion'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + gi_version: 'giVersionValue', + }; + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.giVersionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.giVersionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('giVersionPath', () => { + const result = client.giVersionPath( + 'projectValue', + 'locationValue', + 'giVersionValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.giVersionPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromGiVersionName', () => { + const result = client.matchProjectFromGiVersionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.giVersionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromGiVersionName', () => { + const result = client.matchLocationFromGiVersionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.giVersionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchGiVersionFromGiVersionName', () => { + const result = client.matchGiVersionFromGiVersionName(fakePath); + assert.strictEqual(result, 'giVersionValue'); + assert( + (client.pathTemplates.giVersionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('minorVersion', async () => { - const fakePath = "/rendered/path/minorVersion"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - gi_version: "giVersionValue", - minor_version: "minorVersionValue", - }; - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.minorVersionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.minorVersionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('minorVersionPath', () => { - const result = client.minorVersionPath("projectValue", "locationValue", "giVersionValue", "minorVersionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.minorVersionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMinorVersionName', () => { - const result = client.matchProjectFromMinorVersionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.minorVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMinorVersionName', () => { - const result = client.matchLocationFromMinorVersionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.minorVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchGiVersionFromMinorVersionName', () => { - const result = client.matchGiVersionFromMinorVersionName(fakePath); - assert.strictEqual(result, "giVersionValue"); - assert((client.pathTemplates.minorVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMinorVersionFromMinorVersionName', () => { - const result = client.matchMinorVersionFromMinorVersionName(fakePath); - assert.strictEqual(result, "minorVersionValue"); - assert((client.pathTemplates.minorVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('minorVersion', async () => { + const fakePath = '/rendered/path/minorVersion'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + gi_version: 'giVersionValue', + minor_version: 'minorVersionValue', + }; + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.minorVersionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.minorVersionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('minorVersionPath', () => { + const result = client.minorVersionPath( + 'projectValue', + 'locationValue', + 'giVersionValue', + 'minorVersionValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.minorVersionPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMinorVersionName', () => { + const result = client.matchProjectFromMinorVersionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.minorVersionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMinorVersionName', () => { + const result = client.matchLocationFromMinorVersionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.minorVersionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchGiVersionFromMinorVersionName', () => { + const result = client.matchGiVersionFromMinorVersionName(fakePath); + assert.strictEqual(result, 'giVersionValue'); + assert( + (client.pathTemplates.minorVersionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMinorVersionFromMinorVersionName', () => { + const result = client.matchMinorVersionFromMinorVersionName(fakePath); + assert.strictEqual(result, 'minorVersionValue'); + assert( + (client.pathTemplates.minorVersionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('odbNetwork', async () => { - const fakePath = "/rendered/path/odbNetwork"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - odb_network: "odbNetworkValue", - }; - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.odbNetworkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.odbNetworkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('odbNetworkPath', () => { - const result = client.odbNetworkPath("projectValue", "locationValue", "odbNetworkValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.odbNetworkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromOdbNetworkName', () => { - const result = client.matchProjectFromOdbNetworkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.odbNetworkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromOdbNetworkName', () => { - const result = client.matchLocationFromOdbNetworkName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.odbNetworkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchOdbNetworkFromOdbNetworkName', () => { - const result = client.matchOdbNetworkFromOdbNetworkName(fakePath); - assert.strictEqual(result, "odbNetworkValue"); - assert((client.pathTemplates.odbNetworkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('odbNetwork', async () => { + const fakePath = '/rendered/path/odbNetwork'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + odb_network: 'odbNetworkValue', + }; + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.odbNetworkPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.odbNetworkPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('odbNetworkPath', () => { + const result = client.odbNetworkPath( + 'projectValue', + 'locationValue', + 'odbNetworkValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.odbNetworkPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromOdbNetworkName', () => { + const result = client.matchProjectFromOdbNetworkName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.odbNetworkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromOdbNetworkName', () => { + const result = client.matchLocationFromOdbNetworkName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.odbNetworkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchOdbNetworkFromOdbNetworkName', () => { + const result = client.matchOdbNetworkFromOdbNetworkName(fakePath); + assert.strictEqual(result, 'odbNetworkValue'); + assert( + (client.pathTemplates.odbNetworkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('odbSubnet', async () => { - const fakePath = "/rendered/path/odbSubnet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - odb_network: "odbNetworkValue", - odb_subnet: "odbSubnetValue", - }; - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.odbSubnetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.odbSubnetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('odbSubnetPath', () => { - const result = client.odbSubnetPath("projectValue", "locationValue", "odbNetworkValue", "odbSubnetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.odbSubnetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromOdbSubnetName', () => { - const result = client.matchProjectFromOdbSubnetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.odbSubnetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromOdbSubnetName', () => { - const result = client.matchLocationFromOdbSubnetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.odbSubnetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchOdbNetworkFromOdbSubnetName', () => { - const result = client.matchOdbNetworkFromOdbSubnetName(fakePath); - assert.strictEqual(result, "odbNetworkValue"); - assert((client.pathTemplates.odbSubnetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchOdbSubnetFromOdbSubnetName', () => { - const result = client.matchOdbSubnetFromOdbSubnetName(fakePath); - assert.strictEqual(result, "odbSubnetValue"); - assert((client.pathTemplates.odbSubnetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('odbSubnet', async () => { + const fakePath = '/rendered/path/odbSubnet'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + odb_network: 'odbNetworkValue', + odb_subnet: 'odbSubnetValue', + }; + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.odbSubnetPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.odbSubnetPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('odbSubnetPath', () => { + const result = client.odbSubnetPath( + 'projectValue', + 'locationValue', + 'odbNetworkValue', + 'odbSubnetValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.odbSubnetPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromOdbSubnetName', () => { + const result = client.matchProjectFromOdbSubnetName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.odbSubnetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromOdbSubnetName', () => { + const result = client.matchLocationFromOdbSubnetName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.odbSubnetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchOdbNetworkFromOdbSubnetName', () => { + const result = client.matchOdbNetworkFromOdbSubnetName(fakePath); + assert.strictEqual(result, 'odbNetworkValue'); + assert( + (client.pathTemplates.odbSubnetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchOdbSubnetFromOdbSubnetName', () => { + const result = client.matchOdbSubnetFromOdbSubnetName(fakePath); + assert.strictEqual(result, 'odbSubnetValue'); + assert( + (client.pathTemplates.odbSubnetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('pluggableDatabase', async () => { - const fakePath = "/rendered/path/pluggableDatabase"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - pluggable_database: "pluggableDatabaseValue", - }; - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.pluggableDatabasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.pluggableDatabasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('pluggableDatabasePath', () => { - const result = client.pluggableDatabasePath("projectValue", "locationValue", "pluggableDatabaseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.pluggableDatabasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromPluggableDatabaseName', () => { - const result = client.matchProjectFromPluggableDatabaseName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.pluggableDatabasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromPluggableDatabaseName', () => { - const result = client.matchLocationFromPluggableDatabaseName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.pluggableDatabasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchPluggableDatabaseFromPluggableDatabaseName', () => { - const result = client.matchPluggableDatabaseFromPluggableDatabaseName(fakePath); - assert.strictEqual(result, "pluggableDatabaseValue"); - assert((client.pathTemplates.pluggableDatabasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('pluggableDatabase', async () => { + const fakePath = '/rendered/path/pluggableDatabase'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + pluggable_database: 'pluggableDatabaseValue', + }; + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.pluggableDatabasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.pluggableDatabasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('pluggableDatabasePath', () => { + const result = client.pluggableDatabasePath( + 'projectValue', + 'locationValue', + 'pluggableDatabaseValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.pluggableDatabasePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromPluggableDatabaseName', () => { + const result = client.matchProjectFromPluggableDatabaseName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.pluggableDatabasePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromPluggableDatabaseName', () => { + const result = client.matchLocationFromPluggableDatabaseName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.pluggableDatabasePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchPluggableDatabaseFromPluggableDatabaseName', () => { + const result = + client.matchPluggableDatabaseFromPluggableDatabaseName(fakePath); + assert.strictEqual(result, 'pluggableDatabaseValue'); + assert( + ( + client.pathTemplates.pluggableDatabasePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectLocationCloudVmClusterDbNodes', async () => { - const fakePath = "/rendered/path/projectLocationCloudVmClusterDbNodes"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - cloud_vm_cluster: "cloudVmClusterValue", - db_node: "dbNodeValue", - }; - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectLocationCloudVmClusterDbNodesPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCloudVmClusterDbNodesPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCloudVmClusterDbNodesPath', () => { - const result = client.projectLocationCloudVmClusterDbNodesPath("projectValue", "locationValue", "cloudVmClusterValue", "dbNodeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCloudVmClusterDbNodesPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCloudVmClusterDbNodesName', () => { - const result = client.matchProjectFromProjectLocationCloudVmClusterDbNodesName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCloudVmClusterDbNodesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCloudVmClusterDbNodesName', () => { - const result = client.matchLocationFromProjectLocationCloudVmClusterDbNodesName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCloudVmClusterDbNodesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCloudVmClusterFromProjectLocationCloudVmClusterDbNodesName', () => { - const result = client.matchCloudVmClusterFromProjectLocationCloudVmClusterDbNodesName(fakePath); - assert.strictEqual(result, "cloudVmClusterValue"); - assert((client.pathTemplates.projectLocationCloudVmClusterDbNodesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDbNodeFromProjectLocationCloudVmClusterDbNodesName', () => { - const result = client.matchDbNodeFromProjectLocationCloudVmClusterDbNodesName(fakePath); - assert.strictEqual(result, "dbNodeValue"); - assert((client.pathTemplates.projectLocationCloudVmClusterDbNodesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectLocationCloudVmClusterDbNodes', async () => { + const fakePath = '/rendered/path/projectLocationCloudVmClusterDbNodes'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + cloud_vm_cluster: 'cloudVmClusterValue', + db_node: 'dbNodeValue', + }; + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectLocationCloudVmClusterDbNodesPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCloudVmClusterDbNodesPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCloudVmClusterDbNodesPath', () => { + const result = client.projectLocationCloudVmClusterDbNodesPath( + 'projectValue', + 'locationValue', + 'cloudVmClusterValue', + 'dbNodeValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates + .projectLocationCloudVmClusterDbNodesPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectLocationCloudVmClusterDbNodesName', () => { + const result = + client.matchProjectFromProjectLocationCloudVmClusterDbNodesName( + fakePath, + ); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates + .projectLocationCloudVmClusterDbNodesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromProjectLocationCloudVmClusterDbNodesName', () => { + const result = + client.matchLocationFromProjectLocationCloudVmClusterDbNodesName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates + .projectLocationCloudVmClusterDbNodesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCloudVmClusterFromProjectLocationCloudVmClusterDbNodesName', () => { + const result = + client.matchCloudVmClusterFromProjectLocationCloudVmClusterDbNodesName( + fakePath, + ); + assert.strictEqual(result, 'cloudVmClusterValue'); + assert( + ( + client.pathTemplates + .projectLocationCloudVmClusterDbNodesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchDbNodeFromProjectLocationCloudVmClusterDbNodesName', () => { + const result = + client.matchDbNodeFromProjectLocationCloudVmClusterDbNodesName( + fakePath, + ); + assert.strictEqual(result, 'dbNodeValue'); + assert( + ( + client.pathTemplates + .projectLocationCloudVmClusterDbNodesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectLocationExadbVmClusterDbNodes', async () => { - const fakePath = "/rendered/path/projectLocationExadbVmClusterDbNodes"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - exadb_vm_cluster: "exadbVmClusterValue", - db_node: "dbNodeValue", - }; - const client = new oracledatabaseModule.v1.OracleDatabaseClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectLocationExadbVmClusterDbNodesPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationExadbVmClusterDbNodesPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationExadbVmClusterDbNodesPath', () => { - const result = client.projectLocationExadbVmClusterDbNodesPath("projectValue", "locationValue", "exadbVmClusterValue", "dbNodeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationExadbVmClusterDbNodesPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationExadbVmClusterDbNodesName', () => { - const result = client.matchProjectFromProjectLocationExadbVmClusterDbNodesName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationExadbVmClusterDbNodesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationExadbVmClusterDbNodesName', () => { - const result = client.matchLocationFromProjectLocationExadbVmClusterDbNodesName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationExadbVmClusterDbNodesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchExadbVmClusterFromProjectLocationExadbVmClusterDbNodesName', () => { - const result = client.matchExadbVmClusterFromProjectLocationExadbVmClusterDbNodesName(fakePath); - assert.strictEqual(result, "exadbVmClusterValue"); - assert((client.pathTemplates.projectLocationExadbVmClusterDbNodesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDbNodeFromProjectLocationExadbVmClusterDbNodesName', () => { - const result = client.matchDbNodeFromProjectLocationExadbVmClusterDbNodesName(fakePath); - assert.strictEqual(result, "dbNodeValue"); - assert((client.pathTemplates.projectLocationExadbVmClusterDbNodesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectLocationExadbVmClusterDbNodes', async () => { + const fakePath = '/rendered/path/projectLocationExadbVmClusterDbNodes'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + exadb_vm_cluster: 'exadbVmClusterValue', + db_node: 'dbNodeValue', + }; + const client = new oracledatabaseModule.v1.OracleDatabaseClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectLocationExadbVmClusterDbNodesPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationExadbVmClusterDbNodesPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationExadbVmClusterDbNodesPath', () => { + const result = client.projectLocationExadbVmClusterDbNodesPath( + 'projectValue', + 'locationValue', + 'exadbVmClusterValue', + 'dbNodeValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates + .projectLocationExadbVmClusterDbNodesPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectLocationExadbVmClusterDbNodesName', () => { + const result = + client.matchProjectFromProjectLocationExadbVmClusterDbNodesName( + fakePath, + ); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates + .projectLocationExadbVmClusterDbNodesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromProjectLocationExadbVmClusterDbNodesName', () => { + const result = + client.matchLocationFromProjectLocationExadbVmClusterDbNodesName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates + .projectLocationExadbVmClusterDbNodesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchExadbVmClusterFromProjectLocationExadbVmClusterDbNodesName', () => { + const result = + client.matchExadbVmClusterFromProjectLocationExadbVmClusterDbNodesName( + fakePath, + ); + assert.strictEqual(result, 'exadbVmClusterValue'); + assert( + ( + client.pathTemplates + .projectLocationExadbVmClusterDbNodesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchDbNodeFromProjectLocationExadbVmClusterDbNodesName', () => { + const result = + client.matchDbNodeFromProjectLocationExadbVmClusterDbNodesName( + fakePath, + ); + assert.strictEqual(result, 'dbNodeValue'); + assert( + ( + client.pathTemplates + .projectLocationExadbVmClusterDbNodesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-oracledatabase/webpack.config.js b/packages/google-cloud-oracledatabase/webpack.config.js index e2da9a36088d..6f604f618220 100644 --- a/packages/google-cloud-oracledatabase/webpack.config.js +++ b/packages/google-cloud-oracledatabase/webpack.config.js @@ -1,4 +1,4 @@ -// Copyright 2026 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-orchestration-airflow-service/.eslintignore b/packages/google-cloud-orchestration-airflow-service/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-orchestration-airflow-service/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-orchestration-airflow-service/.eslintrc.json b/packages/google-cloud-orchestration-airflow-service/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-orchestration-airflow-service/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-orchestration-airflow-service/README.md b/packages/google-cloud-orchestration-airflow-service/README.md index d3922fc508d8..18c33c4c2643 100644 --- a/packages/google-cloud-orchestration-airflow-service/README.md +++ b/packages/google-cloud-orchestration-airflow-service/README.md @@ -144,7 +144,7 @@ More Information: [Google Cloud Platform Launch Stages][launch_stages] ## Contributing -Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-orchestration-airflow-service/CONTRIBUTING.md). +Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/CONTRIBUTING.md). Please note that this `README.md` and a variety of configuration files in this repository (including `.nycrc` and `tsconfig.json`) @@ -154,7 +154,7 @@ are generated from a central template. Apache Version 2.0 -See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-orchestration-airflow-service/LICENSE) +See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/LICENSE) [shell_img]: https://gstatic.com/cloudssh/images/open-btn.png [projects]: https://console.cloud.google.com/project diff --git a/packages/google-cloud-orchestration-airflow-service/protos/protos.d.ts b/packages/google-cloud-orchestration-airflow-service/protos/protos.d.ts index 7ad20cea48d0..f9da1dcb3e31 100644 --- a/packages/google-cloud-orchestration-airflow-service/protos/protos.d.ts +++ b/packages/google-cloud-orchestration-airflow-service/protos/protos.d.ts @@ -18427,6 +18427,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -18444,6 +18447,9 @@ export namespace google { /** CommonLanguageSettings destinations. */ public destinations: google.api.ClientLibraryDestination[]; + /** CommonLanguageSettings selectiveGapicGeneration. */ + public selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); + /** * Creates a new CommonLanguageSettings instance using the specified properties. * @param [properties] Properties to set @@ -19144,6 +19150,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -19158,6 +19167,9 @@ export namespace google { /** PythonSettings common. */ public common?: (google.api.ICommonLanguageSettings|null); + /** PythonSettings experimentalFeatures. */ + public experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); + /** * Creates a new PythonSettings instance using the specified properties. * @param [properties] Properties to set @@ -19236,6 +19248,118 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + namespace PythonSettings { + + /** Properties of an ExperimentalFeatures. */ + interface IExperimentalFeatures { + + /** ExperimentalFeatures restAsyncIoEnabled */ + restAsyncIoEnabled?: (boolean|null); + + /** ExperimentalFeatures protobufPythonicTypesEnabled */ + protobufPythonicTypesEnabled?: (boolean|null); + + /** ExperimentalFeatures unversionedPackageDisabled */ + unversionedPackageDisabled?: (boolean|null); + } + + /** Represents an ExperimentalFeatures. */ + class ExperimentalFeatures implements IExperimentalFeatures { + + /** + * Constructs a new ExperimentalFeatures. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.PythonSettings.IExperimentalFeatures); + + /** ExperimentalFeatures restAsyncIoEnabled. */ + public restAsyncIoEnabled: boolean; + + /** ExperimentalFeatures protobufPythonicTypesEnabled. */ + public protobufPythonicTypesEnabled: boolean; + + /** ExperimentalFeatures unversionedPackageDisabled. */ + public unversionedPackageDisabled: boolean; + + /** + * Creates a new ExperimentalFeatures instance using the specified properties. + * @param [properties] Properties to set + * @returns ExperimentalFeatures instance + */ + public static create(properties?: google.api.PythonSettings.IExperimentalFeatures): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Encodes the specified ExperimentalFeatures message. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @param message ExperimentalFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.PythonSettings.IExperimentalFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExperimentalFeatures message, length delimited. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @param message ExperimentalFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.PythonSettings.IExperimentalFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExperimentalFeatures + * @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.api.PythonSettings.ExperimentalFeatures; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExperimentalFeatures + * @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.api.PythonSettings.ExperimentalFeatures; + + /** + * Verifies an ExperimentalFeatures 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 an ExperimentalFeatures message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExperimentalFeatures + */ + public static fromObject(object: { [k: string]: any }): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Creates a plain object from an ExperimentalFeatures message. Also converts values to other types if specified. + * @param message ExperimentalFeatures + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.PythonSettings.ExperimentalFeatures, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExperimentalFeatures to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExperimentalFeatures + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + /** Properties of a NodeSettings. */ interface INodeSettings { @@ -19562,6 +19686,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -19576,6 +19703,9 @@ export namespace google { /** GoSettings common. */ public common?: (google.api.ICommonLanguageSettings|null); + /** GoSettings renamedServices. */ + public renamedServices: { [k: string]: string }; + /** * Creates a new GoSettings instance using the specified properties. * @param [properties] Properties to set @@ -19900,6 +20030,109 @@ export namespace google { PACKAGE_MANAGER = 20 } + /** Properties of a SelectiveGapicGeneration. */ + interface ISelectiveGapicGeneration { + + /** SelectiveGapicGeneration methods */ + methods?: (string[]|null); + + /** SelectiveGapicGeneration generateOmittedAsInternal */ + generateOmittedAsInternal?: (boolean|null); + } + + /** Represents a SelectiveGapicGeneration. */ + class SelectiveGapicGeneration implements ISelectiveGapicGeneration { + + /** + * Constructs a new SelectiveGapicGeneration. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.ISelectiveGapicGeneration); + + /** SelectiveGapicGeneration methods. */ + public methods: string[]; + + /** SelectiveGapicGeneration generateOmittedAsInternal. */ + public generateOmittedAsInternal: boolean; + + /** + * Creates a new SelectiveGapicGeneration instance using the specified properties. + * @param [properties] Properties to set + * @returns SelectiveGapicGeneration instance + */ + public static create(properties?: google.api.ISelectiveGapicGeneration): google.api.SelectiveGapicGeneration; + + /** + * Encodes the specified SelectiveGapicGeneration message. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @param message SelectiveGapicGeneration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.ISelectiveGapicGeneration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SelectiveGapicGeneration message, length delimited. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @param message SelectiveGapicGeneration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.ISelectiveGapicGeneration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SelectiveGapicGeneration + * @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.api.SelectiveGapicGeneration; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SelectiveGapicGeneration + * @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.api.SelectiveGapicGeneration; + + /** + * Verifies a SelectiveGapicGeneration 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 SelectiveGapicGeneration message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SelectiveGapicGeneration + */ + public static fromObject(object: { [k: string]: any }): google.api.SelectiveGapicGeneration; + + /** + * Creates a plain object from a SelectiveGapicGeneration message. Also converts values to other types if specified. + * @param message SelectiveGapicGeneration + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.SelectiveGapicGeneration, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SelectiveGapicGeneration to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SelectiveGapicGeneration + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** LaunchStage enum. */ enum LaunchStage { LAUNCH_STAGE_UNSPECIFIED = 0, @@ -20281,6 +20514,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -20311,6 +20545,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -20360,6 +20597,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -20494,6 +20734,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -20535,6 +20778,9 @@ export namespace google { /** DescriptorProto reservedName. */ public reservedName: string[]; + /** DescriptorProto visibility. */ + public visibility: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility); + /** * Creates a new DescriptorProto instance using the specified properties. * @param [properties] Properties to set @@ -21382,6 +21628,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -21408,6 +21657,9 @@ export namespace google { /** EnumDescriptorProto reservedName. */ public reservedName: string[]; + /** EnumDescriptorProto visibility. */ + public visibility: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility); + /** * Creates a new EnumDescriptorProto instance using the specified properties. * @param [properties] Properties to set @@ -22342,6 +22594,9 @@ export namespace google { /** FieldOptions features */ features?: (google.protobuf.IFeatureSet|null); + /** FieldOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** FieldOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); @@ -22397,6 +22652,9 @@ export namespace google { /** FieldOptions features. */ public features?: (google.protobuf.IFeatureSet|null); + /** FieldOptions featureSupport. */ + public featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** FieldOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; @@ -22617,6 +22875,121 @@ export namespace google { */ public static getTypeUrl(typeUrlPrefix?: string): string; } + + /** Properties of a FeatureSupport. */ + interface IFeatureSupport { + + /** FeatureSupport editionIntroduced */ + editionIntroduced?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSupport editionDeprecated */ + editionDeprecated?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSupport deprecationWarning */ + deprecationWarning?: (string|null); + + /** FeatureSupport editionRemoved */ + editionRemoved?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + } + + /** Represents a FeatureSupport. */ + class FeatureSupport implements IFeatureSupport { + + /** + * Constructs a new FeatureSupport. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.FieldOptions.IFeatureSupport); + + /** FeatureSupport editionIntroduced. */ + public editionIntroduced: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSupport editionDeprecated. */ + public editionDeprecated: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSupport deprecationWarning. */ + public deprecationWarning: string; + + /** FeatureSupport editionRemoved. */ + public editionRemoved: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** + * Creates a new FeatureSupport instance using the specified properties. + * @param [properties] Properties to set + * @returns FeatureSupport instance + */ + public static create(properties?: google.protobuf.FieldOptions.IFeatureSupport): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Encodes the specified FeatureSupport message. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @param message FeatureSupport message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.FieldOptions.IFeatureSupport, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FeatureSupport message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @param message FeatureSupport message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.FieldOptions.IFeatureSupport, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FeatureSupport + * @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.protobuf.FieldOptions.FeatureSupport; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FeatureSupport + * @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.protobuf.FieldOptions.FeatureSupport; + + /** + * Verifies a FeatureSupport 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 FeatureSupport message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FeatureSupport + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Creates a plain object from a FeatureSupport message. Also converts values to other types if specified. + * @param message FeatureSupport + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldOptions.FeatureSupport, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FeatureSupport to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FeatureSupport + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } } /** Properties of an OneofOptions. */ @@ -22855,6 +23228,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -22877,6 +23253,9 @@ export namespace google { /** EnumValueOptions debugRedact. */ public debugRedact: boolean; + /** EnumValueOptions featureSupport. */ + public featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; @@ -23469,6 +23848,12 @@ export namespace google { /** FeatureSet jsonFormat */ jsonFormat?: (google.protobuf.FeatureSet.JsonFormat|keyof typeof google.protobuf.FeatureSet.JsonFormat|null); + + /** FeatureSet enforceNamingStyle */ + enforceNamingStyle?: (google.protobuf.FeatureSet.EnforceNamingStyle|keyof typeof google.protobuf.FeatureSet.EnforceNamingStyle|null); + + /** FeatureSet defaultSymbolVisibility */ + defaultSymbolVisibility?: (google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|keyof typeof google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|null); } /** Represents a FeatureSet. */ @@ -23498,6 +23883,12 @@ export namespace google { /** FeatureSet jsonFormat. */ public jsonFormat: (google.protobuf.FeatureSet.JsonFormat|keyof typeof google.protobuf.FeatureSet.JsonFormat); + /** FeatureSet enforceNamingStyle. */ + public enforceNamingStyle: (google.protobuf.FeatureSet.EnforceNamingStyle|keyof typeof google.protobuf.FeatureSet.EnforceNamingStyle); + + /** FeatureSet defaultSymbolVisibility. */ + public defaultSymbolVisibility: (google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|keyof typeof google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility); + /** * Creates a new FeatureSet instance using the specified properties. * @param [properties] Properties to set @@ -23620,6 +24011,116 @@ export namespace google { ALLOW = 1, LEGACY_BEST_EFFORT = 2 } + + /** EnforceNamingStyle enum. */ + enum EnforceNamingStyle { + ENFORCE_NAMING_STYLE_UNKNOWN = 0, + STYLE2024 = 1, + STYLE_LEGACY = 2 + } + + /** Properties of a VisibilityFeature. */ + interface IVisibilityFeature { + } + + /** Represents a VisibilityFeature. */ + class VisibilityFeature implements IVisibilityFeature { + + /** + * Constructs a new VisibilityFeature. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.FeatureSet.IVisibilityFeature); + + /** + * Creates a new VisibilityFeature instance using the specified properties. + * @param [properties] Properties to set + * @returns VisibilityFeature instance + */ + public static create(properties?: google.protobuf.FeatureSet.IVisibilityFeature): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Encodes the specified VisibilityFeature message. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @param message VisibilityFeature message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.FeatureSet.IVisibilityFeature, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified VisibilityFeature message, length delimited. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @param message VisibilityFeature message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.FeatureSet.IVisibilityFeature, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns VisibilityFeature + * @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.protobuf.FeatureSet.VisibilityFeature; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns VisibilityFeature + * @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.protobuf.FeatureSet.VisibilityFeature; + + /** + * Verifies a VisibilityFeature 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 VisibilityFeature message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns VisibilityFeature + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Creates a plain object from a VisibilityFeature message. Also converts values to other types if specified. + * @param message VisibilityFeature + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FeatureSet.VisibilityFeature, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this VisibilityFeature to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for VisibilityFeature + * @param {"code":"deadline_exceeded","msg":"operation timed out"}